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
693a7558
Commit
693a7558
authored
Jan 15, 2019
by
cjl
Browse files
从jsh远程仓库更新
(cherry picked from commit
36139e26
)
parent
1e1e5f6e
Changes
39
Hide whitespace changes
Inline
Side-by-side
erp_web/pages/reports/vendor_account.html
View file @
693a7558
...
@@ -343,8 +343,7 @@
...
@@ -343,8 +343,7 @@
//报表打印
//报表打印
function
print
()
{
function
print
()
{
$
(
"
#printBtn
"
).
off
(
"
click
"
).
on
(
"
click
"
,
function
()
{
$
(
"
#printBtn
"
).
off
(
"
click
"
).
on
(
"
click
"
,
function
()
{
var
path
=
"
<%=path %>
"
;
CreateFormPage
(
'
打印报表
'
,
$
(
'
#tableData
'
));
CreateFormPage
(
'
打印报表
'
,
$
(
'
#tableData
'
),
path
);
});
});
}
}
</script>
</script>
...
...
pom.xml
View file @
693a7558
...
@@ -42,7 +42,7 @@
...
@@ -42,7 +42,7 @@
<properties>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<java.version>
1.
7
</java.version>
<java.version>
1.
8
</java.version>
</properties>
</properties>
<dependencies>
<dependencies>
...
@@ -96,6 +96,11 @@
...
@@ -96,6 +96,11 @@
<artifactId>
commons-httpclient
</artifactId>
<artifactId>
commons-httpclient
</artifactId>
<version>
3.1
</version>
<version>
3.1
</version>
</dependency>
</dependency>
<dependency>
<groupId>
net.sourceforge.jexcelapi
</groupId>
<artifactId>
jxl
</artifactId>
<version>
2.6.3
</version>
</dependency>
</dependencies>
</dependencies>
<repositories>
<repositories>
...
@@ -174,9 +179,10 @@
...
@@ -174,9 +179,10 @@
<plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
3.7.0
</version>
<configuration>
<configuration>
<source>
1.
7
</source>
<source>
1.
8
</source>
<target>
1.
7
</target>
<target>
1.
8
</target>
</configuration>
</configuration>
</plugin>
</plugin>
</plugins>
</plugins>
...
...
src/main/conf/start.sh
0 → 100644
View file @
693a7558
nohup
./jshERPStart.sh &
\ No newline at end of file
src/main/java/com/jsh/erp/controller/AppController.java
View file @
693a7558
...
@@ -5,13 +5,18 @@ import com.alibaba.fastjson.JSONObject;
...
@@ -5,13 +5,18 @@ import com.alibaba.fastjson.JSONObject;
import
com.jsh.erp.datasource.entities.App
;
import
com.jsh.erp.datasource.entities.App
;
import
com.jsh.erp.service.app.AppService
;
import
com.jsh.erp.service.app.AppService
;
import
com.jsh.erp.service.userBusiness.UserBusinessService
;
import
com.jsh.erp.service.userBusiness.UserBusinessService
;
import
com.jsh.erp.utils.BaseResponseInfo
;
import
com.jsh.erp.utils.FileUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.*
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Properties
;
/**
/**
* @author ji_sheng_hua 752*718*920
* @author ji_sheng_hua 752*718*920
...
@@ -26,14 +31,7 @@ public class AppController {
...
@@ -26,14 +31,7 @@ public class AppController {
@Resource
@Resource
private
UserBusinessService
userBusinessService
;
private
UserBusinessService
userBusinessService
;
/**
* create by: cjl
* description:
* 桌面菜单按钮初始化
* create time: 2019/1/11 17:01
* @Param: request
* @return com.alibaba.fastjson.JSONObject
*/
@GetMapping
(
value
=
"/findDesk"
)
@GetMapping
(
value
=
"/findDesk"
)
public
JSONObject
findDesk
(
HttpServletRequest
request
)
{
public
JSONObject
findDesk
(
HttpServletRequest
request
)
{
JSONObject
obj
=
new
JSONObject
();
JSONObject
obj
=
new
JSONObject
();
...
@@ -123,4 +121,38 @@ public class AppController {
...
@@ -123,4 +121,38 @@ public class AppController {
}
}
return
arr
;
return
arr
;
}
}
/**
* 上传图片
* @param fileInfo
* @param request
*/
@PostMapping
(
value
=
"/uploadImg"
)
public
BaseResponseInfo
uploadImg
(
MultipartFile
fileInfo
,
@RequestParam
(
"fileInfoName"
)
String
fileName
,
HttpServletRequest
request
)
{
BaseResponseInfo
res
=
new
BaseResponseInfo
();
try
{
if
(
fileInfo
!=
null
)
{
String
basePath
=
request
.
getSession
().
getServletContext
().
getRealPath
(
"/"
);
//默认windows文件路径,linux环境下生成的目录与项目同级,而不是下级
String
path
=
basePath
+
"upload/images/deskIcon/"
;
//windows环境下的路径
Properties
pro
=
System
.
getProperties
();
String
osName
=
pro
.
getProperty
(
"os.name"
);
//获得当前操作系统的名称
if
(
"Linux"
.
equals
(
osName
)
||
"linux"
.
equals
(
osName
)
||
"LINUX"
.
equals
(
osName
)){
path
=
basePath
+
"/upload/images/deskIcon/"
;
//linux环境下的路径
}
FileUtils
.
SaveFileFromInputStream
(
fileInfo
.
getInputStream
(),
path
,
fileName
);
res
.
code
=
200
;
res
.
data
=
"上传图片成功"
;
}
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
res
.
code
=
500
;
res
.
data
=
"获取图片失败"
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
res
.
code
=
500
;
res
.
data
=
"上传图片失败"
;
}
return
res
;
}
}
}
src/main/java/com/jsh/erp/controller/DepotItemController.java
View file @
693a7558
...
@@ -9,11 +9,12 @@ import com.jsh.erp.utils.*;
...
@@ -9,11 +9,12 @@ import com.jsh.erp.utils.*;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.dao.DataAccessException
;
import
org.springframework.dao.DataAccessException
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
...
@@ -32,7 +33,8 @@ public class DepotItemController {
...
@@ -32,7 +33,8 @@ public class DepotItemController {
@Resource
@Resource
private
DepotItemService
depotItemService
;
private
DepotItemService
depotItemService
;
@Resource
private
MaterialService
materialService
;
/**
/**
* 根据材料信息获取
* 根据材料信息获取
...
@@ -267,7 +269,26 @@ public class DepotItemController {
...
@@ -267,7 +269,26 @@ public class DepotItemController {
}
}
}
}
/**
* 查询计量单位信息
*
* @return
*/
public
String
findUnitName
(
Long
mId
)
{
String
unitName
=
""
;
try
{
unitName
=
materialService
.
findUnitName
(
mId
);
if
(
unitName
!=
null
)
{
unitName
=
unitName
.
substring
(
1
,
unitName
.
length
()
-
1
);
if
(
unitName
.
equals
(
"null"
))
{
unitName
=
""
;
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
unitName
;
}
@GetMapping
(
value
=
"/getDetailList"
)
@GetMapping
(
value
=
"/getDetailList"
)
public
BaseResponseInfo
getDetailList
(
@RequestParam
(
"headerId"
)
Long
headerId
,
public
BaseResponseInfo
getDetailList
(
@RequestParam
(
"headerId"
)
Long
headerId
,
...
@@ -403,14 +424,12 @@ public class DepotItemController {
...
@@ -403,14 +424,12 @@ public class DepotItemController {
if
(
null
!=
dataList
)
{
if
(
null
!=
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
JSONObject
item
=
new
JSONObject
();
JSONObject
item
=
new
JSONObject
();
Double
prevSum
=
sumNumber
(
"入库"
,
pid
,
diEx
.
getMaterialid
(),
monthTime
,
true
)
-
sumNumber
(
"出库"
,
pid
,
diEx
.
getMaterialid
(),
monthTime
,
true
);
Double
prevSum
=
sumNumber
(
"入库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
true
)
-
sumNumber
(
"出库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
true
);
Double
InSum
=
sumNumber
(
"入库"
,
pid
,
diEx
.
getMaterialid
(),
monthTime
,
false
);
Double
InSum
=
sumNumber
(
"入库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
false
);
Double
OutSum
=
sumNumber
(
"出库"
,
pid
,
diEx
.
getMaterialid
(),
monthTime
,
false
);
Double
OutSum
=
sumNumber
(
"出库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
false
);
Double
prevPrice
=
sumPrice
(
"入库"
,
pid
,
diEx
.
getMaterialid
(),
monthTime
,
true
)
-
sumPrice
(
"出库"
,
pid
,
diEx
.
getMaterialid
(),
monthTime
,
true
);
Double
prevPrice
=
sumPrice
(
"入库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
true
)
-
sumPrice
(
"出库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
true
);
Double
InPrice
=
sumPrice
(
"入库"
,
pid
,
diEx
.
getMaterialid
(),
monthTime
,
false
);
Double
InPrice
=
sumPrice
(
"入库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
false
);
Double
OutPrice
=
sumPrice
(
"出库"
,
pid
,
diEx
.
getMaterialid
(),
monthTime
,
false
);
Double
OutPrice
=
sumPrice
(
"出库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
false
);
item
.
put
(
"Id"
,
diEx
.
getId
());
item
.
put
(
"MaterialId"
,
diEx
.
getMaterialid
());
item
.
put
(
"MaterialName"
,
diEx
.
getMName
());
item
.
put
(
"MaterialName"
,
diEx
.
getMName
());
item
.
put
(
"MaterialModel"
,
diEx
.
getMColor
());
item
.
put
(
"MaterialModel"
,
diEx
.
getMColor
());
//扩展信息
//扩展信息
...
@@ -464,9 +483,9 @@ public class DepotItemController {
...
@@ -464,9 +483,9 @@ public class DepotItemController {
Double
thisAllPrice
=
0.0
;
Double
thisAllPrice
=
0.0
;
if
(
null
!=
dataList
)
{
if
(
null
!=
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
Double
prevPrice
=
sumPrice
(
"入库"
,
pid
,
diEx
.
getM
ateriali
d
(),
monthTime
,
true
)
-
sumPrice
(
"出库"
,
pid
,
diEx
.
getM
ateriali
d
(),
monthTime
,
true
);
Double
prevPrice
=
sumPrice
(
"入库"
,
pid
,
diEx
.
getM
I
d
(),
monthTime
,
true
)
-
sumPrice
(
"出库"
,
pid
,
diEx
.
getM
I
d
(),
monthTime
,
true
);
Double
InPrice
=
sumPrice
(
"入库"
,
pid
,
diEx
.
getM
ateriali
d
(),
monthTime
,
false
);
Double
InPrice
=
sumPrice
(
"入库"
,
pid
,
diEx
.
getM
I
d
(),
monthTime
,
false
);
Double
OutPrice
=
sumPrice
(
"出库"
,
pid
,
diEx
.
getM
ateriali
d
(),
monthTime
,
false
);
Double
OutPrice
=
sumPrice
(
"出库"
,
pid
,
diEx
.
getM
I
d
(),
monthTime
,
false
);
thisAllPrice
=
thisAllPrice
+
(
prevPrice
+
InPrice
-
OutPrice
);
thisAllPrice
=
thisAllPrice
+
(
prevPrice
+
InPrice
-
OutPrice
);
}
}
}
}
...
@@ -512,12 +531,10 @@ public class DepotItemController {
...
@@ -512,12 +531,10 @@ public class DepotItemController {
if
(
null
!=
dataList
)
{
if
(
null
!=
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
JSONObject
item
=
new
JSONObject
();
JSONObject
item
=
new
JSONObject
();
Double
InSum
=
sumNumberBuyOrSale
(
"入库"
,
"采购"
,
diEx
.
getMaterialid
(),
monthTime
);
Double
InSum
=
sumNumberBuyOrSale
(
"入库"
,
"采购"
,
diEx
.
getMId
(),
monthTime
);
Double
OutSum
=
sumNumberBuyOrSale
(
"出库"
,
"采购退货"
,
diEx
.
getMaterialid
(),
monthTime
);
Double
OutSum
=
sumNumberBuyOrSale
(
"出库"
,
"采购退货"
,
diEx
.
getMId
(),
monthTime
);
Double
InSumPrice
=
sumPriceBuyOrSale
(
"入库"
,
"采购"
,
diEx
.
getMaterialid
(),
monthTime
);
Double
InSumPrice
=
sumPriceBuyOrSale
(
"入库"
,
"采购"
,
diEx
.
getMId
(),
monthTime
);
Double
OutSumPrice
=
sumPriceBuyOrSale
(
"出库"
,
"采购退货"
,
diEx
.
getMaterialid
(),
monthTime
);
Double
OutSumPrice
=
sumPriceBuyOrSale
(
"出库"
,
"采购退货"
,
diEx
.
getMId
(),
monthTime
);
item
.
put
(
"Id"
,
diEx
.
getId
());
item
.
put
(
"MaterialId"
,
diEx
.
getMaterialid
());
item
.
put
(
"MaterialName"
,
diEx
.
getMName
());
item
.
put
(
"MaterialName"
,
diEx
.
getMName
());
item
.
put
(
"MaterialModel"
,
diEx
.
getMModel
());
item
.
put
(
"MaterialModel"
,
diEx
.
getMModel
());
//扩展信息
//扩展信息
...
@@ -574,16 +591,14 @@ public class DepotItemController {
...
@@ -574,16 +591,14 @@ public class DepotItemController {
if
(
null
!=
dataList
)
{
if
(
null
!=
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
JSONObject
item
=
new
JSONObject
();
JSONObject
item
=
new
JSONObject
();
Double
OutSumRetail
=
sumNumberBuyOrSale
(
"出库"
,
"零售"
,
diEx
.
getMaterialid
(),
monthTime
);
Double
OutSumRetail
=
sumNumberBuyOrSale
(
"出库"
,
"零售"
,
diEx
.
getMId
(),
monthTime
);
Double
OutSum
=
sumNumberBuyOrSale
(
"出库"
,
"销售"
,
diEx
.
getMaterialid
(),
monthTime
);
Double
OutSum
=
sumNumberBuyOrSale
(
"出库"
,
"销售"
,
diEx
.
getMId
(),
monthTime
);
Double
InSumRetail
=
sumNumberBuyOrSale
(
"入库"
,
"零售退货"
,
diEx
.
getMaterialid
(),
monthTime
);
Double
InSumRetail
=
sumNumberBuyOrSale
(
"入库"
,
"零售退货"
,
diEx
.
getMId
(),
monthTime
);
Double
InSum
=
sumNumberBuyOrSale
(
"入库"
,
"销售退货"
,
diEx
.
getMaterialid
(),
monthTime
);
Double
InSum
=
sumNumberBuyOrSale
(
"入库"
,
"销售退货"
,
diEx
.
getMId
(),
monthTime
);
Double
OutSumRetailPrice
=
sumPriceBuyOrSale
(
"出库"
,
"零售"
,
diEx
.
getMaterialid
(),
monthTime
);
Double
OutSumRetailPrice
=
sumPriceBuyOrSale
(
"出库"
,
"零售"
,
diEx
.
getMId
(),
monthTime
);
Double
OutSumPrice
=
sumPriceBuyOrSale
(
"出库"
,
"销售"
,
diEx
.
getMaterialid
(),
monthTime
);
Double
OutSumPrice
=
sumPriceBuyOrSale
(
"出库"
,
"销售"
,
diEx
.
getMId
(),
monthTime
);
Double
InSumRetailPrice
=
sumPriceBuyOrSale
(
"入库"
,
"零售退货"
,
diEx
.
getMaterialid
(),
monthTime
);
Double
InSumRetailPrice
=
sumPriceBuyOrSale
(
"入库"
,
"零售退货"
,
diEx
.
getMId
(),
monthTime
);
Double
InSumPrice
=
sumPriceBuyOrSale
(
"入库"
,
"销售退货"
,
diEx
.
getMaterialid
(),
monthTime
);
Double
InSumPrice
=
sumPriceBuyOrSale
(
"入库"
,
"销售退货"
,
diEx
.
getMId
(),
monthTime
);
item
.
put
(
"Id"
,
diEx
.
getId
());
item
.
put
(
"MaterialId"
,
diEx
.
getMaterialid
());
item
.
put
(
"MaterialName"
,
diEx
.
getMName
());
item
.
put
(
"MaterialName"
,
diEx
.
getMName
());
item
.
put
(
"MaterialModel"
,
diEx
.
getMModel
());
item
.
put
(
"MaterialModel"
,
diEx
.
getMModel
());
//扩展信息
//扩展信息
...
@@ -640,10 +655,8 @@ public class DepotItemController {
...
@@ -640,10 +655,8 @@ public class DepotItemController {
if
(
null
!=
dataList
)
{
if
(
null
!=
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
JSONObject
item
=
new
JSONObject
();
JSONObject
item
=
new
JSONObject
();
Double
InSum
=
sumNumberGift
(
"礼品充值"
,
pid
,
diEx
.
getMaterialid
(),
"in"
);
Double
InSum
=
sumNumberGift
(
"礼品充值"
,
pid
,
diEx
.
getMId
(),
"in"
);
Double
OutSum
=
sumNumberGift
(
"礼品销售"
,
pid
,
diEx
.
getMaterialid
(),
"out"
);
Double
OutSum
=
sumNumberGift
(
"礼品销售"
,
pid
,
diEx
.
getMId
(),
"out"
);
item
.
put
(
"Id"
,
diEx
.
getId
());
item
.
put
(
"MaterialId"
,
diEx
.
getMaterialid
());
item
.
put
(
"MaterialName"
,
diEx
.
getMName
());
item
.
put
(
"MaterialName"
,
diEx
.
getMName
());
item
.
put
(
"MaterialModel"
,
diEx
.
getMModel
());
item
.
put
(
"MaterialModel"
,
diEx
.
getMModel
());
//扩展信息
//扩展信息
...
@@ -666,6 +679,77 @@ public class DepotItemController {
...
@@ -666,6 +679,77 @@ public class DepotItemController {
return
res
;
return
res
;
}
}
/**
* 导出excel表格
* @param currentPage
* @param pageSize
* @param projectId
* @param monthTime
* @param headIds
* @param materialIds
* @param request
* @param response
* @return
*/
@GetMapping
(
value
=
"/exportExcel"
)
public
BaseResponseInfo
exportExcel
(
@RequestParam
(
"currentPage"
)
Integer
currentPage
,
@RequestParam
(
"pageSize"
)
Integer
pageSize
,
@RequestParam
(
"projectId"
)
Integer
projectId
,
@RequestParam
(
"monthTime"
)
String
monthTime
,
@RequestParam
(
"headIds"
)
String
headIds
,
@RequestParam
(
"materialIds"
)
String
materialIds
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
BaseResponseInfo
res
=
new
BaseResponseInfo
();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
String
message
=
"成功"
;
try
{
List
<
DepotItemVo4WithInfoEx
>
dataList
=
depotItemService
.
findByAll
(
headIds
,
materialIds
,
currentPage
,
pageSize
);
//存放数据json数组
Integer
pid
=
projectId
;
String
[]
names
=
{
"名称"
,
"型号"
,
"单位"
,
"单价"
,
"上月结存数量"
,
"入库数量"
,
"出库数量"
,
"本月结存数量"
,
"结存金额"
};
String
title
=
"库存报表"
;
List
<
String
[]>
objects
=
new
ArrayList
<
String
[]>();
if
(
null
!=
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
String
[]
objs
=
new
String
[
9
];
Double
prevSum
=
sumNumber
(
"入库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
true
)
-
sumNumber
(
"出库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
true
);
Double
InSum
=
sumNumber
(
"入库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
false
);
Double
OutSum
=
sumNumber
(
"出库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
false
);
Double
prevPrice
=
sumPrice
(
"入库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
true
)
-
sumPrice
(
"出库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
true
);
Double
InPrice
=
sumPrice
(
"入库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
false
);
Double
OutPrice
=
sumPrice
(
"出库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
false
);
Double
unitPrice
=
0.0
;
if
(
prevSum
+
InSum
-
OutSum
!=
0.0
)
{
unitPrice
=
(
prevPrice
+
InPrice
-
OutPrice
)
/
(
prevSum
+
InSum
-
OutSum
);
}
Double
thisSum
=
prevSum
+
InSum
-
OutSum
;
Double
thisAllPrice
=
prevPrice
+
InPrice
-
OutPrice
;
objs
[
0
]
=
diEx
.
getMName
().
toString
();
objs
[
1
]
=
diEx
.
getMModel
().
toString
();
objs
[
2
]
=
diEx
.
getMaterialUnit
().
toString
();
objs
[
3
]
=
unitPrice
.
toString
();
objs
[
4
]
=
prevSum
.
toString
();
objs
[
5
]
=
InSum
.
toString
();
objs
[
6
]
=
OutSum
.
toString
();
objs
[
7
]
=
thisSum
.
toString
();
objs
[
8
]
=
thisAllPrice
.
toString
();
objects
.
add
(
objs
);
}
}
File
file
=
ExcelUtils
.
exportObjectsWithoutTitle
(
title
,
names
,
title
,
objects
);
ExportExecUtil
.
showExec
(
file
,
file
.
getName
()
+
"-"
+
monthTime
,
response
);
res
.
code
=
200
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
message
=
"导出失败"
;
res
.
code
=
500
;
}
finally
{
map
.
put
(
"message"
,
message
);
res
.
data
=
map
;
}
return
res
;
}
/**
/**
* 数量合计
* 数量合计
*
*
...
...
src/main/java/com/jsh/erp/controller/MaterialController.java
View file @
693a7558
package
com.jsh.erp.controller
;
package
com.jsh.erp.controller
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONArray
;
import
com.jsh.erp.datasource.entities.Material
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.datasource.entities.MaterialVo4Unit
;
import
com.jsh.erp.datasource.entities.Material
;
import
com.jsh.erp.service.material.MaterialService
;
import
com.jsh.erp.datasource.entities.MaterialVo4Unit
;
import
com.jsh.erp.utils.BaseResponseInfo
;
import
com.jsh.erp.service.material.MaterialService
;
import
com.jsh.erp.utils.ErpInfo
;
import
com.jsh.erp.utils.*
;
import
org.slf4j.Logger
;
import
jxl.Sheet
;
import
org.slf4j.LoggerFactory
;
import
jxl.Workbook
;
import
org.springframework.web.bind.annotation.*
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.annotation.Resource
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.HashMap
;
import
java.util.List
;
import
javax.annotation.Resource
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
static
com
.
jsh
.
erp
.
utils
.
ResponseJsonUtil
.
returnJson
;
import
java.io.File
;
import
java.util.ArrayList
;
/**
import
java.util.HashMap
;
* @author ji|sheng|hua 华夏ERP
import
java.util.List
;
*/
import
java.util.Map
;
@RestController
@RequestMapping
(
value
=
"/material"
)
import
static
com
.
jsh
.
erp
.
utils
.
ResponseJsonUtil
.
returnJson
;
public
class
MaterialController
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
MaterialController
.
class
);
/**
* @author ji|sheng|hua 华夏ERP
@Resource
*/
private
MaterialService
materialService
;
@RestController
@RequestMapping
(
value
=
"/material"
)
@GetMapping
(
value
=
"/checkIsExist"
)
public
class
MaterialController
{
public
String
checkIsExist
(
@RequestParam
(
"id"
)
Long
id
,
@RequestParam
(
"name"
)
String
name
,
private
Logger
logger
=
LoggerFactory
.
getLogger
(
MaterialController
.
class
);
@RequestParam
(
"model"
)
String
model
,
@RequestParam
(
"color"
)
String
color
,
@RequestParam
(
"standard"
)
String
standard
,
@RequestParam
(
"mfrs"
)
String
mfrs
,
@Resource
@RequestParam
(
"otherField1"
)
String
otherField1
,
@RequestParam
(
"otherField2"
)
String
otherField2
,
private
MaterialService
materialService
;
@RequestParam
(
"otherField3"
)
String
otherField3
,
@RequestParam
(
"unit"
)
String
unit
,
@RequestParam
(
"unitId"
)
Long
unitId
,
HttpServletRequest
request
)
{
@GetMapping
(
value
=
"/checkIsExist"
)
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<
String
,
Object
>();
public
String
checkIsExist
(
@RequestParam
(
"id"
)
Long
id
,
@RequestParam
(
"name"
)
String
name
,
int
exist
=
materialService
.
checkIsExist
(
id
,
name
,
model
,
color
,
standard
,
mfrs
,
@RequestParam
(
"model"
)
String
model
,
@RequestParam
(
"color"
)
String
color
,
otherField1
,
otherField2
,
otherField3
,
unit
,
unitId
);
@RequestParam
(
"standard"
)
String
standard
,
@RequestParam
(
"mfrs"
)
String
mfrs
,
if
(
exist
>
0
)
{
@RequestParam
(
"otherField1"
)
String
otherField1
,
@RequestParam
(
"otherField2"
)
String
otherField2
,
objectMap
.
put
(
"status"
,
true
);
@RequestParam
(
"otherField3"
)
String
otherField3
,
@RequestParam
(
"unit"
)
String
unit
,
@RequestParam
(
"unitId"
)
Long
unitId
,
}
else
{
HttpServletRequest
request
)
{
objectMap
.
put
(
"status"
,
false
);
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<
String
,
Object
>();
}
int
exist
=
materialService
.
checkIsExist
(
id
,
name
,
model
,
color
,
standard
,
mfrs
,
return
returnJson
(
objectMap
,
ErpInfo
.
OK
.
name
,
ErpInfo
.
OK
.
code
);
otherField1
,
otherField2
,
otherField3
,
unit
,
unitId
);
}
if
(
exist
>
0
)
{
objectMap
.
put
(
"status"
,
true
);
/**
}
else
{
* 批量设置状态-启用或者禁用
objectMap
.
put
(
"status"
,
false
);
* @param enabled
}
* @param materialIDs
return
returnJson
(
objectMap
,
ErpInfo
.
OK
.
name
,
ErpInfo
.
OK
.
code
);
* @param request
}
* @return
*/
/**
@PostMapping
(
value
=
"/batchSetEnable"
)
* 批量设置状态-启用或者禁用
public
String
batchSetEnable
(
@RequestParam
(
"enabled"
)
Boolean
enabled
,
* @param enabled
@RequestParam
(
"materialIDs"
)
String
materialIDs
,
* @param materialIDs
HttpServletRequest
request
)
{
* @param request
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<
String
,
Object
>();
* @return
int
res
=
materialService
.
batchSetEnable
(
enabled
,
materialIDs
);
*/
if
(
res
>
0
)
{
@PostMapping
(
value
=
"/batchSetEnable"
)
return
returnJson
(
objectMap
,
ErpInfo
.
OK
.
name
,
ErpInfo
.
OK
.
code
);
public
String
batchSetEnable
(
@RequestParam
(
"enabled"
)
Boolean
enabled
,
}
else
{
@RequestParam
(
"materialIDs"
)
String
materialIDs
,
return
returnJson
(
objectMap
,
ErpInfo
.
ERROR
.
name
,
ErpInfo
.
ERROR
.
code
);
HttpServletRequest
request
)
{
}
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<
String
,
Object
>();
}
int
res
=
materialService
.
batchSetEnable
(
enabled
,
materialIDs
);
if
(
res
>
0
)
{
/**
return
returnJson
(
objectMap
,
ErpInfo
.
OK
.
name
,
ErpInfo
.
OK
.
code
);
* 根据id来查询商品名称
}
else
{
* @param id
return
returnJson
(
objectMap
,
ErpInfo
.
ERROR
.
name
,
ErpInfo
.
ERROR
.
code
);
* @param request
}
* @return
}
*/
@GetMapping
(
value
=
"/findById"
)
/**
public
BaseResponseInfo
findById
(
@RequestParam
(
"id"
)
Long
id
,
HttpServletRequest
request
)
{
* 根据id来查询商品名称
BaseResponseInfo
res
=
new
BaseResponseInfo
();
* @param id
try
{
* @param request
List
<
MaterialVo4Unit
>
list
=
materialService
.
findById
(
id
);
* @return
res
.
code
=
200
;
*/
res
.
data
=
list
;
@GetMapping
(
value
=
"/findById"
)
}
catch
(
Exception
e
){
public
BaseResponseInfo
findById
(
@RequestParam
(
"id"
)
Long
id
,
HttpServletRequest
request
)
{
e
.
printStackTrace
();
BaseResponseInfo
res
=
new
BaseResponseInfo
();
res
.
code
=
500
;
try
{
res
.
data
=
"获取数据失败"
;
List
<
MaterialVo4Unit
>
list
=
materialService
.
findById
(
id
);
}
res
.
code
=
200
;
return
res
;
res
.
data
=
list
;
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
/**
res
.
code
=
500
;
* 查找商品信息-下拉框
res
.
data
=
"获取数据失败"
;
* @param mpList
}
* @param request
return
res
;
* @return
}
*/
@GetMapping
(
value
=
"/findBySelect"
)
/**
public
JSONArray
findBySelect
(
@RequestParam
(
"mpList"
)
String
mpList
,
HttpServletRequest
request
)
{
* 查找商品信息-下拉框
JSONArray
dataArray
=
new
JSONArray
();
* @param mpList
try
{
* @param request
List
<
MaterialVo4Unit
>
dataList
=
materialService
.
findBySelect
();
* @return
String
[]
mpArr
=
mpList
.
split
(
","
);
*/
//存放数据json数组
@GetMapping
(
value
=
"/findBySelect"
)
if
(
null
!=
dataList
)
{
public
JSONArray
findBySelect
(
@RequestParam
(
"mpList"
)
String
mpList
,
HttpServletRequest
request
)
{
for
(
MaterialVo4Unit
material
:
dataList
)
{
JSONArray
dataArray
=
new
JSONArray
();
JSONObject
item
=
new
JSONObject
();
try
{
item
.
put
(
"Id"
,
material
.
getId
());
List
<
MaterialVo4Unit
>
dataList
=
materialService
.
findBySelect
();
String
ratio
;
//比例
String
[]
mpArr
=
mpList
.
split
(
","
);
if
(
material
.
getUnitid
()
==
null
||
material
.
getUnitid
().
equals
(
""
))
{
//存放数据json数组
ratio
=
""
;
if
(
null
!=
dataList
)
{
}
else
{
for
(
MaterialVo4Unit
material
:
dataList
)
{
ratio
=
material
.
getUnitName
();
JSONObject
item
=
new
JSONObject
();
ratio
=
ratio
.
substring
(
ratio
.
indexOf
(
"("
));
item
.
put
(
"Id"
,
material
.
getId
());
}
String
ratio
;
//比例
//品名/型号/扩展信息/包装
if
(
material
.
getUnitid
()
==
null
||
material
.
getUnitid
().
equals
(
""
))
{
String
MaterialName
=
material
.
getName
()
+
((
material
.
getModel
()
==
null
||
material
.
getModel
().
equals
(
""
))
?
""
:
"("
+
material
.
getModel
()
+
")"
);
ratio
=
""
;
for
(
int
i
=
0
;
i
<
mpArr
.
length
;
i
++)
{
}
else
{
if
(
mpArr
[
i
].
equals
(
"颜色"
))
{
ratio
=
material
.
getUnitName
();
MaterialName
=
MaterialName
+
((
material
.
getColor
()
==
null
||
material
.
getColor
().
equals
(
""
))
?
""
:
"("
+
material
.
getColor
()
+
")"
);
ratio
=
ratio
.
substring
(
ratio
.
indexOf
(
"("
));
}
}
if
(
mpArr
[
i
].
equals
(
"规格"
))
{
//品名/型号/扩展信息/包装
MaterialName
=
MaterialName
+
((
material
.
getStandard
()
==
null
||
material
.
getStandard
().
equals
(
""
))
?
""
:
"("
+
material
.
getStandard
()
+
")"
);
String
MaterialName
=
material
.
getName
()
+
((
material
.
getModel
()
==
null
||
material
.
getModel
().
equals
(
""
))
?
""
:
"("
+
material
.
getModel
()
+
")"
);
}
for
(
int
i
=
0
;
i
<
mpArr
.
length
;
i
++)
{
if
(
mpArr
[
i
].
equals
(
"制造商"
))
{
if
(
mpArr
[
i
].
equals
(
"颜色"
))
{
MaterialName
=
MaterialName
+
((
material
.
getMfrs
()
==
null
||
material
.
getMfrs
().
equals
(
""
))
?
""
:
"("
+
material
.
getMfrs
()
+
")"
);
MaterialName
=
MaterialName
+
((
material
.
getColor
()
==
null
||
material
.
getColor
().
equals
(
""
))
?
""
:
"("
+
material
.
getColor
()
+
")"
);
}
}
if
(
mpArr
[
i
].
equals
(
"自定义1"
))
{
if
(
mpArr
[
i
].
equals
(
"规格"
))
{
MaterialName
=
MaterialName
+
((
material
.
getOtherfield1
()
==
null
||
material
.
getOtherfield1
().
equals
(
""
))
?
""
:
"("
+
material
.
getOtherfield1
()
+
")"
);
MaterialName
=
MaterialName
+
((
material
.
getStandard
()
==
null
||
material
.
getStandard
().
equals
(
""
))
?
""
:
"("
+
material
.
getStandard
()
+
")"
);
}
}
if
(
mpArr
[
i
].
equals
(
"自定义2"
))
{
if
(
mpArr
[
i
].
equals
(
"制造商"
))
{
MaterialName
=
MaterialName
+
((
material
.
getOtherfield2
()
==
null
||
material
.
getOtherfield2
().
equals
(
""
))
?
""
:
"("
+
material
.
getOtherfield2
()
+
")"
);
MaterialName
=
MaterialName
+
((
material
.
getMfrs
()
==
null
||
material
.
getMfrs
().
equals
(
""
))
?
""
:
"("
+
material
.
getMfrs
()
+
")"
);
}
}
if
(
mpArr
[
i
].
equals
(
"自定义3"
))
{
if
(
mpArr
[
i
].
equals
(
"自定义1"
))
{
MaterialName
=
MaterialName
+
((
material
.
getOtherfield3
()
==
null
||
material
.
getOtherfield3
().
equals
(
""
))
?
""
:
"("
+
material
.
getOtherfield3
()
+
")"
);
MaterialName
=
MaterialName
+
((
material
.
getOtherfield1
()
==
null
||
material
.
getOtherfield1
().
equals
(
""
))
?
""
:
"("
+
material
.
getOtherfield1
()
+
")"
);
}
}
}
if
(
mpArr
[
i
].
equals
(
"自定义2"
))
{
MaterialName
=
MaterialName
+
((
material
.
getUnit
()
==
null
||
material
.
getUnit
().
equals
(
""
))
?
""
:
"("
+
material
.
getUnit
()
+
")"
)
+
ratio
;
MaterialName
=
MaterialName
+
((
material
.
getOtherfield2
()
==
null
||
material
.
getOtherfield2
().
equals
(
""
))
?
""
:
"("
+
material
.
getOtherfield2
()
+
")"
);
item
.
put
(
"MaterialName"
,
MaterialName
);
}
dataArray
.
add
(
item
);
if
(
mpArr
[
i
].
equals
(
"自定义3"
))
{
}
MaterialName
=
MaterialName
+
((
material
.
getOtherfield3
()
==
null
||
material
.
getOtherfield3
().
equals
(
""
))
?
""
:
"("
+
material
.
getOtherfield3
()
+
")"
);
}
}
}
catch
(
Exception
e
)
{
}
e
.
printStackTrace
();
MaterialName
=
MaterialName
+
((
material
.
getUnit
()
==
null
||
material
.
getUnit
().
equals
(
""
))
?
""
:
"("
+
material
.
getUnit
()
+
")"
)
+
ratio
;
}
item
.
put
(
"MaterialName"
,
MaterialName
);
return
dataArray
;
dataArray
.
add
(
item
);
}
}
}
}
catch
(
Exception
e
)
{
/**
e
.
printStackTrace
();
* 查找商品信息-统计排序
}
* @param request
return
dataArray
;
* @return
}
*/
@GetMapping
(
value
=
"/findByOrder"
)
public
BaseResponseInfo
findByOrder
(
HttpServletRequest
request
)
{
/**
BaseResponseInfo
res
=
new
BaseResponseInfo
();
* 查找商品信息-统计排序
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
* @param request
try
{
* @return
List
<
Material
>
dataList
=
materialService
.
findByOrder
();
*/
String
mId
=
""
;
@GetMapping
(
value
=
"/findByOrder"
)
if
(
null
!=
dataList
)
{
public
BaseResponseInfo
findByOrder
(
HttpServletRequest
request
)
{
for
(
Material
material
:
dataList
)
{
BaseResponseInfo
res
=
new
BaseResponseInfo
();
mId
=
mId
+
material
.
getId
()
+
","
;
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
}
try
{
}
List
<
Material
>
dataList
=
materialService
.
findByOrder
();
if
(
mId
!=
""
)
{
String
mId
=
""
;
mId
=
mId
.
substring
(
0
,
mId
.
lastIndexOf
(
","
));
if
(
null
!=
dataList
)
{
}
for
(
Material
material
:
dataList
)
{
map
.
put
(
"mIds"
,
mId
);
mId
=
mId
+
material
.
getId
()
+
","
;
res
.
code
=
200
;
}
res
.
data
=
map
;
}
}
catch
(
Exception
e
){
if
(
mId
!=
""
)
{
e
.
printStackTrace
();
mId
=
mId
.
substring
(
0
,
mId
.
lastIndexOf
(
","
));
res
.
code
=
500
;
}
res
.
data
=
"获取数据失败"
;
map
.
put
(
"mIds"
,
mId
);
}
res
.
code
=
200
;
return
res
;
res
.
data
=
map
;
}
}
catch
(
Exception
e
){
}
e
.
printStackTrace
();
res
.
code
=
500
;
res
.
data
=
"获取数据失败"
;
}
return
res
;
}
/**
* 生成excel表格
* @param name
* @param model
* @param categoryId
* @param categoryIds
* @param request
* @param response
* @return
*/
@GetMapping
(
value
=
"/exportExcel"
)
public
BaseResponseInfo
exportExcel
(
@RequestParam
(
"name"
)
String
name
,
@RequestParam
(
"model"
)
String
model
,
@RequestParam
(
"categoryId"
)
Long
categoryId
,
@RequestParam
(
"categoryIds"
)
String
categoryIds
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
BaseResponseInfo
res
=
new
BaseResponseInfo
();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
String
message
=
"成功"
;
try
{
List
<
MaterialVo4Unit
>
dataList
=
materialService
.
findByAll
(
name
,
model
,
categoryId
,
categoryIds
);
String
[]
names
=
{
"品名"
,
"类型"
,
"型号"
,
"安全存量"
,
"单位"
,
"零售价"
,
"最低售价"
,
"预计采购价"
,
"批发价"
,
"备注"
,
"状态"
};
String
title
=
"商品信息"
;
List
<
String
[]>
objects
=
new
ArrayList
<
String
[]>();
if
(
null
!=
dataList
)
{
for
(
MaterialVo4Unit
m
:
dataList
)
{
String
[]
objs
=
new
String
[
11
];
objs
[
0
]
=
m
.
getName
();
objs
[
1
]
=
m
.
getCategoryName
();
objs
[
2
]
=
m
.
getModel
();
objs
[
3
]
=
m
.
getSafetystock
()
==
null
?
""
:
m
.
getSafetystock
().
toString
();
objs
[
4
]
=
m
.
getUnit
();
objs
[
5
]
=
m
.
getRetailprice
()
==
null
?
""
:
m
.
getRetailprice
().
toString
();
objs
[
6
]
=
m
.
getLowprice
()
==
null
?
""
:
m
.
getLowprice
().
toString
();
objs
[
7
]
=
m
.
getPresetpriceone
()
==
null
?
""
:
m
.
getPresetpriceone
().
toString
();
objs
[
8
]
=
m
.
getPresetpricetwo
()
==
null
?
""
:
m
.
getPresetpricetwo
().
toString
();
objs
[
9
]
=
m
.
getRemark
();
objs
[
10
]
=
m
.
getEnabled
()
?
"启用"
:
"禁用"
;
objects
.
add
(
objs
);
}
}
File
file
=
ExcelUtils
.
exportObjectsWithoutTitle
(
title
,
names
,
title
,
objects
);
ExportExecUtil
.
showExec
(
file
,
file
.
getName
(),
response
);
res
.
code
=
200
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
message
=
"导出失败"
;
res
.
code
=
500
;
}
finally
{
map
.
put
(
"message"
,
message
);
res
.
data
=
map
;
}
return
res
;
}
/**
* excel表格导入
* @param materialFile
* @param request
* @param response
* @return
*/
@PostMapping
(
value
=
"/importExcel"
)
public
void
importExcel
(
MultipartFile
materialFile
,
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
{
BaseResponseInfo
info
=
new
BaseResponseInfo
();
Map
<
String
,
Object
>
data
=
new
HashMap
<
String
,
Object
>();
String
message
=
"成功"
;
try
{
Sheet
src
=
null
;
//文件合法性校验
try
{
Workbook
workbook
=
Workbook
.
getWorkbook
(
materialFile
.
getInputStream
());
src
=
workbook
.
getSheet
(
0
);
}
catch
(
Exception
e
)
{
message
=
"导入文件不合法,请检查"
;
data
.
put
(
"message"
,
message
);
info
.
code
=
400
;
info
.
data
=
data
;
}
//读取所有的摄像机编码
//每行中数据顺序 "品名","类型","型号","安全存量","单位","零售价","最低售价","预计采购价","批发价","备注","状态"
List
<
Material
>
mList
=
new
ArrayList
<
Material
>();
for
(
int
i
=
1
;
i
<
src
.
getRows
();
i
++)
{
Material
m
=
new
Material
();
m
.
setName
(
ExcelUtils
.
getContent
(
src
,
i
,
0
));
m
.
setCategoryid
(
1
l
);
//根目录
m
.
setModel
(
ExcelUtils
.
getContent
(
src
,
i
,
2
));
String
safetyStock
=
ExcelUtils
.
getContent
(
src
,
i
,
3
);
m
.
setSafetystock
(
parseDoubleEx
(
safetyStock
));
m
.
setUnit
(
ExcelUtils
.
getContent
(
src
,
i
,
4
));
String
retailprice
=
ExcelUtils
.
getContent
(
src
,
i
,
5
);
m
.
setRetailprice
(
parseDoubleEx
(
retailprice
));
String
lowPrice
=
ExcelUtils
.
getContent
(
src
,
i
,
6
);
m
.
setLowprice
(
parseDoubleEx
(
lowPrice
));
String
presetpriceone
=
ExcelUtils
.
getContent
(
src
,
i
,
7
);
m
.
setPresetpriceone
(
parseDoubleEx
(
presetpriceone
));
String
presetpricetwo
=
ExcelUtils
.
getContent
(
src
,
i
,
8
);
m
.
setPresetpricetwo
(
parseDoubleEx
(
presetpricetwo
));
m
.
setRemark
(
ExcelUtils
.
getContent
(
src
,
i
,
9
));
String
enabled
=
ExcelUtils
.
getContent
(
src
,
i
,
10
);
m
.
setEnabled
(
enabled
.
equals
(
"启用"
)?
true
:
false
);
mList
.
add
(
m
);
}
info
=
materialService
.
importExcel
(
mList
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
message
=
"导入失败"
;
info
.
code
=
500
;
data
.
put
(
"message"
,
message
);
info
.
data
=
data
;
}
response
.
sendRedirect
(
"../pages/materials/material.html"
);
}
public
Double
parseDoubleEx
(
String
str
){
if
(!
StringUtil
.
isEmpty
(
str
))
{
return
Double
.
parseDouble
(
str
);
}
else
{
return
null
;
}
}
}
src/main/java/com/jsh/erp/controller/SupplierController.java
View file @
693a7558
package
com.jsh.erp.controller
;
package
com.jsh.erp.controller
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.datasource.entities.Supplier
;
import
com.jsh.erp.datasource.entities.Supplier
;
import
com.jsh.erp.service.supplier.SupplierService
;
import
com.jsh.erp.service.supplier.SupplierService
;
import
com.jsh.erp.service.userBusiness.UserBusinessService
;
import
com.jsh.erp.service.userBusiness.UserBusinessService
;
import
com.jsh.erp.utils.BaseResponseInfo
;
import
com.jsh.erp.utils.*
;
import
com.jsh.erp.utils.ErpInfo
;
import
jxl.Sheet
;
import
org.slf4j.Logger
;
import
jxl.Workbook
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.Logger
;
import
org.springframework.dao.DataAccessException
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.dao.DataAccessException
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.HashMap
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.File
;
import
static
com
.
jsh
.
erp
.
utils
.
ResponseJsonUtil
.
returnJson
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
/**
import
java.util.List
;
* @author ji|sheng|hua 华夏erp
import
java.util.Map
;
*/
@RestController
import
static
com
.
jsh
.
erp
.
utils
.
ResponseJsonUtil
.
returnJson
;
@RequestMapping
(
value
=
"/supplier"
)
public
class
SupplierController
{
/**
private
Logger
logger
=
LoggerFactory
.
getLogger
(
SupplierController
.
class
);
* @author ji|sheng|hua 华夏erp
*/
@Resource
@RestController
private
SupplierService
supplierService
;
@RequestMapping
(
value
=
"/supplier"
)
public
class
SupplierController
{
@Resource
private
Logger
logger
=
LoggerFactory
.
getLogger
(
SupplierController
.
class
);
private
UserBusinessService
userBusinessService
;
@Resource
/**
private
SupplierService
supplierService
;
* 更新供应商-只更新预付款,其余用原来的值
* @param supplierId
@Resource
* @param advanceIn
private
UserBusinessService
userBusinessService
;
* @param request
* @return
/**
*/
* 更新供应商-只更新预付款,其余用原来的值
@PostMapping
(
value
=
"/updateAdvanceIn"
)
* @param supplierId
public
String
updateAdvanceIn
(
@RequestParam
(
"supplierId"
)
Long
supplierId
,
* @param advanceIn
@RequestParam
(
"advanceIn"
)
Double
advanceIn
,
* @param request
HttpServletRequest
request
)
{
* @return
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<
String
,
Object
>();
*/
int
res
=
supplierService
.
updateAdvanceIn
(
supplierId
,
advanceIn
);
@PostMapping
(
value
=
"/updateAdvanceIn"
)
if
(
res
>
0
)
{
public
String
updateAdvanceIn
(
@RequestParam
(
"supplierId"
)
Long
supplierId
,
return
returnJson
(
objectMap
,
ErpInfo
.
OK
.
name
,
ErpInfo
.
OK
.
code
);
@RequestParam
(
"advanceIn"
)
Double
advanceIn
,
}
else
{
HttpServletRequest
request
)
{
return
returnJson
(
objectMap
,
ErpInfo
.
ERROR
.
name
,
ErpInfo
.
ERROR
.
code
);
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<
String
,
Object
>();
}
int
res
=
supplierService
.
updateAdvanceIn
(
supplierId
,
advanceIn
);
}
if
(
res
>
0
)
{
return
returnJson
(
objectMap
,
ErpInfo
.
OK
.
name
,
ErpInfo
.
OK
.
code
);
/**
}
else
{
* 查找客户信息-下拉框
return
returnJson
(
objectMap
,
ErpInfo
.
ERROR
.
name
,
ErpInfo
.
ERROR
.
code
);
* @param request
}
* @return
}
*/
@PostMapping
(
value
=
"/findBySelect_cus"
)
/**
public
JSONArray
findBySelectCus
(
HttpServletRequest
request
)
{
* 查找客户信息-下拉框
JSONArray
arr
=
new
JSONArray
();
* @param request
try
{
* @return
List
<
Supplier
>
supplierList
=
supplierService
.
findBySelectCus
();
*/
JSONArray
dataArray
=
new
JSONArray
();
@PostMapping
(
value
=
"/findBySelect_cus"
)
if
(
null
!=
supplierList
)
{
public
JSONArray
findBySelectCus
(
HttpServletRequest
request
)
{
for
(
Supplier
supplier
:
supplierList
)
{
JSONArray
arr
=
new
JSONArray
();
JSONObject
item
=
new
JSONObject
();
try
{
//勾选判断1
List
<
Supplier
>
supplierList
=
supplierService
.
findBySelectCus
();
Boolean
flag
=
false
;
JSONArray
dataArray
=
new
JSONArray
();
try
{
if
(
null
!=
supplierList
)
{
flag
=
userBusinessService
.
checkIsUserBusinessExist
(
null
,
null
,
"["
+
supplier
.
getId
().
toString
()
+
"]"
);
for
(
Supplier
supplier
:
supplierList
)
{
}
catch
(
DataAccessException
e
)
{
JSONObject
item
=
new
JSONObject
();
logger
.
error
(
">>>>>>>>>>>>>>>>>查询用户对应的客户:存在异常!"
);
//勾选判断1
}
Boolean
flag
=
false
;
if
(
flag
==
true
)
{
try
{
item
.
put
(
"id"
,
supplier
.
getId
());
flag
=
userBusinessService
.
checkIsUserBusinessExist
(
null
,
null
,
"["
+
supplier
.
getId
().
toString
()
+
"]"
);
item
.
put
(
"supplier"
,
supplier
.
getSupplier
());
//客户名称
}
catch
(
DataAccessException
e
)
{
dataArray
.
add
(
item
);
logger
.
error
(
">>>>>>>>>>>>>>>>>查询用户对应的客户:存在异常!"
);
}
}
}
if
(
flag
==
true
)
{
}
item
.
put
(
"id"
,
supplier
.
getId
());
arr
=
dataArray
;
item
.
put
(
"supplier"
,
supplier
.
getSupplier
());
//客户名称
}
catch
(
Exception
e
){
dataArray
.
add
(
item
);
e
.
printStackTrace
();
}
}
}
return
arr
;
}
}
arr
=
dataArray
;
}
catch
(
Exception
e
){
/**
e
.
printStackTrace
();
* 查找供应商信息-下拉框
}
* @param request
return
arr
;
* @return
}
*/
@PostMapping
(
value
=
"/findBySelect_sup"
)
/**
public
JSONArray
findBySelectSup
(
HttpServletRequest
request
)
{
* 查找供应商信息-下拉框
JSONArray
arr
=
new
JSONArray
();
* @param request
try
{
* @return
List
<
Supplier
>
supplierList
=
supplierService
.
findBySelectSup
();
*/
JSONArray
dataArray
=
new
JSONArray
();
@PostMapping
(
value
=
"/findBySelect_sup"
)
if
(
null
!=
supplierList
)
{
public
JSONArray
findBySelectSup
(
HttpServletRequest
request
)
{
for
(
Supplier
supplier
:
supplierList
)
{
JSONArray
arr
=
new
JSONArray
();
JSONObject
item
=
new
JSONObject
();
try
{
item
.
put
(
"id"
,
supplier
.
getId
());
List
<
Supplier
>
supplierList
=
supplierService
.
findBySelectSup
();
//供应商名称
JSONArray
dataArray
=
new
JSONArray
();
item
.
put
(
"supplier"
,
supplier
.
getSupplier
());
if
(
null
!=
supplierList
)
{
dataArray
.
add
(
item
);
for
(
Supplier
supplier
:
supplierList
)
{
}
JSONObject
item
=
new
JSONObject
();
}
item
.
put
(
"id"
,
supplier
.
getId
());
arr
=
dataArray
;
//供应商名称
}
catch
(
Exception
e
){
item
.
put
(
"supplier"
,
supplier
.
getSupplier
());
e
.
printStackTrace
();
dataArray
.
add
(
item
);
}
}
return
arr
;
}
}
arr
=
dataArray
;
}
catch
(
Exception
e
){
/**
e
.
printStackTrace
();
* 查找会员信息-下拉框
}
* @param request
return
arr
;
* @return
}
*/
@PostMapping
(
value
=
"/findBySelect_retail"
)
/**
public
JSONArray
findBySelectRetail
(
HttpServletRequest
request
)
{
* 查找会员信息-下拉框
JSONArray
arr
=
new
JSONArray
();
* @param request
try
{
* @return
List
<
Supplier
>
supplierList
=
supplierService
.
findBySelectRetail
();
*/
JSONArray
dataArray
=
new
JSONArray
();
@PostMapping
(
value
=
"/findBySelect_retail"
)
if
(
null
!=
supplierList
)
{
public
JSONArray
findBySelectRetail
(
HttpServletRequest
request
)
{
for
(
Supplier
supplier
:
supplierList
)
{
JSONArray
arr
=
new
JSONArray
();
JSONObject
item
=
new
JSONObject
();
try
{
item
.
put
(
"id"
,
supplier
.
getId
());
List
<
Supplier
>
supplierList
=
supplierService
.
findBySelectRetail
();
//客户名称
JSONArray
dataArray
=
new
JSONArray
();
item
.
put
(
"supplier"
,
supplier
.
getSupplier
());
if
(
null
!=
supplierList
)
{
item
.
put
(
"advanceIn"
,
supplier
.
getAdvancein
());
//预付款金额
for
(
Supplier
supplier
:
supplierList
)
{
dataArray
.
add
(
item
);
JSONObject
item
=
new
JSONObject
();
}
item
.
put
(
"id"
,
supplier
.
getId
());
}
//客户名称
arr
=
dataArray
;
item
.
put
(
"supplier"
,
supplier
.
getSupplier
());
}
catch
(
Exception
e
){
item
.
put
(
"advanceIn"
,
supplier
.
getAdvancein
());
//预付款金额
e
.
printStackTrace
();
dataArray
.
add
(
item
);
}
}
return
arr
;
}
}
arr
=
dataArray
;
}
catch
(
Exception
e
){
/**
e
.
printStackTrace
();
* 根据id查找信息
}
* @param supplierId
return
arr
;
* @param request
}
* @return
*/
/**
@GetMapping
(
value
=
"/findById"
)
* 根据id查找信息
public
BaseResponseInfo
findById
(
@RequestParam
(
"supplierId"
)
Long
supplierId
,
* @param supplierId
HttpServletRequest
request
)
{
* @param request
BaseResponseInfo
res
=
new
BaseResponseInfo
();
* @return
try
{
*/
JSONArray
dataArray
=
new
JSONArray
();
@GetMapping
(
value
=
"/findById"
)
List
<
Supplier
>
dataList
=
supplierService
.
findById
(
supplierId
);
public
BaseResponseInfo
findById
(
@RequestParam
(
"supplierId"
)
Long
supplierId
,
if
(
null
!=
dataList
)
{
HttpServletRequest
request
)
{
for
(
Supplier
supplier
:
dataList
)
{
BaseResponseInfo
res
=
new
BaseResponseInfo
();
JSONObject
item
=
new
JSONObject
();
try
{
item
.
put
(
"id"
,
supplier
.
getId
());
JSONArray
dataArray
=
new
JSONArray
();
//名称
List
<
Supplier
>
dataList
=
supplierService
.
findById
(
supplierId
);
item
.
put
(
"supplier"
,
supplier
.
getSupplier
());
if
(
null
!=
dataList
)
{
item
.
put
(
"type"
,
supplier
.
getType
());
for
(
Supplier
supplier
:
dataList
)
{
item
.
put
(
"contacts"
,
supplier
.
getContacts
());
JSONObject
item
=
new
JSONObject
();
item
.
put
(
"phonenum"
,
supplier
.
getPhonenum
());
item
.
put
(
"id"
,
supplier
.
getId
());
item
.
put
(
"email"
,
supplier
.
getEmail
());
//名称
item
.
put
(
"AdvanceIn"
,
supplier
.
getAdvancein
());
item
.
put
(
"supplier"
,
supplier
.
getSupplier
());
item
.
put
(
"BeginNeedGet"
,
supplier
.
getBeginneedget
());
item
.
put
(
"type"
,
supplier
.
getType
());
item
.
put
(
"BeginNeedPay"
,
supplier
.
getBeginneedpay
());
item
.
put
(
"contacts"
,
supplier
.
getContacts
());
item
.
put
(
"isystem"
,
supplier
.
getIsystem
()
==
(
short
)
0
?
"是"
:
"否"
);
item
.
put
(
"phonenum"
,
supplier
.
getPhonenum
());
item
.
put
(
"description"
,
supplier
.
getDescription
());
item
.
put
(
"email"
,
supplier
.
getEmail
());
item
.
put
(
"fax"
,
supplier
.
getFax
());
item
.
put
(
"AdvanceIn"
,
supplier
.
getAdvancein
());
item
.
put
(
"telephone"
,
supplier
.
getTelephone
());
item
.
put
(
"BeginNeedGet"
,
supplier
.
getBeginneedget
());
item
.
put
(
"address"
,
supplier
.
getAddress
());
item
.
put
(
"BeginNeedPay"
,
supplier
.
getBeginneedpay
());
item
.
put
(
"taxNum"
,
supplier
.
getTaxnum
());
item
.
put
(
"isystem"
,
supplier
.
getIsystem
()
==
(
short
)
0
?
"是"
:
"否"
);
item
.
put
(
"bankName"
,
supplier
.
getBankname
());
item
.
put
(
"description"
,
supplier
.
getDescription
());
item
.
put
(
"accountNumber"
,
supplier
.
getAccountnumber
());
item
.
put
(
"fax"
,
supplier
.
getFax
());
item
.
put
(
"taxRate"
,
supplier
.
getTaxrate
());
item
.
put
(
"telephone"
,
supplier
.
getTelephone
());
item
.
put
(
"enabled"
,
supplier
.
getEnabled
());
item
.
put
(
"address"
,
supplier
.
getAddress
());
dataArray
.
add
(
item
);
item
.
put
(
"taxNum"
,
supplier
.
getTaxnum
());
}
item
.
put
(
"bankName"
,
supplier
.
getBankname
());
res
.
code
=
200
;
item
.
put
(
"accountNumber"
,
supplier
.
getAccountnumber
());
res
.
data
=
dataArray
;
item
.
put
(
"taxRate"
,
supplier
.
getTaxrate
());
}
item
.
put
(
"enabled"
,
supplier
.
getEnabled
());
}
catch
(
Exception
e
)
{
dataArray
.
add
(
item
);
e
.
printStackTrace
();
}
res
.
code
=
500
;
res
.
code
=
200
;
res
.
data
=
"获取数据失败"
;
res
.
data
=
dataArray
;
}
}
return
res
;
}
catch
(
Exception
e
)
{
}
e
.
printStackTrace
();
res
.
code
=
500
;
/**
res
.
data
=
"获取数据失败"
;
* 批量设置状态-启用或者禁用
}
* @param enabled
return
res
;
* @param supplierIDs
}
* @param request
* @return
/**
*/
* 批量设置状态-启用或者禁用
@PostMapping
(
value
=
"/batchSetEnable"
)
* @param enabled
public
String
batchSetEnable
(
@RequestParam
(
"enabled"
)
Boolean
enabled
,
* @param supplierIDs
@RequestParam
(
"supplierIDs"
)
String
supplierIDs
,
* @param request
HttpServletRequest
request
)
{
* @return
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<
String
,
Object
>();
*/
int
res
=
supplierService
.
batchSetEnable
(
enabled
,
supplierIDs
);
@PostMapping
(
value
=
"/batchSetEnable"
)
if
(
res
>
0
)
{
public
String
batchSetEnable
(
@RequestParam
(
"enabled"
)
Boolean
enabled
,
return
returnJson
(
objectMap
,
ErpInfo
.
OK
.
name
,
ErpInfo
.
OK
.
code
);
@RequestParam
(
"supplierIDs"
)
String
supplierIDs
,
}
else
{
HttpServletRequest
request
)
{
return
returnJson
(
objectMap
,
ErpInfo
.
ERROR
.
name
,
ErpInfo
.
ERROR
.
code
);
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<
String
,
Object
>();
}
int
res
=
supplierService
.
batchSetEnable
(
enabled
,
supplierIDs
);
}
if
(
res
>
0
)
{
return
returnJson
(
objectMap
,
ErpInfo
.
OK
.
name
,
ErpInfo
.
OK
.
code
);
/**
}
else
{
* 用户对应客户显示
return
returnJson
(
objectMap
,
ErpInfo
.
ERROR
.
name
,
ErpInfo
.
ERROR
.
code
);
* @param type
}
* @param keyId
}
* @param request
* @return
/**
*/
* 用户对应客户显示
@PostMapping
(
value
=
"/findUserCustomer"
)
* @param type
public
JSONArray
findUserCustomer
(
@RequestParam
(
"UBType"
)
String
type
,
@RequestParam
(
"UBKeyId"
)
String
keyId
,
* @param keyId
HttpServletRequest
request
)
{
* @param request
JSONArray
arr
=
new
JSONArray
();
* @return
try
{
*/
List
<
Supplier
>
dataList
=
supplierService
.
findUserCustomer
();
@PostMapping
(
value
=
"/findUserCustomer"
)
//开始拼接json数据
public
JSONArray
findUserCustomer
(
@RequestParam
(
"UBType"
)
String
type
,
@RequestParam
(
"UBKeyId"
)
String
keyId
,
JSONObject
outer
=
new
JSONObject
();
HttpServletRequest
request
)
{
outer
.
put
(
"id"
,
1
);
JSONArray
arr
=
new
JSONArray
();
outer
.
put
(
"text"
,
"客户列表"
);
try
{
outer
.
put
(
"state"
,
"open"
);
List
<
Supplier
>
dataList
=
supplierService
.
findUserCustomer
();
//存放数据json数组
//开始拼接json数据
JSONArray
dataArray
=
new
JSONArray
();
JSONObject
outer
=
new
JSONObject
();
if
(
null
!=
dataList
)
{
outer
.
put
(
"id"
,
1
);
for
(
Supplier
supplier
:
dataList
)
{
outer
.
put
(
"text"
,
"客户列表"
);
JSONObject
item
=
new
JSONObject
();
outer
.
put
(
"state"
,
"open"
);
item
.
put
(
"id"
,
supplier
.
getId
());
//存放数据json数组
item
.
put
(
"text"
,
supplier
.
getSupplier
());
JSONArray
dataArray
=
new
JSONArray
();
//勾选判断1
if
(
null
!=
dataList
)
{
Boolean
flag
=
false
;
for
(
Supplier
supplier
:
dataList
)
{
try
{
JSONObject
item
=
new
JSONObject
();
flag
=
userBusinessService
.
checkIsUserBusinessExist
(
type
,
keyId
,
"["
+
supplier
.
getId
().
toString
()
+
"]"
);
item
.
put
(
"id"
,
supplier
.
getId
());
}
catch
(
Exception
e
)
{
item
.
put
(
"text"
,
supplier
.
getSupplier
());
logger
.
error
(
">>>>>>>>>>>>>>>>>设置用户对应的客户:类型"
+
type
+
" KeyId为: "
+
keyId
+
" 存在异常!"
);
//勾选判断1
}
Boolean
flag
=
false
;
if
(
flag
==
true
)
{
try
{
item
.
put
(
"checked"
,
true
);
flag
=
userBusinessService
.
checkIsUserBusinessExist
(
type
,
keyId
,
"["
+
supplier
.
getId
().
toString
()
+
"]"
);
}
}
catch
(
Exception
e
)
{
//结束
logger
.
error
(
">>>>>>>>>>>>>>>>>设置用户对应的客户:类型"
+
type
+
" KeyId为: "
+
keyId
+
" 存在异常!"
);
dataArray
.
add
(
item
);
}
}
if
(
flag
==
true
)
{
}
item
.
put
(
"checked"
,
true
);
outer
.
put
(
"children"
,
dataArray
);
}
arr
.
add
(
outer
);
//结束
}
catch
(
Exception
e
)
{
dataArray
.
add
(
item
);
e
.
printStackTrace
();
}
}
}
return
arr
;
outer
.
put
(
"children"
,
dataArray
);
}
arr
.
add
(
outer
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
arr
;
}
/**
* 生成excel表格
* @param supplier
* @param type
* @param phonenum
* @param telephone
* @param description
* @param request
* @param response
* @return
*/
@GetMapping
(
value
=
"/exportExcel"
)
public
BaseResponseInfo
exportExcel
(
@RequestParam
(
"supplier"
)
String
supplier
,
@RequestParam
(
"type"
)
String
type
,
@RequestParam
(
"phonenum"
)
String
phonenum
,
@RequestParam
(
"telephone"
)
String
telephone
,
@RequestParam
(
"description"
)
String
description
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
BaseResponseInfo
res
=
new
BaseResponseInfo
();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
String
message
=
"成功"
;
try
{
List
<
Supplier
>
dataList
=
supplierService
.
findByAll
(
supplier
,
type
,
phonenum
,
telephone
,
description
);
String
[]
names
=
{
"名称"
,
"类型"
,
"联系人"
,
"电话"
,
"电子邮箱"
,
"预收款"
,
"期初应收"
,
"期初应付"
,
"备注"
,
"传真"
,
"手机"
,
"地址"
,
"纳税人识别号"
,
"开户行"
,
"账号"
,
"税率"
,
"状态"
};
String
title
=
"信息报表"
;
List
<
String
[]>
objects
=
new
ArrayList
<
String
[]>();
if
(
null
!=
dataList
)
{
for
(
Supplier
s
:
dataList
)
{
String
[]
objs
=
new
String
[
17
];
objs
[
0
]
=
s
.
getSupplier
();
objs
[
1
]
=
s
.
getType
();
objs
[
2
]
=
s
.
getContacts
();
objs
[
3
]
=
s
.
getPhonenum
();
objs
[
4
]
=
s
.
getEmail
();
objs
[
5
]
=
s
.
getAdvancein
()
==
null
?
""
:
s
.
getAdvancein
().
toString
();
objs
[
6
]
=
s
.
getBeginneedget
()
==
null
?
""
:
s
.
getBeginneedget
().
toString
();
objs
[
7
]
=
s
.
getBeginneedpay
()
==
null
?
""
:
s
.
getBeginneedpay
().
toString
();
objs
[
8
]
=
s
.
getDescription
();
objs
[
9
]
=
s
.
getFax
();
objs
[
10
]
=
s
.
getTelephone
();
objs
[
11
]
=
s
.
getAddress
();
objs
[
12
]
=
s
.
getTaxnum
();
objs
[
13
]
=
s
.
getBankname
();
objs
[
14
]
=
s
.
getAccountnumber
();
objs
[
15
]
=
s
.
getTaxrate
()
==
null
?
""
:
s
.
getTaxrate
().
toString
();
objs
[
16
]
=
s
.
getEnabled
()
?
"启用"
:
"禁用"
;
objects
.
add
(
objs
);
}
}
File
file
=
ExcelUtils
.
exportObjectsWithoutTitle
(
title
,
names
,
title
,
objects
);
ExportExecUtil
.
showExec
(
file
,
file
.
getName
(),
response
);
res
.
code
=
200
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
message
=
"导出失败"
;
res
.
code
=
500
;
}
finally
{
map
.
put
(
"message"
,
message
);
res
.
data
=
map
;
}
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
.
setEnabled
(
enabled
.
equals
(
"启用"
)?
true
:
false
);
s
.
setIsystem
(
Byte
.
parseByte
(
"1"
));
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/datasource/entities/DepotItemVo4WithInfoEx.java
View file @
693a7558
package
com.jsh.erp.datasource.entities
;
package
com.jsh.erp.datasource.entities
;
public
class
DepotItemVo4WithInfoEx
{
public
class
DepotItemVo4WithInfoEx
{
private
Long
id
;
private
Long
id
;
private
Long
headerid
;
private
Long
headerid
;
private
Long
materialid
;
private
Long
materialid
;
private
String
munit
;
private
String
munit
;
private
Double
opernumber
;
private
Double
opernumber
;
private
Double
basicnumber
;
private
Double
basicnumber
;
private
Double
unitprice
;
private
Double
unitprice
;
private
Double
taxunitprice
;
private
Double
taxunitprice
;
private
Double
allprice
;
private
Double
allprice
;
private
String
remark
;
private
String
remark
;
private
String
img
;
private
String
img
;
private
Double
incidentals
;
private
Double
incidentals
;
private
Long
depotid
;
private
Long
depotid
;
private
Long
anotherdepotid
;
private
Long
anotherdepotid
;
private
Double
taxrate
;
private
Double
taxrate
;
private
Double
taxmoney
;
private
Double
taxmoney
;
private
Double
taxlastmoney
;
private
Double
taxlastmoney
;
private
String
otherfield1
;
private
String
otherfield1
;
private
String
otherfield2
;
private
String
otherfield2
;
private
String
otherfield3
;
private
String
otherfield3
;
private
String
otherfield4
;
private
String
otherfield4
;
private
String
otherfield5
;
private
String
otherfield5
;
private
String
mtype
;
private
String
mtype
;
private
String
MName
;
private
Long
MId
;
private
String
MModel
;
private
String
MName
;
private
String
MaterialUnit
;
private
String
MModel
;
private
String
MColor
;
private
String
MaterialUnit
;
private
String
MStandard
;
private
String
MColor
;
private
String
MMfrs
;
private
String
MStandard
;
private
String
MOtherField1
;
private
String
MMfrs
;
private
String
MOtherField2
;
private
String
MOtherField1
;
private
String
MOtherField3
;
private
String
MOtherField2
;
private
String
DepotName
;
private
String
MOtherField3
;
private
String
AnotherDepotName
;
private
String
DepotName
;
private
Long
UnitId
;
private
String
AnotherDepotName
;
private
String
UName
;
private
Long
UnitId
;
public
Long
getId
()
{
private
String
UName
;
return
id
;
}
public
Long
getId
()
{
return
id
;
public
void
setId
(
Long
id
)
{
}
this
.
id
=
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
public
Long
getHeaderid
()
{
}
return
headerid
;
}
public
Long
getHeaderid
()
{
return
headerid
;
public
void
setHeaderid
(
Long
headerid
)
{
}
this
.
headerid
=
headerid
;
}
public
void
setHeaderid
(
Long
headerid
)
{
this
.
headerid
=
headerid
;
public
Long
getMaterialid
()
{
}
return
materialid
;
}
public
Long
getMaterialid
()
{
return
materialid
;
public
void
setMaterialid
(
Long
materialid
)
{
}
this
.
materialid
=
materialid
;
}
public
void
setMaterialid
(
Long
materialid
)
{
this
.
materialid
=
materialid
;
public
String
getMunit
()
{
}
return
munit
;
}
public
String
getMunit
()
{
return
munit
;
public
void
setMunit
(
String
munit
)
{
}
this
.
munit
=
munit
;
}
public
void
setMunit
(
String
munit
)
{
this
.
munit
=
munit
;
public
Double
getOpernumber
()
{
}
return
opernumber
;
}
public
Double
getOpernumber
()
{
return
opernumber
;
public
void
setOpernumber
(
Double
opernumber
)
{
}
this
.
opernumber
=
opernumber
;
}
public
void
setOpernumber
(
Double
opernumber
)
{
this
.
opernumber
=
opernumber
;
public
Double
getBasicnumber
()
{
}
return
basicnumber
;
}
public
Double
getBasicnumber
()
{
return
basicnumber
;
public
void
setBasicnumber
(
Double
basicnumber
)
{
}
this
.
basicnumber
=
basicnumber
;
}
public
void
setBasicnumber
(
Double
basicnumber
)
{
this
.
basicnumber
=
basicnumber
;
public
Double
getUnitprice
()
{
}
return
unitprice
;
}
public
Double
getUnitprice
()
{
return
unitprice
;
public
void
setUnitprice
(
Double
unitprice
)
{
}
this
.
unitprice
=
unitprice
;
}
public
void
setUnitprice
(
Double
unitprice
)
{
this
.
unitprice
=
unitprice
;
public
Double
getTaxunitprice
()
{
}
return
taxunitprice
;
}
public
Double
getTaxunitprice
()
{
return
taxunitprice
;
public
void
setTaxunitprice
(
Double
taxunitprice
)
{
}
this
.
taxunitprice
=
taxunitprice
;
}
public
void
setTaxunitprice
(
Double
taxunitprice
)
{
this
.
taxunitprice
=
taxunitprice
;
public
Double
getAllprice
()
{
}
return
allprice
;
}
public
Double
getAllprice
()
{
return
allprice
;
public
void
setAllprice
(
Double
allprice
)
{
}
this
.
allprice
=
allprice
;
}
public
void
setAllprice
(
Double
allprice
)
{
this
.
allprice
=
allprice
;
public
String
getRemark
()
{
}
return
remark
;
}
public
String
getRemark
()
{
return
remark
;
public
void
setRemark
(
String
remark
)
{
}
this
.
remark
=
remark
;
}
public
void
setRemark
(
String
remark
)
{
this
.
remark
=
remark
;
public
String
getImg
()
{
}
return
img
;
}
public
String
getImg
()
{
return
img
;
public
void
setImg
(
String
img
)
{
}
this
.
img
=
img
;
}
public
void
setImg
(
String
img
)
{
this
.
img
=
img
;
public
Double
getIncidentals
()
{
}
return
incidentals
;
}
public
Double
getIncidentals
()
{
return
incidentals
;
public
void
setIncidentals
(
Double
incidentals
)
{
}
this
.
incidentals
=
incidentals
;
}
public
void
setIncidentals
(
Double
incidentals
)
{
this
.
incidentals
=
incidentals
;
public
Long
getDepotid
()
{
}
return
depotid
;
}
public
Long
getDepotid
()
{
return
depotid
;
public
void
setDepotid
(
Long
depotid
)
{
}
this
.
depotid
=
depotid
;
}
public
void
setDepotid
(
Long
depotid
)
{
this
.
depotid
=
depotid
;
public
Long
getAnotherdepotid
()
{
}
return
anotherdepotid
;
}
public
Long
getAnotherdepotid
()
{
return
anotherdepotid
;
public
void
setAnotherdepotid
(
Long
anotherdepotid
)
{
}
this
.
anotherdepotid
=
anotherdepotid
;
}
public
void
setAnotherdepotid
(
Long
anotherdepotid
)
{
this
.
anotherdepotid
=
anotherdepotid
;
public
Double
getTaxrate
()
{
}
return
taxrate
;
}
public
Double
getTaxrate
()
{
return
taxrate
;
public
void
setTaxrate
(
Double
taxrate
)
{
}
this
.
taxrate
=
taxrate
;
}
public
void
setTaxrate
(
Double
taxrate
)
{
this
.
taxrate
=
taxrate
;
public
Double
getTaxmoney
()
{
}
return
taxmoney
;
}
public
Double
getTaxmoney
()
{
return
taxmoney
;
public
void
setTaxmoney
(
Double
taxmoney
)
{
}
this
.
taxmoney
=
taxmoney
;
}
public
void
setTaxmoney
(
Double
taxmoney
)
{
this
.
taxmoney
=
taxmoney
;
public
Double
getTaxlastmoney
()
{
}
return
taxlastmoney
;
}
public
Double
getTaxlastmoney
()
{
return
taxlastmoney
;
public
void
setTaxlastmoney
(
Double
taxlastmoney
)
{
}
this
.
taxlastmoney
=
taxlastmoney
;
}
public
void
setTaxlastmoney
(
Double
taxlastmoney
)
{
this
.
taxlastmoney
=
taxlastmoney
;
public
String
getOtherfield1
()
{
}
return
otherfield1
;
}
public
String
getOtherfield1
()
{
return
otherfield1
;
public
void
setOtherfield1
(
String
otherfield1
)
{
}
this
.
otherfield1
=
otherfield1
;
}
public
void
setOtherfield1
(
String
otherfield1
)
{
this
.
otherfield1
=
otherfield1
;
public
String
getOtherfield2
()
{
}
return
otherfield2
;
}
public
String
getOtherfield2
()
{
return
otherfield2
;
public
void
setOtherfield2
(
String
otherfield2
)
{
}
this
.
otherfield2
=
otherfield2
;
}
public
void
setOtherfield2
(
String
otherfield2
)
{
this
.
otherfield2
=
otherfield2
;
public
String
getOtherfield3
()
{
}
return
otherfield3
;
}
public
String
getOtherfield3
()
{
return
otherfield3
;
public
void
setOtherfield3
(
String
otherfield3
)
{
}
this
.
otherfield3
=
otherfield3
;
}
public
void
setOtherfield3
(
String
otherfield3
)
{
this
.
otherfield3
=
otherfield3
;
public
String
getOtherfield4
()
{
}
return
otherfield4
;
}
public
String
getOtherfield4
()
{
return
otherfield4
;
public
void
setOtherfield4
(
String
otherfield4
)
{
}
this
.
otherfield4
=
otherfield4
;
}
public
void
setOtherfield4
(
String
otherfield4
)
{
this
.
otherfield4
=
otherfield4
;
public
String
getOtherfield5
()
{
}
return
otherfield5
;
}
public
String
getOtherfield5
()
{
return
otherfield5
;
public
void
setOtherfield5
(
String
otherfield5
)
{
}
this
.
otherfield5
=
otherfield5
;
}
public
void
setOtherfield5
(
String
otherfield5
)
{
this
.
otherfield5
=
otherfield5
;
public
String
getMtype
()
{
}
return
mtype
;
}
public
String
getMtype
()
{
return
mtype
;
public
void
setMtype
(
String
mtype
)
{
}
this
.
mtype
=
mtype
;
}
public
void
setMtype
(
String
mtype
)
{
this
.
mtype
=
mtype
;
public
String
getMName
()
{
}
return
MName
;
}
public
Long
getMId
()
{
return
MId
;
public
void
setMName
(
String
MName
)
{
}
this
.
MName
=
MName
;
}
public
void
setMId
(
Long
MId
)
{
this
.
MId
=
MId
;
public
String
getMModel
()
{
}
return
MModel
;
}
public
String
getMName
()
{
return
MName
;
public
void
setMModel
(
String
MModel
)
{
}
this
.
MModel
=
MModel
;
}
public
void
setMName
(
String
MName
)
{
this
.
MName
=
MName
;
public
String
getMaterialUnit
()
{
}
return
MaterialUnit
;
}
public
String
getMModel
()
{
return
MModel
;
public
void
setMaterialUnit
(
String
materialUnit
)
{
}
MaterialUnit
=
materialUnit
;
}
public
void
setMModel
(
String
MModel
)
{
this
.
MModel
=
MModel
;
public
String
getMColor
()
{
}
return
MColor
;
}
public
String
getMaterialUnit
()
{
return
MaterialUnit
;
public
void
setMColor
(
String
MColor
)
{
}
this
.
MColor
=
MColor
;
}
public
void
setMaterialUnit
(
String
materialUnit
)
{
MaterialUnit
=
materialUnit
;
public
String
getMStandard
()
{
}
return
MStandard
;
}
public
String
getMColor
()
{
return
MColor
;
public
void
setMStandard
(
String
MStandard
)
{
}
this
.
MStandard
=
MStandard
;
}
public
void
setMColor
(
String
MColor
)
{
this
.
MColor
=
MColor
;
public
String
getMMfrs
()
{
}
return
MMfrs
;
}
public
String
getMStandard
()
{
return
MStandard
;
public
void
setMMfrs
(
String
MMfrs
)
{
}
this
.
MMfrs
=
MMfrs
;
}
public
void
setMStandard
(
String
MStandard
)
{
this
.
MStandard
=
MStandard
;
public
String
getMOtherField1
()
{
}
return
MOtherField1
;
}
public
String
getMMfrs
()
{
return
MMfrs
;
public
void
setMOtherField1
(
String
MOtherField1
)
{
}
this
.
MOtherField1
=
MOtherField1
;
}
public
void
setMMfrs
(
String
MMfrs
)
{
this
.
MMfrs
=
MMfrs
;
public
String
getMOtherField2
()
{
}
return
MOtherField2
;
}
public
String
getMOtherField1
()
{
return
MOtherField1
;
public
void
setMOtherField2
(
String
MOtherField2
)
{
}
this
.
MOtherField2
=
MOtherField2
;
}
public
void
setMOtherField1
(
String
MOtherField1
)
{
this
.
MOtherField1
=
MOtherField1
;
public
String
getMOtherField3
()
{
}
return
MOtherField3
;
}
public
String
getMOtherField2
()
{
return
MOtherField2
;
public
void
setMOtherField3
(
String
MOtherField3
)
{
}
this
.
MOtherField3
=
MOtherField3
;
}
public
void
setMOtherField2
(
String
MOtherField2
)
{
this
.
MOtherField2
=
MOtherField2
;
public
String
getDepotName
()
{
}
return
DepotName
;
}
public
String
getMOtherField3
()
{
return
MOtherField3
;
public
void
setDepotName
(
String
depotName
)
{
}
DepotName
=
depotName
;
}
public
void
setMOtherField3
(
String
MOtherField3
)
{
this
.
MOtherField3
=
MOtherField3
;
public
String
getAnotherDepotName
()
{
}
return
AnotherDepotName
;
}
public
String
getDepotName
()
{
return
DepotName
;
public
void
setAnotherDepotName
(
String
anotherDepotName
)
{
}
AnotherDepotName
=
anotherDepotName
;
}
public
void
setDepotName
(
String
depotName
)
{
DepotName
=
depotName
;
public
Long
getUnitId
()
{
}
return
UnitId
;
}
public
String
getAnotherDepotName
()
{
return
AnotherDepotName
;
public
void
setUnitId
(
Long
unitId
)
{
}
UnitId
=
unitId
;
}
public
void
setAnotherDepotName
(
String
anotherDepotName
)
{
AnotherDepotName
=
anotherDepotName
;
public
String
getUName
()
{
}
return
UName
;
}
public
Long
getUnitId
()
{
return
UnitId
;
public
void
setUName
(
String
UName
)
{
}
this
.
UName
=
UName
;
}
public
void
setUnitId
(
Long
unitId
)
{
UnitId
=
unitId
;
}
public
String
getUName
()
{
return
UName
;
}
public
void
setUName
(
String
UName
)
{
this
.
UName
=
UName
;
}
}
}
\ No newline at end of file
src/main/java/com/jsh/erp/datasource/mappers/MaterialMapper.java
View file @
693a7558
package
com.jsh.erp.datasource.mappers
;
package
com.jsh.erp.datasource.mappers
;
import
com.jsh.erp.datasource.entities.Material
;
import
com.jsh.erp.datasource.entities.Material
;
import
com.jsh.erp.datasource.entities.MaterialExample
;
import
com.jsh.erp.datasource.entities.MaterialExample
;
import
java.util.List
;
import
java.util.List
;
import
com.jsh.erp.datasource.entities.MaterialVo4Unit
;
import
com.jsh.erp.datasource.entities.MaterialVo4Unit
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
public
interface
MaterialMapper
{
public
interface
MaterialMapper
{
/**
/**
* This method was generated by MyBatis Generator.
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material
* This method corresponds to the database table jsh_material
*
*
* @mbggenerated
* @mbggenerated
*/
*/
int
countByExample
(
MaterialExample
example
);
int
countByExample
(
MaterialExample
example
);
/**
/**
* This method was generated by MyBatis Generator.
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material
* This method corresponds to the database table jsh_material
*
*
* @mbggenerated
* @mbggenerated
*/
*/
int
deleteByExample
(
MaterialExample
example
);
int
deleteByExample
(
MaterialExample
example
);
/**
/**
* This method was generated by MyBatis Generator.
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material
* This method corresponds to the database table jsh_material
*
*
* @mbggenerated
* @mbggenerated
*/
*/
int
deleteByPrimaryKey
(
Long
id
);
int
deleteByPrimaryKey
(
Long
id
);
/**
/**
* This method was generated by MyBatis Generator.
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material
* This method corresponds to the database table jsh_material
*
*
* @mbggenerated
* @mbggenerated
*/
*/
int
insert
(
Material
record
);
int
insert
(
Material
record
);
/**
/**
* This method was generated by MyBatis Generator.
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material
* This method corresponds to the database table jsh_material
*
*
* @mbggenerated
* @mbggenerated
*/
*/
int
insertSelective
(
Material
record
);
int
insertSelective
(
Material
record
);
/**
/**
* This method was generated by MyBatis Generator.
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material
* This method corresponds to the database table jsh_material
*
*
* @mbggenerated
* @mbggenerated
*/
*/
List
<
Material
>
selectByExample
(
MaterialExample
example
);
List
<
Material
>
selectByExample
(
MaterialExample
example
);
/**
/**
* This method was generated by MyBatis Generator.
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material
* This method corresponds to the database table jsh_material
*
*
* @mbggenerated
* @mbggenerated
*/
*/
Material
selectByPrimaryKey
(
Long
id
);
Material
selectByPrimaryKey
(
Long
id
);
/**
/**
* This method was generated by MyBatis Generator.
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material
* This method corresponds to the database table jsh_material
*
*
* @mbggenerated
* @mbggenerated
*/
*/
int
updateByExampleSelective
(
@Param
(
"record"
)
Material
record
,
@Param
(
"example"
)
MaterialExample
example
);
int
updateByExampleSelective
(
@Param
(
"record"
)
Material
record
,
@Param
(
"example"
)
MaterialExample
example
);
/**
/**
* This method was generated by MyBatis Generator.
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material
* This method corresponds to the database table jsh_material
*
*
* @mbggenerated
* @mbggenerated
*/
*/
int
updateByExample
(
@Param
(
"record"
)
Material
record
,
@Param
(
"example"
)
MaterialExample
example
);
int
updateByExample
(
@Param
(
"record"
)
Material
record
,
@Param
(
"example"
)
MaterialExample
example
);
/**
/**
* This method was generated by MyBatis Generator.
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material
* This method corresponds to the database table jsh_material
*
*
* @mbggenerated
* @mbggenerated
*/
*/
int
updateByPrimaryKeySelective
(
Material
record
);
int
updateByPrimaryKeySelective
(
Material
record
);
/**
/**
* This method was generated by MyBatis Generator.
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_material
* This method corresponds to the database table jsh_material
*
*
* @mbggenerated
* @mbggenerated
*/
*/
int
updateByPrimaryKey
(
Material
record
);
int
updateByPrimaryKey
(
Material
record
);
List
<
MaterialVo4Unit
>
selectByConditionMaterial
(
List
<
MaterialVo4Unit
>
selectByConditionMaterial
(
@Param
(
"name"
)
String
name
,
@Param
(
"name"
)
String
name
,
@Param
(
"model"
)
String
model
,
@Param
(
"model"
)
String
model
,
@Param
(
"categoryId"
)
Long
categoryId
,
@Param
(
"categoryId"
)
Long
categoryId
,
@Param
(
"categoryIds"
)
String
categoryIds
,
@Param
(
"categoryIds"
)
String
categoryIds
,
@Param
(
"mpList"
)
String
mpList
,
@Param
(
"mpList"
)
String
mpList
,
@Param
(
"offset"
)
Integer
offset
,
@Param
(
"offset"
)
Integer
offset
,
@Param
(
"rows"
)
Integer
rows
);
@Param
(
"rows"
)
Integer
rows
);
int
countsByMaterial
(
int
countsByMaterial
(
@Param
(
"name"
)
String
name
,
@Param
(
"name"
)
String
name
,
@Param
(
"model"
)
String
model
,
@Param
(
"model"
)
String
model
,
@Param
(
"categoryId"
)
Long
categoryId
,
@Param
(
"categoryId"
)
Long
categoryId
,
@Param
(
"categoryIds"
)
String
categoryIds
,
@Param
(
"categoryIds"
)
String
categoryIds
,
@Param
(
"mpList"
)
String
mpList
);
@Param
(
"mpList"
)
String
mpList
);
String
findUnitName
(
@Param
(
"mId"
)
Long
mId
);
String
findUnitName
(
@Param
(
"mId"
)
Long
mId
);
List
<
MaterialVo4Unit
>
findById
(
@Param
(
"id"
)
Long
id
);
List
<
MaterialVo4Unit
>
findById
(
@Param
(
"id"
)
Long
id
);
List
<
MaterialVo4Unit
>
findBySelect
();
List
<
MaterialVo4Unit
>
findBySelect
();
int
updatePriceNullByPrimaryKey
(
Long
id
);
int
updatePriceNullByPrimaryKey
(
Long
id
);
int
updateUnitIdNullByPrimaryKey
(
Long
id
);
int
updateUnitIdNullByPrimaryKey
(
Long
id
);
List
<
MaterialVo4Unit
>
findByAll
(
@Param
(
"name"
)
String
name
,
@Param
(
"model"
)
String
model
,
@Param
(
"categoryId"
)
Long
categoryId
,
@Param
(
"categoryIds"
)
String
categoryIds
);
}
}
\ No newline at end of file
src/main/java/com/jsh/erp/datasource/mappers/SupplierMapper.java
View file @
693a7558
package
com.jsh.erp.datasource.mappers
;
package
com.jsh.erp.datasource.mappers
;
import
com.jsh.erp.datasource.entities.Supplier
;
import
com.jsh.erp.datasource.entities.Supplier
;
import
com.jsh.erp.datasource.entities.SupplierExample
;
import
com.jsh.erp.datasource.entities.SupplierExample
;
import
java.util.List
;
import
java.util.List
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
public
interface
SupplierMapper
{
public
interface
SupplierMapper
{
/**
/**
* This method was generated by MyBatis Generator.
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_supplier
* This method corresponds to the database table jsh_supplier
*
*
* @mbggenerated
* @mbggenerated
*/
*/
int
countByExample
(
SupplierExample
example
);
int
countByExample
(
SupplierExample
example
);
/**
/**
* This method was generated by MyBatis Generator.
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_supplier
* This method corresponds to the database table jsh_supplier
*
*
* @mbggenerated
* @mbggenerated
*/
*/
int
deleteByExample
(
SupplierExample
example
);
int
deleteByExample
(
SupplierExample
example
);
/**
/**
* This method was generated by MyBatis Generator.
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_supplier
* This method corresponds to the database table jsh_supplier
*
*
* @mbggenerated
* @mbggenerated
*/
*/
int
deleteByPrimaryKey
(
Long
id
);
int
deleteByPrimaryKey
(
Long
id
);
/**
/**
* This method was generated by MyBatis Generator.
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_supplier
* This method corresponds to the database table jsh_supplier
*
*
* @mbggenerated
* @mbggenerated
*/
*/
int
insert
(
Supplier
record
);
int
insert
(
Supplier
record
);
/**
/**
* This method was generated by MyBatis Generator.
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_supplier
* This method corresponds to the database table jsh_supplier
*
*
* @mbggenerated
* @mbggenerated
*/
*/
int
insertSelective
(
Supplier
record
);
int
insertSelective
(
Supplier
record
);
/**
/**
* This method was generated by MyBatis Generator.
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_supplier
* This method corresponds to the database table jsh_supplier
*
*
* @mbggenerated
* @mbggenerated
*/
*/
List
<
Supplier
>
selectByExample
(
SupplierExample
example
);
List
<
Supplier
>
selectByExample
(
SupplierExample
example
);
/**
/**
* This method was generated by MyBatis Generator.
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_supplier
* This method corresponds to the database table jsh_supplier
*
*
* @mbggenerated
* @mbggenerated
*/
*/
Supplier
selectByPrimaryKey
(
Long
id
);
Supplier
selectByPrimaryKey
(
Long
id
);
/**
/**
* This method was generated by MyBatis Generator.
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_supplier
* This method corresponds to the database table jsh_supplier
*
*
* @mbggenerated
* @mbggenerated
*/
*/
int
updateByExampleSelective
(
@Param
(
"record"
)
Supplier
record
,
@Param
(
"example"
)
SupplierExample
example
);
int
updateByExampleSelective
(
@Param
(
"record"
)
Supplier
record
,
@Param
(
"example"
)
SupplierExample
example
);
/**
/**
* This method was generated by MyBatis Generator.
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_supplier
* This method corresponds to the database table jsh_supplier
*
*
* @mbggenerated
* @mbggenerated
*/
*/
int
updateByExample
(
@Param
(
"record"
)
Supplier
record
,
@Param
(
"example"
)
SupplierExample
example
);
int
updateByExample
(
@Param
(
"record"
)
Supplier
record
,
@Param
(
"example"
)
SupplierExample
example
);
/**
/**
* This method was generated by MyBatis Generator.
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_supplier
* This method corresponds to the database table jsh_supplier
*
*
* @mbggenerated
* @mbggenerated
*/
*/
int
updateByPrimaryKeySelective
(
Supplier
record
);
int
updateByPrimaryKeySelective
(
Supplier
record
);
/**
/**
* This method was generated by MyBatis Generator.
* This method was generated by MyBatis Generator.
* This method corresponds to the database table jsh_supplier
* This method corresponds to the database table jsh_supplier
*
*
* @mbggenerated
* @mbggenerated
*/
*/
int
updateByPrimaryKey
(
Supplier
record
);
int
updateByPrimaryKey
(
Supplier
record
);
List
<
Supplier
>
selectByConditionSupplier
(
List
<
Supplier
>
selectByConditionSupplier
(
@Param
(
"supplier"
)
String
supplier
,
@Param
(
"supplier"
)
String
supplier
,
@Param
(
"type"
)
String
type
,
@Param
(
"type"
)
String
type
,
@Param
(
"phonenum"
)
String
phonenum
,
@Param
(
"phonenum"
)
String
phonenum
,
@Param
(
"telephone"
)
String
telephone
,
@Param
(
"telephone"
)
String
telephone
,
@Param
(
"description"
)
String
description
,
@Param
(
"description"
)
String
description
,
@Param
(
"offset"
)
Integer
offset
,
@Param
(
"offset"
)
Integer
offset
,
@Param
(
"rows"
)
Integer
rows
);
@Param
(
"rows"
)
Integer
rows
);
int
countsBySupplier
(
int
countsBySupplier
(
@Param
(
"supplier"
)
String
supplier
,
@Param
(
"supplier"
)
String
supplier
,
@Param
(
"type"
)
String
type
,
@Param
(
"type"
)
String
type
,
@Param
(
"phonenum"
)
String
phonenum
,
@Param
(
"phonenum"
)
String
phonenum
,
@Param
(
"telephone"
)
String
telephone
,
@Param
(
"telephone"
)
String
telephone
,
@Param
(
"description"
)
String
description
);
@Param
(
"description"
)
String
description
);
List
<
Supplier
>
findByAll
(
@Param
(
"supplier"
)
String
supplier
,
@Param
(
"type"
)
String
type
,
@Param
(
"phonenum"
)
String
phonenum
,
@Param
(
"telephone"
)
String
telephone
,
@Param
(
"description"
)
String
description
);
}
}
\ No newline at end of file
src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java
View file @
693a7558
...
@@ -84,14 +84,18 @@ public class DepotHeadService {
...
@@ -84,14 +84,18 @@ public class DepotHeadService {
}
}
depotHead
.
setCreatetime
(
new
Timestamp
(
System
.
currentTimeMillis
()));
depotHead
.
setCreatetime
(
new
Timestamp
(
System
.
currentTimeMillis
()));
depotHead
.
setStatus
(
false
);
depotHead
.
setStatus
(
false
);
return
depotHeadMapper
.
insert
Selective
(
depotHead
);
return
depotHeadMapper
.
insert
(
depotHead
);
}
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
updateDepotHead
(
String
beanJson
,
Long
id
)
{
public
int
updateDepotHead
(
String
beanJson
,
Long
id
)
{
DepotHead
dh
=
depotHeadMapper
.
selectByPrimaryKey
(
id
);
DepotHead
depotHead
=
JSONObject
.
parseObject
(
beanJson
,
DepotHead
.
class
);
DepotHead
depotHead
=
JSONObject
.
parseObject
(
beanJson
,
DepotHead
.
class
);
depotHead
.
setId
(
id
);
depotHead
.
setId
(
id
);
return
depotHeadMapper
.
updateByPrimaryKeySelective
(
depotHead
);
depotHead
.
setStatus
(
dh
.
getStatus
());
depotHead
.
setCreatetime
(
dh
.
getCreatetime
());
depotHead
.
setOperpersonname
(
dh
.
getOperpersonname
());
return
depotHeadMapper
.
updateByPrimaryKey
(
depotHead
);
}
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
...
...
src/main/java/com/jsh/erp/service/material/MaterialService.java
View file @
693a7558
...
@@ -5,6 +5,7 @@ import com.jsh.erp.datasource.entities.Material;
...
@@ -5,6 +5,7 @@ import com.jsh.erp.datasource.entities.Material;
import
com.jsh.erp.datasource.entities.MaterialExample
;
import
com.jsh.erp.datasource.entities.MaterialExample
;
import
com.jsh.erp.datasource.entities.MaterialVo4Unit
;
import
com.jsh.erp.datasource.entities.MaterialVo4Unit
;
import
com.jsh.erp.datasource.mappers.MaterialMapper
;
import
com.jsh.erp.datasource.mappers.MaterialMapper
;
import
com.jsh.erp.utils.BaseResponseInfo
;
import
com.jsh.erp.utils.StringUtil
;
import
com.jsh.erp.utils.StringUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -14,7 +15,9 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -14,7 +15,9 @@ import org.springframework.transaction.annotation.Transactional;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
@Service
@Service
public
class
MaterialService
{
public
class
MaterialService
{
...
@@ -160,4 +163,32 @@ public class MaterialService {
...
@@ -160,4 +163,32 @@ public class MaterialService {
return
materialMapper
.
selectByExample
(
example
);
return
materialMapper
.
selectByExample
(
example
);
}
}
public
List
<
MaterialVo4Unit
>
findByAll
(
String
name
,
String
model
,
Long
categoryId
,
String
categoryIds
)
{
List
<
MaterialVo4Unit
>
resList
=
new
ArrayList
<
MaterialVo4Unit
>();
List
<
MaterialVo4Unit
>
list
=
materialMapper
.
findByAll
(
name
,
model
,
categoryId
,
categoryIds
);
if
(
null
!=
list
)
{
for
(
MaterialVo4Unit
m
:
list
)
{
resList
.
add
(
m
);
}
}
return
resList
;
}
public
BaseResponseInfo
importExcel
(
List
<
Material
>
mList
)
throws
Exception
{
BaseResponseInfo
info
=
new
BaseResponseInfo
();
Map
<
String
,
Object
>
data
=
new
HashMap
<
String
,
Object
>();
try
{
for
(
Material
m:
mList
)
{
materialMapper
.
insertSelective
(
m
);
}
info
.
code
=
200
;
data
.
put
(
"message"
,
"成功"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
info
.
code
=
500
;
data
.
put
(
"message"
,
e
.
getMessage
());
}
info
.
data
=
data
;
return
info
;
}
}
}
src/main/java/com/jsh/erp/service/supplier/SupplierService.java
View file @
693a7558
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.jsh.erp.datasource.entities.Supplier
;
import
com.jsh.erp.datasource.entities.Supplier
;
import
com.jsh.erp.datasource.entities.SupplierExample
;
import
com.jsh.erp.datasource.entities.SupplierExample
;
import
com.jsh.erp.datasource.mappers.SupplierMapper
;
import
com.jsh.erp.datasource.mappers.SupplierMapper
;
import
com.jsh.erp.utils.BaseResponseInfo
;
import
com.jsh.erp.utils.StringUtil
;
import
com.jsh.erp.utils.StringUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -12,7 +13,9 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -12,7 +13,9 @@ import org.springframework.transaction.annotation.Transactional;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
@Service
@Service
public
class
SupplierService
{
public
class
SupplierService
{
...
@@ -123,4 +126,26 @@ public class SupplierService {
...
@@ -123,4 +126,26 @@ public class SupplierService {
List
<
Supplier
>
list
=
supplierMapper
.
selectByExample
(
example
);
List
<
Supplier
>
list
=
supplierMapper
.
selectByExample
(
example
);
return
list
;
return
list
;
}
}
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
;
}
}
}
src/main/java/com/jsh/erp/utils/ExcelUtils.java
0 → 100644
View file @
693a7558
package
com.jsh.erp.utils
;
import
java.io.File
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
com.alibaba.druid.util.StringUtils
;
import
jxl.Cell
;
import
jxl.Sheet
;
import
jxl.Workbook
;
import
jxl.format.*
;
import
jxl.write.Label
;
import
jxl.write.WritableCellFormat
;
import
jxl.write.WritableFont
;
import
jxl.write.WritableSheet
;
import
jxl.write.WritableWorkbook
;
public
class
ExcelUtils
{
public
static
WritableFont
arial14font
=
null
;
public
static
File
exportObjects
(
String
fileName
,
String
[]
names
,
String
title
,
List
<
String
[]>
objects
)
throws
Exception
{
File
excelFile
=
new
File
(
"fileName.xls"
);
WritableWorkbook
wtwb
=
Workbook
.
createWorkbook
(
excelFile
);
WritableSheet
sheet
=
wtwb
.
createSheet
(
title
,
0
);
sheet
.
getSettings
().
setDefaultColumnWidth
(
20
);
WritableFont
wfont
=
new
WritableFont
(
WritableFont
.
createFont
(
"楷书"
),
15
);
WritableCellFormat
format
=
new
WritableCellFormat
(
wfont
);
WritableFont
wfc
=
new
WritableFont
(
WritableFont
.
ARIAL
,
20
,
WritableFont
.
BOLD
,
false
,
UnderlineStyle
.
NO_UNDERLINE
,
jxl
.
format
.
Colour
.
BLACK
);
WritableCellFormat
wcfFC
=
new
WritableCellFormat
(
wfc
);
wcfFC
.
setAlignment
(
Alignment
.
CENTRE
);
wcfFC
.
setVerticalAlignment
(
VerticalAlignment
.
CENTRE
);
// CellView cellView = new CellView();
// cellView.setAutosize(true); //设置自动大小
format
.
setAlignment
(
Alignment
.
LEFT
);
format
.
setVerticalAlignment
(
VerticalAlignment
.
TOP
);
sheet
.
mergeCells
(
0
,
0
,
names
.
length
-
1
,
0
);
sheet
.
addCell
(
new
Label
(
0
,
0
,
title
,
wcfFC
));
int
rowNum
=
2
;
for
(
int
i
=
0
;
i
<
names
.
length
;
i
++)
{
sheet
.
addCell
(
new
Label
(
i
,
1
,
names
[
i
],
format
));
}
for
(
int
j
=
0
;
j
<
objects
.
size
();
j
++)
{
String
[]
obj
=
objects
.
get
(
j
);
for
(
int
h
=
0
;
h
<
obj
.
length
;
h
++)
{
sheet
.
addCell
(
new
Label
(
h
,
rowNum
,
obj
[
h
],
format
));
}
rowNum
=
rowNum
+
1
;
}
wtwb
.
write
();
wtwb
.
close
();
return
excelFile
;
}
/**
* 导出excel,不需要第一行的title
*
* @param fileName
* @param names
* @param title
* @param objects
* @return
* @throws Exception
*/
public
static
File
exportObjectsWithoutTitle
(
String
fileName
,
String
[]
names
,
String
title
,
List
<
String
[]>
objects
)
throws
Exception
{
File
excelFile
=
new
File
(
fileName
);
WritableWorkbook
wtwb
=
Workbook
.
createWorkbook
(
excelFile
);
WritableSheet
sheet
=
wtwb
.
createSheet
(
title
,
0
);
sheet
.
getSettings
().
setDefaultColumnWidth
(
20
);
// 第一行的格式
WritableFont
wfc
=
new
WritableFont
(
WritableFont
.
ARIAL
,
15
,
WritableFont
.
BOLD
,
false
,
UnderlineStyle
.
NO_UNDERLINE
,
jxl
.
format
.
Colour
.
BLACK
);
WritableCellFormat
wcfFC
=
new
WritableCellFormat
(
wfc
);
wcfFC
.
setVerticalAlignment
(
VerticalAlignment
.
CENTRE
);
// 设置字体以及单元格格式
WritableFont
wfont
=
new
WritableFont
(
WritableFont
.
createFont
(
"楷书"
),
15
);
WritableCellFormat
format
=
new
WritableCellFormat
(
wfont
);
format
.
setAlignment
(
Alignment
.
LEFT
);
format
.
setVerticalAlignment
(
VerticalAlignment
.
TOP
);
// 第一行写入标题
for
(
int
i
=
0
;
i
<
names
.
length
;
i
++)
{
sheet
.
addCell
(
new
Label
(
i
,
0
,
names
[
i
],
wcfFC
));
}
// 其余行依次写入数据
int
rowNum
=
1
;
for
(
int
j
=
0
;
j
<
objects
.
size
();
j
++)
{
String
[]
obj
=
objects
.
get
(
j
);
for
(
int
h
=
0
;
h
<
obj
.
length
;
h
++)
{
sheet
.
addCell
(
new
Label
(
h
,
rowNum
,
obj
[
h
],
format
));
}
rowNum
=
rowNum
+
1
;
}
wtwb
.
write
();
wtwb
.
close
();
return
excelFile
;
}
public
static
String
createTempFile
(
String
[]
names
,
String
title
,
List
<
String
[]>
objects
)
throws
Exception
{
File
excelFile
=
File
.
createTempFile
(
System
.
currentTimeMillis
()
+
""
,
".xls"
);
WritableWorkbook
wtwb
=
Workbook
.
createWorkbook
(
excelFile
);
WritableSheet
sheet
=
wtwb
.
createSheet
(
title
,
0
);
sheet
.
getSettings
().
setDefaultColumnWidth
(
20
);
WritableFont
wfont
=
new
WritableFont
(
WritableFont
.
createFont
(
"楷书"
),
15
);
WritableCellFormat
format
=
new
WritableCellFormat
(
wfont
);
WritableFont
wfc
=
new
WritableFont
(
WritableFont
.
ARIAL
,
20
,
WritableFont
.
BOLD
,
false
,
UnderlineStyle
.
NO_UNDERLINE
,
jxl
.
format
.
Colour
.
BLACK
);
WritableCellFormat
wcfFC
=
new
WritableCellFormat
(
wfc
);
wcfFC
.
setAlignment
(
Alignment
.
CENTRE
);
wcfFC
.
setVerticalAlignment
(
VerticalAlignment
.
CENTRE
);
// CellView cellView = new CellView();
// cellView.setAutosize(true); //设置自动大小
format
.
setAlignment
(
Alignment
.
LEFT
);
format
.
setVerticalAlignment
(
VerticalAlignment
.
TOP
);
sheet
.
mergeCells
(
0
,
0
,
names
.
length
-
1
,
0
);
sheet
.
addCell
(
new
Label
(
0
,
0
,
title
,
wcfFC
));
int
rowNum
=
2
;
for
(
int
i
=
0
;
i
<
names
.
length
;
i
++)
{
sheet
.
addCell
(
new
Label
(
i
,
1
,
names
[
i
],
format
));
}
for
(
int
j
=
0
;
j
<
objects
.
size
();
j
++)
{
String
[]
obj
=
objects
.
get
(
j
);
for
(
int
h
=
0
;
h
<
obj
.
length
;
h
++)
{
sheet
.
addCell
(
new
Label
(
h
,
rowNum
,
obj
[
h
],
format
));
}
rowNum
=
rowNum
+
1
;
}
wtwb
.
write
();
wtwb
.
close
();
return
excelFile
.
getName
();
}
public
static
String
createCheckRandomTempFile
(
String
[]
names
,
String
title
,
List
<
String
[]>
objects
,
Map
<
String
,
String
>
infoMap
)
throws
Exception
{
File
excelFile
=
File
.
createTempFile
(
System
.
currentTimeMillis
()
+
""
,
".xls"
);
WritableWorkbook
wtwb
=
Workbook
.
createWorkbook
(
excelFile
);
WritableSheet
sheet
=
wtwb
.
createSheet
(
title
,
0
);
sheet
.
getSettings
().
setDefaultColumnWidth
(
20
);
WritableFont
wfont
=
new
WritableFont
(
WritableFont
.
createFont
(
"楷书"
),
14
);
WritableCellFormat
format
=
new
WritableCellFormat
(
wfont
);
format
.
setBorder
(
Border
.
ALL
,
BorderLineStyle
.
THIN
);
format
.
setAlignment
(
Alignment
.
CENTRE
);
format
.
setVerticalAlignment
(
VerticalAlignment
.
CENTRE
);
WritableFont
wfc
=
new
WritableFont
(
WritableFont
.
ARIAL
,
20
,
WritableFont
.
BOLD
,
false
,
UnderlineStyle
.
NO_UNDERLINE
,
jxl
.
format
.
Colour
.
BLACK
);
WritableCellFormat
wcfFC
=
new
WritableCellFormat
(
wfc
);
wcfFC
.
setAlignment
(
Alignment
.
LEFT
);
wcfFC
.
setVerticalAlignment
(
VerticalAlignment
.
CENTRE
);
WritableFont
nameWfc
=
new
WritableFont
(
WritableFont
.
ARIAL
,
14
,
WritableFont
.
BOLD
,
false
,
UnderlineStyle
.
NO_UNDERLINE
,
jxl
.
format
.
Colour
.
BLACK
);
WritableCellFormat
nameFormat
=
new
WritableCellFormat
(
nameWfc
);
nameFormat
.
setBorder
(
Border
.
ALL
,
BorderLineStyle
.
THIN
);
nameFormat
.
setAlignment
(
Alignment
.
CENTRE
);
nameFormat
.
setVerticalAlignment
(
VerticalAlignment
.
CENTRE
);
WritableCellFormat
infoFormat
=
new
WritableCellFormat
(
wfont
);
infoFormat
.
setAlignment
(
Alignment
.
LEFT
);
infoFormat
.
setVerticalAlignment
(
VerticalAlignment
.
CENTRE
);
sheet
.
mergeCells
(
0
,
0
,
names
.
length
-
1
,
0
);
sheet
.
addCell
(
new
Label
(
0
,
0
,
infoMap
.
get
(
"title"
),
wcfFC
));
sheet
.
addCell
(
new
Label
(
0
,
2
,
infoMap
.
get
(
"info"
),
infoFormat
));
sheet
.
addCell
(
new
Label
(
2
,
2
,
infoMap
.
get
(
"dvrnvr"
),
infoFormat
));
sheet
.
addCell
(
new
Label
(
4
,
2
,
infoMap
.
get
(
"char"
),
infoFormat
));
sheet
.
addCell
(
new
Label
(
0
,
3
,
infoMap
.
get
(
"infoPercent"
),
infoFormat
));
sheet
.
addCell
(
new
Label
(
2
,
3
,
infoMap
.
get
(
"dvrnvrPercent"
),
infoFormat
));
sheet
.
addCell
(
new
Label
(
4
,
3
,
infoMap
.
get
(
"charPercent"
),
infoFormat
));
int
rowNum
=
5
;
for
(
int
i
=
0
;
i
<
names
.
length
;
i
++)
{
sheet
.
addCell
(
new
Label
(
i
,
4
,
names
[
i
],
nameFormat
));
}
for
(
int
j
=
0
;
j
<
objects
.
size
();
j
++)
{
String
[]
obj
=
objects
.
get
(
j
);
for
(
int
h
=
0
;
h
<
obj
.
length
;
h
++)
{
sheet
.
addCell
(
new
Label
(
h
,
rowNum
,
obj
[
h
],
format
));
}
rowNum
=
rowNum
+
1
;
}
wtwb
.
write
();
wtwb
.
close
();
return
excelFile
.
getName
();
}
public
static
String
getContent
(
Sheet
src
,
int
rowNum
,
int
colNum
)
{
return
src
.
getRow
(
rowNum
)[
colNum
].
getContents
().
trim
();
}
/**
* 从第i行开始到最后检测指定列的唯一性
*
* @param src
* @param colNum
* @param fromRow
* 起始行
* @return
*/
public
static
Boolean
checkUnique
(
Sheet
src
,
int
colNum
,
int
fromRow
)
{
Cell
[]
colCells
=
src
.
getColumn
(
colNum
);
Set
<
String
>
set
=
new
HashSet
<
String
>();
for
(
int
i
=
fromRow
;
i
<
colCells
.
length
;
i
++)
{
if
(!
StringUtils
.
isEmpty
(
colCells
[
i
].
getContents
())
&&
!
set
.
add
(
colCells
[
i
].
getContents
()))
{
return
false
;
}
}
return
true
;
}
public
static
File
getTempFile
(
String
fileName
)
{
String
dir
=
System
.
getProperty
(
"java.io.tmpdir"
);
// 获取系统临时目录
return
new
File
(
dir
+
File
.
separator
+
fileName
);
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
msg
=
"12345"
;
System
.
out
.
println
(
msg
.
indexOf
(
"@"
));
}
}
src/main/java/com/jsh/erp/utils/ExportExecUtil.java
0 → 100644
View file @
693a7558
package
com.jsh.erp.utils
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.OutputStream
;
public
class
ExportExecUtil
{
public
static
void
showExec
(
File
excelFile
,
String
fileName
,
HttpServletResponse
response
)
throws
Exception
{
response
.
setContentType
(
"application/octet-stream"
);
fileName
=
new
String
(
fileName
.
getBytes
(
"gbk"
),
"ISO8859_1"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename=\""
+
fileName
+
".xls"
+
"\""
);
FileInputStream
fis
=
new
FileInputStream
(
excelFile
);
OutputStream
out
=
response
.
getOutputStream
();
int
SIZE
=
1024
*
1024
;
byte
[]
bytes
=
new
byte
[
SIZE
];
int
LENGTH
=
-
1
;
while
((
LENGTH
=
fis
.
read
(
bytes
))
!=
-
1
){
out
.
write
(
bytes
,
0
,
LENGTH
);
}
out
.
flush
();
fis
.
close
();
}
}
src/main/java/com/jsh/erp/utils/FileUtils.java
0 → 100644
View file @
693a7558
package
com.jsh.erp.utils
;
import
com.alibaba.druid.util.StringUtils
;
import
java.io.*
;
import
java.util.*
;
/**
*
* 文件处理工具类
*
*/
public
class
FileUtils
{
/**
* 功 能: 创建文件夹
*
* @param path
* 参 数:要创建的文件夹名称
* @return 返回值: 如果成功true;否则false 如:FileUtils.mkdir("/usr/apps/upload/");
*/
public
static
boolean
makedir
(
String
path
)
{
File
file
=
new
File
(
path
);
if
(!
file
.
exists
())
return
file
.
mkdirs
();
else
return
true
;
}
/**
* 保存文件
*
* @param stream
* @param path
* 存放路径
* @param filename
* 文件名
* @throws IOException
*/
public
static
void
SaveFileFromInputStream
(
InputStream
stream
,
String
path
,
String
filename
)
throws
IOException
{
File
file
=
new
File
(
path
);
boolean
flag
=
true
;
if
(!
file
.
exists
()){
flag
=
file
.
mkdirs
();
}
if
(
flag
){
FileOutputStream
fs
=
new
FileOutputStream
(
new
File
(
path
+
filename
));
byte
[]
buffer
=
new
byte
[
1024
*
1024
];
int
byteread
=
0
;
while
((
byteread
=
stream
.
read
(
buffer
))
!=
-
1
)
{
fs
.
write
(
buffer
,
0
,
byteread
);
fs
.
flush
();
}
fs
.
close
();
stream
.
close
();
}
}
/**
* 列出某个目录下的所有文件,子目录不列出
* @param folderPath:文件夹路径
* @return
*/
public
static
List
<
String
>
listFile
(
String
folderPath
){
List
<
String
>
fileList
=
new
ArrayList
<
String
>();
//FileViewer.getListFiles(destPath, null, false);
File
f
=
new
File
(
folderPath
);
File
[]
t
=
f
.
listFiles
();
for
(
int
i
=
0
;
i
<
t
.
length
;
i
++){
fileList
.
add
(
t
[
i
].
getAbsolutePath
());
}
return
fileList
;
}
/**
* 判断文件是否存在
*
* @param fileName
* @return
*/
public
static
boolean
exists
(
String
fileName
)
{
File
file
=
new
File
(
fileName
);
if
(
file
.
exists
())
{
return
true
;
}
else
{
return
false
;
}
}
/**
* 取当前路径
*
* @return
*/
public
static
String
getCurrentPath
()
{
File
directory
=
new
File
(
"."
);
String
nowPath
=
""
;
try
{
nowPath
=
directory
.
getCanonicalFile
().
toString
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
nowPath
;
}
/**
* 获取文件扩展名
*
* @param fileName
* @return
* */
public
static
String
getFileExtendName
(
String
fileName
)
{
if
(
fileName
==
null
)
{
return
""
;
}
else
{
return
fileName
.
substring
(
fileName
.
lastIndexOf
(
"."
)
+
1
,
fileName
.
length
());
}
}
/**
* 创建一个新文件,如果存在则报错
*
* @param filePath
* @param fileName
* @return
*/
public
static
void
createFile
(
String
filePath
,
String
fileName
)
throws
RuntimeException
{
String
file
=
null
;
if
(
filePath
==
null
)
{
file
=
fileName
;
}
else
{
file
=
filePath
+
File
.
separator
+
fileName
;
}
createFile
(
file
);
}
/**
* 创建一个新文件(含路径),如果存在则报错
*
* @param fileName
* 含有路径的文件名
* @return
*/
public
static
void
createFile
(
String
fileName
)
throws
RuntimeException
{
File
f
=
new
File
(
fileName
);
if
(
f
.
exists
())
{
throw
new
RuntimeException
(
"FILE_EXIST_ERROR"
);
}
else
{
try
{
File
fileFolder
=
f
.
getParentFile
();
if
(!
fileFolder
.
exists
())
fileFolder
.
mkdirs
();
f
.
createNewFile
();
}
catch
(
IOException
ie
)
{
System
.
out
.
println
(
"文件"
+
fileName
+
"创建失败:"
+
ie
.
getMessage
());
throw
new
RuntimeException
(
"FILE_CREATE_ERROR"
);
}
}
}
/**
* 创建目录,如果存在则不创建
*
* @param path
* @return 返回结果null则创建成功,否则返回的是错误信息
* @return
*/
public
static
String
createDir
(
String
path
,
boolean
isCreateSubPah
)
{
String
msg
=
null
;
File
dir
=
new
File
(
path
);
if
(
dir
==
null
)
{
msg
=
"不能创建空目录"
;
return
msg
;
}
if
(
dir
.
isFile
())
{
msg
=
"已有同名文件存在"
;
return
msg
;
}
if
(!
dir
.
exists
())
{
if
(
isCreateSubPah
&&
!
dir
.
mkdirs
())
{
msg
=
"目录创建失败,原因不明"
;
}
else
if
(!
dir
.
mkdir
())
{
msg
=
"目录创建失败,原因不明"
;
}
}
return
msg
;
}
/**
* 删除指定目录或文件。 如果要删除是目录,同时删除子目录下所有的文件
*
* @file:File 目录
* */
public
static
void
delFileOrFolder
(
String
fileName
)
{
if
(!
exists
(
fileName
))
return
;
File
file
=
new
File
(
fileName
);
delFileOrFolder
(
file
);
}
/**
* 删除指定目录或文件。 如果要删除是目录,同时删除子目录下所有的文件
*
* @file:File 目录
* */
public
static
void
delFileOrFolder
(
File
file
)
{
if
(!
file
.
exists
())
return
;
if
(
file
.
isFile
())
{
file
.
delete
();
}
else
{
File
[]
sub
=
file
.
listFiles
();
if
(
sub
==
null
||
sub
.
length
<=
0
)
{
file
.
delete
();
}
else
{
for
(
int
i
=
0
;
i
<
sub
.
length
;
i
++)
{
delFileOrFolder
(
sub
[
i
]);
}
file
.
delete
();
}
}
}
/**
* 从Properties格式配置文件中获取所有参数并保存到HashMap中。
* 配置中的key值即map表中的key值,如果配置文件保存时用的中文,则返回结果也会转成中文。
*
* @param file
* @return
* @throws IOException
*/
@SuppressWarnings
(
"unchecked"
)
public
static
HashMap
readPropertyFile
(
String
file
,
String
charsetName
)
throws
IOException
{
if
(
charsetName
==
null
||
charsetName
.
trim
().
length
()==
0
){
charsetName
=
"gbk"
;
}
HashMap
map
=
new
HashMap
();
InputStream
is
=
null
;
if
(
file
.
startsWith
(
"file:"
))
is
=
new
FileInputStream
(
new
File
(
file
.
substring
(
5
)));
else
is
=
FileUtils
.
class
.
getClassLoader
().
getResourceAsStream
(
file
);
Properties
properties
=
new
Properties
();
properties
.
load
(
is
);
Enumeration
en
=
properties
.
propertyNames
();
while
(
en
.
hasMoreElements
())
{
String
key
=
(
String
)
en
.
nextElement
();
String
code
=
new
String
(
properties
.
getProperty
(
key
).
getBytes
(
"ISO-8859-1"
),
charsetName
);
map
.
put
(
key
,
code
);
}
return
map
;
}
/**
*
* @param path
* 文件路径
* @param suffix
* 后缀名
* @param isdepth
* 是否遍历子目录
* @return
*/
@SuppressWarnings
(
"unchecked"
)
public
static
List
getListFiles
(
String
path
,
String
suffix
,
boolean
isdepth
)
{
File
file
=
new
File
(
path
);
return
FileUtils
.
listFile
(
file
,
suffix
,
isdepth
);
}
/**
* @param f
* @param suffix:后缀名
* @param isdepth:是否遍历子目录
* @return
*/
@SuppressWarnings
(
"unchecked"
)
public
static
List
listFile
(
File
f
,
String
suffix
,
boolean
isdepth
)
{
// 是目录,同时需要遍历子目录
List
<
String
>
fileList
=
new
ArrayList
<
String
>();
if
(
f
.
isDirectory
()
&&
isdepth
==
true
)
{
File
[]
t
=
f
.
listFiles
();
for
(
int
i
=
0
;
i
<
t
.
length
;
i
++)
{
listFile
(
t
[
i
],
suffix
,
isdepth
);
}
}
else
{
String
filePath
=
f
.
getAbsolutePath
();
if
(
suffix
!=
null
)
{
int
begIndex
=
filePath
.
lastIndexOf
(
"."
);
// 最后一个.(即后缀名前面的.)的索引
String
tempsuffix
=
""
;
if
(
begIndex
!=
-
1
)
// 防止是文件但却没有后缀名结束的文件
{
tempsuffix
=
filePath
.
substring
(
begIndex
+
1
,
filePath
.
length
());
}
if
(
tempsuffix
.
equals
(
suffix
))
{
fileList
.
add
(
filePath
);
}
}
else
{
// 后缀名为null则为所有文件
fileList
.
add
(
filePath
);
}
}
return
fileList
;
}
/**
* 方法追加文件:使用FileWriter
*
* @param fileName
* @param content
*/
public
static
void
appendMethod
(
String
fileName
,
String
content
)
{
try
{
// 打开一个写文件器,构造函数中的第二个参数true表示以追加形式写文件
FileWriter
writer
=
new
FileWriter
(
fileName
,
true
);
writer
.
write
(
content
+
"\r\n"
);
writer
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
src/main/resources/mapper_xml/DepotItemMapperEx.xml
View file @
693a7558
...
@@ -33,6 +33,14 @@
...
@@ -33,6 +33,14 @@
<result
column=
"UName"
jdbcType=
"VARCHAR"
property=
"UName"
/>
<result
column=
"UName"
jdbcType=
"VARCHAR"
property=
"UName"
/>
</resultMap>
</resultMap>
<resultMap
extends=
"BaseResultMap"
id=
"ResultByMaterial"
type=
"com.jsh.erp.datasource.entities.DepotItemVo4WithInfoEx"
>
<result
column=
"MId"
jdbcType=
"VARCHAR"
property=
"MId"
/>
<result
column=
"MName"
jdbcType=
"VARCHAR"
property=
"MName"
/>
<result
column=
"MModel"
jdbcType=
"VARCHAR"
property=
"MModel"
/>
<result
column=
"MaterialUnit"
jdbcType=
"VARCHAR"
property=
"MaterialUnit"
/>
<result
column=
"MColor"
jdbcType=
"VARCHAR"
property=
"MColor"
/>
</resultMap>
<select
id=
"selectByConditionDepotItem"
parameterType=
"com.jsh.erp.datasource.entities.DepotItemExample"
resultMap=
"BaseResultMap"
>
<select
id=
"selectByConditionDepotItem"
parameterType=
"com.jsh.erp.datasource.entities.DepotItemExample"
resultMap=
"BaseResultMap"
>
select *
select *
FROM jsh_depotitem
FROM jsh_depotitem
...
@@ -125,40 +133,40 @@
...
@@ -125,40 +133,40 @@
from jsh_depotitem di left join jsh_material m on di.MaterialId=m.id
from jsh_depotitem di left join jsh_material m on di.MaterialId=m.id
left join jsh_unit u on m.UnitId = u.id
left join jsh_unit u on m.UnitId = u.id
left join jsh_depot dp1 on di.DepotId=dp1.id
left join jsh_depot dp1 on di.DepotId=dp1.id
left join jsh_depot dp2 on di.AnotherDepotId=dp
1
.id
left join jsh_depot dp2 on di.AnotherDepotId=dp
2
.id
where di.HeaderId = ${headerId}
where di.HeaderId = ${headerId}
order by di.id asc
order by di.id asc
</select>
</select>
<select
id=
"findByAll"
parameterType=
"com.jsh.erp.datasource.entities.DepotItemExample"
resultMap=
"Result
WithInfoExMap
"
>
<select
id=
"findByAll"
parameterType=
"com.jsh.erp.datasource.entities.DepotItemExample"
resultMap=
"Result
ByMaterial
"
>
select
di.*
, m.Name MName, m.Model MModel, m.Unit MaterialUnit, m.Color MColor
select
m.id MId
, m.Name MName, m.Model MModel, m.Unit MaterialUnit, m.Color MColor
from jsh_depotitem di
from jsh_depotitem di
inner join jsh_material m on di.MaterialId=m.id
inner join jsh_material m on di.MaterialId=m.id
where 1=1
where 1=1
<if
test=
"headIds != null"
>
<if
test=
"headIds != null"
>
and HeaderId in (${headIds})
and
di.
HeaderId in (${headIds})
</if>
</if>
<if
test=
"materialIds != null"
>
<if
test=
"materialIds != null"
>
and MaterialId in (${materialIds})
and
di.
MaterialId in (${materialIds})
</if>
</if>
group by
MaterialId
group by
m.id,m.Name, m.Model, m.Unit, m.Color
<if
test=
"offset != null and rows != null"
>
<if
test=
"offset != null and rows != null"
>
limit #{offset},#{rows}
limit #{offset},#{rows}
</if>
</if>
</select>
</select>
<select
id=
"findByAllCount"
resultType=
"java.lang.Integer"
>
<select
id=
"findByAllCount"
resultType=
"java.lang.Integer"
>
select count(1) from (select
di.I
d
select count(1) from (select
m.i
d
from jsh_depotitem di
from jsh_depotitem di
inner join jsh_material m on di.MaterialId=m.id
inner join jsh_material m on di.MaterialId=m.id
where 1=1
where 1=1
<if
test=
"headIds != null"
>
<if
test=
"headIds != null"
>
and HeaderId in (${headIds})
and
di.
HeaderId in (${headIds})
</if>
</if>
<if
test=
"materialIds != null"
>
<if
test=
"materialIds != null"
>
and MaterialId in (${materialIds})
and
di.
MaterialId in (${materialIds})
</if>
</if>
group by
MaterialI
d) cc
group by
m.i
d) cc
</select>
</select>
<select
id=
"findByTypeInIsPrev"
resultType=
"java.lang.Double"
>
<select
id=
"findByTypeInIsPrev"
resultType=
"java.lang.Double"
>
...
...
src/main/resources/mapper_xml/MaterialMapperEx.xml
View file @
693a7558
...
@@ -77,4 +77,22 @@
...
@@ -77,4 +77,22 @@
UnitId = null
UnitId = null
where Id = #{id,jdbcType=BIGINT}
where Id = #{id,jdbcType=BIGINT}
</update>
</update>
<select
id=
"findByAll"
parameterType=
"com.jsh.erp.datasource.entities.MaterialExample"
resultMap=
"ResultMapList"
>
select m.*,u.uname unitName, mc.name categoryName
FROM jsh_material m
left JOIN jsh_unit u on m.UnitId = u.id
left JOIN jsh_materialcategory mc on m.CategoryId = mc.id
where 1=1
<if
test=
"name != null"
>
and m.name like '%${name}%'
</if>
<if
test=
"model != null"
>
and m.model like '%${model}%'
</if>
<if
test=
"categoryId != 1"
>
and m.CategoryId in (${categoryIds})
</if>
order by m.id asc
</select>
</mapper>
</mapper>
\ No newline at end of file
src/main/resources/mapper_xml/SupplierMapperEx.xml
View file @
693a7558
...
@@ -45,4 +45,25 @@
...
@@ -45,4 +45,25 @@
and description like '%${description}%'
and description like '%${description}%'
</if>
</if>
</select>
</select>
<select
id=
"findByAll"
parameterType=
"com.jsh.erp.datasource.entities.SupplierExample"
resultMap=
"BaseResultMap"
>
select *
FROM jsh_supplier
where 1=1
<if
test=
"supplier != null"
>
and supplier like '%${supplier}%'
</if>
<if
test=
"type != null"
>
and type='${type}'
</if>
<if
test=
"phonenum != null"
>
and phonenum like '%${phonenum}%'
</if>
<if
test=
"telephone != null"
>
and telephone like '%${telephone}%'
</if>
<if
test=
"description != null"
>
and description like '%${description}%'
</if>
</select>
</mapper>
</mapper>
\ No newline at end of file
Prev
1
2
Next
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