Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
device-back
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
device-back
Commits
992e22e5
提交
992e22e5
authored
9月 22, 2020
作者:
Matrix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加了自动核查
上级
5b7aa28e
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
174 行增加
和
17 行删除
+174
-17
DeviceCheckController.java
...device/confirmcheck/controller/DeviceCheckController.java
+119
-3
DeviceCheckDetailEntity.java
...e/confirmcheck/entity/domain/DeviceCheckDetailEntity.java
+9
-9
CheckDeviceStatVo.java
.../dev/device/confirmcheck/entity/vo/CheckDeviceStatVo.java
+9
-2
ObjTransUtil.java
.../com/tykj/dev/device/confirmcheck/utils/ObjTransUtil.java
+21
-0
UnionApplication.java
...on/src/main/java/com/tykj/dev/union/UnionApplication.java
+2
-1
DeviceCheckControllerTest.java
.../com/tykj/dev/confirmcheck/DeviceCheckControllerTest.java
+14
-1
AreaDao.java
...in/java/com/tykj/dev/device/user/subject/dao/AreaDao.java
+0
-1
没有找到文件。
dev-confirmcheck/src/main/java/com/tykj/dev/device/confirmcheck/controller/DeviceCheckController.java
浏览文件 @
992e22e5
...
...
@@ -19,12 +19,14 @@ import com.tykj.dev.device.task.subject.bto.TaskLogBto;
import
com.tykj.dev.device.task.subject.domin.Task
;
import
com.tykj.dev.device.user.subject.dao.AreaDao
;
import
com.tykj.dev.device.user.subject.dao.UnitsDao
;
import
com.tykj.dev.device.user.subject.entity.Area
;
import
com.tykj.dev.device.user.subject.entity.Units
;
import
com.tykj.dev.device.user.subject.entity.User
;
import
com.tykj.dev.device.user.util.AuthenticationUtils
;
import
com.tykj.dev.misc.base.GlobalMap
;
import
com.tykj.dev.misc.base.ResultObj
;
import
com.tykj.dev.misc.base.StatusEnum
;
import
com.tykj.dev.misc.utils.JacksonUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -34,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
java.time.LocalDate
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -83,7 +86,7 @@ public class DeviceCheckController {
@GetMapping
(
"/area/{fatherId}"
)
@ApiOperation
(
value
=
"查询指定区域下的所有区域信息"
)
public
ResponseEntity
findAreaUnderId
(
@PathVariable
Integer
fatherId
)
{
public
ResponseEntity
findAreaUnderId
(
@PathVariable
Integer
fatherId
,
HttpServletRequest
request
)
{
return
ResponseEntity
.
ok
(
new
ResultObj
(
areaRepo
.
findByFatherId
(
fatherId
)));
}
...
...
@@ -107,18 +110,131 @@ public class DeviceCheckController {
}
@ApiOperation
(
value
=
"发起自动核查"
,
notes
=
"发起自动核查"
)
@PostMapping
(
"/check/auto"
)
public
ResponseEntity
startAutoCheck
()
{
// 发起省级的统计 - 获得所有的市级单位
List
<
Units
>
cityUnits
=
unitsRepo
.
findAllByLevel
(
2
);
Units
provUnit
=
unitsRepo
.
findById
(
1
).
get
();
String
baseTitle
=
LocalDate
.
now
().
getYear
()
+
"年"
+
(
LocalDate
.
now
().
getMonthValue
()
+
1
)
+
"月"
;
initStatData
(
"自动核查"
,
// 构建省的统计账单
DeviceCheckStat
provinceStat
=
initStatData
(
"自动核查"
,
0
,
0
,
baseTitle
+
"浙江省自动核查"
,
provUnit
.
getName
(),
cityUnits
);
return
ResponseEntity
.
ok
(
"nothing"
);
List
<
DeviceLibrary
>
deviceList
=
deviceRepo
.
findAll
();
Map
<
String
,
List
<
DeviceLibrary
>>
devInLib
=
deviceList
.
stream
()
.
filter
(
device
->
device
.
getOwnUnit
().
equals
(
device
.
getLocationUnit
()))
.
collect
(
groupingBy
(
DeviceLibrary:
:
getOwnUnit
));
Map
<
String
,
List
<
DeviceLibrary
>>
devNotInLib
=
deviceList
.
stream
()
.
filter
(
device
->
!
device
.
getOwnUnit
().
equals
(
device
.
getLocationUnit
()))
.
collect
(
groupingBy
(
DeviceLibrary:
:
getOwnUnit
));
// 构建省统Task
TaskBto
provStatTask
=
new
Task
(
CHECK_STAT_0
.
id
,
"省自动核查"
,
0
,
".0."
,
CONFIRM_CHECK_STAT
.
id
,
provinceStat
.
getId
(),
provUnit
.
getUnitId
())
.
parse2Bto
();
taskService
.
start
(
provStatTask
);
List
<
CheckDeviceStatVo
>
statVoList
=
new
ArrayList
<>();
List
<
DeviceCheckStat
>
cityStatList
=
new
ArrayList
<>();
List
<
String
>
countyNames
=
new
ArrayList
<>();
// 构建所有市的统计账单(先不考虑JSON-INFO)
for
(
Units
city
:
cityUnits
)
{
List
<
Integer
>
areaIds
=
areaRepo
.
findAllByFatherId
(
city
.
getAreaId
()).
stream
().
map
(
Area:
:
getId
).
collect
(
toList
());
List
<
Units
>
countyUnits
=
unitsRepo
.
findByAreaIdIn
(
areaIds
);
// 构建市统账单
DeviceCheckStat
cityStatDo
=
initStatData
(
"自动核查"
,
0
,
0
,
baseTitle
+
city
.
getName
()
+
"自动核查统计"
,
provUnit
.
getName
(),
countyUnits
);
DeviceCheckStat
cityStat
=
statRepo
.
save
(
cityStatDo
);
cityStatList
.
add
(
cityStat
);
// 构建市统task 获得id
TaskBto
cityStatTask
=
new
Task
(
CHECK_STAT_0
.
id
,
city
.
getName
()
+
"自动核查统计"
,
provStatTask
.
getId
(),
addNode
(
provStatTask
.
getNodeIdDetail
(),
provinceStat
.
getId
()),
CONFIRM_CHECK_STAT
.
id
,
cityStat
.
getId
(),
city
.
getUnitId
())
.
parse2Bto
();
taskService
.
start
(
cityStatTask
);
// 构建市自查账单
DeviceCheckDetailEntity
cityDetailDo
=
DeviceCheckDetailEntity
.
EmptyWithChecker
(
"系统发起的自查|"
+
city
.
getName
()
+
"|"
+
city
.
getAreaId
(),
baseTitle
+
city
.
getName
()
+
"核查任务"
,
0
,
0
,
0
,
0
,
provUnit
.
getName
(),
devInLib
.
getOrDefault
(
city
.
getName
(),
new
ArrayList
<>()),
devNotInLib
.
getOrDefault
(
city
.
getName
(),
new
ArrayList
<>()));
DeviceCheckDetailEntity
cityDetail
=
detailRepo
.
save
(
cityDetailDo
);
List
<
CheckDeviceStatVo
>
cityStatVoList
=
deviceList
.
stream
()
.
filter
(
d
->
d
.
getOwnUnit
().
equals
(
city
.
getName
()))
.
map
(
d
->
transUtil
.
device2InitStatVo
(
d
,
city
.
getName
(),
cityStat
.
getId
(),
cityDetail
.
getId
()))
.
collect
(
toList
());
statVoList
.
addAll
(
cityStatVoList
);
// 构建市自查TASK
TaskBto
cityDetailTask
=
new
Task
(
CHECK_DETAIL_0
.
id
,
city
.
getName
()
+
"自动核查自查"
,
cityStatTask
.
getId
(),
addNode
(
cityStatTask
.
getNodeIdDetail
(),
cityStatTask
.
getId
()),
CONFIRM_CHECK_DETAIL
.
id
,
cityDetail
.
getId
(),
city
.
getUnitId
())
.
parse2Bto
();
taskService
.
start
(
cityDetailTask
);
// 构建县任务
for
(
Units
county
:
countyUnits
)
{
countyNames
.
add
(
county
.
getName
());
//构建县自查账单
DeviceCheckDetailEntity
countyDetailDo
=
DeviceCheckDetailEntity
.
EmptyWithChecker
(
"系统发起的自查|"
+
county
.
getName
()
+
"|"
+
county
.
getAreaId
(),
baseTitle
+
county
.
getName
()
+
"核查任务"
,
0
,
0
,
0
,
0
,
provUnit
.
getName
(),
devInLib
.
getOrDefault
(
city
.
getName
(),
new
ArrayList
<>()),
devNotInLib
.
getOrDefault
(
city
.
getName
(),
new
ArrayList
<>()));
DeviceCheckDetailEntity
countyDetail
=
detailRepo
.
save
(
countyDetailDo
);
List
<
CheckDeviceStatVo
>
countyStatVoList
=
deviceList
.
stream
()
.
filter
(
d
->
d
.
getOwnUnit
().
equals
(
city
.
getName
()))
.
map
(
d
->
transUtil
.
device2InitStatVo
(
d
,
city
.
getName
(),
cityStat
.
getId
(),
countyDetail
.
getId
()))
.
collect
(
toList
());
statVoList
.
addAll
(
countyStatVoList
);
//构建县自查TASK
TaskBto
countyDetailTask
=
new
Task
(
CHECK_DETAIL_0
.
id
,
county
.
getName
()
+
"自动核查自查"
,
cityStatTask
.
getId
(),
addNode
(
cityStatTask
.
getNodeIdDetail
(),
cityStatTask
.
getId
()),
CONFIRM_CHECK_DETAIL
.
id
,
countyDetail
.
getId
(),
county
.
getUnitId
())
.
parse2Bto
();
taskService
.
start
(
countyDetailTask
);
}
// 处理JSON INFO 数据
// 对于省统计来说,需要去掉所有的区地区的数据
CheckDeviceStatVo
provStatVo
=
statVoList
.
stream
()
.
filter
(
stat
->
!
countyNames
.
contains
(
stat
.
getAreaStatList
().
get
(
0
).
getAreaName
()))
.
reduce
(
CheckDeviceStatVo:
:
add
)
.
get
();
provinceStat
.
setStatInfo
(
JacksonUtil
.
toJSon
(
provStatVo
));
statRepo
.
save
(
provinceStat
);
// 对于市统计来说,只需要自己本市以及其下地区的数据
for
(
DeviceCheckStat
csd
:
cityStatList
)
{
List
<
String
>
cityNames
=
new
ArrayList
<>();
if
(
csd
.
getRemark
().
split
(
"\\|"
).
length
<=
1
)
{
continue
;
}
String
areaName
=
csd
.
getRemark
().
split
(
"\\|"
)[
1
];
Integer
cityId
=
Integer
.
valueOf
(
csd
.
getRemark
().
split
(
"\\|"
)[
2
]);
List
<
String
>
childNames
=
areaRepo
.
findByFatherId
(
cityId
).
stream
().
map
(
Area:
:
getName
).
collect
(
toList
());
cityNames
.
add
(
areaName
);
cityNames
.
addAll
(
childNames
);
CheckDeviceStatVo
cityStatVo
=
statVoList
.
stream
()
.
filter
(
stat
->
cityNames
.
contains
(
stat
.
getAreaStatList
().
get
(
0
).
getAreaName
()))
.
reduce
(
CheckDeviceStatVo:
:
add
)
.
get
();
csd
.
setStatInfo
(
JacksonUtil
.
toJSon
(
cityStatVo
));
}
statRepo
.
saveAll
(
cityStatList
);
}
return
ResponseEntity
.
ok
(
"自动发起任务成功"
);
}
/**
...
...
dev-confirmcheck/src/main/java/com/tykj/dev/device/confirmcheck/entity/domain/DeviceCheckDetailEntity.java
浏览文件 @
992e22e5
...
...
@@ -229,8 +229,8 @@ public class DeviceCheckDetailEntity {
/**
* @param checkUnit 要核查的单位
* @param
goodDevices
所属与所在均在本单位的装备集合
* @param
badDevices
所属在,但所在不在本单位的装备集合
* @param
devInLib
所属与所在均在本单位的装备集合
* @param
devNotInLib
所属在,但所在不在本单位的装备集合
* @return 初始化的账单(还没有被人修改过的)
*/
public
static
DeviceCheckDetailEntity
EmptyWithChecker
(
...
...
@@ -241,19 +241,19 @@ public class DeviceCheckDetailEntity {
Integer
userAId
,
Integer
userBId
,
String
checkUnit
,
List
<
DeviceLibrary
>
goodDevices
,
List
<
DeviceLibrary
>
badDevices
)
{
List
<
DeviceLibrary
>
devInLib
,
List
<
DeviceLibrary
>
devNotInLib
)
{
//构造checkDetail 分当前在库与不在库的 赋予不同状态
String
goodCheckDetail
=
""
;
if
(!
CollectionUtils
.
isEmpty
(
goodDevices
))
{
goodCheckDetail
=
goodDevices
.
stream
()
if
(!
CollectionUtils
.
isEmpty
(
devInLib
))
{
goodCheckDetail
=
devInLib
.
stream
()
.
map
(
device
->
device
.
getId
()
+
"-9"
)
.
collect
(
Collectors
.
joining
(
","
));
}
String
badCheckDetail
=
""
;
if
(!
CollectionUtils
.
isEmpty
(
badDevices
))
{
badCheckDetail
=
badDevices
.
stream
()
if
(!
CollectionUtils
.
isEmpty
(
devNotInLib
))
{
badCheckDetail
=
devNotInLib
.
stream
()
.
map
(
device
->
device
.
getId
()
+
"-3"
)
.
collect
(
Collectors
.
joining
(
","
));
}
...
...
@@ -271,7 +271,7 @@ public class DeviceCheckDetailEntity {
userBId
,
TimestampUtil
.
getNowDate
(),
checkUnit
,
goodDevices
.
size
(),
devInLib
.
size
(),
0
,
""
,
checkDetail
,
...
...
dev-confirmcheck/src/main/java/com/tykj/dev/device/confirmcheck/entity/vo/CheckDeviceStatVo.java
浏览文件 @
992e22e5
...
...
@@ -5,6 +5,7 @@ import lombok.Builder;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.util.CollectionUtils
;
import
java.util.List
;
...
...
@@ -45,15 +46,19 @@ public class CheckDeviceStatVo {
/**
* other的model一定要与本deviceModel相同
*/
public
void
add
(
CheckDeviceStatVo
other
)
{
public
CheckDeviceStatVo
add
(
CheckDeviceStatVo
other
)
{
if
(!
deviceModel
.
equals
(
other
.
getDeviceModel
()))
{
log
.
warn
(
"[核查] 合并统计的数据发现装备不统一的情况"
);
return
;
return
this
;
}
deviceCount
+=
other
.
getDeviceCount
();
for
(
CheckAreaStatVo
otherArea
:
other
.
getAreaStatList
())
{
if
(
deviceModel
.
equals
(
other
.
getDeviceModel
()))
{
if
(
CollectionUtils
.
isEmpty
(
areaStatList
))
{
areaStatList
=
other
.
getAreaStatList
();
}
for
(
CheckAreaStatVo
statVo
:
areaStatList
)
{
if
(
statVo
.
getAreaName
().
equals
(
otherArea
.
getAreaName
()))
{
statVo
.
setAreaName
(
otherArea
.
getAreaName
());
...
...
@@ -67,6 +72,8 @@ public class CheckDeviceStatVo {
}
}
}
return
this
;
}
}
dev-confirmcheck/src/main/java/com/tykj/dev/device/confirmcheck/utils/ObjTransUtil.java
浏览文件 @
992e22e5
package
com
.
tykj
.
dev
.
device
.
confirmcheck
.
utils
;
import
com.google.common.collect.Lists
;
import
com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckBillEntity
;
import
com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckDetailEntity
;
import
com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckStat
;
...
...
@@ -46,6 +47,26 @@ public class ObjTransUtil {
@Autowired
private
UnitsDao
unitRepo
;
/**
* 装备转化为初始化的装备统计类
*
* @param device
* @return
*/
public
CheckDeviceStatVo
device2InitStatVo
(
DeviceLibrary
device
)
{
String
ownUnit
=
device
.
getOwnUnit
();
int
areaId
=
unitRepo
.
findAreaIdByName
(
ownUnit
);
String
areaName
=
areaRepo
.
findNameById
(
areaId
);
List
<
CheckAreaStatVo
>
areaStatList
=
Lists
.
newArrayList
(
new
CheckAreaStatVo
(
areaName
,
0
,
1
,
0
,
0
,
0
,
0
));
return
new
CheckDeviceStatVo
(
device
.
getModel
(),
device
.
getName
(),
1
,
areaStatList
);
}
public
CheckDeviceStatVo
device2InitStatVo
(
DeviceLibrary
device
,
String
areaName
,
Integer
statId
,
Integer
detailId
)
{
List
<
CheckAreaStatVo
>
areaStatList
=
Lists
.
newArrayList
(
new
CheckAreaStatVo
(
areaName
,
0
,
1
,
0
,
0
,
statId
,
detailId
));
return
new
CheckDeviceStatVo
(
device
.
getModel
(),
device
.
getName
(),
1
,
areaStatList
);
}
/**
* Do类转化为Vo类
*/
...
...
dev-union/src/main/java/com/tykj/dev/union/UnionApplication.java
浏览文件 @
992e22e5
...
...
@@ -16,9 +16,10 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@EnableTransactionManagement
public
class
UnionApplication
extends
SpringBootServletInitializer
{
@Override
protected
SpringApplicationBuilder
configure
(
SpringApplicationBuilder
applicationBuilder
){
protected
SpringApplicationBuilder
configure
(
SpringApplicationBuilder
applicationBuilder
)
{
return
applicationBuilder
.
sources
(
UnionApplication
.
class
);
}
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
UnionApplication
.
class
,
args
);
}
...
...
dev-union/src/test/java/com/tykj/dev/confirmcheck/DeviceCheckControllerTest.java
浏览文件 @
992e22e5
...
...
@@ -37,7 +37,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
*/
@SuppressWarnings
(
"ALL"
)
@WithMockUser
(
username
=
"shena"
,
password
=
"qwer1234"
,
authorities
=
"省A专管员"
)
@ActiveProfiles
(
"
dev
"
)
@ActiveProfiles
(
"
test
"
)
class
DeviceCheckControllerTest
extends
BaseTest
{
@Autowired
...
...
@@ -55,6 +55,19 @@ class DeviceCheckControllerTest extends BaseTest {
@Autowired
private
ObjTransUtil
transUtil
;
@Test
void
startAutoCheck
()
throws
Exception
{
// 测试
RequestBuilder
request
;
request
=
post
(
"/check/confirm/check/auto"
)
.
header
(
"Origin"
,
"*"
);
mockMvc
.
perform
(
request
)
.
andExpect
(
status
().
isOk
())
.
andDo
(
mvcResult1
->
System
.
out
.
println
(
"[测试结果] 自动发起核查任务测试通过"
));
}
@Test
void
startManualCheck
()
throws
Exception
{
...
...
dev-user/src/main/java/com/tykj/dev/device/user/subject/dao/AreaDao.java
浏览文件 @
992e22e5
...
...
@@ -25,5 +25,4 @@ public interface AreaDao extends JpaRepository<Area, Integer>, JpaSpecificationE
@Query
(
"select o.name from Area o where o.id=?1"
)
String
findNameById
(
int
id
);
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论