diff --git a/op-modules/op-device/src/main/java/com/op/device/service/impl/EquCheckItemServiceImpl.java b/op-modules/op-device/src/main/java/com/op/device/service/impl/EquCheckItemServiceImpl.java index ca59075c..1c240e80 100644 --- a/op-modules/op-device/src/main/java/com/op/device/service/impl/EquCheckItemServiceImpl.java +++ b/op-modules/op-device/src/main/java/com/op/device/service/impl/EquCheckItemServiceImpl.java @@ -189,9 +189,27 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService { equCheckItemMapper.updateEquCheckItem(equCheckItem); for (EquCheckItemDetail detail : equCheckItemDTO.getFormStandard()) { - detail.setUpdatedBy(SecurityContextHolder.getUserName()); - detail.setUpdatedTime(DateUtils.getNowDate()); - equCheckItemDetailMapper.updateEquCheckItemDetail(detail); + // 标准不存在则新增 + if (detail.getDetailCode() == null) { + // 获取标准流水号 + String detailSerialNum = String.format("%03d", equCheckItemDetailMapper.selectSerialNumber(equCheckItem.getItemCode())); + + detail.setDetailId(IdUtils.fastSimpleUUID()); + detail.setParentCode(equCheckItem.getItemCode()); + detail.setFactoryCode(equCheckItem.getFactoryCode()); + detail.setDetailCode(equCheckItem.getItemCode()+detailSerialNum); + detail.setCreatedBy(SecurityContextHolder.getUserName()); + detail.setCreatedTime(DateUtils.getNowDate()); + detail.setUpdatedBy(SecurityContextHolder.getUserName()); + detail.setUpdatedTime(DateUtils.getNowDate()); + + // 插入到数据库 + equCheckItemDetailMapper.insertEquCheckItemDetail(detail); + }else { + detail.setUpdatedBy(SecurityContextHolder.getUserName()); + detail.setUpdatedTime(DateUtils.getNowDate()); + equCheckItemDetailMapper.updateEquCheckItemDetail(detail); + } } return success("修改成功"); }