From d1da7fa2bb7733f33670ddba4620b905c9692f69 Mon Sep 17 00:00:00 2001 From: yuxc <653031404@qq.com> Date: 星期四, 12 十月 2023 16:23:16 +0800 Subject: [PATCH] 1、增加在业务数据增加与修改时验证相应的业务表中ID是否存在。 --- Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmEngineService.java | 19 +++++++++ Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java | 46 ++++++++++++++++++++++- Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmProductCodeServiceImpl.java | 9 ++++ 3 files changed, 71 insertions(+), 3 deletions(-) diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmEngineService.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmEngineService.java index 6dd6af6..81d7ca2 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmEngineService.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmEngineService.java @@ -396,6 +396,25 @@ */ Integer insertBatchByType(String btmType, List<BaseModel> baseModels); /** + * 浼犲叆涓氬姟绫诲瀷浠ュ強ID鏌ヨ涓氬姟琛ㄦ暟鎹槸鍚﹂噸澶� + * + * @param btmType 涓氬姟绫诲瀷 + * @param ids 澶勭悊鏁版嵁 + * @return 鏌ヨ鍒版暟鎹殑鎬绘暟 + */ + Integer selectIdsCounts(String btmType, List<String> ids); + + /** + * 浼犲叆涓氬姟绫诲瀷浠ュ強ID銆丱ID鏌ヨ涓氬姟琛ㄦ暟鎹槸鍚﹂噸澶� + * + * @param btmType 涓氬姟绫诲瀷 + * @param id 澶勭悊鏁版嵁id + * @param oid 澶勭悊鏁版嵁oid + * @return 鏌ヨ鍒版暟鎹殑鎬绘暟 + */ + Integer selectIdAndOidCounts(String btmType, String id, String oid); + + /** * 浼犲叆涓氬姟绫诲瀷浠ュ強鐩竜id闆嗗悎鏌ヨ鏁版嵁杩涜杩斿洖 * * @param btmType 涓氬姟绫诲瀷 diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java index 184ea18..a10b340 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java @@ -2363,8 +2363,14 @@ // cbo.getData().putAll(orderDTO.getData()); cbo.setLastModifyTime(new Date()); cbo.setLastModifier(String.valueOf(AuthUtil.getUser().getUserId())); - updateBatchByBaseModel(classifyFullInfo.getTopClassifyVO().getBtmTypeId(), Collections.singletonList(cbo)); - batchSaveSelectChar(templateVO, Collections.singletonList(cbo)); + if(selectIdAndOidCounts(classifyFullInfo.getTopClassifyVO().getBtmTypeId(),cbo.getId(),cbo.getOid())>0){ + throw new ServiceException("淇敼鐨勭紪鐮佹暟鎹甀D宸叉湁鍘嗗彶璁板綍璇风‘璁わ紒锛�"); + } + R r = updateBatchByBaseModel(classifyFullInfo.getTopClassifyVO().getBtmTypeId(), Collections.singletonList(cbo)); + if(!r.isSuccess()){ + throw new ServiceException(r.getMsg()); + } + batchSaveSelectChar(templateVO, Collections.singletonList(cbo)); } /** @@ -3522,6 +3528,42 @@ }); return commonsMapper.insertByBaseModel(listR.getData().get(0).getTableName(), maps.get(0), maps); } + /** + * 浼犲叆涓氬姟绫诲瀷浠ュ強ID鏌ヨ涓氬姟琛ㄦ暟鎹槸鍚﹂噸澶� + * + * @param btmType 涓氬姟绫诲瀷 + * @param ids 澶勭悊鏁版嵁 + * @return 鏌ヨ鍒版暟鎹殑鎬绘暟 + */ + @Override + public Integer selectIdsCounts(String btmType, List<String> ids) { + //浣跨敤浼犲叆鐨勪笟鍔$被鍨嬫煡璇㈣〃 + R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType)); + if (!listR.isSuccess() || listR.getData().size() == 0) { + throw new VciBaseException("浼犲叆涓氬姟绫诲瀷鏈煡璇㈠埌鐩稿簲琛ㄥ崟锛岃妫�鏌ワ紒"); + } + return commonsMapper.queryCountBySql("select count(*) from " + + listR.getData().get(0).getTableName() + " where id in ("+ ids.stream().map(s -> "'" + s + "'").collect(Collectors.joining(",")) +")"); + } + + /** + * 浼犲叆涓氬姟绫诲瀷浠ュ強ID銆丱ID鏌ヨ涓氬姟琛ㄦ暟鎹槸鍚﹂噸澶� + * + * @param btmType 涓氬姟绫诲瀷 + * @param id 澶勭悊鏁版嵁id + * @param oid 澶勭悊鏁版嵁oid + * @return 鏌ヨ鍒版暟鎹殑鎬绘暟 + */ + @Override + public Integer selectIdAndOidCounts(String btmType, String id, String oid) { + //浣跨敤浼犲叆鐨勪笟鍔$被鍨嬫煡璇㈣〃 + R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType)); + if (!listR.isSuccess() || listR.getData().size() == 0) { + throw new VciBaseException("浼犲叆涓氬姟绫诲瀷鏈煡璇㈠埌鐩稿簲琛ㄥ崟锛岃妫�鏌ワ紒"); + } + return commonsMapper.queryCountBySql("select count(*) from " + + listR.getData().get(0).getTableName() + " where id ='" + id + "' and oid <> '" + oid + "'"); + } /** * 浼犲叆涓氬姟绫诲瀷浠ュ強鐩竜id闆嗗悎鏌ヨ鏁版嵁杩涜杩斿洖 diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmProductCodeServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmProductCodeServiceImpl.java index cf29925..0e4b705 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmProductCodeServiceImpl.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmProductCodeServiceImpl.java @@ -30,6 +30,7 @@ import com.vci.ubcs.starter.web.util.VciBaseUtil; import com.vci.ubcs.starter.web.util.VciDateUtil; import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -275,6 +276,9 @@ codeAllCodeService.saveBatch(addCodeDOs); } mdmEngineService.insertBatchByType(dataCBOList.get(0).getBtmname(),dataCBOList); + if(mdmEngineService.selectIdsCounts(dataCBOList.get(0).getBtmname(),dataCBOList.stream().map(BaseModel::getId).collect(Collectors.toList()))>0){ + throw new ServiceException("鐢熸垚缂栫爜鏁版嵁ID宸叉湁鍘嗗彶璁板綍璇风‘璁わ紒锛�"); + } } return codeList; }else { @@ -351,7 +355,10 @@ Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(CodeAllCode::getId))), ArrayList::new)); if( distinctCodeAllCOdes.size() != allCodeDOList.size() ){ - throw new VciBaseException("缂栫爜鏁版嵁閲嶅锛屾棤娉曚繚瀛橈紝璇锋敞鎰忥紒"); + throw new ServiceException("缂栫爜鏁版嵁閲嶅锛屾棤娉曚繚瀛橈紝璇锋敞鎰忥紒"); + } + if(mdmEngineService.selectIdsCounts(dataCBOList.get(0).getBtmname(),dataCBOList.stream().map(BaseModel::getId).collect(Collectors.toList()))>0){ + throw new ServiceException("鐢熸垚缂栫爜鏁版嵁ID宸叉湁鍘嗗彶璁板綍璇风‘璁わ紒锛�"); } codeAllCodeService.saveBatch(allCodeDOList); // iCodeWupinService.saveBatch(dataCBOList); -- Gitblit v1.9.3