| | |
| | | package com.vci.ubcs.code.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.vci.ubcs.code.constant.MdmBtmTypeConstant; |
| | | import com.vci.ubcs.code.dao.CodeClassifyTemplateAttrDaoI; |
| | | import com.vci.ubcs.code.dao.CodeClassifyTemplateDaoI; |
| | | import com.vci.ubcs.code.enumpack.CodeLevelTypeEnum; |
| | | import com.vci.ubcs.code.model.CodeClassifyTemplateAttrDO; |
| | | import com.vci.ubcs.code.model.CodeClassifyTemplateDO; |
| | | import com.vci.ubcs.code.service.CodeClassifyTemplateAttrServiceI; |
| | | import com.vci.ubcs.code.service.CodeTemplatePhaseServiceI; |
| | | import com.vci.ubcs.code.utils.PatternUtil; |
| | | import com.vci.starter.revision.service.RevisionModelUtil; |
| | | import com.vci.starter.web.constant.QueryOptionConstant; |
| | | import com.vci.starter.web.enumpck.VciFieldTypeEnum; |
| | | import com.vci.starter.web.exception.VciBaseException; |
| | | import com.vci.starter.web.pagemodel.*; |
| | | import com.vci.starter.web.util.BeanUtil; |
| | | import com.vci.starter.web.util.BeanUtilForVCI; |
| | | import com.vci.starter.web.util.VciBaseUtil; |
| | | import com.vci.starter.web.util.VciDateUtil; |
| | | import com.vci.starter.web.wrapper.VciQueryWrapperForDO; |
| | | import com.vci.web.pageModel.BatchCBO; |
| | | import com.vci.web.pageModel.OsBtmTypeAttributeVO; |
| | | import com.vci.web.pageModel.UIFormReferVO; |
| | | import com.vci.web.service.BdSelectInputCharServiceI; |
| | | import com.vci.web.service.OsAttributeServiceI; |
| | | import com.vci.web.service.OsBtmServiceI; |
| | | import com.vci.web.service.WebBoServiceI; |
| | | import com.vci.web.util.WebUtil; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | 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.dto.CodeClassifyTemplateAttrDTO; |
| | | import com.vci.ubcs.code.entity.CodeClassify; |
| | | import com.vci.ubcs.code.entity.CodeClassifyTemplateAttr; |
| | | 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.service.ICodeClassifyTemplateAttrService; |
| | | import com.vci.ubcs.code.service.ICodeReferConfigService; |
| | | import com.vci.ubcs.code.service.ICodeTempphaseService; |
| | | import com.vci.ubcs.code.vo.CodeReferConfigVO; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeClassifyTemplateAttrVO; |
| | | import com.vci.ubcs.code.vo.pagemodel.UIFormReferVO; |
| | | import com.vci.ubcs.code.wrapper.CodeClassifyTemplateAttrWrapper; |
| | | import com.vci.ubcs.omd.feign.IBtmTypeClient; |
| | | import com.vci.ubcs.omd.vo.BtmTypeAttributeVO; |
| | | import com.vci.ubcs.omd.vo.BtmTypeVO; |
| | | import com.vci.ubcs.starter.exception.VciBaseException; |
| | | import com.vci.ubcs.starter.revision.service.RevisionModelUtil; |
| | | import com.vci.ubcs.starter.util.DefaultAttrAssimtUtil; |
| | | import com.vci.ubcs.starter.util.MdmBtmTypeConstant; |
| | | import com.vci.ubcs.starter.util.PatternUtil; |
| | | import com.vci.ubcs.starter.util.UBCSCondition; |
| | | import com.vci.ubcs.starter.web.enumpck.VciFieldTypeEnum; |
| | | import com.vci.ubcs.starter.web.pagemodel.*; |
| | | import com.vci.ubcs.starter.web.pagemodel.PageHelper; |
| | | 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.log.exception.ServiceException; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | 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; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.vci.frameworkcore.constant.FrameWorkBusLangCodeConstant.DATA_OID_NOT_EXIST; |
| | | import static com.vci.frameworkcore.constant.FrameWorkLangCodeConstant.*; |
| | | import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.*; |
| | | import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.DATA_OID_NOT_EXIST; |
| | | |
| | | /** |
| | | * 主题库分类的模板属性服务 |
| | | * @author weidy |
| | | * @date 2022-01-24 |
| | | * @author ludc |
| | | * @date 2023/5/5 |
| | | */ |
| | | @Service |
| | | public class CodeClassifyTemplateAttrServiceImpl implements CodeClassifyTemplateAttrServiceI { |
| | | public class CodeClassifyTemplateAttrServiceImpl extends ServiceImpl<CodeClassifyTemplateAttrMapper, CodeClassifyTemplateAttr> implements ICodeClassifyTemplateAttrService { |
| | | |
| | | /** |
| | | * 日志 |
| | | */ |
| | | private Logger logger = LoggerFactory.getLogger(getClass()); |
| | | /** |
| | | * 数据操作层 |
| | | */ |
| | | @Resource |
| | | private CodeClassifyTemplateAttrMapper codeClassifyTemplateAttrMapper; |
| | | |
| | | /** |
| | | * 数据操作层 |
| | | */ |
| | | @Resource |
| | | private CodeClassifyTemplateAttrDaoI codeClassifyTemplateAttrMapper; |
| | | @Resource |
| | | IDictBizClient iDictBizClient; |
| | | |
| | | /** |
| | | * 模板数据操作层 |
| | | */ |
| | | @Resource |
| | | private CodeClassifyTemplateDaoI codeClassifyTemplateMapper; |
| | | @Resource |
| | | CodeClassifyTemplateMapper codeClassifyTemplateMapper; |
| | | |
| | | /** |
| | | * 模板数据操作层 |
| | | */ |
| | | @Resource |
| | | private CodeTemplatePhaseServiceI codeTemplatePhaseServiceI; |
| | | @Resource |
| | | private ICodeReferConfigService codeReferConfigService; |
| | | |
| | | |
| | | /** |
| | | * 业务类型操作的服务 |
| | | */ |
| | | @Autowired |
| | | @Resource |
| | | @Lazy |
| | | private WebBoServiceI boService; |
| | | ICodeTempphaseService codeTempphaseService; |
| | | |
| | | /** |
| | | * 对象的操作 |
| | | */ |
| | | @Autowired |
| | | private RevisionModelUtil revisionModelUtil; |
| | | /** |
| | | * 对象的操作 |
| | | */ |
| | | @Autowired(required = false) |
| | | private RevisionModelUtil revisionModelUtil; |
| | | |
| | | /** |
| | | * 查询这个业务类型的所有属性 |
| | | */ |
| | | @Autowired |
| | | private OsBtmServiceI btmService; |
| | | /** |
| | | * 属性服务对象 |
| | | */ |
| | | @Resource |
| | | private IBtmTypeClient btmTypeClient; |
| | | |
| | | /** |
| | | * 可选可输服务 |
| | | */ |
| | | @Autowired |
| | | private BdSelectInputCharServiceI charService; |
| | | /** |
| | | * 查询所有的主题库分类的模板属性 |
| | | * @param mpjLambdaWrapper 查询条件 |
| | | * @param pageHelper 分页和排序 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 查询条件和分页出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public IPage<CodeClassifyTemplateAttrVO> gridCodeClassifyTemplateAttr(MPJLambdaWrapper<CodeClassifyTemplateAttr> mpjLambdaWrapper , PageHelper pageHelper) throws VciBaseException { |
| | | //没有传递参数,就不执行查询逻辑 |
| | | if(mpjLambdaWrapper == null){ |
| | | return new Page<>(); |
| | | } |
| | | Query query = new Query(); |
| | | if (pageHelper == null) { |
| | | pageHelper = new PageHelper(-1); |
| | | query.setSize(-1); |
| | | }else { |
| | | query.setCurrent(pageHelper.getPage()); |
| | | query.setSize(pageHelper.getLimit()); |
| | | } |
| | | //pageHelper.addDefaultAsc("ordernum"); |
| | | query.setAscs("ORDERNUM"); |
| | | //这儿是个连表查询 |
| | | IPage<CodeClassifyTemplateAttr> doList = codeClassifyTemplateAttrMapper.selectPage(Condition.getPage(query), mpjLambdaWrapper); |
| | | IPage<CodeClassifyTemplateAttrVO> voList = new Page<>(); |
| | | if (!CollectionUtils.isEmpty(doList.getRecords())) { |
| | | voList = CodeClassifyTemplateAttrWrapper.build().pageVO(doList); |
| | | } |
| | | return voList; |
| | | } |
| | | |
| | | /** |
| | | * 属性的服务 |
| | | */ |
| | | @Autowired |
| | | private OsAttributeServiceI attributeService; |
| | | /** |
| | | * 参照主题库分类的模板属性列表 |
| | | * @param conditionMap 查询条件 |
| | | * @param pageHelper 分页和排序 |
| | | * @return 主题库分类的模板属性显示对象列表,生效的内容 |
| | | * @throws VciBaseException 查询条件和分页出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public IPage<CodeClassifyTemplateAttrVO> refDataGridCodeClassifyTemplateAttr(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException{ |
| | | if(conditionMap == null){ |
| | | conditionMap = new HashMap<String, String>(); |
| | | } |
| | | return gridCodeClassifyTemplateAttr(UBCSCondition.getMPJLambdaWrapperByMapString(conditionMap, CodeClassifyTemplateAttr.class),pageHelper); |
| | | } |
| | | |
| | | /** |
| | | * 查询所有的主题库分类的模板属性 |
| | | * @param conditionMap 查询条件 |
| | | * @param pageHelper 分页和排序 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 查询条件和分页出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public DataGrid<CodeClassifyTemplateAttrVO> gridCodeClassifyTemplateAttr(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException{ |
| | | DataGrid<CodeClassifyTemplateAttrVO> dataGrid=new DataGrid<CodeClassifyTemplateAttrVO>(); |
| | | //没有传递参数,就不执行查询逻辑 |
| | | if(conditionMap.size()==0){ |
| | | dataGrid.setData(new ArrayList<>()); |
| | | dataGrid.setTotal(0); |
| | | return dataGrid; |
| | | } |
| | | @Override |
| | | public IPage<CodeClassifyTemplateAttrVO> selectCodeClstempattrPage(IPage<CodeClassifyTemplateAttrVO> page, CodeClassifyTemplateAttrVO CodeClstempattr) { |
| | | return page.setRecords(baseMapper.selectCodeClstempattrPage(page, CodeClstempattr)); |
| | | } |
| | | |
| | | if (pageHelper == null) { |
| | | pageHelper = new PageHelper(-1); |
| | | } |
| | | pageHelper.addDefaultAsc("ordernum"); |
| | | List<CodeClassifyTemplateAttrDO> doList = codeClassifyTemplateAttrMapper.selectByCondition(conditionMap,pageHelper); |
| | | if (!CollectionUtils.isEmpty(doList)) { |
| | | dataGrid.setData(codeClassifyTemplateAttrDO2VOs(doList)); |
| | | dataGrid.setTotal(VciBaseUtil.getInt(String.valueOf(codeClassifyTemplateAttrMapper.countByCondition(conditionMap)))); |
| | | } |
| | | return dataGrid; |
| | | } |
| | | /** |
| | | * 使用模板的主键获取模板的属性--批量 |
| | | * |
| | | * @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"); |
| | | // QueryWrapper<CodeClassifyTemplateAttr> wrapper = new QueryWrapper<>(); |
| | | // wrapper.in("classifytemplateoid",templateOids); |
| | | // wrapper.orderByAsc("orderNum"); |
| | | List<CodeClassifyTemplateAttr> attrDOS = baseMapper.selectByClassifytemplateoidRel(VciBaseUtil.toInSql(templateOids.toArray(new String[0]))); |
| | | // baseMapper.selectByClassifytemplateoid(VciBaseUtil.toInSql(templateOids.toArray(new String[0]))); |
| | | |
| | | /** |
| | | * 批量数据对象转换为显示对象 |
| | | * @param codeClassifyTemplateAttrDOs 数据对象列表 |
| | | * @return 显示对象 |
| | | * @throws VciBaseException 参数为空或者不存在的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public List<CodeClassifyTemplateAttrVO> codeClassifyTemplateAttrDO2VOs(Collection<CodeClassifyTemplateAttrDO> codeClassifyTemplateAttrDOs) throws VciBaseException{ |
| | | List<CodeClassifyTemplateAttrVO> voList = new ArrayList<CodeClassifyTemplateAttrVO>(); |
| | | if(!CollectionUtils.isEmpty(codeClassifyTemplateAttrDOs)){ |
| | | for(CodeClassifyTemplateAttrDO s: codeClassifyTemplateAttrDOs){ |
| | | CodeClassifyTemplateAttrVO vo = codeClassifyTemplateAttrDO2VO(s); |
| | | if(vo != null){ |
| | | voList.add(vo); |
| | | } |
| | | } |
| | | } |
| | | return voList; |
| | | } |
| | | if(!CollectionUtils.isEmpty(attrDOS)){ |
| | | attrDOList.addAll(attrDOS); |
| | | } |
| | | }); |
| | | return codeClassifyTemplateAttrDO2VOs(attrDOList); |
| | | } |
| | | |
| | | /** |
| | | * 数据对象转换为显示对象 |
| | | * @param codeClassifyTemplateAttrDO 数据对象 |
| | | * @return 显示对象 |
| | | * @throws VciBaseException 拷贝属性出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeClassifyTemplateAttrVO codeClassifyTemplateAttrDO2VO(CodeClassifyTemplateAttrDO codeClassifyTemplateAttrDO) throws VciBaseException{ |
| | | CodeClassifyTemplateAttrVO vo = new CodeClassifyTemplateAttrVO(); |
| | | if(codeClassifyTemplateAttrDO != null){ |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDO,vo); |
| | | //如果有lcstatus的类的话 |
| | | vo.setAttributeDataTypeText(VciFieldTypeEnum.getTextByValue(vo.getAttributedatatype())); |
| | | } |
| | | return vo; |
| | | } |
| | | /** |
| | | * 批量数据对象转换为显示对象 |
| | | * @param codeClassifyTemplateAttrDOs 数据对象列表 |
| | | * @return 显示对象 |
| | | * @throws VciBaseException 参数为空或者不存在的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public List<CodeClassifyTemplateAttrVO> codeClassifyTemplateAttrDO2VOs(Collection<CodeClassifyTemplateAttr> codeClassifyTemplateAttrDOs) throws VciBaseException{ |
| | | 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 codeClassifyTemplateAttrDTO 主题库分类的模板属性数据传输对象 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 参数为空,唯一项,必输项不通过时会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeClassifyTemplateAttrVO addSave(CodeClassifyTemplateAttrDTO codeClassifyTemplateAttrDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeClassifyTemplateAttrDTO,"需要添加的数据对象"); |
| | | //将DTO转换为DO |
| | | CodeClassifyTemplateAttrDO codeClassifyTemplateAttrDO = new CodeClassifyTemplateAttrDO(); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDO); |
| | | codeClassifyTemplateAttrMapper.insert(codeClassifyTemplateAttrDO); |
| | | return codeClassifyTemplateAttrDO2VO(codeClassifyTemplateAttrDO); |
| | | } |
| | | /** |
| | | * 数据对象转换为显示对象 |
| | | * @param codeClassifyTemplateAttrDO 数据对象 |
| | | * @return 显示对象 |
| | | * @throws VciBaseException 拷贝属性出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeClassifyTemplateAttrVO codeClassifyTemplateAttrDO2VO(CodeClassifyTemplateAttr codeClassifyTemplateAttrDO) throws VciBaseException{ |
| | | CodeClassifyTemplateAttrVO vo = new CodeClassifyTemplateAttrVO(); |
| | | if(codeClassifyTemplateAttrDO != null){ |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDO,vo); |
| | | //如果有lcstatus的类的话 |
| | | vo.setAttributeDataTypeText(VciFieldTypeEnum.getTextByValue(vo.getAttributeDataType())); |
| | | } |
| | | return vo; |
| | | } |
| | | |
| | | /** |
| | | * 批量添加 |
| | | * @param codeClassifyTemplateAttrDTOs 数据传输对象 |
| | | * @return 保存后的显示对象 |
| | | * @throws VciBaseException 执行出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public List<CodeClassifyTemplateAttrVO> batchAddSave(List<CodeClassifyTemplateAttrDTO> codeClassifyTemplateAttrDTOs) throws VciBaseException{ |
| | | if(CollectionUtils.isEmpty(codeClassifyTemplateAttrDTOs)){ |
| | | return new ArrayList<>(); |
| | | } |
| | | // @Override |
| | | // public IPage<CodeClassifyTemplateAttrVO> selectCodeClstempattrPage(IPage<CodeClassifyTemplateAttrVO> page, CodeClassifyTemplateAttrVO CodeClstempattr) { |
| | | // return page.setRecords(baseMapper.selectCodeClstempattrPage(page, CodeClstempattr)); |
| | | // } |
| | | |
| | | //取所有属性的英文名称,第三个验证需要用到 |
| | | 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(","))}); |
| | | } |
| | | // /** |
| | | // * 使用模板的主键获取模板的属性--批量 |
| | | // * |
| | | // * @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); |
| | | // } |
| | | |
| | | //模板oid |
| | | String CLASSIFYTEMPLATEOID = null; |
| | | //转换 |
| | | List<CodeClassifyTemplateAttrDO> codeClassifyTemplateAttrDOInsert = new ArrayList<CodeClassifyTemplateAttrDO>(); |
| | | List<String> prefix = new ArrayList<>(); |
| | | List<String> suffix = new ArrayList<>(); |
| | | List<String> dateFormates = new ArrayList<>(); |
| | | for (CodeClassifyTemplateAttrDTO codeClassifyTemplateAttrDTO:codeClassifyTemplateAttrDTOs){ |
| | | VciBaseUtil.alertNotNull(codeClassifyTemplateAttrDTO,"需要添加的数据对象"); |
| | | //将DTO转换为DO |
| | | CodeClassifyTemplateAttrDO codeClassifyTemplateAttrDO = new CodeClassifyTemplateAttrDO(); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDO); |
| | | codeClassifyTemplateAttrDOInsert.add(codeClassifyTemplateAttrDO); |
| | | // /** |
| | | // * 批量数据对象转换为显示对象 |
| | | // * @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; |
| | | // } |
| | | |
| | | 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()}); |
| | | } |
| | | // /** |
| | | // * 数据对象转换为显示对象 |
| | | // * @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; |
| | | // } |
| | | |
| | | //判断传过来的参照配置是否是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}); |
| | | } |
| | | } |
| | | } |
| | | /** |
| | | * 查询所有的主题库分类的模板属性 |
| | | * @param conditionMap 查询条件 |
| | | * @param pageHelper 分页和排序 |
| | | * @return 执行结果 |
| | | */ |
| | | @Override |
| | | public DataGrid<CodeClassifyTemplateAttrVO> gridCodeClassifyTemplateAttr(Map<String, String> conditionMap, PageHelper pageHelper) { |
| | | DataGrid<CodeClassifyTemplateAttrVO> dataGrid=new DataGrid<>(); |
| | | //没有传递参数,就不执行查询逻辑 |
| | | if(conditionMap.size()==0){ |
| | | dataGrid.setData(new ArrayList<>()); |
| | | dataGrid.setTotal(0); |
| | | return dataGrid; |
| | | } |
| | | |
| | | if(CLASSIFYTEMPLATEOID==null){ |
| | | CLASSIFYTEMPLATEOID = codeClassifyTemplateAttrDTO.getClassifytemplateoid(); |
| | | } |
| | | if (pageHelper == null) { |
| | | pageHelper = new PageHelper(-1); |
| | | } |
| | | pageHelper.addDefaultAsc("ordernum"); |
| | | Query query = new Query(); |
| | | query.setAscs("ordernum"); |
| | | query.setSize(pageHelper.getLimit()); |
| | | if(pageHelper.getLimit() != -1){ |
| | | query.setCurrent(pageHelper.getPage()); |
| | | } |
| | | IPage<CodeClassifyTemplateAttr> doList = baseMapper. |
| | | selectPage(Condition.getPage(query), UBCSCondition.getQueryWrapperByMapString(conditionMap,CodeClassifyTemplateAttr.class).orderByAsc("ordernum")); |
| | | if (!CollectionUtils.isEmpty(doList.getRecords())) { |
| | | dataGrid.setData(codeClassifyTemplateAttrDO2VOs(doList.getRecords())); |
| | | dataGrid.setTotal(VciBaseUtil.getInt(String.valueOf(baseMapper.selectCount(UBCSCondition.getQueryWrapperByMapString(conditionMap,CodeClassifyTemplateAttr.class))))); |
| | | } |
| | | return dataGrid; |
| | | } |
| | | |
| | | } |
| | | /** |
| | | * 增加主题库分类的模板属性 |
| | | * @param codeClassifyTemplateAttrDTO 主题库分类的模板属性数据传输对象 |
| | | * @return 执行结果 |
| | | */ |
| | | @Override |
| | | public CodeClassifyTemplateAttrVO addSave(CodeClassifyTemplateAttrDTO codeClassifyTemplateAttrDTO){ |
| | | VciBaseUtil.alertNotNull(codeClassifyTemplateAttrDTO,"需要添加的数据对象"); |
| | | //将DTO转换为DO |
| | | CodeClassifyTemplateAttr codeClassifyTemplateAttrDO = new CodeClassifyTemplateAttr(); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDO); |
| | | DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeClassifyTemplateAttrDO,"codeclstempattr"); |
| | | baseMapper.insert(codeClassifyTemplateAttrDO); |
| | | return codeClassifyTemplateAttrDO2VO(codeClassifyTemplateAttrDO); |
| | | } |
| | | |
| | | //执行数据保存操作 |
| | | WebUtil.setPersistence(false);//不执行保存 |
| | | /** |
| | | * 批量添加 |
| | | * @param codeClassifyTemplateAttrDTOs 数据传输对象 |
| | | * @return 保存后的显示对象 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public List<CodeClassifyTemplateAttrVO> batchAddSave(List<CodeClassifyTemplateAttrDTO> codeClassifyTemplateAttrDTOs) { |
| | | if(CollectionUtils.isEmpty(codeClassifyTemplateAttrDTOs)){ |
| | | return new ArrayList<>(); |
| | | } |
| | | |
| | | //先都删了 |
| | | VciQueryWrapperForDO deleteAttrWrapper = new VciQueryWrapperForDO(CodeClassifyTemplateAttrDO.class); |
| | | deleteAttrWrapper.addQueryMap("CLASSIFYTEMPLATEOID",CLASSIFYTEMPLATEOID); |
| | | List<CodeClassifyTemplateAttrDO> codeClassifyTemplateAttrDODelete = codeClassifyTemplateAttrMapper.selectByWrapper(deleteAttrWrapper); |
| | | //取所有属性的英文名称,第三个验证需要用到 |
| | | Map<String,CodeClassifyTemplateAttrDTO> attrDTOMap =codeClassifyTemplateAttrDTOs.stream().collect(Collectors.toMap(s->s.getId().toLowerCase(Locale.ROOT), t->t)); |
| | | |
| | | //oids |
| | | List<String> oids = new ArrayList<String>(); |
| | | for (CodeClassifyTemplateAttrDO codeClassifyTemplateAttrDO:codeClassifyTemplateAttrDODelete){ |
| | | oids.add(codeClassifyTemplateAttrDO.getOid()); |
| | | } |
| | | BatchCBO batchCBOTemplateDelete = new BatchCBO(); |
| | | if(!CollectionUtils.isEmpty(oids)){ |
| | | batchCBOTemplateDelete = codeClassifyTemplateAttrMapper.batchDeleteByOids(oids); |
| | | } |
| | | //找属性中文名字重复 |
| | | 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(","))}); |
| | | } |
| | | |
| | | //再新增 |
| | | if(!CollectionUtils.isEmpty(codeClassifyTemplateAttrDOInsert)){ |
| | | BatchCBO batchCBOTemplateAdd = codeClassifyTemplateAttrMapper.batchInsert(codeClassifyTemplateAttrDOInsert); |
| | | batchCBOTemplateDelete.copyFromOther(batchCBOTemplateAdd); |
| | | } |
| | | // 模板oid |
| | | String CLASSIFYTEMPLATEOID = null; |
| | | // |
| | | CodeReferConfigVO codeReferConfigVO = 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); |
| | | codeClassifyTemplateAttrDO.setCreateTime(codeClassifyTemplateAttrDO.getCreateTime()!=null?codeClassifyTemplateAttrDO.getCreateTime():new Date()); |
| | | // codeClassifyTemplateAttrDO.setCreator(String.valueOf(AuthUtil.getUser().getUserId())); |
| | | codeClassifyTemplateAttrDO.setCreator(String.valueOf(AuthUtil.getUser().getAccount())); |
| | | codeClassifyTemplateAttrDO.setLastModifyTime(new Date()); |
| | | // codeClassifyTemplateAttrDO.setLastModifier(String.valueOf(AuthUtil.getUser().getUserId())); |
| | | codeClassifyTemplateAttrDO.setLastModifier(String.valueOf(AuthUtil.getUser().getAccount())); |
| | | codeClassifyTemplateAttrDOInsert.add(codeClassifyTemplateAttrDO); |
| | | |
| | | //调用阶段 |
| | | if(!CollectionUtils.isEmpty(codeClassifyTemplateAttrDOInsert)){ |
| | | BatchCBO batchCBO0 = codeTemplatePhaseServiceI.codeTemplateAttrModifyTrigger(codeClassifyTemplateAttrDOInsert); |
| | | batchCBOTemplateDelete.copyFromOther(batchCBO0); |
| | | } |
| | | 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()}); |
| | | } |
| | | |
| | | SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo(); |
| | | //处理可输可选的字符 |
| | | if(!CollectionUtils.isEmpty(prefix)){ |
| | | charService.saveBySameNamespaceAndFlag(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR,"prefix",prefix,sessionInfo); |
| | | } |
| | | if(!CollectionUtils.isEmpty(suffix)){ |
| | | charService.saveBySameNamespaceAndFlag(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR,"suffix",suffix,sessionInfo); |
| | | } |
| | | if(!CollectionUtils.isEmpty(dateFormates)){ |
| | | charService.saveBySameNamespaceAndFlag(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR,"dateFormates",dateFormates,sessionInfo); |
| | | } |
| | | //判断传过来的参照配置是否是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}); |
| | | } |
| | | } |
| | | } |
| | | |
| | | WebUtil.setPersistence(true);//执行保存 |
| | | boService.persistenceBatch(batchCBOTemplateDelete);//一起执行保存 |
| | | return codeClassifyTemplateAttrDO2VOs(codeClassifyTemplateAttrDOInsert); |
| | | } |
| | | if(CLASSIFYTEMPLATEOID==null){ |
| | | CLASSIFYTEMPLATEOID = codeClassifyTemplateAttrDTO.getClassifyTemplateOid(); |
| | | } |
| | | |
| | | /** |
| | | * 修改主题库分类的模板属性 |
| | | * @param codeClassifyTemplateAttrDTO 主题库分类的模板属性数据传输对象 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 参数为空,唯一项,必输项不通过时会抛出异常 |
| | | */ |
| | | @Override |
| | | public BaseResult editSave(CodeClassifyTemplateAttrDTO codeClassifyTemplateAttrDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeClassifyTemplateAttrDTO,"数据对象",codeClassifyTemplateAttrDTO.getOid(),"主题库分类的模板属性主键"); |
| | | // 参照配置是否需要持久化 |
| | | codeReferConfigVO = JSONObject.parseObject(codeClassifyTemplateAttrDTO.getReferConfig(), CodeReferConfigVO.class); |
| | | if(Func.isNotEmpty(codeReferConfigVO) && codeReferConfigVO.getIsPersistence()=="true"){ |
| | | codeReferConfigService.insert(codeReferConfigVO); |
| | | } |
| | | } |
| | | |
| | | //判断传过来的枚举注入是否是jsonArr格式 |
| | | if(StringUtils.isNotBlank(codeClassifyTemplateAttrDTO.getEnumString())&&!checkKVArr(codeClassifyTemplateAttrDTO.getEnumString())){ |
| | | throw new VciBaseException("枚举注入数据格式错误!"); |
| | | } |
| | | //先都删了 |
| | | 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()); |
| | | } |
| | | if(!CollectionUtils.isEmpty(oids)){ |
| | | this.removeBatchByIds(oids); |
| | | } |
| | | //再新增 |
| | | if(!CollectionUtils.isEmpty(codeClassifyTemplateAttrDOInsert)){ |
| | | this.saveBatch(codeClassifyTemplateAttrDOInsert); |
| | | } |
| | | |
| | | //调用阶段 |
| | | if(!CollectionUtils.isEmpty(codeClassifyTemplateAttrDOInsert)){ |
| | | codeTempphaseService.codeTemplateAttrModifyTrigger(codeClassifyTemplateAttrDOInsert); |
| | | |
| | | } |
| | | |
| | | //处理可输可选的字符 |
| | | if(!CollectionUtils.isEmpty(prefix)){ |
| | | for (String s : prefix) { |
| | | DictBiz dictBiz = new DictBiz(); |
| | | dictBiz.setCode(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR); |
| | | dictBiz.setDictKey("prefix"); |
| | | dictBiz.setDictValue(s); |
| | | iDictBizClient.getCheck(dictBiz) ; |
| | | } |
| | | } |
| | | if(!CollectionUtils.isEmpty(suffix)){ |
| | | for (String s : suffix) { |
| | | DictBiz dictBiz = new DictBiz(); |
| | | dictBiz.setCode(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR); |
| | | dictBiz.setDictKey("suffix"); |
| | | dictBiz.setDictValue(s); |
| | | iDictBizClient.getCheck(dictBiz) ; |
| | | } |
| | | } |
| | | if(!CollectionUtils.isEmpty(dateFormates)){ |
| | | for (String s : dateFormates) { |
| | | DictBiz dictBiz = new DictBiz(); |
| | | dictBiz.setCode(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR); |
| | | dictBiz.setDictKey("dateFormates"); |
| | | dictBiz.setDictValue(s); |
| | | iDictBizClient.getCheck(dictBiz) ; |
| | | } |
| | | } |
| | | 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(),"主题库分类的模板属性主键"); |
| | | |
| | | //判断传过来的参照配置是否是json格式 |
| | | if(StringUtils.isNotBlank(codeClassifyTemplateAttrDTO.getReferbtmid())&&!checkKVObj(codeClassifyTemplateAttrDTO.getReferbtmid())){ |
| | | throw new VciBaseException("枚举注入数据格式错误!"); |
| | | } |
| | | //判断传过来的枚举注入是否是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 |
| | | CodeClassifyTemplateAttrDO codeClassifyTemplateAttrDOCopyFromDTO = new CodeClassifyTemplateAttrDO(); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDOCopyFromDTO); |
| | | boolean tsBoolean = boService.checkTs(codeClassifyTemplateAttrDOCopyFromDTO); |
| | | if(!tsBoolean){//不是最新的不让改 |
| | | return BaseResult.fail("当前数据不是最新,请刷新后再修改!"); |
| | | } |
| | | |
| | | //将DTO转换为DO |
| | | CodeClassifyTemplateAttrDO codeClassifyTemplateAttrDO = selectByOid(codeClassifyTemplateAttrDTO.getOid()); |
| | | revisionModelUtil.copyFromDTOIgnore(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDO); |
| | | codeClassifyTemplateAttrMapper.updateByPrimaryKey(codeClassifyTemplateAttrDO); |
| | | return BaseResult.success(codeClassifyTemplateAttrDO2VO(codeClassifyTemplateAttrDO)); |
| | | } |
| | | //检查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("当前数据不是最新,请刷新后再修改!"); |
| | | } |
| | | |
| | | /** |
| | | * 校验是否可以删除,如果存在下级,并且下级有数据引用则不能删除 |
| | | * @param codeClassifyTemplateAttrDTO 数据传输对象 |
| | | * @param codeClassifyTemplateAttrDO 数据库中的数据对象 |
| | | * @return success为true为可以删除,false表示有数据引用,obj为true表示有下级 |
| | | */ |
| | | private BaseResult checkIsCanDeleteForDO(CodeClassifyTemplateAttrDTO codeClassifyTemplateAttrDTO, CodeClassifyTemplateAttrDO codeClassifyTemplateAttrDO) { |
| | | boService.checkTs(codeClassifyTemplateAttrDO); |
| | | if(!checkIsLinked(codeClassifyTemplateAttrDO.getOid())) { |
| | | return BaseResult.success(); |
| | | }else{ |
| | | return BaseResult.fail(DATA_LINKED_NOT_DELETE,new String[]{""}); |
| | | } |
| | | } |
| | | //将DTO转换为DO |
| | | CodeClassifyTemplateAttr codeClassifyTemplateAttrDO = baseMapper.selectById(codeClassifyTemplateAttrDTO.getOid()); |
| | | revisionModelUtil.copyFromDTOIgnore(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDO); |
| | | baseMapper.updateById(codeClassifyTemplateAttrDO); |
| | | return R.data(codeClassifyTemplateAttrDO2VO(codeClassifyTemplateAttrDO)); |
| | | } |
| | | |
| | | /** |
| | | * 校验是否被引用 |
| | | * @param oid 主键 |
| | | * @throws VciBaseException 被引用的时候会抛出异常 |
| | | */ |
| | | private boolean checkIsLinked(String oid) throws VciBaseException{ |
| | | //TODO 添加需要校验引用的地方 |
| | | return false; |
| | | } |
| | | /** |
| | | * 删除主题库分类的模板属性 |
| | | * @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 主题库分类的模板属性数据传输对象,oid和ts需要传输 |
| | | * @return 删除结果反馈::success:成功,fail:失败 |
| | | * @throws VciBaseException 参数为空,被引用时抛出异常 |
| | | */ |
| | | @Override |
| | | public BaseResult deleteCodeClassifyTemplateAttr(CodeClassifyTemplateAttrDTO codeClassifyTemplateAttrDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeClassifyTemplateAttrDTO,"主题库分类的模板属性数据对象",codeClassifyTemplateAttrDTO.getOid(),"主题库分类的模板属性的主键"); |
| | | CodeClassifyTemplateAttrDO codeClassifyTemplateAttrDO = selectByOid(codeClassifyTemplateAttrDTO.getOid()); |
| | | BaseResult baseResult = checkIsCanDeleteForDO(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDO); |
| | | if(baseResult.isSuccess()) { |
| | | }else{ |
| | | return baseResult; |
| | | } |
| | | //执行删除操作 |
| | | BatchCBO batchCBO = codeClassifyTemplateAttrMapper.deleteByPrimaryKey(codeClassifyTemplateAttrDO.getOid()); |
| | | return (batchCBO!=null && batchCBO.getDeleteCbos() !=null &&batchCBO.getDeleteCbos().size() > 0)?BaseResult.successMsg(DELETE_SUCCESS):BaseResult.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)); |
| | | |
| | | /** |
| | | * 主键获取主题库分类的模板属性 |
| | | * @param oid 主键 |
| | | * @return 主题库分类的模板属性显示对象 |
| | | * @throws VciBaseException 参数为空,数据不存在时会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeClassifyTemplateAttrVO getObjectByOid(String oid) throws VciBaseException{ |
| | | return codeClassifyTemplateAttrDO2VO(selectByOid(oid)); |
| | | } |
| | | 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 主键 |
| | | * @return 数据对象 |
| | | * @throws VciBaseException 参数为空,并且数据不存在的时候会抛出异常 |
| | | */ |
| | | private CodeClassifyTemplateAttrDO selectByOid(String oid) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(oid,"主键"); |
| | | CodeClassifyTemplateAttrDO codeClassifyTemplateAttrDO = codeClassifyTemplateAttrMapper.selectByPrimaryKey(oid.trim()); |
| | | if(codeClassifyTemplateAttrDO == null || StringUtils.isBlank(codeClassifyTemplateAttrDO.getOid())){ |
| | | throw new VciBaseException(DATA_OID_NOT_EXIST); |
| | | } |
| | | return codeClassifyTemplateAttrDO; |
| | | } |
| | | /** |
| | | * 校验是否被引用 |
| | | * @param oid 主键 |
| | | * @throws VciBaseException 被引用的时候会抛出异常 |
| | | */ |
| | | private boolean checkIsLinked(String oid) throws VciBaseException{ |
| | | //TODO 添加需要校验引用的地方 |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 主键批量获取主题库分类的模板属性 |
| | | * @param oidCollections 主键集合,但是受性能影响,建议一次查询不超过10000个 |
| | | * @return 主题库分类的模板属性显示对象 |
| | | * @throws VciBaseException 查询出现异常时会抛出 |
| | | */ |
| | | @Override |
| | | public Collection<CodeClassifyTemplateAttrVO> listCodeClassifyTemplateAttrByOids(Collection<String> oidCollections) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(oidCollections,"数据对象主键集合"); |
| | | List<CodeClassifyTemplateAttrDO> codeClassifyTemplateAttrDOList = listCodeClassifyTemplateAttrDOByOidCollections(oidCollections); |
| | | return codeClassifyTemplateAttrDO2VOs(codeClassifyTemplateAttrDOList); |
| | | } |
| | | /** |
| | | * 主键获取主题库分类的模板属性 |
| | | * @param oid 主键 |
| | | * @return 主题库分类的模板属性显示对象 |
| | | * @throws VciBaseException 参数为空,数据不存在时会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeClassifyTemplateAttrVO getObjectByOid(String oid) throws VciBaseException{ |
| | | return codeClassifyTemplateAttrDO2VO(selectByOid(oid)); |
| | | } |
| | | |
| | | /** |
| | | * 使用主键集合查询数据对象 |
| | | * @param oidCollections 主键的集合 |
| | | * @return 数据对象列表 |
| | | */ |
| | | private List<CodeClassifyTemplateAttrDO> listCodeClassifyTemplateAttrDOByOidCollections(Collection<String> oidCollections){ |
| | | List<CodeClassifyTemplateAttrDO> codeClassifyTemplateAttrDOList = new ArrayList<CodeClassifyTemplateAttrDO>(); |
| | | if(!CollectionUtils.isEmpty(oidCollections)){ |
| | | Collection<Collection<String>> oidCollectionsList = VciBaseUtil.switchCollectionForOracleIn(oidCollections); |
| | | for(Collection<String> oids: oidCollectionsList){ |
| | | List<CodeClassifyTemplateAttrDO> tempDOList = codeClassifyTemplateAttrMapper.selectByPrimaryKeyCollection(oids); |
| | | if(!CollectionUtils.isEmpty(tempDOList)){ |
| | | codeClassifyTemplateAttrDOList.addAll(tempDOList); |
| | | } |
| | | } |
| | | } |
| | | return codeClassifyTemplateAttrDOList; |
| | | } |
| | | /** |
| | | * 主键查询数据对象 |
| | | * @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 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 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 baseQueryObject |
| | | * @return |
| | | */ |
| | | @Override |
| | | public DataGrid<OsBtmTypeAttributeVO> codeClassifyTemplateAttrByBtm(BaseQueryObject baseQueryObject){ |
| | | if(baseQueryObject.getConditionMap() == null){ |
| | | baseQueryObject.setConditionMap(new HashMap<>()); |
| | | } |
| | | DataGrid<OsBtmTypeAttributeVO> dataGrid=new DataGrid<OsBtmTypeAttributeVO>(); |
| | | //模板oid |
| | | String templateAttrOid = baseQueryObject.getConditionMap().get("oid"); |
| | | String name = baseQueryObject.getConditionMap().getOrDefault("name",""); |
| | | String id = baseQueryObject.getConditionMap().getOrDefault("id",""); |
| | | /** |
| | | * 使用主键集合查询数据对象 |
| | | * @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; |
| | | } |
| | | |
| | | //没有oid不执行逻辑 |
| | | if(StringUtils.isBlank(templateAttrOid)){ |
| | | dataGrid.setData(new ArrayList<>()); |
| | | dataGrid.setTotal(0); |
| | | return dataGrid; |
| | | } |
| | | /** |
| | | * 查询这个模板,业务类型下的所有未选择的属性 |
| | | * @param baseQueryObject |
| | | * @return |
| | | */ |
| | | @Override |
| | | public DataGrid<BtmTypeAttributeVO> codeClassifyTemplateAttrByBtm(BaseQueryObject baseQueryObject){ |
| | | if(baseQueryObject.getConditionMap() == null){ |
| | | baseQueryObject.setConditionMap(new HashMap<>()); |
| | | } |
| | | DataGrid<BtmTypeAttributeVO> dataGrid=new DataGrid<BtmTypeAttributeVO>(); |
| | | //模板oid |
| | | String templateAttrOid = baseQueryObject.getConditionMap().get("oid"); |
| | | String name = baseQueryObject.getConditionMap().getOrDefault("name",""); |
| | | String id = baseQueryObject.getConditionMap().getOrDefault("id",""); |
| | | |
| | | //查询模板对象 |
| | | CodeClassifyTemplateDO codeClassifyTemplateDO = codeClassifyTemplateMapper.selectByPrimaryKey(templateAttrOid); |
| | | //没有oid不执行逻辑 |
| | | if(StringUtils.isBlank(templateAttrOid)){ |
| | | dataGrid.setData(new ArrayList<>()); |
| | | dataGrid.setTotal(0); |
| | | return dataGrid; |
| | | } |
| | | |
| | | //这个业务类型下的所有属性 |
| | | List<OsBtmTypeAttributeVO> boAttrs = this.btmService.listAttributeByBtmId(codeClassifyTemplateDO.getBtmTypeId()); |
| | | //查询模板对象 |
| | | CodeClassifyTemplate codeClassifyTemplateDO = codeClassifyTemplateMapper.selectById(templateAttrOid); |
| | | // 没有模板对象不执行逻辑 |
| | | if(Objects.isNull(codeClassifyTemplateDO)){ |
| | | dataGrid.setData(new ArrayList<>()); |
| | | dataGrid.setTotal(0); |
| | | return dataGrid; |
| | | } |
| | | //这个业务类型下的所有属性 |
| | | R<BtmTypeVO> btmTypeVOR = btmTypeClient.getAllAttributeByBtmId(codeClassifyTemplateDO.getBtmTypeId()); |
| | | if(!btmTypeVOR.isSuccess()){ |
| | | throw new ServiceException("业务类型feign调用错误!"); |
| | | } |
| | | |
| | | //把默认的属性也添加到boAttrs |
| | | if(boAttrs == null){ |
| | | boAttrs = new ArrayList<>(); |
| | | } |
| | | if(!CollectionUtils.isEmpty(attributeService.getDefaultAttributeVOs())){ |
| | | List<OsBtmTypeAttributeVO> finalBoAttrs = boAttrs; |
| | | attributeService.getDefaultAttributeVOs().stream().forEach(attr-> { |
| | | OsBtmTypeAttributeVO attributeVO = new OsBtmTypeAttributeVO(); |
| | | BeanUtil.convert(attr, attributeVO); |
| | | if (VciQueryWrapperForDO.ID_FIELD.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; |
| | | } |
| | | //这个模板下已经有的属性 |
| | | // VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(CodeClassifyTemplateAttrDO.class); |
| | | // queryWrapper.addQueryMap("CLASSIFYTEMPLATEOID",templateAttrOid); |
| | | Map<String,Object> condition = new HashMap<>(1); |
| | | condition.put("CLASSIFYTEMPLATEOID",templateAttrOid); |
| | | |
| | | //这个模板下已经有的属性 |
| | | VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(CodeClassifyTemplateAttrDO.class); |
| | | queryWrapper.addQueryMap("CLASSIFYTEMPLATEOID",templateAttrOid); |
| | | List<CodeClassifyTemplateAttrDO> codeClassifyTemplateAttrDOList = codeClassifyTemplateAttrMapper.selectByWrapper(queryWrapper); |
| | | List<String> btmOids = new ArrayList<String>(); |
| | | for (CodeClassifyTemplateAttrDO codeClassifyTemplateAttrDO:codeClassifyTemplateAttrDOList){ |
| | | btmOids.add(codeClassifyTemplateAttrDO.getId()); |
| | | } |
| | | List<CodeClassifyTemplateAttr> codeClassifyTemplateAttrDOList = baseMapper.selectByMap(condition); |
| | | |
| | | //过滤掉已经存在的属性 |
| | | List<OsBtmTypeAttributeVO> boAttrss = new ArrayList<OsBtmTypeAttributeVO>(); |
| | | for (OsBtmTypeAttributeVO 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; |
| | | } |
| | | List<String> btmIds = new ArrayList<String>(); |
| | | for (CodeClassifyTemplateAttr codeClassifyTemplateAttrDO:codeClassifyTemplateAttrDOList){ |
| | | btmIds.add(codeClassifyTemplateAttrDO.getId()); |
| | | } |
| | | |
| | | /** |
| | | * 查询这个模板,业务类型下已选择的属性 |
| | | * @param baseQueryObject |
| | | * @return |
| | | */ |
| | | @Override |
| | | public DataGrid<OsBtmTypeAttributeVO> codeClassifyTemplateAttrByBtmHave(BaseQueryObject baseQueryObject){ |
| | | DataGrid<OsBtmTypeAttributeVO> dataGrid=new DataGrid<OsBtmTypeAttributeVO>(); |
| | | //模板oid |
| | | String templateAttrOid = baseQueryObject.getConditionMap().get("oid"); |
| | | //过滤掉已经存在的属性 |
| | | List<BtmTypeAttributeVO> boAttrss = new ArrayList<BtmTypeAttributeVO>(); |
| | | for (BtmTypeAttributeVO osBtmTypeAttributeVO:btmTypeVOR.getData().getAttributes()){ |
| | | if(!btmIds.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) { |
| | | if(!VciFieldTypeEnum.VTDouble.equals(osBtmTypeAttributeVO.getAttrDataType())){ |
| | | osBtmTypeAttributeVO.setPrecisionLength(null); |
| | | osBtmTypeAttributeVO.setScaleLength(null); |
| | | } |
| | | boAttrss.add(osBtmTypeAttributeVO); |
| | | } |
| | | } |
| | | } |
| | | // 按照id升序排序 |
| | | boAttrss = boAttrss.stream().sorted(Comparator.comparing(BtmTypeAttributeVO::getId)).collect(Collectors.toList()); |
| | | dataGrid.setData(boAttrss); |
| | | dataGrid.setTotal(boAttrss.size()); |
| | | return dataGrid; |
| | | } |
| | | |
| | | //没有oid不执行逻辑 |
| | | if(StringUtils.isBlank(templateAttrOid)){ |
| | | dataGrid.setData(new ArrayList<>()); |
| | | dataGrid.setTotal(0); |
| | | return dataGrid; |
| | | } |
| | | /** |
| | | * 查询这个模板,业务类型下已选择的属性 |
| | | * @param baseQueryObject |
| | | * @return |
| | | */ |
| | | @Override |
| | | public DataGrid<BtmTypeAttributeVO> codeClassifyTemplateAttrByBtmHave(BaseQueryObject baseQueryObject){ |
| | | DataGrid<BtmTypeAttributeVO> dataGrid=new DataGrid<BtmTypeAttributeVO>(); |
| | | //模板oid |
| | | String templateAttrOid = baseQueryObject.getConditionMap().get("oid"); |
| | | |
| | | //查询模板对象 |
| | | CodeClassifyTemplateDO codeClassifyTemplateDO = codeClassifyTemplateMapper.selectByPrimaryKey(templateAttrOid); |
| | | //没有oid不执行逻辑 |
| | | if(StringUtils.isBlank(templateAttrOid)){ |
| | | dataGrid.setData(new ArrayList<>()); |
| | | dataGrid.setTotal(0); |
| | | return dataGrid; |
| | | } |
| | | |
| | | //这个业务类型下的所有属性 |
| | | List<OsBtmTypeAttributeVO> boAttrs = this.btmService.listAttributeByBtmIdHasDefault(codeClassifyTemplateDO.getBtmTypeId()); |
| | | //查询模板对象 |
| | | CodeClassifyTemplate codeClassifyTemplateDO = codeClassifyTemplateMapper.selectById(templateAttrOid); |
| | | |
| | | //这个模板下已经有的属性 |
| | | VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(CodeClassifyTemplateAttrDO.class); |
| | | queryWrapper.addQueryMap("CLASSIFYTEMPLATEOID",templateAttrOid); |
| | | List<CodeClassifyTemplateAttrDO> codeClassifyTemplateAttrDOList = codeClassifyTemplateAttrMapper.selectByWrapper(queryWrapper); |
| | | List<String> btmOids = new ArrayList<String>(); |
| | | for (CodeClassifyTemplateAttrDO codeClassifyTemplateAttrDO:codeClassifyTemplateAttrDOList){ |
| | | btmOids.add(codeClassifyTemplateAttrDO.getId()); |
| | | } |
| | | //这个业务类型下的所有属性 |
| | | // TODO 已完善 |
| | | List<BtmTypeAttributeVO> boAttrs = (List<BtmTypeAttributeVO>) btmTypeClient.getAllAttributeByBtmId(codeClassifyTemplateDO.getBtmTypeId()); |
| | | //这个模板下已经有的属性 |
| | | //把默认的属性也添加到boAttrs |
| | | if(boAttrs == null){ |
| | | boAttrs = new ArrayList<>(); |
| | | } |
| | | QueryWrapper<CodeClassifyTemplateAttr> wrapper=new QueryWrapper<>(); |
| | | wrapper.eq("CLASSIFYTEMPLATEOID",templateAttrOid); |
| | | |
| | | //过滤掉除了自身的别的属性 |
| | | List<OsBtmTypeAttributeVO> boAttrss = new ArrayList<OsBtmTypeAttributeVO>(); |
| | | for (OsBtmTypeAttributeVO 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 BaseResult copyto(CodeClassifyTemplateAttrDTO codeClassifyTemplateAttrDTO) throws VciBaseException{ |
| | | List<CodeClassifyTemplateAttr> codeClassifyTemplateAttrDOList = baseMapper.selectList(wrapper); |
| | | List<String> btmOids = new ArrayList<String>(); |
| | | for (CodeClassifyTemplateAttr codeClassifyTemplateAttrDO:codeClassifyTemplateAttrDOList){ |
| | | btmOids.add(codeClassifyTemplateAttrDO.getId()); |
| | | } |
| | | |
| | | String templateAttrOid = codeClassifyTemplateAttrDTO.getOid(); |
| | | //过滤掉除了自身的别的属性 |
| | | List<BtmTypeAttributeVO> boAttrss = new ArrayList<BtmTypeAttributeVO>(); |
| | | |
| | | //查询出来要复制的对象 |
| | | CodeClassifyTemplateAttrDO codeClassifyTemplateAttrDO = selectByOid(templateAttrOid); |
| | | String id = codeClassifyTemplateAttrDO.getId();//英文名称 |
| | | String classfyTemplateOid = codeClassifyTemplateAttrDO.getClassifyTemplateOid(); |
| | | for (BtmTypeAttributeVO osBtmTypeAttributeVO:boAttrs){ |
| | | if(btmOids.contains(osBtmTypeAttributeVO.getId())){ |
| | | boAttrss.add(osBtmTypeAttributeVO); |
| | | } |
| | | } |
| | | dataGrid.setData(boAttrss); |
| | | dataGrid.setTotal(boAttrss.size()); |
| | | return dataGrid; |
| | | } |
| | | |
| | | //查询其他id=id的模板属性 |
| | | VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(CodeClassifyTemplateAttrDO.class); |
| | | queryWrapper.addQueryMap("id",id); |
| | | //所有id=id的模板属性 |
| | | List<CodeClassifyTemplateAttrDO> codeClassifyTemplateAttrDOList = codeClassifyTemplateAttrMapper.selectByWrapper(queryWrapper); |
| | | //要删除的模板属性的oids |
| | | List<String> deleteOids = new ArrayList<String>(); |
| | | //要修改的模板属性对象 |
| | | List<CodeClassifyTemplateAttrDO> codeClassifyTemplateAttrDOListInsert = new ArrayList<CodeClassifyTemplateAttrDO>(); |
| | | for (CodeClassifyTemplateAttrDO codeClassifyTemplateAttrDOi:codeClassifyTemplateAttrDOList){ |
| | | String oid = codeClassifyTemplateAttrDOi.getOid(); |
| | | String templateOldOid = codeClassifyTemplateAttrDOi.getClassifyTemplateOid(); |
| | | /** |
| | | * 同步到其他模板 |
| | | * @param codeClassifyTemplateAttrDTO oid |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R copyto(CodeClassifyTemplateAttrDTO codeClassifyTemplateAttrDTO) throws VciBaseException{ |
| | | |
| | | CodeClassifyTemplateAttrDO codeClassifyTemplateAttrDOInsert = new CodeClassifyTemplateAttrDO(); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDO,codeClassifyTemplateAttrDOInsert); |
| | | codeClassifyTemplateAttrDOInsert.setOid(oid); |
| | | codeClassifyTemplateAttrDOInsert.setClassifyTemplateOid(templateOldOid); |
| | | codeClassifyTemplateAttrDOListInsert.add(codeClassifyTemplateAttrDOInsert); |
| | | String templateAttrOid = codeClassifyTemplateAttrDTO.getOid(); |
| | | |
| | | deleteOids.add(codeClassifyTemplateAttrDOi.getOid()); |
| | | } |
| | | //查询出来要复制的对象 |
| | | CodeClassifyTemplateAttr codeClassifyTemplateAttrDO = selectByOid(templateAttrOid); |
| | | String id = codeClassifyTemplateAttrDO.getId();//英文名称 |
| | | String classfyTemplateOid = codeClassifyTemplateAttrDO.getClassifyTemplateOid(); |
| | | |
| | | WebUtil.setPersistence(false);//不执行保存 |
| | | //查询其他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); |
| | | |
| | | //删除 |
| | | BatchCBO batchCBOTemplateAttrDelete = codeClassifyTemplateAttrMapper.batchDeleteByOids(deleteOids); |
| | | //要删除的模板属性的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(); |
| | | |
| | | //再新增 |
| | | BatchCBO batchCBOTemplateAttrInsert = codeClassifyTemplateAttrMapper.batchInsert(codeClassifyTemplateAttrDOListInsert); |
| | | batchCBOTemplateAttrDelete.copyFromOther(batchCBOTemplateAttrInsert); |
| | | CodeClassifyTemplateAttr codeClassifyTemplateAttrDOInsert = new CodeClassifyTemplateAttr(); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDO,codeClassifyTemplateAttrDOInsert); |
| | | codeClassifyTemplateAttrDOInsert.setOid(oid); |
| | | codeClassifyTemplateAttrDOInsert.setClassifyTemplateOid(templateOldOid); |
| | | codeClassifyTemplateAttrDOListInsert.add(codeClassifyTemplateAttrDOInsert); |
| | | |
| | | WebUtil.setPersistence(true);//执行保存 |
| | | boService.persistenceBatch(batchCBOTemplateAttrDelete);//一起执行保存 |
| | | deleteOids.add(codeClassifyTemplateAttrDOi.getOid()); |
| | | } |
| | | |
| | | return BaseResult.success(); |
| | | } |
| | | // WebUtil.setPersistence(false);//不执行保存 |
| | | |
| | | /** |
| | | * 使用模板的主键获取模板的属性--批量 |
| | | * |
| | | * @param templateOidCollection 模板的主键 |
| | | * @return 属性的信息 |
| | | */ |
| | | @Override |
| | | public List<CodeClassifyTemplateAttrVO> listCodeClassifyTemplateAttrByTemplateOids(Collection<String> templateOidCollection) { |
| | | if(CollectionUtils.isEmpty(templateOidCollection)){ |
| | | return new ArrayList<>(); |
| | | } |
| | | List<CodeClassifyTemplateAttrDO> 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<CodeClassifyTemplateAttrDO> attrDOS = codeClassifyTemplateAttrMapper.selectByCondition(conditionMap, pageHelper); |
| | | if(!CollectionUtils.isEmpty(attrDOS)){ |
| | | attrDOList.addAll(attrDOS); |
| | | } |
| | | }); |
| | | return codeClassifyTemplateAttrDO2VOs(attrDOList); |
| | | } |
| | | //删除 |
| | | // BatchCBO batchCBOTemplateAttrDelete = codeClassifyTemplateAttrDOissifyTemplateAttrMapper.batchDeleteByOids(deleteOids); |
| | | baseMapper.deleteBatchIds(deleteOids); |
| | | //再新增 |
| | | // BatchCBO batchCBOTemplateAttrInsert = codeClassifyTemplateAttrMapper.batchInsert(codeClassifyTemplateAttrDOListInsert); |
| | | // batchCBOTemplateAttrDelete.copyFromOther(batchCBOTemplateAttrInsert); |
| | | this.saveBatch(codeClassifyTemplateAttrDOListInsert); |
| | | |
| | | 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; |
| | | } |
| | | // WebUtil.setPersistence(true);//执行保存 |
| | | // boService.persistenceBatch(batchCBOTemplateAttrDelete);//一起执行保存 |
| | | |
| | | /** |
| | | * 校验时间格式 |
| | | * @param dateFormat 时间格式 |
| | | * @return true表示校验通过 |
| | | */ |
| | | public boolean checkDateFormat(String dateFormat){ |
| | | try{ |
| | | VciDateUtil.date2Str(new Date(),dateFormat); |
| | | return true; |
| | | }catch (Throwable e){ |
| | | return false; |
| | | } |
| | | } |
| | | return R.success("操作成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 使用查询封装器来查询 |
| | | * @param wrapper 查询封装器 |
| | | * @return 数据对象 |
| | | */ |
| | | @Override |
| | | public List<CodeClassifyTemplateAttr> selectByWrapper(Wrapper wrapper) { |
| | | return codeClassifyTemplateAttrMapper.selectList(wrapper); |
| | | } |
| | | |
| | | } |
| | | |