diff --git a/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue b/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue index abd8159..28582c6 100644 --- a/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue +++ b/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue @@ -569,24 +569,24 @@ export default { }, ruleData: function () { return { - note: ['对应模块(必填):填写正确的模块名称', - '对应功能(必填):填写正确的功能名称', - '对应实体(必填):填写正确的实体名称', - '顺序号(必填);同功能下不重复', - '规则编码(必填):功能编码+顺序号(格式001)', - '规则描述(非必填)', - '分析图(非必填)', - '责任人(非必填)', - '任务等级(必填):值:1、2、3、4、5个等级', - '任务状态(必填):值:未发布、已发布、开发中、已完成、已撤回、已取消', - '版本状态(必填): 可填入值为[当前、历史]', - '规则状态(必填): 值:正常、停用、废弃', - '开始时间(必填) ', - '任务时长(必填)', - '提交时间(必填)', - '实际时长(必填)', - '规则状态(必填): 值:正常、停用、废弃', - '版本号:请填写小与五位数的正整数' + note: ['对应模块(必填):填写正确的模块名称', + '对应功能(必填):填写正确的功能名称', + '对应实体(必填):填写正确的实体名称', + '顺序号(必填):同功能下不重复', + '规则编码(必填):功能编码+顺序号(格式001)', + '规则描述(非必填)', + '分析图(非必填)', + '责任人(非必填):如果有多个值请使用,分割', + '任务等级(必填):值:1、2、3、4、5个等级', + '任务状态(必填):值:未发布、已发布、开发中、已完成、已撤回、已取消', + '版本状态(必填): 可填入值为[当前、历史]', + '规则状态(必填): 值:正常、停用、废弃', + '开始时间(非必填):时间格式2023-04-11 14:21:22', + '任务时长(非必填)', + '提交时间(非必填):时间格式2023-04-11 14:21:22', + '实际时长(非必填)', + '规则状态(必填):值:正常、停用、废弃', + '版本号(必填):请填写小于五位数的正整数' ], title: '导入规则', uploadUrl: this.ruleImportExcelUrl, diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/controller/RulexController.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/controller/RulexController.java index 90d4409..67cc313 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/controller/RulexController.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/controller/RulexController.java @@ -1,9 +1,11 @@ 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.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.google.common.base.Joiner; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; 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.service.IModulexService; 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.service.ISysUserService; import org.jeecg.modules.tablex.entity.Tablex; import org.jeecg.modules.tablex.service.ITablexService; import org.jeecg.modules.tablex.ws.WebSocketUtils; @@ -52,6 +56,7 @@ import java.io.IOException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; +import java.util.stream.Collectors; /** * @Description: 规则管理 @@ -91,6 +96,9 @@ public class RulexController extends JeecgController { @Value("${jeecg.wordPath}") private String wordPath; + @Autowired + private ISysUserService iSysUserService; + /** * 分页列表查询 * @@ -533,11 +541,42 @@ public class RulexController extends JeecgController { rulex.setRuleNo(ruleVo.getRuleNo()); //规则编码 String ruleCode = ruleVo.getRuleCode(); - Functionx functionxServiceById = functionxService.getById(byId1.getId()); - String functionCode = functionxServiceById.getFunctionCode(); - // if (!ruleCode.matches(functionCode)) - // return Result.error("规则编码错误"); - rulex.setRuleCode(functionCode); + String functionCode1 = byId1.getFunctionCode(); + if (ruleCode == null) { + message.put("isError", "true"); + message.put("closeable", "true"); + 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(); if (pmDescribe != null) @@ -547,22 +586,64 @@ public class RulexController extends JeecgController { if (diagrams != null) rulex.setDiagrams(diagrams); //版本号 - Integer integer1; - try { - integer1 = Integer.valueOf(ruleVo.getVerison()); - } catch (Exception e) { - TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了 + String verison = ruleVo.getVerison(); + if (ruleVo.getVerison()==null||verison.length() >=5){ message.put("isError", "true"); - message.put("closeable","true"); - message.put("status","第"+(i + 1) +"条数据,版本号输入错误,请核对"); + message.put("closeable", "true"); + message.put("status", "第" + (i + 1) + "条数据,版本号错误,请核对"); 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(); - if (managerUsers != null) - rulex.setManagerUsers(managerUsers); + if (managerUsers != null){ + LambdaQueryWrapper sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); + String[] split = managerUsers.split(","); + sysUserLambdaQueryWrapper.in(SysUser::getUsername,split); + List 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 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", "正在读取数据"); webSocketUtils.sendMessage(loginUser.getId(), message); //存入集合待存真实表