From 3579af2945dd38d841a23cd340acd474bb63773a Mon Sep 17 00:00:00 2001 From: lihang <lihang@vci-tech.com> Date: 星期四, 04 五月 2023 18:02:01 +0800 Subject: [PATCH] 业务类型与DDL服务相关的添加 --- Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClstempattrServiceImpl.java | 691 --------------------------------------------------------- 1 files changed, 4 insertions(+), 687 deletions(-) diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClstempattrServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClstempattrServiceImpl.java index ccc9518..404f4d4 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClstempattrServiceImpl.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClstempattrServiceImpl.java @@ -16,47 +16,23 @@ */ package com.vci.ubcs.code.service.impl; -import com.alibaba.fastjson.JSONObject; -import com.alibaba.nacos.common.utils.StringUtils; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.vci.ubcs.code.constant.MdmBtmTypeConstant; -import com.vci.ubcs.code.dto.CodeClstempattrDTO; import com.vci.ubcs.code.entity.CodeClstempattrEntity; -import com.vci.ubcs.code.entity.CodeClstemplateEntity; -import com.vci.ubcs.code.enumpack.CodeLevelTypeEnum; import com.vci.ubcs.code.mapper.CodeClstempattrMapper; -import com.vci.ubcs.code.mapper.CodeClstemplateMapper; -import com.vci.ubcs.code.mapper.CodeOsbtmtypeattributeMapper; import com.vci.ubcs.code.service.ICodeClstempattrService; -import com.vci.ubcs.code.service.ICodeTempphaseService; import com.vci.ubcs.code.vo.CodeClstempattrVO; -import com.vci.ubcs.code.vo.CodeOsbtmtypeattributeVO; -import com.vci.ubcs.starter.exception.VciBaseException; -import com.vci.ubcs.starter.revision.service.RevisionModelUtil; -import com.vci.ubcs.starter.util.PatternUtil; + import com.vci.ubcs.starter.web.enumpck.VciFieldTypeEnum; -import com.vci.ubcs.starter.web.pagemodel.*; import com.vci.ubcs.starter.web.util.BeanUtilForVCI; import com.vci.ubcs.starter.web.util.VciBaseUtil; -import com.vci.ubcs.starter.web.util.VciDateUtil; -import com.vci.ubcs.system.entity.DictBiz; -import com.vci.ubcs.system.feign.IDictBizClient; -import org.springblade.core.mp.support.Condition; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cglib.beans.BeanMap; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; -import java.util.*; -import java.util.stream.Collectors; - -import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; /** * 缂栫爜搴撳畾涔�-妯℃澘灞炴�� 鏈嶅姟瀹炵幇绫� @@ -69,22 +45,6 @@ @Resource CodeClstempattrMapper codeClstempattrMapper; -// @Resource -// ICodeTempphaseService codeTempphaseService; - @Resource - IDictBizClient iDictBizClient; - @Resource - CodeClstemplateMapper codeClstemplateMapper; - @Resource - CodeOsbtmtypeattributeMapper codeOsbtmtypeattributeMapper; - @Resource - ICodeTempphaseService codeTempphaseService; - - /** - * 瀵硅薄鐨勬搷浣� - */ - @Autowired(required = false) - private RevisionModelUtil revisionModelUtil; @Override public IPage<CodeClstempattrVO> selectCodeClstempattrPage(IPage<CodeClstempattrVO> page, CodeClstempattrVO CodeClstempattr) { @@ -151,648 +111,5 @@ vo.setAttributeDataTypeText(VciFieldTypeEnum.getTextByValue(vo.getAttributedatatype())); } return vo; - } - - /** - * 鏌ヨ鎵�鏈夌殑涓婚搴撳垎绫荤殑妯℃澘灞炴�� - * @param conditionMap 鏌ヨ鏉′欢 - * @param pageHelper 鍒嗛〉鍜屾帓搴� - * @return 鎵ц缁撴灉 - */ - @Override - public DataGrid<CodeClstempattrVO> gridCodeClassifyTemplateAttr(Map<String, String> conditionMap, PageHelper pageHelper) { - DataGrid<CodeClstempattrVO> dataGrid=new DataGrid<CodeClstempattrVO>(); - //娌℃湁浼犻�掑弬鏁帮紝灏变笉鎵ц鏌ヨ閫昏緫 - if(conditionMap.size()==0){ - dataGrid.setData(new ArrayList<>()); - dataGrid.setTotal(0); - return dataGrid; - } - - if (pageHelper == null) { - pageHelper = new PageHelper(-1); - } - pageHelper.addDefaultAsc("ordernum"); -// IPage iPage = new IPage(); - Query query = new Query(); - query.setAscs("ordernum"); -// query.setSize(100); - if(pageHelper.getLimit() != -1){ - query.setSize(pageHelper.getLimit()); - query.setCurrent(pageHelper.getPage()); - } -// Condition.getPage(query) - CodeClstempattrVO codeClstempattrVO = new CodeClstempattrVO(); -// BeanUtil.toBean(map,codeClstempattrVO); -// BeanUtil - BeanMap beanMap = BeanMap.create(codeClstempattrVO); - - beanMap.putAll(conditionMap); -// Condition.getQueryWrapper( - IPage<CodeClstempattrEntity> doList = baseMapper. - selectPage(Condition.getPage(query), Condition.getQueryWrapper(codeClstempattrVO)); - - - if (!CollectionUtils.isEmpty(doList.getRecords())) { -// CodeClstempattrEntity codeClstempattrEntity = new CodeClstempattrEntity(); -// BeanUtils.copyProperties(conditionMap, codeClstempattrEntity); -// List<CodeClstempattrEntity> codeClstempattrEntities = new ArrayList<>(); -// BeanUtils.copyProperties(doList,codeClstempattrEntities); -// codeClstempattrEntities.addAll(doList); - dataGrid.setData(codeClassifyTemplateAttrDO2VOs(doList.getRecords())); - dataGrid.setTotal(VciBaseUtil.getInt(String.valueOf(baseMapper.selectCount(Condition.getQueryWrapper(codeClstempattrVO))))); - } - return dataGrid; - } - - /** - * 澧炲姞涓婚搴撳垎绫荤殑妯℃澘灞炴�� - * @param codeClassifyTemplateAttrDTO 涓婚搴撳垎绫荤殑妯℃澘灞炴�ф暟鎹紶杈撳璞� - * @return 鎵ц缁撴灉 - */ - @Override - public CodeClstempattrVO addSave(CodeClstempattrDTO codeClassifyTemplateAttrDTO){ - VciBaseUtil.alertNotNull(codeClassifyTemplateAttrDTO,"闇�瑕佹坊鍔犵殑鏁版嵁瀵硅薄"); - //灏咲TO杞崲涓篋O - CodeClstempattrEntity codeClassifyTemplateAttrDO = new CodeClstempattrEntity(); - BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDO); - baseMapper.insert(codeClassifyTemplateAttrDO); - return codeClassifyTemplateAttrDO2VO(codeClassifyTemplateAttrDO); - } - - - /** - * 鎵归噺娣诲姞 - * @param codeClassifyTemplateAttrDTOs 鏁版嵁浼犺緭瀵硅薄 - * @return 淇濆瓨鍚庣殑鏄剧ず瀵硅薄 - */ - @Override - @Transactional - public List<CodeClstempattrVO> batchAddSave(List<CodeClstempattrDTO> codeClassifyTemplateAttrDTOs) { - if(CollectionUtils.isEmpty(codeClassifyTemplateAttrDTOs)){ - return new ArrayList<>(); - } - - //鍙栨墍鏈夊睘鎬х殑鑻辨枃鍚嶇О锛岀涓変釜楠岃瘉闇�瑕佺敤鍒� - Map<String,CodeClstempattrDTO> attrDTOMap =codeClassifyTemplateAttrDTOs.stream().collect(Collectors.toMap(s->s.getId().toLowerCase(Locale.ROOT), t->t)); - - //鎵惧睘鎬т腑鏂囧悕瀛楅噸澶� - Map<String, Long> nameCountMap = codeClassifyTemplateAttrDTOs.stream().collect(Collectors.groupingBy(s -> s.getName(), Collectors.counting())); - List<String> repeatNameList = nameCountMap.keySet().stream().filter(s -> nameCountMap.get(s) > 1).collect(Collectors.toList()); - if(!CollectionUtils.isEmpty(repeatNameList)){ - throw new VciBaseException("妯℃澘灞炴�т腑鏂囧悕绉般�恵0}銆戦噸澶�",new String[]{ repeatNameList.stream().collect(Collectors.joining(","))}); - } - //鎵惧睘鎬ц嫳鏂囧悕瀛楅噸澶� - Map<String, Long> idCountMap = codeClassifyTemplateAttrDTOs.stream().collect(Collectors.groupingBy(s -> s.getId().toLowerCase(Locale.ROOT), Collectors.counting())); - List<String> repeatIdList = idCountMap.keySet().stream().filter(s -> idCountMap.get(s) > 1).collect(Collectors.toList()); - if(!CollectionUtils.isEmpty(repeatIdList)){ - throw new VciBaseException("妯℃澘灞炴�ц嫳鏂囧悕绉般�恵0}銆戦噸澶�",new String[]{ repeatIdList.stream().collect(Collectors.joining(","))}); - } - - //妯℃澘oid - String CLASSIFYTEMPLATEOID = null; - //杞崲 - List<CodeClstempattrEntity> codeClassifyTemplateAttrDOInsert = new ArrayList<CodeClstempattrEntity>(); - List<String> prefix = new ArrayList<>(); - List<String> suffix = new ArrayList<>(); - List<String> dateFormates = new ArrayList<>(); - for (CodeClstempattrEntity codeClassifyTemplateAttrDTO:codeClassifyTemplateAttrDTOs){ - VciBaseUtil.alertNotNull(codeClassifyTemplateAttrDTO,"闇�瑕佹坊鍔犵殑鏁版嵁瀵硅薄"); - //灏咲TO杞崲涓篋O - CodeClstempattrEntity codeClassifyTemplateAttrDO = new CodeClstempattrEntity(); - BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDO); - codeClassifyTemplateAttrDOInsert.add(codeClassifyTemplateAttrDO); - - if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getPrefixvalue())){ - prefix.add(codeClassifyTemplateAttrDO.getPrefixvalue()); - } - if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getSuffixvalue())){ - suffix.add(codeClassifyTemplateAttrDO.getSuffixvalue()); - } - if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getCodedateformat())){ - dateFormates.add(codeClassifyTemplateAttrDO.getCodedateformat()); - } - //鍒ゆ柇浼犺繃鏉ョ殑鏋氫妇娉ㄥ叆鏄惁鏄痡sonArr鏍煎紡 - if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getEnumstring())&&!checkKVArr(codeClassifyTemplateAttrDO.getEnumstring())){ - throw new VciBaseException("{0}{1}灞炴�х殑鏋氫妇娉ㄥ叆鏁版嵁鏍煎紡閿欒!",new String[]{codeClassifyTemplateAttrDO.getId(),codeClassifyTemplateAttrDO.getName()}); - } - //鍒嗙被娉ㄥ叆 - if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getClassifyinvokeattr()) - && !CodeLevelTypeEnum.MIN.getValue().equalsIgnoreCase(codeClassifyTemplateAttrDO.getClassifyinvokelevel()) - && VciBaseUtil.getInt(codeClassifyTemplateAttrDO.getClassifyinvokelevel()) < 0){ - throw new VciBaseException("{0}{1}灞炴�х殑鏄垎绫绘敞鍏ワ紝浣嗘槸娉ㄥ叆灞傜骇涓嶈兘灏忎簬0!",new String[]{codeClassifyTemplateAttrDO.getId(),codeClassifyTemplateAttrDO.getName()}); - } - - //鍒ゆ柇浼犺繃鏉ョ殑鍙傜収閰嶇疆鏄惁鏄痡son鏍煎紡 - if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getReferconfig())&&!checkKVObj(codeClassifyTemplateAttrDO.getReferconfig())){ - throw new VciBaseException("{0}{1}灞炴�х殑鍙傜収閰嶇疆鏁版嵁鏍煎紡閿欒!",new String[]{codeClassifyTemplateAttrDO.getId(),codeClassifyTemplateAttrDO.getName()}); - } - if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getCodedateformat()) && !checkDateFormat(codeClassifyTemplateAttrDO.getCodedateformat())){ - throw new VciBaseException("{0}{1}灞炴�х殑鏃堕棿鏍煎紡涓嶇鍚堣姹�",new String[]{codeClassifyTemplateAttrDO.getId(),codeClassifyTemplateAttrDO.getName()}); - } - //濡傛灉鏄粍鍚堣鍒欙紝閲岄潰浣跨敤鐨勫睘鎬т笉鑳界己澶憋紝涔熼兘寰楁樉绀� - String componentrule = codeClassifyTemplateAttrDTO.getComponentrule(); - boolean isContainsDynamicParameter = PatternUtil.isContainsDynamicParameter(componentrule); - if(isContainsDynamicParameter){ - List<String> userdAttrList = PatternUtil.getKeyListByContent(componentrule);//鍖呭惈鐨勬墍鏈�${xxx}涓殑xxx - if(!CollectionUtils.isEmpty(userdAttrList)){ - String unExistAttr = userdAttrList.stream().filter(s -> !attrDTOMap.containsKey(s.toLowerCase(Locale.ROOT))).collect(Collectors.joining(",")); - if(StringUtils.isNotBlank(unExistAttr)){ - throw new VciBaseException("{0}灞炴�ф槸缁勫悎瑙勫垯锛屼絾鏄鍒欓噷鍖呭惈鐨勫睘鎬{1}]鍦ㄥ綋鍓嶆ā鏉夸腑涓嶅瓨鍦�!",new String[]{codeClassifyTemplateAttrDO.getName(), unExistAttr}); - } - //瑕佺湅鐪嬭〃鍗曟槸鍚︽樉绀� - String unFormDisplayAttr = userdAttrList.stream().filter(s -> !VciBaseUtil.getBoolean(attrDTOMap.getOrDefault(s.toLowerCase(Locale.ROOT), - new CodeClstempattrDTO()).getFormdisplayflag())).collect(Collectors.joining(",")); - if(StringUtils.isNotBlank(unFormDisplayAttr)){ - throw new VciBaseException("{0}灞炴�ф槸缁勫悎瑙勫垯锛屼絾鏄鍒欓噷鍖呭惈鐨勫睘鎬{1}]鍦ㄥ綋鍓嶆ā鏉夸腑娌℃湁璁剧疆 琛ㄥ崟鏄剧ず ",new String[]{codeClassifyTemplateAttrDO.getName(),unFormDisplayAttr}); - } - } - } - - if(CLASSIFYTEMPLATEOID==null){ - CLASSIFYTEMPLATEOID = codeClassifyTemplateAttrDTO.getClassifytemplateoid(); - } - - } - - //鎵ц鏁版嵁淇濆瓨鎿嶄綔 -// WebUtil.setPersistence(false);//涓嶆墽琛屼繚瀛� - - //鍏堥兘鍒犱簡 -// VciQueryWrapperForDO deleteAttrWrapper = new VciQueryWrapperForDO(CodeClassifyTemplateAttrDO.class); -// deleteAttrWrapper.addQueryMap("CLASSIFYTEMPLATEOID",CLASSIFYTEMPLATEOID); - Map<String,Object> condition = new HashMap<>(); - condition.put("CLASSIFYTEMPLATEOID",CLASSIFYTEMPLATEOID); - List<CodeClstempattrEntity> codeClassifyTemplateAttrDODelete = baseMapper.selectByMap(condition); - - //oids - List<String> oids = new ArrayList<String>(); - for (CodeClstempattrEntity codeClassifyTemplateAttrDO:codeClassifyTemplateAttrDODelete){ - oids.add(codeClassifyTemplateAttrDO.getOid()); - } -// BatchCBO batchCBOTemplateDelete = new BatchCBO(); - if(!CollectionUtils.isEmpty(oids)){ - baseMapper.deleteBatchIds(oids); - } - - //鍐嶆柊澧� - if(!CollectionUtils.isEmpty(codeClassifyTemplateAttrDOInsert)){ - this.saveBatch(codeClassifyTemplateAttrDOInsert); - } - - //璋冪敤闃舵 - if(!CollectionUtils.isEmpty(codeClassifyTemplateAttrDOInsert)){ - codeTempphaseService.codeTemplateAttrModifyTrigger(codeClassifyTemplateAttrDOInsert); - - } - - -// SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo(); - //澶勭悊鍙緭鍙�夌殑瀛楃 - if(!CollectionUtils.isEmpty(prefix)){ - for (String s : prefix) { - DictBiz dictBiz = new DictBiz(); - dictBiz.setCode(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR); - dictBiz.setDictKey(s); - dictBiz.setDictValue("prefix"); - iDictBizClient.getCheck(dictBiz) ; - } -// .saveBySameNamespaceAndFlag(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR,"prefix",prefix,sessionInfo); - } - if(!CollectionUtils.isEmpty(suffix)){ - for (String s : suffix) { - DictBiz dictBiz = new DictBiz(); - dictBiz.setCode(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR); - dictBiz.setDictKey(s); - dictBiz.setDictValue("suffix"); - iDictBizClient.getCheck(dictBiz) ; - } -// charService.saveBySameNamespaceAndFlag(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR,"suffix",suffix,sessionInfo); - } - if(!CollectionUtils.isEmpty(dateFormates)){ - for (String s : dateFormates) { - DictBiz dictBiz = new DictBiz(); - dictBiz.setCode(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR); - dictBiz.setDictKey(s); - dictBiz.setDictValue("dateFormates"); - iDictBizClient.getCheck(dictBiz) ; - } -// charService.saveBySameNamespaceAndFlag(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR,"dateFormates",dateFormates,sessionInfo); - } - -// WebUtil.setPersistence(true);//鎵ц淇濆瓨 -// boService.persistenceBatch(batchCBOTemplateDelete);//涓�璧锋墽琛屼繚瀛� - return codeClassifyTemplateAttrDO2VOs(codeClassifyTemplateAttrDOInsert); - } - - public boolean checkKVArr(String kvString){ - boolean isKV = true; - try { - JSONObject.parseArray(kvString, KeyValue.class); - }catch (Exception e){ - isKV=false; - } - return isKV; - } - public boolean checkKVObj(String kvString){ - boolean isKV = true; - try { - JSONObject.parseObject(kvString, UIFormReferVO.class); - }catch (Exception e){ - isKV=false; - } - return isKV; - } - - /** - * 鏍¢獙鏃堕棿鏍煎紡 - * @param dateFormat 鏃堕棿鏍煎紡 - * @return true琛ㄧず鏍¢獙閫氳繃 - */ - public boolean checkDateFormat(String dateFormat){ - try{ - VciDateUtil.date2Str(new Date(),dateFormat); - return true; - }catch (Throwable e){ - return false; - } - } - - - /** - * 淇敼涓婚搴撳垎绫荤殑妯℃澘灞炴�� - * @param codeClassifyTemplateAttrDTO 涓婚搴撳垎绫荤殑妯℃澘灞炴�ф暟鎹紶杈撳璞� - * @return 鎵ц缁撴灉 - * @throws VciBaseException 鍙傛暟涓虹┖锛屽敮涓�椤癸紝蹇呰緭椤逛笉閫氳繃鏃朵細鎶涘嚭寮傚父 - */ - @Override - public R editSave(CodeClstempattrDTO codeClassifyTemplateAttrDTO) throws VciBaseException{ - VciBaseUtil.alertNotNull(codeClassifyTemplateAttrDTO,"鏁版嵁瀵硅薄",codeClassifyTemplateAttrDTO.getOid(),"涓婚搴撳垎绫荤殑妯℃澘灞炴�т富閿�"); - - //鍒ゆ柇浼犺繃鏉ョ殑鏋氫妇娉ㄥ叆鏄惁鏄痡sonArr鏍煎紡 - if(StringUtils.isNotBlank(codeClassifyTemplateAttrDTO.getEnumstring())&&!checkKVArr(codeClassifyTemplateAttrDTO.getEnumstring())){ - throw new VciBaseException("鏋氫妇娉ㄥ叆鏁版嵁鏍煎紡閿欒!"); - } - - //鍒ゆ柇浼犺繃鏉ョ殑鍙傜収閰嶇疆鏄惁鏄痡son鏍煎紡 - if(StringUtils.isNotBlank(codeClassifyTemplateAttrDTO.getReferbtmid())&&!checkKVObj(codeClassifyTemplateAttrDTO.getReferbtmid())){ - throw new VciBaseException("鏋氫妇娉ㄥ叆鏁版嵁鏍煎紡閿欒!"); - } - - - //妫�鏌s - CodeClstempattrEntity codeClassifyTemplateAttrDOCopyFromDTO = new CodeClstempattrEntity(); -// BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDOCopyFromDTO); -// boolean tsBoolean = boService.checkTs(codeClassifyTemplateAttrDOCopyFromDTO); - - //妫�鏌s -// Map<String,Object> condition = new HashMap<>(2); -// condition.put("oid",codeClassifyTemplateAttrDTO.getOid()); -// condition.put("ts",codeClassifyTemplateAttrDTO.getTs()); - CodeClstempattrEntity detail = baseMapper.selectById(codeClassifyTemplateAttrDTO.getOid()); - if(!detail.getTs().toString().equals(codeClassifyTemplateAttrDTO.getTs().toString())){//涓嶆槸鏈�鏂扮殑涓嶈鏀� - return R.fail("褰撳墠鏁版嵁涓嶆槸鏈�鏂帮紝璇峰埛鏂板悗鍐嶄慨鏀癸紒"); - } - - //灏咲TO杞崲涓篋O - CodeClstempattrEntity codeClassifyTemplateAttrDO = baseMapper.selectById(codeClassifyTemplateAttrDTO.getOid()); - revisionModelUtil.copyFromDTOIgnore(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDO); - baseMapper.updateById(codeClassifyTemplateAttrDO); - return R.data(codeClassifyTemplateAttrDO2VO(codeClassifyTemplateAttrDO)); - } - - /** - * 鍒犻櫎涓婚搴撳垎绫荤殑妯℃澘灞炴�� - * @param codeClassifyTemplateAttrDTO 涓婚搴撳垎绫荤殑妯℃澘灞炴�ф暟鎹紶杈撳璞★紝oid鍜宼s闇�瑕佷紶杈� - * @return 鍒犻櫎缁撴灉鍙嶉锛氾細success锛氭垚鍔燂紝fail锛氬け璐� - * @throws VciBaseException 鍙傛暟涓虹┖锛岃寮曠敤鏃舵姏鍑哄紓甯� - */ - @Override - public R deleteCodeClassifyTemplateAttr(CodeClstempattrDTO codeClassifyTemplateAttrDTO) throws VciBaseException{ - VciBaseUtil.alertNotNull(codeClassifyTemplateAttrDTO,"涓婚搴撳垎绫荤殑妯℃澘灞炴�ф暟鎹璞�",codeClassifyTemplateAttrDTO.getOid(),"涓婚搴撳垎绫荤殑妯℃澘灞炴�х殑涓婚敭"); - CodeClstempattrEntity codeClassifyTemplateAttrDO = baseMapper.selectById(codeClassifyTemplateAttrDTO.getOid()); - R baseResult = checkIsCanDeleteForDO(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDO); - if(baseResult.isSuccess()) { - }else{ - return baseResult; - } - //鎵ц鍒犻櫎鎿嶄綔 - int deleteNum = baseMapper.deleteById(codeClassifyTemplateAttrDO.getOid()); - return deleteNum>0?R.success(DELETE_SUCCESS):R.fail(DELETE_FAIL); - } - - /** - * 鏍¢獙鏄惁鍙互鍒犻櫎锛屽鏋滃瓨鍦ㄤ笅绾э紝骞朵笖涓嬬骇鏈夋暟鎹紩鐢ㄥ垯涓嶈兘鍒犻櫎 - * @param codeClassifyTemplateAttrDTO 鏁版嵁浼犺緭瀵硅薄 - * @param codeClassifyTemplateAttrDO 鏁版嵁搴撲腑鐨勬暟鎹璞� - * @return success涓簍rue涓哄彲浠ュ垹闄わ紝false琛ㄧず鏈夋暟鎹紩鐢紝obj涓簍rue琛ㄧず鏈変笅绾� - */ - private R checkIsCanDeleteForDO(CodeClstempattrDTO codeClassifyTemplateAttrDTO, CodeClstempattrEntity codeClassifyTemplateAttrDO) { -// boService.checkTs(codeClassifyTemplateAttrDO); -// Map<String,Object> condition = new HashMap<>(2); -// condition.put("oid",codeClassifyTemplateAttrDTO.getOid()); -// condition.put("ts",codeClassifyTemplateAttrDTO.getTs()); - CodeClstempattrEntity detail = baseMapper.selectById(codeClassifyTemplateAttrDTO.getOid()); -// .selectOne(Condition.getQueryWrapper(condition,CodeClstempattrEntity.class)); - - if(!detail.getTs().toString().equals(codeClassifyTemplateAttrDTO.getTs().toString())){//涓嶆槸鏈�鏂扮殑涓嶈鏀� - return R.fail("褰撳墠鏁版嵁涓嶆槸鏈�鏂帮紝璇峰埛鏂板悗鍐嶄慨鏀癸紒"); - } - if(!checkIsLinked(codeClassifyTemplateAttrDO.getOid())) { - return R.success("鍙互鍒犻櫎锛�"); - }else{ - return R.fail(DATA_LINKED_NOT_DELETE); - } - } - - /** - * 鏍¢獙鏄惁琚紩鐢� - * @param oid 涓婚敭 - * @throws VciBaseException 琚紩鐢ㄧ殑鏃跺�欎細鎶涘嚭寮傚父 - */ - private boolean checkIsLinked(String oid) throws VciBaseException{ - //TODO 娣诲姞闇�瑕佹牎楠屽紩鐢ㄧ殑鍦版柟 - return false; - } - - /** - * 涓婚敭鑾峰彇涓婚搴撳垎绫荤殑妯℃澘灞炴�� - * @param oid 涓婚敭 - * @return 涓婚搴撳垎绫荤殑妯℃澘灞炴�ф樉绀哄璞� - * @throws VciBaseException 鍙傛暟涓虹┖锛屾暟鎹笉瀛樺湪鏃朵細鎶涘嚭寮傚父 - */ - @Override - public CodeClstempattrVO getObjectByOid(String oid) throws VciBaseException{ - return codeClassifyTemplateAttrDO2VO(selectByOid(oid)); - } - /** - * 涓婚敭鏌ヨ鏁版嵁瀵硅薄 - * @param oid 涓婚敭 - * @return 鏁版嵁瀵硅薄 - * @throws VciBaseException 鍙傛暟涓虹┖锛屽苟涓旀暟鎹笉瀛樺湪鐨勬椂鍊欎細鎶涘嚭寮傚父 - */ - private CodeClstempattrEntity selectByOid(String oid) throws VciBaseException{ - VciBaseUtil.alertNotNull(oid,"涓婚敭"); - CodeClstempattrEntity codeClassifyTemplateAttrDO = baseMapper.selectById(oid.trim()); - if(codeClassifyTemplateAttrDO == null || StringUtils.isBlank(codeClassifyTemplateAttrDO.getOid())){ - throw new VciBaseException(DATA_OID_NOT_EXIST); - } - return codeClassifyTemplateAttrDO; - } - - /** - * 涓婚敭鎵归噺鑾峰彇涓婚搴撳垎绫荤殑妯℃澘灞炴�� - * @param oidCollections 涓婚敭闆嗗悎锛屼絾鏄彈鎬ц兘褰卞搷锛屽缓璁竴娆℃煡璇笉瓒呰繃10000涓� - * @return 涓婚搴撳垎绫荤殑妯℃澘灞炴�ф樉绀哄璞� - * @throws VciBaseException 鏌ヨ鍑虹幇寮傚父鏃朵細鎶涘嚭 - */ - @Override - public Collection<CodeClstempattrVO> listCodeClassifyTemplateAttrByOids(Collection<String> oidCollections) { - VciBaseUtil.alertNotNull(oidCollections,"鏁版嵁瀵硅薄涓婚敭闆嗗悎"); - List<CodeClstempattrEntity> codeClassifyTemplateAttrDOList = listCodeClassifyTemplateAttrDOByOidCollections(oidCollections); - return codeClassifyTemplateAttrDO2VOs(codeClassifyTemplateAttrDOList); - } - - /** - * 浣跨敤涓婚敭闆嗗悎鏌ヨ鏁版嵁瀵硅薄 - * @param oidCollections 涓婚敭鐨勯泦鍚� - * @return 鏁版嵁瀵硅薄鍒楄〃 - */ - private List<CodeClstempattrEntity> listCodeClassifyTemplateAttrDOByOidCollections(Collection<String> oidCollections){ - List<CodeClstempattrEntity> codeClassifyTemplateAttrDOList = new ArrayList<CodeClstempattrEntity>(); - if(!CollectionUtils.isEmpty(oidCollections)){ - Collection<Collection<String>> oidCollectionsList = VciBaseUtil.switchCollectionForOracleIn(oidCollections); - for(Collection<String> oids: oidCollectionsList){ - List<CodeClstempattrEntity> tempDOList = baseMapper.selectBatchIds(oids); - if(!CollectionUtils.isEmpty(tempDOList)){ - codeClassifyTemplateAttrDOList.addAll(tempDOList); - } - } - } - return codeClassifyTemplateAttrDOList; - } - - /** - * 鍙傜収涓婚搴撳垎绫荤殑妯℃澘灞炴�у垪琛� - * @param conditionMap 鏌ヨ鏉′欢 - * @param pageHelper 鍒嗛〉鍜屾帓搴� - * @return 涓婚搴撳垎绫荤殑妯℃澘灞炴�ф樉绀哄璞″垪琛紝鐢熸晥鐨勫唴瀹� - * @throws VciBaseException 鏌ヨ鏉′欢鍜屽垎椤靛嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父 - */ - @Override - public DataGrid<CodeClstempattrVO> refDataGridCodeClassifyTemplateAttr(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException{ - if(conditionMap == null){ - conditionMap = new HashMap<String, String>(); - } - return gridCodeClassifyTemplateAttr(conditionMap,pageHelper); - } - - /** - * 鏌ヨ杩欎釜妯℃澘锛屼笟鍔$被鍨嬩笅鐨勬墍鏈夋湭閫夋嫨鐨勫睘鎬� - * @param baseQueryObject - * @return - */ - @Override - public DataGrid<CodeOsbtmtypeattributeVO> codeClassifyTemplateAttrByBtm(BaseQueryObject baseQueryObject){ - if(baseQueryObject.getConditionMap() == null){ - baseQueryObject.setConditionMap(new HashMap<>()); - } - DataGrid<CodeOsbtmtypeattributeVO> dataGrid=new DataGrid<CodeOsbtmtypeattributeVO>(); - //妯℃澘oid - String templateAttrOid = baseQueryObject.getConditionMap().get("oid"); - String name = baseQueryObject.getConditionMap().getOrDefault("name",""); - String id = baseQueryObject.getConditionMap().getOrDefault("id",""); - - //娌℃湁oid涓嶆墽琛岄�昏緫 - if(StringUtils.isBlank(templateAttrOid)){ - dataGrid.setData(new ArrayList<>()); - dataGrid.setTotal(0); - return dataGrid; - } - - //鏌ヨ妯℃澘瀵硅薄 - CodeClstemplateEntity codeClassifyTemplateDO = codeClstemplateMapper.selectById(templateAttrOid); - - //杩欎釜涓氬姟绫诲瀷涓嬬殑鎵�鏈夊睘鎬� - List<CodeOsbtmtypeattributeVO> boAttrs = (List<CodeOsbtmtypeattributeVO>) codeOsbtmtypeattributeMapper.selectById(codeClassifyTemplateDO.getBtmTypeId());// this.btmService.listAttributeByBtmId(codeClassifyTemplateDO.getBtmTypeId()); -// codeOsbtmtypeattributeMapper.selectById(codeClassifyTemplateDO.getBtmTypeId()); -// BeanUtils.copyProperties(codeOsbtmtypeattributeMapper.selectById(codeClassifyTemplateDO.getBtmTypeId()),boAttrs); - //鎶婇粯璁ょ殑灞炴�т篃娣诲姞鍒癰oAttrs - if(boAttrs == null){ - boAttrs = new ArrayList<>(); - } - if(!false){ -// List<CodeOsbtmtypeattributeVO> finalBoAttrs = boAttrs; -// attributeService.getDefaultAttributeVOs().stream().forEach(attr-> { -// CodeOsbtmtypeattributeVO attributeVO = new CodeOsbtmtypeattributeVO(); -// BeanUtil.convert(attr, attributeVO); -// if ("id".equalsIgnoreCase(attributeVO.getId())) { -// attributeVO.setName("浼佷笟缂栫爜"); -// } -// if ("name".equalsIgnoreCase(attributeVO.getId())) { -// attributeVO.setName("闆嗗洟鐮�"); -// } -// attributeVO.setAttrDataType(attr.getAttributeDataType()); -// attributeVO.setAttributeLength(attr.getAttrLength()); -// attributeVO.setReferBtmTypeId(attr.getBtmTypeId()); -// attributeVO.setReferBtmTypeName(attr.getBtmTypeName()); -// finalBoAttrs.add(attributeVO); -// }); -// boAttrs = finalBoAttrs; - Object o = null; - } - - //杩欎釜妯℃澘涓嬪凡缁忔湁鐨勫睘鎬� -// VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(CodeClassifyTemplateAttrDO.class); -// queryWrapper.addQueryMap("CLASSIFYTEMPLATEOID",templateAttrOid); - Map<String,Object> condition = new HashMap<>(1); - condition.put("CLASSIFYTEMPLATEOID",templateAttrOid); - List<CodeClstempattrEntity> codeClassifyTemplateAttrDOList = codeClstempattrMapper.selectByMap(condition); - - List<String> btmOids = new ArrayList<String>(); - for (CodeClstempattrEntity codeClassifyTemplateAttrDO:codeClassifyTemplateAttrDOList){ - btmOids.add(codeClassifyTemplateAttrDO.getId()); - } - - //杩囨护鎺夊凡缁忓瓨鍦ㄧ殑灞炴�� - List<CodeOsbtmtypeattributeVO> boAttrss = new ArrayList<CodeOsbtmtypeattributeVO>(); - - for (CodeOsbtmtypeattributeVO osBtmTypeAttributeVO:boAttrs){ - if(!btmOids.contains(osBtmTypeAttributeVO.getId())){ - //鐪嬬湅鏄笉鏄湁妯$硦鏌ヨ - boolean inSearch = true; - if(StringUtils.isNotBlank(name) && !osBtmTypeAttributeVO.getName().contains(name.replace("*",""))){ - inSearch = false; - } - if(StringUtils.isNotBlank(id) && !osBtmTypeAttributeVO.getId().contains(id.replace("*",""))){ - inSearch = false; - } - if(inSearch) { - boAttrss.add(osBtmTypeAttributeVO); - } - } - } - dataGrid.setData(boAttrss); - dataGrid.setTotal(boAttrss.size()); - return dataGrid; - } - - - - /** - * 鏌ヨ杩欎釜妯℃澘锛屼笟鍔$被鍨嬩笅宸查�夋嫨鐨勫睘鎬� - * @param baseQueryObject - * @return - */ - @Override - public DataGrid<CodeOsbtmtypeattributeVO> codeClassifyTemplateAttrByBtmHave(BaseQueryObject baseQueryObject){ - DataGrid<CodeOsbtmtypeattributeVO> dataGrid=new DataGrid<CodeOsbtmtypeattributeVO>(); - //妯℃澘oid - String templateAttrOid = baseQueryObject.getConditionMap().get("oid"); - - //娌℃湁oid涓嶆墽琛岄�昏緫 - if(StringUtils.isBlank(templateAttrOid)){ - dataGrid.setData(new ArrayList<>()); - dataGrid.setTotal(0); - return dataGrid; - } - - //鏌ヨ妯℃澘瀵硅薄 - CodeClstemplateEntity codeClassifyTemplateDO = codeClstemplateMapper.selectById(templateAttrOid); - - //杩欎釜涓氬姟绫诲瀷涓嬬殑鎵�鏈夊睘鎬� - List<CodeOsbtmtypeattributeVO> boAttrs = (List<CodeOsbtmtypeattributeVO>) codeOsbtmtypeattributeMapper.selectById(codeClassifyTemplateDO.getBtmTypeId());//this.btmService.listAttributeByBtmIdHasDefault(codeClassifyTemplateDO.getBtmTypeId()); -// codeOsbtmtypeattributeMapper.selectById(codeClassifyTemplateDO.getBtmTypeId()); -// BeanUtils.copyProperties(codeOsbtmtypeattributeMapper.selectById(codeClassifyTemplateDO.getBtmTypeId()),boAttrs); - //杩欎釜妯℃澘涓嬪凡缁忔湁鐨勫睘鎬� - //鎶婇粯璁ょ殑灞炴�т篃娣诲姞鍒癰oAttrs - if(boAttrs == null){ - boAttrs = new ArrayList<>(); - } -// VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(CodeClassifyTemplateAttrDO.class); -// queryWrapper.addQueryMap("CLASSIFYTEMPLATEOID",templateAttrOid); - -// Map<String,Object> condition = new HashMap<>(1); -// condition.put("CLASSIFYTEMPLATEOID",templateAttrOid); - - QueryWrapper<CodeClstempattrEntity> wrapper=new QueryWrapper<>(); - wrapper.eq("CLASSIFYTEMPLATEOID",templateAttrOid); - - List<CodeClstempattrEntity> codeClassifyTemplateAttrDOList = codeClstempattrMapper.selectList(wrapper); - List<String> btmOids = new ArrayList<String>(); - for (CodeClstempattrEntity codeClassifyTemplateAttrDO:codeClassifyTemplateAttrDOList){ - btmOids.add(codeClassifyTemplateAttrDO.getId()); - } - - //杩囨护鎺夐櫎浜嗚嚜韬殑鍒殑灞炴�� - List<CodeOsbtmtypeattributeVO> boAttrss = new ArrayList<CodeOsbtmtypeattributeVO>(); - - for (CodeOsbtmtypeattributeVO osBtmTypeAttributeVO:boAttrs){ - if(btmOids.contains(osBtmTypeAttributeVO.getId())){ - boAttrss.add(osBtmTypeAttributeVO); - } - } - dataGrid.setData(boAttrss); - dataGrid.setTotal(boAttrss.size()); - return dataGrid; - } - - - /** - * 鍚屾鍒板叾浠栨ā鏉� - * @param codeClassifyTemplateAttrDTO oid - * @return - */ - @Override - public R copyto(CodeClstempattrDTO codeClassifyTemplateAttrDTO) throws VciBaseException{ - - String templateAttrOid = codeClassifyTemplateAttrDTO.getOid(); - - //鏌ヨ鍑烘潵瑕佸鍒剁殑瀵硅薄 - CodeClstempattrEntity codeClassifyTemplateAttrDO = selectByOid(templateAttrOid); - String id = codeClassifyTemplateAttrDO.getId();//鑻辨枃鍚嶇О - String classfyTemplateOid = codeClassifyTemplateAttrDO.getClassifytemplateoid(); - - //鏌ヨ鍏朵粬id=id鐨勬ā鏉垮睘鎬� -// VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(CodeClassifyTemplateAttrDO.class); -// queryWrapper.addQueryMap("id",id); -// Map<String,Object> condition = new HashMap<>(1); -// condition.put("id",id); - QueryWrapper<CodeClstempattrEntity> wrapper=new QueryWrapper<>(); - wrapper.eq("id",id); - //鎵�鏈塱d=id鐨勬ā鏉垮睘鎬� - List<CodeClstempattrEntity> codeClassifyTemplateAttrDOList =codeClstempattrMapper.selectList(wrapper); - - //瑕佸垹闄ょ殑妯℃澘灞炴�х殑oids - List<String> deleteOids = new ArrayList<String>(); - //瑕佷慨鏀圭殑妯℃澘灞炴�у璞� - List<CodeClstempattrEntity> codeClassifyTemplateAttrDOListInsert = new ArrayList<CodeClstempattrEntity>(); - for (CodeClstempattrEntity codeClassifyTemplateAttrDOi:codeClassifyTemplateAttrDOList){ - String oid = codeClassifyTemplateAttrDOi.getOid(); - String templateOldOid = codeClassifyTemplateAttrDOi.getClassifytemplateoid(); - - CodeClstempattrEntity codeClassifyTemplateAttrDOInsert = new CodeClstempattrEntity(); - BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDO,codeClassifyTemplateAttrDOInsert); - codeClassifyTemplateAttrDOInsert.setOid(oid); - codeClassifyTemplateAttrDOInsert.setClassifytemplateoid(templateOldOid); - codeClassifyTemplateAttrDOListInsert.add(codeClassifyTemplateAttrDOInsert); - - deleteOids.add(codeClassifyTemplateAttrDOi.getOid()); - } - -// WebUtil.setPersistence(false);//涓嶆墽琛屼繚瀛� - - //鍒犻櫎 -// BatchCBO batchCBOTemplateAttrDelete = codeClassifyTemplateAttrDOissifyTemplateAttrMapper.batchDeleteByOids(deleteOids); - codeClstempattrMapper.deleteBatchIds(deleteOids); - //鍐嶆柊澧� -// BatchCBO batchCBOTemplateAttrInsert = codeClassifyTemplateAttrMapper.batchInsert(codeClassifyTemplateAttrDOListInsert); -// batchCBOTemplateAttrDelete.copyFromOther(batchCBOTemplateAttrInsert); - this.saveBatch(codeClassifyTemplateAttrDOListInsert); - -// WebUtil.setPersistence(true);//鎵ц淇濆瓨 -// boService.persistenceBatch(batchCBOTemplateAttrDelete);//涓�璧锋墽琛屼繚瀛� - - return R.success("鎿嶄綔鎴愬姛锛�"); } } -- Gitblit v1.9.3