| | |
| | | package com.vci.ubcs.code.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.vci.ubcs.code.constant.MdmBtmTypeConstant; |
| | | import com.vci.ubcs.code.dto.CodeClassifyTemplateAttrDTO; |
| | | import com.vci.ubcs.code.entity.CodeClassifyTemplateAttr; |
| | | import com.vci.ubcs.code.entity.CodeClstemplateEntity; |
| | | import com.vci.ubcs.code.entity.CodeClassifyTemplate; |
| | | import com.vci.ubcs.code.enumpack.CodeLevelTypeEnum; |
| | | import com.vci.ubcs.code.mapper.CodeClassifyTemplateAttrMapper; |
| | | import com.vci.ubcs.code.mapper.CodeClassifyTemplateMapper; |
| | | import com.vci.ubcs.code.mapper.CodeOsbtmtypeattributeMapper; |
| | | import com.vci.ubcs.code.service.ICodeClassifyTemplateAttrService; |
| | | import com.vci.ubcs.code.service.ICodeTempphaseService; |
| | | import com.vci.ubcs.code.vo.CodeOsbtmtypeattributeVO; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeClassifyTemplateAttrVO; |
| | | import com.vci.ubcs.code.wrapper.CodeClstempattrWrapper; |
| | | import com.vci.ubcs.common.utils.PageDO2PageVO; |
| | | import com.vci.ubcs.code.wrapper.CodeClassifyTemplateAttrWrapper; |
| | | import com.vci.ubcs.starter.exception.VciBaseException; |
| | | import com.vci.ubcs.starter.util.Map2MPLLambdaUtil; |
| | | import com.vci.ubcs.starter.util.MybatisParameterUtil; |
| | | import com.vci.ubcs.starter.revision.service.RevisionModelUtil; |
| | | import com.vci.ubcs.starter.util.PatternUtil; |
| | | import com.vci.ubcs.starter.web.enumpck.VciFieldTypeEnum; |
| | | import com.vci.ubcs.starter.web.pagemodel.DataGrid; |
| | | import com.vci.ubcs.starter.web.pagemodel.PageHelper; |
| | | import com.vci.ubcs.starter.web.pagemodel.*; |
| | | import com.vci.ubcs.starter.web.util.BeanUtilForVCI; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import com.vci.ubcs.starter.web.util.VciDateUtil; |
| | | import com.vci.ubcs.system.entity.DictBiz; |
| | | import com.vci.ubcs.system.feign.IDictBizClient; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.cglib.beans.BeanMap; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.*; |
| | | import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.DATA_OID_NOT_EXIST; |
| | | |
| | | /** |
| | | * 主题库分类的模板属性服务 |
| | |
| | | */ |
| | | @Resource |
| | | private CodeClassifyTemplateAttrMapper codeClassifyTemplateAttrMapper; |
| | | |
| | | // @Resource |
| | | // CodeClstempattrMapper codeClstempattrMapper; |
| | | // @Resource |
| | | // ICodeTempphaseService codeTempphaseService; |
| | | @Resource |
| | | IDictBizClient iDictBizClient; |
| | | @Resource |
| | | CodeClassifyTemplateMapper codeClassifyTemplateMapper; |
| | | @Resource |
| | | CodeOsbtmtypeattributeMapper codeOsbtmtypeattributeMapper; |
| | | @Resource |
| | | @Lazy |
| | | ICodeTempphaseService codeTempphaseService; |
| | | /** |
| | | * 对象的操作 |
| | | */ |
| | | @Autowired(required = false) |
| | | private RevisionModelUtil revisionModelUtil; |
| | | |
| | | /** |
| | | * 查询所有的主题库分类的模板属性 |
| | |
| | | IPage<CodeClassifyTemplateAttr> doList = codeClassifyTemplateAttrMapper.selectPage(Condition.getPage(query), mpjLambdaWrapper); |
| | | IPage<CodeClassifyTemplateAttrVO> voList = new Page<>(); |
| | | if (!CollectionUtils.isEmpty(doList.getRecords())) { |
| | | voList = CodeClstempattrWrapper.build().pageVO(doList); |
| | | voList = CodeClassifyTemplateAttrWrapper.build().pageVO(doList); |
| | | } |
| | | return voList; |
| | | } |
| | | |
| | | /** |
| | | * 参照主题库分类的模板属性列表 |
| | | * @param conditionMap 查询条件 |
| | | * @param pageHelper 分页和排序 |
| | | * @return 主题库分类的模板属性显示对象列表,生效的内容 |
| | | * @throws VciBaseException 查询条件和分页出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public IPage<CodeClassifyTemplateAttrVO> refDataGridCodeClassifyTemplateAttr(Map<String, Object> conditionMap, PageHelper pageHelper) throws VciBaseException{ |
| | | if(conditionMap == null){ |
| | | conditionMap = new HashMap<String, Object>(); |
| | | } |
| | | return gridCodeClassifyTemplateAttr(Map2MPLLambdaUtil.getMPJLambdaWrapper(conditionMap, CodeClassifyTemplateAttr.class),pageHelper); |
| | | } |
| | | // /** |
| | | // * 参照主题库分类的模板属性列表 |
| | | // * @param conditionMap 查询条件 |
| | | // * @param pageHelper 分页和排序 |
| | | // * @return 主题库分类的模板属性显示对象列表,生效的内容 |
| | | // * @throws VciBaseException 查询条件和分页出错的时候会抛出异常 |
| | | // */ |
| | | // @Override |
| | | // public IPage<CodeClassifyTemplateAttrVO> refDataGridCodeClassifyTemplateAttr(Map<String, Object> conditionMap, PageHelper pageHelper) throws VciBaseException{ |
| | | // if(conditionMap == null){ |
| | | // conditionMap = new HashMap<String, Object>(); |
| | | // } |
| | | // return gridCodeClassifyTemplateAttr(Map2MPLLambdaUtil.getMPJLambdaWrapper(conditionMap, CodeClassifyTemplateAttr.class),pageHelper); |
| | | // } |
| | | |
| | | @Override |
| | | public IPage<CodeClassifyTemplateAttrVO> selectCodeClstempattrPage(IPage<CodeClassifyTemplateAttrVO> page, CodeClassifyTemplateAttrVO CodeClstempattr) { |
| | |
| | | return vo; |
| | | } |
| | | |
| | | // @Override |
| | | // public IPage<CodeClassifyTemplateAttrVO> selectCodeClstempattrPage(IPage<CodeClassifyTemplateAttrVO> page, CodeClassifyTemplateAttrVO CodeClstempattr) { |
| | | // return page.setRecords(baseMapper.selectCodeClstempattrPage(page, CodeClstempattr)); |
| | | // } |
| | | |
| | | |
| | | // /** |
| | | // * 使用模板的主键获取模板的属性--批量 |
| | | // * |
| | | // * @param templateOidCollection 模板的主键 |
| | | // * @return 属性的信息 |
| | | // */ |
| | | // @Override |
| | | // public List<CodeClassifyTemplateAttrVO> listCodeClassifyTemplateAttrByTemplateOids(Collection<String> templateOidCollection) { |
| | | // if(CollectionUtils.isEmpty(templateOidCollection)){ |
| | | // return new ArrayList<>(); |
| | | // } |
| | | // List<CodeClassifyTemplateAttr> attrDOList = new ArrayList<>(); |
| | | // VciBaseUtil.switchCollectionForOracleIn(templateOidCollection).stream().forEach(templateOids->{ |
| | | //// Map<String,String> conditionMap = new HashMap<>(); |
| | | //// conditionMap.put("classifytemplateoid", QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(templateOids.toArray(new String[0])) + ")"); |
| | | //// PageHelper pageHelper = new PageHelper(-1); |
| | | //// pageHelper.addDefaultAsc("orderNum"); |
| | | // List<CodeClassifyTemplateAttr> attrDOS = baseMapper.selectByClassifytemplateoid(VciBaseUtil.toInSql(templateOids.toArray(new String[0]))); |
| | | // |
| | | // if(!CollectionUtils.isEmpty(attrDOS)){ |
| | | // attrDOList.addAll(attrDOS); |
| | | // } |
| | | // }); |
| | | // return codeClassifyTemplateAttrDO2VOs(attrDOList); |
| | | // } |
| | | |
| | | // /** |
| | | // * 批量数据对象转换为显示对象 |
| | | // * @param codeClassifyTemplateAttrDOs 数据对象列表 |
| | | // * @return 显示对象 |
| | | // */ |
| | | // @Override |
| | | // public List<CodeClassifyTemplateAttrVO> codeClassifyTemplateAttrDO2VOs(Collection<CodeClassifyTemplateAttr> codeClassifyTemplateAttrDOs){ |
| | | // List<CodeClassifyTemplateAttrVO> voList = new ArrayList<CodeClassifyTemplateAttrVO>(); |
| | | // if(!CollectionUtils.isEmpty(codeClassifyTemplateAttrDOs)){ |
| | | // for(CodeClassifyTemplateAttr s: codeClassifyTemplateAttrDOs){ |
| | | // CodeClassifyTemplateAttrVO vo = codeClassifyTemplateAttrDO2VO(s); |
| | | // if(vo != null){ |
| | | // voList.add(vo); |
| | | // } |
| | | // } |
| | | // } |
| | | // return voList; |
| | | // } |
| | | |
| | | // /** |
| | | // * 数据对象转换为显示对象 |
| | | // * @param codeClassifyTemplateAttrDO 数据对象 |
| | | // * @return 显示对象 |
| | | // */ |
| | | // @Override |
| | | // public CodeClassifyTemplateAttrVO codeClassifyTemplateAttrDO2VO(CodeClassifyTemplateAttr codeClassifyTemplateAttrDO){ |
| | | // CodeClassifyTemplateAttrVO vo = new CodeClassifyTemplateAttrVO(); |
| | | // if(codeClassifyTemplateAttrDO != null){ |
| | | // BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDO,vo); |
| | | // //如果有lcstatus的类的话 |
| | | // vo.setAttributeDataTypeText(VciFieldTypeEnum.getTextByValue(vo.getAttributeDataType())); |
| | | // } |
| | | // return vo; |
| | | // } |
| | | |
| | | /** |
| | | * 查询所有的主题库分类的模板属性 |
| | | * @param conditionMap 查询条件 |
| | | * @param pageHelper 分页和排序 |
| | | * @return 执行结果 |
| | | */ |
| | | @Override |
| | | public DataGrid<CodeClassifyTemplateAttrVO> gridCodeClassifyTemplateAttr(Map<String, String> conditionMap, PageHelper pageHelper) { |
| | | DataGrid<CodeClassifyTemplateAttrVO> dataGrid=new DataGrid<CodeClassifyTemplateAttrVO>(); |
| | | //没有传递参数,就不执行查询逻辑 |
| | | if(conditionMap.size()==0){ |
| | | dataGrid.setData(new ArrayList<>()); |
| | | dataGrid.setTotal(0); |
| | | return dataGrid; |
| | | } |
| | | |
| | | if (pageHelper == null) { |
| | | pageHelper = new PageHelper(-1); |
| | | } |
| | | pageHelper.addDefaultAsc("ordernum"); |
| | | // IPage iPage = new IPage(); |
| | | Query query = new Query(); |
| | | query.setAscs("ordernum"); |
| | | // query.setSize(100); |
| | | if(pageHelper.getLimit() != -1){ |
| | | query.setSize(pageHelper.getLimit()); |
| | | query.setCurrent(pageHelper.getPage()); |
| | | } |
| | | // Condition.getPage(query) |
| | | CodeClassifyTemplateAttr codeClstempattrVO = new CodeClassifyTemplateAttr(); |
| | | // BeanUtil.toBean(map,codeClstempattrVO); |
| | | // BeanUtil |
| | | BeanMap beanMap = BeanMap.create(codeClstempattrVO); |
| | | |
| | | beanMap.putAll(conditionMap); |
| | | // Condition.getQueryWrapper( |
| | | IPage<CodeClassifyTemplateAttr> doList = baseMapper. |
| | | selectPage(Condition.getPage(query), Condition.getQueryWrapper(codeClstempattrVO)); |
| | | |
| | | |
| | | if (!CollectionUtils.isEmpty(doList.getRecords())) { |
| | | // CodeClstempattrEntity codeClstempattrEntity = new CodeClstempattrEntity(); |
| | | // BeanUtils.copyProperties(conditionMap, codeClstempattrEntity); |
| | | // List<CodeClstempattrEntity> codeClstempattrEntities = new ArrayList<>(); |
| | | // BeanUtils.copyProperties(doList,codeClstempattrEntities); |
| | | // codeClstempattrEntities.addAll(doList); |
| | | dataGrid.setData(codeClassifyTemplateAttrDO2VOs(doList.getRecords())); |
| | | dataGrid.setTotal(VciBaseUtil.getInt(String.valueOf(baseMapper.selectCount(Condition.getQueryWrapper(codeClstempattrVO))))); |
| | | } |
| | | return dataGrid; |
| | | } |
| | | |
| | | /** |
| | | * 增加主题库分类的模板属性 |
| | | * @param codeClassifyTemplateAttrDTO 主题库分类的模板属性数据传输对象 |
| | | * @return 执行结果 |
| | | */ |
| | | @Override |
| | | public CodeClassifyTemplateAttrVO addSave(CodeClassifyTemplateAttrDTO codeClassifyTemplateAttrDTO){ |
| | | VciBaseUtil.alertNotNull(codeClassifyTemplateAttrDTO,"需要添加的数据对象"); |
| | | //将DTO转换为DO |
| | | CodeClassifyTemplateAttr codeClassifyTemplateAttrDO = new CodeClassifyTemplateAttr(); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDO); |
| | | baseMapper.insert(codeClassifyTemplateAttrDO); |
| | | return codeClassifyTemplateAttrDO2VO(codeClassifyTemplateAttrDO); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 批量添加 |
| | | * @param codeClassifyTemplateAttrDTOs 数据传输对象 |
| | | * @return 保存后的显示对象 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public List<CodeClassifyTemplateAttrVO> batchAddSave(List<CodeClassifyTemplateAttrDTO> codeClassifyTemplateAttrDTOs) { |
| | | if(CollectionUtils.isEmpty(codeClassifyTemplateAttrDTOs)){ |
| | | return new ArrayList<>(); |
| | | } |
| | | |
| | | //取所有属性的英文名称,第三个验证需要用到 |
| | | Map<String,CodeClassifyTemplateAttrDTO> attrDTOMap =codeClassifyTemplateAttrDTOs.stream().collect(Collectors.toMap(s->s.getId().toLowerCase(Locale.ROOT), t->t)); |
| | | |
| | | //找属性中文名字重复 |
| | | Map<String, Long> nameCountMap = codeClassifyTemplateAttrDTOs.stream().collect(Collectors.groupingBy(s -> s.getName(), Collectors.counting())); |
| | | List<String> repeatNameList = nameCountMap.keySet().stream().filter(s -> nameCountMap.get(s) > 1).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(repeatNameList)){ |
| | | throw new VciBaseException("模板属性中文名称【{0}】重复",new String[]{ repeatNameList.stream().collect(Collectors.joining(","))}); |
| | | } |
| | | //找属性英文名字重复 |
| | | Map<String, Long> idCountMap = codeClassifyTemplateAttrDTOs.stream().collect(Collectors.groupingBy(s -> s.getId().toLowerCase(Locale.ROOT), Collectors.counting())); |
| | | List<String> repeatIdList = idCountMap.keySet().stream().filter(s -> idCountMap.get(s) > 1).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(repeatIdList)){ |
| | | throw new VciBaseException("模板属性英文名称【{0}】重复",new String[]{ repeatIdList.stream().collect(Collectors.joining(","))}); |
| | | } |
| | | |
| | | //模板oid |
| | | String CLASSIFYTEMPLATEOID = null; |
| | | //转换 |
| | | List<CodeClassifyTemplateAttr> codeClassifyTemplateAttrDOInsert = new ArrayList<CodeClassifyTemplateAttr>(); |
| | | List<String> prefix = new ArrayList<>(); |
| | | List<String> suffix = new ArrayList<>(); |
| | | List<String> dateFormates = new ArrayList<>(); |
| | | for (CodeClassifyTemplateAttrDTO codeClassifyTemplateAttrDTO:codeClassifyTemplateAttrDTOs){ |
| | | VciBaseUtil.alertNotNull(codeClassifyTemplateAttrDTO,"需要添加的数据对象"); |
| | | //将DTO转换为DO |
| | | CodeClassifyTemplateAttr codeClassifyTemplateAttrDO = new CodeClassifyTemplateAttr(); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDO); |
| | | codeClassifyTemplateAttrDOInsert.add(codeClassifyTemplateAttrDO); |
| | | |
| | | if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getPrefixValue())){ |
| | | prefix.add(codeClassifyTemplateAttrDO.getPrefixValue()); |
| | | } |
| | | if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getSuffixValue())){ |
| | | suffix.add(codeClassifyTemplateAttrDO.getSuffixValue()); |
| | | } |
| | | if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getCodeDateFormat())){ |
| | | dateFormates.add(codeClassifyTemplateAttrDO.getCodeDateFormat()); |
| | | } |
| | | //判断传过来的枚举注入是否是jsonArr格式 |
| | | if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getEnumString())&&!checkKVArr(codeClassifyTemplateAttrDO.getEnumString())){ |
| | | throw new VciBaseException("{0}{1}属性的枚举注入数据格式错误!",new String[]{codeClassifyTemplateAttrDO.getId(),codeClassifyTemplateAttrDO.getName()}); |
| | | } |
| | | //分类注入 |
| | | if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getClassifyInvokeAttr()) |
| | | && !CodeLevelTypeEnum.MIN.getValue().equalsIgnoreCase(codeClassifyTemplateAttrDO.getClassifyInvokeLevel()) |
| | | && VciBaseUtil.getInt(codeClassifyTemplateAttrDO.getClassifyInvokeLevel()) < 0){ |
| | | throw new VciBaseException("{0}{1}属性的是分类注入,但是注入层级不能小于0!",new String[]{codeClassifyTemplateAttrDO.getId(),codeClassifyTemplateAttrDO.getName()}); |
| | | } |
| | | |
| | | //判断传过来的参照配置是否是json格式 |
| | | if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getReferConfig())&&!checkKVObj(codeClassifyTemplateAttrDO.getReferConfig())){ |
| | | throw new VciBaseException("{0}{1}属性的参照配置数据格式错误!",new String[]{codeClassifyTemplateAttrDO.getId(),codeClassifyTemplateAttrDO.getName()}); |
| | | } |
| | | if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getCodeDateFormat()) && !checkDateFormat(codeClassifyTemplateAttrDO.getCodeDateFormat())){ |
| | | throw new VciBaseException("{0}{1}属性的时间格式不符合要求",new String[]{codeClassifyTemplateAttrDO.getId(),codeClassifyTemplateAttrDO.getName()}); |
| | | } |
| | | //如果是组合规则,里面使用的属性不能缺失,也都得显示 |
| | | String componentrule = codeClassifyTemplateAttrDTO.getComponentrule(); |
| | | boolean isContainsDynamicParameter = PatternUtil.isContainsDynamicParameter(componentrule); |
| | | if(isContainsDynamicParameter){ |
| | | List<String> userdAttrList = PatternUtil.getKeyListByContent(componentrule);//包含的所有${xxx}中的xxx |
| | | if(!CollectionUtils.isEmpty(userdAttrList)){ |
| | | String unExistAttr = userdAttrList.stream().filter(s -> !attrDTOMap.containsKey(s.toLowerCase(Locale.ROOT))).collect(Collectors.joining(",")); |
| | | if(StringUtils.isNotBlank(unExistAttr)){ |
| | | throw new VciBaseException("{0}属性是组合规则,但是规则里包含的属性[{1}]在当前模板中不存在!",new String[]{codeClassifyTemplateAttrDO.getName(), unExistAttr}); |
| | | } |
| | | //要看看表单是否显示 |
| | | String unFormDisplayAttr = userdAttrList.stream().filter(s -> !VciBaseUtil.getBoolean(attrDTOMap.getOrDefault(s.toLowerCase(Locale.ROOT), |
| | | new CodeClassifyTemplateAttrDTO()).getFormdisplayflag())).collect(Collectors.joining(",")); |
| | | if(StringUtils.isNotBlank(unFormDisplayAttr)){ |
| | | throw new VciBaseException("{0}属性是组合规则,但是规则里包含的属性[{1}]在当前模板中没有设置 表单显示 ",new String[]{codeClassifyTemplateAttrDO.getName(),unFormDisplayAttr}); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if(CLASSIFYTEMPLATEOID==null){ |
| | | CLASSIFYTEMPLATEOID = codeClassifyTemplateAttrDTO.getClassifytemplateoid(); |
| | | } |
| | | |
| | | } |
| | | |
| | | //执行数据保存操作 |
| | | // WebUtil.setPersistence(false);//不执行保存 |
| | | |
| | | //先都删了 |
| | | // VciQueryWrapperForDO deleteAttrWrapper = new VciQueryWrapperForDO(CodeClassifyTemplateAttrDO.class); |
| | | // deleteAttrWrapper.addQueryMap("CLASSIFYTEMPLATEOID",CLASSIFYTEMPLATEOID); |
| | | Map<String,Object> condition = new HashMap<>(); |
| | | condition.put("CLASSIFYTEMPLATEOID",CLASSIFYTEMPLATEOID); |
| | | List<CodeClassifyTemplateAttr> codeClassifyTemplateAttrDODelete = baseMapper.selectByMap(condition); |
| | | |
| | | //oids |
| | | List<String> oids = new ArrayList<String>(); |
| | | for (CodeClassifyTemplateAttr codeClassifyTemplateAttrDO:codeClassifyTemplateAttrDODelete){ |
| | | oids.add(codeClassifyTemplateAttrDO.getOid()); |
| | | } |
| | | // BatchCBO batchCBOTemplateDelete = new BatchCBO(); |
| | | if(!CollectionUtils.isEmpty(oids)){ |
| | | baseMapper.deleteBatchIds(oids); |
| | | } |
| | | |
| | | //再新增 |
| | | if(!CollectionUtils.isEmpty(codeClassifyTemplateAttrDOInsert)){ |
| | | this.saveBatch(codeClassifyTemplateAttrDOInsert); |
| | | } |
| | | |
| | | //调用阶段 |
| | | if(!CollectionUtils.isEmpty(codeClassifyTemplateAttrDOInsert)){ |
| | | codeTempphaseService.codeTemplateAttrModifyTrigger(codeClassifyTemplateAttrDOInsert); |
| | | |
| | | } |
| | | |
| | | |
| | | // SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo(); |
| | | //处理可输可选的字符 |
| | | if(!CollectionUtils.isEmpty(prefix)){ |
| | | for (String s : prefix) { |
| | | DictBiz dictBiz = new DictBiz(); |
| | | dictBiz.setCode(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR); |
| | | dictBiz.setDictKey(s); |
| | | dictBiz.setDictValue("prefix"); |
| | | iDictBizClient.getCheck(dictBiz) ; |
| | | } |
| | | // .saveBySameNamespaceAndFlag(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR,"prefix",prefix,sessionInfo); |
| | | } |
| | | if(!CollectionUtils.isEmpty(suffix)){ |
| | | for (String s : suffix) { |
| | | DictBiz dictBiz = new DictBiz(); |
| | | dictBiz.setCode(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR); |
| | | dictBiz.setDictKey(s); |
| | | dictBiz.setDictValue("suffix"); |
| | | iDictBizClient.getCheck(dictBiz) ; |
| | | } |
| | | // charService.saveBySameNamespaceAndFlag(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR,"suffix",suffix,sessionInfo); |
| | | } |
| | | if(!CollectionUtils.isEmpty(dateFormates)){ |
| | | for (String s : dateFormates) { |
| | | DictBiz dictBiz = new DictBiz(); |
| | | dictBiz.setCode(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR); |
| | | dictBiz.setDictKey(s); |
| | | dictBiz.setDictValue("dateFormates"); |
| | | iDictBizClient.getCheck(dictBiz) ; |
| | | } |
| | | // charService.saveBySameNamespaceAndFlag(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR,"dateFormates",dateFormates,sessionInfo); |
| | | } |
| | | |
| | | // WebUtil.setPersistence(true);//执行保存 |
| | | // boService.persistenceBatch(batchCBOTemplateDelete);//一起执行保存 |
| | | return codeClassifyTemplateAttrDO2VOs(codeClassifyTemplateAttrDOInsert); |
| | | } |
| | | |
| | | public boolean checkKVArr(String kvString){ |
| | | boolean isKV = true; |
| | | try { |
| | | JSONObject.parseArray(kvString, KeyValue.class); |
| | | }catch (Exception e){ |
| | | isKV=false; |
| | | } |
| | | return isKV; |
| | | } |
| | | public boolean checkKVObj(String kvString){ |
| | | boolean isKV = true; |
| | | try { |
| | | JSONObject.parseObject(kvString, UIFormReferVO.class); |
| | | }catch (Exception e){ |
| | | isKV=false; |
| | | } |
| | | return isKV; |
| | | } |
| | | |
| | | /** |
| | | * 校验时间格式 |
| | | * @param dateFormat 时间格式 |
| | | * @return true表示校验通过 |
| | | */ |
| | | public boolean checkDateFormat(String dateFormat){ |
| | | try{ |
| | | VciDateUtil.date2Str(new Date(),dateFormat); |
| | | return true; |
| | | }catch (Throwable e){ |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改主题库分类的模板属性 |
| | | * @param codeClassifyTemplateAttrDTO 主题库分类的模板属性数据传输对象 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 参数为空,唯一项,必输项不通过时会抛出异常 |
| | | */ |
| | | @Override |
| | | public R editSave(CodeClassifyTemplateAttrDTO codeClassifyTemplateAttrDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeClassifyTemplateAttrDTO,"数据对象",codeClassifyTemplateAttrDTO.getOid(),"主题库分类的模板属性主键"); |
| | | |
| | | //判断传过来的枚举注入是否是jsonArr格式 |
| | | if(StringUtils.isNotBlank(codeClassifyTemplateAttrDTO.getEnumString())&&!checkKVArr(codeClassifyTemplateAttrDTO.getEnumString())){ |
| | | throw new VciBaseException("枚举注入数据格式错误!"); |
| | | } |
| | | |
| | | //判断传过来的参照配置是否是json格式 |
| | | if(StringUtils.isNotBlank(codeClassifyTemplateAttrDTO.getReferbtmid())&&!checkKVObj(codeClassifyTemplateAttrDTO.getReferbtmid())){ |
| | | throw new VciBaseException("枚举注入数据格式错误!"); |
| | | } |
| | | |
| | | |
| | | //检查ts |
| | | CodeClassifyTemplateAttr codeClassifyTemplateAttrDOCopyFromDTO = new CodeClassifyTemplateAttr(); |
| | | // BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDOCopyFromDTO); |
| | | // boolean tsBoolean = boService.checkTs(codeClassifyTemplateAttrDOCopyFromDTO); |
| | | |
| | | //检查ts |
| | | // Map<String,Object> condition = new HashMap<>(2); |
| | | // condition.put("oid",codeClassifyTemplateAttrDTO.getOid()); |
| | | // condition.put("ts",codeClassifyTemplateAttrDTO.getTs()); |
| | | CodeClassifyTemplateAttr detail = baseMapper.selectById(codeClassifyTemplateAttrDTO.getOid()); |
| | | if(!detail.getTs().toString().equals(codeClassifyTemplateAttrDTO.getTs().toString())){//不是最新的不让改 |
| | | return R.fail("当前数据不是最新,请刷新后再修改!"); |
| | | } |
| | | |
| | | //将DTO转换为DO |
| | | CodeClassifyTemplateAttr codeClassifyTemplateAttrDO = baseMapper.selectById(codeClassifyTemplateAttrDTO.getOid()); |
| | | revisionModelUtil.copyFromDTOIgnore(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDO); |
| | | baseMapper.updateById(codeClassifyTemplateAttrDO); |
| | | return R.data(codeClassifyTemplateAttrDO2VO(codeClassifyTemplateAttrDO)); |
| | | } |
| | | |
| | | /** |
| | | * 删除主题库分类的模板属性 |
| | | * @param codeClassifyTemplateAttrDTO 主题库分类的模板属性数据传输对象,oid和ts需要传输 |
| | | * @return 删除结果反馈::success:成功,fail:失败 |
| | | * @throws VciBaseException 参数为空,被引用时抛出异常 |
| | | */ |
| | | @Override |
| | | public R deleteCodeClassifyTemplateAttr(CodeClassifyTemplateAttrDTO codeClassifyTemplateAttrDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeClassifyTemplateAttrDTO,"主题库分类的模板属性数据对象",codeClassifyTemplateAttrDTO.getOid(),"主题库分类的模板属性的主键"); |
| | | CodeClassifyTemplateAttr codeClassifyTemplateAttrDO = baseMapper.selectById(codeClassifyTemplateAttrDTO.getOid()); |
| | | R baseResult = checkIsCanDeleteForDO(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDO); |
| | | if(baseResult.isSuccess()) { |
| | | }else{ |
| | | return baseResult; |
| | | } |
| | | //执行删除操作 |
| | | int deleteNum = baseMapper.deleteById(codeClassifyTemplateAttrDO.getOid()); |
| | | return deleteNum>0?R.success(DELETE_SUCCESS):R.fail(DELETE_FAIL); |
| | | } |
| | | |
| | | /** |
| | | * 校验是否可以删除,如果存在下级,并且下级有数据引用则不能删除 |
| | | * @param codeClassifyTemplateAttrDTO 数据传输对象 |
| | | * @param codeClassifyTemplateAttrDO 数据库中的数据对象 |
| | | * @return success为true为可以删除,false表示有数据引用,obj为true表示有下级 |
| | | */ |
| | | private R checkIsCanDeleteForDO(CodeClassifyTemplateAttrDTO codeClassifyTemplateAttrDTO, CodeClassifyTemplateAttr codeClassifyTemplateAttrDO) { |
| | | // boService.checkTs(codeClassifyTemplateAttrDO); |
| | | // Map<String,Object> condition = new HashMap<>(2); |
| | | // condition.put("oid",codeClassifyTemplateAttrDTO.getOid()); |
| | | // condition.put("ts",codeClassifyTemplateAttrDTO.getTs()); |
| | | CodeClassifyTemplateAttr detail = baseMapper.selectById(codeClassifyTemplateAttrDTO.getOid()); |
| | | // .selectOne(Condition.getQueryWrapper(condition,CodeClstempattrEntity.class)); |
| | | |
| | | if(!detail.getTs().toString().equals(codeClassifyTemplateAttrDTO.getTs().toString())){//不是最新的不让改 |
| | | return R.fail("当前数据不是最新,请刷新后再修改!"); |
| | | } |
| | | if(!checkIsLinked(codeClassifyTemplateAttrDO.getOid())) { |
| | | return R.success("可以删除!"); |
| | | }else{ |
| | | return R.fail(DATA_LINKED_NOT_DELETE); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 校验是否被引用 |
| | | * @param oid 主键 |
| | | * @throws VciBaseException 被引用的时候会抛出异常 |
| | | */ |
| | | private boolean checkIsLinked(String oid) throws VciBaseException{ |
| | | //TODO 添加需要校验引用的地方 |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 主键获取主题库分类的模板属性 |
| | | * @param oid 主键 |
| | | * @return 主题库分类的模板属性显示对象 |
| | | * @throws VciBaseException 参数为空,数据不存在时会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeClassifyTemplateAttrVO getObjectByOid(String oid) throws VciBaseException{ |
| | | return codeClassifyTemplateAttrDO2VO(selectByOid(oid)); |
| | | } |
| | | /** |
| | | * 主键查询数据对象 |
| | | * @param oid 主键 |
| | | * @return 数据对象 |
| | | * @throws VciBaseException 参数为空,并且数据不存在的时候会抛出异常 |
| | | */ |
| | | private CodeClassifyTemplateAttr selectByOid(String oid) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(oid,"主键"); |
| | | CodeClassifyTemplateAttr codeClassifyTemplateAttrDO = baseMapper.selectById(oid.trim()); |
| | | if(codeClassifyTemplateAttrDO == null || StringUtils.isBlank(codeClassifyTemplateAttrDO.getOid())){ |
| | | throw new VciBaseException(DATA_OID_NOT_EXIST); |
| | | } |
| | | return codeClassifyTemplateAttrDO; |
| | | } |
| | | |
| | | /** |
| | | * 主键批量获取主题库分类的模板属性 |
| | | * @param oidCollections 主键集合,但是受性能影响,建议一次查询不超过10000个 |
| | | * @return 主题库分类的模板属性显示对象 |
| | | * @throws VciBaseException 查询出现异常时会抛出 |
| | | */ |
| | | @Override |
| | | public Collection<CodeClassifyTemplateAttrVO> listCodeClassifyTemplateAttrByOids(Collection<String> oidCollections) { |
| | | VciBaseUtil.alertNotNull(oidCollections,"数据对象主键集合"); |
| | | List<CodeClassifyTemplateAttr> codeClassifyTemplateAttrDOList = listCodeClassifyTemplateAttrDOByOidCollections(oidCollections); |
| | | return codeClassifyTemplateAttrDO2VOs(codeClassifyTemplateAttrDOList); |
| | | } |
| | | |
| | | /** |
| | | * 使用主键集合查询数据对象 |
| | | * @param oidCollections 主键的集合 |
| | | * @return 数据对象列表 |
| | | */ |
| | | private List<CodeClassifyTemplateAttr> listCodeClassifyTemplateAttrDOByOidCollections(Collection<String> oidCollections){ |
| | | List<CodeClassifyTemplateAttr> codeClassifyTemplateAttrDOList = new ArrayList<CodeClassifyTemplateAttr>(); |
| | | if(!CollectionUtils.isEmpty(oidCollections)){ |
| | | Collection<Collection<String>> oidCollectionsList = VciBaseUtil.switchCollectionForOracleIn(oidCollections); |
| | | for(Collection<String> oids: oidCollectionsList){ |
| | | List<CodeClassifyTemplateAttr> tempDOList = baseMapper.selectBatchIds(oids); |
| | | if(!CollectionUtils.isEmpty(tempDOList)){ |
| | | codeClassifyTemplateAttrDOList.addAll(tempDOList); |
| | | } |
| | | } |
| | | } |
| | | return codeClassifyTemplateAttrDOList; |
| | | } |
| | | |
| | | /** |
| | | * 参照主题库分类的模板属性列表 |
| | | * @param conditionMap 查询条件 |
| | | * @param pageHelper 分页和排序 |
| | | * @return 主题库分类的模板属性显示对象列表,生效的内容 |
| | | * @throws VciBaseException 查询条件和分页出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public DataGrid<CodeClassifyTemplateAttrVO> refDataGridCodeClassifyTemplateAttr(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException{ |
| | | if(conditionMap == null){ |
| | | conditionMap = new HashMap<String, String>(); |
| | | } |
| | | return gridCodeClassifyTemplateAttr(conditionMap,pageHelper); |
| | | } |
| | | |
| | | /** |
| | | * 查询这个模板,业务类型下的所有未选择的属性 |
| | | * @param baseQueryObject |
| | | * @return |
| | | */ |
| | | @Override |
| | | public DataGrid<CodeOsbtmtypeattributeVO> codeClassifyTemplateAttrByBtm(BaseQueryObject baseQueryObject){ |
| | | if(baseQueryObject.getConditionMap() == null){ |
| | | baseQueryObject.setConditionMap(new HashMap<>()); |
| | | } |
| | | DataGrid<CodeOsbtmtypeattributeVO> dataGrid=new DataGrid<CodeOsbtmtypeattributeVO>(); |
| | | //模板oid |
| | | String templateAttrOid = baseQueryObject.getConditionMap().get("oid"); |
| | | String name = baseQueryObject.getConditionMap().getOrDefault("name",""); |
| | | String id = baseQueryObject.getConditionMap().getOrDefault("id",""); |
| | | |
| | | //没有oid不执行逻辑 |
| | | if(StringUtils.isBlank(templateAttrOid)){ |
| | | dataGrid.setData(new ArrayList<>()); |
| | | dataGrid.setTotal(0); |
| | | return dataGrid; |
| | | } |
| | | |
| | | //查询模板对象 |
| | | CodeClassifyTemplate codeClassifyTemplateDO = codeClassifyTemplateMapper.selectById(templateAttrOid); |
| | | |
| | | //这个业务类型下的所有属性 |
| | | List<CodeOsbtmtypeattributeVO> boAttrs = (List<CodeOsbtmtypeattributeVO>) codeOsbtmtypeattributeMapper.selectById(codeClassifyTemplateDO.getBtmTypeId());// this.btmService.listAttributeByBtmId(codeClassifyTemplateDO.getBtmTypeId()); |
| | | // codeOsbtmtypeattributeMapper.selectById(codeClassifyTemplateDO.getBtmTypeId()); |
| | | // BeanUtils.copyProperties(codeOsbtmtypeattributeMapper.selectById(codeClassifyTemplateDO.getBtmTypeId()),boAttrs); |
| | | //把默认的属性也添加到boAttrs |
| | | if(boAttrs == null){ |
| | | boAttrs = new ArrayList<>(); |
| | | } |
| | | if(!false){ |
| | | // List<CodeOsbtmtypeattributeVO> finalBoAttrs = boAttrs; |
| | | // attributeService.getDefaultAttributeVOs().stream().forEach(attr-> { |
| | | // CodeOsbtmtypeattributeVO attributeVO = new CodeOsbtmtypeattributeVO(); |
| | | // BeanUtil.convert(attr, attributeVO); |
| | | // if ("id".equalsIgnoreCase(attributeVO.getId())) { |
| | | // attributeVO.setName("企业编码"); |
| | | // } |
| | | // if ("name".equalsIgnoreCase(attributeVO.getId())) { |
| | | // attributeVO.setName("集团码"); |
| | | // } |
| | | // attributeVO.setAttrDataType(attr.getAttributeDataType()); |
| | | // attributeVO.setAttributeLength(attr.getAttrLength()); |
| | | // attributeVO.setReferBtmTypeId(attr.getBtmTypeId()); |
| | | // attributeVO.setReferBtmTypeName(attr.getBtmTypeName()); |
| | | // finalBoAttrs.add(attributeVO); |
| | | // }); |
| | | // boAttrs = finalBoAttrs; |
| | | Object o = null; |
| | | } |
| | | |
| | | //这个模板下已经有的属性 |
| | | // VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(CodeClassifyTemplateAttrDO.class); |
| | | // queryWrapper.addQueryMap("CLASSIFYTEMPLATEOID",templateAttrOid); |
| | | Map<String,Object> condition = new HashMap<>(1); |
| | | condition.put("CLASSIFYTEMPLATEOID",templateAttrOid); |
| | | List<CodeClassifyTemplateAttr> codeClassifyTemplateAttrDOList = baseMapper.selectByMap(condition); |
| | | |
| | | List<String> btmOids = new ArrayList<String>(); |
| | | for (CodeClassifyTemplateAttr codeClassifyTemplateAttrDO:codeClassifyTemplateAttrDOList){ |
| | | btmOids.add(codeClassifyTemplateAttrDO.getId()); |
| | | } |
| | | |
| | | //过滤掉已经存在的属性 |
| | | List<CodeOsbtmtypeattributeVO> boAttrss = new ArrayList<CodeOsbtmtypeattributeVO>(); |
| | | |
| | | for (CodeOsbtmtypeattributeVO osBtmTypeAttributeVO:boAttrs){ |
| | | if(!btmOids.contains(osBtmTypeAttributeVO.getId())){ |
| | | //看看是不是有模糊查询 |
| | | boolean inSearch = true; |
| | | if(StringUtils.isNotBlank(name) && !osBtmTypeAttributeVO.getName().contains(name.replace("*",""))){ |
| | | inSearch = false; |
| | | } |
| | | if(StringUtils.isNotBlank(id) && !osBtmTypeAttributeVO.getId().contains(id.replace("*",""))){ |
| | | inSearch = false; |
| | | } |
| | | if(inSearch) { |
| | | boAttrss.add(osBtmTypeAttributeVO); |
| | | } |
| | | } |
| | | } |
| | | dataGrid.setData(boAttrss); |
| | | dataGrid.setTotal(boAttrss.size()); |
| | | return dataGrid; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询这个模板,业务类型下已选择的属性 |
| | | * @param baseQueryObject |
| | | * @return |
| | | */ |
| | | @Override |
| | | public DataGrid<CodeOsbtmtypeattributeVO> codeClassifyTemplateAttrByBtmHave(BaseQueryObject baseQueryObject){ |
| | | DataGrid<CodeOsbtmtypeattributeVO> dataGrid=new DataGrid<CodeOsbtmtypeattributeVO>(); |
| | | //模板oid |
| | | String templateAttrOid = baseQueryObject.getConditionMap().get("oid"); |
| | | |
| | | //没有oid不执行逻辑 |
| | | if(StringUtils.isBlank(templateAttrOid)){ |
| | | dataGrid.setData(new ArrayList<>()); |
| | | dataGrid.setTotal(0); |
| | | return dataGrid; |
| | | } |
| | | |
| | | //查询模板对象 |
| | | CodeClassifyTemplate codeClassifyTemplateDO = codeClassifyTemplateMapper.selectById(templateAttrOid); |
| | | |
| | | //这个业务类型下的所有属性 |
| | | List<CodeOsbtmtypeattributeVO> boAttrs = (List<CodeOsbtmtypeattributeVO>) codeOsbtmtypeattributeMapper.selectById(codeClassifyTemplateDO.getBtmTypeId());//this.btmService.listAttributeByBtmIdHasDefault(codeClassifyTemplateDO.getBtmTypeId()); |
| | | // codeOsbtmtypeattributeMapper.selectById(codeClassifyTemplateDO.getBtmTypeId()); |
| | | // BeanUtils.copyProperties(codeOsbtmtypeattributeMapper.selectById(codeClassifyTemplateDO.getBtmTypeId()),boAttrs); |
| | | //这个模板下已经有的属性 |
| | | //把默认的属性也添加到boAttrs |
| | | if(boAttrs == null){ |
| | | boAttrs = new ArrayList<>(); |
| | | } |
| | | // VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(CodeClassifyTemplateAttrDO.class); |
| | | // queryWrapper.addQueryMap("CLASSIFYTEMPLATEOID",templateAttrOid); |
| | | |
| | | // Map<String,Object> condition = new HashMap<>(1); |
| | | // condition.put("CLASSIFYTEMPLATEOID",templateAttrOid); |
| | | |
| | | QueryWrapper<CodeClassifyTemplateAttr> wrapper=new QueryWrapper<>(); |
| | | wrapper.eq("CLASSIFYTEMPLATEOID",templateAttrOid); |
| | | |
| | | List<CodeClassifyTemplateAttr> codeClassifyTemplateAttrDOList = baseMapper.selectList(wrapper); |
| | | List<String> btmOids = new ArrayList<String>(); |
| | | for (CodeClassifyTemplateAttr codeClassifyTemplateAttrDO:codeClassifyTemplateAttrDOList){ |
| | | btmOids.add(codeClassifyTemplateAttrDO.getId()); |
| | | } |
| | | |
| | | //过滤掉除了自身的别的属性 |
| | | List<CodeOsbtmtypeattributeVO> boAttrss = new ArrayList<CodeOsbtmtypeattributeVO>(); |
| | | |
| | | for (CodeOsbtmtypeattributeVO osBtmTypeAttributeVO:boAttrs){ |
| | | if(btmOids.contains(osBtmTypeAttributeVO.getId())){ |
| | | boAttrss.add(osBtmTypeAttributeVO); |
| | | } |
| | | } |
| | | dataGrid.setData(boAttrss); |
| | | dataGrid.setTotal(boAttrss.size()); |
| | | return dataGrid; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 同步到其他模板 |
| | | * @param codeClassifyTemplateAttrDTO oid |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R copyto(CodeClassifyTemplateAttrDTO codeClassifyTemplateAttrDTO) throws VciBaseException{ |
| | | |
| | | String templateAttrOid = codeClassifyTemplateAttrDTO.getOid(); |
| | | |
| | | //查询出来要复制的对象 |
| | | CodeClassifyTemplateAttr codeClassifyTemplateAttrDO = selectByOid(templateAttrOid); |
| | | String id = codeClassifyTemplateAttrDO.getId();//英文名称 |
| | | String classfyTemplateOid = codeClassifyTemplateAttrDO.getClassifyTemplateOid(); |
| | | |
| | | //查询其他id=id的模板属性 |
| | | // VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(CodeClassifyTemplateAttrDO.class); |
| | | // queryWrapper.addQueryMap("id",id); |
| | | // Map<String,Object> condition = new HashMap<>(1); |
| | | // condition.put("id",id); |
| | | QueryWrapper<CodeClassifyTemplateAttr> wrapper=new QueryWrapper<>(); |
| | | wrapper.eq("id",id); |
| | | //所有id=id的模板属性 |
| | | List<CodeClassifyTemplateAttr> codeClassifyTemplateAttrDOList =baseMapper.selectList(wrapper); |
| | | |
| | | //要删除的模板属性的oids |
| | | List<String> deleteOids = new ArrayList<String>(); |
| | | //要修改的模板属性对象 |
| | | List<CodeClassifyTemplateAttr> codeClassifyTemplateAttrDOListInsert = new ArrayList<CodeClassifyTemplateAttr>(); |
| | | for (CodeClassifyTemplateAttr codeClassifyTemplateAttrDOi:codeClassifyTemplateAttrDOList){ |
| | | String oid = codeClassifyTemplateAttrDOi.getOid(); |
| | | String templateOldOid = codeClassifyTemplateAttrDOi.getClassifyTemplateOid(); |
| | | |
| | | CodeClassifyTemplateAttr codeClassifyTemplateAttrDOInsert = new CodeClassifyTemplateAttr(); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDO,codeClassifyTemplateAttrDOInsert); |
| | | codeClassifyTemplateAttrDOInsert.setOid(oid); |
| | | codeClassifyTemplateAttrDOInsert.setClassifyTemplateOid(templateOldOid); |
| | | codeClassifyTemplateAttrDOListInsert.add(codeClassifyTemplateAttrDOInsert); |
| | | |
| | | deleteOids.add(codeClassifyTemplateAttrDOi.getOid()); |
| | | } |
| | | |
| | | // WebUtil.setPersistence(false);//不执行保存 |
| | | |
| | | //删除 |
| | | // BatchCBO batchCBOTemplateAttrDelete = codeClassifyTemplateAttrDOissifyTemplateAttrMapper.batchDeleteByOids(deleteOids); |
| | | baseMapper.deleteBatchIds(deleteOids); |
| | | //再新增 |
| | | // BatchCBO batchCBOTemplateAttrInsert = codeClassifyTemplateAttrMapper.batchInsert(codeClassifyTemplateAttrDOListInsert); |
| | | // batchCBOTemplateAttrDelete.copyFromOther(batchCBOTemplateAttrInsert); |
| | | this.saveBatch(codeClassifyTemplateAttrDOListInsert); |
| | | |
| | | // WebUtil.setPersistence(true);//执行保存 |
| | | // boService.persistenceBatch(batchCBOTemplateAttrDelete);//一起执行保存 |
| | | |
| | | return R.success("操作成功!"); |
| | | } |
| | | |
| | | } |