From 744171debef6aee198be296520f0b86dc1586723 Mon Sep 17 00:00:00 2001 From: ludc Date: 星期三, 02 八月 2023 20:02:08 +0800 Subject: [PATCH] 提交代码 --- Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeBasicSecServiceImpl.java | 163 +++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 112 insertions(+), 51 deletions(-) diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeBasicSecServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeBasicSecServiceImpl.java index e363a31..c19a4ca 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeBasicSecServiceImpl.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeBasicSecServiceImpl.java @@ -2,17 +2,14 @@ import com.alibaba.cloud.commons.lang.StringUtils; import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.vci.ubcs.code.constant.MdmBtmTypeConstant; import com.vci.ubcs.code.dto.CodeBasicSecDTO; -import com.vci.ubcs.code.entity.CodeBasicSec; -import com.vci.ubcs.code.entity.CodeClassify; -import com.vci.ubcs.code.entity.CodeClassifyValue; -import com.vci.ubcs.code.entity.CodeFixedValue; +import com.vci.ubcs.code.entity.*; import com.vci.ubcs.code.enumpack.*; import com.vci.ubcs.code.lifecycle.CodeRuleLC; import com.vci.ubcs.code.mapper.CodeBasicSecMapper; @@ -20,9 +17,7 @@ import com.vci.ubcs.code.mapper.CodeFixedValueMapper; import com.vci.ubcs.code.service.*; import com.vci.ubcs.code.vo.CodeReferConfigVO; -import com.vci.ubcs.code.vo.pagemodel.CodeBasicSecVO; -import com.vci.ubcs.code.vo.pagemodel.CodeFixedValueVO; -import com.vci.ubcs.code.vo.pagemodel.CodeRuleVO; +import com.vci.ubcs.code.vo.pagemodel.*; import com.vci.ubcs.code.wrapper.CodeBasicSecWrapper; import com.vci.ubcs.omd.cache.EnumCache; import com.vci.ubcs.omd.enums.EnumEnum; @@ -32,11 +27,8 @@ import com.vci.ubcs.starter.util.DefaultAttrAssimtUtil; import com.vci.ubcs.starter.util.UBCSCondition; import com.vci.ubcs.starter.util.UBCSSqlKeyword; -import com.vci.ubcs.starter.web.enumpck.NewAppConstantEnum; import com.vci.ubcs.starter.web.enumpck.OsCodeFillTypeEnum; -import com.vci.ubcs.starter.web.pagemodel.BladeQueryObject; -import com.vci.ubcs.starter.web.pagemodel.KeyValue; -import com.vci.ubcs.starter.web.pagemodel.UIFormReferVO; +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.WebUtil; @@ -44,10 +36,9 @@ import com.vci.ubcs.system.feign.IDictBizClient; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.support.Query; -import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.Func; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -131,9 +122,11 @@ MPJLambdaWrapper<CodeBasicSec> mpjLambdaWrapper = new MPJLambdaWrapper<>(CodeBasicSec.class, CodeTableNameEnum.PL_CODE_BASICSEC.getText()) .selectAll(CodeBasicSec.class) .selectAs(CodeClassify::getName, CodeBasicSec::getReferCodeClassifyOidName) - .leftJoin(CodeClassify.class,CodeTableNameEnum.PL_CODE_CLASSIFY.getText(), CodeClassify::getOid, CodeBasicSec::getReferCodeClassifyOid); + .leftJoin(CodeClassify.class, CodeTableNameEnum.PL_CODE_CLASSIFY.getText(), CodeClassify::getOid, CodeBasicSec::getReferCodeClassifyOid) + .leftJoin(CodeBasicSec.class,CodeTableNameEnum.PL_CODE_BASICSEC.getText()+1,CodeBasicSec::getOid,CodeBasicSec::getParentClassifySecOid + ,ext->ext.selectAs(CodeBasicSec::getName,CodeBasicSec::getParentClassifySecText)); // 娣诲姞where鏉′欢 - UBCSSqlKeyword.buildCondition(conditionMap,mpjLambdaWrapper); + UBCSSqlKeyword.buildConditionByAs(conditionMap,mpjLambdaWrapper,CodeTableNameEnum.PL_CODE_BASICSEC.getText()); IPage<CodeBasicSec> codeBasicSecIPage = codeBasicSecMapper.selectPage(UBCSCondition.getPage(query), mpjLambdaWrapper); return CodeBasicSecWrapper.build().pageVO(codeBasicSecIPage); } @@ -163,8 +156,10 @@ Set<String> fixedSecOidSet = fixedSecList.stream().map(CodeBasicSec::getOid).collect(Collectors.toSet()); // 閫氳繃澶栭敭杩涜鏌ヨ List<CodeFixedValue> fixedValueS = fixedValueMapper.selectList(Wrappers.<CodeFixedValue>query().lambda().in(CodeFixedValue::getCodeFixedSecOid,fixedSecOidSet)); - // 鏍规嵁鏌ヨ鍑烘潵鐨刬d鎵ц鍥哄畾鐮佹鎵ц鍒犻櫎 - deletFlag = fixedValueMapper.deleteBatchIds(fixedValueS.stream().map(CodeFixedValue::getOid).collect(Collectors.toSet()))>0; + if(!fixedValueS.isEmpty()){ + // 鏍规嵁鏌ヨ鍑烘潵鐨刬d鎵ц鍥哄畾鐮佹鎵ц鍒犻櫎 + deletFlag = fixedValueMapper.deleteBatchIds(fixedValueS.stream().map(CodeFixedValue::getOid).collect(Collectors.toSet()))>0; + } } // 4銆佸啀鍒犻櫎鍒嗙被鐮佹 List<CodeBasicSec> classifySecList = deleteList.stream().filter(sec -> { @@ -175,8 +170,10 @@ Set<String> classifySecOidSet = classifySecList.stream().map(CodeBasicSec::getOid).collect(Collectors.toSet()); // 閫氳繃澶栭敭杩涜鏌ヨ List<CodeClassifyValue> fixedValueS = codeClassifyValueMapper.selectList(Wrappers.<CodeClassifyValue>query().lambda().in(CodeClassifyValue::getCodeClassifySecOid,classifySecOidSet)); - // 鏍规嵁鏌ヨ鍑烘潵鐨勪富閿甶d鎵ц鍥哄畾鐮佹鎵ц鍒犻櫎 - deletFlag = fixedValueMapper.deleteBatchIds(fixedValueS.stream().map(CodeClassifyValue::getOid).collect(Collectors.toSet()))>0; + if(!fixedValueS.isEmpty()){ + // 鏍规嵁鏌ヨ鍑烘潵鐨勪富閿甶d鎵ц鍥哄畾鐮佹鎵ц鍒犻櫎 + deletFlag = fixedValueMapper.deleteBatchIds(fixedValueS.stream().map(CodeClassifyValue::getOid).collect(Collectors.toSet()))>0; + } } return deletFlag; } @@ -259,16 +256,17 @@ //寮曠敤鐮佹鐨勬椂鍊欙紝闇�瑕佸垽鏂弬鐓х殑淇℃伅鏄惁姝g‘ if(CodeSecTypeEnum.CODE_REFER_SEC.getValue().equalsIgnoreCase(codeBasicSecDO.getSecType())){ if(StringUtils.isBlank(codeBasicSecDO.getReferConfig())){ - throw new VciBaseException("寮曠敤鐮佹鐨勬椂鍊欙紝闇�瑕佸~鍐� 鍙傜収閰嶇疆 鐨勫唴瀹�"); + throw new VciBaseException("寮曠敤鐮佹鐨勬椂鍊欙紝闇�瑕佸~鍐� 鍙傜収閰嶇疆鐨勫唴瀹�"); } try{ //JSONObject.parseObject(codeBasicSecDO.getReferConfig(), UIFormReferVO.class); codeReferConfigVO = JSONObject.parseObject(codeBasicSecDO.getReferConfig(), CodeReferConfigVO.class); // 灏嗗弬鐓ч厤缃繘琛屾寔涔呭寲锛岀粰鐢ㄦ埛鎻愪緵鍙彲閫夋嫨鍙傜収閰嶇疆鐨勬柟寮� - }catch (Throwable e){ throw new VciBaseException("寮曠敤鐮佹鐨勬椂鍊欙紝鍙傜収閰嶇疆鐨勫唴瀹圭殑鏍煎紡涓嶆纭�,",new String[0],e); } + // 鍒ゆ柇鏄惁涓哄紩鐢ㄧ爜娈碉紝濡傛灉鏄簲鐢ㄧ爜娈电殑璇濓紝涓轰簡閫傞厤鍓嶇缁勪欢锛岃繖閲岃瀵硅〃杩涜澶勭悊涓�涓嬶紝鎸夌収浠ュ墠鐨勫弬鐓ф牸寮忚繘琛岃浆鎹� + codeBasicSecDO.setReferValueInfo(referConfigToUIUiTable(codeReferConfigVO)); if(codeReferConfigVO.getIsPersistence()=="true"){ codeReferConfigService.insert(codeReferConfigVO); } @@ -277,14 +275,59 @@ //SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo(); if(StringUtils.isNotBlank(codeBasicSecDO.getCodeFillSeparator())){ DictBiz dictBiz = new DictBiz(); - dictBiz.setCode(MdmBtmTypeConstant.CODE_BASIC_SEC); - dictBiz.setDictKey("codefileseparator"); + dictBiz.setCode("codeFillSeparator"); + dictBiz.setDictKey(codeBasicSecDO.getCodeFillSeparator()); dictBiz.setDictValue(codeBasicSecDO.getCodeFillSeparator()); //浠庡師鏉ョ殑charService锛堝彲杈撳彲閫夛級鏇存敼涓鸿皟鐢╫md涓殑鎺ュ彛鏉ュ疄鐜� iDictBizClient.getCheck(dictBiz); //charService.save(MdmBtmTypeConstant.CODE_BASIC_SEC,"codefileseparator",codeBasicSecDO.getCodeFillSeparator(),sessionInfo); } return resBoolean; + } + + /** + * 灏唕eferconfig杞崲涓篔SON鏍煎紡鐨刄IFormReferVO + * @param codeReferConfig + * @return + */ + private String referConfigToUIUiTable(CodeReferConfigVO codeReferConfig){ + // 鎷疯礉涓轰互鍓嶇殑鑰佸璞� + UIReferConfigFormVO uiFormReferVO = new UIReferConfigFormVO(); + BeanUtil.copy(codeReferConfig,uiFormReferVO); + + // 琛ㄦ牸鐨勮嚜瀹氫箟瀹氫箟 + UITableConfigVO uiTableConfigVO = new UITableConfigVO(); + uiTableConfigVO.setPage(new UITablePageVO(codeReferConfig.getLimit(),1)); + // 鍒楄〃鐨勫垪鐨勪俊鎭浆鎹� + List<TableColVO> uiTableFieldVOs = new ArrayList<>(); + // 蹇�熸煡璇㈠垪 + List<TableColVO> queryColumns = new ArrayList<>(); + if(!CollectionUtils.isEmpty(codeReferConfig.getCodeShowFieldConfigVOS())){ + codeReferConfig.getCodeShowFieldConfigVOS().stream().forEach(showField ->{ + TableColVO tableColVO = new TableColVO(); + BeanUtil.copy(showField,tableColVO); + tableColVO.setSortField(showField.getAttrSortField()); + uiTableFieldVOs.add(tableColVO); + if(showField.getIsQuery().equals("true")){ + queryColumns.add(tableColVO); + } + }); + } + // 鏄剧ず鐨勫垪 + uiTableConfigVO.setCols(uiTableFieldVOs); + // 蹇�熸煡璇㈠垪 + uiTableConfigVO.setQueryColumns(queryColumns); + //set缁欒〃鏍奸厤缃睘鎬� + uiFormReferVO.setTableConfig(uiTableConfigVO); + // 绛涢�夋潯浠� + HashMap<String, String> whereMap = new HashMap<>(); + if(!codeReferConfig.getCodeSrchCondConfigVOS().isEmpty()){ + codeReferConfig.getCodeSrchCondConfigVOS().stream().forEach(srch->{ + whereMap.put(srch.getFilterField()+srch.getFilterType(),srch.getFilterValue()); + }); + } + uiFormReferVO.setWhere(whereMap); + return JSONObject.toJSONString(uiFormReferVO); } /** @@ -317,25 +360,31 @@ && StringUtils.isBlank(codeBasicSecDO.getCodeFillSeparator())){ throw new VciBaseException("褰撹ˉ浣嶆柟寮忎负宸﹁ˉ浣嶆垨鑰呭彸琛ヤ綅鐨勬椂鍊欙紝琛ヤ綅瀛楃涓嶈兘涓虹┖"); } + CodeReferConfigVO codeReferConfigVO = null; //寮曠敤鐮佹鐨勬椂鍊欙紝闇�瑕佸垽鏂弬鐓х殑淇℃伅鏄惁姝g‘ if(CodeSecTypeEnum.CODE_REFER_SEC.getValue().equalsIgnoreCase(codeBasicSecDO.getSecType())){ if(StringUtils.isBlank(codeBasicSecDO.getReferConfig())){ - throw new VciBaseException("寮曠敤鐮佹鐨勬椂鍊欙紝闇�瑕佸~鍐� 鍙傜収閰嶇疆 鐨勫唴瀹�"); + throw new VciBaseException("寮曠敤鐮佹鐨勬椂鍊欙紝闇�瑕佸~鍐欏弬鐓ч厤缃殑鍐呭"); } try{ - JSONObject.parseObject(codeBasicSecDO.getReferConfig(), UIFormReferVO.class); + // JSONObject.parseObject(codeBasicSecDO.getReferConfig(), UIFormReferVO.class); + codeReferConfigVO = JSONObject.parseObject(codeBasicSecDO.getReferConfig(), CodeReferConfigVO.class); }catch (Throwable e){ throw new VciBaseException("寮曠敤鐮佹鐨勬椂鍊欙紝鍙傜収閰嶇疆鐨勫唴瀹圭殑鏍煎紡涓嶆纭�,",new String[0],e); + } + // 鍒ゆ柇鏄惁涓哄紩鐢ㄧ爜娈碉紝濡傛灉鏄簲鐢ㄧ爜娈电殑璇濓紝涓轰簡閫傞厤鍓嶇缁勪欢锛岃繖閲岃瀵硅〃杩涜澶勭悊涓�涓嬶紝鎸夌収浠ュ墠鐨勫弬鐓ф牸寮忚繘琛岃浆鎹� + codeBasicSecDO.setReferValueInfo(referConfigToUIUiTable(codeReferConfigVO)); + if(codeReferConfigVO.getIsPersistence()=="true"){ + codeReferConfigService.insert(codeReferConfigVO); } } revisionModelUtil.copyFromDTOIgnore(codeBasicSecDTO, codeBasicSecDO); resBoolean = codeBasicSecMapper.updateById(codeBasicSecDO)>0; //SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo(); if(StringUtils.isNotBlank(codeBasicSecDO.getCodeFillSeparator())){ - //杩欏効鐩墠闇�瑕佹敼 2023/4/24 DictBiz dictBiz = new DictBiz(); - dictBiz.setCode(MdmBtmTypeConstant.CODE_BASIC_SEC); - dictBiz.setDictKey("codefileseparator"); + dictBiz.setCode("codeFillSeparator"); + dictBiz.setDictKey(codeBasicSecDO.getCodeFillSeparator()); dictBiz.setDictValue(codeBasicSecDO.getCodeFillSeparator()); //浠庡師鏉ョ殑charService锛堝彲杈撳彲閫夛級鏇存敼涓鸿皟鐢╫md涓殑鎺ュ彛鏉ュ疄鐜� iDictBizClient.getCheck(dictBiz); @@ -489,7 +538,7 @@ return null; } conditionMap.put("secType",(CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue())); - return refDataGridCodeBasicSec(query.setAscs("ordernum"),conditionMap); + return refDataGridCodeBasicSec(query.setAscs("orderNum"),conditionMap); } /** @@ -508,20 +557,23 @@ } List<CodeBasicSec> createList = new ArrayList<>(); List<CodeBasicSec> basicSecDOS = codeBasicSecMapper.selectBatchIds(oidList); + if(basicSecDOS.isEmpty()){ + return R.fail("鍏嬮殕鐨勭爜娈典俊鎭笉瀛樺湪锛�"); + } basicSecDOS.forEach(sec -> { CodeBasicSec newSecDO = new CodeBasicSec(); BeanUtilForVCI.copyPropertiesIgnoreCase(sec,newSecDO); - newSecDO.setOid(""); - newSecDO.setNameOid(""); - newSecDO.setRevisionOid(""); + newSecDO.setOid(VciBaseUtil.getPk()); + newSecDO.setNameOid(VciBaseUtil.getPk()); + newSecDO.setRevisionOid(VciBaseUtil.getPk()); newSecDO.setId(newSecDO.getId() + "_copy"); newSecDO.setName(newSecDO.getName() + "_copy"); newSecDO.setPkCodeRule(pkCodeRule); createList.add(newSecDO); }); - boolean b = saveBatch(createList); + boolean resBoolean = saveBatch(createList); //codeBasicSecMapper.insertBatch(createList); - return R.data(b,"鍏嬮殕鐮佹淇℃伅鎴愬姛"); + return resBoolean ? R.data(resBoolean,"鍏嬮殕鐮佹淇℃伅鎴愬姛"):R.fail("鍏嬮殕鐮佹淇℃伅澶辫触锛�"); } /** @@ -700,7 +752,6 @@ return codeBasicSecDO; } - /** * 浣跨敤瑙勫垯鐨勪富閿幏鍙栧搴旂殑鐮佹鍐呭 * @@ -712,14 +763,10 @@ if(StringUtils.isBlank(ruleOid)){ return new ArrayList<>(); } -// Map<String,String> conditionMap = new HashMap<>(); -// conditionMap.put("pkCodeRule",ruleOid); -// PageHelper pageHelper = new PageHelper(-1); -// pageHelper.addDefaultAsc("ordernum"); - QueryWrapper<CodeBasicSec> wrapper = new QueryWrapper<>(); - wrapper.eq("pkCodeRule",ruleOid); - wrapper.orderByAsc("ordernum"); - List<CodeBasicSec> secDOList = baseMapper.selectList(wrapper);//.selectByCondition(conditionMap, pageHelper); + LambdaQueryWrapper<CodeBasicSec> wrapper = Wrappers.<CodeBasicSec>query().lambda() + .eq(CodeBasicSec::getPkCodeRule, ruleOid) + .orderByAsc(CodeBasicSec::getOrderNum); + List<CodeBasicSec> secDOList = baseMapper.selectList(wrapper);// return codeBasicSecDO2VOs(secDOList,true); } @@ -787,18 +834,31 @@ public CodeBasicSecVO codeBasicSecDO2VO(CodeBasicSec codeBasicSecDO) throws VciBaseException { CodeBasicSecVO codeBasicSecVO = new CodeBasicSecVO(); if (codeBasicSecDO != null) { - BeanUtilForVCI.copyPropertiesIgnoreCase(codeBasicSecVO, codeBasicSecVO); - codeBasicSecVO.setSecTypeText(CodeSecTypeEnum.getTextByValue(codeBasicSecVO.getSecType())); - codeBasicSecVO.setCodeLevelTypeText(CodeLevelTypeEnum.getTextByValue(codeBasicSecVO.getCodeLevelType())); - codeBasicSecVO.setCodeSecLengthTypeText(CodeSecLengthTypeEnum.getTextByValue(codeBasicSecVO.getCodeSecLengthType())); - codeBasicSecVO.setValueCutTypeText(CodeCutTypeEnum.getValueByText(codeBasicSecVO.getValueCutType())); - codeBasicSecVO.setCodeGetValueTypeText(CodeGetValueTypeEnum.getValueByText(codeBasicSecVO.getCodeGetValueType())); + BeanUtilForVCI.copyPropertiesIgnoreCase(codeBasicSecDO, codeBasicSecVO); + if(StringUtils.isNotBlank(codeBasicSecDO.getSecType())){ + codeBasicSecVO.setSecTypeText(EnumCache.getValue(EnumEnum.CODE_SEC_TYPE,codeBasicSecDO.getSecType())); + } + if(StringUtils.isNotBlank(codeBasicSecDO.getCodeLevelType())){ + codeBasicSecVO.setCodeLevelTypeText(EnumCache.getValue(EnumEnum.CODE_LEVEL_TYPE,codeBasicSecDO.getCodeLevelType())); + } + if(StringUtils.isNotBlank(codeBasicSecDO.getCodeSecLengthType())){ + codeBasicSecVO.setCodeSecLengthTypeText(EnumCache.getValue(EnumEnum.CODE_SEC_LENGTH,codeBasicSecDO.getCodeSecLengthType())); + } + if(StringUtils.isNotBlank(codeBasicSecDO.getValueCutType())){ + codeBasicSecVO.setValueCutTypeText(EnumCache.getValue(EnumEnum.CODE_CUT_TYPE,codeBasicSecDO.getValueCutType())); + } + if(StringUtils.isNotBlank(codeBasicSecDO.getCodeGetValueType())){ + codeBasicSecVO.setCodeGetValueTypeText(EnumCache.getValue(EnumEnum.CODE_GET_VALUE_TYPE,codeBasicSecDO.getCodeGetValueType())); + } // 濡傛灉鏄垎绫荤爜娈甸渶瑕佹煡璇㈡墍灞炲垎绫荤殑涓枃鍚嶇О if(codeBasicSecDO.getSecType().equals("codeclassifysec") && Func.isNotEmpty(codeBasicSecDO.getParentClassifySecOid())){ CodeBasicSec codeBasicSec = codeBasicSecMapper.selectOne(Wrappers.<CodeBasicSec>query().lambda() .eq(CodeBasicSec::getOid, codeBasicSecDO.getParentClassifySecOid()) .eq(CodeBasicSec::getSecType, codeBasicSecDO.getSecType())); - codeBasicSecVO.setParentClassifySecText(codeBasicSec.getName()); + if(Func.isNotEmpty(codeBasicSec)){ + codeBasicSecVO.setParentClassifySecOid(codeBasicSec.getOid()); + codeBasicSecVO.setParentClassifySecText(codeBasicSec.getName()); + } } //濡傛灉鏈塴cstatus鐨勭被鐨勮瘽 if (true) { @@ -807,4 +867,5 @@ } return codeBasicSecVO; } + } -- Gitblit v1.9.3