代码提交
This commit is contained in:
parent
cf547a0424
commit
5603db4730
|
|
@ -443,10 +443,12 @@ public class DevMergeServiceImpl implements DevMergeService {
|
|||
}
|
||||
|
||||
// 2. 过滤null元素
|
||||
list = list.stream().filter(Objects::nonNull).collect(Collectors.toList());
|
||||
list = list.stream().filter(Objects::nonNull)
|
||||
.filter(item-> StringUtils.hasText(item.getProfession()) || isCoreFieldHasValue(item))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 2.1 过滤装备类目都没选择的数据
|
||||
list = list.stream().filter(item -> StringUtils.isNotBlank(item.getProfession())).collect(Collectors.toList());
|
||||
//list = list.stream().filter(item -> StringUtils.isNotBlank(item.getProfession())).collect(Collectors.toList());
|
||||
|
||||
// 3. 再次检查过滤后是否有有效数据
|
||||
if (list.isEmpty()) {
|
||||
|
|
@ -463,21 +465,21 @@ public class DevMergeServiceImpl implements DevMergeService {
|
|||
|
||||
// 2. 批量校验DTO字段合法性(JSR-303)
|
||||
List<String> errorMessages = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
EquipmentImportDTO item = list.get(i);
|
||||
Set<ConstraintViolation<EquipmentImportDTO>> violations = validator.validate(item);
|
||||
if (!violations.isEmpty()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("第").append(i + 1).append("行数据错误:"); // 行号从1开始,方便用户定位
|
||||
for (ConstraintViolation<EquipmentImportDTO> violation : violations) {
|
||||
sb.append(violation.getMessage()).append(";");
|
||||
}
|
||||
errorMessages.add(sb.toString());
|
||||
}
|
||||
}
|
||||
if (!errorMessages.isEmpty()) {
|
||||
return AjaxResult.error("导入失败,存在以下错误:" + String.join(" ", errorMessages));
|
||||
}
|
||||
// for (int i = 0; i < list.size(); i++) {
|
||||
// EquipmentImportDTO item = list.get(i);
|
||||
// Set<ConstraintViolation<EquipmentImportDTO>> violations = validator.validate(item);
|
||||
// if (!violations.isEmpty()) {
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// sb.append("第").append(i + 1).append("行数据错误:"); // 行号从1开始,方便用户定位
|
||||
// for (ConstraintViolation<EquipmentImportDTO> violation : violations) {
|
||||
// sb.append(violation.getMessage()).append(";");
|
||||
// }
|
||||
// errorMessages.add(sb.toString());
|
||||
// }
|
||||
// }
|
||||
// if (!errorMessages.isEmpty()) {
|
||||
// return AjaxResult.error("导入失败,存在以下错误:" + String.join(" ", errorMessages));
|
||||
// }
|
||||
|
||||
// 4. 遍历数据,进行最终校验和导入
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
|
|
@ -1153,4 +1155,21 @@ public class DevMergeServiceImpl implements DevMergeService {
|
|||
|
||||
return typePropertiesMap;
|
||||
}
|
||||
|
||||
private boolean isCoreFieldHasValue(EquipmentImportDTO item){
|
||||
return StringUtils.hasText(item.getEquipmentName())
|
||||
|| StringUtils.hasText(item.getSpecification())
|
||||
|| item.getOriginalValue() != null
|
||||
|| StringUtils.hasText(item.getManufacturer())
|
||||
|| item.getProductionDate() != null
|
||||
|| item.getNextMaintenanceDate() != null
|
||||
|| StringUtils.hasText(item.getOriginalCode())
|
||||
|| item.getMaxServiceYears() != null
|
||||
|| StringUtils.hasText(item.getUnit())
|
||||
|| item.getPurchaseDate() != null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -352,12 +352,13 @@ public class RepairServiceImpl implements RepairService {
|
|||
if ("装备".equals(toBeRepair.getType())) {
|
||||
ToBeRepair bean1 = mapper.selectMaDevInfoByTypeIdAndCode(toBeRepair);
|
||||
if (bean1 == null || !"5".equals(bean1.getStatus())) {
|
||||
throw new RuntimeException(toBeRepair.getCode() + "编码设备已经处理过");
|
||||
return AjaxResult.error(toBeRepair.getCode() + "编码设备已经处理过",AjaxResult.class);
|
||||
}
|
||||
} else if ("工具".equals(toBeRepair.getType())) {
|
||||
ToBeRepair bean1 = mapper.selectByTypeIdAndCode(toBeRepair);
|
||||
if (bean1 == null || !"2".equals(bean1.getStatus())) {
|
||||
throw new RuntimeException(toBeRepair.getCode() + "编码设备已经处理过");
|
||||
return AjaxResult.error(toBeRepair.getCode() + "编码设备已经处理过",AjaxResult.class);
|
||||
|
||||
}
|
||||
}
|
||||
} else if ("数量管理".equals(toBeRepair.getManageMode())) {
|
||||
|
|
@ -365,7 +366,7 @@ public class RepairServiceImpl implements RepairService {
|
|||
//todo 目前数量管理的设备都是工具
|
||||
ToBeRepair bean1 = mapper.selectByTypeIdAndCode(toBeRepair);
|
||||
if (bean1 == null || bean1.getRepairNum().compareTo(toBeRepair.getRepairNum()) < 0) {
|
||||
throw new RuntimeException(toBeRepair.getTypeModelName() + "剩余维修设备数量不足");
|
||||
return AjaxResult.error(toBeRepair.getTypeModelName() + "剩余维修设备数量不足",AjaxResult.class);
|
||||
}
|
||||
}
|
||||
if (!StringHelper.isNullOrEmptyString(toBeRepair.getAuditStatus())) {
|
||||
|
|
|
|||
|
|
@ -346,8 +346,20 @@
|
|||
LEFT JOIN tool_ledger tl on tl.id=od.ma_id
|
||||
LEFT JOIN tool_type tt ON tl.type_id = tt.type_id
|
||||
LEFT JOIN tool_type tt1 ON tt1.type_id = tt.parent_id
|
||||
where od.devType=#{status}
|
||||
AND tl.type_id = #{typeId}
|
||||
<where>
|
||||
od.devType=#{status}
|
||||
AND tl.type_id = #{typeId}
|
||||
and od.real_num is NOT null
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
AND (
|
||||
tl.tool_code LIKE CONCAT('%', #{keyWord}, '%')
|
||||
OR tt.type_name LIKE CONCAT('%', #{keyWord}, '%')
|
||||
OR tt1.type_name LIKE CONCAT('%', #{keyWord}, '%')
|
||||
OR oi.pro_name LIKE CONCAT('%', #{keyWord}, '%')
|
||||
OR od.real_num =#{keyWord}
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="insertDevInfoProperties">
|
||||
|
|
|
|||
Loading…
Reference in New Issue