Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
74fc3875
Commit
74fc3875
authored
Jan 05, 2019
by
季圣华
Browse files
增加供应商的导入功能
parent
2b7a7bbd
Changes
6
Hide whitespace changes
Inline
Side-by-side
erp_web/pages/manage/customer.html
View file @
74fc3875
...
...
@@ -160,7 +160,7 @@
<!-- 导入excel表格 -->
<div
id=
"importExcelDlg"
style=
"padding:10px 20px"
>
<form
id=
"importExcelFM"
method=
"post"
enctype=
"multipart/form-data"
action=
"/supplier/importExcelCustomer
.action
"
>
action=
"/supplier/importExcelCustomer"
>
<div
class=
"fitem"
style=
"padding:5px"
>
<label>
文件名称
</label>
<input
name=
"supplierFile"
id=
"supplierFile"
type=
"file"
style=
"width: 230px;height: 20px"
/>
...
...
@@ -175,7 +175,6 @@
<option
value=
"1"
selected=
"selected"
>
否
</option>
</select>
</div>
<input
type=
"hidden"
name=
"clientIp"
id=
"clientIp"
value=
"<%=clientIp %>"
/>
<div
id=
"dlg-buttons5"
>
<a
href=
"javascript:void(0)"
id=
"saveimport"
class=
"easyui-linkbutton"
iconCls=
"icon-ok"
>
导入
</a>
<a
href=
"javascript:void(0)"
id=
"cancelimport"
class=
"easyui-linkbutton"
iconCls=
"icon-cancel"
...
...
erp_web/pages/manage/member.html
View file @
74fc3875
...
...
@@ -160,7 +160,7 @@
<!-- 导入excel表格 -->
<div
id=
"importExcelDlg"
style=
"padding:10px 20px"
>
<form
id=
"importExcelFM"
method=
"post"
enctype=
"multipart/form-data"
action=
"/supplier/importExcelMember
.action
"
>
action=
"/supplier/importExcelMember"
>
<div
class=
"fitem"
style=
"padding:5px"
>
<label>
文件名称
</label>
<input
name=
"supplierFile"
id=
"supplierFile"
type=
"file"
style=
"width: 230px;height: 20px"
/>
...
...
@@ -175,7 +175,6 @@
<option
value=
"1"
selected=
"selected"
>
否
</option>
</select>
</div>
<input
type=
"hidden"
name=
"clientIp"
id=
"clientIp"
value=
"<%=clientIp %>"
/>
<div
id=
"dlg-buttons5"
>
<a
href=
"javascript:void(0)"
id=
"saveimport"
class=
"easyui-linkbutton"
iconCls=
"icon-ok"
>
导入
</a>
<a
href=
"javascript:void(0)"
id=
"cancelimport"
class=
"easyui-linkbutton"
iconCls=
"icon-cancel"
...
...
erp_web/pages/manage/vendor.html
View file @
74fc3875
...
...
@@ -160,7 +160,7 @@
<!-- 导入excel表格 -->
<div
id=
"importExcelDlg"
style=
"padding:10px 20px"
>
<form
id=
"importExcelFM"
method=
"post"
enctype=
"multipart/form-data"
action=
"/supplier/importExcelVendor
.action
"
>
action=
"/supplier/importExcelVendor"
>
<div
class=
"fitem"
style=
"padding:5px"
>
<label>
文件名称
</label>
<input
name=
"supplierFile"
id=
"supplierFile"
type=
"file"
style=
"width: 230px;height: 20px"
/>
...
...
@@ -175,7 +175,6 @@
<option
value=
"1"
selected=
"selected"
>
否
</option>
</select>
</div>
<input
type=
"hidden"
name=
"clientIp"
id=
"clientIp"
value=
"<%=clientIp %>"
/>
<div
id=
"dlg-buttons5"
>
<a
href=
"javascript:void(0)"
id=
"saveimport"
class=
"easyui-linkbutton"
iconCls=
"icon-ok"
>
导入
</a>
<a
href=
"javascript:void(0)"
id=
"cancelimport"
class=
"easyui-linkbutton"
iconCls=
"icon-cancel"
...
...
src/main/java/com/jsh/erp/controller/SupplierController.java
View file @
74fc3875
...
...
@@ -5,14 +5,14 @@ import com.alibaba.fastjson.JSONObject;
import
com.jsh.erp.datasource.entities.Supplier
;
import
com.jsh.erp.service.supplier.SupplierService
;
import
com.jsh.erp.service.userBusiness.UserBusinessService
;
import
com.jsh.erp.utils.BaseResponseInfo
;
import
com.jsh.erp.utils.ErpInfo
;
import
com.jsh.erp.utils.ExcelUtils
;
import
com.jsh.erp.utils.ExportExecUtil
;
import
com.jsh.erp.utils.*
;
import
jxl.Sheet
;
import
jxl.Workbook
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.dao.DataAccessException
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -327,4 +327,108 @@ public class SupplierController {
}
return
res
;
}
/**
* 导入excel表格-供应商
* @param supplierFile
* @param request
* @param response
* @return
*/
@PostMapping
(
value
=
"/importExcelVendor"
)
public
void
importExcelVendor
(
MultipartFile
supplierFile
,
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
{
importFun
(
supplierFile
);
response
.
sendRedirect
(
"../pages/manage/vendor.html"
);
}
/**
* 导入excel表格-客户
* @param supplierFile
* @param request
* @param response
* @return
*/
@PostMapping
(
value
=
"/importExcelCustomer"
)
public
void
importExcelCustomer
(
MultipartFile
supplierFile
,
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
{
importFun
(
supplierFile
);
response
.
sendRedirect
(
"../pages/manage/customer.html"
);
}
/**
* 导入excel表格-会员
* @param supplierFile
* @param request
* @param response
* @return
*/
@PostMapping
(
value
=
"/importExcelMember"
)
public
void
importExcelMember
(
MultipartFile
supplierFile
,
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
{
importFun
(
supplierFile
);
response
.
sendRedirect
(
"../pages/manage/member.html"
);
}
public
String
importFun
(
MultipartFile
supplierFile
){
BaseResponseInfo
info
=
new
BaseResponseInfo
();
Map
<
String
,
Object
>
data
=
new
HashMap
<
String
,
Object
>();
String
message
=
"成功"
;
try
{
Sheet
src
=
null
;
//文件合法性校验
try
{
Workbook
workbook
=
Workbook
.
getWorkbook
(
supplierFile
.
getInputStream
());
src
=
workbook
.
getSheet
(
0
);
}
catch
(
Exception
e
)
{
message
=
"导入文件不合法,请检查"
;
data
.
put
(
"message"
,
message
);
info
.
code
=
400
;
info
.
data
=
data
;
}
//读取所有的摄像机编码
//每行中数据顺序 "名称","类型","联系人","电话","电子邮箱","预收款","期初应收","期初应付","备注","传真","手机","地址","纳税人识别号","开户行","账号","税率","状态"
List
<
Supplier
>
sList
=
new
ArrayList
<
Supplier
>();
for
(
int
i
=
1
;
i
<
src
.
getRows
();
i
++)
{
Supplier
s
=
new
Supplier
();
s
.
setSupplier
(
ExcelUtils
.
getContent
(
src
,
i
,
0
));
s
.
setType
(
ExcelUtils
.
getContent
(
src
,
i
,
1
));
s
.
setContacts
(
ExcelUtils
.
getContent
(
src
,
i
,
2
));
s
.
setPhonenum
(
ExcelUtils
.
getContent
(
src
,
i
,
3
));
s
.
setEmail
(
ExcelUtils
.
getContent
(
src
,
i
,
4
));
s
.
setAdvancein
(
parseDoubleEx
(
ExcelUtils
.
getContent
(
src
,
i
,
5
)));
s
.
setBeginneedget
(
parseDoubleEx
(
ExcelUtils
.
getContent
(
src
,
i
,
6
)));
s
.
setBeginneedpay
(
parseDoubleEx
(
ExcelUtils
.
getContent
(
src
,
i
,
7
)));
s
.
setDescription
(
ExcelUtils
.
getContent
(
src
,
i
,
8
));
s
.
setFax
(
ExcelUtils
.
getContent
(
src
,
i
,
9
));
s
.
setTelephone
(
ExcelUtils
.
getContent
(
src
,
i
,
10
));
s
.
setAddress
(
ExcelUtils
.
getContent
(
src
,
i
,
11
));
s
.
setTaxnum
(
ExcelUtils
.
getContent
(
src
,
i
,
12
));
s
.
setBankname
(
ExcelUtils
.
getContent
(
src
,
i
,
13
));
s
.
setAccountnumber
(
ExcelUtils
.
getContent
(
src
,
i
,
14
));
s
.
setTaxrate
(
parseDoubleEx
(
ExcelUtils
.
getContent
(
src
,
i
,
15
)));
String
enabled
=
ExcelUtils
.
getContent
(
src
,
i
,
16
);
s
.
setIsystem
(
Byte
.
parseByte
(
"1"
));
s
.
setEnabled
(
enabled
.
equals
(
"启用"
)?
true
:
false
);
sList
.
add
(
s
);
}
info
=
supplierService
.
importExcel
(
sList
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
message
=
"导入失败"
;
info
.
code
=
500
;
data
.
put
(
"message"
,
message
);
info
.
data
=
data
;
}
return
null
;
}
public
Double
parseDoubleEx
(
String
str
){
if
(!
StringUtil
.
isEmpty
(
str
))
{
return
Double
.
parseDouble
(
str
);
}
else
{
return
null
;
}
}
}
src/main/java/com/jsh/erp/service/material/MaterialService.java
View file @
74fc3875
...
...
@@ -184,6 +184,5 @@ public class MaterialService {
}
info
.
data
=
data
;
return
info
;
}
}
src/main/java/com/jsh/erp/service/supplier/SupplierService.java
View file @
74fc3875
...
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.jsh.erp.datasource.entities.Supplier
;
import
com.jsh.erp.datasource.entities.SupplierExample
;
import
com.jsh.erp.datasource.mappers.SupplierMapper
;
import
com.jsh.erp.utils.BaseResponseInfo
;
import
com.jsh.erp.utils.StringUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -11,7 +12,9 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Service
public
class
SupplierService
{
...
...
@@ -120,4 +123,22 @@ public class SupplierService {
public
List
<
Supplier
>
findByAll
(
String
supplier
,
String
type
,
String
phonenum
,
String
telephone
,
String
description
)
{
return
supplierMapper
.
findByAll
(
supplier
,
type
,
phonenum
,
telephone
,
description
);
}
public
BaseResponseInfo
importExcel
(
List
<
Supplier
>
mList
)
throws
Exception
{
BaseResponseInfo
info
=
new
BaseResponseInfo
();
Map
<
String
,
Object
>
data
=
new
HashMap
<
String
,
Object
>();
try
{
for
(
Supplier
s:
mList
)
{
supplierMapper
.
insertSelective
(
s
);
}
info
.
code
=
200
;
data
.
put
(
"message"
,
"成功"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
info
.
code
=
500
;
data
.
put
(
"message"
,
e
.
getMessage
());
}
info
.
data
=
data
;
return
info
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment