| | |
| | | package com.vci.ubcs.code.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | |
| | | 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.SaveLogUtil; |
| | | import com.vci.ubcs.starter.util.SpecialCharacterConverter; |
| | | import com.vci.ubcs.starter.util.UBCSSqlKeyword; |
| | | import com.vci.ubcs.starter.web.constant.QueryOptionConstant; |
| | | import com.vci.ubcs.starter.web.constant.RegExpConstant; |
| | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.log.annotation.OperateLog; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.cache.Cache; |
| | |
| | | */ |
| | | @Autowired |
| | | private IMDMIFlowAttrClient imdmiFlowAttrClient; |
| | | // @Autowired |
| | | // private CodeOsbtmtypeMapper codeOsbtmtypeMapper;---- |
| | | |
| | | // @Autowired |
| | | // private CodeOsbtmtypeMapper codeOsbtmtypeMapper; |
| | | |
| | | /** |
| | | * 日志保存工具类 |
| | | */ |
| | | @Autowired |
| | | private SaveLogUtil saveLogUtil; |
| | | |
| | | |
| | | /** |
| | |
| | | @Transactional |
| | | @Override |
| | | public void changeStatus(BaseModelDTO baseModelDTO) { |
| | | VciBaseUtil.alertNotNull(baseModelDTO, "数据信息", baseModelDTO.getOid(), "主键", baseModelDTO.getBtmname(), "业务类型", baseModelDTO.getLcStatus(), "目标状态"); |
| | | List<String> oids = VciBaseUtil.str2List(baseModelDTO.getOid()); |
| | | List<BaseModel> baseModels = new ArrayList<>(); |
| | | baseModels = selectByTypeAndOid(baseModelDTO.getBtmname(), baseModelDTO.getOid()); |
| | | if (baseModels.size() == 0) { |
| | | throw new VciBaseException("未查询到相关数据。"); |
| | | } |
| | | //还需要修改allCode的生命周期 |
| | | QueryWrapper<CodeAllCode> allCodeWrapper = new QueryWrapper<>(); |
| | | allCodeWrapper.eq("createcodebtm", baseModelDTO.getBtmname()); |
| | | allCodeWrapper.in("createcodeoid", oids); |
| | | List<CodeAllCode> codeCbos = codeAllCodeService.selectByWrapper(allCodeWrapper);// 回收需要业务数据删除 |
| | | if (CodeDefaultLC.TASK_BACK.getValue().equals(baseModelDTO.getLcStatus())) { |
| | | R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(baseModelDTO.getBtmname())); |
| | | if (!listR.isSuccess() || listR.getData().size() == 0) { |
| | | throw new VciBaseException("传入业务类型未查询到相应表单,请检查!"); |
| | | } |
| | | // 直接删除,不给状态 |
| | | commonsMapper.deleteByTaleAndOid(listR.getData().get(0).getTableName(), VciBaseUtil.toInSql(baseModelDTO.getOid())); |
| | | // commonsMapper.updateByTaleAndOid(listR.getData().get(0).getTableName(), VciBaseUtil.toInSql(baseModelDTO.getOid()),CodeDefaultLC.TASK_BACK.getValue()); |
| | | } else { |
| | | for (BaseModel baseModel : baseModels) { |
| | | baseModel.setLcStatus(baseModelDTO.getLcStatus()); |
| | | } |
| | | R r = updateBatchByBaseModel(baseModelDTO.getBtmname(), baseModels); |
| | | if(!r.isSuccess()){ |
| | | throw new VciBaseException("更新数据出错,重试!"+r.getMsg()); |
| | | try { |
| | | VciBaseUtil.alertNotNull(baseModelDTO, "数据信息", baseModelDTO.getOid(), "主键", baseModelDTO.getBtmname(), "业务类型", baseModelDTO.getLcStatus(), "目标状态"); |
| | | List<String> oids = VciBaseUtil.str2List(baseModelDTO.getOid()); |
| | | List<BaseModel> baseModels = new ArrayList<>(); |
| | | baseModels = selectByTypeAndOid(baseModelDTO.getBtmname(), baseModelDTO.getOid()); |
| | | if (baseModels.size() == 0) { |
| | | throw new VciBaseException("未查询到相关数据。"); |
| | | } |
| | | //还需要修改allCode的生命周期 |
| | | QueryWrapper<CodeAllCode> allCodeWrapper = new QueryWrapper<>(); |
| | | allCodeWrapper.eq("createcodebtm", baseModelDTO.getBtmname()); |
| | | allCodeWrapper.in("createcodeoid", oids); |
| | | List<CodeAllCode> codeCbos = codeAllCodeService.selectByWrapper(allCodeWrapper);// 回收需要业务数据删除 |
| | | if (CodeDefaultLC.TASK_BACK.getValue().equals(baseModelDTO.getLcStatus())) { |
| | | R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(baseModelDTO.getBtmname())); |
| | | if (!listR.isSuccess() || listR.getData().size() == 0) { |
| | | throw new VciBaseException("传入业务类型未查询到相应表单,请检查!"); |
| | | } |
| | | // 直接删除,不给状态 |
| | | commonsMapper.deleteByTaleAndOid(listR.getData().get(0).getTableName(), VciBaseUtil.toInSql(baseModelDTO.getOid())); |
| | | // commonsMapper.updateByTaleAndOid(listR.getData().get(0).getTableName(), VciBaseUtil.toInSql(baseModelDTO.getOid()),CodeDefaultLC.TASK_BACK.getValue()); |
| | | } else { |
| | | for (BaseModel baseModel : baseModels) { |
| | | baseModel.setLcStatus(baseModelDTO.getLcStatus()); |
| | | } |
| | | R r = updateBatchByBaseModel(baseModelDTO.getBtmname(), baseModels); |
| | | if(!r.isSuccess()){ |
| | | throw new VciBaseException("更新数据出错,重试!"+r.getMsg()); |
| | | } |
| | | } |
| | | for (CodeAllCode codeCbo : codeCbos) { |
| | | codeCbo.setLcStatus(baseModelDTO.getLcStatus()); |
| | | } |
| | | codeAllCodeService.updateBatchById(codeCbos); |
| | | |
| | | //记录日志信息 |
| | | saveLogUtil.operateLog( |
| | | CodeDefaultLC.getTextByValue(baseModelDTO.getLcStatus()), |
| | | false, |
| | | JSON.toJSONString(baseModels) |
| | | ); |
| | | }catch (Exception e){ |
| | | // 插入更改日志记录 |
| | | saveLogUtil.operateLog(CodeDefaultLC.getTextByValue(baseModelDTO.getLcStatus()),true,e.getMessage()); |
| | | throw e; |
| | | } |
| | | for (CodeAllCode codeCbo : codeCbos) { |
| | | codeCbo.setLcStatus(baseModelDTO.getLcStatus()); |
| | | } |
| | | codeAllCodeService.updateBatchById(codeCbos); |
| | | } |
| | | |
| | | /** |
| | |
| | | sql[0] += " and oid != '" + orderDTO.getCopyFromVersion() + "'"; |
| | | } |
| | | sql[0] += " and lastR = '1' and lastV = '1' "; |
| | | // 获取不参与校验的分类oid |
| | | String isParticipateCheckOids = classifyService.selectLeafByParentClassifyOid(classifyFullInfo.getTopClassifyVO().getOid(), classifyFullInfo.getCurrentClassifyVO().getOid()); |
| | | if(Func.isNotEmpty(isParticipateCheckOids)){ |
| | | sql[0] += " and codeclsfid not in(" + isParticipateCheckOids + ")"; |
| | |
| | | * @param authUser |
| | | * @return |
| | | */ |
| | | private String addSaveBZCode(CodeBZApplyDTO codeBZApplyDTO, boolean authUser) throws Exception { |
| | | public String addSaveBZCode(CodeBZApplyDTO codeBZApplyDTO, boolean authUser) throws Exception { |
| | | String code=""; |
| | | VciBaseUtil.alertNotNull(codeBZApplyDTO.getCodeClassifyOid(), "主题库分类的主键", |
| | | codeBZApplyDTO.getTemplateOid(), "模板的主键", codeBZApplyDTO.getCodeRuleOid(), "编码规则的主键"); |
| | |
| | | LinkedList<CodeOrderSecDTO> newSecDTOList=new LinkedList<>(); |
| | | changeCodeOrderSecDTO(ruleVO,secDTOS,oldCode,newSecDTOList);//根据要求重新算码段码值 |
| | | if(!codeBZApplyDTO.isEditSeries()){//变更为标准 |
| | | if(!codeBZApplyDTO.isSeries()){//如果是表准,则需要将系列好流水置为null |
| | | //if(!codeBZApplyDTO.isSeries()){//如果是表准,则需要将系列好流水置为null |
| | | //因为是标准则控制码段中的系列流水码段值为空 |
| | | newSecDTOList.stream().forEach(codeOrderSecDTO -> { |
| | | if(codeCodeBasicSecMap.containsKey(codeOrderSecDTO.getSecOid())&&codeCodeBasicSecMap.get(codeOrderSecDTO.getSecOid()).getName().equals(secName)){ |
| | | codeOrderSecDTO.setSecValue(""); |
| | | } |
| | | }); |
| | | } |
| | | //} |
| | | orderDTO.setSecDTOList(newSecDTOList); |
| | | return createDataBZ(orderDTO,ruleVO,authUser); |
| | | }else{//变更为系列.则按照逻辑去处理 |
| | |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public String addSaveBZCodeNotauthUser(CodeBZApplyDTO codeBZApplyDTO, boolean authUser) throws Exception { |
| | | return addSaveBZCode(codeBZApplyDTO,authUser); |
| | | } |
| | |
| | | temp = "%s"; |
| | | } |
| | | queryKey = String.format(temp, "nvl("+ "t." + attrId +",'/')"); |
| | | queryValue = String.format(temp, "'" + (trim ? value.trim() : value) + "'"); |
| | | queryValue = String.format(temp, "'" + (trim ? SpecialCharacterConverter.escapeSpecialCharacters(value.trim()):SpecialCharacterConverter.escapeSpecialCharacters(value)) + "'"); |
| | | conditionMap.put(queryKey, queryValue); |
| | | } else { |
| | | if(StringUtils.isNotBlank(value)) { |
| | | //为空的时候不代表不校验,只是不去除相关的信息 |
| | | conditionMap.put("nvl("+ "t." + attrId+",'/')", "'" + value + "'"); |
| | | conditionMap.put("nvl("+ "t." + attrId+",'/')", "'" + SpecialCharacterConverter.escapeSpecialCharacters(value) + "'"); |
| | | }else{ |
| | | conditionMap.put("t." + attrId, QueryOptionConstant.ISNULL); |
| | | } |
| | |
| | | return getSqlByValue(key, value, attrVOMap,btmType); |
| | | } |
| | | }*/ |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | cbo.setLastModifyTime(new Date()); |
| | | cbo.setLastModifier(String.valueOf(AuthUtil.getUser().getAccount())); |
| | | R r = updateBatchByBaseModel(classifyFullInfo.getTopClassifyVO().getBtmTypeId(), Collections.singletonList(cbo)); |
| | | |
| | | if(!r.isSuccess()){ |
| | | throw new ServiceException(r.getMsg()); |
| | | } |
| | |
| | | oldCbo.setLastModifier(String.valueOf(AuthUtil.getUser().getAccount())); |
| | | oldCbo.setLastModifyTime(new Date()); |
| | | try { |
| | | // 修改版次号 |
| | | updateBatchByBaseModel(oldCbo.getBtmname(), Collections.singletonList(oldCbo)); |
| | | // 插入新的数据 |
| | | insertBatchByType(cbo.getBtmname(), Collections.singletonList(cbo)); |
| | | } catch (Exception vciError) { |
| | | throw new VciBaseException("数据更改保存出错了", new String[0], vciError); |
| | | } |
| | | // 记录数据更改日志 |
| | | saveLogUtil.operateLog("数据更改",false, StringUtil.format("{}\n修改为:\n{}",JSON.toJSONString(Collections.singletonList(oldCbo)),JSON.toJSONString(Collections.singletonList(cbo)))); |
| | | } catch (Exception vciError) { |
| | | // 记录数据更改报错时的日志 |
| | | saveLogUtil.operateLog("数据更改",true,vciError.getMessage()); |
| | | throw new VciBaseException("数据更改保存出错了", new String[0], vciError); |
| | | } |
| | | |
| | | batchSaveSelectChar(templateVO, Collections.singletonList(cbo)); |
| | | } |
| | | |