| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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.*; |
| | | |
| | | /** |
| | | * 码段基础信息服务接口 |
| | |
| | | */ |
| | | @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) { |
| | |
| | | //将DTO转换为DO |
| | | 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() |
| | |
| | | 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()); |
| | |
| | | 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()); |
| | |
| | | * @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); |
| | | } |
| | | |
| | | /** |
| | |
| | | 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); |
| | | } |
| | | |
| | |
| | | @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() |
| | |
| | | ); |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | |
| | | @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; |
| | | } |
| | | |
| | | /** |