| | |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | * @throws VciBaseException 参数为空,唯一项,必输项不通过时会抛出异常 |
| | | */ |
| | | @Override |
| | | public boolean addSave(CodeRuleDTO codeRuleDTO) throws VciBaseException { |
| | | public R addSave(CodeRuleDTO codeRuleDTO) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(codeRuleDTO, "需要添加的数据对象"); |
| | | //将DTO转换为DO |
| | | if(checkCodeRuleRepeat(codeRuleDTO.getId())){ |
| | | return R.fail("规则编号已存在!"); |
| | | } |
| | | // 将DTO转换为DO |
| | | CodeRule codeRule = Objects.requireNonNull(BeanUtil.copy(codeRuleDTO, CodeRule.class)); |
| | | // 填充默认值 |
| | | DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeRule, MdmBtmTypeConstant.CODE_RULE); |
| | | codeRule.setLctid(CODE_RULE_LC); |
| | | codeRule.setLcStatus(FRAMEWORK_RELEASE_EDITING); |
| | | return codeRuleMapper.insert(codeRule)>0; |
| | | return R.status(codeRuleMapper.insert(codeRule)>0); |
| | | } |
| | | |
| | | /** |
| | | * 检查id编号是否重复 |
| | | * @param id 当前编号 |
| | | * @return 返回false表示未重复 |
| | | */ |
| | | @Override |
| | | public boolean checkCodeRuleRepeat(String id){ |
| | | Long count = this.codeRuleMapper.selectCount(Wrappers.<CodeRule>query().lambda().eq(CodeRule::getId, id)); |
| | | if(count>0){ |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @throws VciBaseException 参数为空,唯一项,必输项不通过时会抛出异常 |
| | | */ |
| | | @Override |
| | | public boolean editSave(CodeRuleDTO codeRuleDTO) throws VciBaseException{ |
| | | public R editSave(CodeRuleDTO codeRuleDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeRuleDTO, "数据对象", codeRuleDTO.getOid(), "主数据编码规则主键"); |
| | | if(checkCodeRuleRepeat(codeRuleDTO.getId())){ |
| | | return R.fail("规则编号已存在!"); |
| | | } |
| | | if (!checkEditDelStatus(codeRuleDTO.getLcStatus())) { |
| | | throw new VciBaseException("编码规则已发布,不允许编辑或删除"); |
| | | } |
| | |
| | | CodeRule codeRule = selectByOid(codeRuleDTO.getOid()); |
| | | revisionModelUtil.copyFromDTOIgnore(codeRuleDTO, codeRule); |
| | | DefaultAttrAssimtUtil.updateDefaultAttrAssimt(codeRule); |
| | | return codeRuleMapper.updateById(codeRule)>0; |
| | | return R.status(codeRuleMapper.updateById(codeRule)>0); |
| | | } |
| | | |
| | | /** |
| | |
| | | vo.setLcStatusText(CodeRuleLC.getTextByValue(vo.getLcStatus())); |
| | | if (hasSec) { |
| | | List<CodeBasicSecVO> codeBasicSecVOS = codeBasicSecService.listCodeBasicSecByRuleOid(vo.getOid()); |
| | | // 判断是否为引用码段,如果是应用码段的话,为了适配前端组件,这里要对表进行处理一下,按照以前的参照格式进行转换 |
| | | codeBasicSecVOS.stream().peek(item->{ |
| | | //引用码段 |
| | | if(item.getSecType().equals(CodeSecTypeEnum.CODE_REFER_SEC) && StringUtils.isNotEmpty(item.getReferConfig())){ |
| | | item.setReferConfig(referConfigTOUIUiTable(item)); |
| | | } |
| | | }); |
| | | //查询码段 |
| | | vo.setSecVOList(codeBasicSecVOS); |
| | | } |
| | | } |
| | | return vo; |
| | | } |
| | | |
| | | /** |
| | | * 将referconfig转换为JSON格式的UIFormReferVO |
| | | * @param item |
| | | * @return |
| | | */ |
| | | private String referConfigTOUIUiTable(CodeBasicSecVO item){ |
| | | // JSON格式的参照配置转换为对象 |
| | | CodeReferConfig codeReferConfig = JSONObject.parseObject(item.getReferConfig(), CodeReferConfig.class); |
| | | // 拷贝为以前的老对象 |
| | | UIFormReferVO uiFormReferVO = new UIFormReferVO(); |
| | | BeanUtil.copy(codeReferConfig,uiFormReferVO); |
| | | |
| | | // 表格的自定义定义 |
| | | UITableCustomDefineVO uiTableCustomDefineVO = new UITableCustomDefineVO(); |
| | | uiTableCustomDefineVO.setPage(new UITablePageVO(codeReferConfig.getLimit(),1)); |
| | | // 列表的列的信息转换 |
| | | List<UITableFieldVO> uiTableFieldVOs = new ArrayList<>(); |
| | | // 快速查询列 |
| | | List<UITableFieldVO> queryColumns = new ArrayList<>(); |
| | | codeReferConfig.getCodeShowFieldConfigs().stream().forEach(showField ->{ |
| | | UITableFieldVO uiTableFieldVO = new UITableFieldVO(); |
| | | BeanUtil.copy(showField,uiTableFieldVO); |
| | | uiTableFieldVOs.add(uiTableFieldVO); |
| | | if(showField.getIsQuery().equals("true")){ |
| | | queryColumns.add(uiTableFieldVO); |
| | | } |
| | | }); |
| | | // 显示的列 |
| | | uiTableCustomDefineVO.setCols(uiTableFieldVOs); |
| | | // 快速查询列 |
| | | uiTableCustomDefineVO.setQueryColumns(queryColumns); |
| | | // 筛选条件 |
| | | HashMap<String, String> whereMap = new HashMap<>(); |
| | | codeReferConfig.getCodeSrchCondConfigs().stream().forEach(srch->{ |
| | | whereMap.put(srch.getFilterValue()+"_"+srch.getFilterType(),srch.getFilterValue()); |
| | | }); |
| | | uiFormReferVO.setWhere(whereMap); |
| | | return JSONObject.toJSONString(uiFormReferVO); |
| | | } |
| | | |
| | | |
| | | |
| | | } |