Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
indicators
Overview
Overview
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
zhangkb
indicators
Commits
5a0c17c1
Commit
5a0c17c1
authored
Jun 16, 2020
by
张祺
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
指标值的导入功能实现并增加审批记录功能
parent
1a3bd09d
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
447 additions
and
29 deletions
+447
-29
pom.xml
pom.xml
+9
-3
DataEnterCtrl.java
...com/keymobile/indicators/api/hytobacco/DataEnterCtrl.java
+126
-0
ExcelTempCtrl.java
...com/keymobile/indicators/api/hytobacco/ExcelTempCtrl.java
+89
-1
TaskCtrl.java
...java/com/keymobile/indicators/api/hytobacco/TaskCtrl.java
+15
-9
AuditRecord.java
...mobile/indicators/model/entity/dataenter/AuditRecord.java
+38
-0
ExcelIndicator.java
...ile/indicators/model/entity/dataenter/ExcelIndicator.java
+0
-5
ExcelTemplate.java
...bile/indicators/model/entity/dataenter/ExcelTemplate.java
+5
-0
TaskAssginParam.java
...le/indicators/model/entity/dataenter/TaskAssginParam.java
+1
-1
TaskAuditRecordMapper.java
...cators/model/mapper/indicators/TaskAuditRecordMapper.java
+20
-0
TaskIndValueMapper.java
...ndicators/model/mapper/indicators/TaskIndValueMapper.java
+7
-1
TaskService.java
...m/keymobile/indicators/service/dataenter/TaskService.java
+22
-3
TaskServiceImpl.java
...le/indicators/service/dataenter/impl/TaskServiceImpl.java
+60
-4
ExcelUtil.java
src/main/java/com/keymobile/indicators/utils/ExcelUtil.java
+30
-0
TaskAuditRecord.xml
src/main/resources/mybatis/mapping/TaskAuditRecord.xml
+15
-0
TaskIndicatorValueMapper.xml
...in/resources/mybatis/mapping/TaskIndicatorValueMapper.xml
+10
-2
No files found.
pom.xml
View file @
5a0c17c1
...
@@ -21,6 +21,8 @@
...
@@ -21,6 +21,8 @@
<java.version>
1.8
</java.version>
<java.version>
1.8
</java.version>
<spring-cloud.version>
Finchley.RELEASE
</spring-cloud.version>
<spring-cloud.version>
Finchley.RELEASE
</spring-cloud.version>
<akka.version>
2.6.0-M4
</akka.version>
<akka.version>
2.6.0-M4
</akka.version>
<poi.version>
4.1.1
</poi.version>
<easyExcel.version>
2.1.1
</easyExcel.version>
</properties>
</properties>
<dependencies>
<dependencies>
...
@@ -116,14 +118,18 @@
...
@@ -116,14 +118,18 @@
<dependency>
<dependency>
<groupId>
org.apache.poi
</groupId>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi
</artifactId>
<artifactId>
poi
</artifactId>
<version>
3.10-FINAL
</version>
<version>
${poi.version}
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.apache.poi
</groupId>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi-ooxml
</artifactId>
<artifactId>
poi-ooxml
</artifactId>
<version>
3.10-FINAL
</version>
<version>
${poi.version}
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
easyexcel
</artifactId>
<version>
${easyExcel.version}
</version>
</dependency>
</dependency>
<!-- mybatis -->
<!-- mybatis -->
<dependency>
<dependency>
<groupId>
org.mybatis.spring.boot
</groupId>
<groupId>
org.mybatis.spring.boot
</groupId>
...
...
src/main/java/com/keymobile/indicators/api/hytobacco/DataEnterCtrl.java
View file @
5a0c17c1
...
@@ -5,6 +5,8 @@ import com.keymobile.indicators.model.entity.dataenter.*;
...
@@ -5,6 +5,8 @@ import com.keymobile.indicators.model.entity.dataenter.*;
import
com.keymobile.indicators.result.Result
;
import
com.keymobile.indicators.result.Result
;
import
com.keymobile.indicators.service.dataenter.ExcelTemplateService
;
import
com.keymobile.indicators.service.dataenter.ExcelTemplateService
;
import
com.keymobile.indicators.service.dataenter.TaskService
;
import
com.keymobile.indicators.service.dataenter.TaskService
;
import
com.keymobile.indicators.utils.DateUtils
;
import
com.keymobile.indicators.utils.ExcelUtil
;
import
com.keymobile.indicators.utils.IdWorker
;
import
com.keymobile.indicators.utils.IdWorker
;
import
com.keymobile.indicators.utils.SystemUserUtil
;
import
com.keymobile.indicators.utils.SystemUserUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
...
@@ -12,6 +14,9 @@ import io.swagger.annotations.ApiOperation;
...
@@ -12,6 +14,9 @@ import io.swagger.annotations.ApiOperation;
import
io.swagger.annotations.ApiParam
;
import
io.swagger.annotations.ApiParam
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.poi.xssf.usermodel.XSSFRow
;
import
org.apache.poi.xssf.usermodel.XSSFSheet
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
@@ -19,6 +24,7 @@ import org.springframework.web.multipart.MultipartFile;
...
@@ -19,6 +24,7 @@ import org.springframework.web.multipart.MultipartFile;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
...
@@ -127,9 +133,77 @@ public class DataEnterCtrl {
...
@@ -127,9 +133,77 @@ public class DataEnterCtrl {
try
{
try
{
InputStream
is
=
file
.
getInputStream
();
InputStream
is
=
file
.
getInputStream
();
XSSFWorkbook
xssfWorkbook
=
new
XSSFWorkbook
(
is
);
XSSFWorkbook
xssfWorkbook
=
new
XSSFWorkbook
(
is
);
XSSFSheet
sheet
=
xssfWorkbook
.
getSheetAt
(
0
);
ExcelTemplate
template
=
excelTemplateService
.
getByTaskId
(
taskId
);
ExcelTemplate
template
=
excelTemplateService
.
getByTaskId
(
taskId
);
List
<
ExcelIndicator
>
inds
=
template
.
getInds
();
List
<
ExcelIndicator
>
inds
=
template
.
getInds
();
List
<
ExcelObj
>
objs
=
template
.
getObjs
();
List
<
ExcelObj
>
objs
=
template
.
getObjs
();
boolean
hasSameTerm
=
false
;
//需要同期?
int
startRow
=
1
;
int
startColumn
=
1
;
int
lastRow
=
sheet
.
getLastRowNum
();
String
sameTermValutTime
=
null
;
Task
task
=
taskService
.
getById
(
taskId
);
if
(
template
.
getNeedSameTerm
()
!=
null
&&
template
.
getNeedSameTerm
())
{
hasSameTerm
=
true
;
sameTermValutTime
=
getSameTermValueTime
(
task
.
getValueTime
());
}
StringBuilder
sb
=
new
StringBuilder
();
List
<
TaskIndValue
>
taskIndValues
=
new
ArrayList
<>();
if
(
template
.
getCType
()
==
1
)
{
// 指标是列值
if
(
hasSameTerm
)
{
startRow
=
2
;
}
for
(
int
i
=
0
;
i
<
objs
.
size
();
i
++)
{
int
t
=
i
+
startRow
;
XSSFRow
row
=
sheet
.
getRow
(
t
);
ExcelObj
obj
=
objs
.
get
(
i
);
int
start
=
startColumn
;
for
(
int
j
=
0
;
j
<
inds
.
size
();
j
++)
{
ExcelIndicator
ind
=
inds
.
get
(
j
);
String
val1
=
ExcelUtil
.
getXSSFCellValue
(
row
.
getCell
(
j
+
start
));
String
val2
=
ExcelUtil
.
getXSSFCellValue
(
row
.
getCell
(
j
+
start
+
1
));
TaskIndValue
value
=
this
.
doGenTaskIndValue
(
val1
,
obj
,
ind
,
template
.
getId
(),
taskId
,
task
.
getValueTime
(),
userId
,
now
);
taskIndValues
.
add
(
value
);
if
(
hasSameTerm
)
{
TaskIndValue
value2
=
this
.
doGenTaskIndValue
(
val2
,
obj
,
ind
,
template
.
getId
(),
taskId
,
sameTermValutTime
,
userId
,
now
);
taskIndValues
.
add
(
value2
);
start
++;
}
}
}
}
else
{
if
(
hasSameTerm
)
{
startColumn
=
2
;
}
for
(
int
i
=
0
;
i
<
inds
.
size
();
i
++)
{
int
t
=
i
+
startRow
;
XSSFRow
row
=
sheet
.
getRow
(
t
);
ExcelIndicator
ind
=
inds
.
get
(
i
);
for
(
int
j
=
0
;
j
<
objs
.
size
();
j
++)
{
ExcelObj
obj
=
objs
.
get
(
j
);
String
val1
=
ExcelUtil
.
getXSSFCellValue
(
row
.
getCell
(
startColumn
+
j
));
TaskIndValue
value
=
this
.
doGenTaskIndValue
(
val1
,
obj
,
ind
,
template
.
getId
(),
taskId
,
task
.
getValueTime
(),
userId
,
now
);
taskIndValues
.
add
(
value
);
if
(
hasSameTerm
)
{
XSSFRow
row2
=
sheet
.
getRow
(
t
+
1
);
startRow
++;
String
val2
=
ExcelUtil
.
getXSSFCellValue
(
row2
.
getCell
(
startColumn
+
j
));
TaskIndValue
value2
=
this
.
doGenTaskIndValue
(
val2
,
obj
,
ind
,
template
.
getId
(),
taskId
,
sameTermValutTime
,
userId
,
now
);
startRow
--;
taskIndValues
.
add
(
value2
);
}
}
startRow
++;
}
}
taskService
.
saveTaskValues
(
taskIndValues
,
taskId
,
Constants
.
INPUT_EXCEL
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"数据填报导入出错:taskId="
+
taskId
,
e
);
log
.
error
(
"数据填报导入出错:taskId="
+
taskId
,
e
);
result
=
Result
.
genFailedResult
(
"导入excel出错"
);
result
=
Result
.
genFailedResult
(
"导入excel出错"
);
...
@@ -137,4 +211,56 @@ public class DataEnterCtrl {
...
@@ -137,4 +211,56 @@ public class DataEnterCtrl {
return
result
;
return
result
;
}
}
/**
* 获取同期时间
* @param valueTime
* @return
* @throws Exception
*/
private
String
getSameTermValueTime
(
String
valueTime
)
throws
Exception
{
String
format
=
"yyyy-MM"
;
Date
date
=
DateUtils
.
getDate
(
valueTime
,
format
);
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
date
);
calendar
.
add
(
Calendar
.
YEAR
,
-
1
);
date
=
calendar
.
getTime
();
return
DateUtils
.
formatDate
(
date
,
format
);
}
/**
* 生成指标值对象
* @param indValue
* @param obj
* @param ind
* @param tempId
* @param taskId
* @param valueTime
* @param userId
* @param now
* @return
*/
private
TaskIndValue
doGenTaskIndValue
(
String
indValue
,
ExcelObj
obj
,
ExcelIndicator
ind
,
Integer
tempId
,
String
taskId
,
String
valueTime
,
String
userId
,
Date
now
)
{
TaskIndValue
value
=
new
TaskIndValue
();
value
.
setId
(
IdWorker
.
getStrId
());
value
.
setTempId
(
tempId
);
value
.
setObjType
(
obj
.
getObjType
());
value
.
setObjName
(
obj
.
getObjName
());
value
.
setObjId
(
obj
.
getObjId
());
value
.
setValueTime
(
valueTime
);
value
.
setIndId
(
ind
.
getIndId
());
value
.
setIndUnit
(
ind
.
getIndUnit
());
value
.
setIndName
(
ind
.
getIndName
());
value
.
setIndSource
(
ind
.
getIndSource
());
value
.
setIndValue
(
indValue
);
value
.
setTaskId
(
taskId
);
value
.
setCreator
(
userId
);
value
.
setUpdater
(
userId
);
value
.
setUpdateTime
(
now
);
value
.
setCreateTime
(
now
);
value
.
setState
(
Constants
.
DATA_STATE_A
);
return
value
;
}
}
}
src/main/java/com/keymobile/indicators/api/hytobacco/ExcelTempCtrl.java
View file @
5a0c17c1
package
com
.
keymobile
.
indicators
.
api
.
hytobacco
;
package
com
.
keymobile
.
indicators
.
api
.
hytobacco
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.support.ExcelTypeEnum
;
import
com.alibaba.excel.write.builder.ExcelWriterBuilder
;
import
com.alibaba.excel.write.merge.OnceAbsoluteMergeStrategy
;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
import
com.keymobile.indicators.model.entity.dataenter.ExcelIndicator
;
import
com.keymobile.indicators.model.entity.dataenter.ExcelObj
;
import
com.keymobile.indicators.model.entity.dataenter.ExcelTemplate
;
import
com.keymobile.indicators.model.entity.dataenter.ExcelTemplate
;
import
com.keymobile.indicators.result.Result
;
import
com.keymobile.indicators.result.Result
;
import
com.keymobile.indicators.service.dataenter.ExcelTemplateService
;
import
com.keymobile.indicators.service.dataenter.ExcelTemplateService
;
...
@@ -8,6 +14,7 @@ import com.keymobile.indicators.utils.SystemUserUtil;
...
@@ -8,6 +14,7 @@ import com.keymobile.indicators.utils.SystemUserUtil;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
io.swagger.annotations.ApiParam
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
@@ -15,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
...
@@ -15,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.net.URLEncoder
;
import
java.net.URLEncoder
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -22,6 +30,7 @@ import java.util.Map;
...
@@ -22,6 +30,7 @@ import java.util.Map;
@Api
(
tags
={
"数据填报-填报excel模板管理"
})
@Api
(
tags
={
"数据填报-填报excel模板管理"
})
@RestController
@RestController
@RequestMapping
(
value
=
"/excel"
)
@RequestMapping
(
value
=
"/excel"
)
@Slf4j
public
class
ExcelTempCtrl
{
public
class
ExcelTempCtrl
{
@Autowired
@Autowired
...
@@ -86,15 +95,94 @@ public class ExcelTempCtrl {
...
@@ -86,15 +95,94 @@ public class ExcelTempCtrl {
response
.
setContentType
(
"application/vnd.ms-excel"
);
response
.
setContentType
(
"application/vnd.ms-excel"
);
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setCharacterEncoding
(
"utf-8"
);
ExcelTemplate
template
=
excelTemplateService
.
getById
(
id
);
ExcelTemplate
template
=
excelTemplateService
.
getById
(
id
);
List
<
ExcelIndicator
>
inds
=
template
.
getInds
();
List
<
ExcelObj
>
objs
=
template
.
getObjs
();
String
fileName
=
URLEncoder
.
encode
(
template
.
getName
(),
"UTF-8"
);
String
fileName
=
URLEncoder
.
encode
(
template
.
getName
(),
"UTF-8"
);
List
<
List
<
String
>>
datas
=
new
ArrayList
<>();
boolean
hasSameTerm
=
false
;
//需要同期?
if
(
template
.
getNeedSameTerm
()
!=
null
&&
template
.
getNeedSameTerm
())
{
hasSameTerm
=
true
;
}
List
<
OnceAbsoluteMergeStrategy
>
merges
=
new
ArrayList
<>();
List
<
List
<
String
>>
headers
=
new
ArrayList
<>();
if
(
template
.
getCType
()
==
1
)
{
// 列类型:1、指标 2 考核对象
List
<
String
>
column1
=
new
ArrayList
<>();
column1
.
add
(
""
);
headers
.
add
(
column1
);
for
(
ExcelIndicator
indicator
:
inds
)
{
List
<
String
>
header
=
new
ArrayList
<>();
headers
.
add
(
header
);
header
.
add
(
indicator
.
getIndName
());
if
(
hasSameTerm
)
{
header
.
add
(
"本期"
);
List
<
String
>
header2
=
new
ArrayList
<>();
headers
.
add
(
header2
);
header2
.
add
(
indicator
.
getIndName
());
header2
.
add
(
"同期"
);
hasSameTerm
=
true
;
}
}
if
(
hasSameTerm
)
{
//如果有同期值需要占据两行
column1
.
add
(
""
);
}
for
(
ExcelObj
obj
:
objs
)
{
List
<
String
>
data
=
new
ArrayList
<>();
data
.
add
(
obj
.
getObjName
());
datas
.
add
(
data
);
}
}
else
{
int
i
=
1
;
for
(
ExcelIndicator
indicator
:
inds
)
{
List
<
String
>
data
=
new
ArrayList
<>();
datas
.
add
(
data
);
data
.
add
(
indicator
.
getIndName
());
if
(
hasSameTerm
)
{
OnceAbsoluteMergeStrategy
mergeStrategy
=
new
OnceAbsoluteMergeStrategy
(
i
,
i
+
1
,
0
,
0
);
i
+=
2
;
merges
.
add
(
mergeStrategy
);
List
<
String
>
h2
=
new
ArrayList
<>();
data
.
add
(
"本期"
);
h2
.
add
(
""
);
h2
.
add
(
"同期"
);
datas
.
add
(
h2
);
}
}
List
<
String
>
column1
=
new
ArrayList
<>();
column1
.
add
(
""
);
headers
.
add
(
column1
);
for
(
ExcelObj
obj
:
objs
)
{
List
<
String
>
header
=
new
ArrayList
<>();
header
.
add
(
obj
.
getObjName
());
headers
.
add
(
header
);
}
if
(
hasSameTerm
)
{
//如果有同期值,需要占据两列
List
<
String
>
column2
=
new
ArrayList
<>();
column2
.
add
(
""
);
headers
.
add
(
0
,
column2
);
}
}
response
.
setHeader
(
"Content-disposition"
,
"attachment;filename="
+
fileName
+
".xlsx"
);
response
.
setHeader
(
"Content-disposition"
,
"attachment;filename="
+
fileName
+
".xlsx"
);
ExcelWriterBuilder
writerBuilder
=
EasyExcel
.
write
(
response
.
getOutputStream
());
if
(
hasSameTerm
&&
merges
.
size
()
>
0
)
{
for
(
OnceAbsoluteMergeStrategy
mergeStrategy
:
merges
)
{
writerBuilder
.
registerWriteHandler
(
mergeStrategy
);
}
}
writerBuilder
.
excelType
(
ExcelTypeEnum
.
XLSX
).
head
(
headers
)
.
autoCloseStream
(
false
).
sheet
(
"数据填报"
).
doWrite
(
datas
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"生成excel模板出错"
,
e
);
response
.
reset
();
response
.
reset
();
response
.
setContentType
(
"application/json"
);
response
.
setContentType
(
"application/json"
);
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setCharacterEncoding
(
"utf-8"
);
Map
<
String
,
String
>
map
=
new
HashMap
<>(
4
);
Map
<
String
,
String
>
map
=
new
HashMap
<>(
4
);
map
.
put
(
"status"
,
"failure"
);
map
.
put
(
"status"
,
"failure"
);
map
.
put
(
"message"
,
"导出模板失败"
+
e
.
getMessage
()
);
map
.
put
(
"message"
,
"导出模板失败"
);
Gson
gson
=
new
Gson
();
Gson
gson
=
new
Gson
();
response
.
getWriter
().
write
(
gson
.
toJson
(
map
));
response
.
getWriter
().
write
(
gson
.
toJson
(
map
));
}
}
...
...
src/main/java/com/keymobile/indicators/api/hytobacco/TaskCtrl.java
View file @
5a0c17c1
package
com
.
keymobile
.
indicators
.
api
.
hytobacco
;
package
com
.
keymobile
.
indicators
.
api
.
hytobacco
;
import
com.keymobile.indicators.model.entity.dataenter.QueryTaskParam
;
import
com.keymobile.indicators.model.entity.dataenter.*
;
import
com.keymobile.indicators.model.entity.dataenter.Task
;
import
com.keymobile.indicators.model.entity.dataenter.TaskAssginParam
;
import
com.keymobile.indicators.model.entity.dataenter.TaskAuditResult
;
import
com.keymobile.indicators.result.Result
;
import
com.keymobile.indicators.result.Result
;
import
com.keymobile.indicators.service.dataenter.TaskRuleService
;
import
com.keymobile.indicators.service.dataenter.TaskRuleService
;
import
com.keymobile.indicators.service.dataenter.TaskService
;
import
com.keymobile.indicators.service.dataenter.TaskService
;
import
com.keymobile.indicators.utils.SystemUserUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
io.swagger.annotations.ApiParam
;
...
@@ -14,6 +12,8 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -14,6 +12,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
@Api
(
tags
={
"数据填报-填报任务管理"
})
@Api
(
tags
={
"数据填报-填报任务管理"
})
@RestController
@RestController
@RequestMapping
(
value
=
"/task"
)
@RequestMapping
(
value
=
"/task"
)
...
@@ -53,17 +53,23 @@ public class TaskCtrl {
...
@@ -53,17 +53,23 @@ public class TaskCtrl {
}
}
@ApiOperation
(
"提交任务去审核"
)
@ApiOperation
(
"提交任务去审核"
)
@
Pos
tMapping
(
"toSubmit"
)
@
Ge
tMapping
(
"toSubmit"
)
public
Result
toSubmit
(
@ApiParam
(
name
=
"任务id"
)
@RequestParam
String
id
)
{
public
Result
toSubmit
(
@ApiParam
(
name
=
"任务id"
)
@RequestParam
(
"taskId"
)
String
id
)
{
taskService
.
submitTask
(
id
,
SystemUserUtil
.
getCurrentUserId
());
return
Result
.
genOkResult
();
return
Result
.
genOkResult
();
}
}
@ApiOperation
(
"审核任务"
)
@ApiOperation
(
"审核任务"
)
@PostMapping
(
"audit"
)
@PostMapping
(
"audit"
)
public
Result
audit
(
@ApiParam
(
name
=
"
任务id
"
)
@RequestBody
TaskAuditResult
param
)
{
public
Result
audit
(
@ApiParam
(
name
=
"
审核信息
"
)
@RequestBody
TaskAuditResult
param
)
{
taskService
.
auditTask
(
param
,
SystemUserUtil
.
getCurrentUserId
());
return
Result
.
genOkResult
();
return
Result
.
genOkResult
();
}
}
@ApiOperation
(
"根据任务id获取审批记录"
)
@GetMapping
(
"findAuditRecord"
)
public
List
<
AuditRecord
>
findAuditRecord
(
@ApiParam
(
name
=
"任务id"
)
@RequestParam
(
"taskId"
)
String
id
)
{
return
taskService
.
findAuditRecordByTaskId
(
id
);
}
}
}
src/main/java/com/keymobile/indicators/model/entity/dataenter/AuditRecord.java
0 → 100644
View file @
5a0c17c1
package
com
.
keymobile
.
indicators
.
model
.
entity
.
dataenter
;
import
com.keymobile.indicators.model.entity.BaseModel
;
import
lombok.Data
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
/**
* 任务填报记录内容
*/
@Data
@Table
(
name
=
"data_enter_task_record"
)
public
class
AuditRecord
extends
BaseModel
{
@Id
private
String
id
;
/**
* 所属任务Id
*/
private
String
taskId
;
/**
* 所属任务父id
*/
private
String
pTaskId
;
/**
* 操作记录类型
*/
private
String
recordType
;
/**
* 内容描述
*/
private
String
description
;
}
src/main/java/com/keymobile/indicators/model/entity/dataenter/ExcelIndicator.java
View file @
5a0c17c1
...
@@ -45,11 +45,6 @@ public class ExcelIndicator extends BaseModel {
...
@@ -45,11 +45,6 @@ public class ExcelIndicator extends BaseModel {
private
Integer
indSource
;
private
Integer
indSource
;
/**
/**
* 是否需要同期值
*/
private
Boolean
needSameTerm
;
/**
* 顺序号
* 顺序号
*/
*/
private
Integer
orderNum
;
private
Integer
orderNum
;
...
...
src/main/java/com/keymobile/indicators/model/entity/dataenter/ExcelTemplate.java
View file @
5a0c17c1
...
@@ -28,6 +28,11 @@ public class ExcelTemplate extends BaseModel {
...
@@ -28,6 +28,11 @@ public class ExcelTemplate extends BaseModel {
private
Integer
cType
;
private
Integer
cType
;
/**
/**
* 是否需要同期值
*/
private
Boolean
needSameTerm
;
/**
* 任务规则id
* 任务规则id
*/
*/
private
Integer
ruleId
;
private
Integer
ruleId
;
...
...
src/main/java/com/keymobile/indicators/model/entity/dataenter/TaskAssginParam.java
View file @
5a0c17c1
...
@@ -25,6 +25,6 @@ public class TaskAssginParam {
...
@@ -25,6 +25,6 @@ public class TaskAssginParam {
@ApiModelProperty
(
"把任务分发给对象id"
)
@ApiModelProperty
(
"把任务分发给对象id"
)
private
List
<
String
>
objIds
;
private
List
<
String
>
objIds
;
@ApiModelProperty
(
"分发对象类型: 1 组织机构 2 人员"
)
@ApiModelProperty
(
"分发对象类型: 1 组织机构 2 人员
3 角色
"
)
private
int
objType
=
1
;
private
int
objType
=
1
;
}
}
src/main/java/com/keymobile/indicators/model/mapper/indicators/TaskAuditRecordMapper.java
0 → 100644
View file @
5a0c17c1
package
com
.
keymobile
.
indicators
.
model
.
mapper
.
indicators
;
import
com.keymobile.indicators.model.entity.dataenter.AuditRecord
;
import
com.keymobile.indicators.model.entity.dataenter.TaskRuleIndicator
;
import
org.apache.ibatis.annotations.Mapper
;
import
tk.mybatis.mapper.common.BaseMapper
;
import
java.util.List
;
@Mapper
public
interface
TaskAuditRecordMapper
extends
BaseMapper
<
AuditRecord
>
{
/**
* 根据任务id获取处理记录
* @param taskId
* @return
*/
List
<
AuditRecord
>
getByTaskId
(
String
taskId
);
}
src/main/java/com/keymobile/indicators/model/mapper/indicators/TaskIndValueMapper.java
View file @
5a0c17c1
...
@@ -14,7 +14,7 @@ public interface TaskIndValueMapper extends BaseMapper<TaskIndValue> {
...
@@ -14,7 +14,7 @@ public interface TaskIndValueMapper extends BaseMapper<TaskIndValue> {
* 批量插入填报值
* 批量插入填报值
* @param valueList
* @param valueList
*/
*/
void
batchInsert
(
List
<
TaskIndValue
>
valueList
);
void
batchInsert
(
@Param
(
"valueList"
)
List
<
TaskIndValue
>
valueList
);
/**
/**
* 根据任务id获取填报数据项值
* 根据任务id获取填报数据项值
...
@@ -51,4 +51,10 @@ public interface TaskIndValueMapper extends BaseMapper<TaskIndValue> {
...
@@ -51,4 +51,10 @@ public interface TaskIndValueMapper extends BaseMapper<TaskIndValue> {
* @return
* @return
*/
*/
List
<
TaskIndValue
>
findDefaultValues
(
@Param
(
"valueTime"
)
String
valueTime
,
@Param
(
"ids"
)
List
<
String
>
ids
);
List
<
TaskIndValue
>
findDefaultValues
(
@Param
(
"valueTime"
)
String
valueTime
,
@Param
(
"ids"
)
List
<
String
>
ids
);
/**
* 审批通过指标值
* @param taskId
*/
void
updateTaskValueToPass
(
@Param
(
"taskId"
)
String
taskId
);
}
}
src/main/java/com/keymobile/indicators/service/dataenter/TaskService.java
View file @
5a0c17c1
package
com
.
keymobile
.
indicators
.
service
.
dataenter
;
package
com
.
keymobile
.
indicators
.
service
.
dataenter
;
import
com.keymobile.indicators.model.entity.dataenter.QueryTaskParam
;
import
com.keymobile.indicators.model.entity.dataenter.*
;
import
com.keymobile.indicators.model.entity.dataenter.Task
;
import
com.keymobile.indicators.model.entity.dataenter.TaskIndValue
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
java.util.List
;
import
java.util.List
;
...
@@ -91,4 +89,25 @@ public interface TaskService {
...
@@ -91,4 +89,25 @@ public interface TaskService {
* @return
* @return
*/
*/
List
<
TaskIndValue
>
findDefaultValues
(
String
valueTime
,
List
<
String
>
indIds
);
List
<
TaskIndValue
>
findDefaultValues
(
String
valueTime
,
List
<
String
>
indIds
);
/**
* 提交任务
* @param taskId
* @param userId 提交人id
*/
void
submitTask
(
String
taskId
,
String
userId
);
/**
* 审批任务
* @param auditResult
* @param auditUserId 审批人id
*/
void
auditTask
(
TaskAuditResult
auditResult
,
String
auditUserId
);
/**
* 根据任务id获取审批记录
* @param taskId
* @return
*/
List
<
AuditRecord
>
findAuditRecordByTaskId
(
String
taskId
);
}
}
src/main/java/com/keymobile/indicators/service/dataenter/impl/TaskServiceImpl.java
View file @
5a0c17c1
package
com
.
keymobile
.
indicators
.
service
.
dataenter
.
impl
;
package
com
.
keymobile
.
indicators
.
service
.
dataenter
.
impl
;
import
com.keymobile.indicators.constant.Constants
;
import
com.keymobile.indicators.constant.Constants
;
import
com.keymobile.indicators.model.entity.dataenter.QueryTaskParam
;
import
com.keymobile.indicators.model.entity.dataenter.*
;
import
com.keymobile.indicators.model.entity.dataenter.Task
;
import
com.keymobile.indicators.model.mapper.indicators.TaskAuditRecordMapper
;
import
com.keymobile.indicators.model.entity.dataenter.TaskIndValue
;
import
com.keymobile.indicators.model.entity.dataenter.TaskIndicator
;
import
com.keymobile.indicators.model.mapper.indicators.TaskIndValueMapper
;
import
com.keymobile.indicators.model.mapper.indicators.TaskIndValueMapper
;
import
com.keymobile.indicators.model.mapper.indicators.TaskIndicatorMapper
;
import
com.keymobile.indicators.model.mapper.indicators.TaskIndicatorMapper
;
import
com.keymobile.indicators.model.mapper.indicators.TaskMapper
;
import
com.keymobile.indicators.model.mapper.indicators.TaskMapper
;
...
@@ -34,6 +32,9 @@ public class TaskServiceImpl implements TaskService {
...
@@ -34,6 +32,9 @@ public class TaskServiceImpl implements TaskService {
@Autowired
@Autowired
private
TaskIndValueMapper
taskIndValueMapper
;
private
TaskIndValueMapper
taskIndValueMapper
;
@Autowired
private
TaskAuditRecordMapper
taskAuditRecordMapper
;
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Task
createTask
(
Task
task
)
{
public
Task
createTask
(
Task
task
)
{
...
@@ -121,4 +122,59 @@ public class TaskServiceImpl implements TaskService {
...
@@ -121,4 +122,59 @@ public class TaskServiceImpl implements TaskService {
public
List
<
TaskIndValue
>
findDefaultValues
(
String
valueTime
,
List
<
String
>
indIds
)
{
public
List
<
TaskIndValue
>
findDefaultValues
(
String
valueTime
,
List
<
String
>
indIds
)
{
return
taskIndValueMapper
.
findDefaultValues
(
valueTime
,
indIds
);
return
taskIndValueMapper
.
findDefaultValues
(
valueTime
,
indIds
);
}
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
submitTask
(
String
taskId
,
String
userId
)
{
Date
now
=
new
Date
();
Task
task
=
taskMapper
.
selectByPrimaryKey
(
taskId
);
//TODO
task
.
setAuditUsers
(
",1,"
);
task
.
setUpdater
(
userId
);
task
.
setUpdateTime
(
now
);
task
.
setStatus
(
Constants
.
APPLY_STATE_AUDITING
);
taskMapper
.
updateByPrimaryKey
(
task
);
AuditRecord
auditRecord
=
new
AuditRecord
();
auditRecord
.
setRecordType
(
"提交"
);
auditRecord
.
setTaskId
(
taskId
);
auditRecord
.
setId
(
IdWorker
.
getStrId
());
auditRecord
.
setPTaskId
(
task
.
getPId
());
auditRecord
.
setCreator
(
userId
);
auditRecord
.
setUpdater
(
userId
);
auditRecord
.
setUpdateTime
(
now
);
auditRecord
.
setCreateTime
(
now
);
taskAuditRecordMapper
.
insert
(
auditRecord
);
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
auditTask
(
TaskAuditResult
auditResult
,
String
auditUserId
)
{
Date
now
=
new
Date
();
Task
task
=
taskMapper
.
selectByPrimaryKey
(
auditResult
.
getTaskId
());
task
.
setUpdateTime
(
now
);
int
status
=
Constants
.
APPLY_STATE_REJECTED
;
String
recordType
=
"审批拒绝"
;
if
(
auditResult
.
isResult
())
{
status
=
Constants
.
APPLY_STATE_PASSED
;
recordType
=
"审批通过"
;
taskIndValueMapper
.
updateTaskValueToPass
(
task
.
getId
());
}
task
.
setStatus
(
status
);
taskMapper
.
updateByPrimaryKey
(
task
);
AuditRecord
auditRecord
=
new
AuditRecord
();
auditRecord
.
setRecordType
(
recordType
);
auditRecord
.
setTaskId
(
task
.
getId
());
auditRecord
.
setId
(
IdWorker
.
getStrId
());
auditRecord
.
setPTaskId
(
task
.
getPId
());
auditRecord
.
setCreator
(
auditUserId
);
auditRecord
.
setUpdater
(
auditUserId
);
auditRecord
.
setUpdateTime
(
now
);
auditRecord
.
setCreateTime
(
now
);
taskAuditRecordMapper
.
insert
(
auditRecord
);
}
@Override
public
List
<
AuditRecord
>
findAuditRecordByTaskId
(
String
taskId
)
{
return
taskAuditRecordMapper
.
getByTaskId
(
taskId
);
}
}
}
src/main/java/com/keymobile/indicators/utils/ExcelUtil.java
0 → 100644
View file @
5a0c17c1
package
com
.
keymobile
.
indicators
.
utils
;
import
org.apache.poi.ss.usermodel.CellType
;
import
org.apache.poi.xssf.usermodel.XSSFCell
;
/**
* excel操作工具类
*/
public
class
ExcelUtil
{
/**
* 获取excel单元格值
* @param xssfCell
* @return
*/
public
static
String
getXSSFCellValue
(
XSSFCell
xssfCell
)
{
String
cellValue
=
null
;
CellType
cellType
=
xssfCell
.
getCellType
();
if
(
CellType
.
STRING
.
equals
(
cellType
))
{
cellValue
=
xssfCell
.
getStringCellValue
();
}
else
if
(
CellType
.
NUMERIC
.
equals
(
cellType
))
{
cellValue
=
String
.
valueOf
(
xssfCell
.
getNumericCellValue
());
}
else
if
(
CellType
.
BOOLEAN
.
equals
(
cellType
))
{
cellValue
=
String
.
valueOf
(
xssfCell
.
getBooleanCellValue
());
}
else
if
(
CellType
.
FORMULA
.
equals
(
cellType
))
{
cellValue
=
String
.
valueOf
(
xssfCell
.
getCellFormula
());
}
return
cellValue
;
}
}
src/main/resources/mybatis/mapping/TaskAuditRecord.xml
0 → 100644
View file @
5a0c17c1
<?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=
"com.keymobile.indicators.model.mapper.indicators.TaskAuditRecordMapper"
>
<select
id=
"getByTaskId"
parameterType=
"java.lang.String"
resultType=
"com.keymobile.indicators.model.entity.dataenter.AuditRecord"
>
select *
from data_enter_task_record
where task_id = #{taskId}
order by create_time desc
</select>
</mapper>
\ No newline at end of file
src/main/resources/mybatis/mapping/TaskIndicatorValueMapper.xml
View file @
5a0c17c1
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
(id,task_id,ind_id,ind_name,ind_unit,ind_source,ind_value,
(id,task_id,ind_id,ind_name,ind_unit,ind_source,ind_value,
value_time,obj_id,obj_name,obj_type,temp_id,status,
value_time,obj_id,obj_name,obj_type,temp_id,status,
state,creator ,updater,create_time,update_time)
state,creator ,updater,create_time,update_time)
values
values
<foreach
collection=
"valueList"
item=
"val"
separator=
","
>
<foreach
collection=
"valueList"
item=
"val"
separator=
","
>
(#{val.id},#{val.taskId}, #{val.indId}, #{val.indName}, #{val.indUnit}, #{val.indSource},#{val.indValue},
(#{val.id},#{val.taskId}, #{val.indId}, #{val.indName}, #{val.indUnit}, #{val.indSource},#{val.indValue},
#{val.valueTime},#{val.objId},#{val.objName},#{val.objType}, #{tempId}, #{status},
#{val.valueTime},#{val.objId},#{val.objName},#{val.objType}, #{tempId}, #{status},
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
<delete
id=
"deleteByTaskId"
parameterType=
"java.lang.String"
>
<delete
id=
"deleteByTaskId"
parameterType=
"java.lang.String"
>
delete
delete
from data_enter_task_ind_val
from data_enter_task_ind_val
where task_id = #{taskId}
where task_id = #{taskId}
</delete>
</delete>
...
@@ -59,6 +59,13 @@
...
@@ -59,6 +59,13 @@
</foreach>
</foreach>
)
)
</if>
</if>
order by update_time desc
</select>
</select>
<update
id=
"updateTaskValueToPass"
parameterType=
"java.lang.String"
>
update data_enter_task_ind_val
set status = 3
where task_id = #{taskId}
</update>
</mapper>
</mapper>
\ No newline at end of file
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