From 93c7226d536d312fc083a57619629192ba076413 Mon Sep 17 00:00:00 2001 From: xiejun <xj@2023> Date: 星期五, 01 十二月 2023 12:36:50 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java | 104 ++++++++++++++++++++++++++++++++++------------------ 1 files changed, 68 insertions(+), 36 deletions(-) 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 749bcb2..2dd56b5 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 @@ -1,5 +1,6 @@ package com.vci.ubcs.code.service.impl; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -42,6 +43,7 @@ import com.vci.ubcs.starter.revision.model.TreeWrapperOptions; import com.vci.ubcs.starter.revision.service.RevisionModelUtil; import com.vci.ubcs.starter.util.MdmBtmTypeConstant; +import com.vci.ubcs.starter.util.SaveLogUtil; import com.vci.ubcs.starter.util.UBCSSqlKeyword; import com.vci.ubcs.starter.web.constant.QueryOptionConstant; import com.vci.ubcs.starter.web.constant.RegExpConstant; @@ -62,12 +64,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springblade.core.cache.utils.CacheUtil; +import org.springblade.core.log.annotation.OperateLog; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringPool; +import org.springblade.core.tool.utils.StringUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.cache.Cache; @@ -346,8 +350,15 @@ */ @Autowired private IMDMIFlowAttrClient imdmiFlowAttrClient; -// @Autowired -// private CodeOsbtmtypeMapper codeOsbtmtypeMapper;---- + + // @Autowired + // private CodeOsbtmtypeMapper codeOsbtmtypeMapper; + + /** + * 鏃ュ織淇濆瓨宸ュ叿绫� + */ + @Autowired + private SaveLogUtil saveLogUtil; /** @@ -410,39 +421,52 @@ @Transactional @Override public void changeStatus(BaseModelDTO baseModelDTO) { - VciBaseUtil.alertNotNull(baseModelDTO, "鏁版嵁淇℃伅", baseModelDTO.getOid(), "涓婚敭", baseModelDTO.getBtmname(), "涓氬姟绫诲瀷", baseModelDTO.getLcStatus(), "鐩爣鐘舵��"); - List<String> oids = VciBaseUtil.str2List(baseModelDTO.getOid()); - List<BaseModel> baseModels = new ArrayList<>(); - baseModels = selectByTypeAndOid(baseModelDTO.getBtmname(), baseModelDTO.getOid()); - if (baseModels.size() == 0) { - throw new VciBaseException("鏈煡璇㈠埌鐩稿叧鏁版嵁銆�"); - } - //杩橀渶瑕佷慨鏀筧llCode鐨勭敓鍛藉懆鏈� - QueryWrapper<CodeAllCode> allCodeWrapper = new QueryWrapper<>(); - allCodeWrapper.eq("createcodebtm", baseModelDTO.getBtmname()); - allCodeWrapper.in("createcodeoid", oids); - List<CodeAllCode> codeCbos = codeAllCodeService.selectByWrapper(allCodeWrapper);// 鍥炴敹闇�瑕佷笟鍔℃暟鎹垹闄� - if (CodeDefaultLC.TASK_BACK.getValue().equals(baseModelDTO.getLcStatus())) { - R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(baseModelDTO.getBtmname())); - if (!listR.isSuccess() || listR.getData().size() == 0) { - throw new VciBaseException("浼犲叆涓氬姟绫诲瀷鏈煡璇㈠埌鐩稿簲琛ㄥ崟锛岃妫�鏌ワ紒"); - } - // 鐩存帴鍒犻櫎锛屼笉缁欑姸鎬� - commonsMapper.deleteByTaleAndOid(listR.getData().get(0).getTableName(), VciBaseUtil.toInSql(baseModelDTO.getOid())); - // commonsMapper.updateByTaleAndOid(listR.getData().get(0).getTableName(), VciBaseUtil.toInSql(baseModelDTO.getOid()),CodeDefaultLC.TASK_BACK.getValue()); - } else { - for (BaseModel baseModel : baseModels) { - baseModel.setLcStatus(baseModelDTO.getLcStatus()); - } - R r = updateBatchByBaseModel(baseModelDTO.getBtmname(), baseModels); - if(!r.isSuccess()){ - throw new VciBaseException("鏇存柊鏁版嵁鍑洪敊锛岄噸璇曪紒"+r.getMsg()); + try { + VciBaseUtil.alertNotNull(baseModelDTO, "鏁版嵁淇℃伅", baseModelDTO.getOid(), "涓婚敭", baseModelDTO.getBtmname(), "涓氬姟绫诲瀷", baseModelDTO.getLcStatus(), "鐩爣鐘舵��"); + List<String> oids = VciBaseUtil.str2List(baseModelDTO.getOid()); + List<BaseModel> baseModels = new ArrayList<>(); + baseModels = selectByTypeAndOid(baseModelDTO.getBtmname(), baseModelDTO.getOid()); + if (baseModels.size() == 0) { + throw new VciBaseException("鏈煡璇㈠埌鐩稿叧鏁版嵁銆�"); } + //杩橀渶瑕佷慨鏀筧llCode鐨勭敓鍛藉懆鏈� + QueryWrapper<CodeAllCode> allCodeWrapper = new QueryWrapper<>(); + allCodeWrapper.eq("createcodebtm", baseModelDTO.getBtmname()); + allCodeWrapper.in("createcodeoid", oids); + List<CodeAllCode> codeCbos = codeAllCodeService.selectByWrapper(allCodeWrapper);// 鍥炴敹闇�瑕佷笟鍔℃暟鎹垹闄� + if (CodeDefaultLC.TASK_BACK.getValue().equals(baseModelDTO.getLcStatus())) { + R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(baseModelDTO.getBtmname())); + if (!listR.isSuccess() || listR.getData().size() == 0) { + throw new VciBaseException("浼犲叆涓氬姟绫诲瀷鏈煡璇㈠埌鐩稿簲琛ㄥ崟锛岃妫�鏌ワ紒"); + } + // 鐩存帴鍒犻櫎锛屼笉缁欑姸鎬� + commonsMapper.deleteByTaleAndOid(listR.getData().get(0).getTableName(), VciBaseUtil.toInSql(baseModelDTO.getOid())); + // commonsMapper.updateByTaleAndOid(listR.getData().get(0).getTableName(), VciBaseUtil.toInSql(baseModelDTO.getOid()),CodeDefaultLC.TASK_BACK.getValue()); + } else { + for (BaseModel baseModel : baseModels) { + baseModel.setLcStatus(baseModelDTO.getLcStatus()); + } + R r = updateBatchByBaseModel(baseModelDTO.getBtmname(), baseModels); + if(!r.isSuccess()){ + throw new VciBaseException("鏇存柊鏁版嵁鍑洪敊锛岄噸璇曪紒"+r.getMsg()); + } + } + for (CodeAllCode codeCbo : codeCbos) { + codeCbo.setLcStatus(baseModelDTO.getLcStatus()); + } + codeAllCodeService.updateBatchById(codeCbos); + + //璁板綍鏃ュ織淇℃伅 + saveLogUtil.operateLog( + CodeDefaultLC.getTextByValue(baseModelDTO.getLcStatus()), + false, + JSON.toJSONString(baseModels) + ); + }catch (Exception e){ + // 鎻掑叆鏇存敼鏃ュ織璁板綍 + saveLogUtil.operateLog(CodeDefaultLC.getTextByValue(baseModelDTO.getLcStatus()),true,e.getMessage()); + throw e; } - for (CodeAllCode codeCbo : codeCbos) { - codeCbo.setLcStatus(baseModelDTO.getLcStatus()); - } - codeAllCodeService.updateBatchById(codeCbos); } /** @@ -2705,6 +2729,7 @@ cbo.setLastModifyTime(new Date()); cbo.setLastModifier(String.valueOf(AuthUtil.getUser().getAccount())); R r = updateBatchByBaseModel(classifyFullInfo.getTopClassifyVO().getBtmTypeId(), Collections.singletonList(cbo)); + if(!r.isSuccess()){ throw new ServiceException(r.getMsg()); } @@ -3079,11 +3104,18 @@ oldCbo.setLastModifier(String.valueOf(AuthUtil.getUser().getAccount())); oldCbo.setLastModifyTime(new Date()); try { + // 淇敼鐗堟鍙� updateBatchByBaseModel(oldCbo.getBtmname(), Collections.singletonList(oldCbo)); + // 鎻掑叆鏂扮殑鏁版嵁 insertBatchByType(cbo.getBtmname(), Collections.singletonList(cbo)); - } catch (Exception vciError) { - throw new VciBaseException("鏁版嵁鏇存敼淇濆瓨鍑洪敊浜�", new String[0], vciError); - } + // 璁板綍鏁版嵁鏇存敼鏃ュ織 + saveLogUtil.operateLog("鏁版嵁鏇存敼",false, StringUtil.format("{}\n淇敼涓�:\n{}",JSON.toJSONString(Collections.singletonList(oldCbo)),JSON.toJSONString(Collections.singletonList(cbo)))); + } catch (Exception vciError) { + // 璁板綍鏁版嵁鏇存敼鎶ラ敊鏃剁殑鏃ュ織 + saveLogUtil.operateLog("鏁版嵁鏇存敼",true,vciError.getMessage()); + throw new VciBaseException("鏁版嵁鏇存敼淇濆瓨鍑洪敊浜�", new String[0], vciError); + } + batchSaveSelectChar(templateVO, Collections.singletonList(cbo)); } -- Gitblit v1.9.3