From 3cc2b58dcb169f147bc5bdccfd782514d736531d Mon Sep 17 00:00:00 2001
From: 田源 <lastanimals@163.com>
Date: 星期二, 30 一月 2024 11:23:09 +0800
Subject: [PATCH] 主题库定义编码规则 规则基础配置 业务类型
---
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeDuckingSyncServiceImpl.java | 568 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 561 insertions(+), 7 deletions(-)
diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeDuckingSyncServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeDuckingSyncServiceImpl.java
index a2b2c06..b3d3f2b 100644
--- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeDuckingSyncServiceImpl.java
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeDuckingSyncServiceImpl.java
@@ -7,7 +7,11 @@
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
+import com.vci.ubcs.code.Scheduling.NonWebRequestAttributes;
+import com.vci.ubcs.code.bo.CodeClassifyFullInfoBO;
import com.vci.ubcs.code.constant.MdmDuckingConstant;
+import com.vci.ubcs.code.dto.CodeOrderDTO;
+import com.vci.ubcs.code.dto.CodeOrderSecDTO;
import com.vci.ubcs.code.dto.datapush.classify.JsonRootDataDTO;
import com.vci.ubcs.code.dto.datapush.classify.NodeClassifyDTO;
import com.vci.ubcs.code.dto.datapush.classify.NodeDataDTO;
@@ -20,33 +24,71 @@
import com.vci.ubcs.code.dto.datapush.result.ResultNodeDataDTO;
import com.vci.ubcs.code.dto.datapush.result.ResultNodeObjectDTO;
import com.vci.ubcs.code.entity.*;
+import com.vci.ubcs.code.enumpack.CodeDefaultLC;
+import com.vci.ubcs.code.enumpack.CodeSecTypeEnum;
import com.vci.ubcs.code.enumpack.SysIntegrationDataFlowTypeEnum;
+import com.vci.ubcs.code.feign.MdmSearchItemCodeProvider;
+import com.vci.ubcs.code.mapper.CommonsMapper;
import com.vci.ubcs.code.service.*;
+import com.vci.ubcs.code.util.gennerAttrMapUtil;
+import com.vci.ubcs.code.vo.pagemodel.*;
+import com.vci.ubcs.code.vo.webserviceModel.apply.ApplyDataVO;
+import com.vci.ubcs.code.vo.webserviceModel.apply.ApplyDatasVO;
+import com.vci.ubcs.code.vo.webserviceModel.apply.ProppertyVO;
+import com.vci.ubcs.code.vo.webserviceModel.apply.SectionVO;
+import com.vci.ubcs.code.vo.webserviceModel.applybz.ApplyBZDataVO;
+import com.vci.ubcs.code.vo.webserviceModel.applybz.ApplyBZDatasVO;
+import com.vci.ubcs.code.vo.webserviceModel.attrmap.*;
+import com.vci.ubcs.code.vo.webserviceModel.result.xml.XMLResultDataObjectDetailDO;
+import com.vci.ubcs.code.webService.config.AttributeMapConfig;
+import com.vci.ubcs.omd.feign.IBtmTypeClient;
+import com.vci.ubcs.omd.vo.BtmTypeVO;
+import com.vci.ubcs.starter.exception.VciBaseException;
+import com.vci.ubcs.starter.revision.model.BaseModel;
+import com.vci.ubcs.starter.util.DefaultAttrAssimtUtil;
import com.vci.ubcs.starter.util.HttpUtils;
import com.vci.ubcs.code.util.WsErpClientUtil;
-import com.vci.ubcs.code.vo.pagemodel.CodeClassifyTemplateAttrVO;
-import com.vci.ubcs.code.vo.pagemodel.CodeClassifyTemplateVO;
-import com.vci.ubcs.code.vo.pagemodel.CodeClassifyVO;
import com.vci.ubcs.starter.web.enumpck.UserSecretEnum;
import com.vci.ubcs.starter.web.pagemodel.SessionInfo;
+import com.vci.ubcs.starter.web.util.BeanUtil;
+import com.vci.ubcs.starter.web.util.BeanUtilForVCI;
import com.vci.ubcs.starter.web.util.VciBaseUtil;
import com.vci.ubcs.starter.web.util.WebUtil;
+import com.vci.ubcs.system.user.entity.User;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.map.CaseInsensitiveMap;
+import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.redis.cache.BladeRedis;
+import org.springblade.core.secure.BladeUser;
+import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.support.DefaultTransactionStatus;
import org.springframework.util.CollectionUtils;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
+import org.springframework.web.context.request.RequestAttributes;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
+import javax.jws.WebMethod;
+import javax.servlet.http.HttpServletRequest;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.handler.MessageContext;
+import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import static com.vci.ubcs.code.constant.MdmDuckingConstant.*;
+import static com.vci.ubcs.code.constant.MdmEngineConstant.DEFAULT_SYNC_ATTR_LIST;
+import static com.vci.ubcs.code.enumpack.CodeSecTypeEnum.CODE_CLASSIFY_SEC;
/*
@@ -60,10 +102,39 @@
public class CodeDuckingSyncServiceImpl implements ICodeDuckingSyncService {
@Value("${dataSyncPush.dataParamName:xmlData}")
public String DATA_PARAM_NAME;
- @Value("${dataSyncPush.dataId:itemOid}")
+ @Value("${dataSyncPush.dataId:itemid}")
private String itemId;
+ @Value("${erp.item.attrKey:xhdh}")
+ public String attrKey;
+
+ @Value("${erp.item.systemId:ERP}")
+ public String systemId;
+ @Value("${erp.item.secName:鍥哄畾鐮佹}")
+ public String secName;
+ @Value("${erp.item.secValue:A}")
+ public String secValue;
+
+ @Value("${erp.item.btmName:XHDH}")
+ public String btmName;
+ /**
+ * 涓氬姟绫诲瀷鐨勬湇鍔�
+ */
+ @Autowired
+ private IBtmTypeClient btmTypeClient;
+ /**
+ * 閫氱敤鏌ヨ
+ */
+ @Resource
+ private CommonsMapper commonsMapper;
@Resource
private MdmEngineService mdmEngineServiceI;
+ /**
+ * 鎵归噺澶勭悊鐨勬湇鍔�
+ */
+ @Resource
+ private MdmIOService mdmIOService;
+ @Resource
+ private IPasswordFreeLoginService passwordFreeLoginService;
@Resource
private IDockingLogeService dockingLogeService;
@@ -75,6 +146,11 @@
private IDockingSystemConfigService dockingSystemConfigService;
@Resource
private ICodeClassifyService codeClassifyService;
+
+ @Autowired
+ private ICodeClassifyValueService codeClassifyValueService;
+ @Autowired(required = false)
+ private AttributeMapConfig attributeMapConfig;
/***
* resdis缂撳瓨鏈嶅姟
*/
@@ -84,9 +160,10 @@
private IDockingSysIntParamService dockingSysIntParamService;
@Resource
private IDockingSysIntHeaderService dockingSysIntHeaderService;
-
-
-
+ @Autowired(required = false)
+ private MdmSearchItemCodeProvider mdmSearchItemCodeProvider;
+ @Autowired
+ HttpServletRequest request;
@Override
public void DockingDataSyncScheduing() {
@@ -148,8 +225,485 @@
});
return R.success("鎵嬪姩鎺ㄩ�佸畬鎴�,璇锋牳瀵规槸鍚︽帹閫佹垚鍔�");
}
+ private SearchItemDataVO initData(String status,String itemCode,String mmCode){
+ SearchItemDataVO searchItemDataVO=new SearchItemDataVO();
+ searchItemDataVO.setLastchangedon(new Date());
+ searchItemDataVO.setLastchangedby("19831133");
+ searchItemDataVO.setCreatby("19831133");
+ searchItemDataVO.setCreatedon(new Date());
+ searchItemDataVO.setIsenabled(status);
+ searchItemDataVO.setMaterialcode("XMDH0001");
+ searchItemDataVO.setStatus("1");
+ searchItemDataVO.setProjectcode("3333");
+ searchItemDataVO.setProjectitem(itemCode);
+ searchItemDataVO.setMmodelcode(mmCode);
+ return searchItemDataVO;
+ }
+ public HttpServletRequest getRequest(){
+ HttpServletRequest request =null;
+ RequestAttributes requestAttributes = null;
+ try{
+ requestAttributes = RequestContextHolder.currentRequestAttributes();
+ }catch (IllegalStateException e){
+ //requestAttributes = new NonWebRequestAttributes();
+ //RequestContextHolder.setRequestAttributes(requestAttributes, true);
+ request = new MockHttpServletRequest();
+ RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request),true);
+ }finally {
+ if (requestAttributes instanceof ServletRequestAttributes) {
+ ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes)RequestContextHolder.currentRequestAttributes();
+ request = servletRequestAttributes.getRequest();
+ }
+ }
+ return request;
+ }
+ /***
+ * 鍚屾鍨嬪彿浠e彿
+ */
+ @Override
+ public void saveItemDataSyncScheduing(String endDate) {
+ String paramString="";
+ String backString="鎴愬姛";
+ String msg="鎴愬姛";
+ boolean success=true;
+ SearchItemParam searchItemParam=new SearchItemParam();
+ searchItemParam.setSystag("VCI"); //璋冪敤绯荤粺鏍囪瘑
+ SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ String lastchangedon="";
+ if(StringUtils.isBlank(endDate)) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.set(Calendar.HOUR_OF_DAY, 0);
+ calendar.set(Calendar.MINUTE, 0);
+ calendar.set(Calendar.SECOND, 0);
+ log.info("鏌ヨ鏃堕棿------->"+calendar.getTime());
+ lastchangedon= dft.format(calendar.getTime());
+ }else{
+ lastchangedon=endDate;
+ }
+ searchItemParam.setLastchangedon(lastchangedon);
+ searchItemParam.setStatus("1");//
+ Map<String,String>searchDataMap= VciBaseUtil.objectToMapString(searchItemParam);
+ SearchItemVO searchItemVO= mdmSearchItemCodeProvider.getppModelByElem(searchDataMap);
+ /*SearchItemVO searchItemVO=new SearchItemVO();
+ List<SearchItemDataVO> data=new ArrayList<>();
+ SearchItemDataVO searchItemDataVO1=initData("1","","pro-00001");
+ SearchItemDataVO searchItemDataVO2=initData("0","item-00001","");
+ data.add(searchItemDataVO1);
+ data.add(searchItemDataVO2);
+ searchItemVO.setData(data);
+ searchItemVO.setCode("200");
+ searchItemVO.setMsg("");*/
+ if(searchItemVO!=null) {
+ paramString = JSONObject.toJSON(searchItemVO).toString();
+ try {
+ //鍏嶅瘑鐧诲綍鐢宠token锛宺equest涓坊鍔犵敤鎴蜂俊鎭�
+ try {
+ passwordFreeLoginService.pwdFreeLoginByBoolean(systemId.toLowerCase(Locale.ROOT),getRequest());
+ }catch (Throwable e){
+ throw new Throwable("鐢ㄦ埛閴存潈澶辫触.");
+ }
+ final BladeUser user = AuthUtil.getUser();
+ List<CodeClassify> codeClassifyList = codeClassifyService.selectByWrapper(Wrappers.<CodeClassify>query().lambda().in(CodeClassify::getId, btmName));
+ if (CollectionUtils.isEmpty(codeClassifyList)) {
+ throw new Throwable("鍒嗙被鏈煡璇㈠埌");
+ }
+ CodeClassify codeClassify= codeClassifyList.get(0);
+ CodeClassifyTemplateVO templateVO = mdmEngineServiceI.getUsedTemplateByClassifyOid(codeClassify.getOid());
+ if(templateVO==null||StringUtils.isBlank(templateVO.getOid())){
+ throw new Throwable ("鏍规嵁浼犺緭鐨勫垎绫伙紝鏈幏鍙朚DM绯荤粺涓搴旀ā鏉�");
+ }
+ List<CodeClassifyTemplateAttrVO> attrVOS = templateVO.getAttributes().stream().filter(s -> !DEFAULT_SYNC_ATTR_LIST.contains(s.getId()) &&
+ ((Func.isNotEmpty(s.getClassifyInvokeAttr()) || Func.isNotEmpty(s.getClassifyInvokeAttrName())) || VciBaseUtil.getBoolean(s.getFormDisplayFlag()))
+ ).collect(Collectors.toList());
+ List<SearchItemDataVO> dataList = searchItemVO.getData();
+ Map<String, SearchItemDataVO> dataVOMap = new HashMap<>();
+ List<String> itemCodeList = new ArrayList<>();
+ ApplyDatasVO allDatasVO = new ApplyDatasVO();
+ List<ApplyDataVO> allObjectList=new ArrayList<>();
+ if (!CollectionUtils.isEmpty(dataList)) {
+ dataList.stream().forEach(searchItemDataVO -> {
+ String itemCode = StringUtils.isNotBlank(searchItemDataVO.getProjectitem()) ? searchItemDataVO.getProjectitem() : searchItemDataVO.getMmodelcode();//椤圭洰浠e彿
+ dataVOMap.put(itemCode, searchItemDataVO);
+ itemCodeList.add(itemCode);
+ });
+ String tableName = "";
+ R<BtmTypeVO> r = btmTypeClient.getAllAttributeByBtmId(codeClassify.getBtmTypeId());
+ if (!r.isSuccess()) {
+ throw new Throwable(r.getMsg());
+ }
+ BtmTypeVO btmTypeVO = r.getData();
+ if (btmTypeVO == null) {
+ throw new Throwable("鏍规嵁涓氬姟绫诲瀷鏈煡璇㈠埌涓氬姟绫诲瀷瀵硅薄锛�");
+ }
+ tableName = btmTypeVO.getTableName();
+ if (StringUtils.isBlank(tableName)) {
+ throw new Throwable("鏍规嵁涓氬姟绫诲瀷鏈煡璇㈠埌涓氬姟绫诲瀷鐩稿叧鑱旂殑琛�");
+ }
+ StringBuffer sb = new StringBuffer();
+ sb.append(" select * from ");
+ sb.append(tableName);
+ sb.append(" where 1=1");
+ sb.append(" and lastr=1 and lastv=1");
+ sb.append(" and codeclsfid = '" + codeClassify.getOid() + "' ");
+ sb.append(" and "+ VciBaseUtil.toInSql(attrKey,itemCodeList.toArray(new String[]{})));
+ List<Map<String, String>> newDataList = commonsMapper.queryByOnlySqlForMap(sb.toString());
+ //List<BaseModel> baseModelList=new ArrayList<>();
+ Map<String,BaseModel> baseModelMap=new HashMap<>();
+ newDataList.stream().forEach(dataMap->{
+ BaseModel baseModel=new BaseModel();
+ Map<String,String> newDateMap=new CaseInsensitiveMap<>(dataMap);
+ DefaultAttrAssimtUtil.copplyDefaultAttrAssimt(newDateMap,baseModel,true,user);
+ DefaultAttrAssimtUtil.updateDefaultAttrAssimt(baseModel,user);
+ //baseModelList.add(baseModel);
+
+ String attrKeyValue=newDateMap.getOrDefault(attrKey,"");
+ baseModelMap.put(attrKeyValue,baseModel);
+ });
+
+ List<ApplyDataVO> addObjectList=new ArrayList<>();
+ List<ApplyDataVO> editObjectList=new ArrayList<>();
+ dataVOMap.forEach((key,value)->{
+ if(baseModelMap.containsKey(key)){
+ BaseModel baseModel=baseModelMap.get(key);
+ changeObjectToMap(value,baseModel.getId(),user,"editstatus",editObjectList);
+ }else{
+ changeObjectToMap(value,"",user,"create",addObjectList);
+ }
+ });
+ allObjectList.addAll(addObjectList);
+ allObjectList.addAll(editObjectList);
+ allDatasVO.setObject(allObjectList);
+ LinkedList<XMLResultDataObjectDetailDO> allResultDataObjectDetailDOS=new LinkedList<>();
+ if(!CollectionUtils.isEmpty(addObjectList)){
+ //瑙勫垯鐨勪富閿渶瑕佸幓鑾峰彇
+ CodeClassifyFullInfoBO classifyFullInfo = codeClassifyService.getClassifyFullInfo(codeClassify.getOid());
+ if(classifyFullInfo==null ||classifyFullInfo.getCurrentClassifyVO()==null || StringUtils.isBlank(classifyFullInfo.getCurrentClassifyVO().getOid())){
+ log.info("classifyFullInfo:"+"鏍规嵁浼犺緭鐨勫垎绫伙紝鏈幏鍙栧垎绫荤浉鍏充俊鎭�");
+ throw new Throwable ("鏍规嵁浼犺緭鐨勫垎绫伙紝鏈幏鍙栧垎绫荤浉鍏充俊鎭�");
+ }
+ CodeRuleVO ruleVO = mdmEngineServiceI.getCodeRuleByClassifyFullInfo(classifyFullInfo);
+ if(ruleVO==null||StringUtils.isBlank(ruleVO.getOid())){
+ throw new Throwable ("鏍规嵁浼犺緭鐨勫垎绫伙紝鏈幏鍙朚DM绯荤粺涓搴旇鍒�");
+ }
+ DataObjectVO dataObjectVO = new DataObjectVO();
+ ApplyDatasVO applyDatasVO = new ApplyDatasVO();
+ applyDatasVO.setObject(addObjectList);
+ LinkedList<XMLResultDataObjectDetailDO> resultDataObjectDetailDOs = new LinkedList<>();
+ this.getConfigDatas(systemId, btmName, applyDatasVO, attrVOS, dataObjectVO);
+ CodeOrderDTO orderDTO = new CodeOrderDTO();
+ orderDTO.setCodeClassifyOid(codeClassify.getOid());//鍒嗙被涓婚敭
+ //鐮佹璁剧疆
+ List<SectionVO> section=new ArrayList<>();
+ SectionVO sectionVO=new SectionVO();
+ sectionVO.setValue(secValue);
+ sectionVO.setName(secName);
+ section.add(sectionVO);
+ log.info("end锛氳鍒欒幏鍙栧畬姣�");
+ List<CodeOrderSecDTO> codeOrderSecDTOList = getRuleCodeOrderSecDTOs(section, ruleVO,classifyFullInfo);
+ log.info("end锛氱爜娈佃幏鍙栧畬姣�");
+ orderDTO.setSecDTOList(codeOrderSecDTOList);//鍒嗙被鐮佹
+ mdmIOService.batchSyncApplyCode(orderDTO, dataObjectVO, resultDataObjectDetailDOs,false);
+ allResultDataObjectDetailDOS.addAll(resultDataObjectDetailDOs);
+ }
+ //鏇存柊鏁版嵁锛堟洿鏂扮姸鎬侊級
+ if(!CollectionUtils.isEmpty(editObjectList)){
+ DataObjectVO dataObjectVO = new DataObjectVO();
+ ApplyDatasVO applyDatasVO = new ApplyDatasVO();
+ applyDatasVO.setObject(editObjectList);
+ LinkedList<XMLResultDataObjectDetailDO> resultDataObjectDetailDOs = new LinkedList<>();
+ CodeClassifyVO codeClassifyVO=new CodeClassifyVO();
+ BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassify, codeClassifyVO);
+ this.getConfigDatas(systemId, btmName, applyDatasVO, attrVOS, dataObjectVO);
+ mdmIOService.batchSyncEditDatas(codeClassifyVO,dataObjectVO, resultDataObjectDetailDOs,false);
+ allResultDataObjectDetailDOS.addAll(resultDataObjectDetailDOs);
+ }
+ Object paramObject = JSONObject.toJSON(allDatasVO);
+ paramString=Func.isEmpty(paramObject)?"":paramObject.toString();
+ Object backObject = JSONObject.toJSON(allResultDataObjectDetailDOS);
+ backString=Func.isEmpty(backObject)?"":backObject.toString();
+ }
+ }
+ catch (Throwable e){
+ e.printStackTrace();;
+ log.error("鏌ヨ澶辫触--->"+e);
+ success=false;
+ backString="鏌ヨ澶辫触--->"+e;
+ msg="鏌ヨ澶辫触--->"+e;
+ throw new VciBaseException(e.getMessage());
+ }finally {
+ try {
+ //璁板綍鏃ュ織
+ this.saveLogs(systemId, systemId, paramString, backString, success, msg, "queryData");
+ }catch (Throwable e){
+ e.printStackTrace();
+ log.error(e.getMessage());
+ throw new VciBaseException(e.getMessage());
+ }
+ }
+ }
+ }
+
+ /***
+ * 璁板綍鏃ュ織淇℃伅
+ * @param systemId
+ * @param parmaData
+ * @param result
+ * @return
+ */
+ private void saveLogs(String systemId,String systemName,String parmaData, String result,boolean isSucess,String msg,String operation){
+ //璁板綍鏃ュ織淇℃伅
+ DockingLog dockingLoge=new DockingLog();
+ //String oid=redisService.getUUIDEveryDay();
+ dockingLoge.setSystemCode(StringUtils.isBlank(systemId)?"-":systemId);//璁剧疆绯荤粺鏍囪瘑
+ dockingLoge.setSystemName(StringUtils.isBlank(systemName)?"-":systemName);
+ dockingLoge.setMsg(msg);//鏃ュ織娑堟伅
+ dockingLoge.setClassifyId("-");//鍒嗙被缂栧彿
+ dockingLoge.setClassifyName("-");//鍒嗙被鍚嶇О
+ dockingLoge.setClassifyOid("-");//鍒嗙被涓婚敭
+ dockingLoge.setUniqueCode("-");//鍞竴鏍囪瘑
+ dockingLoge.setSystemOid("-");//绯荤粺鏍囪瘑
+// dockingLogeDO.setName(operation);
+ //dockingLogeDO.setOid(oid);//鏃ュ織涓婚敭
+ dockingLoge.setParamString(parmaData);//鍙傛暟淇℃伅
+ dockingLoge.setReturnString(result);//杩斿洖淇℃伅
+ dockingLoge.setType(operation);//鏃ュ織鎿嶄綔绫诲瀷
+ dockingLoge.setCreateTime(new Date());
+ if(isSucess) {
+ dockingLoge.setInterfaceStatus("true");//鎺ュ彛闆嗘垚鐘舵��
+ }else{
+ dockingLoge.setInterfaceStatus("false");//鎺ュ彛闆嗘垚鐘舵��
+ }
+ dockingLogeService.save(dockingLoge);
+ log.info("闆嗘垚鎺ㄩ�佹暟鎹垚鍔�,systemId:"+systemId+",systemname:"+systemName+",operation:"+operation+",param:"+parmaData);
+ }
+
+ /***
+ * 鏍规嵁浼犲叆鐨勫弬鏁颁俊鎭牎楠岀爜娈佃鍒�
+ */
+ private List<CodeOrderSecDTO> getRuleCodeOrderSecDTOs(List<SectionVO> SectionVOList, CodeRuleVO ruleVO, CodeClassifyFullInfoBO classifyFullInfo) throws Throwable{
+ List<CodeBasicSecVO> codeBasicSecVOS= ruleVO.getSecVOList();
+ Map<String,String> sectionVOMap=new HashMap<>();
+ SectionVOList.stream().forEach(SectionVO->{
+ sectionVOMap.put(SectionVO.getName(),SectionVO.getValue());
+ });
+ //Map<String,CodeClassifyVO> codeClassifyVOMap= classifyFullInfo.getParentClassifyVOs().stream().collect(Collectors.toMap(s -> s.getId(), t -> t,(o1, o2)->o2));
+ List<CodeOrderSecDTO> codeOrderSecDTOList=new ArrayList<>();
+ Map<String,String> errorMap=new HashMap<>();
+ for(CodeBasicSecVO codeBasicSecVO: codeBasicSecVOS) {
+ String sectype = codeBasicSecVO.getSecType();
+ String newSecName=codeBasicSecVO.getName();
+ String classifySecOid= codeBasicSecVO.getOid();
+ String message="";
+ if (!sectype.equals(CodeSecTypeEnum.CODE_SERIAL_SEC.getValue())) {
+ String name = codeBasicSecVO.getName();
+ String sectypeText = codeBasicSecVO.getSecTypeText();
+ log.info("鐮佹鍚嶇О:"+name);
+ log.info("鎻忚堪:"+sectypeText);
+ CodeOrderSecDTO CodeOrderSecDTO = new CodeOrderSecDTO();
+ if (sectionVOMap.containsKey(name)) {
+ CodeOrderSecDTO.setSecOid(codeBasicSecVO.getOid());
+ String sectypeValue = sectionVOMap.get(name);
+ log.info("鐮佹鍊�:"+sectypeValue);
+ CodeSecTypeEnum secType = CodeSecTypeEnum.forValue(sectype);
+ if(CODE_CLASSIFY_SEC.equals(secType)) {//濡傛灉鏄垎绫荤殑璇濓紝鍒欓渶瑕佸尮閰嶄紶杩囨潵鐨勫垎绫讳唬鍙蜂笌
+ //鍏堢畝绉版槸鍚︽湁鍏宠仈妯℃澘锛屾湁妯℃澘瑕佸厛鍒犻櫎
+ List<CodeClassifyValue> codeClassifyValueDOList = codeClassifyValueService.list(Wrappers.<CodeClassifyValue>query().lambda().eq(CodeClassifyValue::getCodeClassifySecOid,classifySecOid));
+
+ if (!CollectionUtils.isEmpty(codeClassifyValueDOList)) {
+ Map<String, CodeClassifyValue> codeClassifyValueDOMap = codeClassifyValueDOList.stream().collect(Collectors.toMap(s -> s.getId(), t -> t, (o1, o2) -> o2));
+ if(codeClassifyValueDOMap.containsKey(sectypeValue)){
+ CodeClassifyValue codeClassifyValue= codeClassifyValueDOMap.get(sectypeValue);
+ sectypeValue=codeClassifyValue.getOid();
+ }else {
+ //throw new Throwable("浼犲叆鐨勫垎绫荤爜娈碉細銆�" + name + " 鍊硷細" + sectypeValue + "銆戯紝涓嶇鍚堝綋鍓嶅垎绫诲眰绾т唬鍙�");
+ message="浼犲叆鐨勫垎绫荤爜娈碉細銆�" + name + " 鍊硷細" + sectypeValue + "銆戯紝涓嶇鍚堝綋鍓嶅垎绫诲眰绾т唬鍙�";
+ errorMap.put("error",errorMap.getOrDefault("error","")+";"+message);
+ }
+ }
+ }
+ if(StringUtils.isBlank(sectypeValue)){
+ message="浼犲叆鐨勫垎绫荤爜娈碉細銆�" + name + " 銆戠殑鍊间笉鍏佽涓虹┖";
+ errorMap.put("error",errorMap.getOrDefault("error","")+";"+message);
+ }
+ CodeOrderSecDTO.setSecValue(sectypeValue);
+ codeOrderSecDTOList.add(CodeOrderSecDTO);
+ } else {
+ message="浼犲叆鐨勭爜娈佃鍒欑己灏�" + name;
+ errorMap.put("error",errorMap.getOrDefault("error","")+";"+message);
+ }
+ }
+ }
+ if(errorMap.size()>0){
+ throw new Throwable(errorMap.getOrDefault("error",""));
+ }
+ return codeOrderSecDTOList;
+ }
+ /***
+ * 璇诲彇灞炴�ф槧灏勯厤缃俊鎭�
+ * @param systemId
+ * @param libray
+ * @param applyDatasVO
+ * @param codeClassifyTemplateAttrVOList
+ * @param dataObjectVO
+ * @throws Throwable
+ */
+ public void getConfigDatas(String systemId,String libray, ApplyDatasVO applyDatasVO,List<CodeClassifyTemplateAttrVO> codeClassifyTemplateAttrVOList,DataObjectVO dataObjectVO) throws Throwable {
+
+ LinkedHashMap<String,LinkedHashMap<String,String>> dataKeyValueMap=new LinkedHashMap<>();
+ //濡傛灉灏嗘暟鎹浆鎹㈡垚鎵�闇�瑕佺殑鏁版嵁瀵硅薄
+ Map<String, String> attrMapConfigMap=new HashMap<>();
+ Map<String, String> propMaps=new HashMap<>();
+ log.info("寮�濮嬭鍙栫郴缁熼厤缃枃浠� start");
+ Map<String, String> stringStringMap=attributeMapConfig.getSystem_attrmap();
+ log.info("闆嗘垚绯荤粺灞炴�ф槧灏勯厤缃枃浠舵潯鐩暟-銆�"+stringStringMap.size());
+ //stringStringMap.put("RLM","D:\\RLM.xml");
+ if(!CollectionUtils.isEmpty(stringStringMap)) {
+ List<LibraryClsfDO> libraryClsfDOList=new ArrayList<>();
+ try {
+ log.info("info锛氶渶瑕佽鍙栭厤缃枃浠�");
+ LibraryDO libraryDO = gennerAttrMapUtil.getNewInstance().gennerAttrMapBySystem(systemId, stringStringMap);
+ libraryClsfDOList = libraryDO.getClsf();
+ } catch (Throwable e) {
+ e.printStackTrace();
+ throw new Throwable("闆嗘垚绯荤粺鏍囪瘑涓猴細銆�" + systemId + "銆戯紝鍒嗙被搴撲负:銆�" + libray + "銆戠殑闆嗘垚灞炴�ч厤缃枃浠惰鍙栧け璐�");
+ }
+ String path = stringStringMap.get(systemId);
+ if (!CollectionUtils.isEmpty(libraryClsfDOList)) {
+ Map<String, List<ClsfAttrMappingDO>> libPropMaps = libraryClsfDOList.stream().collect(Collectors.toMap(LibraryClsfDO::getLibrary, LibraryClsfDO::getProp, (key1, key2) -> key2));
+ log.info("鏍规嵁鍙傛暟锛歭ibray锛�-銆�" + libray + "浠庨厤缃枃浠朵腑鎵惧搴斿睘鎬ф槧灏勯厤缃�");
+ if (libPropMaps.containsKey(libray.toUpperCase(Locale.ROOT))) {
+ log.info("鏍规嵁鍙傛暟锛歭ibray锛�-銆�" + libray + "鍖归厤鍒扮浉搴旂殑灞炴�ф槧灏勪俊鎭�");
+ List<ClsfAttrMappingDO> clsfAttrMappingDOList = libPropMaps.get(libray.toUpperCase(Locale.ROOT));
+ propMaps = clsfAttrMappingDOList.stream().collect(Collectors.toMap(ClsfAttrMappingDO::getSourceKey, ClsfAttrMappingDO::getTargetKey, (key1, key2) -> key2));
+ log.info("鏍规嵁鍙傛暟锛歭ibray锛�-銆�" + libray + "鍖归厤鍒扮浉搴旂殑灞炴�ф槧灏勪俊鎭�,灞炴�ф槧灏勬潯鐩暟+" + clsfAttrMappingDOList.size());
+ } else {
+ throw new Throwable("鏍规嵁绯荤粺鏍囪瘑銆�" + systemId + "銆戞壘鍒板搴旂殑閰嶇疆鏂囦欢:銆�" + path + "銆戯紝浣嗘湭鑾峰彇鍒板搴旂殑搴撱��" + libray + "銆戝睘鎬ф槧灏勪俊鎭厤缃�");
+ }
+ }else{
+ throw new Throwable("鏍规嵁绯荤粺鏍囪瘑銆�" + systemId + "銆戞壘鍒板搴旂殑閰嶇疆鏂囦欢:銆�" + path + "銆戯紝浣嗘湭鑾峰彇鍒板搴旂殑搴撱��" + libray + "銆戝睘鎬ф槧灏勪俊鎭厤缃�");
+ }
+ }else{
+ throw new Throwable("鏈幏鍙栧埌闆嗘垚灞炴�ф槧灏勭郴缁熼厤缃俊鎭�");
+ }
+ log.info("鏍规嵁鍙傛暟锛歭ibray锛�-銆�"+libray+"浠庨厤缃枃浠朵腑鎵惧搴斿睘鎬ф槧灏勯厤缃� end ");
+ LinkedList<String> rowNameList=new LinkedList<>();
+ LinkedHashMap<String,Integer> filedIndexMap=new LinkedHashMap<>();
+ //鏍规嵁鍒嗙被妯℃澘缁勭粐鏁版嵁
+ final int[] index = {0};
+ try {
+ //闄ゅ幓榛樿鐨勫睘鎬�.杩樻湁鍙湁鍏锋湁鍒嗙被娉ㄥ叆鐨勬墠杩囨护鍑烘潵
+ codeClassifyTemplateAttrVOList = codeClassifyTemplateAttrVOList.stream().filter(
+ s ->!DEFAULT_SYNC_ATTR_LIST.contains(s.getId()) &&
+ ((Func.isNotEmpty(s.getClassifyInvokeAttr()) || Func.isNotEmpty(s.getClassifyInvokeAttrName())) || VciBaseUtil.getBoolean(s.getFormDisplayFlag()))
+ ).collect(Collectors.toList());
+ codeClassifyTemplateAttrVOList.stream().forEach(codeClassifyTemplateAttrVO -> {
+ String attrName = codeClassifyTemplateAttrVO.getName();
+ String field = codeClassifyTemplateAttrVO.getId();
+ rowNameList.add(attrName);
+ filedIndexMap.put(field, index[0]++);
+ });
+ dataObjectVO.setColName(rowNameList);//鏀惧叆灞炴��
+ attrMapConfigMap.putAll(propMaps);
+ LinkedList<RowDatas> rowDataList = new LinkedList<>();
+ List<ApplyDataVO> applyDataVOList=new ArrayList<>();
+
+ if(!CollectionUtils.isEmpty(applyDatasVO.getObject())){
+ applyDataVOList=applyDatasVO.getObject();
+ }
+ //Map<String, List<ProppertyVO>> dataPropMap = applyDataVOList.stream().collect(Collectors.toMap(ApplyDataVO::getId, ApplyDataVO::getProp, (key1, key2) -> key2));
+ final int[] rowIndex = {0};
+ applyDataVOList.stream().forEach(applyDataVO -> {
+ rowIndex[0]++;
+ RowDatas rowDatas = new RowDatas();
+ rowDatas.setOid(applyDataVO.getId());
+ rowDatas.setCreator(applyDataVO.getCreator());
+ rowDatas.setEditor(applyDataVO.getEditor());
+ rowDatas.setCode(applyDataVO.getCode());
+ rowDatas.setOperation(applyDataVO.getOperate());
+ rowDatas.setStatus(applyDataVO.getStatus());
+ rowDatas.setRowIndex(rowIndex[0] + "");
+ List<ProppertyVO> proppertyVOList = applyDataVO.getProp();
+
+ LinkedHashMap<Integer, String> integerValueMap = new LinkedHashMap<>();
+ Map<String, String> filedValueMap = new HashMap<>();
+ if (!CollectionUtils.isEmpty(proppertyVOList)) {
+ Map<String, String> sourceKeyValueMap = proppertyVOList.stream().collect(Collectors.toMap(ProppertyVO::getKey, ProppertyVO::getValue, (key1, key2) -> key2));
+ Map<String, String> keyValueMap = new HashMap<>();
+ //鍒ゆ柇attrMapConfigMap鏄惁鏈夊�硷紝濡傛灉娌℃湁鍒欒鏄庡熀纭�榛樿鐨勬槸缂栫爜绯荤粺瀛楁
+ if (!CollectionUtils.isEmpty(attrMapConfigMap)) {
+ sourceKeyValueMap.keySet().forEach(sourceKey -> {
+ String dataValue = sourceKeyValueMap.get(sourceKey);
+ if (attrMapConfigMap.containsKey(sourceKey)) {
+ String targetKey = attrMapConfigMap.get(sourceKey);
+ keyValueMap.put(targetKey, StringUtils.isBlank(dataValue)?"":dataValue);
+ }
+ });
+ } else {
+ sourceKeyValueMap.forEach((filed,value)->{
+ keyValueMap.put(filed,StringUtils.isBlank(value)?"":value) ;
+ });
+ }
+
+ filedIndexMap.forEach((attrKey, column) -> {
+ String keyValue = "";
+ if (keyValueMap.containsKey(attrKey)) {
+ keyValue =StringUtils.isBlank(keyValueMap.get(attrKey))?"":keyValueMap.get(attrKey);
+ }
+ integerValueMap.put(column, keyValue);
+ filedValueMap.put(attrKey, keyValue);
+ });
+ }
+ rowDatas.setData(integerValueMap);
+ rowDatas.setFiledValue(filedValueMap);
+ rowDataList.add(rowDatas);
+ });
+ dataObjectVO.setRowData(rowDataList);
+ }catch (Throwable e){
+ throw new Throwable("缁勭粐鏁版嵁鏄犲皠鍊煎け璐�");
+ }
+ }
+ private void changeObjectToMap(SearchItemDataVO searchItemDataVO, String code, BladeUser user,String operation,List<ApplyDataVO> object){
+ ApplyDataVO applyDataVO=new ApplyDataVO();
+ List<ProppertyVO> propList=new ArrayList<>();
+ //String status= searchItemDataVO.getStatus();//鏁版嵁鐘舵�� 瀛楃鍨嬶紝鏋氫妇鍊硷紱鍒跺崟锛�0锛涘鎵逛腑锛�1锛涢�氳繃锛�2锛涢┏鍥烇細3锛�
+
+ String mmodelCode=searchItemDataVO.getMmodelcode();//鍒堕�犲瀷鍙蜂唬鍙�
+ initProperty("mmodelcode","",mmodelCode,propList);
+ String projectCode= searchItemDataVO.getProjectcode();//椤圭洰缂栫爜
+ initProperty("projectcode","",projectCode,propList);
+ String projectItem=searchItemDataVO.getProjectitem();//椤圭洰浠e彿
+ initProperty("projectitem","",projectItem,propList);
+ String materialCode=searchItemDataVO.getMaterialcode();//浜у搧缂栫爜
+ initProperty("materialcode","",materialCode,propList);
+ //缁勫悎灞炴�х殑澶勭悊
+ initProperty(attrKey,"",StringUtils.isNotBlank(projectItem)?projectItem:mmodelCode,propList);
+ String creatBy=searchItemDataVO.getCreatby();//鍒涘缓鑰�
+ Date cretaeDon= searchItemDataVO.getCreatedon();//鍒涘缓鏃ユ湡 鏃ユ湡鍨嬶紝濡傦細2023-09-08 19:24:11
+ String lastchangeBy=searchItemDataVO.getLastchangedby();//鏇存敼鑰�
+ Date lastchangeDon=searchItemDataVO.getLastchangedon();//鏇存敼鏃堕棿 鏃ユ湡鍨嬶紝濡傦細2023-09-08 19:24:11
+ String isenabled= searchItemDataVO.getIsenabled();//瀛楃鍨嬶紝鏋氫妇鍊硷紱鍋滅敤锛�0锛涘惎鐢細1锛�
+ applyDataVO.setOperate(operation);
+ applyDataVO.setCode(code);
+ if(isenabled.equals("0")){
+ applyDataVO.setStatus(CodeDefaultLC.DISABLE.getValue());
+ }else{
+ applyDataVO.setStatus(CodeDefaultLC.RELEASED.getValue());
+ }
+ applyDataVO.setId(VciBaseUtil.getPk());
+ applyDataVO.setEditor(lastchangeBy);
+ applyDataVO.setCreator(creatBy);
+ applyDataVO.setProp(propList);
+ object.add(applyDataVO);
+ }
+ private void initProperty(String key,String text,String value,List<ProppertyVO> propList){
+ ProppertyVO vo=new ProppertyVO();
+ vo.setKey(key);
+ vo.setText(text);
+ vo.setValue(value);
+ propList.add(vo);
+ }
/***
* 鏌ヨredis涓暟鎹紝瀵规瘮鍚庢彃鍏ockingtask
* @param type
--
Gitblit v1.9.3