Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
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
80d06a30
Commit
80d06a30
authored
Oct 13, 2020
by
qinhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
质量检测-导出修改
parent
675377ff
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
398 additions
and
14 deletions
+398
-14
QualityApplyController.java
...sc/cement/business/controller/QualityApplyController.java
+109
-0
ReportController.java
.../wise/sc/cement/business/controller/ReportController.java
+1
-1
QualityApply.java
.../java/cn/wise/sc/cement/business/entity/QualityApply.java
+102
-0
QualityApplyMapper.java
...cn/wise/sc/cement/business/mapper/QualityApplyMapper.java
+16
-0
QualityApplyMapper.xml
...wise/sc/cement/business/mapper/xml/QualityApplyMapper.xml
+5
-0
IQualityApplyService.java
...wise/sc/cement/business/service/IQualityApplyService.java
+36
-0
QualityApplyServiceImpl.java
...cement/business/service/impl/QualityApplyServiceImpl.java
+125
-0
WordUtil.java
...c/main/java/cn/wise/sc/cement/business/util/WordUtil.java
+4
-13
No files found.
cement-business/src/main/java/cn/wise/sc/cement/business/controller/QualityApplyController.java
0 → 100644
View file @
80d06a30
package
cn
.
wise
.
sc
.
cement
.
business
.
controller
;
import
cn.hutool.core.date.DateUtil
;
import
cn.wise.sc.cement.business.entity.QualityApply
;
import
cn.wise.sc.cement.business.model.BaseResponse
;
import
cn.wise.sc.cement.business.service.IQualityApplyService
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.CrossOrigin
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletResponse
;
import
java.time.LocalDate
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
/**
* <p>
* 前端控制器
* </p>
*
* @author ztw
* @since 2020-10-12
*/
@Api
(
tags
=
"质量检测审批"
)
@Slf4j
@CrossOrigin
@RestController
@RequestMapping
(
"/business/qualityApply"
)
public
class
QualityApplyController
{
final
IQualityApplyService
iQualityApplyService
;
public
QualityApplyController
(
IQualityApplyService
iQualityApplyService
)
{
this
.
iQualityApplyService
=
iQualityApplyService
;
}
@PostMapping
(
"/apply"
)
@ApiOperation
(
"质量详情审核"
)
public
BaseResponse
<
Boolean
>
applyQuality
(
@RequestBody
List
<
QualityApply
>
qualityApply
)
{
boolean
save
=
iQualityApplyService
.
saveBatch
(
qualityApply
);
if
(
save
)
{
return
BaseResponse
.
okData
(
true
);
}
else
{
return
BaseResponse
.
errorMsg
(
"添加失败!"
);
}
}
public
static
void
main
(
String
[]
args
)
{
List
<
QualityApply
>
list
=
new
ArrayList
<>();
QualityApply
qualityApply
=
new
QualityApply
();
qualityApply
.
setCementCode
(
"test"
);
qualityApply
.
setCreateTime
(
LocalDate
.
now
());
qualityApply
.
setInputResult
(
"[1,2,3,4]"
);
qualityApply
.
setProjectId
(
1
);
qualityApply
.
setProjectName
(
"test"
);
qualityApply
.
setUserName
(
"检测人"
);
qualityApply
.
setSampleCode
(
"001"
);
qualityApply
.
setSampleForm
(
"粉末"
);
qualityApply
.
setSampleName
(
"样品A"
);
qualityApply
.
setTeams
(
"[S,CO3,LiO2,H2Co3]"
);
qualityApply
.
setTeamGroupId
(
1
);
QualityApply
qualityApply1
=
new
QualityApply
();
qualityApply1
.
setCementCode
(
"test"
);
qualityApply1
.
setCreateTime
(
LocalDate
.
now
());
qualityApply1
.
setInputResult
(
"[1,2,3,4]"
);
qualityApply1
.
setProjectId
(
1
);
qualityApply1
.
setProjectName
(
"test"
);
qualityApply1
.
setUserName
(
"检测人"
);
qualityApply1
.
setSampleCode
(
"001"
);
qualityApply1
.
setSampleForm
(
"粉末"
);
qualityApply1
.
setSampleName
(
"样品A"
);
qualityApply1
.
setTeams
(
"[S,CO3,LiO2,H2Co3]"
);
qualityApply1
.
setTeamGroupId
(
1
);
list
.
add
(
qualityApply1
);
String
ss
=
"[\"S\",\"CO3\",\"LiO2\",\"H2Co3\"]"
;
list
.
add
(
qualityApply
);
List
<
String
>
a
=
new
ArrayList
<>();
a
.
add
(
"S"
);
a
.
add
(
"CO3"
);
a
.
add
(
"LiO2"
);
a
.
add
(
"H2Co3"
);
System
.
out
.
println
(
JSON
.
toJSONString
(
a
));
System
.
out
.
println
(
JSON
.
toJSONString
(
list
));
}
@PostMapping
(
"/export"
)
@ApiOperation
(
"导出质量监控"
)
public
void
exportQuality
(
String
startDate
,
String
endDate
,
HttpServletResponse
response
)
{
Date
startParse
=
DateUtil
.
parse
(
startDate
);
Date
endParse
=
DateUtil
.
parse
(
endDate
);
iQualityApplyService
.
exportQuality
(
startParse
,
endParse
,
response
);
}
}
cement-business/src/main/java/cn/wise/sc/cement/business/controller/ReportController.java
View file @
80d06a30
...
@@ -94,7 +94,7 @@ public class ReportController {
...
@@ -94,7 +94,7 @@ public class ReportController {
beanParams
.
put
(
"projectName"
,
rts
.
getProjectName
());
beanParams
.
put
(
"projectName"
,
rts
.
getProjectName
());
beanParams
.
put
(
"printDate"
,
rts
.
getPrintDate
());
beanParams
.
put
(
"printDate"
,
rts
.
getPrintDate
());
WordUtil
.
writeWordReport
(
rts
.
getProjectName
()
+
"(报告)"
,
"report.ftl"
,
WordUtil
.
writeWordReport
(
rts
.
getProjectName
()
+
"(报告)
.xls
"
,
"report.ftl"
,
beanParams
,
response
);
beanParams
,
response
);
}
}
...
...
cement-business/src/main/java/cn/wise/sc/cement/business/entity/QualityApply.java
0 → 100644
View file @
80d06a30
package
cn
.
wise
.
sc
.
cement
.
business
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
java.time.LocalDate
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
java.io.Serializable
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
/**
* <p>
*
* </p>
*
* @author ztw
* @since 2020-10-12
*/
@Data
@ApiModel
(
"审核"
)
@EqualsAndHashCode
(
callSuper
=
false
)
@Accessors
(
chain
=
true
)
public
class
QualityApply
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 项目名
*/
@ApiModelProperty
(
"项目名字"
)
private
String
projectName
;
/**
* 项目id
*/
@ApiModelProperty
(
"项目id"
)
private
Integer
projectId
;
@TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
private
Integer
id
;
/**
* 来样编号
*/
@ApiModelProperty
(
"来样编号"
)
private
String
sampleCode
;
/**
* 本所编号
*/
@ApiModelProperty
(
"本所编号"
)
private
String
cementCode
;
/**
* 样品状态
*/
@ApiModelProperty
(
"样品状态"
)
private
String
sampleForm
;
/**
* 计算结果
*/
@ApiModelProperty
(
"输入结果"
)
private
String
inputResult
;
/**
* 检测项id
*/
@ApiModelProperty
(
"检测项id"
)
private
Integer
teamGroupId
;
/**
* 时间
*/
@ApiModelProperty
(
"项目时间"
)
private
LocalDate
createTime
;
/**
* 1:人工检测 2:标准 3:误差
*/
@ApiModelProperty
(
"1:人工检测 2:标准 3:误差"
)
private
Integer
status
;
/**
* 样品名称
*/
@ApiModelProperty
(
"样品名称"
)
private
String
sampleName
;
/**
* 检测项名
*/
@ApiModelProperty
(
"检测项名"
)
private
String
teams
;
@ApiModelProperty
(
"检测人"
)
private
String
userName
;
}
cement-business/src/main/java/cn/wise/sc/cement/business/mapper/QualityApplyMapper.java
0 → 100644
View file @
80d06a30
package
cn
.
wise
.
sc
.
cement
.
business
.
mapper
;
import
cn.wise.sc.cement.business.entity.QualityApply
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
/**
* <p>
* Mapper 接口
* </p>
*
* @author ztw
* @since 2020-10-12
*/
public
interface
QualityApplyMapper
extends
BaseMapper
<
QualityApply
>
{
}
cement-business/src/main/java/cn/wise/sc/cement/business/mapper/xml/QualityApplyMapper.xml
0 → 100644
View file @
80d06a30
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"cn.wise.sc.cement.business.mapper.QualityApplyMapper"
>
</mapper>
cement-business/src/main/java/cn/wise/sc/cement/business/service/IQualityApplyService.java
0 → 100644
View file @
80d06a30
package
cn
.
wise
.
sc
.
cement
.
business
.
service
;
import
cn.wise.sc.cement.business.entity.QualityApply
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Set
;
/**
* <p>
* 服务类
* </p>
*
* @author ztw
* @since 2020-10-12
*/
public
interface
IQualityApplyService
extends
IService
<
QualityApply
>
{
/**
* 查询质量检测审核状态
*
* @param projectIds 项目id
* @return 已检测的质量监控
*/
Set
<
Integer
>
selectQualityApplyStatusByProIds
(
List
<
Integer
>
projectIds
);
/**
* 导出质量检测详情
*
* @param startParse 开始时间
* @param endParse 结束时间
*/
void
exportQuality
(
Date
startParse
,
Date
endParse
,
HttpServletResponse
response
);
}
cement-business/src/main/java/cn/wise/sc/cement/business/service/impl/QualityApplyServiceImpl.java
0 → 100644
View file @
80d06a30
package
cn
.
wise
.
sc
.
cement
.
business
.
service
.
impl
;
import
cn.wise.sc.cement.business.entity.QualityApply
;
import
cn.wise.sc.cement.business.mapper.QualityApplyMapper
;
import
cn.wise.sc.cement.business.service.IQualityApplyService
;
import
cn.wise.sc.cement.business.util.ExcelUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
lombok.Data
;
import
org.apache.poi.ss.usermodel.Header
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.springframework.stereotype.Service
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
/**
* <p>
* 服务实现类
* </p>
*
* @author ztw
* @since 2020-10-12
*/
@Service
public
class
QualityApplyServiceImpl
extends
ServiceImpl
<
QualityApplyMapper
,
QualityApply
>
implements
IQualityApplyService
{
@Override
public
Set
<
Integer
>
selectQualityApplyStatusByProIds
(
List
<
Integer
>
projectIds
)
{
if
(
projectIds
.
size
()
==
0
)
{
return
new
HashSet
<>();
}
QueryWrapper
<
QualityApply
>
qw
=
new
QueryWrapper
<>();
qw
.
in
(
"project_id"
,
projectIds
);
List
<
QualityApply
>
list
=
this
.
list
(
qw
);
if
(
list
.
size
()
==
0
)
{
return
new
HashSet
<>();
}
return
list
.
stream
().
map
(
QualityApply:
:
getProjectId
).
collect
(
Collectors
.
toSet
());
}
@Override
public
void
exportQuality
(
Date
startParse
,
Date
endParse
,
HttpServletResponse
response
)
{
QueryWrapper
<
QualityApply
>
qw
=
new
QueryWrapper
<>();
if
(
startParse
!=
null
)
{
qw
.
ge
(
"create_time"
,
startParse
);
}
if
(
endParse
!=
null
)
{
qw
.
le
(
"create_time"
,
endParse
);
}
List
<
QualityApply
>
list
=
this
.
list
(
qw
);
//找到所有项目id归类
Set
<
Integer
>
projectIds
=
list
.
stream
().
map
(
QualityApply:
:
getProjectId
).
collect
(
Collectors
.
toSet
());
String
[]
headers
=
new
String
[
30
];
List
<
Object
[]>
datas
=
new
ArrayList
<>();
for
(
Integer
projectId
:
projectIds
)
{
//找到每个项目的检测组 以检测组归类
Set
<
Integer
>
teamIds
=
list
.
stream
()
.
filter
(
arg
->
arg
.
getProjectId
().
intValue
()
==
projectId
)
.
map
(
QualityApply:
:
getTeamGroupId
)
.
collect
(
Collectors
.
toSet
());
for
(
Integer
teamId
:
teamIds
)
{
List
<
QualityApply
>
samples
=
list
.
stream
().
filter
(
arg
->
arg
.
getTeamGroupId
().
intValue
()
==
teamId
&&
arg
.
getProjectId
().
intValue
()
==
projectId
)
.
collect
(
Collectors
.
toList
());
//以样品归类
Set
<
Integer
>
sampleIds
=
samples
.
stream
().
map
(
QualityApply:
:
getTeamGroupId
)
.
collect
(
Collectors
.
toSet
());
//写每个样品的表头
list
.
stream
()
.
filter
(
arg
->
arg
.
getTeamGroupId
().
intValue
()
==
teamId
)
.
findFirst
().
ifPresent
(
arg
->
{
List
<
String
>
teams
=
JSON
.
parseArray
(
arg
.
getTeams
(),
String
.
class
);
Object
[]
objs
=
new
Object
[
teams
.
size
()
+
7
];
objs
[
0
]
=
"项目名称"
;
objs
[
1
]
=
"项目编号"
;
objs
[
2
]
=
"样品名称"
;
objs
[
3
]
=
"样品状态"
;
objs
[
4
]
=
"来样编号"
;
objs
[
5
]
=
"本所编号"
;
objs
[
6
]
=
"分析"
;
for
(
int
i
=
0
;
i
<
teams
.
size
();
i
++)
{
objs
[
7
+
i
]
=
teams
.
get
(
i
);
}
datas
.
add
(
objs
);
});
//为每个样品写值
samples
.
forEach
(
arg
->
{
List
<
String
>
inputValus
=
JSON
.
parseArray
(
arg
.
getInputResult
(),
String
.
class
);
Object
[]
objs
=
new
Object
[
inputValus
.
size
()
+
7
];
if
(!
"误差"
.
equals
(
arg
.
getUserName
()))
{
objs
[
0
]
=
arg
.
getProjectName
();
objs
[
1
]
=
arg
.
getProjectId
();
objs
[
2
]
=
arg
.
getSampleName
();
objs
[
3
]
=
arg
.
getSampleForm
();
objs
[
4
]
=
arg
.
getSampleCode
();
objs
[
5
]
=
arg
.
getCementCode
();
}
//添加名字
objs
[
6
]
=
arg
.
getUserName
();
for
(
int
i
=
0
;
i
<
inputValus
.
size
();
i
++)
{
objs
[
7
+
i
]
=
inputValus
.
get
(
i
);
}
for
(
int
i
=
0
;
i
<
inputValus
.
size
();
i
++)
{
objs
[
7
+
i
]
=
inputValus
.
get
(
i
);
}
datas
.
add
(
objs
);
});
}
}
ExcelUtil
.
excelExport
(
"qualityApply"
,
headers
,
datas
,
response
);
}
}
cement-business/src/main/java/cn/wise/sc/cement/business/util/WordUtil.java
View file @
80d06a30
...
@@ -3,6 +3,7 @@ package cn.wise.sc.cement.business.util;
...
@@ -3,6 +3,7 @@ package cn.wise.sc.cement.business.util;
import
freemarker.template.Configuration
;
import
freemarker.template.Configuration
;
import
freemarker.template.Template
;
import
freemarker.template.Template
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.File
;
import
java.io.File
;
...
@@ -52,30 +53,20 @@ public class WordUtil {
...
@@ -52,30 +53,20 @@ public class WordUtil {
configuration
.
setClassForTemplateLoading
(
WordUtil
.
class
,
FTL_FP
);
configuration
.
setClassForTemplateLoading
(
WordUtil
.
class
,
FTL_FP
);
Template
template
=
configuration
.
getTemplate
(
templateFileName
,
"UTF-8"
);
Template
template
=
configuration
.
getTemplate
(
templateFileName
,
"UTF-8"
);
//将文件输出到response,返回给客户端
String
filePath
;
String
filePath
;
filePath
=
""
;
filePath
=
""
;
File
file1
=
new
File
(
filePath
);
if
(!
file1
.
exists
())
{
boolean
mkdirs
=
file1
.
mkdirs
();
if
(!
mkdirs
)
{
response
.
getWriter
().
write
(
"导出失败,文件命名冲突!"
);
log
.
debug
(
"创建报告导出文件失败!"
);
return
;
}
}
//变量替换
//输出文件
file
=
new
File
(
filePath
+
templeName
);
file
=
new
File
(
filePath
+
templeName
);
//输出文件
FileOutputStream
fos
=
new
FileOutputStream
(
file
);
FileOutputStream
fos
=
new
FileOutputStream
(
file
);
out
=
new
OutputStreamWriter
(
fos
,
StandardCharsets
.
UTF_8
);
out
=
new
OutputStreamWriter
(
fos
,
StandardCharsets
.
UTF_8
);
//变量替换
template
.
process
(
beanParams
,
out
);
template
.
process
(
beanParams
,
out
);
FileInputStream
in
=
new
FileInputStream
(
file
);
FileInputStream
in
=
new
FileInputStream
(
file
);
byte
[]
buffer
=
new
byte
[
in
.
available
()];
byte
[]
buffer
=
new
byte
[
in
.
available
()];
int
i
=
in
.
read
(
buffer
);
int
i
=
in
.
read
(
buffer
);
if
(
i
==
-
1
){
if
(
i
==
-
1
)
{
return
;
return
;
}
}
in
.
close
();
in
.
close
();
...
...
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