From 8238e7215367e39de004c29244d2597bb1e5519b Mon Sep 17 00:00:00 2001 From: xiejun <xiejun@vci-tech.com> Date: 星期二, 23 一月 2024 10:13:16 +0800 Subject: [PATCH] 集团码申请接口调试 --- Source/UBCS/ubcs-service-api/ubcs-applyjtcodeservice-api/src/main/java/com/vci/ubcs/code/applyjtcodeservice/vo/DockingMainData.java | 5 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/Scheduling/SearchDataSyncForERPScheduling.java | 59 ++++++++ Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/pagemodel/SearchItemVO.java | 19 ++ Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/feign/MdmSearchItemCodeProvider.java | 28 ++++ Source/UBCS/ubcs-service/ubcs-applyjtcodeservice/src/main/java/com/vci/ubcs/code/applyjtcodeservice/service/impl/GroupMdmInterServiceImpl.java | 130 +++++++++++++----- Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeDuckingSyncServiceImpl.java | 96 +++++++++++++ Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeDuckingSyncService.java | 2 Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/pagemodel/SearchItemDataVO.java | 49 +++++++ Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/pagemodel/SearchItemParam.java | 24 +++ 9 files changed, 370 insertions(+), 42 deletions(-) diff --git a/Source/UBCS/ubcs-service-api/ubcs-applyjtcodeservice-api/src/main/java/com/vci/ubcs/code/applyjtcodeservice/vo/DockingMainData.java b/Source/UBCS/ubcs-service-api/ubcs-applyjtcodeservice-api/src/main/java/com/vci/ubcs/code/applyjtcodeservice/vo/DockingMainData.java index 9415317..e8ffe25 100644 --- a/Source/UBCS/ubcs-service-api/ubcs-applyjtcodeservice-api/src/main/java/com/vci/ubcs/code/applyjtcodeservice/vo/DockingMainData.java +++ b/Source/UBCS/ubcs-service-api/ubcs-applyjtcodeservice-api/src/main/java/com/vci/ubcs/code/applyjtcodeservice/vo/DockingMainData.java @@ -28,6 +28,10 @@ */ private String className; /*** + * 闆嗗洟鐮� + */ + private String customCoding; + /*** * 妯″瀷瑙嗗浘淇℃伅 */ private List<DockingViewVO> viewInfos; @@ -41,6 +45,7 @@ ", createBy='" + createBy + '\'' + ", className='" + className + '\'' + ", viewInfos=" + viewInfos + + ", customCoding=" + customCoding + '}'; } } diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/feign/MdmSearchItemCodeProvider.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/feign/MdmSearchItemCodeProvider.java new file mode 100644 index 0000000..6eb55d2 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/feign/MdmSearchItemCodeProvider.java @@ -0,0 +1,28 @@ +package com.vci.ubcs.code.feign; + +import com.vci.ubcs.code.vo.pagemodel.SearchItemParam; +import com.vci.ubcs.code.vo.pagemodel.SearchItemVO; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +import javax.validation.constraints.NotNull; + +/**** + * 浠庡閮ㄨ幏鍙栧瀷鍙蜂唬鍙凤紝鎴栬�呴」鐩唬鍙� + * @author xiejun + * @date 2023-05-26 + */ +@FeignClient(name = "erpIntegration", + url = "${erp.item.url:http://127.0.0.1:8080}", + path = "") +public interface MdmSearchItemCodeProvider { + + /*** + * 鏌ヨ椤圭洰浠e彿鎴栬�呭瀷鍙蜂唬鍙� + * @param searchItemParam + * @return 鎵ц缁撴灉 + */ + @PostMapping("/api/pp/pp/ext/extend/v1.0/getppModelByElem") + SearchItemVO getppModelByElem(@NotNull @RequestBody SearchItemParam searchItemParam); +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/pagemodel/SearchItemDataVO.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/pagemodel/SearchItemDataVO.java new file mode 100644 index 0000000..e5c434e --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/pagemodel/SearchItemDataVO.java @@ -0,0 +1,49 @@ +package com.vci.ubcs.code.vo.pagemodel; + +import lombok.Data; + +import java.util.Date; + +@Data +public class SearchItemDataVO { + /*** + * 鏁版嵁鐘舵�� 瀛楃鍨嬶紝鏋氫妇鍊硷紱鍒跺崟锛�0锛涘鎵逛腑锛�1锛涢�氳繃锛�2锛涢┏鍥烇細3锛� + */ + private String status; + /** + * 鍒堕�犲瀷鍙蜂唬鍙� + */ + private String mmodelcode; + /** + * 椤圭洰浠e彿 + */ + private String projectitem; + /*** + * 椤圭洰缂栫爜 + */ + private String projectcode; + /*** + * 浜у搧缂栫爜 + */ + private String materialcode; + /*** + * 鍒涘缓鑰� + */ + private String creatby; + /*** + * 鍒涘缓鏃ユ湡 鏃ユ湡鍨嬶紝濡傦細2023-09-08 19:24:11 + */ + private Date createdon; + /*** + * 鏇存敼鑰� + */ + private String lastchangedby; + /*** + * 鏇存敼鏃堕棿 鏃ユ湡鍨嬶紝濡傦細2023-09-08 19:24:11 + */ + private Date lastchangedon; + /*** + * 瀛楃鍨嬶紝鏋氫妇鍊硷紱鍋滅敤锛�0锛涘惎鐢細1锛� + */ + private String isenabled; +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/pagemodel/SearchItemParam.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/pagemodel/SearchItemParam.java new file mode 100644 index 0000000..bcf4e58 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/pagemodel/SearchItemParam.java @@ -0,0 +1,24 @@ +package com.vci.ubcs.code.vo.pagemodel; + +import lombok.Data; + +import java.util.Date; +@Data +public class SearchItemParam { + /*** + * 璋冪敤绯荤粺鏍囪瘑 + */ + private String systag; + /** + * 鏁版嵁鐘舵�� + */ + private String status; + /** + * 鏄惁鍋滅敤 + */ + private String isenabled; + /** + * 鏈�鍚庝慨鏀规棩鏈� + */ + private Date lastchangedon; +} diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/pagemodel/SearchItemVO.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/pagemodel/SearchItemVO.java new file mode 100644 index 0000000..8a4d891 --- /dev/null +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/code/vo/pagemodel/SearchItemVO.java @@ -0,0 +1,19 @@ +package com.vci.ubcs.code.vo.pagemodel; + +import lombok.Data; + +import java.util.List; + +@Data +public class SearchItemVO { + /*** + * 杩斿洖鏍囪瘑 + */ + private String code; + /*** + * 娑堟伅淇℃伅 + */ + private String msg; + + private List<SearchItemDataVO> data; +} diff --git a/Source/UBCS/ubcs-service/ubcs-applyjtcodeservice/src/main/java/com/vci/ubcs/code/applyjtcodeservice/service/impl/GroupMdmInterServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-applyjtcodeservice/src/main/java/com/vci/ubcs/code/applyjtcodeservice/service/impl/GroupMdmInterServiceImpl.java index a2775b8..7267079 100644 --- a/Source/UBCS/ubcs-service/ubcs-applyjtcodeservice/src/main/java/com/vci/ubcs/code/applyjtcodeservice/service/impl/GroupMdmInterServiceImpl.java +++ b/Source/UBCS/ubcs-service/ubcs-applyjtcodeservice/src/main/java/com/vci/ubcs/code/applyjtcodeservice/service/impl/GroupMdmInterServiceImpl.java @@ -1,5 +1,6 @@ package com.vci.ubcs.code.applyjtcodeservice.service.impl; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -10,6 +11,8 @@ import com.vci.ubcs.code.applyjtcodeservice.service.IGroupMdmInterService; import com.vci.ubcs.code.applyjtcodeservice.vo.*; import com.vci.ubcs.code.vo.pagemodel.CodeClassifyTemplateAttrVO; +import com.vci.ubcs.code.vo.webserviceModel.apply.ApplyDataVO; +import com.vci.ubcs.code.vo.webserviceModel.apply.InterParameterVO; import com.vci.ubcs.code.vo.webserviceModel.result.xml.XMLResultDataObjectDetailDO; import com.vci.ubcs.starter.util.MdmBtmTypeConstant; import com.vci.ubcs.code.applyjtcodeservice.feign.MdmApplyGroupCodeProvider; @@ -22,6 +25,7 @@ import org.apache.commons.collections4.map.CaseInsensitiveMap; 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.stereotype.Service; @@ -44,11 +48,11 @@ private String code=""; private String msg=""; - @Value("${docking.apply.partCoe:10}") + @Value("${docking.apply.partCode:101}") public String partCoe; @Value("${docking.apply.usedFlag:false}") public boolean usedFlag; - @Value("${docking.apply.unitCode:41000}") + @Value("${docking.apply.unitCode:4100}") public String dockingApplyUnitCode; @Value("${docking.apply.sysName:410-MDM}") @@ -120,18 +124,33 @@ Map<String, DockingPreApplyForm> addDockingPreApplyFormMap = new HashMap<String, DockingPreApplyForm>(); Map<String, DockingPreApplyForm> editDockingPreApplyFormMap = new HashMap<String, DockingPreApplyForm>(); Map<String, BaseModel> baseModelMap = new HashMap<String, BaseModel>(); + //鏁版嵁搴撲笉瀛樺湪鐨� + /*List<BaseModel> newDdataModelList = dataModelList.stream().filter(cbo -> { + String groupcode =cbo.getData().getOrDefault("GROUPCODE",""); + return StringUtils.isBlank(groupcode); + }).collect(Collectors.toList()); + if(newDdataModelList.size()==0) + return R.fail("鐢宠鎺ュ彛璋冪敤鎴愬姛,鎵�鏈夋暟鎹凡缁忓瓨鍦ㄩ泦鍥㈢爜");*/ + //缁勭粐鏁版嵁 dockingGroupDataVO = queryApplycodeDataObjects(1, dataModelList, addDockingPreApplyFormMap, editDockingPreApplyFormMap, baseModelMap); - DockingResultVO resultDataObject = mdmApplyGroupCodeProvider.receiveAddApply(dockingGroupDataVO); + Object object = JSONObject.toJSON(dockingGroupDataVO); + String resultStr = object.toString(); + log.info("鐢宠闆嗗洟鐮佹暟鎹牸寮�:->"+resultStr); + DockingResultVO resultDataObject =new DockingResultVO(); + resultDataObject= mdmApplyGroupCodeProvider.receiveAddApply(dockingGroupDataVO); code = resultDataObject.getCode(); msg = resultDataObject.getMsg(); + boolean res=false; if ("1".equals(resultDataObject.getCode())) {//缁撴灉姝g‘鐨勬儏鍐� List<DockingDataVO> dataObjectVOList = resultDataObject.getData(); + res=true; dataObjectVOList.stream().forEach(dataObject -> { boolean isEditDatas = false; String code2 = dataObject.getCode(); DockingMainDataVO data2 = dataObject.getData(); String applyId = data2.getApplyId();//鐢宠鍗昳d + BaseModel baseModel = baseModelMap.get(applyId); String customCoding = StringUtils.isBlank(data2.getCustomCoding()) ? "" : data2.getCustomCoding();//闆嗗洟鐮佹 msg = dataObject.getMsg(); if (code2.equals("1")) {//缁撴灉姝g‘鐨勬儏鍐� @@ -143,8 +162,16 @@ if (editDockingPreApplyFormMap.containsKey(applyId)) { DockingPreApplyForm dockingPreApplyForm = editDockingPreApplyFormMap.get(applyId); dockingPreApplyForm.setCode(code2); + //dockingPreApplyForm.setDescription(baseModel.getId()); dockingPreApplyForm.setMsg("鐢宠锛�" + msg); - dockingPreApplyForm.setGroupCode(customCoding); + if(StringUtils.isBlank(dockingPreApplyForm.getGroupCode())) { + dockingPreApplyForm.setGroupCode(customCoding); + }else{ + isEditDatas = true; + if (StringUtils.isBlank(customCoding)) { + customCoding=dockingPreApplyForm.getGroupCode(); + } + } ObjectMapper mp = new ObjectMapper(); String writeValueAsString = null; try { @@ -152,11 +179,13 @@ dockingPreApplyForm.setContent(writeValueAsString); } catch (JsonProcessingException e) { } + DefaultAttrAssimtUtil.updateDefaultAttrAssimt(dockingPreApplyForm); } //鏂板鐨勭敵璇峰崟鏁版嵁 if (addDockingPreApplyFormMap.containsKey(applyId)) { DockingPreApplyForm dockingPreApplyForm = addDockingPreApplyFormMap.get(applyId); dockingPreApplyForm.setCode(code2); + dockingPreApplyForm.setDescription(baseModel.getId()); dockingPreApplyForm.setMsg("鐢宠锛�" + msg); dockingPreApplyForm.setGroupCode(customCoding); ObjectMapper mp = new ObjectMapper(); @@ -166,25 +195,28 @@ dockingPreApplyForm.setContent(writeValueAsString); } catch (JsonProcessingException e) { } + DefaultAttrAssimtUtil.addDefaultAttrAssimt(dockingPreApplyForm, MdmBtmTypeConstant.DOCKING_PRE_JAPPLYFORM); } //濡傛灉鏈夐泦鍥㈢爜鍒欐洿鏂版暟鎹� if (isEditDatas) { if (baseModelMap.containsKey(applyId)) { - BaseModel baseModel = baseModelMap.get(applyId); - String classOid=baseModel.getData().getOrDefault("CODECLSFID",""); + baseModel = baseModelMap.get(applyId); + Map<String,String> dataValueMap=new CaseInsensitiveMap<>(baseModel.getData()); + String classOid=dataValueMap.getOrDefault("CODECLSFID",""); if(partCoe.equals(classOid)){ baseModel.setId(10+customCoding); + customCoding=10+customCoding; } BeanUtilForVCI.copyDeclaredIgnoreCase(baseModel, baseModel); DefaultAttrAssimtUtil.updateDefaultAttrAssimt(baseModel); - DefaultAttrAssimtUtil.updateDefaultAttrAssimt(baseModel); - - baseModel.getData().getOrDefault("groupCode", customCoding); + // DefaultAttrAssimtUtil.updateDefaultAttrAssimt(baseModel); + baseModel.getData().put("GROUPCODE",customCoding); updateCbos.add(baseModel);//鏇存柊鏁版嵁闆嗗洟code } } }); } else { + res=false; editDockingPreApplyFormMap.forEach((key, dockingPreApplyForm) -> { dockingPreApplyForm.setCode("2"); dockingPreApplyForm.setMsg("鐢宠锛�" + msg); @@ -209,6 +241,9 @@ //淇濆瓨琛ㄥ崟鏁版嵁 dockingPreApplyFormService.saveOrUpdateBatch(dockingPreAttrMappings); mdmEngineClient.updateBatchBtypeDatas(btmName, updateCbos);//淇濆瓨鏁版嵁 + if(!res){ + throw new VciBaseException(msg); + } } return R.success("鐢宠鎺ュ彛璋冪敤鎴愬姛"); } catch (VciBaseException e) { @@ -274,7 +309,9 @@ DockingPreApplyForm dockingPreApplyForm = editDockingPreApplyFormMap.get(applyId); dockingPreApplyForm.setCode(code2); dockingPreApplyForm.setMsg("淇敼锛�" + msg); - dockingPreApplyForm.setGroupCode(customCoding); + if(StringUtils.isBlank(dockingPreApplyForm.getGroupCode())) { + dockingPreApplyForm.setGroupCode(customCoding); + } ObjectMapper mp = new ObjectMapper(); String writeValueAsString = null; try { @@ -282,13 +319,16 @@ dockingPreApplyForm.setContent(writeValueAsString); } catch (JsonProcessingException e) { } + DefaultAttrAssimtUtil.updateDefaultAttrAssimt(dockingPreApplyForm); } //鏂板鐨勭敵璇峰崟鏁版嵁 if (addDockingPreApplyFormMap.containsKey(applyId)) { DockingPreApplyForm dockingPreApplyForm = addDockingPreApplyFormMap.get(applyId); dockingPreApplyForm.setCode(code2); dockingPreApplyForm.setMsg("淇敼锛�" + msg); - dockingPreApplyForm.setGroupCode(customCoding); + if(StringUtils.isBlank(dockingPreApplyForm.getGroupCode())) { + dockingPreApplyForm.setGroupCode(customCoding); + } ObjectMapper mp = new ObjectMapper(); String writeValueAsString = null; try { @@ -296,6 +336,7 @@ dockingPreApplyForm.setContent(writeValueAsString); } catch (JsonProcessingException e) { } + DefaultAttrAssimtUtil.addDefaultAttrAssimt(dockingPreApplyForm, MdmBtmTypeConstant.DOCKING_PRE_JAPPLYFORM); } //濡傛灉鏈夐泦鍥㈢爜鍒欐洿鏂版暟鎹� if (isEditDatas) { @@ -308,7 +349,7 @@ } DefaultAttrAssimtUtil.updateDefaultAttrAssimt(baseModel); // baseModel.setId(customCoding); - baseModel.getData().put("groupCode", customCoding); + baseModel.getData().put("GROUPCODE", customCoding); updateCbos.add(baseModel);//鏇存柊鏁版嵁闆嗗洟code } } @@ -519,8 +560,9 @@ int code=dockingApplyFormQueryStatusVO.getCode(); String mesg=dockingApplyFormQueryStatusVO.getMsg(); if(code==1){ + message=mesg; List<DockingApplyFormStatusVO> dockingApplyFormStatusVOList=dockingApplyFormQueryStatusVO.getData(); - if(CollectionUtils.isEmpty(dockingApplyFormStatusVOList)){ + if(!CollectionUtils.isEmpty(dockingApplyFormStatusVOList)){ for (DockingApplyFormStatusVO applyFormDataState : dockingApplyFormStatusVOList) { String applyId=applyFormDataState.getApplyNum(); String state= applyFormDataState.getFormState(); @@ -532,20 +574,23 @@ } } boolean res=this.dockingPreApplyFormService.saveOrUpdateBatch(dockingPreApplyFormList); - if(res){ - R.success("鐢宠闆嗗洟鐮佺姸鎬佹煡璇㈡垚鍔�:"+mesg); - } }else{ throw new Throwable("娌℃湁鑾峰彇鍒扮浉鍏虫暟鎹俊鎭�"); } }else{ - throw new Throwable(mesg); + message=mesg; + dockingPreApplyFormList.stream().forEach(dockingPreApplyForm -> { + dockingPreApplyForm.setMsg("鐢宠鍗曟煡鐪嬪け璐ワ細"+mesg); + }); + this.dockingPreApplyFormService.saveOrUpdateBatch(dockingPreApplyFormList); + throw new Throwable(message); } }catch (Throwable e){ e.printStackTrace(); + //message=""+e; log.error("鑾峰彇鐢宠鍗曠姸鎬佸け璐�"+e); - throw new VciBaseException(message); + throw new VciBaseException(e.getMessage()); } log.info("鏌ヨ鐢宠鍗曠姸鎬佹帴鍙nd"); return R.success(message); @@ -609,6 +654,7 @@ log.info("classify:-------------->閾炬帴鍚嶇О:"+nodeLinkName); if (dockingPreClassify == null || StringUtils.isBlank(dockingPreClassify.getOid())) { + dockingPreClassify=new DockingPreClassify(); DefaultAttrAssimtUtil.addDefaultAttrAssimt(dockingPreClassify,MdmBtmTypeConstant.DOCKING_PRE_JCLASSIFY); } else { DefaultAttrAssimtUtil.updateDefaultAttrAssimt(dockingPreClassify); @@ -704,7 +750,7 @@ .eq(DockingPreMetaAttr::getSourceClassifyId,jclassId).eq(DockingPreMetaAttr::getViewModelId,jviewModelObject.getOid()) .eq(DockingPreMetaAttr:: getPid,pid)); Map<String,DockingPreMetaAttr> jmetaattrMap = dockingPreMetaAttrList.stream().filter( - s -> com.alibaba.cloud.commons.lang.StringUtils.isNotBlank(s.getEnglishName())).collect(Collectors.toMap(s -> s.getEnglishName().toLowerCase(Locale.ROOT), t -> t)); + s -> com.alibaba.cloud.commons.lang.StringUtils.isNotBlank(s.getEnglishName())).collect(Collectors.toMap(s -> s.getEnglishName(), t -> t)); for (DockingClassifyMetaAttrVO dockingClassifyMetaAttrVO : metaList) { String chineseName = com.alibaba.cloud.commons.lang.StringUtils.isBlank(dockingClassifyMetaAttrVO.getChineseName())?"":dockingClassifyMetaAttrVO.getChineseName();// 灞炴�у悕绉� @@ -773,6 +819,7 @@ */ private void getRange(DockingPreMetaAttr metaAttrObject,Map<String, String> range) throws Throwable { String metaAttrOid = com.alibaba.cloud.commons.lang.StringUtils.isBlank(metaAttrObject.getOid())?"":metaAttrObject.getOid();// 灞炴�х殑oid + String jchinesename = com.alibaba.cloud.commons.lang.StringUtils.isBlank(metaAttrObject.getChineseName())?"":metaAttrObject.getChineseName(); Map<String, DockingPreAttrRange> rangeMap = new HashMap<>(); try { @@ -780,7 +827,9 @@ condtionMa.put("jmetalistid", metaAttrOid); List<DockingPreAttrRange> jmetaattrList = dockingPreAttrRangeService.selectByWrapper(Wrappers.<DockingPreAttrRange>query().lambda() .eq(DockingPreAttrRange::getMetaListId,metaAttrOid));// 鏍规嵁鍒嗙被鏌ヨ妯″瀷瑙嗗浘瀵硅薄 - rangeMap= jmetaattrList.stream().collect(Collectors.toMap(s -> com.alibaba.cloud.commons.lang.StringUtils.isNotBlank(s.getNumText().toLowerCase(Locale.ROOT))?"":s.getNumText().toLowerCase(Locale.ROOT), t -> t)); + log.info("鑾峰彇灞炴�х編鍓� 灞炴�d------->"+metaAttrOid); + //rangeMap= jmetaattrList.stream().collect(Collectors.toMap(s ->StringUtils.isNotBlank(s.getNumText())?"":s.getNumText(), t -> t)); + rangeMap=jmetaattrList.stream().filter(data -> data != null && StringUtils.isNotBlank(data.getNumText())).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getNumText(), t -> t)); for (String rangeKey : range.keySet()) { DockingPreAttrRange rangeObject = new DockingPreAttrRange(); @@ -810,44 +859,42 @@ } } - - - /** * 缁勭粐鏁版嵁 * */ private DockingGroupDataVO queryApplycodeDataObjects(int optationtype,List<BaseModel> codeWupins,Map<String,DockingPreApplyForm> addDockingPreApplyFormMap,Map<String,DockingPreApplyForm> editDockingPreApplyFormMap,Map<String,BaseModel> codeWupinMap) throws VciBaseException{ try { - String curUserName = AuthUtil.getUser().getUserName(); + String curUserName ="28201728"; //AuthUtil.getUser().getUserName(); //鐢宠鐨勬暟鎹� List<DockingMainData> mainDataList=new ArrayList<DockingMainData>(); for (BaseModel dataBusinessObject : codeWupins) { String format = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date()); - Map<String,String> dataValueMap=new CaseInsensitiveMap<>(dataBusinessObject.getData()); - String codeclsfid =dataValueMap.getOrDefault("codeclsfid",""); + //String codeclsfid = dataBusinessObject.getData().getOrDefault("codeclsfid".toUpperCase(Locale.ROOT),""); + Map<String,String> dataMap=new CaseInsensitiveMap<>(dataBusinessObject.getData()); + String codeclsfid=dataMap.getOrDefault("codeclsfid",""); String btmName = dataBusinessObject.getBtmname(); String oid = dataBusinessObject.getOid(); - DockingPreApplyForm dockingPreApplyForm = new DockingPreApplyForm(); String dataOid = dataBusinessObject.getOid(); Map<String, String> conditionsMap = new HashMap<String, String>(); - List<DockingPreApplyForm> applyFormObjects = dockingPreApplyFormService.list(Wrappers.<DockingPreApplyForm>query().lambda().eq(DockingPreApplyForm::getDataOid, dataOid).eq(DockingPreApplyForm::getOperationType, optationtype)); + //List<DockingPreApplyForm> applyFormObjects = dockingPreApplyFormService.list(Wrappers.<DockingPreApplyForm>query().lambda().eq(DockingPreApplyForm::getDataOid, dataOid).eq(DockingPreApplyForm::getOperationType, optationtype)); + // DockingPreApplyForm dockingPreApplyForm=new DockingPreApplyForm(); String apllyCode = ""; - if (!CollectionUtils.isEmpty(applyFormObjects)) { + /*if (!CollectionUtils.isEmpty(applyFormObjects)) { dockingPreApplyForm = applyFormObjects.get(0); apllyCode = dockingPreApplyForm.getId(); editDockingPreApplyFormMap.put(apllyCode, dockingPreApplyForm);//鐢宠鍗曞拰鐢宠鍗曞璞″叧绯� - } else { + } else {*/ apllyCode = dockingApplyUnitCode + "-" + format; dockingPreApplyForm.setId(apllyCode); dockingPreApplyForm.setName(""); dockingPreApplyForm.setOperationType(optationtype+""); - dockingPreApplyForm.setDescription(dataBusinessObject.getDescription());//鑾峰彇鏁版嵁鎻忚堪淇℃伅 + dockingPreApplyForm.setDescription(dataBusinessObject.getId());//鑾峰彇鏁版嵁鎻忚堪淇℃伅 dockingPreApplyForm.setDataOid(oid); dockingPreApplyForm.setDataBtmName(btmName); addDockingPreApplyFormMap.put(apllyCode, dockingPreApplyForm);//鐢宠鍗曞拰鐢宠鍗曞璞″叧绯� - } + // } codeWupinMap.put(apllyCode, dataBusinessObject);//鐢宠鍗曞拰瀵瑰簲鏁版嵁鍏崇郴 conditionsMap = new HashMap<String, String>(); @@ -865,6 +912,11 @@ mainData.setApplyId(apllyCode);//鐢宠鍗曞彿 mainData.setClassName(dockingPreClassify.getNodeLinkName());//鍒嗙被鍚嶇О mainData.setCreateBy(curUserName);// + if(optationtype==2) { + String groucode=dataBusinessObject.getData().getOrDefault("GROUPCODE",""); + dockingPreApplyForm.setGroupCode(groucode); + mainData.setCustomCoding(groucode); + } mainData.setSecretLevel("鍐呴儴");//瀵嗙骇锛岄粯璁や负鍐呴儴 mainData.setViewInfos(getviewInfos(optationtype,dockingPreClassify, dataBusinessObject));//鑾峰彇瑙嗗浘妯″瀷 mainDataList.add(mainData); @@ -919,7 +971,7 @@ //鏋勯�犳ā鍨嬭鍥炬暟鎹� List<Map<String, Object>> viewValueList=new ArrayList<Map<String,Object>>(); String oid = dockingPreViewModel.getOid(); - Map<String,String> dataValueMap=new CaseInsensitiveMap<>(dataBusinessObject.getData()); + Map<String,String> dataValueMap=new CaseInsensitiveMap<>(dataBusinessObject.getData()); String codeClassifyId=dataValueMap.get("codeclsfid"); Map<String,String>conditionsMap=new HashMap<String, String>(); List<DockingPreAttrMapping> dockingPreAttrMappingList = dockingPreAttrMappingMapper.selectList(Wrappers.<DockingPreAttrMapping>query().lambda() @@ -946,15 +998,15 @@ Object newVaue=null; if(StringUtils.isNotBlank(jtargetattrkey)){ getAttrRange(dockingPreMetaAttr);//鑾峰彇瀛楁鍙栧�艰寖鍥� - String value =""; + String value=""; if(jtargetattrkey.toLowerCase(Locale.ROOT).equals("name")){ value=dataBusinessObject.getName(); }else if(jtargetattrkey.toLowerCase(Locale.ROOT).equals("id")){ value=dataBusinessObject.getId(); }else if(jtargetattrkey.toLowerCase(Locale.ROOT).equals("description")){ value=dataBusinessObject.getDescription(); - }else { - value = dataValueMap.get(jtargetattrkey) == null ? "" : dataValueMap.getOrDefault(jtargetattrkey, ""); + }else{ + value=dataValueMap.get(jtargetattrkey)==null?"":dataValueMap.getOrDefault(jtargetattrkey,""); } newVaue = getVaue(dockingPreMetaAttr, value); }else{ @@ -963,9 +1015,11 @@ if(newVaue==null||"".equals(newVaue)){ newVaue= dockingPreMetaAttr.getDefaultValue(); } + //newVaue= Func.isNotEmpty(newVaue)?newVaue:""; viewValueMap.put(jenglishname, newVaue); } } + viewValueList.add(viewValueMap); return viewValueList; } @@ -1027,7 +1081,7 @@ return null; }else { try { - return simpleDateFormat.parse(value); + return simpleDateFormat.format(simpleDateFormat.parse(value)); } catch (ParseException e) { throw new VciBaseException("date", new String[]{"鏃ユ湡鏍煎紡杞崲閿欒"}); } @@ -1038,7 +1092,7 @@ return null; }else{ try { - return simpleDateFormat.parse(value); + return simpleDateFormat.format(simpleDateFormat.parse(value)); } catch (ParseException e) { throw new VciBaseException("date", new String[]{"鏃ユ湡鏍煎紡杞崲閿欒"}); } diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/Scheduling/SearchDataSyncForERPScheduling.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/Scheduling/SearchDataSyncForERPScheduling.java new file mode 100644 index 0000000..145f6aa --- /dev/null +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/Scheduling/SearchDataSyncForERPScheduling.java @@ -0,0 +1,59 @@ +package com.vci.ubcs.code.Scheduling; + +import com.vci.ubcs.code.service.ICodeDuckingSyncService; +import com.vci.ubcs.code.service.UniversalInterfaceI; +import com.vci.ubcs.starter.web.enumpck.BooleanEnum; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import javax.annotation.Resource; +import java.text.SimpleDateFormat; +import java.util.Date; + +/*** + * 闆嗘垚浠诲姟瀹氭椂鍣� + * 浠嶦RP鏌ヨ鍨嬪彿浠e彿,椤圭洰浠e彿 + * @author xj + * @date 2024-01-19 + */ +@Component +@Slf4j +public class SearchDataSyncForERPScheduling { + @Resource + private ICodeDuckingSyncService codeDuckingSyncServiceI; + + @Value("${erp.item.isStart:false}") + public boolean ERP_ITEM_ISSTARE; + + @Value("${erp.item.btmName:XHDH}") + public String ERP_ITEM_BTMNAME; + /** + * 鏄惁鍒濆鍖栧畬鎴愪簡 + */ + public static volatile String FINISH_INIT = "false"; + /** + * 鍦ㄥ垵濮嬪寲瀹屾垚鍚庢墽琛� + */ + @PostConstruct() + public void onInit(){ + FINISH_INIT = "true"; + } + + //榛樿姣忓崄鍒嗛挓鎵ц鏂规硶 + @Scheduled(cron = "${dataSyncPush.cronTime:0 0/10 * * * ?}") + public void scheduled() { + log.info("鎵ц浠嶦RP椤圭洰浠e彿/鍨嬪彿浠e彿鏁版嵁 start:"); + log.info("鎵ц涓绘暟鎹泦鎴愭暟鎹帹閫� end: "+ "寮�鍏虫槸鍚﹀紑鍚�:" +ERP_ITEM_ISSTARE); + if(ERP_ITEM_ISSTARE && BooleanEnum.TRUE.getValue().equalsIgnoreCase(FINISH_INIT)) { + SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss."); + String time = formatter.format(new Date()); + codeDuckingSyncServiceI.saveItemDataSyncScheduing(ERP_ITEM_BTMNAME); + String outInfo = "============ 鎵ц浜嗕粠ERP椤圭洰浠e彿/鍨嬪彿浠e彿鏁版嵁 end;"; + log.info(outInfo+time); + } + + } +} diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeDuckingSyncService.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeDuckingSyncService.java index 21f6d55..6762ec7 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeDuckingSyncService.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/ICodeDuckingSyncService.java @@ -47,5 +47,7 @@ * @return */ R sendData(String oids); + + void saveItemDataSyncScheduing(String btmName); } 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 56b35b8..e963093 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,6 +7,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.io.xml.DomDriver; +import com.vci.ubcs.code.applyjtcodeservice.feign.MdmApplyGroupCodeProvider; import com.vci.ubcs.code.constant.MdmDuckingConstant; import com.vci.ubcs.code.dto.datapush.classify.JsonRootDataDTO; import com.vci.ubcs.code.dto.datapush.classify.NodeClassifyDTO; @@ -21,19 +22,23 @@ import com.vci.ubcs.code.dto.datapush.result.ResultNodeObjectDTO; import com.vci.ubcs.code.entity.*; 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.vo.pagemodel.*; +import com.vci.ubcs.omd.feign.IBtmTypeClient; +import com.vci.ubcs.omd.vo.BtmTypeVO; 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.VciBaseUtil; import com.vci.ubcs.starter.web.util.WebUtil; import lombok.extern.slf4j.Slf4j; +import org.apache.poi.util.StringUtil; import org.springblade.core.redis.cache.BladeRedis; import org.springblade.core.tool.api.R; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -62,6 +67,20 @@ public String DATA_PARAM_NAME; @Value("${dataSyncPush.dataId:itemid}") private String itemId; + + @Value("${erp.item.attrKey:xhdh}") + public String attrKey; + + /** + * 涓氬姟绫诲瀷鐨勬湇鍔� + */ + @Autowired + private IBtmTypeClient btmTypeClient; + /** + * 閫氱敤鏌ヨ + */ + @Resource + private CommonsMapper commonsMapper; @Resource private MdmEngineService mdmEngineServiceI; @@ -84,7 +103,8 @@ private IDockingSysIntParamService dockingSysIntParamService; @Resource private IDockingSysIntHeaderService dockingSysIntHeaderService; - + @Autowired(required = false) + private MdmSearchItemCodeProvider mdmSearchItemCodeProvider; @Override @@ -149,6 +169,74 @@ return R.success("鎵嬪姩鎺ㄩ�佸畬鎴�,璇锋牳瀵规槸鍚︽帹閫佹垚鍔�"); } + /*** + * 鍚屾鍨嬪彿浠e彿 + */ + @Override + public void saveItemDataSyncScheduing(String btmName) { + SearchItemParam searchItemParam=new SearchItemParam(); + searchItemParam.setSystag("CODE"); //璋冪敤绯荤粺鏍囪瘑 + searchItemParam.setLastchangedon(new Date()); + searchItemParam.setStatus("1");// + SearchItemVO searchItemVO= mdmSearchItemCodeProvider.getppModelByElem(searchItemParam); + if(searchItemVO!=null) { + searchItemVO.getCode(); + searchItemVO.getMsg(); + List<CodeClassify> codeClassifyList = codeClassifyService.selectByWrapper(Wrappers.<CodeClassify>query().lambda().in(CodeClassify::getId, btmName)); + try { + if (CollectionUtils.isEmpty(codeClassifyList)) { + throw new Throwable("鍒嗙被鏈煡璇㈠埌"); + } + CodeClassify codeClassify= codeClassifyList.get(0); + List<SearchItemDataVO> dataList = searchItemVO.getData(); + Map<String, SearchItemDataVO> dataVOMap = new HashMap<>(); + List<String> itemCodeList = 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(btmName); + if (!r.isSuccess()) { + throw new Throwable(r.getMsg()); + } + BtmTypeVO btmTypeVO = r.getData(); + if (btmTypeVO == null) { + throw new Throwable("鏍规嵁涓氬姟绫诲瀷鏈煡璇㈠埌涓氬姟绫诲瀷瀵硅薄锛�"); + } + tableName = btmTypeVO.getTableName(); + if (com.alibaba.nacos.common.utils.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() + "'"); + List<Map<String, String>> newDataList = commonsMapper.queryByOnlySqlForMap(sb.toString()); + newDataList.stream().forEach(dataMap->{ + String value= dataMap.getOrDefault(attrKey,""); + if(dataVOMap.containsKey(attrKey)){ + SearchItemDataVO searchItemDataVO=dataVOMap.get(attrKey); + + }else{ + + + } + + }); + + } + } + catch (Throwable e){ + log.error("鏌ヨ澶辫触--->"+e); + } + } + } + /*** * 鏌ヨredis涓暟鎹紝瀵规瘮鍚庢彃鍏ockingtask -- Gitblit v1.9.3