| | |
| | | package com.vci.ubcs.code.service.impl; |
| | | |
| | | |
| | | import com.alibaba.cloud.commons.lang.StringUtils; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.vci.ubcs.code.constant.MdmBtmTypeConstant; |
| | | import com.vci.ubcs.code.dao.CodeBasicSecDaoI; |
| | | import com.vci.ubcs.code.dao.CodeClassifyValueDaoI; |
| | | import com.vci.ubcs.code.dao.CodeFixedValueDaoI; |
| | | import com.vci.ubcs.code.enumpack.CodeSecTypeEnum; |
| | | import com.vci.ubcs.code.lifecycle.CodeRuleLC; |
| | | import com.vci.ubcs.code.model.CodeBasicSecDO; |
| | | import com.vci.ubcs.code.model.CodeClassifyValueDO; |
| | | import com.vci.ubcs.code.model.CodeFixedValueDO; |
| | | import com.vci.ubcs.code.service.CodeBasicSecServiceI; |
| | | import com.vci.ubcs.code.service.CodeClassifyValueServiceI; |
| | | import com.vci.ubcs.code.service.CodeFixedValueServiceI; |
| | | import com.vci.ubcs.code.service.CodeRuleServiceI; |
| | | import com.vci.frameworkcore.lcstatuspck.FrameworkDataLCStatus; |
| | | import com.vci.starter.revision.bo.TreeWrapperOptions; |
| | | import com.vci.starter.revision.service.RevisionModelUtil; |
| | | import com.vci.starter.web.constant.QueryOptionConstant; |
| | | import com.vci.starter.web.exception.VciBaseException; |
| | | import com.vci.starter.web.pagemodel.*; |
| | | import com.vci.starter.web.util.BeanUtilForVCI; |
| | | import com.vci.starter.web.util.VciBaseUtil; |
| | | import com.vci.starter.web.wrapper.VciParentQueryOption; |
| | | import com.vci.starter.web.wrapper.VciQueryWrapperForDO; |
| | | import com.vci.web.enumpck.OsCodeFillTypeEnum; |
| | | import com.vci.web.pageModel.BatchCBO; |
| | | import com.vci.web.pageModel.UIFormReferVO; |
| | | import com.vci.web.service.BdSelectInputCharServiceI; |
| | | import com.vci.web.service.WebBoServiceI; |
| | | import com.vci.web.util.WebUtil; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | 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.*; |
| | | 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.mapper.CodeFixedValueMapper; |
| | | import com.vci.ubcs.code.service.ICodeBasicSecService; |
| | | import com.vci.ubcs.code.service.ICodeClassifyValueService; |
| | | import com.vci.ubcs.code.service.ICodeRuleService; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeBasicSecVO; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeClassifyValueVO; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeFixedValueVO; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeRuleVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import com.vci.ubcs.code.wrapper.CodeBasicSecWrapper; |
| | | 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 org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import plm.bs.bom.clientobject.ClientBusinessObject; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.concurrent.CopyOnWriteArrayList; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.vci.frameworkcore.constant.FrameWorkLangCodeConstant.*; |
| | | import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.*; |
| | | |
| | | /** |
| | | * 码段基础信息服务 |
| | | * 码段基础信息服务接口 |
| | | * |
| | | * @author weidy |
| | | * @date 2022-01-24 |
| | | */ |
| | | @Service |
| | | public class CodeBasicSecServiceImpl implements CodeBasicSecServiceI { |
| | | public class CodeBasicSecServiceImpl extends ServiceImpl<CodeBasicSecMapper, CodeBasicSec> implements ICodeBasicSecService { |
| | | |
| | | /** |
| | | * 日志 |
| | | */ |
| | | private Logger logger = LoggerFactory.getLogger(getClass()); |
| | | @Resource |
| | | private CodeBasicSecMapper codeBasicSecMapper; |
| | | |
| | | /** |
| | | * 数据操作层 |
| | | */ |
| | | @Resource |
| | | private CodeBasicSecDaoI codeBasicSecMapper; |
| | | /** |
| | | * 固定码段的码值数据操作层 |
| | | */ |
| | | @Resource |
| | | private CodeFixedValueMapper fixedValueMapper; |
| | | |
| | | /** |
| | | * 业务类型操作的服务 |
| | | */ |
| | | @Autowired |
| | | /** |
| | | * 分类码段的码值数据操作层 |
| | | */ |
| | | @Resource |
| | | private CodeClassifyValueMapper codeClassifyValueMapper; |
| | | |
| | | @Resource |
| | | private RevisionModelUtil revisionModelUtil; |
| | | |
| | | @Resource |
| | | @Lazy |
| | | private WebBoServiceI boService; |
| | | private ICodeRuleService codeRuleService; |
| | | |
| | | /** |
| | | * 对象的操作 |
| | | */ |
| | | @Autowired |
| | | private RevisionModelUtil revisionModelUtil; |
| | | @Resource |
| | | private ICodeClassifyValueService codeClassifyValueService; |
| | | |
| | | /** |
| | | * 主数据编码规则服务 |
| | | */ |
| | | @Autowired |
| | | private CodeRuleServiceI codeRuleService; |
| | | @Resource |
| | | private IDictBizClient iDictBizClient; |
| | | |
| | | /** |
| | | * 分类码段的码值服务 |
| | | */ |
| | | @Autowired |
| | | private CodeClassifyValueServiceI codeClassifyValueService; |
| | | /** |
| | | * 上层分类码段的属性名称 |
| | | */ |
| | | private static final String PARENT_FIELD_NAME = "parentclassifysecoid"; |
| | | |
| | | /** |
| | | * 分类码段的码值数据操作层 |
| | | */ |
| | | @Autowired |
| | | private CodeClassifyValueDaoI codeClassifyValueMapper; |
| | | /** |
| | | * 上级分类码值的属性名称 |
| | | */ |
| | | private static final String PARENT_CLASSIFY_VALUE_FIELD_NAME = "parentClassifyValueOid"; |
| | | |
| | | /** |
| | | * 固定码段的码值的服务 |
| | | */ |
| | | @Autowired |
| | | private CodeFixedValueServiceI fixedValueService; |
| | | /** |
| | | * 查询所有的码段基础信息 |
| | | * |
| | | * @param page 查询条件 |
| | | * @param codeBasicSecVO 分页和排序 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 查询条件和分页出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public IPage<CodeBasicSecVO> gridCodeBasicSec(IPage<CodeBasicSecVO> page, CodeBasicSecVO codeBasicSecVO) throws VciBaseException { |
| | | if(Func.isEmpty(codeBasicSecVO.getPkCodeRule()) || Func.isBlank(codeBasicSecVO.getPkCodeRule())){ |
| | | return null; |
| | | } |
| | | List<CodeBasicSec> codeBasicSecs = codeBasicSecMapper.selectCodeBasicSecPage(page, codeBasicSecVO); |
| | | return page.setRecords(CodeBasicSecWrapper.build().listVO(codeBasicSecs)); |
| | | } |
| | | |
| | | /** |
| | | * 固定码段的码值数据操作层 |
| | | */ |
| | | @Autowired |
| | | private CodeFixedValueDaoI fixedValueMapper; |
| | | /** |
| | | * 上层分类码段的属性名称 |
| | | */ |
| | | private static final String PARENT_FIELD_NAME = "parentclassifysecoid"; |
| | | /** |
| | | * 根据编码规则批量删除码段基本信息 |
| | | * @param codeRuleOid 编码规则主键 |
| | | * @return 执行结果 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean batchDeleteSecByCodeRuleOid(String codeRuleOid) { |
| | | VciBaseUtil.alertNotNull(codeRuleOid,"编码规则主键"); |
| | | // 1、通过pkcoderule作为条件,先查询要删除基础码段 |
| | | List<CodeBasicSec> deleteList = this.codeBasicSecMapper.selectList(Wrappers.<CodeBasicSec>query().eq("pkcoderule", codeRuleOid)); |
| | | if (CollectionUtils.isEmpty(deleteList)){ |
| | | return true; |
| | | } |
| | | // 2、再删除基础码段 |
| | | boolean deletFlag = codeBasicSecMapper.deleteBatchIds(deleteList.stream().map(CodeBasicSec::getOid).collect(Collectors.toSet())) > 0; |
| | | // 3、再根据删除固定码段,丛查询出来的基础码段中过滤出包含固定码段的记录 |
| | | List<CodeBasicSec> fixedSecList = deleteList.stream().filter(sec -> { |
| | | return CodeSecTypeEnum.CODE_FIXED_SEC.getValue().equals(sec.getSecType()); |
| | | }).collect(Collectors.toList()); |
| | | if (!CollectionUtils.isEmpty(fixedSecList)){ |
| | | // 将要作为删除条件的值放在一个集合里面 |
| | | Set<String> fixedSecOidSet = fixedSecList.stream().map(CodeBasicSec::getOid).collect(Collectors.toSet()); |
| | | // 通过外键进行查询 |
| | | List<CodeFixedValue> fixedValueS = fixedValueMapper.selectList(Wrappers.<CodeFixedValue>query().lambda().in(CodeFixedValue::getCodeFixedSecOid,fixedSecOidSet)); |
| | | // 根据查询出来的id执行固定码段执行删除 |
| | | deletFlag = fixedValueMapper.deleteBatchIds(fixedValueS.stream().map(CodeFixedValue::getOid).collect(Collectors.toSet()))>0; |
| | | } |
| | | // 4、再删除分类码段 |
| | | List<CodeBasicSec> classifySecList = deleteList.stream().filter(sec -> { |
| | | return CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue().equals(sec.getSecType()); |
| | | }).collect(Collectors.toList()); |
| | | if (!CollectionUtils.isEmpty(classifySecList)){ |
| | | // 将要作为删除条件的值放在一个集合里面 |
| | | Set<String> classifySecOidSet = classifySecList.stream().map(CodeBasicSec::getOid).collect(Collectors.toSet()); |
| | | // 通过外键进行查询 |
| | | List<CodeClassifyValue> fixedValueS = codeClassifyValueMapper.selectList(Wrappers.<CodeClassifyValue>query().lambda().in(CodeClassifyValue::getCodeClassifySecOid,classifySecOidSet)); |
| | | // 根据查询出来的主键id执行固定码段执行删除 |
| | | deletFlag = fixedValueMapper.deleteBatchIds(fixedValueS.stream().map(CodeClassifyValue::getOid).collect(Collectors.toSet()))>0; |
| | | } |
| | | return deletFlag; |
| | | } |
| | | |
| | | /** |
| | | * 上级分类码值的属性名称 |
| | | */ |
| | | private static final String PARENT_CLASSIFY_VALUE_FIELD_NAME = "parentClassifyValueOid"; |
| | | /** |
| | | * 根据码段分类的类型判断属性是否是空的 |
| | | * |
| | | * @param codeBasicSecDTO 码段基础信息数据传输对象 |
| | | * @return 有空的则传key-属性名 value-字段含义,没有空的则传 key-success value-true |
| | | */ |
| | | @Override |
| | | public KeyValue checkAttrNullableBySecType(CodeBasicSecDTO codeBasicSecDTO) { |
| | | 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) { |
| | | throw new VciBaseException("码段分类填写出错,请查验后重试"); |
| | | } |
| | | for (String key : notNullableAttr.keySet()) { |
| | | if (StringUtils.isBlank(WebUtil.getStringValueFromObject(attrMap.get(key)))) { |
| | | KeyValue kv = new KeyValue(); |
| | | kv.setKey(key); |
| | | kv.setValue(notNullableAttr.get(key)); |
| | | return kv; |
| | | } |
| | | } |
| | | KeyValue kv = new KeyValue(); |
| | | kv.setKey("success"); |
| | | kv.setValue("true"); |
| | | return kv; |
| | | } |
| | | |
| | | /** |
| | | * 可选可输服务 |
| | | */ |
| | | @Autowired |
| | | private BdSelectInputCharServiceI charService; |
| | | /** |
| | | * 增加码段基础信息 |
| | | * |
| | | * @param codeBasicSecDTO 码段基础信息数据传输对象 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 参数为空,唯一项,必输项不通过时会抛出异常 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean addSave(CodeBasicSecDTO codeBasicSecDTO) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(codeBasicSecDTO, "需要添加的数据对象",codeBasicSecDTO.getPkCodeRule(),"编码规则的主键"); |
| | | CodeRuleVO ruleVO = codeRuleService.getObjectByOid(codeBasicSecDTO.getPkCodeRule()); |
| | | if(!CodeRuleLC.EDITING.getValue().equalsIgnoreCase(ruleVO.getLcStatus())){ |
| | | throw new VciBaseException("编码规则的状态不是【" + CodeRuleLC.EDITING.getText() + "】!不允许修改"); |
| | | } |
| | | KeyValue attrKv = checkAttrNullableBySecType(codeBasicSecDTO); |
| | | if (! "success".equals(attrKv.getKey())){ |
| | | throw new VciBaseException(attrKv.getValue() + "不能为空"); |
| | | } |
| | | |
| | | /** |
| | | * 查询所有的码段基础信息 |
| | | * |
| | | * @param conditionMap 查询条件 |
| | | * @param pageHelper 分页和排序 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 查询条件和分页出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public DataGrid<CodeBasicSecVO> gridCodeBasicSec(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException { |
| | | if (pageHelper == null) { |
| | | pageHelper = new PageHelper(-1); |
| | | } |
| | | pageHelper.addDefaultAsc("ordernum"); |
| | | if(!conditionMap.containsKey("pkCodeRule") || StringUtils.isBlank(conditionMap.get("pkCodeRule"))){ |
| | | return new DataGrid<>(); |
| | | } |
| | | List<CodeBasicSecDO> doList = codeBasicSecMapper.selectByCondition(conditionMap, pageHelper); |
| | | DataGrid<CodeBasicSecVO> dataGrid = new DataGrid<CodeBasicSecVO>(); |
| | | if (!CollectionUtils.isEmpty(doList)) { |
| | | dataGrid.setData(codeBasicSecDO2VOs(doList)); |
| | | dataGrid.setTotal(VciBaseUtil.getInt(String.valueOf(codeBasicSecMapper.countByCondition(conditionMap)))); |
| | | } |
| | | return dataGrid; |
| | | } |
| | | //将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() |
| | | .eq(CodeBasicSec::getPkCodeRule,codeBasicSecDTO.getPkCodeRule())); |
| | | if(total == null){ |
| | | total = 0L; |
| | | } |
| | | codeBasicSecDO.setOrderNum(total.intValue() + 1); |
| | | |
| | | /** |
| | | * 批量数据对象转换为显示对象 |
| | | * |
| | | * @param codeBasicSecDOs 数据对象列表 |
| | | * @return 显示对象 |
| | | * @throws VciBaseException 参数为空或者不存在的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public List<CodeBasicSecVO> codeBasicSecDO2VOs(Collection<CodeBasicSecDO> codeBasicSecDOs) throws VciBaseException { |
| | | List<CodeBasicSecVO> voList = new ArrayList<CodeBasicSecVO>(); |
| | | if (!CollectionUtils.isEmpty(codeBasicSecDOs)) { |
| | | for (CodeBasicSecDO s : codeBasicSecDOs) { |
| | | CodeBasicSecVO vo = codeBasicSecDO2VO(s); |
| | | if (vo != null) { |
| | | voList.add(vo); |
| | | } |
| | | } |
| | | } |
| | | return voList; |
| | | } |
| | | //补位的时候,要控制补位字符 |
| | | if((OsCodeFillTypeEnum.LEFT.getValue().equalsIgnoreCase(codeBasicSecDO.getCodeFillType()) |
| | | || OsCodeFillTypeEnum.RIGHT.getValue().equalsIgnoreCase(codeBasicSecDO.getCodeFillType())) |
| | | && StringUtils.isBlank(codeBasicSecDO.getCodeFillSeparator())){ |
| | | throw new VciBaseException("当补位方式为左补位或者右补位的时候,补位字符不能为空"); |
| | | } |
| | | //引用码段的时候,需要判断参照的信息是否正确 |
| | | if(CodeSecTypeEnum.CODE_REFER_SEC.getValue().equalsIgnoreCase(codeBasicSecDO.getSecType())){ |
| | | if(StringUtils.isBlank(codeBasicSecDO.getReferConfig())){ |
| | | throw new VciBaseException("引用码段的时候,需要填写 参照配置 的内容"); |
| | | } |
| | | try{ |
| | | JSONObject.parseObject(codeBasicSecDO.getReferConfig(), UIFormReferVO.class); |
| | | }catch (Throwable e){ |
| | | throw new VciBaseException("引用码段的时候,参照配置的内容的格式不正确,",new String[0],e); |
| | | } |
| | | } |
| | | boolean resBoolean = codeBasicSecMapper.insert(codeBasicSecDO) > 0; |
| | | //SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo(); |
| | | if(StringUtils.isNotBlank(codeBasicSecDO.getCodeFillSeparator())){ |
| | | DictBiz dictBiz = new DictBiz(); |
| | | dictBiz.setCode(MdmBtmTypeConstant.CODE_BASIC_SEC); |
| | | dictBiz.setDictKey("codefileseparator"); |
| | | dictBiz.setDictValue(codeBasicSecDO.getCodeFillSeparator()); |
| | | //从原来的charService(可输可选)更改为调用omd中的接口来实现 |
| | | iDictBizClient.getCheck(dictBiz); |
| | | //charService.save(MdmBtmTypeConstant.CODE_BASIC_SEC,"codefileseparator",codeBasicSecDO.getCodeFillSeparator(),sessionInfo); |
| | | } |
| | | return resBoolean; |
| | | } |
| | | |
| | | /** |
| | | * 批量数据对象转换为显示对象 |
| | | * |
| | | * @param codeBasicSecDOs 数据对象列表 |
| | | * @param hasFixedValue 是否有固定值 |
| | | * @return 显示对象 |
| | | * @throws VciBaseException 参数为空或者不存在的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public List<CodeBasicSecVO> codeBasicSecDO2VOs(Collection<CodeBasicSecDO> codeBasicSecDOs, boolean hasFixedValue) throws VciBaseException { |
| | | List<CodeBasicSecVO> voList = new ArrayList<CodeBasicSecVO>(); |
| | | if (!CollectionUtils.isEmpty(codeBasicSecDOs)) { |
| | | for (CodeBasicSecDO s : codeBasicSecDOs) { |
| | | CodeBasicSecVO vo = codeBasicSecDO2VO(s); |
| | | if (vo != null) { |
| | | voList.add(vo); |
| | | } |
| | | } |
| | | } |
| | | if(hasFixedValue && !CollectionUtils.isEmpty(voList)){ |
| | | List<CodeBasicSecVO> fixedSecVOList = voList.stream().filter(s -> CodeSecTypeEnum.CODE_FIXED_SEC.getValue().equalsIgnoreCase(s.getSectype())).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(fixedSecVOList)){ |
| | | //查询固定码的码值 |
| | | Map<String, List<CodeFixedValueVO>> secValueMap = fixedValueService.listCodeFixedValueBySecOids(fixedSecVOList.stream().map(CodeBasicSecVO::getOid).collect(Collectors.toList())); |
| | | voList.stream().forEach(vo->{ |
| | | vo.setFixedValueVOList(secValueMap.getOrDefault(vo.getOid(),null)); |
| | | }); |
| | | } |
| | | } |
| | | return voList; |
| | | } |
| | | /** |
| | | * 修改码段基础信息 |
| | | * |
| | | * @param codeBasicSecDTO 码段基础信息数据传输对象 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 参数为空,唯一项,必输项不通过时会抛出异常 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean editSave(CodeBasicSecDTO codeBasicSecDTO) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(codeBasicSecDTO, "需要添加的数据对象"); |
| | | KeyValue attrKv = checkAttrNullableBySecType(codeBasicSecDTO); |
| | | if (! "success".equals(attrKv.getKey())){ |
| | | throw new VciBaseException(attrKv.getValue() + "不能为空"); |
| | | } |
| | | //将DTO转换为DO |
| | | CodeBasicSec codeBasicSecDO = selectByOid(codeBasicSecDTO.getOid()); |
| | | boolean status = codeRuleService.checkEditDelStatus(codeRuleService.getObjectByOid(codeBasicSecDO.getPkCodeRule()).getLcStatus()); |
| | | boolean resBoolean; |
| | | if (!status){ |
| | | //返回错误信息 |
| | | throw new VciBaseException("编码规则不允许编辑或删除!"); |
| | | } else { |
| | | //补位的时候,要控制补位字符 |
| | | if((OsCodeFillTypeEnum.LEFT.getValue().equalsIgnoreCase(codeBasicSecDO.getCodeFillType()) |
| | | || OsCodeFillTypeEnum.RIGHT.getValue().equalsIgnoreCase(codeBasicSecDO.getCodeFillType())) |
| | | && StringUtils.isBlank(codeBasicSecDO.getCodeFillSeparator())){ |
| | | throw new VciBaseException("当补位方式为左补位或者右补位的时候,补位字符不能为空"); |
| | | } |
| | | //引用码段的时候,需要判断参照的信息是否正确 |
| | | if(CodeSecTypeEnum.CODE_REFER_SEC.getValue().equalsIgnoreCase(codeBasicSecDO.getSecType())){ |
| | | if(StringUtils.isBlank(codeBasicSecDO.getReferConfig())){ |
| | | throw new VciBaseException("引用码段的时候,需要填写 参照配置 的内容"); |
| | | } |
| | | try{ |
| | | JSONObject.parseObject(codeBasicSecDO.getReferConfig(), UIFormReferVO.class); |
| | | }catch (Throwable e){ |
| | | throw new VciBaseException("引用码段的时候,参照配置的内容的格式不正确,",new String[0],e); |
| | | } |
| | | } |
| | | 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.setDictValue(codeBasicSecDO.getCodeFillSeparator()); |
| | | //从原来的charService(可输可选)更改为调用omd中的接口来实现 |
| | | iDictBizClient.getCheck(dictBiz); |
| | | //charService.save(MdmBtmTypeConstant.CODE_BASIC_SEC,"codefileseparator",codeBasicSecDO.getCodeFillSeparator(),sessionInfo); |
| | | } |
| | | } |
| | | return resBoolean; |
| | | } |
| | | |
| | | /** |
| | | * 数据对象转换为显示对象 |
| | | * |
| | | * @param codeBasicSecDO 数据对象 |
| | | * @return 显示对象 |
| | | * @throws VciBaseException 拷贝属性出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeBasicSecVO codeBasicSecDO2VO(CodeBasicSecDO codeBasicSecDO) throws VciBaseException { |
| | | CodeBasicSecVO vo = new CodeBasicSecVO(); |
| | | if (codeBasicSecDO != null) { |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeBasicSecDO, vo); |
| | | //如果有lcstatus的类的话 |
| | | if (true) { |
| | | //vo.setLcStatusText({lcStatusFullClassName}.getTextByValue(vo.getLcStatus())); |
| | | } |
| | | } |
| | | return vo; |
| | | } |
| | | /** |
| | | * 根据码段类型获取不可为空的字段 |
| | | * |
| | | * @param secType 码段类型 |
| | | * @return 不可为空的字段集合 |
| | | */ |
| | | private Map<String, String> getNotNullableAttr(String secType) { |
| | | Map<String, String> attrMap = new HashMap<>(); |
| | | if (CodeSecTypeEnum.CODE_ATTR_SEC.getValue().equalsIgnoreCase(secType)) { |
| | | attrMap.put("name", "属性码段名称"); |
| | | } else if (CodeSecTypeEnum.CODE_DATE_SEC.getValue().equalsIgnoreCase(secType)) { |
| | | attrMap.put("name", "日期码段名称"); |
| | | attrMap.put("codeDateFormatStr", "日期格式"); |
| | | } else if (CodeSecTypeEnum.CODE_FIXED_SEC.getValue().equalsIgnoreCase(secType)) { |
| | | attrMap.put("name", "固定码段名称"); |
| | | attrMap.put("codeSecLengthType", "码段长度类型"); |
| | | attrMap.put("codeSecLength", "码段的长度"); |
| | | } else if (CodeSecTypeEnum.CODE_LEVEL_SEC.getValue().equalsIgnoreCase(secType)) { |
| | | attrMap.put("name", "层级码段名称"); |
| | | attrMap.put("codeLevelType", "层级类型"); |
| | | attrMap.put("valueCutType", "字符截取类型"); |
| | | } else if (CodeSecTypeEnum.CODE_REFER_SEC.getValue().equalsIgnoreCase(secType)) { |
| | | attrMap.put("name", "引用码段名称"); |
| | | } else if (CodeSecTypeEnum.CODE_SERIAL_SEC.getValue().equalsIgnoreCase(secType)) { |
| | | attrMap.put("name", "流水码段名称"); |
| | | attrMap.put("codeSecLength", "码段的长度"); |
| | | attrMap.put("codeFillType", "编码补位方式"); |
| | | attrMap.put("codeFillLength", "填充长度"); |
| | | attrMap.put("codeFillLimit", "流水上限"); |
| | | attrMap.put("codeFillFlag", "流水是否补码"); |
| | | } else if (CodeSecTypeEnum.CODE_VARIABLE_SEC.getValue().equalsIgnoreCase(secType)) { |
| | | attrMap.put("name", "可变码段名称"); |
| | | attrMap.put("codeSecLength", "码段的长度"); |
| | | attrMap.put("codeFillType", "编码补位方式"); |
| | | } else if (CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue().equalsIgnoreCase(secType)) { |
| | | attrMap.put("name", "分类码段名称"); |
| | | attrMap.put("codeSecLengthType", "码段长度类型"); |
| | | attrMap.put("codeSecLength", "码段的长度"); |
| | | } else { |
| | | attrMap = null; |
| | | } |
| | | return attrMap; |
| | | } |
| | | |
| | | /** |
| | | * 增加码段基础信息 |
| | | * |
| | | * @param codeBasicSecDTO 码段基础信息数据传输对象 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 参数为空,唯一项,必输项不通过时会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeBasicSecVO addSave(CodeBasicSecDTO codeBasicSecDTO) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(codeBasicSecDTO, "需要添加的数据对象",codeBasicSecDTO.getPkCodeRule(),"编码规则的主键"); |
| | | CodeRuleVO ruleVO = codeRuleService.getObjectByOid(codeBasicSecDTO.getPkCodeRule()); |
| | | if(!CodeRuleLC.EDITING.getValue().equalsIgnoreCase(ruleVO.getLcStatus())){ |
| | | throw new VciBaseException("编码规则的状态不是【" + CodeRuleLC.EDITING.getText() + "】!不允许修改"); |
| | | } |
| | | KeyValue attrKv = checkAttrNullableBySecType(codeBasicSecDTO); |
| | | if (! "success".equals(attrKv.getKey())){ |
| | | throw new VciBaseException(attrKv.getValue() + "不能为空"); |
| | | } |
| | | /** |
| | | * 删除码段基础信息 |
| | | * @param codeBasicSecDTO 码段基础信息数据传输对象,oid和ts需要传输 |
| | | * @return 删除结果反馈::success:成功,fail:失败 |
| | | * @throws VciBaseException 参数为空,被引用时抛出异常 |
| | | */ |
| | | @Override |
| | | public R deleteCodeBasicSec(CodeBasicSecDTO codeBasicSecDTO) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(codeBasicSecDTO, "码段基础信息数据对象", codeBasicSecDTO.getOid(), "码段基础信息的主键"); |
| | | 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); |
| | | } |
| | | |
| | | //将DTO转换为DO |
| | | CodeBasicSecDO codeBasicSecDO = new CodeBasicSecDO(); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeBasicSecDTO, codeBasicSecDO); |
| | | //排序号,默认等于当前已有的数量加1 |
| | | Map<String,String> conditionMap = new HashMap<>(); |
| | | conditionMap.put("pkCodeRule",ruleVO.getOid()); |
| | | Long total = codeBasicSecMapper.countByCondition(conditionMap); |
| | | if(total == null){ |
| | | total = 0L; |
| | | } |
| | | codeBasicSecDO.setOrderNum(total.intValue() + 1); |
| | | /** |
| | | * 主键获取码段基础信息 |
| | | * |
| | | * @param oid 主键 |
| | | * @return 码段基础信息显示对象 |
| | | * @throws VciBaseException 参数为空,数据不存在时会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeBasicSecVO getObjectByOid(String oid) throws VciBaseException { |
| | | return CodeBasicSecWrapper.build().entityVO(selectByOid(oid)); |
| | | } |
| | | |
| | | //补位的时候,要控制补位字符 |
| | | if((OsCodeFillTypeEnum.LEFT.getValue().equalsIgnoreCase(codeBasicSecDO.getCodeFillType()) |
| | | || OsCodeFillTypeEnum.RIGHT.getValue().equalsIgnoreCase(codeBasicSecDO.getCodeFillType())) |
| | | && StringUtils.isBlank(codeBasicSecDO.getCodeFillSeparator())){ |
| | | throw new VciBaseException("当补位方式为左补位或者右补位的时候,补位字符不能为空"); |
| | | } |
| | | //引用码段的时候,需要判断参照的信息是否正确 |
| | | if(CodeSecTypeEnum.CODE_REFER_SEC.getValue().equalsIgnoreCase(codeBasicSecDO.getSecType())){ |
| | | if(StringUtils.isBlank(codeBasicSecDO.getReferConfig())){ |
| | | throw new VciBaseException("引用码段的时候,需要填写 参照配置 的内容"); |
| | | } |
| | | try{ |
| | | JSONObject.parseObject(codeBasicSecDO.getReferConfig(), UIFormReferVO.class); |
| | | }catch (Throwable e){ |
| | | throw new VciBaseException("引用码段的时候,参照配置的内容的格式不正确,",new String[0],e); |
| | | } |
| | | } |
| | | codeBasicSecMapper.insert(codeBasicSecDO); |
| | | SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo(); |
| | | if(StringUtils.isNotBlank(codeBasicSecDO.getCodeFillSeparator())){ |
| | | charService.save(MdmBtmTypeConstant.CODE_BASIC_SEC,"codefileseparator",codeBasicSecDO.getCodeFillSeparator(),sessionInfo); |
| | | } |
| | | return codeBasicSecDO2VO(codeBasicSecDO); |
| | | } |
| | | /** |
| | | * 主键批量获取码段基础信息 |
| | | * |
| | | * @param oidCollections 主键集合,但是受性能影响,建议一次查询不超过10000个 |
| | | * @return 码段基础信息显示对象 |
| | | * @throws VciBaseException 查询出现异常时会抛出 |
| | | */ |
| | | @Override |
| | | public Collection<CodeBasicSecVO> listCodeBasicSecByOids(Collection<String> oidCollections) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(oidCollections, "数据对象主键集合"); |
| | | List<CodeBasicSec> codeBasicSecDOList = listCodeBasicSecDOByOidCollections(oidCollections); |
| | | return CodeBasicSecWrapper.build().listVO(codeBasicSecDOList); |
| | | } |
| | | |
| | | /** |
| | | * 修改码段基础信息 |
| | | * |
| | | * @param codeBasicSecDTO 码段基础信息数据传输对象 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 参数为空,唯一项,必输项不通过时会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeBasicSecVO editSave(CodeBasicSecDTO codeBasicSecDTO) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(codeBasicSecDTO, "需要添加的数据对象"); |
| | | KeyValue attrKv = checkAttrNullableBySecType(codeBasicSecDTO); |
| | | if (! "success".equals(attrKv.getKey())){ |
| | | throw new VciBaseException(attrKv.getValue() + "不能为空"); |
| | | } |
| | | //将DTO转换为DO |
| | | CodeBasicSecDO codeBasicSecDO = selectByOid(codeBasicSecDTO.getOid()); |
| | | boolean status = codeRuleService.checkEditDelStatus(codeRuleService.getObjectByOid(codeBasicSecDO.getPkCodeRule()).getLcStatus()); |
| | | if (!status){ |
| | | //返回错误信息 |
| | | throw new VciBaseException("编码规则不允许编辑或删除!"); |
| | | } else { |
| | | //补位的时候,要控制补位字符 |
| | | if((OsCodeFillTypeEnum.LEFT.getValue().equalsIgnoreCase(codeBasicSecDO.getCodeFillType()) |
| | | || OsCodeFillTypeEnum.RIGHT.getValue().equalsIgnoreCase(codeBasicSecDO.getCodeFillType())) |
| | | && StringUtils.isBlank(codeBasicSecDO.getCodeFillSeparator())){ |
| | | throw new VciBaseException("当补位方式为左补位或者右补位的时候,补位字符不能为空"); |
| | | } |
| | | //引用码段的时候,需要判断参照的信息是否正确 |
| | | if(CodeSecTypeEnum.CODE_REFER_SEC.getValue().equalsIgnoreCase(codeBasicSecDO.getSecType())){ |
| | | if(StringUtils.isBlank(codeBasicSecDO.getReferConfig())){ |
| | | throw new VciBaseException("引用码段的时候,需要填写 参照配置 的内容"); |
| | | } |
| | | try{ |
| | | JSONObject.parseObject(codeBasicSecDO.getReferConfig(), UIFormReferVO.class); |
| | | }catch (Throwable e){ |
| | | throw new VciBaseException("引用码段的时候,参照配置的内容的格式不正确,",new String[0],e); |
| | | } |
| | | } |
| | | revisionModelUtil.copyFromDTOIgnore(codeBasicSecDTO, codeBasicSecDO); |
| | | codeBasicSecMapper.updateByPrimaryKey(codeBasicSecDO); |
| | | SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo(); |
| | | if(StringUtils.isNotBlank(codeBasicSecDO.getCodeFillSeparator())){ |
| | | charService.save(MdmBtmTypeConstant.CODE_BASIC_SEC,"codefileseparator",codeBasicSecDO.getCodeFillSeparator(),sessionInfo); |
| | | } |
| | | } |
| | | return codeBasicSecDO2VO(codeBasicSecDO); |
| | | } |
| | | /** |
| | | * 参照码段基础信息列表 |
| | | * |
| | | * @param codeBasicSecVO 查询条件 |
| | | * @param page 分页和排序 |
| | | * @return 码段基础信息显示对象列表,生效的内容 |
| | | * @throws VciBaseException 查询条件和分页出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public IPage<CodeBasicSecVO> refDataGridCodeBasicSec(IPage<CodeBasicSecVO> page, CodeBasicSecVO codeBasicSecVO) throws VciBaseException { |
| | | return gridCodeBasicSec(page,codeBasicSecVO); |
| | | } |
| | | |
| | | /** |
| | | * 参照分类的码段 |
| | | * @param codeBasicSecVO 查询条件 |
| | | * @param page 分页的对象 |
| | | * @return 码段的内容 |
| | | */ |
| | | @Override |
| | | public IPage<CodeBasicSecVO> refDataGridClassifySec(IPage<CodeBasicSecVO> page, CodeBasicSecVO codeBasicSecVO) throws VciBaseException { |
| | | if(Func.isEmpty(codeBasicSecVO.getPkCodeRule()) || Func.isBlank(codeBasicSecVO.getPkCodeRule())){ |
| | | return null; |
| | | } |
| | | codeBasicSecVO.setSecType(CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue()); |
| | | return refDataGridCodeBasicSec(page,codeBasicSecVO); |
| | | } |
| | | |
| | | /** |
| | | * 校验是否可以删除,如果存在下级,并且下级有数据引用则不能删除 |
| | | * |
| | | * @param codeBasicSecDTO 数据传输对象 |
| | | * @param codeBasicSecDO 数据库中的数据对象 |
| | | * @return success为true为可以删除,false表示有数据引用,obj为true表示有下级 |
| | | */ |
| | | private BaseResult checkIsCanDeleteForDO(CodeBasicSecDTO codeBasicSecDTO, CodeBasicSecDO codeBasicSecDO) { |
| | | boService.checkTs(codeBasicSecDTO); |
| | | if (!checkIsLinked(null, codeBasicSecDO.getOid())) { |
| | | return BaseResult.success(); |
| | | } else { |
| | | return BaseResult.fail(DATA_LINKED_NOT_DELETE, new String[]{""}); |
| | | } |
| | | } |
| | | /** |
| | | * 克隆码段信息 |
| | | * |
| | | * @param oidList 源码段信息主键集合 |
| | | * @param pkCodeRule 目标编码规则 |
| | | * @return 克隆结果反馈::success:成功,fail:失败 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R cloneCodeBasicSec(List<String> oidList, String pkCodeRule) { |
| | | boolean isLinked = checkIsLinked(pkCodeRule,null); |
| | | if (isLinked) { |
| | | return R.fail("编码规则已被引用,不允许编辑或删除"); |
| | | } |
| | | List<CodeBasicSec> createList = new ArrayList<>(); |
| | | List<CodeBasicSec> basicSecDOS = codeBasicSecMapper.selectBatchIds(oidList); |
| | | basicSecDOS.forEach(sec -> { |
| | | CodeBasicSec newSecDO = new CodeBasicSec(); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(sec,newSecDO); |
| | | newSecDO.setOid(""); |
| | | newSecDO.setNameOid(""); |
| | | newSecDO.setRevisionOid(""); |
| | | newSecDO.setId(newSecDO.getId() + "_copy"); |
| | | newSecDO.setName(newSecDO.getName() + "_copy"); |
| | | newSecDO.setPkCodeRule(pkCodeRule); |
| | | createList.add(newSecDO); |
| | | }); |
| | | boolean b = saveBatch(createList); |
| | | //codeBasicSecMapper.insertBatch(createList); |
| | | return R.data(b,"克隆码段信息成功"); |
| | | } |
| | | |
| | | /** |
| | | * 校验是否被引用 |
| | | * |
| | | * @param codeRuleOid 编码规则主键 |
| | | * @param codeBasicSecOid 编码基础信息主键 |
| | | * @return true表示已被引用,false表示未被引用 |
| | | * @throws VciBaseException 被引用的时候会抛出异常 |
| | | */ |
| | | private boolean checkIsLinked(String codeRuleOid, String codeBasicSecOid) throws VciBaseException { |
| | | boolean flag = true; |
| | | if (StringUtils.isNotBlank(codeRuleOid)) { |
| | | boolean status = codeRuleService.checkEditDelStatus(codeRuleService.getObjectByOid(codeRuleOid).getLcStatus()); |
| | | if (!status){ |
| | | return true; |
| | | } |
| | | boolean alreadyInUse = codeRuleService.isAlreadyInUse(codeRuleOid); |
| | | if (!alreadyInUse){ |
| | | flag = false; |
| | | } |
| | | } else { |
| | | boolean status = codeRuleService.checkEditDelStatus(codeRuleService.getObjectByOid(codeBasicSecMapper.selectByPrimaryKey(codeBasicSecOid).getPkCodeRule()).getLcStatus()); |
| | | if (!status){ |
| | | return true; |
| | | } |
| | | boolean alreadyInUse = codeRuleService.isAlreadyInUse(codeBasicSecMapper.selectByPrimaryKey(codeBasicSecOid).getPkCodeRule()); |
| | | if (!alreadyInUse){ |
| | | flag = false; |
| | | } |
| | | } |
| | | return flag; |
| | | } |
| | | /** |
| | | * 查询目标分类码段所在的树结构 |
| | | * |
| | | * @param oid 目标分类码段主键 |
| | | * @return 分类码段树结构 |
| | | */ |
| | | /*@Override |
| | | public List<Tree> gridCodeClassifySecTree(String oid) { |
| | | VciParentQueryOption queryOption = new VciParentQueryOption(PARENT_FIELD_NAME); |
| | | queryOption.setfOid(oid); |
| | | queryOption.setLinkTypeFlag(false); |
| | | queryOption.setHasSelf(true); |
| | | VciQueryWrapperForDO wrapper = new VciQueryWrapperForDO(CodeBasicSec.class); |
| | | wrapper.childQueryParent(queryOption); |
| | | List<CodeBasicSec> doList = codeBasicSecMapper.selectByWrapper(wrapper); |
| | | List<String> secOid = new ArrayList<>(); |
| | | doList.forEach(o -> secOid.add(o.getOid())); |
| | | List<CodeClassifyValueVO> valueVOs = (List<CodeClassifyValueVO>) codeClassifyValueService.listCodeClassifyValueByOids(secOid); |
| | | TreeQueryObject treeQueryObject = new TreeQueryObject(); |
| | | treeQueryObject.setMultipleSelect(false); |
| | | treeQueryObject.setShowCheckBox(false); |
| | | treeQueryObject.setQueryAllLevel(false); |
| | | treeQueryObject.setValueField("oid"); |
| | | treeQueryObject.setTextField("name"); |
| | | treeQueryObject.setQueryAllRev(false); |
| | | TreeWrapperOptions treeWrapperOptions = new TreeWrapperOptions(PARENT_CLASSIFY_VALUE_FIELD_NAME); |
| | | treeWrapperOptions.copyFromTreeQuery(treeQueryObject); |
| | | return revisionModelUtil.doList2Trees(valueVOs,treeWrapperOptions,(CodeClassifyValueVO s) ->{ |
| | | //可以在这里处理树节点的显示 |
| | | return s.getId() + " " + s.getName() + (FrameworkDataLCStatus.DISABLED.getValue().equalsIgnoreCase(s |
| | | .getLcStatus()) ? (" 【停用】 ") : ""); |
| | | }); |
| | | }*/ |
| | | |
| | | /** |
| | | * 删除码段基础信息 |
| | | * |
| | | * @param codeBasicSecDTO 码段基础信息数据传输对象,oid和ts需要传输 |
| | | * @return 删除结果反馈::success:成功,fail:失败 |
| | | * @throws VciBaseException 参数为空,被引用时抛出异常 |
| | | */ |
| | | @Override |
| | | public BaseResult deleteCodeBasicSec(CodeBasicSecDTO codeBasicSecDTO) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(codeBasicSecDTO, "码段基础信息数据对象", codeBasicSecDTO.getOid(), "码段基础信息的主键"); |
| | | return deleteCodeBasicSecByPrimaryKey(codeBasicSecDTO.getOid()); |
| | | } |
| | | /** |
| | | * 上移 |
| | | * |
| | | * @param oid 主键 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean upOrderNum(String oid) { |
| | | CodeBasicSec secDO = selectByOid(oid); |
| | | if(secDO.getOrderNum() > 1){ |
| | | //等于1的时候不能上移了 |
| | | //找比自己小的 |
| | | List<CodeBasicSec> lastSecDOs = codeBasicSecMapper.selectList(Wrappers.<CodeBasicSec>query() |
| | | .lambda().eq(CodeBasicSec::getPkCodeRule,secDO.getPkCodeRule()) |
| | | .eq(CodeBasicSec::getOrderNum,String.valueOf(secDO.getOrderNum()-1)) |
| | | ); |
| | | if(!CollectionUtils.isEmpty(lastSecDOs)){ |
| | | CodeBasicSec lastSec = lastSecDOs.get(0); |
| | | codeBasicSecMapper.update(null, Wrappers.<CodeBasicSec>update() |
| | | .lambda().set(CodeBasicSec::getOrderNum, lastSec.getOrderNum() + 1) |
| | | .eq(CodeBasicSec::getOid, lastSec.getOid()) |
| | | ); |
| | | } |
| | | codeBasicSecMapper.update(null, Wrappers.<CodeBasicSec>update() |
| | | .lambda().set(CodeBasicSec::getOrderNum, secDO.getOrderNum() - 1) |
| | | .eq(CodeBasicSec::getOid, secDO.getOid()) |
| | | ); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 主键删除码段基础信息 |
| | | * |
| | | * @param oid 码段基础信息主键 |
| | | * @return 删除结果反馈::success:成功,fail:失败 |
| | | * @throws VciBaseException 参数为空,被引用时抛出异常 |
| | | */ |
| | | @Override |
| | | public BaseResult deleteCodeBasicSecByPrimaryKey(String oid) throws VciBaseException { |
| | | CodeBasicSecDO codeBasicSecDO = selectByOid(oid); |
| | | boolean isLinked = checkIsLinked(codeBasicSecDO.getPkCodeRule(), oid); |
| | | if (isLinked) { |
| | | return BaseResult.fail("编码规则已被引用,不允许编辑或删除"); |
| | | } |
| | | Map<String,String> conditionMap = new HashMap<>(); |
| | | //执行删除操作 |
| | | WebUtil.setPersistence(false); |
| | | BatchCBO batchCBO = codeBasicSecMapper.deleteByPrimaryKey(oid); |
| | | Set<ClientBusinessObject> deleteSet = new HashSet<>(); |
| | | deleteSet.addAll(batchCBO.getDeleteCbos()); |
| | | if (CodeSecTypeEnum.CODE_FIXED_SEC.getValue().equals(codeBasicSecDO.getSecType())){ |
| | | conditionMap.put("codefixedsecoid",codeBasicSecDO.getOid()); |
| | | VciQueryWrapperForDO wrapper = new VciQueryWrapperForDO(conditionMap, CodeFixedValueDO.class); |
| | | List<CodeFixedValueDO> fixedValueDOS = fixedValueMapper.selectByWrapper(wrapper); |
| | | BatchCBO valueCBO = fixedValueMapper.batchDeleteByOids(fixedValueDOS.stream().map(CodeFixedValueDO::getOid).collect(Collectors.toSet())); |
| | | deleteSet.addAll(valueCBO.getDeleteCbos()); |
| | | } |
| | | if (CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue().equals(codeBasicSecDO.getSecType())){ |
| | | conditionMap.put("codeclassifysecoid",codeBasicSecDO.getOid()); |
| | | VciQueryWrapperForDO wrapper = new VciQueryWrapperForDO(conditionMap, CodeClassifyValueDO.class); |
| | | List<CodeClassifyValueDO> classifyValueDOS = codeClassifyValueMapper.selectByWrapper(wrapper); |
| | | if(!CollectionUtils.isEmpty(classifyValueDOS)) { |
| | | BatchCBO valueCBO = codeClassifyValueMapper.batchDeleteByOids(classifyValueDOS.stream().map(CodeClassifyValueDO::getOid).collect(Collectors.toSet())); |
| | | deleteSet.addAll(valueCBO.getDeleteCbos()); |
| | | } |
| | | } |
| | | batchCBO.setDeleteCbos(deleteSet); |
| | | WebUtil.setPersistence(true); |
| | | boService.persistenceBatch(batchCBO); |
| | | return (batchCBO != null && batchCBO.getDeleteCbos() != null && batchCBO.getDeleteCbos().size() > 0) ? BaseResult.successMsg(DELETE_SUCCESS) : BaseResult.fail(DELETE_FAIL); |
| | | } |
| | | /** |
| | | * 下移 |
| | | * |
| | | * @param oid 主键 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean downOrderNum(String oid) { |
| | | CodeBasicSec secDO = selectByOid(oid); |
| | | Long total = codeBasicSecMapper.selectCount(Wrappers.<CodeBasicSec>query() |
| | | .lambda().eq(CodeBasicSec::getPkCodeRule,secDO.getPkCodeRule()) |
| | | ); |
| | | if(secDO.getOrderNum() < total){ |
| | | //小于总数的时候才下移 |
| | | List<CodeBasicSec> lastSecDOs = codeBasicSecMapper.selectList(Wrappers.<CodeBasicSec>query() |
| | | .lambda().eq(CodeBasicSec::getOrderNum,secDO.getOrderNum()+1) |
| | | .eq(CodeBasicSec::getPkCodeRule,secDO.getPkCodeRule()) |
| | | ); |
| | | if(!CollectionUtils.isEmpty(lastSecDOs)){ |
| | | CodeBasicSec lastSec = lastSecDOs.get(0); |
| | | codeBasicSecMapper.update(null, Wrappers.<CodeBasicSec>update() |
| | | .lambda().set(CodeBasicSec::getOrderNum, lastSec.getOrderNum() - 1) |
| | | .eq(CodeBasicSec::getOid, lastSec.getOid()) |
| | | ); |
| | | } |
| | | codeBasicSecMapper.update(null, Wrappers.<CodeBasicSec>update() |
| | | .lambda().set(CodeBasicSec::getOrderNum, secDO.getOrderNum() + 1) |
| | | .eq(CodeBasicSec::getOid, secDO.getOid()) |
| | | ); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 主键获取码段基础信息 |
| | | * |
| | | * @param oid 主键 |
| | | * @return 码段基础信息显示对象 |
| | | * @throws VciBaseException 参数为空,数据不存在时会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeBasicSecVO getObjectByOid(String oid) throws VciBaseException { |
| | | return codeBasicSecDO2VO(selectByOid(oid)); |
| | | } |
| | | /** |
| | | * 树形结构查询oid |
| | | * @param codeClassifySecOid |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<String> getOidByCodeclassifysecOid(String codeClassifySecOid) { |
| | | return codeBasicSecMapper.getOidByCodeclassifysecOid(codeClassifySecOid.trim()); |
| | | } |
| | | |
| | | /** |
| | | * 主键查询数据对象 |
| | | * |
| | | * @param oid 主键 |
| | | * @return 数据对象 |
| | | * @throws VciBaseException 参数为空,并且数据不存在的时候会抛出异常 |
| | | */ |
| | | private CodeBasicSecDO selectByOid(String oid) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(oid, "主键"); |
| | | CodeBasicSecDO codeBasicSecDO = codeBasicSecMapper.selectByPrimaryKey(oid.trim()); |
| | | if (codeBasicSecDO == null || StringUtils.isBlank(codeBasicSecDO.getOid())) { |
| | | throw new VciBaseException(DATA_OID_NOT_EXIST); |
| | | } |
| | | return codeBasicSecDO; |
| | | } |
| | | /** |
| | | * 校验是否被引用 |
| | | * |
| | | * @param codeRuleOid 编码规则主键 |
| | | * @param codeBasicSecOid 编码基础信息主键 |
| | | * @return true表示已被引用,false表示未被引用 |
| | | * @throws VciBaseException 被引用的时候会抛出异常 |
| | | */ |
| | | private boolean checkIsLinked(String codeRuleOid, String codeBasicSecOid) throws VciBaseException { |
| | | boolean flag = true; |
| | | if (StringUtils.isNotBlank(codeRuleOid)) { |
| | | boolean status = codeRuleService.checkEditDelStatus(codeRuleService.getObjectByOid(codeRuleOid).getLcStatus()); |
| | | if (!status){ |
| | | return true; |
| | | } |
| | | boolean alreadyInUse = codeRuleService.isAlreadyInUse(codeRuleOid); |
| | | if (!alreadyInUse){ |
| | | flag = false; |
| | | } |
| | | } else { |
| | | boolean status = codeRuleService.checkEditDelStatus(codeRuleService.getObjectByOid(codeBasicSecMapper.selectById(codeBasicSecOid).getPkCodeRule()).getLcStatus()); |
| | | if (!status){ |
| | | return true; |
| | | } |
| | | boolean alreadyInUse = codeRuleService.isAlreadyInUse(codeBasicSecMapper.selectById(codeBasicSecOid).getPkCodeRule()); |
| | | if (!alreadyInUse){ |
| | | flag = false; |
| | | } |
| | | } |
| | | return flag; |
| | | } |
| | | |
| | | /** |
| | | * 主键批量获取码段基础信息 |
| | | * |
| | | * @param oidCollections 主键集合,但是受性能影响,建议一次查询不超过10000个 |
| | | * @return 码段基础信息显示对象 |
| | | * @throws VciBaseException 查询出现异常时会抛出 |
| | | */ |
| | | @Override |
| | | public Collection<CodeBasicSecVO> listCodeBasicSecByOids(Collection<String> oidCollections) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(oidCollections, "数据对象主键集合"); |
| | | List<CodeBasicSecDO> codeBasicSecDOList = listCodeBasicSecDOByOidCollections(oidCollections); |
| | | return codeBasicSecDO2VOs(codeBasicSecDOList); |
| | | } |
| | | /** |
| | | * 使用主键集合查询数据对象 |
| | | * |
| | | * @param oidCollections 主键的集合 |
| | | * @return 数据对象列表 |
| | | */ |
| | | private List<CodeBasicSec> listCodeBasicSecDOByOidCollections(Collection<String> oidCollections) { |
| | | List<CodeBasicSec> codeBasicSecDOList = new ArrayList<>(); |
| | | if (!CollectionUtils.isEmpty(oidCollections)) { |
| | | Collection<Collection<String>> oidCollectionsList = VciBaseUtil.switchCollectionForOracleIn(oidCollections); |
| | | for (Collection<String> oids : oidCollectionsList) { |
| | | List<CodeBasicSec> tempDOList = codeBasicSecMapper.selectBatchIds(oids); |
| | | if (!CollectionUtils.isEmpty(tempDOList)) { |
| | | codeBasicSecDOList.addAll(tempDOList); |
| | | } |
| | | } |
| | | } |
| | | return codeBasicSecDOList; |
| | | } |
| | | |
| | | /** |
| | | * 使用主键集合查询数据对象 |
| | | * |
| | | * @param oidCollections 主键的集合 |
| | | * @return 数据对象列表 |
| | | */ |
| | | private List<CodeBasicSecDO> listCodeBasicSecDOByOidCollections(Collection<String> oidCollections) { |
| | | List<CodeBasicSecDO> codeBasicSecDOList = new ArrayList<CodeBasicSecDO>(); |
| | | if (!CollectionUtils.isEmpty(oidCollections)) { |
| | | Collection<Collection<String>> oidCollectionsList = VciBaseUtil.switchCollectionForOracleIn(oidCollections); |
| | | for (Collection<String> oids : oidCollectionsList) { |
| | | List<CodeBasicSecDO> tempDOList = codeBasicSecMapper.selectByPrimaryKeyCollection(oids); |
| | | if (!CollectionUtils.isEmpty(tempDOList)) { |
| | | codeBasicSecDOList.addAll(tempDOList); |
| | | } |
| | | } |
| | | } |
| | | return codeBasicSecDOList; |
| | | } |
| | | /** |
| | | * 主键查询数据对象 |
| | | * |
| | | * @param oid 主键 |
| | | * @return 数据对象 |
| | | * @throws VciBaseException 参数为空,并且数据不存在的时候会抛出异常 |
| | | */ |
| | | private CodeBasicSec selectByOid(String oid) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(oid, "主键"); |
| | | CodeBasicSec codeBasicSecDO = codeBasicSecMapper.selectById(oid.trim()); |
| | | if (codeBasicSecDO == null || StringUtils.isBlank(codeBasicSecDO.getOid())) { |
| | | throw new VciBaseException(DATA_OID_NOT_EXIST); |
| | | } |
| | | return codeBasicSecDO; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 参照码段基础信息列表 |
| | | * |
| | | * @param conditionMap 查询条件 |
| | | * @param pageHelper 分页和排序 |
| | | * @return 码段基础信息显示对象列表,生效的内容 |
| | | * @throws VciBaseException 查询条件和分页出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public DataGrid<CodeBasicSecVO> refDataGridCodeBasicSec(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException { |
| | | if (conditionMap == null) { |
| | | conditionMap = new HashMap<String, String>(); |
| | | } |
| | | return gridCodeBasicSec(conditionMap, pageHelper); |
| | | } |
| | | |
| | | /** |
| | | * 克隆码段信息 |
| | | * |
| | | * @param oidList 源码段信息主键集合 |
| | | * @param pkCodeRule 目标编码规则 |
| | | * @return 克隆结果反馈::success:成功,fail:失败 |
| | | */ |
| | | @Override |
| | | public BaseResult cloneCodeBasicSec(List<String> oidList, String pkCodeRule) { |
| | | boolean isLinked = checkIsLinked(pkCodeRule,null); |
| | | if (isLinked) { |
| | | return BaseResult.fail("编码规则已被引用,不允许编辑或删除"); |
| | | } |
| | | List<CodeBasicSecDO> createList = new ArrayList<>(); |
| | | List<CodeBasicSecDO> basicSecDOS = codeBasicSecMapper.selectByPrimaryKeyCollection(oidList); |
| | | basicSecDOS.forEach(sec -> { |
| | | CodeBasicSecDO newSecDO = new CodeBasicSecDO(); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(sec,newSecDO); |
| | | newSecDO.setOid(""); |
| | | newSecDO.setNameOid(""); |
| | | newSecDO.setRevisionOid(""); |
| | | newSecDO.setId(newSecDO.getId() + "_copy"); |
| | | newSecDO.setName(newSecDO.getName() + "_copy"); |
| | | newSecDO.setPkCodeRule(pkCodeRule); |
| | | createList.add(newSecDO); |
| | | }); |
| | | codeBasicSecMapper.batchInsert(createList); |
| | | return BaseResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * 根据码段分类的类型判断属性是否是空的 |
| | | * |
| | | * @param codeBasicSecDTO 码段基础信息数据传输对象 |
| | | * @return 有空的则传key-属性名 value-字段含义,没有空的则传 key-success value-true |
| | | */ |
| | | @Override |
| | | public KeyValue checkAttrNullableBySecType(CodeBasicSecDTO codeBasicSecDTO) { |
| | | 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) { |
| | | throw new VciBaseException("码段分类填写出错,请查验后重试"); |
| | | } |
| | | for (String key : notNullableAttr.keySet()) { |
| | | if (StringUtils.isBlank(WebUtil.getStringValueFromObject(attrMap.get(key)))) { |
| | | KeyValue kv = new KeyValue(); |
| | | kv.setKey(key); |
| | | kv.setValue(notNullableAttr.get(key)); |
| | | return kv; |
| | | } |
| | | } |
| | | KeyValue kv = new KeyValue(); |
| | | kv.setKey("success"); |
| | | kv.setValue("true"); |
| | | return kv; |
| | | } |
| | | |
| | | /** |
| | | * 使用规则的主键获取对应的码段内容 |
| | | * |
| | | * @param ruleOid 规则的内容 |
| | | * @return 码段的内容 |
| | | */ |
| | | @Override |
| | | public List<CodeBasicSecVO> listCodeBasicSecByRuleOid(String ruleOid) { |
| | | 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"); |
| | | List<CodeBasicSecDO> secDOList = codeBasicSecMapper.selectByCondition(conditionMap, pageHelper); |
| | | return codeBasicSecDO2VOs(secDOList,true); |
| | | } |
| | | |
| | | /** |
| | | * 使用规则的主键获取对应的码段的内容 |
| | | * |
| | | * @param ruleCollection 规则主键集合 |
| | | * @return 码段的内容 |
| | | */ |
| | | @Override |
| | | public List<CodeBasicSecVO> listCodeBasicSecByRuleOids(Collection<String> ruleCollection) { |
| | | if(CollectionUtils.isEmpty(ruleCollection)){ |
| | | return new ArrayList<>(); |
| | | } |
| | | List<CodeBasicSecDO> secDOList = new CopyOnWriteArrayList<>(); |
| | | SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo(); |
| | | VciBaseUtil.switchCollectionForOracleIn(ruleCollection).parallelStream().forEach(ruleOids->{ |
| | | WebUtil.setCurrentUserSessionInfo(sessionInfo); |
| | | Map<String,String> conditionMap = new HashMap<>(); |
| | | conditionMap.put("pkcoderule", QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(ruleOids.toArray(new String[0])) + ")"); |
| | | PageHelper pageHelper = new PageHelper(-1); |
| | | pageHelper.addDefaultAsc("ordernum"); |
| | | List<CodeBasicSecDO> tempSecDOs = codeBasicSecMapper.selectByCondition(conditionMap, pageHelper); |
| | | if(!CollectionUtils.isEmpty(tempSecDOs)){ |
| | | secDOList.addAll(tempSecDOs); |
| | | } |
| | | }); |
| | | return codeBasicSecDO2VOs(secDOList); |
| | | } |
| | | |
| | | /** |
| | | * 参照分类的码段 |
| | | * |
| | | * @param conditionMap 查询条件,必须要有pkCodeRule |
| | | * @param pageHelper 分页的对象 |
| | | * @return 码段的内容 |
| | | */ |
| | | @Override |
| | | public DataGrid<CodeBasicSecVO> refDataGridClassifySec(Map<String, String> conditionMap, PageHelper pageHelper) { |
| | | if(CollectionUtils.isEmpty(conditionMap) || !conditionMap.containsKey("pkCodeRule")){ |
| | | return new DataGrid<>(); |
| | | } |
| | | conditionMap.put("secType",CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue()); |
| | | return refDataGridCodeBasicSec(conditionMap,pageHelper); |
| | | } |
| | | |
| | | /** |
| | | * 根据码段类型获取不可为空的字段 |
| | | * |
| | | * @param secType 码段类型 |
| | | * @return 不可为空的字段集合 |
| | | */ |
| | | private Map<String, String> getNotNullableAttr(String secType) { |
| | | Map<String, String> attrMap = new HashMap<>(); |
| | | if (CodeSecTypeEnum.CODE_ATTR_SEC.getValue().equalsIgnoreCase(secType)) { |
| | | attrMap.put("name", "属性码段名称"); |
| | | } else if (CodeSecTypeEnum.CODE_DATE_SEC.getValue().equalsIgnoreCase(secType)) { |
| | | attrMap.put("name", "日期码段名称"); |
| | | attrMap.put("codeDateFormatStr", "日期格式"); |
| | | } else if (CodeSecTypeEnum.CODE_FIXED_SEC.getValue().equalsIgnoreCase(secType)) { |
| | | attrMap.put("name", "固定码段名称"); |
| | | attrMap.put("codeSecLengthType", "码段长度类型"); |
| | | attrMap.put("codeSecLength", "码段的长度"); |
| | | } else if (CodeSecTypeEnum.CODE_LEVEL_SEC.getValue().equalsIgnoreCase(secType)) { |
| | | attrMap.put("name", "层级码段名称"); |
| | | attrMap.put("codeLevelType", "层级类型"); |
| | | attrMap.put("valueCutType", "字符截取类型"); |
| | | } else if (CodeSecTypeEnum.CODE_REFER_SEC.getValue().equalsIgnoreCase(secType)) { |
| | | attrMap.put("name", "引用码段名称"); |
| | | } else if (CodeSecTypeEnum.CODE_SERIAL_SEC.getValue().equalsIgnoreCase(secType)) { |
| | | attrMap.put("name", "流水码段名称"); |
| | | attrMap.put("codeSecLength", "码段的长度"); |
| | | attrMap.put("codeFillType", "编码补位方式"); |
| | | attrMap.put("codeFillLength", "填充长度"); |
| | | attrMap.put("codeFillLimit", "流水上限"); |
| | | attrMap.put("codeFillFlag", "流水是否补码"); |
| | | } else if (CodeSecTypeEnum.CODE_VARIABLE_SEC.getValue().equalsIgnoreCase(secType)) { |
| | | attrMap.put("name", "可变码段名称"); |
| | | attrMap.put("codeSecLength", "码段的长度"); |
| | | attrMap.put("codeFillType", "编码补位方式"); |
| | | } else if (CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue().equalsIgnoreCase(secType)) { |
| | | attrMap.put("name", "分类码段名称"); |
| | | attrMap.put("codeSecLengthType", "码段长度类型"); |
| | | attrMap.put("codeSecLength", "码段的长度"); |
| | | } else { |
| | | attrMap = null; |
| | | } |
| | | return attrMap; |
| | | } |
| | | |
| | | /** |
| | | * 查询目标分类码段所在的树结构 |
| | | * |
| | | * @param oid 目标分类码段主键 |
| | | * @return 分类码段树结构 |
| | | */ |
| | | @Override |
| | | public List<Tree> gridCodeClassifySecTree(String oid) { |
| | | VciParentQueryOption queryOption = new VciParentQueryOption(PARENT_FIELD_NAME); |
| | | queryOption.setfOid(oid); |
| | | queryOption.setLinkTypeFlag(false); |
| | | queryOption.setHasSelf(true); |
| | | VciQueryWrapperForDO wrapper = new VciQueryWrapperForDO(CodeBasicSecDO.class); |
| | | wrapper.childQueryParent(queryOption); |
| | | List<CodeBasicSecDO> doList = codeBasicSecMapper.selectByWrapper(wrapper); |
| | | List<String> secOid = new ArrayList<>(); |
| | | doList.forEach(o -> secOid.add(o.getOid())); |
| | | List<CodeClassifyValueVO> valueVOs = (List<CodeClassifyValueVO>) codeClassifyValueService.listCodeClassifyValueByOids(secOid); |
| | | TreeQueryObject treeQueryObject = new TreeQueryObject(); |
| | | treeQueryObject.setMultipleSelect(false); |
| | | treeQueryObject.setShowCheckBox(false); |
| | | treeQueryObject.setQueryAllLevel(false); |
| | | treeQueryObject.setValueField("oid"); |
| | | treeQueryObject.setTextField("name"); |
| | | treeQueryObject.setQueryAllRev(false); |
| | | TreeWrapperOptions treeWrapperOptions = new TreeWrapperOptions(PARENT_CLASSIFY_VALUE_FIELD_NAME); |
| | | treeWrapperOptions.copyFromTreeQuery(treeQueryObject); |
| | | return revisionModelUtil.doList2Trees(valueVOs,treeWrapperOptions,(CodeClassifyValueVO s) ->{ |
| | | //可以在这里处理树节点的显示 |
| | | return s.getId() + " " + s.getName() + (FrameworkDataLCStatus.DISABLED.getValue().equalsIgnoreCase(s |
| | | .getLcStatus()) ? (" 【停用】 ") : ""); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 根据编码规则批量删除码段基本信息 |
| | | * @param codeRuleOid 编码规则主键 |
| | | * @return 执行结果 |
| | | */ |
| | | @Override |
| | | public BatchCBO batchDeleteSecByCodeRuleOid(String codeRuleOid) { |
| | | VciBaseUtil.alertNotNull(codeRuleOid,"编码规则主键"); |
| | | Map<String,String> conditionMap = new HashMap<>(); |
| | | conditionMap.put("pkcoderule",codeRuleOid); |
| | | VciQueryWrapperForDO wrapper = new VciQueryWrapperForDO(conditionMap,CodeBasicSecDO.class); |
| | | List<CodeBasicSecDO> deleteList = codeBasicSecMapper.selectByWrapper(wrapper); |
| | | if (CollectionUtils.isEmpty(deleteList)){ |
| | | return new BatchCBO(); |
| | | } |
| | | BatchCBO batchCBO = codeBasicSecMapper.batchDeleteByOids(deleteList.stream().map(CodeBasicSecDO::getOid).collect(Collectors.toSet())); |
| | | Set<ClientBusinessObject> deleteSet = new HashSet<>(); |
| | | deleteSet.addAll(batchCBO.getDeleteCbos()); |
| | | List<CodeBasicSecDO> fixedSecList = deleteList.stream().filter(sec -> { |
| | | return CodeSecTypeEnum.CODE_FIXED_SEC.getValue().equals(sec.getSecType()); |
| | | }).collect(Collectors.toList()); |
| | | List<CodeBasicSecDO> classifySecList = deleteList.stream().filter(sec -> { |
| | | return CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue().equals(sec.getSecType()); |
| | | }).collect(Collectors.toList()); |
| | | Set<String> fixedSecOidSet = fixedSecList.stream().map(CodeBasicSecDO::getOid).collect(Collectors.toSet()); |
| | | Set<String> classifySecOidSet = classifySecList.stream().map(CodeBasicSecDO::getOid).collect(Collectors.toSet()); |
| | | if (!CollectionUtils.isEmpty(fixedSecOidSet)){ |
| | | StringBuilder sb = new StringBuilder(); |
| | | fixedSecOidSet.stream().forEach(oid -> { |
| | | sb.append("'").append(oid).append("',"); |
| | | }); |
| | | String inSql = sb.toString().substring(0,sb.toString().length()-1); |
| | | VciQueryWrapperForDO wrapperForValue = new VciQueryWrapperForDO(null,CodeFixedValueDO.class); |
| | | PageHelper ph = new PageHelper(); |
| | | ph.setLimit(-1); |
| | | wrapperForValue.in("codefixedsecoid",inSql); |
| | | List<CodeFixedValueDO> fixedValueDOS = fixedValueMapper.selectByWrapper(wrapperForValue); |
| | | BatchCBO fixedCBO = fixedValueMapper.batchDeleteByOids(fixedValueDOS.stream().map(CodeFixedValueDO::getOid).collect(Collectors.toSet())); |
| | | deleteSet.addAll(fixedCBO.getDeleteCbos()); |
| | | } |
| | | if (!CollectionUtils.isEmpty(classifySecOidSet)){ |
| | | StringBuilder sb = new StringBuilder(); |
| | | classifySecOidSet.stream().forEach(oid -> { |
| | | sb.append("'").append(oid).append("',"); |
| | | }); |
| | | String inSql = sb.toString().substring(0,sb.toString().length()-1); |
| | | VciQueryWrapperForDO wrapperForValue = new VciQueryWrapperForDO(null,CodeClassifyValueDO.class); |
| | | PageHelper ph = new PageHelper(); |
| | | ph.setLimit(-1); |
| | | wrapperForValue.in("codeclassifysecoid",inSql); |
| | | List<CodeClassifyValueDO> classifyValueDOS = codeClassifyValueMapper.selectByWrapper(wrapperForValue); |
| | | BatchCBO fixedCBO = codeClassifyValueMapper.batchDeleteByOids(classifyValueDOS.stream().map(CodeClassifyValueDO::getOid).collect(Collectors.toSet())); |
| | | deleteSet.addAll(fixedCBO.getDeleteCbos()); |
| | | } |
| | | batchCBO.setDeleteCbos(deleteSet); |
| | | return batchCBO; |
| | | } |
| | | |
| | | /** |
| | | * 上移 |
| | | * |
| | | * @param oid 主键 |
| | | */ |
| | | @Override |
| | | public void upOrderNum(String oid) { |
| | | CodeBasicSecDO secDO = selectByOid(oid); |
| | | BatchCBO batchCBO = new BatchCBO(); |
| | | WebUtil.setPersistence(false); |
| | | if(secDO.getOrderNum() >1){ |
| | | //等于1的时候不能上移了 |
| | | //找比自己小的 |
| | | Map<String,String> conditionMap = new HashMap<>(); |
| | | conditionMap.put("pkCodeRule",secDO.getPkCodeRule()); |
| | | conditionMap.put("ordernum",String.valueOf(secDO.getOrderNum()-1)); |
| | | List<CodeBasicSecDO> lastSecDOs = codeBasicSecMapper.selectByCondition(conditionMap,new PageHelper(-1)); |
| | | if(!CollectionUtils.isEmpty(lastSecDOs)){ |
| | | CodeBasicSecDO lastSec = lastSecDOs.get(0); |
| | | lastSec.setOrderNum(lastSec.getOrderNum()+1); |
| | | batchCBO.copyFromOther(codeBasicSecMapper.updateByPrimaryKey(lastSec)); |
| | | } |
| | | secDO.setOrderNum(secDO.getOrderNum()-1); |
| | | batchCBO.copyFromOther(codeBasicSecMapper.updateByPrimaryKey(secDO)); |
| | | } |
| | | WebUtil.setPersistence(true); |
| | | boService.persistenceBatch(batchCBO); |
| | | } |
| | | |
| | | /** |
| | | * 下移 |
| | | * |
| | | * @param oid 主键 |
| | | */ |
| | | @Override |
| | | public void downOrderNum(String oid) { |
| | | CodeBasicSecDO secDO = selectByOid(oid); |
| | | BatchCBO batchCBO = new BatchCBO(); |
| | | WebUtil.setPersistence(false); |
| | | Map<String,String> conditionMap = new HashMap<>(); |
| | | conditionMap.put("pkCodeRule",secDO.getPkCodeRule()); |
| | | Long total = codeBasicSecMapper.countByCondition(conditionMap); |
| | | if(secDO.getOrderNum() < total){ |
| | | //小于总数的时候才下移 |
| | | conditionMap.put("ordernum",String.valueOf(secDO.getOrderNum()+1)); |
| | | List<CodeBasicSecDO> lastSecDOs = codeBasicSecMapper.selectByCondition(conditionMap,new PageHelper(-1)); |
| | | if(!CollectionUtils.isEmpty(lastSecDOs)){ |
| | | CodeBasicSecDO lastSec = lastSecDOs.get(0); |
| | | lastSec.setOrderNum(lastSec.getOrderNum()-1); |
| | | batchCBO.copyFromOther(codeBasicSecMapper.updateByPrimaryKey(lastSec)); |
| | | } |
| | | secDO.setOrderNum(secDO.getOrderNum()+1); |
| | | batchCBO.copyFromOther(codeBasicSecMapper.updateByPrimaryKey(secDO)); |
| | | } |
| | | WebUtil.setPersistence(true); |
| | | boService.persistenceBatch(batchCBO); |
| | | } |
| | | } |
| | | |