Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
device-back
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
device-back
Commits
eafc9aae
提交
eafc9aae
authored
9月 26, 2020
作者:
Matrix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[核查模块] 去除一些不必要的代码
上级
2409a64f
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
65 行增加
和
70 行删除
+65
-70
DeviceCheckController.java
...device/confirmcheck/controller/DeviceCheckController.java
+65
-70
没有找到文件。
dev-confirmcheck/src/main/java/com/tykj/dev/device/confirmcheck/controller/DeviceCheckController.java
浏览文件 @
eafc9aae
...
...
@@ -32,7 +32,6 @@ import com.tykj.dev.misc.utils.MapperUtils;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -50,7 +49,7 @@ import static java.util.stream.Collectors.*;
/**
* @author dengdiyi
*/
@SuppressWarnings
(
"OptionalGetWithoutIsPresent"
)
@SuppressWarnings
(
{
"OptionalGetWithoutIsPresent"
}
)
@RestController
@RequestMapping
(
value
=
"/check/confirm"
)
@AutoDocument
...
...
@@ -59,28 +58,31 @@ import static java.util.stream.Collectors.*;
@Slf4j
public
class
DeviceCheckController
{
@Autowired
private
DeviceCheckStatRepo
statRepo
;
@Autowired
private
DeviceCheckBillDao
billRepo
;
@Autowired
private
AreaDao
areaRepo
;
@Autowired
private
UnitsDao
unitsRepo
;
@Autowired
private
DeviceLibraryDao
deviceRepo
;
@Autowired
private
DeviceCheckDetailDao
detailRepo
;
@Autowired
private
ObjTransUtil
transUtil
;
@Autowired
private
TaskDao
taskRepo
;
@Autowired
private
TaskService
taskService
;
@Autowired
private
AuthenticationUtils
AuthenticationUtils
;
@Autowired
private
AreaCache
areaCache
;
private
final
DeviceCheckStatRepo
statRepo
;
private
final
DeviceCheckBillDao
billRepo
;
private
final
AreaDao
areaRepo
;
private
final
UnitsDao
unitsRepo
;
private
final
DeviceLibraryDao
deviceRepo
;
private
final
DeviceCheckDetailDao
detailRepo
;
private
final
ObjTransUtil
transUtil
;
private
final
TaskDao
taskRepo
;
private
final
TaskService
taskService
;
private
final
AuthenticationUtils
AuthenticationUtils
;
private
final
AreaCache
areaCache
;
public
DeviceCheckController
(
DeviceCheckBillDao
billRepo
,
DeviceCheckStatRepo
statRepo
,
AreaDao
areaRepo
,
UnitsDao
unitsRepo
,
DeviceLibraryDao
deviceRepo
,
DeviceCheckDetailDao
detailRepo
,
ObjTransUtil
transUtil
,
TaskDao
taskRepo
,
TaskService
taskService
,
AuthenticationUtils
AuthenticationUtils
,
AreaCache
areaCache
)
{
this
.
billRepo
=
billRepo
;
this
.
statRepo
=
statRepo
;
this
.
areaRepo
=
areaRepo
;
this
.
unitsRepo
=
unitsRepo
;
this
.
deviceRepo
=
deviceRepo
;
this
.
detailRepo
=
detailRepo
;
this
.
transUtil
=
transUtil
;
this
.
taskRepo
=
taskRepo
;
this
.
taskService
=
taskService
;
this
.
AuthenticationUtils
=
AuthenticationUtils
;
this
.
areaCache
=
areaCache
;
}
@GetMapping
(
"/area/{fatherId}"
)
@ApiOperation
(
value
=
"查询指定区域下的所有区域信息"
)
...
...
@@ -111,7 +113,7 @@ public class DeviceCheckController {
@PostMapping
(
"/auto"
)
public
ResponseEntity
<
ResultObj
<
Map
<
String
,
List
<
Integer
>>>>
startAutoCheck
()
{
// 构建返回数据对象
Map
<
String
,
List
<
Integer
>>
resultIds
=
new
HashMap
<>();
Map
<
String
,
List
<
Integer
>>
resultIds
=
new
HashMap
<>(
8
);
resultIds
.
put
(
"statId"
,
new
ArrayList
<>());
resultIds
.
put
(
"detailId"
,
new
ArrayList
<>());
resultIds
.
put
(
"taskId"
,
new
ArrayList
<>());
...
...
@@ -260,7 +262,6 @@ public class DeviceCheckController {
if
(
csd
.
getRemark
().
split
(
"\\|"
).
length
<=
1
)
{
continue
;
}
String
unitName
=
csd
.
getRemark
().
split
(
"\\|"
)[
1
];
Integer
cityId
=
Integer
.
valueOf
(
csd
.
getRemark
().
split
(
"\\|"
)[
2
]);
String
cityName
=
areaCache
.
findById
(
cityId
).
getName
();
List
<
String
>
childNames
=
areaRepo
.
findByFatherId
(
cityId
).
stream
().
map
(
Area:
:
getName
).
collect
(
toList
());
...
...
@@ -394,9 +395,6 @@ public class DeviceCheckController {
statRepo
.
save
(
cityVo
.
toDo
());
log
.
info
(
"[核查模块 检测到是自动核查任务,将省级统计 id = {} 认为开启]"
,
provStat
.
getId
());
}
TaskBto
fatherStatTask
=
taskService
.
get
(
fatherId
);
return
ResponseEntity
.
ok
(
new
ResultObj
<>(
"专管员A操作成功"
));
}
...
...
@@ -434,12 +432,11 @@ public class DeviceCheckController {
// 如果是4流程的,则需要指定核查组成员A接任务
detailRepo
.
updateCheckStatus
(
id
,
checkStatus
);
if
(
userAId
>
0
&&
userBId
>
0
)
{
currentTask
=
taskService
.
moveToNext
(
currentTask
,
checkUserAId
);
taskService
.
moveToNext
(
currentTask
,
checkUserAId
);
}
else
{
// 如果是2流程的,则直接结束该任务
taskService
.
moveToEnd
(
currentTask
);
summaryDetail
(
currentTask
,
currentDetail
);
}
}
else
{
//不通过则回到第一阶段
...
...
@@ -460,7 +457,8 @@ public class DeviceCheckController {
DeviceCheckDetail
currentDetail
=
detailRepo
.
findById
(
id
).
get
();
if
(
pass
)
{
// 如果当前是第3步(利用余数来判断),则需要指定核查组B的人来接受任务
if
(
currentTask
.
getBillStatus
()
%
10
==
2
)
{
boolean
stepC
=
currentTask
.
getBillStatus
()
%
10
==
2
;
if
(
stepC
)
{
log
.
info
(
"[核查模块] C 检查组成员A正在进行核查操作,核查详情账单id为 : {}"
,
id
);
if
(!
currentTask
.
getBillStatus
().
equals
(
CHECK_DETAIL_2
.
id
))
{
return
ResponseEntity
.
status
(
400
).
body
(
new
ResultObj
<>(
String
.
format
(
"当前任务的状态异常!当前任务状态为 %s , 任务状态应该为 %s"
,
GlobalMap
.
getStatusEnumMap
().
get
(
currentTask
.
getBillStatus
()),
CHECK_DETAIL_2
.
name
)));
...
...
@@ -469,7 +467,8 @@ public class DeviceCheckController {
log
.
info
(
"[核查模块] C 操作完毕"
);
}
if
(
currentTask
.
getBillStatus
()
%
10
==
3
)
{
boolean
stepD
=
currentTask
.
getBillStatus
()
%
10
==
3
;
if
(
stepD
)
{
if
(!
currentTask
.
getBillStatus
().
equals
(
CHECK_DETAIL_3
.
id
))
{
return
ResponseEntity
.
status
(
400
).
body
(
new
ResultObj
<>(
String
.
format
(
"当前任务的状态异常!当前任务状态为 %s , 任务状态应该为 %s"
,
GlobalMap
.
getStatusEnumMap
().
get
(
currentTask
.
getBillStatus
()),
CHECK_DETAIL_3
.
name
)));
}
...
...
@@ -479,7 +478,6 @@ public class DeviceCheckController {
summaryDetail
(
currentTask
,
currentDetail
);
log
.
info
(
"[核查模块] D 操作完毕"
);
}
}
else
{
// 如果没通过则返回第1步
StatusEnum
firstStatus
=
getFirstStatus
(
currentTask
.
getBillStatus
());
...
...
@@ -489,35 +487,6 @@ public class DeviceCheckController {
return
ResponseEntity
.
ok
(
new
ResultObj
<>(
"操作成功"
));
}
private
void
summaryDetail
(
TaskBto
currentTask
,
DeviceCheckDetail
currentDetail
)
{
log
.
info
(
"[核查模块] 正在进行数据汇总"
);
// 任务结束后需要将当前城市的统计信息汇总上去()
Units
units
=
unitsRepo
.
findById
(
currentTask
.
getOwnUnit
()).
get
();
int
level
=
units
.
getLevel
();
// 先找到汇总地区的账单id 查询当前detail task 的 父级TASK
Integer
fatherTaskId
=
currentTask
.
getParentTaskId
();
int
statId
=
taskRepo
.
findBillId
(
fatherTaskId
,
CONFIRM_CHECK_STAT
.
id
);
// 获得当前城市的统计信息 以及 要汇总的地区信息 并累加保存
List
<
CheckDeviceStatVo
>
addVos
=
parseStatString2Vo
(
currentTask
,
level
,
currentDetail
.
getCheckDetail
());
CheckStatVo
resultVo
=
transUtil
.
checkStatDo2Vo
(
statRepo
.
findById
(
statId
).
get
());
resultVo
=
resultVo
.
cleanReduce
(
addVos
);
statRepo
.
save
(
resultVo
.
toDo
());
// 判断地区数据是否均汇总完毕
boolean
over
=
taskService
.
TaskTreeIsOver
(
fatherTaskId
);
// 如果汇总完毕则将父级的统计任务推进
if
(
over
)
{
TaskBto
fatherTask
=
taskService
.
get
(
fatherTaskId
);
//如果上一个id是-1 则证明是所有人的跟踪统计,即自动核查,那么下一步推进到所有人的待办
Integer
lastUserId
=
fatherTask
.
getLastUserId
()
==
-
1
?
0
:
fatherTask
.
getLastUserId
();
taskService
.
moveToNext
(
fatherTask
,
lastUserId
);
}
log
.
info
(
"[核查模块] 数据汇总完毕"
);
}
/**
* @param statId 统计账单主键id
*/
...
...
@@ -547,8 +516,8 @@ public class DeviceCheckController {
// 如果所有子地区统计任务都已经完结,则推进父地区统计任务进度
boolean
allOver
=
taskService
.
TaskTreeIsOver
(
parentTaskId
);
if
(
allOver
)
{
log
.
info
(
"[核查任务] 所有市的核查统计任务已经完毕,推进省级的核查统计任务"
);
TaskBto
statTask
=
taskService
.
moveToNext
(
parentTask
,
0
);
TaskBto
provTask
=
taskService
.
moveToNext
(
parentTask
,
0
);
log
.
info
(
"[核查任务] 所有市的核查统计任务已经完毕,推进省级 id = {}的核查统计任务"
,
provTask
.
getId
()
);
}
}
...
...
@@ -556,6 +525,36 @@ public class DeviceCheckController {
return
ResponseEntity
.
ok
(
new
ResultObj
<>(
"统计数据确认完毕"
));
}
/**
* 任务结束后需要将当前城市的统计信息汇总上
*
* @param currentTask 当前任务
* @param currentDetail 需要汇总的详情核查数据对象
*/
private
void
summaryDetail
(
TaskBto
currentTask
,
DeviceCheckDetail
currentDetail
)
{
log
.
info
(
"[核查模块] 正在进行数据汇总"
);
// 先找到汇总地区的账单id 查询当前detail task 的 父级TASK
Integer
fatherTaskId
=
currentTask
.
getParentTaskId
();
int
statId
=
taskRepo
.
findBillId
(
fatherTaskId
,
CONFIRM_CHECK_STAT
.
id
);
// 获得当前城市的统计信息 以及 要汇总的地区信息 并累加保存
List
<
CheckDeviceStatVo
>
addVos
=
parseStatString2Vo
(
currentTask
,
currentDetail
.
getCheckDetail
());
CheckStatVo
resultVo
=
transUtil
.
checkStatDo2Vo
(
statRepo
.
findById
(
statId
).
get
());
resultVo
=
resultVo
.
cleanReduce
(
addVos
);
statRepo
.
save
(
resultVo
.
toDo
());
// 判断地区数据是否均汇总完毕
boolean
over
=
taskService
.
TaskTreeIsOver
(
fatherTaskId
);
// 如果汇总完毕则将父级的统计任务推进
if
(
over
)
{
TaskBto
fatherTask
=
taskService
.
get
(
fatherTaskId
);
//如果上一个id是-1 则证明是所有人的跟踪统计,即自动核查,那么下一步推进到所有人的待办
Integer
lastUserId
=
fatherTask
.
getLastUserId
()
==
-
1
?
0
:
fatherTask
.
getLastUserId
();
taskService
.
moveToNext
(
fatherTask
,
lastUserId
);
}
log
.
info
(
"[核查模块] 数据汇总完毕"
);
}
/**
* 获取指定任务的第一步的任务状态
...
...
@@ -567,7 +566,7 @@ public class DeviceCheckController {
return
GlobalMap
.
getStatusEnumMap
().
get
(
currentStatusId
-
remainder
);
}
public
List
<
CheckDeviceStatVo
>
parseStatString2Vo
(
TaskBto
task
,
int
cityLevel
,
String
statString
)
{
public
List
<
CheckDeviceStatVo
>
parseStatString2Vo
(
TaskBto
task
,
String
statString
)
{
List
<
CheckDeviceStatVo
>
statVoList
=
new
ArrayList
<>();
//分为 id - status 的数组 其中status 0缺失 1无误 2新增 3不在库
String
[]
statArray
=
statString
.
split
(
","
);
...
...
@@ -633,10 +632,6 @@ public class DeviceCheckController {
.
collect
(
toMap
(
CheckDeviceStatVo:
:
getDeviceModel
,
Function
.
identity
(),
CheckDeviceStatVo:
:
reduce
))
.
values
();
//构造最终数据
LocalDate
startTime
=
LocalDate
.
now
();
LocalDate
endTime
=
startTime
.
plusMonths
(
1
);
return
new
DeviceCheckStat
(
title
,
startUnitName
+
"待核查装备统计单"
,
JacksonUtil
.
toJSon
(
new
ArrayList
<>(
statVos
)),
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论