From c71cca6babec17f4bdfa54f80aeaf4135e7440ef Mon Sep 17 00:00:00 2001
From: 田源 <lastanimals@163.com>
Date: 星期五, 01 十二月 2023 14:35:55 +0800
Subject: [PATCH] 主数据标准需求更改
---
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java | 119 ++++++++++++++++++++++++++++++++++++++---------------------
1 files changed, 76 insertions(+), 43 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 76d26b5..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);
}
/**
@@ -886,7 +910,7 @@
* @param authUser
* @return
*/
- private String addSaveBZCode(CodeBZApplyDTO codeBZApplyDTO, boolean authUser) throws Exception {
+ public String addSaveBZCode(CodeBZApplyDTO codeBZApplyDTO, boolean authUser) throws Exception {
String code="";
VciBaseUtil.alertNotNull(codeBZApplyDTO.getCodeClassifyOid(), "涓婚搴撳垎绫荤殑涓婚敭",
codeBZApplyDTO.getTemplateOid(), "妯℃澘鐨勪富閿�", codeBZApplyDTO.getCodeRuleOid(), "缂栫爜瑙勫垯鐨勪富閿�");
@@ -961,21 +985,20 @@
LinkedList<CodeOrderSecDTO> newSecDTOList=new LinkedList<>();
changeCodeOrderSecDTO(ruleVO,secDTOS,oldCode,newSecDTOList);//鏍规嵁瑕佹眰閲嶆柊绠楃爜娈电爜鍊�
if(!codeBZApplyDTO.isEditSeries()){//鍙樻洿涓烘爣鍑�
- if(!codeBZApplyDTO.isSeries()){//濡傛灉鏄〃鍑嗭紝鍒欓渶瑕佸皢绯诲垪濂芥祦姘寸疆涓簄ull
+ //if(!codeBZApplyDTO.isSeries()){//濡傛灉鏄〃鍑嗭紝鍒欓渶瑕佸皢绯诲垪濂芥祦姘寸疆涓簄ull
//鍥犱负鏄爣鍑嗗垯鎺у埗鐮佹涓殑绯诲垪娴佹按鐮佹鍊间负绌�
newSecDTOList.stream().forEach(codeOrderSecDTO -> {
if(codeCodeBasicSecMap.containsKey(codeOrderSecDTO.getSecOid())&&codeCodeBasicSecMap.get(codeOrderSecDTO.getSecOid()).getName().equals(secName)){
codeOrderSecDTO.setSecValue("");
}
});
- }
+ //}
orderDTO.setSecDTOList(newSecDTOList);
return createDataBZ(orderDTO,ruleVO,authUser);
}else{//鍙樻洿涓虹郴鍒�.鍒欐寜鐓ч�昏緫鍘诲鐞�
-
-
+ orderDTO.setSecDTOList(newSecDTOList);
+ return createDataBZ(orderDTO,ruleVO,authUser);
}
- return "";
}
private String createDataBZ(CodeOrderDTO orderDTO, CodeRuleVO ruleVO,boolean authUser) throws Exception {
CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid());
@@ -1113,6 +1136,7 @@
* @return
* @throws Exception
*/
+ @Override
public String addSaveBZCodeNotauthUser(CodeBZApplyDTO codeBZApplyDTO, boolean authUser) throws Exception {
return addSaveBZCode(codeBZApplyDTO,authUser);
}
@@ -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));
}
@@ -4520,7 +4552,8 @@
toBo.setVersionSeq(Integer.valueOf(nextRevision.get("VERSIONSEQ").toString()));
toBo.setVersionValue(nextRevision.get("VERSIONVAL").toString());
toBo.setLctid(fromBo.getLctid());
- toBo.setLcStatus("Editing");
+ //toBo.setLcStatus("Editing");
+ toBo.setLcStatus(CodeDefaultLC.RELEASED.getValue());
toBo.setId(fromBo.getId());
toBo.setName(fromBo.getName());
toBo.setDescription(fromBo.getDescription());
--
Gitblit v1.9.3