From 7ff176bf622d6a4bad0fb2bdf92f11a79f0dd24a Mon Sep 17 00:00:00 2001 From: ludc Date: 星期四, 04 五月 2023 14:17:49 +0800 Subject: [PATCH] 增加弹窗界面,整合代码 --- Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeBasicSecServiceImpl.java | 146 ++++++++++++++++++++++++++++++++++-------------- 1 files changed, 104 insertions(+), 42 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 cd84de8..cab8c88 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 @@ -8,9 +8,10 @@ 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.enumpack.CodeSecTypeEnum; +import com.vci.ubcs.code.enumpack.*; import com.vci.ubcs.code.lifecycle.CodeRuleLC; import com.vci.ubcs.code.mapper.CodeBasicSecMapper; import com.vci.ubcs.code.mapper.CodeClassifyValueMapper; @@ -21,16 +22,17 @@ import com.vci.ubcs.code.vo.pagemodel.CodeBasicSecVO; import com.vci.ubcs.code.vo.pagemodel.CodeRuleVO; import com.vci.ubcs.code.wrapper.CodeBasicSecWrapper; -import com.vci.ubcs.com.vci.starter.exception.VciBaseException; -import com.vci.ubcs.com.vci.starter.revision.service.RevisionModelUtil; -import com.vci.ubcs.com.vci.starter.web.enumpck.OsCodeFillTypeEnum; -import com.vci.ubcs.com.vci.starter.web.pagemodel.KeyValue; -import com.vci.ubcs.com.vci.starter.web.pagemodel.UIFormReferVO; -import com.vci.ubcs.com.vci.starter.web.util.BeanUtilForVCI; -import com.vci.ubcs.com.vci.starter.web.util.VciBaseUtil; -import com.vci.ubcs.com.vci.starter.web.util.WebUtil; -import com.vci.ubcs.omd.entity.DictBizM; -import com.vci.ubcs.omd.feign.IDictBizClient; +import com.vci.ubcs.starter.exception.VciBaseException; +import com.vci.ubcs.starter.revision.service.RevisionModelUtil; +import com.vci.ubcs.starter.web.enumpck.OsCodeFillTypeEnum; +import com.vci.ubcs.starter.web.pagemodel.KeyValue; +import com.vci.ubcs.starter.web.pagemodel.UIFormReferVO; +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.entity.DictBiz; +import com.vci.ubcs.system.feign.IDictBizClient; +import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springframework.context.annotation.Lazy; @@ -42,7 +44,7 @@ import java.util.*; import java.util.stream.Collectors; -import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.DATA_OID_NOT_EXIST; +import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.*; /** * 鐮佹鍩虹淇℃伅鏈嶅姟鎺ュ彛 @@ -122,8 +124,12 @@ if (CollectionUtils.isEmpty(deleteList)){ return true; } + boolean deletFlag = false; // 2銆佸啀鍒犻櫎鍩虹鐮佹 - boolean deletFlag = codeBasicSecMapper.deleteBatchIds(deleteList.stream().map(CodeBasicSec::getOid).collect(Collectors.toSet())) > 0; + Set<String> basicOids = deleteList.stream().map(CodeBasicSec::getOid).collect(Collectors.toSet()); + if(basicOids.size()>0 || !Func.isEmpty(basicOids)){ + deletFlag = codeBasicSecMapper.deleteBatchIds(basicOids) > 0; + } // 3銆佸啀鏍规嵁鍒犻櫎鍥哄畾鐮佹锛屼笡鏌ヨ鍑烘潵鐨勫熀纭�鐮佹涓繃婊ゅ嚭鍖呭惈鍥哄畾鐮佹鐨勮褰� List<CodeBasicSec> fixedSecList = deleteList.stream().filter(sec -> { return CodeSecTypeEnum.CODE_FIXED_SEC.getValue().equals(sec.getSecType()); @@ -133,8 +139,11 @@ 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; + Set<String> collectOid = fixedValueS.stream().map(CodeFixedValue::getOid).collect(Collectors.toSet()); + if(collectOid.size()>0 || !Func.isEmpty(collectOid)){ + // 鏍规嵁鏌ヨ鍑烘潵鐨刬d鎵ц鍥哄畾鐮佹鎵ц鍒犻櫎 + fixedValueMapper.deleteBatchIds(collectOid); + } } // 4銆佸啀鍒犻櫎鍒嗙被鐮佹 List<CodeBasicSec> classifySecList = deleteList.stream().filter(sec -> { @@ -144,9 +153,12 @@ // 灏嗚浣滀负鍒犻櫎鏉′欢鐨勫�兼斁鍦ㄤ竴涓泦鍚堥噷闈� Set<String> classifySecOidSet = classifySecList.stream().map(CodeBasicSec::getOid).collect(Collectors.toSet()); // 閫氳繃澶栭敭杩涜鏌ヨ - List<CodeClassifyValue> fixedValueS = codeClassifyValueMapper.selectList(Wrappers.<CodeClassifyValue>query().lambda().in(CodeClassifyValue::getCodeClassifySecOid,classifySecOidSet)); + List<CodeClassifyValue> classifyValues = codeClassifyValueMapper.selectList(Wrappers.<CodeClassifyValue>query().lambda().in(CodeClassifyValue::getCodeClassifySecOid,classifySecOidSet)); // 鏍规嵁鏌ヨ鍑烘潵鐨勪富閿甶d鎵ц鍥哄畾鐮佹鎵ц鍒犻櫎 - deletFlag = fixedValueMapper.deleteBatchIds(fixedValueS.stream().map(CodeClassifyValue::getOid).collect(Collectors.toSet()))>0; + Set<String> codeclassifyOids = classifyValues.stream().map(CodeClassifyValue::getOid).collect(Collectors.toSet()); + if(codeclassifyOids.size()>0 || !Func.isEmpty(codeclassifyOids)){ + fixedValueMapper.deleteBatchIds(codeclassifyOids); + } } return deletFlag; } @@ -159,8 +171,8 @@ */ @Override public KeyValue checkAttrNullableBySecType(CodeBasicSecDTO codeBasicSecDTO) { - VciBaseUtil.alertNotNull(codeBasicSecDTO.getSectype(), "鐮佹鍒嗙被"); - String secType = codeBasicSecDTO.getSectype(); + VciBaseUtil.alertNotNull(codeBasicSecDTO.getSecType(), "鐮佹鍒嗙被"); + String secType = codeBasicSecDTO.getSecType(); HashMap<String, String> attrMap = JSONObject.parseObject(JSONObject.toJSONString(codeBasicSecDTO), HashMap.class); Map<String, String> notNullableAttr = getNotNullableAttr(secType); if (notNullableAttr == null) { @@ -203,6 +215,22 @@ //灏咲TO杞崲涓篋O CodeBasicSec codeBasicSecDO = new CodeBasicSec(); BeanUtilForVCI.copyPropertiesIgnoreCase(codeBasicSecDTO, codeBasicSecDO); + //text杞崲 + codeBasicSecDO.setSecTypeText(CodeSecTypeEnum.getTextByValue(codeBasicSecDTO.getSecType())); + codeBasicSecDO.setCodeLevelTypeText(CodeLevelTypeEnum.getTextByValue(codeBasicSecDTO.getCodeLevelType())); + codeBasicSecDO.setCodeSecLengthTypeText(CodeSecLengthTypeEnum.getTextByValue(codeBasicSecDTO.getCodeSecLengthType())); + codeBasicSecDO.setValueCutTypeText(CodeCutTypeEnum.getValueByText(codeBasicSecDTO.getValueCutType())); + codeBasicSecDO.setCodeGetValueTypeText(CodeGetValueTypeEnum.getValueByText(codeBasicSecDTO.getCodeGetValueType())); + //濉厖涓�浜涢粯璁ゅ�� + codeBasicSecDO.setOid(VciBaseUtil.getPk()); + codeBasicSecDO.setRevisionOid(VciBaseUtil.getPk()); + codeBasicSecDO.setNameOid(VciBaseUtil.getPk()); + codeBasicSecDO.setBtmname(MdmBtmTypeConstant.CODE_BASIC_SEC); + codeBasicSecDO.setTs(new Date()); + codeBasicSecDO.setCreateTime(new Date()); + codeBasicSecDO.setCreator(AuthUtil.getUserId().toString()); + codeBasicSecDO.setLastModifier(AuthUtil.getUserId().toString()); + codeBasicSecDO.setLastModifyTime(new Date()); //鎺掑簭鍙凤紝榛樿绛変簬褰撳墠宸叉湁鐨勬暟閲忓姞1 Long total = codeBasicSecMapper.selectCount(Wrappers.<CodeBasicSec>query() .lambda() @@ -232,7 +260,7 @@ boolean resBoolean = codeBasicSecMapper.insert(codeBasicSecDO) > 0; //SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo(); if(StringUtils.isNotBlank(codeBasicSecDO.getCodeFillSeparator())){ - DictBizM dictBiz = new DictBizM(); + DictBiz dictBiz = new DictBiz(); dictBiz.setCode(MdmBtmTypeConstant.CODE_BASIC_SEC); dictBiz.setDictKey("codefileseparator"); dictBiz.setDictValue(codeBasicSecDO.getCodeFillSeparator()); @@ -287,7 +315,8 @@ resBoolean = codeBasicSecMapper.updateById(codeBasicSecDO)>0; //SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo(); if(StringUtils.isNotBlank(codeBasicSecDO.getCodeFillSeparator())){ - DictBizM dictBiz = new DictBizM(); + //杩欏効鐩墠闇�瑕佹敼 2023/4/24 + DictBiz dictBiz = new DictBiz(); dictBiz.setCode(MdmBtmTypeConstant.CODE_BASIC_SEC); dictBiz.setDictKey("codefileseparator"); dictBiz.setDictValue(codeBasicSecDO.getCodeFillSeparator()); @@ -350,9 +379,46 @@ * @throws VciBaseException 鍙傛暟涓虹┖锛岃寮曠敤鏃舵姏鍑哄紓甯� */ @Override - public boolean deleteCodeBasicSec(CodeBasicSecDTO codeBasicSecDTO) throws VciBaseException { + public R deleteCodeBasicSec(CodeBasicSecDTO codeBasicSecDTO) throws VciBaseException { VciBaseUtil.alertNotNull(codeBasicSecDTO, "鐮佹鍩虹淇℃伅鏁版嵁瀵硅薄", codeBasicSecDTO.getOid(), "鐮佹鍩虹淇℃伅鐨勪富閿�"); - return this.codeBasicSecMapper.deleteById(codeBasicSecDTO.getOid())>0; + return this.deleteCodeBasicSecByPrimaryKey(codeBasicSecDTO.getOid()); + } + + /** + * 涓婚敭鍒犻櫎鐮佹鍩虹淇℃伅 + * + * @param oid 鐮佹鍩虹淇℃伅涓婚敭 + * @return 鍒犻櫎缁撴灉鍙嶉锛氾細success锛氭垚鍔燂紝fail锛氬け璐� + * @throws VciBaseException 鍙傛暟涓虹┖锛岃寮曠敤鏃舵姏鍑哄紓甯� + */ + @Override + @Transactional(rollbackFor = Exception.class) + public R deleteCodeBasicSecByPrimaryKey(String oid) throws VciBaseException { + CodeBasicSec codeBasicSecDO = selectByOid(oid); + boolean isLinked = checkIsLinked(codeBasicSecDO.getPkCodeRule(), oid); + if (isLinked) { + return R.fail("缂栫爜瑙勫垯宸茶寮曠敤锛屼笉鍏佽缂栬緫鎴栧垹闄�"); + } + //鎵ц鍒犻櫎鎿嶄綔 + boolean eftDeleteBasic = codeBasicSecMapper.deleteById(oid) > 0; + if (CodeSecTypeEnum.CODE_FIXED_SEC.getValue().equals(codeBasicSecDO.getSecType())){ + List<CodeFixedValue> fixedValueDOS = fixedValueMapper.selectList(Wrappers.<CodeFixedValue>query() + .lambda().eq(CodeFixedValue::getCodeFixedSecOid,codeBasicSecDO.getOid()) + ); + if(!CollectionUtils.isEmpty(fixedValueDOS)){ + fixedValueMapper.deleteBatchIds(fixedValueDOS.stream().map(CodeFixedValue::getOid).collect(Collectors.toSet())); + } + } + if (CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue().equals(codeBasicSecDO.getSecType())){ + List<CodeClassifyValue> classifyValueDOS = codeClassifyValueMapper.selectList(Wrappers.<CodeClassifyValue>query() + .lambda().eq(CodeClassifyValue::getCodeClassifySecOid,codeBasicSecDO.getOid()) + ); + if(!CollectionUtils.isEmpty(classifyValueDOS)) { + codeClassifyValueMapper.deleteBatchIds(classifyValueDOS.stream().map(CodeClassifyValue::getOid).collect(Collectors.toSet())); + } + } + + return eftDeleteBasic ? R.success(DELETE_SUCCESS) : R.fail(DELETE_FAIL); } /** @@ -405,7 +471,7 @@ if(Func.isEmpty(codeBasicSecVO.getPkCodeRule()) || Func.isBlank(codeBasicSecVO.getPkCodeRule())){ return null; } - codeBasicSecVO.setSectype(CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue()); + codeBasicSecVO.setSecType(CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue()); return refDataGridCodeBasicSec(page,codeBasicSecVO); } @@ -484,9 +550,7 @@ @Transactional(rollbackFor = Exception.class) public boolean upOrderNum(String oid) { CodeBasicSec secDO = selectByOid(oid); - boolean resUpBoolean = false; - boolean resDownBoolean = false; - if(secDO.getOrderNum() >1){ + if(secDO.getOrderNum() > 1){ //绛変簬1鐨勬椂鍊欎笉鑳戒笂绉讳簡 //鎵炬瘮鑷繁灏忕殑 List<CodeBasicSec> lastSecDOs = codeBasicSecMapper.selectList(Wrappers.<CodeBasicSec>query() @@ -495,18 +559,17 @@ ); if(!CollectionUtils.isEmpty(lastSecDOs)){ CodeBasicSec lastSec = lastSecDOs.get(0); - resDownBoolean = codeBasicSecMapper.update(null, Wrappers.<CodeBasicSec>update() + codeBasicSecMapper.update(null, Wrappers.<CodeBasicSec>update() .lambda().set(CodeBasicSec::getOrderNum, lastSec.getOrderNum() + 1) .eq(CodeBasicSec::getOid, lastSec.getOid()) - ) > 0; + ); } - secDO.setOrderNum(secDO.getOrderNum()-1); - resUpBoolean = codeBasicSecMapper.update(null, Wrappers.<CodeBasicSec>update() + codeBasicSecMapper.update(null, Wrappers.<CodeBasicSec>update() .lambda().set(CodeBasicSec::getOrderNum, secDO.getOrderNum() - 1) .eq(CodeBasicSec::getOid, secDO.getOid()) - ) > 0; + ); } - return resDownBoolean && resUpBoolean; + return true; } /** @@ -518,29 +581,28 @@ @Transactional(rollbackFor = Exception.class) public boolean downOrderNum(String oid) { CodeBasicSec secDO = selectByOid(oid); - boolean resUpBoolean = false; - boolean resDownBoolean = false; Long total = codeBasicSecMapper.selectCount(Wrappers.<CodeBasicSec>query() .lambda().eq(CodeBasicSec::getPkCodeRule,secDO.getPkCodeRule()) ); - if(secDO.getOrderNum() < total){ + if(secDO.getOrderNum() < total){ //灏忎簬鎬绘暟鐨勬椂鍊欐墠涓嬬Щ List<CodeBasicSec> lastSecDOs = codeBasicSecMapper.selectList(Wrappers.<CodeBasicSec>query() - .lambda().eq(CodeBasicSec::getOrderNum,String.valueOf(secDO.getOrderNum()+1)) + .lambda().eq(CodeBasicSec::getOrderNum,secDO.getOrderNum()+1) + .eq(CodeBasicSec::getPkCodeRule,secDO.getPkCodeRule()) ); if(!CollectionUtils.isEmpty(lastSecDOs)){ CodeBasicSec lastSec = lastSecDOs.get(0); - resUpBoolean = codeBasicSecMapper.update(null, Wrappers.<CodeBasicSec>update() + codeBasicSecMapper.update(null, Wrappers.<CodeBasicSec>update() .lambda().set(CodeBasicSec::getOrderNum, lastSec.getOrderNum() - 1) .eq(CodeBasicSec::getOid, lastSec.getOid()) - ) > 0; + ); } - resDownBoolean = codeBasicSecMapper.update(null, Wrappers.<CodeBasicSec>update() + codeBasicSecMapper.update(null, Wrappers.<CodeBasicSec>update() .lambda().set(CodeBasicSec::getOrderNum, secDO.getOrderNum() + 1) .eq(CodeBasicSec::getOid, secDO.getOid()) - ) > 0; + ); } - return resDownBoolean && resUpBoolean; + return true; } /** -- Gitblit v1.9.3