Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
tianjin-cement
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
竹天卫
tianjin-cement
Commits
169620c3
Commit
169620c3
authored
Mar 12, 2021
by
竹天卫
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
导出委托进展
parent
bea3477f
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
267 additions
and
152 deletions
+267
-152
DataStatisticsController.java
.../cement/business/controller/DataStatisticsController.java
+6
-13
EntrustController.java
...wise/sc/cement/business/controller/EntrustController.java
+1
-3
DataStatisticsMapper.java
.../wise/sc/cement/business/mapper/DataStatisticsMapper.java
+1
-0
DataStatisticsMapper.xml
...se/sc/cement/business/mapper/xml/DataStatisticsMapper.xml
+56
-1
EntrustMapper.xml
...a/cn/wise/sc/cement/business/mapper/xml/EntrustMapper.xml
+1
-1
IDataStatisticsService.java
...se/sc/cement/business/service/IDataStatisticsService.java
+4
-2
IEntrustService.java
...a/cn/wise/sc/cement/business/service/IEntrustService.java
+2
-3
DataStatisticsServiceImpl.java
...ment/business/service/impl/DataStatisticsServiceImpl.java
+176
-120
EntrustServiceImpl.java
...e/sc/cement/business/service/impl/EntrustServiceImpl.java
+20
-9
No files found.
cement-business/src/main/java/cn/wise/sc/cement/business/controller/DataStatisticsController.java
View file @
169620c3
...
...
@@ -5,6 +5,7 @@ import cn.wise.sc.cement.business.model.PageQuery;
import
cn.wise.sc.cement.business.model.query.CountItemDistributionQuery
;
import
cn.wise.sc.cement.business.model.vo.ItemDistributionVo
;
import
cn.wise.sc.cement.business.service.IDataStatisticsService
;
import
cn.wise.sc.cement.business.service.IEntrustService
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
...
...
@@ -34,6 +35,8 @@ public class DataStatisticsController {
@Autowired
private
IDataStatisticsService
dataStatisticsService
;
@Autowired
private
IEntrustService
entrustService
;
@ApiOperation
(
value
=
"统计概览-重要数值统计"
)
...
...
@@ -112,24 +115,14 @@ public class DataStatisticsController {
public
void
exportEntrustList
(
Integer
cycle
,
String
startDate
,
String
endDate
,
Integer
clientId
,
String
clientName
,
String
fileName
,
HttpServletResponse
response
)
{
try
{
dataStatisticsService
.
exportEntrustList
(
cycle
,
startDate
,
endDate
,
clientId
,
clientName
,
fileName
,
response
);
}
catch
(
Exception
e
)
{
log
.
debug
(
"列表导出-委托单进展统计{}"
,
e
);
}
}
// dataStatisticsService.exportEntrustList(cycle, startDate, endDate, clientId, clientName, fileName, response);
dataStatisticsService
.
exportConsignation
(
cycle
,
startDate
,
endDate
,
clientId
,
clientName
,
fileName
,
response
);
@ApiOperation
(
"委托单进展统计-列表导出(新)"
)
@PostMapping
(
"/exportEntrustIngList"
)
public
void
exportEntrustIngList
(
Integer
cycle
,
String
startDate
,
String
endDate
,
Integer
clientId
,
String
clientName
,
String
fileName
,
HttpServletResponse
response
)
{
try
{
dataStatisticsService
.
exportEntrustIngList
(
cycle
,
startDate
,
endDate
,
clientId
,
clientName
,
fileName
,
response
);
}
catch
(
Exception
e
)
{
log
.
debug
(
"
委托单进展统计-列表导出(新)
{}"
,
e
);
log
.
debug
(
"
列表导出-委托单进展统计
{}"
,
e
);
}
}
@ApiOperation
(
value
=
"统计概览-进行中任务数量统计"
)
@GetMapping
(
"/countTaskIng"
)
public
BaseResponse
countTaskIng
(
PageQuery
pageQuery
,
String
startDate
,
String
endDate
)
{
...
...
cement-business/src/main/java/cn/wise/sc/cement/business/controller/EntrustController.java
View file @
169620c3
...
...
@@ -81,12 +81,10 @@ public class EntrustController {
public
void
export
(
String
startDate
,
String
endDate
,
Integer
status
,
Integer
clientId
,
String
projectName
,
String
projectCode
,
String
fileName
,
HttpServletResponse
response
)
{
long
a
=
System
.
currentTimeMillis
();
try
{
entrustService
.
export
Consignation
(
startDate
,
endDate
,
status
,
entrustService
.
export
(
startDate
,
endDate
,
status
,
clientId
,
projectName
,
projectCode
,
fileName
,
response
);
System
.
out
.
println
(
System
.
currentTimeMillis
()-
a
);
}
catch
(
Exception
e
)
{
log
.
debug
(
"委托列表导出{}"
,
e
);
}
...
...
cement-business/src/main/java/cn/wise/sc/cement/business/mapper/DataStatisticsMapper.java
View file @
169620c3
...
...
@@ -39,6 +39,7 @@ public interface DataStatisticsMapper {
IPage
<
EntrustVo
>
countEntrustPage
(
@Param
(
"page"
)
Page
page
,
@Param
(
"params"
)
Map
<
String
,
Object
>
params
);
List
<
Map
<
String
,
Object
>>
exportEntrustList
(
@Param
(
"params"
)
Map
<
String
,
Object
>
params
);
List
<
Map
<
String
,
Object
>>
exportEntrustNewList
(
@Param
(
"params"
)
Map
<
String
,
Object
>
params
);
IPage
<
DataStatisticsVo
>
countHandlePage
(
@Param
(
"page"
)
Page
page
,
@Param
(
"params"
)
Map
<
String
,
Object
>
params
);
...
...
cement-business/src/main/java/cn/wise/sc/cement/business/mapper/xml/DataStatisticsMapper.xml
View file @
169620c3
...
...
@@ -188,7 +188,7 @@
IF(ISNULL(e.id),'',e.id) as entrustId,
IF(ISNULL(e.entrust_code),'',e.entrust_code) as 委托单号,
IF(ISNULL(c.name),'',c.name) as 委托单位,
IF(ISNULL(p.
name),'',p.nam
e) as 项目编号,
IF(ISNULL(p.
code),'',p.cod
e) as 项目编号,
IF(ISNULL(p.name),'',p.name) as 项目名称,
IF(ISNULL(su.name),'',su.name) as 委托人,
IF(ISNULL(e.sample_num),'',e.sample_num) as 样品数量,
...
...
@@ -222,6 +222,61 @@
order by 序号
</select>
<select
id=
"exportEntrustNewList"
resultType=
"java.util.HashMap"
>
SELECT
(@i:=@i+1) as 序号,
e.id as entrustId,
IF(ISNULL(e.entrust_code),'',e.entrust_code) as 委托单号,
(
CASE e.is_urgent
WHEN 0 THEN '不加急'
WHEN 1 THEN '加急'
ELSE NULL
END
) as 是否加急,
IF(ISNULL(p.name),'',p.name) as 项目名称,
IF(ISNULL(p.code),'',p.code) as 项目编号,
IF(ISNULL(su.name),'',su.name) as 委托人,
IF(ISNULL(c.name),'',c.name) as 委托单位,
IF(ISNULL(e.entrust_date),'',e.entrust_date) as 委托日期,
IF(ISNULL(e.sample_num),'',e.sample_num) as 样品数量,
(
CASE e.status
WHEN 0 THEN '未评审'
WHEN 1 THEN '已通过'
WHEN 2 THEN '未通过'
WHEN 3 THEN '样品处理中'
WHEN 4 THEN '样品处理完成'
WHEN 5 THEN '样品检测中'
WHEN 6 THEN '样品检测完成'
WHEN 7 THEN '校核中'
WHEN 8 THEN '校核完成'
WHEN 9 THEN '修改待确认'
WHEN 10 THEN '已作废'
ELSE ''
END
) as 状态
from entrust e
left join project p on p.id = e.project_id
left join client c on c.id = e.client_id
left join sys_user su on su.id = e.user_id
,(select @i:=0)aa
where e.status != 0 and e.project_type is not null
<if
test=
"params.clientId != null"
>
and e.clientId = #{clientId}
</if>
<if
test=
"params.clientName != null and params.clientName != ''"
>
and c.name like concat('%', #{params.clientName}, '%')
</if>
<if
test=
"params.startDate != null and params.startDate != ''"
>
and DATE(e.create_time)
>
= #{params.startDate}
</if>
<if
test=
"params.endDate != null and params.endDate != ''"
>
and DATE(e.create_time)
<
= #{params.endDate}
</if>
order by 序号
</select>
<select
id=
"countHandlePage"
resultType=
"cn.wise.sc.cement.business.model.vo.DataStatisticsVo"
>
SELECT su.id as id, su.name as name, count(*) as value FROM sample_handle sh
...
...
cement-business/src/main/java/cn/wise/sc/cement/business/mapper/xml/EntrustMapper.xml
View file @
169620c3
...
...
@@ -82,7 +82,7 @@
END
) as 是否加急,
IF(ISNULL(p.name),'',p.name) as 项目名称,
IF(ISNULL(p.
name),'',p.nam
e) as 项目编号,
IF(ISNULL(p.
code),'',p.cod
e) as 项目编号,
IF(ISNULL(su.name),'',su.name) as 委托人,
IF(ISNULL(c.name),'',c.name) as 委托单位,
IF(ISNULL(e.entrust_date),'',e.entrust_date) as 委托日期,
...
...
cement-business/src/main/java/cn/wise/sc/cement/business/service/IDataStatisticsService.java
View file @
169620c3
...
...
@@ -39,8 +39,10 @@ public interface IDataStatisticsService {
void
exportEntrustList
(
Integer
cycle
,
String
startDate
,
String
endDate
,
Integer
clientId
,
String
clientName
,
String
fileName
,
HttpServletResponse
response
);
void
exportEntrustIngList
(
Integer
cycle
,
String
startDate
,
String
endDate
,
Integer
clientId
,
String
clientName
,
String
fileName
,
HttpServletResponse
response
);
void
exportConsignation
(
Integer
cycle
,
String
startDate
,
String
endDate
,
Integer
clientId
,
String
clientName
,
String
fileName
,
HttpServletResponse
response
);
BaseResponse
<
Map
<
String
,
Object
>>
countTaskIng
(
PageQuery
pageQuery
,
String
startDate
,
String
endDate
);
...
...
cement-business/src/main/java/cn/wise/sc/cement/business/service/IEntrustService.java
View file @
169620c3
...
...
@@ -144,9 +144,8 @@ public interface IEntrustService extends IService<Entrust> {
Integer
clientId
,
String
projectName
,
String
projectCode
,
String
fileName
,
HttpServletResponse
response
);
void
exportConsignation
(
String
startDate
,
String
endDate
,
Integer
status
,
Integer
clientId
,
String
projectName
,
String
projectCode
,
String
fileName
,
HttpServletResponse
response
);
void
exportConsignation
(
Integer
cycle
,
String
startDate
,
String
endDate
,
Integer
clientId
,
String
clientName
,
String
fileName
,
HttpServletResponse
response
);
BaseResponse
<
EntrustVo
>
getBaseDtail
(
Integer
id
);
...
...
cement-business/src/main/java/cn/wise/sc/cement/business/service/impl/DataStatisticsServiceImpl.java
View file @
169620c3
...
...
@@ -24,6 +24,10 @@ import io.swagger.models.auth.In;
import
lombok.Data
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.poi.ss.usermodel.HorizontalAlignment
;
import
org.apache.poi.ss.usermodel.VerticalAlignment
;
import
org.apache.poi.ss.util.CellRangeAddress
;
import
org.apache.poi.xssf.usermodel.*
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -72,9 +76,13 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
private
TeamMapper
teamMapper
;
@Resource
private
SampleMapper
sampleMapper
;
@Resource
private
ITeamService
teamService
;
/**
/**
* 统计概览-重要数值统计
* @return
*/
...
...
@@ -353,9 +361,8 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
}
/**
* 委托单进展统计-列表导出(新)
/**
* 最新模板委托单进展统计
* @param cycle
* @param startDate
* @param endDate
...
...
@@ -364,138 +371,187 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
* @param fileName
* @param response
*/
public
void
exportEntrustIngList
(
Integer
cycle
,
String
startDate
,
String
endDate
,
Integer
clientId
,
String
clientName
,
String
fileName
,
HttpServletResponse
response
){
//1.获取委托可见的所有检测项list
//2. 获取委托列表
//3. 样品列表
//4. 检测项列表
@Override
public
void
exportConsignation
(
Integer
cycle
,
String
startDate
,
String
endDate
,
Integer
clientId
,
String
clientName
,
String
fileName
,
HttpServletResponse
response
)
{
//1.首先查询所有可见的检测项
QueryWrapper
<
Team
>
teamQueryWrapper
=
new
QueryWrapper
<>();
teamQueryWrapper
.
eq
(
"is_display"
,
1
);
teamQueryWrapper
.
eq
(
"status"
,
1
);
List
<
Team
>
teamList
=
teamService
.
list
(
teamQueryWrapper
);
//转化成id为key的map
// Map<Integer, Team> teamMap = teamList.stream().collect(Collectors.toMap(Team::getId, a -> a, (k1, k2) -> k1));
//2.条件查询委托单项
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"cycle"
,
cycle
);
params
.
put
(
"startDate"
,
startDate
);
params
.
put
(
"endDate"
,
endDate
);
params
.
put
(
"clientId"
,
clientId
);
params
.
put
(
"clientName"
,
clientName
);
List
<
Map
<
String
,
Object
>>
list
=
dataStatisticsMapper
.
exportEntrustList
(
params
);
List
<
String
>
teamNameList
=
teamMapper
.
getNameList
();
if
(
teamNameList
==
null
||
teamNameList
.
size
()<=
0
){
return
;
}
if
(!
CollectionUtils
.
isEmpty
(
list
))
{
String
[]
headers
=
new
String
[
10
+
teamNameList
.
size
()*
3
];
headers
[
0
]
=
"序号"
;
headers
[
1
]
=
"委托单号"
;
headers
[
2
]
=
"委托单位"
;
headers
[
3
]
=
"项目编号"
;
headers
[
4
]
=
"项目名称"
;
headers
[
5
]
=
"委托人"
;
headers
[
6
]
=
"样品数量"
;
headers
[
7
]
=
"委托日期"
;
headers
[
8
]
=
"是否加急"
;
headers
[
9
]
=
"实际产值"
;
Integer
cloumNo
=
9
;
for
(
int
i
=
0
;
i
<
teamNameList
.
size
();
i
++){
headers
[
10
+
i
]
=
teamNameList
.
get
(
i
)+
"(产值)"
;
cloumNo
=
cloumNo
+
1
;
}
for
(
int
i
=
0
;
i
<
teamNameList
.
size
();
i
++){
headers
[
cloumNo
+
1
]
=
teamNameList
.
get
(
i
)+
"(单价)"
;
headers
[
cloumNo
+
2
]
=
teamNameList
.
get
(
i
)+
"(数量)"
;
cloumNo
=
cloumNo
+
2
;
}
List
<
Object
[]>
datas
=
new
ArrayList
<>(
list
.
size
());
for
(
Map
<
String
,
Object
>
m
:
list
)
{
Object
[]
objects
=
new
Object
[
headers
.
length
];
String
objj
=
m
.
get
(
"entrustId"
).
toString
();
String
isUrgent
=
m
.
get
(
"isUrgent"
).
toString
();
Integer
entrustId
=
Integer
.
valueOf
(
objj
);
//只统计主样的信息
List
<
Sample
>
sampleList
=
sampleMapper
.
getSampleList
(
entrustId
);
//检测项目名称
List
<
Integer
>
teamIdList
=
new
ArrayList
<>();
Map
<
Integer
,
Integer
>
teamMap
=
new
HashMap
<>();
//所有样品主样的产值
BigDecimal
outputValue
=
new
BigDecimal
(
"0.00"
);
if
(
sampleList
!=
null
&&
sampleList
.
size
()
>
0
)
{
//样品名称 列表中的拼接
for
(
Sample
sample
:
sampleList
)
{
if
(
sample
.
getOutputValue
()
!=
null
){
outputValue
=
outputValue
.
compareTo
(
BigDecimal
.
ZERO
)
==
0
?
sample
.
getOutputValue
()
:
(
outputValue
.
add
(
sample
.
getOutputValue
()));
}
String
teamIds
=
sample
.
getTeamIds
();
if
(
teamIds
!=
null
)
{
String
[]
teamIdS
=
teamIds
.
split
(
"、"
);
for
(
String
teamId
:
teamIdS
)
{
Team
team
=
teamMapper
.
selectById
(
Integer
.
valueOf
(
teamId
));
if
(
team
!=
null
)
{
if
(!
teamIdList
.
contains
(
team
.
getId
())){
teamMap
.
put
(
team
.
getId
(),
1
);
teamIdList
.
add
(
team
.
getId
());
}
else
{
teamMap
.
put
(
team
.
getId
(),
teamMap
.
get
(
team
.
getId
())+
1
);
}
}
}
}
List
<
Map
<
String
,
Object
>>
entrustList
=
dataStatisticsMapper
.
exportEntrustNewList
(
params
);
//获取所有的委托单号
List
<
Integer
>
queryList
=
entrustList
.
stream
().
map
(
x
->
Integer
.
parseInt
(
x
.
get
(
"entrustId"
).
toString
())).
collect
(
Collectors
.
toList
());
//3.根据委托单号获取样品
QueryWrapper
<
Sample
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
in
(
"entrust_id"
,
queryList
);
List
<
Sample
>
sampleList
=
sampleService
.
list
(
queryWrapper
);
//4.查询所有的派发检测项
QueryWrapper
<
SampleDistribution
>
sdqueryWrapper
=
new
QueryWrapper
<>();
sdqueryWrapper
.
in
(
"entrust_id"
,
queryList
);
sdqueryWrapper
.
in
(
"sample_id"
,
sampleList
.
stream
().
filter
(
x
->
x
.
getCementCode
().
equals
(
x
.
getParallelCode
())).
map
(
Sample:
:
getId
).
collect
(
Collectors
.
toList
()));
List
<
SampleDistribution
>
sampleDistributions
=
sampleDistributionService
.
list
(
sdqueryWrapper
);
//5.分组并统计
Map
<
Integer
,
List
<
SampleDistribution
>>
groupByEntrustId
=
sampleDistributions
.
stream
().
collect
(
Collectors
.
groupingBy
(
SampleDistribution:
:
getEntrustId
,
Collectors
.
toList
()));
//6.开始填充数据。首先填充表头
XSSFWorkbook
wb
=
new
XSSFWorkbook
();
XSSFSheet
sheet
=
wb
.
createSheet
();
XSSFCellStyle
style
=
wb
.
createCellStyle
();
XSSFFont
font
=
wb
.
createFont
();
//水平居中
style
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
//垂直居中
style
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
//生成表头
String
[]
in_fo
=
{
"委托单号"
,
"委托单位"
,
"项目编号"
,
"项目名称"
,
"委托人"
,
"样品数量"
,
"委托日期"
,
"是否加急"
,
"实际产值"
,
};
List
<
String
>
infoHeader
=
Arrays
.
asList
(
in_fo
);
generatoronsignationWorkbook
(
font
,
style
,
sheet
,
infoHeader
,
teamList
.
stream
().
map
(
Team:
:
getName
).
collect
(
Collectors
.
toList
()));
//填充数据,从第二行开始
int
rownum
=
2
;
for
(
int
j
=
0
;
j
<
entrustList
.
size
();
j
++)
{
Map
<
String
,
Object
>
entrust
=
entrustList
.
get
(
j
);
int
entrustId
=
Integer
.
parseInt
(
entrust
.
get
(
"entrustId"
).
toString
());
if
(
groupByEntrustId
.
get
(
entrustId
)
!=
null
)
{
XSSFRow
row0
=
sheet
.
createRow
(
rownum
++);
Map
<
Integer
,
List
<
SampleDistribution
>>
sampleDistribuGroup
=
groupByEntrustId
.
get
(
entrustId
).
stream
().
collect
(
Collectors
.
groupingBy
(
SampleDistribution:
:
getTeamId
,
Collectors
.
toList
()));
//处理委托人信息表头
for
(
int
i
=
0
;
i
<
infoHeader
.
size
();
i
++)
{
XSSFCell
tempCell
=
row0
.
createCell
(
i
);
if
(
infoHeader
.
get
(
i
).
equals
(
"实际产值"
)){
Double
outPutValue
=
sampleList
.
stream
()
.
filter
(
x
->
x
.
getCementCode
().
equals
(
x
.
getParallelCode
())
&&
x
.
getEntrustId
()
==
entrustId
)
.
mapToDouble
(
item
->
item
.
getOutputValue
().
doubleValue
()).
sum
();
tempCell
.
setCellValue
(
outPutValue
==
null
?
""
:
outPutValue
.
toString
());
tempCell
.
setCellStyle
(
style
);
}
else
{
tempCell
.
setCellValue
(
entrust
.
get
(
infoHeader
.
get
(
i
))
==
null
?
""
:
entrust
.
get
(
infoHeader
.
get
(
i
)).
toString
());
tempCell
.
setCellStyle
(
style
);
}
}
//遍历检测项的数量 求得检测项的单价 和 计算的产值,如果是加急状态产值需要 ✖3倍计算
JSONArray
jsonArray
=
new
JSONArray
();
for
(
Map
.
Entry
<
Integer
,
Integer
>
entry
:
teamMap
.
entrySet
()){
Team
team
=
teamMapper
.
selectById
(
entry
.
getKey
());
if
(
team
!=
null
){
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
team
.
getName
()+
"(单价)"
,
team
.
getCharge
());
jsonObject
.
put
(
team
.
getName
()+
"(数量)"
,
entry
.
getValue
());
BigDecimal
outPutValue
=
team
.
getCharge
().
multiply
(
new
BigDecimal
(
entry
.
getValue
()));
if
(
isUrgent
.
equals
(
"1"
)){
outPutValue
.
multiply
(
new
BigDecimal
(
3
));
}
jsonObject
.
put
(
team
.
getName
()+
"(产值)"
,
outPutValue
.
toString
());
jsonArray
.
add
(
jsonObject
);
}
//处理检测项总产值表头
for
(
int
i
=
infoHeader
.
size
();
i
<
teamList
.
size
()
+
infoHeader
.
size
();
i
++)
{
XSSFCell
tempCell
=
row0
.
createCell
(
i
);
Team
team
=
teamList
.
get
(
i
-
infoHeader
.
size
());
tempCell
.
setCellValue
(
sampleDistribuGroup
.
get
(
team
.
getId
())
==
null
?
""
:
team
.
getCharge
().
multiply
(
new
BigDecimal
(
sampleDistribuGroup
.
get
(
team
.
getId
()).
size
())).
toString
());
tempCell
.
setCellStyle
(
style
);
}
// JSONArray checkElementArray = mapToJSONArray(teamMap);
// String teamString = JSON.toJSON(checkElementArray).toString();
for
(
int
j
=
0
;
j
<
headers
.
length
;
j
++)
{
String
obj
=
""
;
if
(
j
>
9
){
for
(
int
k
=
0
;
k
<
jsonArray
.
size
();
k
++){
JSONObject
jsonObject
=
jsonArray
.
getJSONObject
(
k
);
if
(
jsonObject
.
containsKey
(
headers
[
j
])){
String
value
=
jsonObject
.
getString
(
headers
[
j
]).
toString
();
objects
[
j
]
=
value
;
}
}
}
else
if
(
j
==
9
){
objects
[
9
]
=
outputValue
;
}
else
{
obj
=
m
.
get
(
headers
[
j
]).
toString
();
if
(
j
==
0
)
{
obj
=
obj
.
split
(
"\\."
)[
0
];
}
objects
[
j
]
=
obj
;
}
//增加1空列
{
XSSFCell
tempCell
=
row0
.
createCell
(
teamList
.
size
()
+
infoHeader
.
size
());
tempCell
.
setCellValue
(
""
);
tempCell
.
setCellStyle
(
style
);
}
//处理检测项信息表头
for
(
int
i
=
teamList
.
size
()
+
infoHeader
.
size
()
+
1
;
i
<
infoHeader
.
size
()
+
1
+
teamList
.
size
()
*
3
;
i
++)
{
Team
team
=
teamList
.
get
((
i
-
teamList
.
size
()
-
infoHeader
.
size
()
-
1
)
/
2
);
XSSFCell
tempCell1
=
row0
.
createCell
(
i
);
tempCell1
.
setCellStyle
(
style
);
tempCell1
.
setCellValue
(
sampleDistribuGroup
.
get
(
team
.
getId
())
==
null
?
""
:
team
.
getCharge
().
toString
());
XSSFCell
tempCell2
=
row0
.
createCell
(++
i
);
tempCell2
.
setCellValue
(
sampleDistribuGroup
.
get
(
team
.
getId
())
==
null
?
""
:
sampleDistribuGroup
.
get
(
team
.
getId
()).
size
()
+
""
);
tempCell2
.
setCellStyle
(
style
);
}
datas
.
add
(
objects
);
}
ExcelUtil
.
excelExport
(
fileName
==
null
||
fileName
.
trim
().
length
()
<=
0
?
"委托单进展统计-列表导出"
:
fileName
,
headers
,
datas
,
response
);
}
ExcelUtil
.
excelExportNew
(
fileName
==
null
||
fileName
.
trim
().
length
()
<=
0
?
"委托列表"
:
fileName
,
wb
,
response
);
}
private
static
void
generatoronsignationWorkbook
(
XSSFFont
font
,
XSSFCellStyle
style
,
XSSFSheet
sheet
,
List
<
String
>
infoHeader
,
List
<
String
>
teamsHeader
)
{
//委托项的表头
int
rownum
=
0
;
//创建第一行
XSSFRow
row0
=
sheet
.
createRow
(
rownum
++);
//处理委托人信息表头
for
(
int
i
=
0
;
i
<
infoHeader
.
size
();
i
++)
{
XSSFCell
tempCell
=
row0
.
createCell
(
i
);
tempCell
.
setCellValue
(
infoHeader
.
get
(
i
));
tempCell
.
setCellStyle
(
style
);
}
//处理检测项总产值表头
for
(
int
i
=
infoHeader
.
size
();
i
<
teamsHeader
.
size
()
+
infoHeader
.
size
();
i
++)
{
XSSFCell
tempCell
=
row0
.
createCell
(
i
);
tempCell
.
setCellValue
(
ExcelUtil
.
applyFontsub
(
teamsHeader
.
get
(
i
-
infoHeader
.
size
()),
font
));
tempCell
.
setCellStyle
(
style
);
}
//增加1空列
{
XSSFCell
tempCell
=
row0
.
createCell
(
teamsHeader
.
size
()
+
infoHeader
.
size
());
tempCell
.
setCellValue
(
""
);
tempCell
.
setCellStyle
(
style
);
}
//处理检测项信息表头
for
(
int
i
=
teamsHeader
.
size
()
+
infoHeader
.
size
()
+
1
;
i
<
infoHeader
.
size
()
+
1
+
teamsHeader
.
size
()
*
3
;
i
++)
{
String
header
=
teamsHeader
.
get
((
i
-
teamsHeader
.
size
()
-
infoHeader
.
size
()
-
1
)
/
2
);
XSSFCell
tempCell1
=
row0
.
createCell
(
i
);
tempCell1
.
setCellStyle
(
style
);
tempCell1
.
setCellValue
(
ExcelUtil
.
applyFontsub
(
header
,
font
));
XSSFCell
tempCell2
=
row0
.
createCell
(++
i
);
tempCell2
.
setCellValue
(
ExcelUtil
.
applyFontsub
(
header
,
font
));
tempCell2
.
setCellStyle
(
style
);
//合并表头
sheet
.
addMergedRegion
(
new
CellRangeAddress
(
0
,
0
,
i
-
1
,
i
));
}
//创建第二行
XSSFRow
row1
=
sheet
.
createRow
(
rownum
++);
//处理委托人信息表头
for
(
int
i
=
0
;
i
<
infoHeader
.
size
();
i
++)
{
XSSFCell
tempCell
=
row1
.
createCell
(
i
);
tempCell
.
setCellValue
(
""
);
tempCell
.
setCellStyle
(
style
);
//合并表头
sheet
.
addMergedRegion
(
new
CellRangeAddress
(
0
,
1
,
i
,
i
));
}
//处理检测项总产值表头
for
(
int
i
=
infoHeader
.
size
();
i
<
teamsHeader
.
size
()
+
infoHeader
.
size
();
i
++)
{
XSSFCell
tempCell
=
row1
.
createCell
(
i
);
tempCell
.
setCellValue
(
"计算产值"
);
tempCell
.
setCellStyle
(
style
);
}
//增加1空列
{
XSSFCell
tempCell
=
row0
.
createCell
(
teamsHeader
.
size
()
+
infoHeader
.
size
());
tempCell
.
setCellValue
(
""
);
tempCell
.
setCellStyle
(
style
);
}
//处理检测项信息表头
for
(
int
i
=
teamsHeader
.
size
()
+
1
+
infoHeader
.
size
();
i
<
infoHeader
.
size
()
+
1
+
teamsHeader
.
size
()
*
3
;
i
++)
{
XSSFCell
tempCell1
=
row1
.
createCell
(
i
);
tempCell1
.
setCellValue
(
"单价"
);
tempCell1
.
setCellStyle
(
style
);
XSSFCell
tempCell2
=
row1
.
createCell
(++
i
);
tempCell2
.
setCellValue
(
"数量"
);
tempCell2
.
setCellStyle
(
style
);
}
}
...
...
cement-business/src/main/java/cn/wise/sc/cement/business/service/impl/EntrustServiceImpl.java
View file @
169620c3
...
...
@@ -5347,24 +5347,25 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
private
ISampleDistributionService
sampleDistributionService
;
@Override
public
void
exportConsignation
(
String
startDate
,
String
endDate
,
Integer
status
,
Integer
clientId
,
String
projectName
,
String
projectCod
e
,
public
void
exportConsignation
(
Integer
cycle
,
String
startDate
,
String
endDate
,
Integer
clientId
,
String
clientNam
e
,
String
fileName
,
HttpServletResponse
response
)
{
//1.首先查询所有可见的检测项
QueryWrapper
<
Team
>
teamQueryWrapper
=
new
QueryWrapper
<>();
teamQueryWrapper
.
eq
(
"is_display"
,
1
);
teamQueryWrapper
.
eq
(
"status"
,
1
);
List
<
Team
>
teamList
=
teamService
.
list
(
teamQueryWrapper
);
//转化成id为key的map
Map
<
Integer
,
Team
>
teamMap
=
teamList
.
stream
().
collect
(
Collectors
.
toMap
(
Team:
:
getId
,
a
->
a
,
(
k1
,
k2
)
->
k1
));
//
Map<Integer, Team> teamMap = teamList.stream().collect(Collectors.toMap(Team::getId, a -> a, (k1, k2) -> k1));
//2.条件查询委托单项
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"cycle"
,
cycle
);
params
.
put
(
"startDate"
,
startDate
);
params
.
put
(
"endDate"
,
endDate
);
params
.
put
(
"status"
,
status
);
params
.
put
(
"clientId"
,
clientId
);
params
.
put
(
"projectName"
,
projectName
);
params
.
put
(
"projectCode"
,
projectCode
);
params
.
put
(
"clientName"
,
clientName
);
List
<
Map
<
String
,
Object
>>
entrustList
=
entrustMapper
.
exportList
(
params
);
//获取所有的委托单号
List
<
Integer
>
queryList
=
entrustList
.
stream
().
map
(
x
->
Integer
.
parseInt
(
x
.
get
(
"entrustId"
).
toString
())).
collect
(
Collectors
.
toList
());
...
...
@@ -5396,7 +5397,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
"项目名称"
,
"委托人"
,
"样品数量"
,
"
发样
日期"
,
"
委托
日期"
,
"是否加急"
,
"实际产值"
,
};
...
...
@@ -5414,9 +5415,19 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
//处理委托人信息表头
for
(
int
i
=
0
;
i
<
infoHeader
.
size
();
i
++)
{
XSSFCell
tempCell
=
row0
.
createCell
(
i
);
tempCell
.
setCellValue
(
entrust
.
get
(
infoHeader
.
get
(
i
))
==
null
?
""
:
entrust
.
get
(
infoHeader
.
get
(
i
)).
toString
());
tempCell
.
setCellStyle
(
style
);
if
(
infoHeader
.
get
(
i
).
equals
(
"实际产值"
)){
Double
outPutValue
=
sampleList
.
stream
()
.
filter
(
x
->
x
.
getCementCode
().
equals
(
x
.
getParallelCode
())
&&
x
.
getEntrustId
()
==
entrustId
)
.
mapToDouble
(
item
->
item
.
getOutputValue
().
doubleValue
()).
sum
();
tempCell
.
setCellValue
(
outPutValue
==
null
?
""
:
outPutValue
.
toString
());
tempCell
.
setCellStyle
(
style
);
}
else
{
tempCell
.
setCellValue
(
entrust
.
get
(
infoHeader
.
get
(
i
))
==
null
?
""
:
entrust
.
get
(
infoHeader
.
get
(
i
)).
toString
());
tempCell
.
setCellStyle
(
style
);
}
}
//处理检测项总产值表头
for
(
int
i
=
infoHeader
.
size
();
i
<
teamList
.
size
()
+
infoHeader
.
size
();
i
++)
{
XSSFCell
tempCell
=
row0
.
createCell
(
i
);
...
...
Write
Preview
Markdown
is supported
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