| | |
| | | import com.vci.ubcs.starter.revision.model.TreeQueryObject; |
| | | import com.vci.ubcs.starter.revision.model.TreeWrapperOptions; |
| | | import com.vci.ubcs.starter.revision.service.RevisionModelUtil; |
| | | import com.vci.ubcs.starter.util.MdmBtmTypeConstant; |
| | | import com.vci.ubcs.starter.util.UBCSSqlKeyword; |
| | | import com.vci.ubcs.starter.web.constant.QueryOptionConstant; |
| | | import com.vci.ubcs.starter.web.constant.RegExpConstant; |
| | |
| | | cbo.setCreator(String.valueOf(AuthUtil.getUser().getUserId())); |
| | | cbo.setLastModifier(String.valueOf(AuthUtil.getUser().getUserId())); |
| | | cbo.setTenantId(AuthUtil.getTenantId()); |
| | | if(StringUtils.isNotBlank(orderDTO.getLcStatus())||StringUtils.isNotBlank(orderDTO.getData().get("lcStatus"))){ |
| | | cbo.setLcStatus(StringUtils.isNotBlank(orderDTO.getLcStatus())?orderDTO.getLcStatus():orderDTO.getData().get("lcStatus")); |
| | | } |
| | | // //TODO:因为默认的属性都不拷贝,目前集团码叫name,并没有从DTO拷贝到cbo里。增加一个单独处理,以后再看要不要调整 |
| | | cbo.setName(orderDTO.getName() == null ? "" : orderDTO.getName()); |
| | | // //end -- modify by lihang @20220407 |
| | |
| | | String value = null; |
| | | if (VciQueryWrapperForDO.BASIC_FIELD_MAP.containsKey(attrId)) { |
| | | value = WebUtil.getStringValueFromObject(WebUtil.getValueFromField(WebUtil.getFieldForObject(attrId, orderDTO.getClass()).getName(), orderDTO)); |
| | | } else { |
| | | if(StringUtils.isBlank(value)){ |
| | | value = orderDTO.getData().getOrDefault(attrId, ""); |
| | | } |
| | | } else { |
| | | //说明是自行配置的 |
| | | //前端必须要传递小写的属性 |
| | | value = orderDTO.getData().getOrDefault(attrId, ""); |
| | | String orDefault = orderDTO.getData().getOrDefault(attrId, ""); |
| | | value = Func.isBlank(orDefault) ? orderDTO.getData() |
| | | .getOrDefault(attrId.toUpperCase(Locale.ROOT), ""):orDefault; |
| | | } |
| | | return value; |
| | | } |
| | |
| | | } |
| | | final String[] sql = {"select count(*) from " + listR.getData().get(0).getTableName() + " t where 1 = 1 "}; |
| | | conditionMap.forEach((key, value) -> { |
| | | sql[0] += " and " + key + " = " + value; |
| | | if(StringUtils.isBlank(value)||value.equals(QueryOptionConstant.ISNULL)) { |
| | | sql[0] += " and " + key + " is null"; |
| | | }else{ |
| | | sql[0] += " and " + key + " = " + value; |
| | | } |
| | | }); |
| | | if (StringUtils.isNotBlank(orderDTO.getOid())) { |
| | | //修改的时候,需要排除自己 |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 校验关键属性 |
| | | * |
| | | * @param orderDTO 编码申请的相关的信息 |
| | | */ |
| | | @Override |
| | | public List<Map> checkKeyAttrOnOrderFordatas(CodeOrderDTO orderDTO) { |
| | | List<Map>dataList=new ArrayList<>(); |
| | | CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid()); |
| | | CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid()); |
| | | //先获取关键属性的规则,也利用继承的方式 |
| | | CodeKeyAttrRepeatVO keyRuleVO = keyRuleService.getRuleByClassifyFullInfo(classifyFullInfo); |
| | | //注意的是keyRuleVO可能为空,表示不使用规则控制 |
| | | //获取所有的关键属性 |
| | | Map<String, CodeClassifyTemplateAttrVO> ketAttrMap = templateVO.getAttributes().stream().filter(s -> VciBaseUtil.getBoolean(s.getKeyAttrFlag())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); |
| | | Map<String, String> conditionMap = new HashMap<>(); |
| | | boolean trimAll = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnoreallspaceflag()); |
| | | //全部去空的优先级大于去空 |
| | | boolean trim = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnorespaceflag()); |
| | | boolean ignoreCase = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnorecaseflag()); |
| | | boolean ignoreWidth = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnorewidthflag()); |
| | | ketAttrMap.forEach((attrId, attrVO) -> { |
| | | String value = getValueFromOrderDTO(orderDTO, attrId); |
| | | if (value == null) { |
| | | value = ""; |
| | | } |
| | | wrapperKeyAttrConditionMap(value, keyRuleVO, attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap); |
| | | }); |
| | | |
| | | //没有限制分类,但是一个模板只可能在一个业务类型里面,所以直接查询这个业务类型即可 |
| | | if (!CollectionUtils.isEmpty(conditionMap)) { |
| | | conditionMap.put("CODETEMPLATEOID","'" + orderDTO.getTemplateOid() + "'"); |
| | | // final String[] sql = {"select count(*) from " + VciBaseUtil.getTableName(classifyFullInfo.getTopClassifyVO().getBtmtypeid()) + " t where 1 = 1 "}; |
| | | R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(classifyFullInfo.getTopClassifyVO().getBtmTypeId())); |
| | | // String referTable = VciBaseUtil.getTableName(referVO.getReferType()); |
| | | if (!listR.isSuccess() || listR.getData().size() == 0) { |
| | | throw new VciBaseException("传入业务类型未查询到相应表单,请检查!"); |
| | | } |
| | | final String[] sql = {"select * from " + listR.getData().get(0).getTableName() + " t where 1 = 1 "}; |
| | | conditionMap.forEach((key, value) -> { |
| | | sql[0] += " and " + key + " = " + value; |
| | | }); |
| | | if (StringUtils.isNotBlank(orderDTO.getOid())) { |
| | | //修改的时候,需要排除自己 |
| | | sql[0] += " and oid != '" + orderDTO.getOid() + "'"; |
| | | } else if (StringUtils.isNotBlank(orderDTO.getCopyFromVersion())) { |
| | | sql[0] += " and oid != '" + orderDTO.getCopyFromVersion() + "'"; |
| | | } |
| | | sql[0] += " and lastR = '1' and lastV = '1' "; |
| | | // if (boService.queryCountBySql(sql[0], new HashMap<>()) > 0) { |
| | | dataList=commonsMapper.selectBySql(sql[0]); |
| | | if (!CollectionUtils.isEmpty(dataList)) { |
| | | // String ruleInfoMsg = keyRuleVO == null ? "" : "查询规则:去除空格--{0},忽略大小写--{1},忽略全半角--{2},忽略全部空格--{3}"; |
| | | // String[] objs = new String[]{trim ? "是" : "否", ignoreCase ? "是" : "否", ignoreWidth ? "是" : "否", trimAll ? "是" : "否"}; |
| | | // throw new VciBaseException("根据您填写的关键属性的内容,结合关键属性查询规则,发现这个数据已经在系统中存在了。请修正!。" + ruleInfoMsg, objs); |
| | | return dataList; |
| | | } |
| | | } |
| | | return dataList; |
| | | } |
| | | |
| | | /** |
| | | * 封装关键属性的查询语句 |
| | |
| | | boolean ignoreSpace = trim || trimAll; |
| | | if (StringUtils.isBlank(value)) { |
| | | //为空的时候,不能用QueryOperation.ISNULL,平台不知道啥时候不处理这种了 |
| | | conditionMap.put("t." + attrId, "null"); |
| | | conditionMap.put("t." + attrId, QueryOptionConstant.ISNULL); |
| | | } else { |
| | | if (keyRuleVO != null) { |
| | | String queryKey = ""; |
| | |
| | | queryValue = String.format(temp, "'" + (trim ? value.trim() : value) + "'"); |
| | | conditionMap.put(queryKey, queryValue); |
| | | } else { |
| | | //为空的时候不代表不校验,只是不去除相关的信息 |
| | | conditionMap.put("t." + attrId, "'" +value+ "'"); |
| | | if(StringUtils.isNotBlank(value)) { |
| | | //为空的时候不代表不校验,只是不去除相关的信息 |
| | | conditionMap.put("t." + attrId, "'" + value + "'"); |
| | | }else{ |
| | | conditionMap.put("t." + attrId, QueryOptionConstant.ISNULL); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | return (BaseModel) valueWrapper.get(); |
| | | } catch (Exception e) { |
| | | logger.error("创建业务类型对象", e); |
| | | throw new VciBaseException("initBtmError", new String[]{btmName}); |
| | | throw new ServiceException("initBtmError:"+"业务类型:"+btmName+":"+e.getMessage()); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | fieldVO.setOptionJsMap(eventJsMap); |
| | | fieldVO.setStyle(attrVO.getTableDisplayStyle()); |
| | | fieldVO.setTableDisplayFlag(attrVO.getTableDisplayFlag()); |
| | | //列表里不允许直接编辑 |
| | | fieldVO.setDateFormate(attrVO.getCodeDateFormat()); |
| | | return fieldVO; |
| | |
| | | uiFormReferVO.setTableConfig(uiTableConfigVO); |
| | | // 筛选条件 |
| | | HashMap<String, String> whereMap = new HashMap<>(); |
| | | if(!codeReferConfig.getCodeSrchCondConfigVOS().isEmpty()){ |
| | | if(!CollectionUtils.isEmpty(codeReferConfig.getCodeSrchCondConfigVOS())){ |
| | | codeReferConfig.getCodeSrchCondConfigVOS().stream().forEach(srch->{ |
| | | whereMap.put(srch.getFilterField()+srch.getFilterType(),srch.getFilterValue()); |
| | | }); |
| | |
| | | if (conditionMap == null) { |
| | | conditionMap = new HashMap<>(); |
| | | } |
| | | //pageHelper.addDefaultDesc("createTime"); |
| | | pageHelper.addDefaultDesc("id"); |
| | | pageHelper.addDefaultDesc("createTime"); |
| | | // pageHelper.addDefaultDesc("id"); |
| | | if (!classifyService.checkHasChild(codeClassifyOid)) { |
| | | conditionMap.put("t." + CODE_CLASSIFY_OID_FIELD, codeClassifyOid); |
| | | } else { |
| | | // conditionMap.put(CODE_CLASSIFY_OID_FIELD, QueryOptionConstant.IN + "(select oid from " + VciBaseUtil.getTableName(MdmBtmTypeConstant.CODE_CLASSIFY) |
| | | |
| | | List<BtmTypeVO> classifyData = btmTypeClient.selectByIdCollection(Collections.singletonList(MdmBtmTypeConstant.CODE_CLASSIFY)).getData(); |
| | | if(Func.isEmpty(classifyData)){ |
| | | throw new ServiceException("业务类型中英文名称和查询条件配置不一致,请修改业务类型中分类表英文名称为"+MdmBtmTypeConstant.CODE_CLASSIFY); |
| | | } |
| | | conditionMap.put("t." + CODE_CLASSIFY_OID_FIELD, QueryOptionConstant.IN + "(select oid from " + |
| | | btmTypeClient.selectByIdCollection(Collections.singletonList("classify")) |
| | | .getData().get(0).getTableName() + " where lcstatus='" + FrameWorkDefaultValueConstant |
| | | classifyData.get(0).getTableName() + " where lcstatus='" + FrameWorkDefaultValueConstant |
| | | .FRAMEWORK_DATA_ENABLED + "' start with parentCodeClassifyOid = '" + codeClassifyOid + |
| | | "' CONNECT BY PRIOR OID = parentCodeClassifyOid )"); |
| | | } |
| | |
| | | List<BaseModel> updateList = new ArrayList<>(); |
| | | // 应该都是一个分类下的业务数据,找第一条的就行 |
| | | CodeClassifyFullInfoBO topClassifyFullInfo = classifyService.getClassifyFullInfo(orderDTOList.get(0).getCodeClassifyOid()); |
| | | // Map<String,String> cboOidMap = new HashMap<>(); |
| | | if (CollectionUtils.isEmpty(orderDTOMap.keySet())) { |
| | | throw new VciBaseException(DATA_OID_NOT_EXIST); |
| | | } |
| | | |
| | | List<BaseModel> cboList = selectByTypeAndOid(topClassifyFullInfo.getTopClassifyVO().getBtmTypeId(), VciBaseUtil.array2String(orderDTOMap.keySet().toArray(new String[0]))); |
| | | // cboOidMap.put("oid",QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(orderDTOMap.keySet().toArray(new String[0])) + ")"); |
| | | // List<ClientBusinessObject> cboList = boService.queryCBO(classifyFullInfo.getTopClassifyVO().getBtmtypeid(), cboOidMap); |
| | | if (CollectionUtils.isEmpty(cboList)) { |
| | | if (CollectionUtils.isEmpty(cboList)) { |
| | | throw new VciBaseException(DATA_OID_NOT_EXIST); |
| | | } |
| | | // BatchCBO batchCBO = new BatchCBO(); |
| | | // CodeClassifyTemplateVO firstTemplateVO = templateService.getObjectHasAttrByOid(orderDTOMap.values().stream().findFirst().get().getTemplateOid()); |
| | | Map<String, BaseModel> cboMap = cboList.stream().filter(cbo -> cbo != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)); |
| | | Map<String, BaseModel> cboMap = cboList.stream().filter(cbo -> cbo != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)); |
| | | orderDTOMap.keySet().stream().forEach(oid -> { |
| | | CodeOrderDTO orderDTO = orderDTOMap.get(oid); |
| | | CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid()); |
| | | CodeClassifyTemplateVO firstTemplateVO = templateService.getObjectHasAttrByOid(orderDTOMap.values().stream().findFirst().get().getTemplateOid()); |
| | | BaseModel cbo = cboMap.get(oid); |
| | | String code = cbo.getId(); |
| | | if (!cbo.getTs().toString().contains(orderDTO.getTs().toString())) { |
| | | if (!cbo.getTs().toString().contains(VciDateUtil.date2Str(orderDTO.getTs(), VciDateUtil.DateTimeFormat))) { |
| | | throw new VciBaseException("数据不是最新的,可能他人已经修改,请刷新后再试"); |
| | | } |
| | | if (!CodeDefaultLC.EDITING.getValue().equalsIgnoreCase(cbo.getLcStatus()) && !orderDTO.isEditInProcess()) { |
| | |
| | | //企业码和集团码的不修改 |
| | | cbo.setDescription(StringUtils.isBlank(orderDTO.getDescription()) ? "" : orderDTO.getDescription()); |
| | | cbo.setName(orderDTO.getName()); |
| | | // try { |
| | | // cbo.setAttributeValue("id",code); |
| | | cbo.setId(code); |
| | | cbo.setDescription(StringUtils.isBlank(orderDTO.getDescription()) ? "" : orderDTO.getDescription()); |
| | | // cbo.setAttributeValueWithNoCheck("description", StringUtils.isBlank(orderDTO.getDescription())?"":orderDTO.getDescription()); |
| | | // cbo.setAttributeValue("name", orderDTO.getName()); |
| | | cbo.setName(orderDTO.getName()); |
| | | // } catch (VCIError e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // batchCBO.getUpdateCbos().add(cbo); |
| | | |
| | | updateList.add(cbo); |
| | | batchSaveSelectChar(firstTemplateVO, cboList); |
| | | }); |
| | | // boService.persistenceBatch(batchCBO); |
| | | updateBatchByBaseModel(topClassifyFullInfo.getTopClassifyVO().getBtmTypeId(), updateList); |
| | | return R.success("操作成功!"); |
| | | } |
| | |
| | | String codeRuleOid = classifyVO.getCodeRuleOid(); |
| | | if (StringUtils.isBlank(codeRuleOid)) { |
| | | //往上找 |
| | | CodeClassifyFullInfoBO fullInfo = classifyService.getClassifyFullInfo(codeClassifyOid); |
| | | return getCodeRuleByClassifyFullInfo(fullInfo); |
| | | CodeRuleVO classifyFullInfoCodeRule = getCodeRuleByClassifyFullInfo(classifyService.getClassifyFullInfo(codeClassifyOid)); |
| | | return toCodeValueApplyStatus(classifyFullInfoCodeRule); |
| | | } |
| | | //我们查询编码规则 |
| | | return ruleService.getObjectHasSecByOid(codeRuleOid); |
| | | //查询编码规则 |
| | | CodeRuleVO objectHasSecByOid = ruleService.getObjectHasSecByOid(codeRuleOid); |
| | | return toCodeValueApplyStatus(objectHasSecByOid); |
| | | } |
| | | |
| | | /** |
| | | * 编码申请表单,隐藏、可输、只读转换 |
| | | * @param codeRuleVO |
| | | * @return |
| | | */ |
| | | private CodeRuleVO toCodeValueApplyStatus(CodeRuleVO codeRuleVO){ |
| | | if(codeRuleVO.getSecVOList().isEmpty()){ |
| | | return codeRuleVO; |
| | | } |
| | | // 可输码段类型 |
| | | List<String> inputTypes = Arrays.asList( |
| | | CodeSecTypeEnum.CODE_FIXED_SEC.getValue(), |
| | | CodeSecTypeEnum.CODE_VARIABLE_SEC.getValue(), |
| | | CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue(), |
| | | CodeSecTypeEnum.CODE_REFER_SEC.getValue() |
| | | ); |
| | | // 只读码段类型 |
| | | List<String> readOnlyTypes = Arrays.asList( |
| | | CodeSecTypeEnum.CODE_LEVEL_SEC.getValue(), |
| | | CodeSecTypeEnum.CODE_ATTR_SEC.getValue(), |
| | | CodeSecTypeEnum.CODE_DATE_SEC.getValue() |
| | | ); |
| | | // 隐藏码段类型 |
| | | /*List<String> hideType = Arrays.asList( |
| | | CodeSecTypeEnum.CODE_SERIAL_SEC.getValue() |
| | | );*/ |
| | | // 当前规则的所有类型码段 |
| | | List<String> secTypeList = codeRuleVO.getSecVOList().stream().map(CodeBasicSecVO::getSecType).collect(Collectors.toList()); |
| | | // 情况一 全部是只读的码段类型 |
| | | boolean hasAllReadOnlyType =secTypeList.stream().allMatch(item -> readOnlyTypes.stream().anyMatch(item1-> item.equals(item1))); |
| | | // 全部是只读的码段类型 |
| | | if(hasAllReadOnlyType){ |
| | | List<CodeBasicSecVO> basicSecVOS = codeRuleVO.getSecVOList().stream().map(secVO -> { |
| | | secVO.setCodeValueApplyStatus(3); |
| | | // 日期码段设置默认值 |
| | | if (secVO.getSecType().equals(CodeSecTypeEnum.CODE_DATE_SEC.getValue())) { |
| | | try { |
| | | secVO.setCodeDateFormatStr(Func.format(new Date(),secVO.getCodeDateFormatStr())); |
| | | }catch (Exception e){ |
| | | throw new ServiceException("日期码段日期格式配置有误,导致转换出错:"+e.getMessage()); |
| | | } |
| | | } |
| | | return secVO; |
| | | }).collect(Collectors.toList()); |
| | | codeRuleVO.setSecVOList(basicSecVOS); |
| | | return codeRuleVO; |
| | | } |
| | | // 情况二 全部都是可输入类型的 |
| | | boolean hasAllInputType = secTypeList.stream().allMatch(item -> inputTypes.stream().anyMatch(item1-> item.equals(item1))); |
| | | if(hasAllInputType){ |
| | | List<CodeBasicSecVO> basicSecVOS = codeRuleVO.getSecVOList().stream().map(secVO -> { |
| | | secVO.setCodeValueApplyStatus(1); |
| | | // 日期码段设置默认值 |
| | | if (secVO.getSecType().equals(CodeSecTypeEnum.CODE_DATE_SEC.getValue())) { |
| | | try { |
| | | secVO.setCodeDateFormatStr(Func.format(new Date(),secVO.getCodeDateFormatStr())); |
| | | }catch (Exception e){ |
| | | throw new ServiceException("日期码段日期格式配置有误,导致转换出错:"+e.getMessage()); |
| | | } |
| | | } |
| | | return secVO; |
| | | }).collect(Collectors.toList()); |
| | | codeRuleVO.setSecVOList(basicSecVOS); |
| | | return codeRuleVO; |
| | | } |
| | | // 情况三包含人为选择的码段,又有只读类型码段的,所有码段都要显示出来,可输设置为1,只读设置为2,隐藏设置为3 |
| | | List<CodeBasicSecVO> basicSecVOS = codeRuleVO.getSecVOList().stream().map(secVO -> { |
| | | if(inputTypes.contains(secVO.getSecType())){ |
| | | secVO.setCodeValueApplyStatus(1); |
| | | }else if(readOnlyTypes.contains(secVO.getSecType())){ |
| | | secVO.setCodeValueApplyStatus(2); |
| | | }else{ |
| | | secVO.setCodeValueApplyStatus(3); |
| | | } |
| | | // 日期码段设置默认值 |
| | | if (secVO.getSecType().equals(CodeSecTypeEnum.CODE_DATE_SEC.getValue())) { |
| | | try { |
| | | secVO.setCodeDateFormatStr(Func.format(new Date(),secVO.getCodeDateFormatStr())); |
| | | }catch (Exception e){ |
| | | throw new ServiceException("日期码段日期格式配置有误,导致转换出错:"+e.getMessage()); |
| | | } |
| | | } |
| | | return secVO; |
| | | }).collect(Collectors.toList()); |
| | | codeRuleVO.setSecVOList(basicSecVOS); |
| | | return codeRuleVO; |
| | | } |
| | | |
| | | /** |
| | | * 使用分类的全部信息获取编码规则 |
| | | * |