导入规则修改

dev^2
zjh 1 year ago
parent 24740d7d44
commit 5bea448de0
  1. 36
      ant-design-vue-jeecg/src/views/modulex/ModulexList.vue
  2. 113
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/controller/RulexController.java

@ -569,24 +569,24 @@ export default {
}, },
ruleData: function () { ruleData: function () {
return { return {
note: ['对应模块(必填)填写正确的模块名称', note: ['对应模块(必填):填写正确的模块名称',
'对应功能(必填)填写正确的功能名称', '对应功能(必填):填写正确的功能名称',
'对应实体(必填)填写正确的实体名称', '对应实体(必填):填写正确的实体名称',
'顺序号(必填);同功能下不重复', '顺序号(必填):同功能下不重复',
'规则编码(必填):功能编码+顺序号(格式001)', '规则编码(必填):功能编码+顺序号(格式001)',
'规则描述(非必填)', '规则描述(非必填)',
'分析图(非必填)', '分析图(非必填)',
'责任人(非必填)', '责任人(非必填):如果有多个值请使用,分割',
'任务等级(必填):值:1、2、3、4、5个等级', '任务等级(必填):值:1、2、3、4、5个等级',
'任务状态(必填):值:未发布、已发布、开发中、已完成、已撤回、已取消', '任务状态(必填):值:未发布、已发布、开发中、已完成、已撤回、已取消',
'版本状态(必填): 可填入值为[当前、历史]', '版本状态(必填): 可填入值为[当前、历史]',
'规则状态(必填): 值:正常、停用、废弃', '规则状态(必填): 值:正常、停用、废弃',
'开始时间(必填) ', '开始时间(必填):时间格式2023-04-11 14:21:22',
'任务时长(必填)', '任务时长(必填)',
'提交时间(必填)', '提交时间(必填):时间格式2023-04-11 14:21:22',
'实际时长(必填)', '实际时长(必填)',
'规则状态(必填): 值:正常、停用、废弃', '规则状态(必填):值:正常、停用、废弃',
'版本号:请填写小与五位数的正整数' '版本号(必填):请填写小于五位数的正整数'
], ],
title: '导入规则', title: '导入规则',
uploadUrl: this.ruleImportExcelUrl, uploadUrl: this.ruleImportExcelUrl,

@ -1,9 +1,11 @@
package org.jeecg.modules.demo.rulex.controller; package org.jeecg.modules.demo.rulex.controller;
import cn.hutool.core.util.NumberUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.base.Joiner;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -28,7 +30,9 @@ import org.jeecg.modules.fieldx.service.IFieldxService;
import org.jeecg.modules.modulex.entity.Modulex; import org.jeecg.modules.modulex.entity.Modulex;
import org.jeecg.modules.modulex.service.IModulexService; import org.jeecg.modules.modulex.service.IModulexService;
import org.jeecg.modules.system.entity.SysDictItem; import org.jeecg.modules.system.entity.SysDictItem;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.mapper.SysDictItemMapper; import org.jeecg.modules.system.mapper.SysDictItemMapper;
import org.jeecg.modules.system.service.ISysUserService;
import org.jeecg.modules.tablex.entity.Tablex; import org.jeecg.modules.tablex.entity.Tablex;
import org.jeecg.modules.tablex.service.ITablexService; import org.jeecg.modules.tablex.service.ITablexService;
import org.jeecg.modules.tablex.ws.WebSocketUtils; import org.jeecg.modules.tablex.ws.WebSocketUtils;
@ -52,6 +56,7 @@ import java.io.IOException;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* @Description: 规则管理 * @Description: 规则管理
@ -91,6 +96,9 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
@Value("${jeecg.wordPath}") @Value("${jeecg.wordPath}")
private String wordPath; private String wordPath;
@Autowired
private ISysUserService iSysUserService;
/** /**
* 分页列表查询 * 分页列表查询
* *
@ -533,11 +541,42 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
rulex.setRuleNo(ruleVo.getRuleNo()); rulex.setRuleNo(ruleVo.getRuleNo());
//规则编码 //规则编码
String ruleCode = ruleVo.getRuleCode(); String ruleCode = ruleVo.getRuleCode();
Functionx functionxServiceById = functionxService.getById(byId1.getId()); String functionCode1 = byId1.getFunctionCode();
String functionCode = functionxServiceById.getFunctionCode(); if (ruleCode == null) {
// if (!ruleCode.matches(functionCode)) message.put("isError", "true");
// return Result.error("规则编码错误"); message.put("closeable", "true");
rulex.setRuleCode(functionCode); message.put("status", "第" + (i + 1) + "条数据,规则编码错误,请核对");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (i + 1) + "条数据,规则编码错误,请核对");
}
//截取到功能编码校验(去除后三位)
if (!ruleCode.substring(0,ruleCode.length() - 3).equals(functionCode1)){
message.put("isError", "true");
message.put("closeable", "true");
message.put("status", "第" + (i + 1) + "条数据,规则编码错误,请核对");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (i + 1) + "条数据,规则编码错误,请核对");
}
//后三位
String substring = ruleCode.substring(ruleCode.length()-3);
try {
Integer integer1 = Integer.valueOf(substring);
if (integer1<0){
message.put("isError", "true");
message.put("closeable", "true");
message.put("status", "第" + (i + 1) + "条数据,规则编码错误,请核对");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (i + 1) + "条数据,规则编码错误,请核对");
}
} catch (NumberFormatException e) {
message.put("isError", "true");
message.put("closeable", "true");
message.put("status", "第" + (i + 1) + "条数据,规则编码错误,请核对");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (i + 1) + "条数据,规则编码错误,请核对");
}
rulex.setRuleCode(ruleCode);
//规则描述 //规则描述
String pmDescribe = ruleVo.getPmDescribe(); String pmDescribe = ruleVo.getPmDescribe();
if (pmDescribe != null) if (pmDescribe != null)
@ -547,22 +586,64 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
if (diagrams != null) if (diagrams != null)
rulex.setDiagrams(diagrams); rulex.setDiagrams(diagrams);
//版本号 //版本号
Integer integer1; String verison = ruleVo.getVerison();
try { if (ruleVo.getVerison()==null||verison.length() >=5){
integer1 = Integer.valueOf(ruleVo.getVerison());
} catch (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
message.put("isError", "true"); message.put("isError", "true");
message.put("closeable","true"); message.put("closeable", "true");
message.put("status","第"+(i + 1) +"条数据,版本号输入错误,请核对"); message.put("status", "第" + (i + 1) + "条数据,版本号错误,请核对");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第"+(i + 1) +"条数据,版本号输入错误,请核对"); return Result.error("第" + (i + 1) + "条数据,版本号错误,请核对");
} }
rulex.setVerison(String.valueOf(integer1)); try {
Integer integer2 = Integer.valueOf(verison);
if (integer2>0)
rulex.setVerison(String.valueOf(integer2));
else {
message.put("isError", "true");
message.put("closeable", "true");
message.put("status", "第" + (i + 1) + "条数据,版本号输入错误,请核对");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (i + 1) + "条数据,版本号输入错误,请核对");
}
} catch (NumberFormatException e) {
message.put("isError", "true");
message.put("closeable", "true");
message.put("status", "第" + (i + 1) + "条数据,版本号输入错误,请核对");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (i + 1) + "条数据,版本号输入错误,请核对");
}
//责任人 //责任人
String managerUsers = ruleVo.getManagerUsers(); String managerUsers = ruleVo.getManagerUsers();
if (managerUsers != null) if (managerUsers != null){
rulex.setManagerUsers(managerUsers); LambdaQueryWrapper<SysUser> sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
String[] split = managerUsers.split(",");
sysUserLambdaQueryWrapper.in(SysUser::getUsername,split);
List<SysUser> iSysUserServiceOne = iSysUserService.list(sysUserLambdaQueryWrapper);
if(iSysUserServiceOne==null){
message.put("isError", "true");
message.put("status","导入失败,责任人信息查询不到");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,责任人信息查询不到");
}
if (iSysUserServiceOne.size()>1) {
List<String> list3 = iSysUserServiceOne.stream().map(SysUser::getId).collect(Collectors.toList());
if (list3 == null) {
message.put("isError", "true");
message.put("status","导入失败,责任人信息查询不到");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,责任人信息查询不到");
}
rulex.setManagerUsers(Joiner.on(",").join(list3));
}else if (iSysUserServiceOne.size()==1){
String id = iSysUserServiceOne.get(0).getId();
rulex.setManagerUsers(id);
}
}
message.put("status", "正在读取数据"); message.put("status", "正在读取数据");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
//存入集合待存真实表 //存入集合待存真实表

Loading…
Cancel
Save