| | |
| | | |
| | | 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.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.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.mapper.CodeFixedValueMapper; |
| | | import com.vci.ubcs.code.service.ICodeBasicSecService; |
| | | import com.vci.ubcs.code.service.ICodeClassifyValueService; |
| | | import com.vci.ubcs.code.service.ICodeFixedValueService; |
| | | import com.vci.ubcs.code.service.ICodeRuleService; |
| | | 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.wrapper.CodeBasicSecWrapper; |
| | | import com.vci.ubcs.starter.exception.VciBaseException; |
| | |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | 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; |
| | |
| | | private IDictBizClient iDictBizClient; |
| | | |
| | | /** |
| | | * 固定码段的码值的服务 |
| | | */ |
| | | @Resource |
| | | private ICodeFixedValueService fixedValueService; |
| | | |
| | | /** |
| | | * 上层分类码段的属性名称 |
| | | */ |
| | | private static final String PARENT_FIELD_NAME = "parentclassifysecoid"; |
| | |
| | | if (CollectionUtils.isEmpty(deleteList)){ |
| | | return true; |
| | | } |
| | | boolean deletFlag = false; |
| | | // 2、再删除基础码段 |
| | | Set<String> basicOids = deleteList.stream().map(CodeBasicSec::getOid).collect(Collectors.toSet()); |
| | | if(basicOids.size()>0 || !Func.isEmpty(basicOids)){ |
| | | deletFlag = codeBasicSecMapper.deleteBatchIds(basicOids) > 0; |
| | | } |
| | | 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()); |
| | |
| | | Set<String> fixedSecOidSet = fixedSecList.stream().map(CodeBasicSec::getOid).collect(Collectors.toSet()); |
| | | // 通过外键进行查询 |
| | | List<CodeFixedValue> fixedValueS = fixedValueMapper.selectList(Wrappers.<CodeFixedValue>query().lambda().in(CodeFixedValue::getCodeFixedSecOid,fixedSecOidSet)); |
| | | Set<String> collectOid = fixedValueS.stream().map(CodeFixedValue::getOid).collect(Collectors.toSet()); |
| | | if(collectOid.size()>0 || !Func.isEmpty(collectOid)){ |
| | | // 根据查询出来的id执行固定码段执行删除 |
| | | fixedValueMapper.deleteBatchIds(collectOid); |
| | | } |
| | | // 根据查询出来的id执行固定码段执行删除 |
| | | deletFlag = fixedValueMapper.deleteBatchIds(fixedValueS.stream().map(CodeFixedValue::getOid).collect(Collectors.toSet()))>0; |
| | | } |
| | | // 4、再删除分类码段 |
| | | List<CodeBasicSec> classifySecList = deleteList.stream().filter(sec -> { |
| | |
| | | // 将要作为删除条件的值放在一个集合里面 |
| | | Set<String> classifySecOidSet = classifySecList.stream().map(CodeBasicSec::getOid).collect(Collectors.toSet()); |
| | | // 通过外键进行查询 |
| | | List<CodeClassifyValue> classifyValues = codeClassifyValueMapper.selectList(Wrappers.<CodeClassifyValue>query().lambda().in(CodeClassifyValue::getCodeClassifySecOid,classifySecOidSet)); |
| | | List<CodeClassifyValue> fixedValueS = codeClassifyValueMapper.selectList(Wrappers.<CodeClassifyValue>query().lambda().in(CodeClassifyValue::getCodeClassifySecOid,classifySecOidSet)); |
| | | // 根据查询出来的主键id执行固定码段执行删除 |
| | | Set<String> codeclassifyOids = classifyValues.stream().map(CodeClassifyValue::getOid).collect(Collectors.toSet()); |
| | | if(codeclassifyOids.size()>0 || !Func.isEmpty(codeclassifyOids)){ |
| | | fixedValueMapper.deleteBatchIds(codeclassifyOids); |
| | | } |
| | | deletFlag = fixedValueMapper.deleteBatchIds(fixedValueS.stream().map(CodeClassifyValue::getOid).collect(Collectors.toSet()))>0; |
| | | } |
| | | return deletFlag; |
| | | } |
| | |
| | | return codeBasicSecDO; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 使用规则的主键获取对应的码段内容 |
| | | * |
| | | * @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"); |
| | | QueryWrapper<CodeBasicSec> wrapper = new QueryWrapper<>(); |
| | | wrapper.orderByAsc("ordernum"); |
| | | List<CodeBasicSec> secDOList = codeBasicSecMapper.selectList(wrapper);//.selectByCondition(conditionMap, pageHelper); |
| | | return codeBasicSecDO2VOs(secDOList,true); |
| | | } |
| | | |
| | | /** |
| | | * 批量数据对象转换为显示对象 |
| | | * |
| | | * @param codeBasicSecDOs 数据对象列表 |
| | | * @param hasFixedValue 是否有固定值 |
| | | * @return 显示对象 |
| | | * @throws VciBaseException 参数为空或者不存在的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public List<CodeBasicSecVO> codeBasicSecDO2VOs(Collection<CodeBasicSec> codeBasicSecDOs, boolean hasFixedValue) throws VciBaseException { |
| | | List<CodeBasicSecVO> voList = new ArrayList<CodeBasicSecVO>(); |
| | | if (!CollectionUtils.isEmpty(codeBasicSecDOs)) { |
| | | for (CodeBasicSec 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 codeBasicSecDO 数据对象 |
| | | * @return 显示对象 |
| | | * @throws VciBaseException 拷贝属性出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeBasicSecVO codeBasicSecDO2VO(CodeBasicSec 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; |
| | | } |
| | | } |