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
6728d2be
Commit
6728d2be
authored
Oct 12, 2020
by
qinhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
标准产值--添加百分比验证
parent
072f1fa2
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
78 deletions
+47
-78
NormProductionController.java
.../cement/business/controller/NormProductionController.java
+5
-11
ReportController.java
.../wise/sc/cement/business/controller/ReportController.java
+1
-1
NormProductionServiceImpl.java
...ment/business/service/impl/NormProductionServiceImpl.java
+13
-53
WordUtil.java
...c/main/java/cn/wise/sc/cement/business/util/WordUtil.java
+28
-13
No files found.
cement-business/src/main/java/cn/wise/sc/cement/business/controller/NormProductionController.java
View file @
6728d2be
...
@@ -14,10 +14,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
...
@@ -14,10 +14,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
@@ -25,9 +21,7 @@ import org.springframework.web.bind.annotation.PutMapping;
...
@@ -25,9 +21,7 @@ import org.springframework.web.bind.annotation.PutMapping;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -95,7 +89,7 @@ public class NormProductionController {
...
@@ -95,7 +89,7 @@ public class NormProductionController {
@GetMapping
(
"/statistics"
)
@GetMapping
(
"/statistics"
)
@ApiOperation
(
"标准产值统计"
)
@ApiOperation
(
"标准产值统计"
)
public
BaseResponse
normProductionStatistics
(
String
start
,
String
end
,
String
name
,
PageQuery
pageQuery
)
{
public
BaseResponse
<
Page
<
NormProductionStatistics
>>
normProductionStatistics
(
String
start
,
String
end
,
String
name
,
PageQuery
pageQuery
)
{
Long
startTime
=
null
;
Long
startTime
=
null
;
Long
endTime
=
null
;
Long
endTime
=
null
;
...
@@ -113,12 +107,12 @@ public class NormProductionController {
...
@@ -113,12 +107,12 @@ public class NormProductionController {
return
BaseResponse
.
okData
(
rts
);
return
BaseResponse
.
okData
(
rts
);
}
}
}
}
return
baseResponse
;
return
BaseResponse
.
errorMsg
(
"没有找到相关数据!"
)
;
}
}
@GetMapping
(
"/statistics/detail"
)
@GetMapping
(
"/statistics/detail"
)
@ApiOperation
(
"标准产值详情"
)
@ApiOperation
(
"标准产值详情"
)
public
BaseResponse
normProductionDetails
(
Integer
userId
,
String
start
,
public
BaseResponse
<
Page
<
NormProduction
.
NormProductionDetail
>>
normProductionDetails
(
Integer
userId
,
String
start
,
String
end
,
PageQuery
pageQuery
)
{
String
end
,
PageQuery
pageQuery
)
{
Long
startTime
=
null
;
Long
startTime
=
null
;
Long
endTime
=
null
;
Long
endTime
=
null
;
...
@@ -131,12 +125,12 @@ public class NormProductionController {
...
@@ -131,12 +125,12 @@ public class NormProductionController {
Page
<
NormProduction
.
NormProductionDetail
>
rts
=
PageUtil
.
listConvertToPage
(
data
,
pageQuery
);
Page
<
NormProduction
.
NormProductionDetail
>
rts
=
PageUtil
.
listConvertToPage
(
data
,
pageQuery
);
return
BaseResponse
.
okData
(
rts
);
return
BaseResponse
.
okData
(
rts
);
}
}
return
BaseResponse
.
okData
(
data
);
return
BaseResponse
.
errorMsg
(
"没有找到相关数据!"
);
}
}
@GetMapping
(
"/total/production"
)
@GetMapping
(
"/total/production"
)
@ApiOperation
(
"总产值统计"
)
@ApiOperation
(
"总产值统计"
)
public
BaseResponse
production
(
PageQuery
pageQuery
,
String
name
,
String
start
,
String
end
)
{
public
BaseResponse
<
Page
<
ProductionVo
>>
production
(
PageQuery
pageQuery
,
String
name
,
String
start
,
String
end
)
{
Long
startTime
=
null
;
Long
startTime
=
null
;
Long
endTime
=
null
;
Long
endTime
=
null
;
...
...
cement-business/src/main/java/cn/wise/sc/cement/business/controller/ReportController.java
View file @
6728d2be
...
@@ -80,7 +80,7 @@ public class ReportController {
...
@@ -80,7 +80,7 @@ public class ReportController {
ReportDetailVo
rts
=
iEntrustService
.
getReportDetail
(
entrustId
);
ReportDetailVo
rts
=
iEntrustService
.
getReportDetail
(
entrustId
);
Map
<
String
,
Object
>
beanParams
=
new
HashMap
<>();
Map
<
String
,
Object
>
beanParams
=
new
HashMap
<>(
10
);
beanParams
.
put
(
"sendName"
,
rts
.
getSendName
());
beanParams
.
put
(
"sendName"
,
rts
.
getSendName
());
beanParams
.
put
(
"sender"
,
rts
.
getSender
());
beanParams
.
put
(
"sender"
,
rts
.
getSender
());
beanParams
.
put
(
"sendDate"
,
rts
.
getSendDate
());
beanParams
.
put
(
"sendDate"
,
rts
.
getSendDate
());
...
...
cement-business/src/main/java/cn/wise/sc/cement/business/service/impl/NormProductionServiceImpl.java
View file @
6728d2be
...
@@ -109,12 +109,12 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper,
...
@@ -109,12 +109,12 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper,
return
BaseResponse
.
errorMsg
(
"当前标准产值已存在!"
);
return
BaseResponse
.
errorMsg
(
"当前标准产值已存在!"
);
}
}
//判断比例是否为总值100%
//判断比例是否为总值100%
//
if (normProduction.getAnalyseRate()
if
(
normProduction
.
getAnalyseRate
()
//
+ normProduction.getAssessRate()
+
normProduction
.
getAssessRate
()
//
+ normProduction.getSeparateRate()
+
normProduction
.
getSeparateRate
()
//
+ normProduction.getReportedResultRate() != 1) {
+
normProduction
.
getReportedResultRate
()
!=
1
)
{
//
return BaseResponse.errorMsg("百分比总和不等于1");
return
BaseResponse
.
errorMsg
(
"百分比总和不等于1"
);
//
}
}
//状态为1
//状态为1
normProduction
.
setStatus
(
1
);
normProduction
.
setStatus
(
1
);
...
@@ -122,7 +122,7 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper,
...
@@ -122,7 +122,7 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper,
if
(
save
)
{
if
(
save
)
{
return
BaseResponse
.
okData
(
normProduction
);
return
BaseResponse
.
okData
(
normProduction
);
}
else
{
}
else
{
return
BaseResponse
.
errorMsg
(
"失败!"
);
return
BaseResponse
.
errorMsg
(
"失败!
除检测组id之外其他字段必填!
"
);
}
}
}
}
...
@@ -196,12 +196,12 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper,
...
@@ -196,12 +196,12 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper,
}
}
//判断比例是否为总值100%
//判断比例是否为总值100%
//
if (production.getAnalyseRate()
if
(
production
.
getAnalyseRate
()
//
+ production.getAssessRate()
+
production
.
getAssessRate
()
//
+ production.getSeparateRate()
+
production
.
getSeparateRate
()
//
+ production.getReportedResultRate() != 1) {
+
production
.
getReportedResultRate
()
!=
1
)
{
//
return BaseResponse.errorMsg("百分比总和不等于1");
return
BaseResponse
.
errorMsg
(
"百分比总和不等于1"
);
//
}
}
//判断配置项目是否已存在
//判断配置项目是否已存在
QueryWrapper
<
NormProduction
>
qw
=
new
QueryWrapper
<>();
QueryWrapper
<
NormProduction
>
qw
=
new
QueryWrapper
<>();
...
@@ -551,46 +551,6 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper,
...
@@ -551,46 +551,6 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper,
}
}
}
}
/**
* 计算校核单每条数据的标准产值
*
* @param qwCheck 统计条件
* @return 校核任务详情
*/
private
List
<
NormProduction
.
NormProductionDetail
>
calculateSampleCheck
(
QueryWrapper
<
SampleCheckTeam
>
qwCheck
)
{
//计算处理的绩效
List
<
SampleCheckTeam
>
sampleCheckTeams
=
iSampleCheckTeamService
.
list
(
qwCheck
);
List
<
EntrustSample
>
entrustSamples
=
iSampleCheckTeamService
.
getEntrustSample
();
List
<
NormProduction
.
NormProductionDetail
>
rts
=
new
ArrayList
<>(
sampleCheckTeams
.
size
());
for
(
SampleCheckTeam
sampleCheckTeam
:
sampleCheckTeams
)
{
//判断是否已经配置了 获取到核算处理的联表
EntrustSample
entrustSample
=
entrustSamples
.
stream
()
.
filter
(
arg
->
arg
.
getDistributionId
().
intValue
()
==
sampleCheckTeam
.
getId
())
.
findFirst
().
orElse
(
null
);
if
(
entrustSample
==
null
)
{
continue
;
}
//todo
String
key
=
entrustSample
.
getTeamGroupId
()
+
":"
+
"1"
;
//判断缓存是否存在
if
(!
normProductionCache
.
containsKey
(
key
))
{
//初始化
initNormProductionCache
();
}
NormProduction
normProduction
=
normProductionCache
.
get
(
key
);
NormProduction
.
NormProductionDetail
productionDetail
=
initNormProductionDetail
(
entrustSample
,
normProduction
,
normProduction
.
getAssessRate
());
productionDetail
.
setUserId
(
entrustSample
.
getUserId
());
productionDetail
.
setCheckTime
(
sampleCheckTeam
.
getCreateTime
());
productionDetail
.
setDistributionId
(
sampleCheckTeam
.
getId
());
productionDetail
.
setAssessId
(
entrustSample
.
getTeamGroupId
());
rts
.
add
(
productionDetail
);
}
return
rts
;
}
/**
/**
* 计算处理派发单每条数据的标准产值
* 计算处理派发单每条数据的标准产值
*
*
...
...
cement-business/src/main/java/cn/wise/sc/cement/business/util/WordUtil.java
View file @
6728d2be
...
@@ -2,7 +2,7 @@ package cn.wise.sc.cement.business.util;
...
@@ -2,7 +2,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
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
;
...
@@ -11,7 +11,6 @@ import java.io.FileOutputStream;
...
@@ -11,7 +11,6 @@ import java.io.FileOutputStream;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.OutputStreamWriter
;
import
java.io.OutputStreamWriter
;
import
java.io.Writer
;
import
java.io.Writer
;
import
java.net.URLEncoder
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -20,24 +19,29 @@ import java.util.Map;
...
@@ -20,24 +19,29 @@ import java.util.Map;
* @author: qh
* @author: qh
* @create: 2020-10-10 15:22
* @create: 2020-10-10 15:22
**/
**/
@Slf4j
public
class
WordUtil
{
public
class
WordUtil
{
/**
/**
* 模板路径
* 模板路径
*/
*/
private
static
final
String
FTL_FP
=
"/templates/"
;
private
static
final
String
FTL_FP
=
"/templates/"
;
private
static
Configuration
configuration
;
private
static
Configuration
configuration
;
static
{
static
{
configuration
=
new
Configuration
(
Configuration
.
DEFAULT_INCOMPATIBLE_IMPROVEMENTS
);
configuration
=
new
Configuration
(
Configuration
.
DEFAULT_INCOMPATIBLE_IMPROVEMENTS
);
configuration
.
setDefaultEncoding
(
"utf-8"
);
configuration
.
setDefaultEncoding
(
"utf-8"
);
//读配置文件
// path = PropertiesUtil.get("FILE_PATH")+"/";
}
}
public
static
Boolean
writeWordReport
(
/**
* 根据模板导出office文件
*
* @param templeName 导出的文件名
* @param templateFileName 模板名字
* @param beanParams 替换模板中的参数 <${模板占位符},对应值>
* @param response 响应体
*/
public
static
void
writeWordReport
(
String
templeName
,
String
templeName
,
String
templateFileName
,
String
templateFileName
,
Map
<
String
,
Object
>
beanParams
,
Map
<
String
,
Object
>
beanParams
,
...
@@ -53,7 +57,12 @@ public class WordUtil {
...
@@ -53,7 +57,12 @@ public class WordUtil {
filePath
=
""
;
filePath
=
""
;
File
file1
=
new
File
(
filePath
);
File
file1
=
new
File
(
filePath
);
if
(!
file1
.
exists
())
{
if
(!
file1
.
exists
())
{
file1
.
mkdirs
();
boolean
mkdirs
=
file1
.
mkdirs
();
if
(!
mkdirs
)
{
response
.
getWriter
().
write
(
"导出失败,文件命名冲突!"
);
log
.
debug
(
"创建报告导出文件失败!"
);
return
;
}
}
}
//变量替换
//变量替换
//输出文件
//输出文件
...
@@ -63,9 +72,14 @@ public class WordUtil {
...
@@ -63,9 +72,14 @@ public class WordUtil {
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
()];
in
.
read
(
buffer
);
int
i
=
in
.
read
(
buffer
);
if
(
i
==
-
1
){
return
;
}
in
.
close
();
in
.
close
();
response
.
reset
();
response
.
reset
();
ServletOutputStream
outputStream
=
response
.
getOutputStream
();
ServletOutputStream
outputStream
=
response
.
getOutputStream
();
response
.
setCharacterEncoding
(
StandardCharsets
.
UTF_8
.
toString
());
response
.
setCharacterEncoding
(
StandardCharsets
.
UTF_8
.
toString
());
...
@@ -75,15 +89,16 @@ public class WordUtil {
...
@@ -75,15 +89,16 @@ public class WordUtil {
outputStream
.
write
(
buffer
);
outputStream
.
write
(
buffer
);
outputStream
.
flush
();
outputStream
.
flush
();
outputStream
.
close
();
outputStream
.
close
();
return
true
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
return
false
;
}
finally
{
}
finally
{
try
{
try
{
if
(
out
!=
null
)
{
if
(
out
!=
null
)
{
out
.
close
();
out
.
close
();
file
.
delete
();
boolean
delete
=
file
.
delete
();
if
(!
delete
)
{
log
.
debug
(
file
.
getName
()
+
"文件删除失败!"
);
}
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
...
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