Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
device-back
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
device-back
Commits
6b49c8ff
提交
6b49c8ff
authored
9月 22, 2020
作者:
Matrix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[核查模块] 修复了单个数组对象转换带来的异常问题
上级
78cf8e40
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
65 行增加
和
9 行删除
+65
-9
ObjTransUtil.java
.../com/tykj/dev/device/confirmcheck/utils/ObjTransUtil.java
+26
-3
DeviceCheckControllerTest.java
.../com/tykj/dev/confirmcheck/DeviceCheckControllerTest.java
+39
-6
没有找到文件。
dev-confirmcheck/src/main/java/com/tykj/dev/device/confirmcheck/utils/ObjTransUtil.java
浏览文件 @
6b49c8ff
package
com
.
tykj
.
dev
.
device
.
confirmcheck
.
utils
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.google.common.collect.Lists
;
import
com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckBillEntity
;
import
com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckDetailEntity
;
...
...
@@ -21,6 +22,7 @@ import org.springframework.http.ResponseEntity;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
...
...
@@ -81,7 +83,19 @@ public class ObjTransUtil {
String
userBName
=
checkUserB
==
null
?
""
:
checkUserB
.
getName
();
//解析JSON并赋值
CheckDeviceStatVo
[]
checkDeviceStatVos
=
JacksonUtil
.
readValue
(
statDo
.
getStatInfo
(),
CheckDeviceStatVo
[].
class
);
ObjectMapper
objectMapper
=
new
ObjectMapper
();
CheckDeviceStatVo
[]
checkDeviceStatVos
=
new
CheckDeviceStatVo
[
0
];
try
{
boolean
isArray
=
objectMapper
.
readTree
(
statDo
.
getStatInfo
()).
isArray
();
if
(
isArray
)
{
JacksonUtil
.
readValue
(
statDo
.
getStatInfo
(),
CheckDeviceStatVo
[].
class
);
}
else
{
CheckDeviceStatVo
checkDeviceStatVo
=
JacksonUtil
.
readValue
(
statDo
.
getStatInfo
(),
CheckDeviceStatVo
.
class
);
checkDeviceStatVos
=
new
CheckDeviceStatVo
[]{
checkDeviceStatVo
};
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
initialStat
.
setDeviceStatVoList
(
Arrays
.
asList
(
checkDeviceStatVos
));
initialStat
.
setCheckUserAName
(
userAName
);
initialStat
.
setCheckUserBName
(
userBName
);
...
...
@@ -138,10 +152,19 @@ public class ObjTransUtil {
Integer
userAId
=
detailDo
.
getUserAId
();
Integer
userBId
=
detailDo
.
getUserBId
();
String
checkUserAName
=
userRepo
.
findById
(
checkUserAId
).
orElse
(
null
).
getName
()
;
String
checkUserBName
=
userRepo
.
findById
(
checkUserBId
).
orElse
(
null
).
getName
()
;
String
checkUserAName
=
""
;
String
checkUserBName
=
""
;
String
userAName
=
""
;
String
userBName
=
""
;
if
(
checkUserAId
!=
null
&&
checkUserAId
!=
0
)
{
checkUserAName
=
userRepo
.
findById
(
checkUserAId
).
orElse
(
null
).
getName
();
}
if
(
checkUserBId
!=
null
&&
checkUserBId
!=
0
)
{
checkUserBName
=
userRepo
.
findById
(
checkUserBId
).
orElse
(
null
).
getName
();
}
if
(
userAId
!=
null
&&
userAId
!=
0
)
{
userAName
=
userRepo
.
findById
(
userAId
).
orElse
(
null
).
getName
();
}
...
...
dev-union/src/test/java/com/tykj/dev/confirmcheck/DeviceCheckControllerTest.java
浏览文件 @
6b49c8ff
...
...
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.github.wenhao.jpa.Specifications
;
import
com.google.common.collect.Lists
;
import
com.tykj.dev.device.confirmcheck.controller.DeviceCheckController
;
import
com.tykj.dev.device.confirmcheck.entity.vo.CheckBillVo
;
import
com.tykj.dev.device.confirmcheck.entity.vo.CheckDetailVo
;
import
com.tykj.dev.device.confirmcheck.entity.vo.DevLibVo
;
...
...
@@ -20,6 +21,7 @@ import org.springframework.http.MediaType;
import
org.springframework.security.test.context.support.WithMockUser
;
import
org.springframework.test.context.ActiveProfiles
;
import
org.springframework.test.web.servlet.MockMvc
;
import
org.springframework.test.web.servlet.MvcResult
;
import
org.springframework.test.web.servlet.RequestBuilder
;
import
java.io.IOException
;
...
...
@@ -47,6 +49,9 @@ class DeviceCheckControllerTest extends BaseTest {
@Autowired
protected
MockMvc
mockMvc
;
@Autowired
private
DeviceCheckController
checkController
;
@Autowired
private
DeviceCheckDetailDao
detailRepo
;
...
...
@@ -68,14 +73,42 @@ class DeviceCheckControllerTest extends BaseTest {
.
header
(
"Origin"
,
"*"
);
mockMvc
.
perform
(
request
)
MvcResult
mvcResult
=
mockMvc
.
perform
(
request
)
.
andExpect
(
status
().
isOk
())
.
andDo
(
result
->
{
String
resultString
=
result
.
getResponse
().
getContentAsString
();
System
.
out
.
println
(
"[测试结果] 自动发起核查任务测试通过,返回结果为 : "
+
resultString
);
deleteAutoCheckData
(
resultString
);
.
andReturn
();
String
resultString
=
mvcResult
.
getResponse
().
getContentAsString
();
System
.
out
.
println
(
"[测试结果] 自动发起核查任务测试通过,返回结果为 : "
+
resultString
);
// 测试 生成的数据是否都能正常访问
ObjectMapper
objectMapper
=
new
ObjectMapper
();
JsonNode
jsonNode
=
objectMapper
.
readTree
(
resultString
);
StreamSupport
.
stream
(
jsonNode
.
get
(
"data"
).
get
(
"statId"
).
spliterator
(),
false
)
.
map
(
JsonNode:
:
asInt
)
.
forEach
(
statId
->
{
//测试访问
checkController
.
findStatById
(
statId
);
System
.
out
.
printf
(
"[数据清理-统计] 删除id为 %d 的统计数据 %n"
,
statId
);
statRepo
.
deleteById
(
statId
);
});
StreamSupport
.
stream
(
jsonNode
.
get
(
"data"
).
get
(
"detailId"
).
spliterator
(),
false
)
.
map
(
JsonNode:
:
asInt
)
.
forEach
(
detailId
->
{
//测试访问
checkController
.
findDetail
(
detailId
);
System
.
out
.
printf
(
"[数据清理-自查] 删除id为 %d 的自查数据 %n"
,
detailId
);
detailRepo
.
deleteById
(
detailId
);
});
StreamSupport
.
stream
(
jsonNode
.
get
(
"data"
).
get
(
"taskId"
).
spliterator
(),
false
)
.
map
(
JsonNode:
:
asInt
)
.
forEach
(
taskId
->
{
System
.
out
.
printf
(
"[数据清理-任务] 删除id为 %d 的任务数据 %n"
,
taskId
);
taskRepo
.
deleteById
(
taskId
);
});
// deleteAutoCheckData(resultString);
}
private
void
deleteAutoCheckData
(
String
resultString
)
throws
IOException
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论