|
@@ -92,15 +92,10 @@ public class ObjectDigitalServiceImpl extends ServiceImpl<ObjectDigitalMapper, O
|
|
|
|
|
|
@Override
|
|
|
public List<ObjectDigital> insert(List<ObjectDigital> voList) {
|
|
|
- //验证失败的数据
|
|
|
- List<ObjectDigital> errorList = validateOnSave(voList, false);
|
|
|
-
|
|
|
- if(CollUtil.isEmpty(voList) && CollUtil.isEmpty(errorList)) {
|
|
|
+ validateOnSave(voList, false);
|
|
|
+ if(CollUtil.isEmpty(voList)) {
|
|
|
return null;
|
|
|
}
|
|
|
- if(CollUtil.isEmpty(voList) && !CollUtil.isEmpty(errorList)) {
|
|
|
- return errorList;
|
|
|
- }
|
|
|
//获取对象类型
|
|
|
Map<String, String> typeMap = typeService.queryObjTypeMap();
|
|
|
voList.forEach(vo -> {
|
|
@@ -120,8 +115,6 @@ public class ObjectDigitalServiceImpl extends ServiceImpl<ObjectDigitalMapper, O
|
|
|
// 新增后消息
|
|
|
messageSender.sendMessage(DigitalMessageConstant.OPERATE_AFTER_INSERT, null, vo, false);
|
|
|
});
|
|
|
- //返回总体数据
|
|
|
- voList.addAll(errorList);
|
|
|
return voList;
|
|
|
}
|
|
|
|
|
@@ -482,6 +475,39 @@ public class ObjectDigitalServiceImpl extends ServiceImpl<ObjectDigitalMapper, O
|
|
|
return objectDigitals.stream().map(item -> item.getClassCode()).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 新增 更新 验证对象,将验证失败的信息放到ObjectDigital。mark中,并返回所有验证失败的记录
|
|
|
+ *
|
|
|
+ * @param voList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<ObjectDigital> validateInfoCodeAndGetError(List<ObjectDigital> voList) {
|
|
|
+ if(CollUtil.isEmpty(voList)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ // 保存时,项目ID一定有,而且都是操作这个项目的数据。这是前提,若后续放开全集团保存,则应按项目分组后查询信息点
|
|
|
+ String projectId = AppContext.getContext().getProjectId();
|
|
|
+ //获取该信息点当前classCode
|
|
|
+ List<String> classCodes = CollUtil.getFieldValues(voList, "classCode", String.class);
|
|
|
+ // 查询信息点定义
|
|
|
+ Map<String, Map<String, ObjectInfoDefine>> typeInfoMap = infoService.queryInfoMapByClass(projectId, classCodes);
|
|
|
+ // 信息点校验器
|
|
|
+ List<ObjectDigital> restList = new ArrayList<>();
|
|
|
+ for(ObjectDigital vo:voList) {
|
|
|
+ // 获取信息点列表
|
|
|
+ Map<String, ObjectInfoDefine> infoMap = typeInfoMap == null ? null : typeInfoMap.get(vo.getClassCode());
|
|
|
+ if (MapUtil.isEmpty(infoMap)) {
|
|
|
+ log.error(StrUtil.format("没有对象类型【{}】的信息点定义信息!", vo.getClassCode()));
|
|
|
+ vo.setMark(StrUtil.format("没有对象类型【{}】的信息点定义信息!", vo.getClassCode()));
|
|
|
+ // 只保留验证失败的
|
|
|
+ restList.add(vo);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return restList;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/***
|
|
|
* Description: 通用处理分页数据方法
|
|
@@ -686,20 +712,18 @@ public class ObjectDigitalServiceImpl extends ServiceImpl<ObjectDigitalMapper, O
|
|
|
* @param voList
|
|
|
* @param isUpdate
|
|
|
*/
|
|
|
- private List<ObjectDigital> validateOnSave(List<ObjectDigital> voList, boolean isUpdate) {
|
|
|
- return validateInfoCode(voList);
|
|
|
+ private void validateOnSave(List<ObjectDigital> voList, boolean isUpdate) {
|
|
|
+ validateInfoCode(voList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 信息点值校验
|
|
|
* @param voList
|
|
|
- * @return 对象类型不存在的需要返回
|
|
|
*/
|
|
|
- private List<ObjectDigital> validateInfoCode(List<ObjectDigital> voList) {
|
|
|
+ private void validateInfoCode(List<ObjectDigital> voList) {
|
|
|
if(CollUtil.isEmpty(voList)) {
|
|
|
- return Collections.emptyList();
|
|
|
+ return ;
|
|
|
}
|
|
|
- List<ObjectDigital> errorList = new ArrayList<>();
|
|
|
// 保存时,项目ID一定有,而且都是操作这个项目的数据。这是前提,若后续放开全集团保存,则应按项目分组后查询信息点
|
|
|
String projectId = AppContext.getContext().getProjectId();
|
|
|
//获取该信息点当前classCode
|
|
@@ -713,8 +737,6 @@ public class ObjectDigitalServiceImpl extends ServiceImpl<ObjectDigitalMapper, O
|
|
|
Map<String, ObjectInfoDefine> infoMap = typeInfoMap == null ? null : typeInfoMap.get(vo.getClassCode());
|
|
|
if(MapUtil.isEmpty(infoMap)) {
|
|
|
log.error(StrUtil.format("没有对象类型【{}】的信息点定义信息!", vo.getClassCode()));
|
|
|
- vo.setMark(StrUtil.format("没有对象类型【{}】的信息点定义信息!", vo.getClassCode()));
|
|
|
- errorList.add(vo);
|
|
|
continue;
|
|
|
}
|
|
|
// 只保留有对象类型的
|
|
@@ -739,7 +761,6 @@ public class ObjectDigitalServiceImpl extends ServiceImpl<ObjectDigitalMapper, O
|
|
|
} catch (BusinessException e) {
|
|
|
// 校验不通过的移除
|
|
|
infoKeys.remove();
|
|
|
-
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
@@ -749,7 +770,6 @@ public class ObjectDigitalServiceImpl extends ServiceImpl<ObjectDigitalMapper, O
|
|
|
if(CollUtil.isNotEmpty(restList)) {
|
|
|
voList.addAll(restList);
|
|
|
}
|
|
|
- return errorList;
|
|
|
}
|
|
|
|
|
|
/**
|