| | |
| | | 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.CodeClassifyTemplate; |
| | |
| | | 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.IAttributeClient; |
| | | 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.BeanUtil; |
| | | 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 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.springframework.beans.BeanUtils; |
| | | import org.springblade.core.tool.utils.Func; |
| | | 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; |
| | |
| | | @Resource |
| | | private CodeClassifyTemplateAttrMapper codeClassifyTemplateAttrMapper; |
| | | |
| | | // @Resource |
| | | // CodeClstempattrMapper codeClstempattrMapper; |
| | | // @Resource |
| | | // ICodeTempphaseService codeTempphaseService; |
| | | |
| | | @Resource |
| | | IDictBizClient iDictBizClient; |
| | | |
| | | @Resource |
| | | CodeClassifyTemplateMapper codeClassifyTemplateMapper; |
| | | |
| | | @Resource |
| | | private ICodeReferConfigService codeReferConfigService; |
| | | |
| | | @Resource |
| | | @Lazy |
| | |
| | | pageHelper.addDefaultAsc("ordernum"); |
| | | Query query = new Query(); |
| | | query.setAscs("ordernum"); |
| | | query.setSize(pageHelper.getLimit()); |
| | | if(pageHelper.getLimit() != -1){ |
| | | query.setSize(pageHelper.getLimit()); |
| | | query.setCurrent(pageHelper.getPage()); |
| | | } |
| | | IPage<CodeClassifyTemplateAttr> doList = baseMapper. |
| | | selectPage(Condition.getPage(query), UBCSCondition.getQueryWrapperByMapString(conditionMap,CodeClassifyTemplateAttr.class)); |
| | | 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))))); |
| | |
| | | throw new VciBaseException("模板属性英文名称【{0}】重复",new String[]{ repeatIdList.stream().collect(Collectors.joining(","))}); |
| | | } |
| | | |
| | | //模板oid |
| | | // 模板oid |
| | | String CLASSIFYTEMPLATEOID = null; |
| | | // |
| | | CodeReferConfigVO codeReferConfigVO = null; |
| | | //转换 |
| | | List<CodeClassifyTemplateAttr> codeClassifyTemplateAttrDOInsert = new ArrayList<CodeClassifyTemplateAttr>(); |
| | | List<String> prefix = new ArrayList<>(); |
| | |
| | | //将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.setLastModifyTime(new Date()); |
| | | codeClassifyTemplateAttrDO.setLastModifier(String.valueOf(AuthUtil.getUser().getUserId())); |
| | | codeClassifyTemplateAttrDOInsert.add(codeClassifyTemplateAttrDO); |
| | | |
| | | if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getPrefixValue())){ |
| | |
| | | throw new VciBaseException("{0}{1}属性的时间格式不符合要求",new String[]{codeClassifyTemplateAttrDO.getId(),codeClassifyTemplateAttrDO.getName()}); |
| | | } |
| | | //如果是组合规则,里面使用的属性不能缺失,也都得显示 |
| | | String componentrule = codeClassifyTemplateAttrDTO.getComponentrule(); |
| | | String componentrule = codeClassifyTemplateAttrDTO.getComponentRule(); |
| | | boolean isContainsDynamicParameter = PatternUtil.isContainsDynamicParameter(componentrule); |
| | | if(isContainsDynamicParameter){ |
| | | List<String> userdAttrList = PatternUtil.getKeyListByContent(componentrule);//包含的所有${xxx}中的xxx |
| | |
| | | } |
| | | //要看看表单是否显示 |
| | | String unFormDisplayAttr = userdAttrList.stream().filter(s -> !VciBaseUtil.getBoolean(attrDTOMap.getOrDefault(s.toLowerCase(Locale.ROOT), |
| | | new CodeClassifyTemplateAttrDTO()).getFormdisplayflag())).collect(Collectors.joining(",")); |
| | | 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(); |
| | | CLASSIFYTEMPLATEOID = codeClassifyTemplateAttrDTO.getClassifyTemplateOid(); |
| | | } |
| | | |
| | | // 参照配置是否需要持久化 |
| | | codeReferConfigVO = JSONObject.parseObject(codeClassifyTemplateAttrDTO.getReferConfig(), CodeReferConfigVO.class); |
| | | if(Func.isNotEmpty(codeReferConfigVO) && codeReferConfigVO.getIsPersistence()=="true"){ |
| | | codeReferConfigService.insert(codeReferConfigVO); |
| | | } |
| | | } |
| | | |
| | | //执行数据保存操作 |
| | | // 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); |
| | |
| | | for (CodeClassifyTemplateAttr codeClassifyTemplateAttrDO:codeClassifyTemplateAttrDODelete){ |
| | | oids.add(codeClassifyTemplateAttrDO.getOid()); |
| | | } |
| | | // BatchCBO batchCBOTemplateDelete = new BatchCBO(); |
| | | if(!CollectionUtils.isEmpty(oids)){ |
| | | baseMapper.deleteBatchIds(oids); |
| | | this.removeBatchByIds(oids); |
| | | } |
| | | |
| | | //再新增 |
| | | if(!CollectionUtils.isEmpty(codeClassifyTemplateAttrDOInsert)){ |
| | | this.saveBatch(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"); |
| | | dictBiz.setDictKey("prefix"); |
| | | dictBiz.setDictValue(s); |
| | | 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"); |
| | | dictBiz.setDictKey("suffix"); |
| | | dictBiz.setDictValue(s); |
| | | 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"); |
| | | dictBiz.setDictKey("dateFormates"); |
| | | dictBiz.setDictValue(s); |
| | | iDictBizClient.getCheck(dictBiz) ; |
| | | } |
| | | // charService.saveBySameNamespaceAndFlag(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR,"dateFormates",dateFormates,sessionInfo); |
| | | } |
| | | |
| | | // WebUtil.setPersistence(true);//执行保存 |
| | | // boService.persistenceBatch(batchCBOTemplateDelete);//一起执行保存 |
| | | return codeClassifyTemplateAttrDO2VOs(codeClassifyTemplateAttrDOInsert); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | //判断传过来的参照配置是否是json格式 |
| | | if(StringUtils.isNotBlank(codeClassifyTemplateAttrDTO.getReferbtmid())&&!checkKVObj(codeClassifyTemplateAttrDTO.getReferbtmid())){ |
| | | if(StringUtils.isNotBlank(codeClassifyTemplateAttrDTO.getReferBtmId())&&!checkKVObj(codeClassifyTemplateAttrDTO.getReferBtmId())){ |
| | | throw new VciBaseException("枚举注入数据格式错误!"); |
| | | } |
| | | |
| | |
| | | } |
| | | //这个业务类型下的所有属性 |
| | | R<BtmTypeVO> btmTypeVOR = btmTypeClient.getAllAttributeByBtmId(codeClassifyTemplateDO.getBtmTypeId()); |
| | | if(btmTypeVOR.getCode() != 200){ |
| | | throw new ServiceException("业务类型feign调用失败!"); |
| | | if(!btmTypeVOR.isSuccess()){ |
| | | throw new ServiceException("业务类型feign调用错误!"); |
| | | } |
| | | |
| | | //这个模板下已经有的属性 |
| | | // VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(CodeClassifyTemplateAttrDO.class); |
| | | // queryWrapper.addQueryMap("CLASSIFYTEMPLATEOID",templateAttrOid); |
| | | // 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>(); |
| | | List<String> btmIds = new ArrayList<String>(); |
| | | for (CodeClassifyTemplateAttr codeClassifyTemplateAttrDO:codeClassifyTemplateAttrDOList){ |
| | | btmOids.add(codeClassifyTemplateAttrDO.getId()); |
| | | btmIds.add(codeClassifyTemplateAttrDO.getId()); |
| | | } |
| | | |
| | | //过滤掉已经存在的属性 |
| | | List<BtmTypeAttributeVO> boAttrss = new ArrayList<BtmTypeAttributeVO>(); |
| | | |
| | | for (BtmTypeAttributeVO osBtmTypeAttributeVO:btmTypeVOR.getData().getAttributes()){ |
| | | if(!btmOids.contains(osBtmTypeAttributeVO.getId())){ |
| | | if(!btmIds.contains(osBtmTypeAttributeVO.getId())){ |
| | | //看看是不是有模糊查询 |
| | | boolean inSearch = true; |
| | | if(StringUtils.isNotBlank(name) && !osBtmTypeAttributeVO.getName().contains(name.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; |
| | |
| | | CodeClassifyTemplate codeClassifyTemplateDO = codeClassifyTemplateMapper.selectById(templateAttrOid); |
| | | |
| | | //这个业务类型下的所有属性 |
| | | // 待完善 |
| | | List<BtmTypeAttributeVO> boAttrs = null; // (List<BtmTypeAttributeVO>) attributeClient.selectById(codeClassifyTemplateDO.getBtmTypeId());//this.btmService.listAttributeByBtmIdHasDefault(codeClassifyTemplateDO.getBtmTypeId()); |
| | | // codeOsbtmtypeattributeMapper.selectById(codeClassifyTemplateDO.getBtmTypeId()); |
| | | // BeanUtils.copyProperties(codeOsbtmtypeattributeMapper.selectById(codeClassifyTemplateDO.getBtmTypeId()),boAttrs); |
| | | // TODO 已完善 |
| | | List<BtmTypeAttributeVO> boAttrs = (List<BtmTypeAttributeVO>) btmTypeClient.getAllAttributeByBtmId(codeClassifyTemplateDO.getBtmTypeId()); |
| | | //这个模板下已经有的属性 |
| | | //把默认的属性也添加到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); |
| | | |