diff --git a/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue b/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue index 5f3d235..b11b49b 100644 --- a/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue +++ b/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue @@ -505,7 +505,8 @@ export default { }, tablexData: function () { return { - note: ['对应模块(必填):填写正确的模块名称', + note: ['项目名称(必填): 填写已导入的正确的项目名称', + '对应模块(必填):填写已导入的正确的模块名称', '中文名称(必填):与模块名称相同。', '英文名称(必填):与模块名称相同,填写模块名称的英文名称。', '实体状态:可填入值为[正常、停用、废弃],若不填写,默认为“正常”状态。', @@ -524,12 +525,16 @@ export default { '项目名称(必填): 从已存在的项目中选', '中文名称(必填): 相同上级的模块不能重名', '英文名称(必填): 中文名称的英文名称', - '模块编码(必填): 项目编码+模块缩写', + '内容描述(非必填): 最大长度500', '责任人(非必填): 模块的开发任务可以分配给1个或多个人员', '任务等级(必填): 值: 1、2、3、4、5', - '开发状态(必填):值: 未发布、已发布、开发中、已完成、已撤回、已取消', + '任务状态(必填):值: 未发布、已发布、开发中、已完成、已撤回、已取消', + '发布时间(非必填):格式为yyyy-MM-dd HH:mm:ss 例:2023-01-01 12:00:00', '任务时长(必填): 单位小时: 等于下级模块时长的和;默认1(小时)', - '实际时长(必填): 单位小时;最小0.1小时;默认16', + '开始时间(非必填):格式为yyyy-MM-dd HH:mm:ss 例:2023-01-01 12:00:00', + '提交时间(非必填):格式为yyyy-MM-dd HH:mm:ss 例:2023-01-01 12:00:00', + '实际时长(非必填): 单位小时;最小0.1小时', + '用户角色(非必填):对应角色列表', '关联实体(非必填): 关联实体表;关联的是该模块管理的实体', '模块状态(必填): 可填入值为正常、停用、废弃', '版本状态(必填): 可填入值为当前、历史', @@ -571,7 +576,7 @@ export default { }, fieldData: function () { return { - note: ['序号: 请按顺序填入每行数据的序号,比如第一行就写1', + note: ['项目名称(非空): 请填写字段对应的项目名称', '表名(非空): 请填写实体表的名称', '中文名称(非空): 请填写字段名称', '英文名称(非空): 请填写字段名称的英语名称', @@ -597,22 +602,25 @@ export default { }, ruleData: function () { return { - note: ['对应模块(必填):填写正确的模块名称', + note: [ + '对应项目(必填):填写正确的项目名称', + '上级模块(非必填):填写正确的上级模块名称', + '对应模块(必填):填写正确的模块名称', '对应功能(必填):填写正确的功能名称', - '对应实体(必填):填写正确的实体名称', - '顺序号(必填):同功能下不重复', + '对应实体(非必填):填写正确的实体名称', + '对应字段(非必填):填写正确的字段名称', + '顺序号(必填):同功能下不重复,为正整数且与规则编码顺序号相等', '规则编码(必填):功能编码+顺序号(格式001)', '规则描述(非必填)', - '分析图(非必填)', - '责任人(非必填):如果有多个值请使用,分割', + '责任人(非必填):如果有多个值请使用逗号分割', '任务等级(必填):值:1、2、3、4、5个等级', '任务状态(必填):值:未发布、已发布、开发中、已完成、已撤回、已取消', '版本状态(必填): 可填入值为[当前、历史]', '规则状态(必填): 值:正常、停用、废弃', '开始时间(非必填):时间格式2023-04-11 14:21:22', - '任务时长(非必填)', + '任务时长(非必填):正整数', '提交时间(非必填):时间格式2023-04-11 14:21:22', - '实际时长(非必填)', + '实际时长(非必填):正整数', '规则状态(必填):值:正常、停用、废弃', '版本号(必填):请填写小于五位数的正整数' ], 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 88af61d..98abf5d 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 @@ -29,6 +29,8 @@ import org.jeecg.modules.fieldx.entity.Fieldx; 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.projectx.entity.Projectx; +import org.jeecg.modules.projectx.service.impl.ProjectxServiceImpl; import org.jeecg.modules.system.entity.SysDictItem; import org.jeecg.modules.system.entity.SysUser; import org.jeecg.modules.system.mapper.SysDictItemMapper; @@ -96,6 +98,9 @@ public class RulexController extends JeecgController { @Autowired private WebSocketUtils webSocketUtils; + @Autowired + private ProjectxServiceImpl projectxService; + @Value("${jeecg.wordPath}") private String wordPath; @@ -258,13 +263,13 @@ public class RulexController extends JeecgController { message.put("uploaded", "0"); message.put("status", "判断文件结构"); message.put("isError", "false"); - message.put("closeable","false"); + message.put("closeable", "false"); webSocketUtils.sendMessage(loginUser.getId(), message); //判断文件是否为空 if (file == null) { message.put("isError", "true"); - message.put("closeable","true"); - message.put("status","文件上传失败,请重新上传"); + message.put("closeable", "true"); + message.put("status", "文件上传失败,请重新上传"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("文件上传失败,请重新上传"); } @@ -274,8 +279,8 @@ public class RulexController extends JeecgController { (!originalFilename.endsWith("xls") && !originalFilename.endsWith("xlsx"))) { message.put("isError", "true"); - message.put("closeable","true"); - message.put("status","文件格式不正确"); + message.put("closeable", "true"); + message.put("status", "文件格式不正确"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("文件格式不正确"); } @@ -285,8 +290,8 @@ public class RulexController extends JeecgController { params.setHeadRows(1);//表头行数,默认1 params.setNeedSave(true);//是否需要保存上传的Excel,默认为false - message.put("status", "数据预读入"); - webSocketUtils.sendMessage(loginUser.getId(), message); + message.put("status", "数据预读入"); + webSocketUtils.sendMessage(loginUser.getId(), message); List list = null; try { list = ExcelImportUtil.importExcel(file.getInputStream(), RuleVo.class, params); @@ -294,44 +299,45 @@ public class RulexController extends JeecgController { e.printStackTrace(); } if (list == null || list.size() <= 0) { - message.put("isError", "true"); - message.put("closeable","true"); - message.put("status","文件导入失败:模板中暂无数据"); - webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("文件导入失败:模板中暂无数据"); - } - //必要字段判断空值 - for (int i = 0; i < list.size(); i++) { - if ( - StringUtils.isBlank(list.get(i).getRuleNo()) || - StringUtils.isBlank(list.get(i).getRuleCode()) || + message.put("isError", "true"); + message.put("closeable", "true"); + message.put("status", "文件导入失败:模板中暂无数据"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("文件导入失败:模板中暂无数据"); + } + //必要字段判断空值 + for (int i = 0; i < list.size(); i++) { + if ( + StringUtils.isBlank(list.get(i).getRuleNo()) || + StringUtils.isBlank(list.get(i).getProjectId()) || + StringUtils.isBlank(list.get(i).getRuleCode()) || // StringUtils.isBlank() list.get(i).getPmDescribe() == null && - StringUtils.isBlank(list.get(i).getModuleId() ) || - StringUtils.isBlank(list.get(i).getFunctionId()) || + StringUtils.isBlank(list.get(i).getModuleId()) || + StringUtils.isBlank(list.get(i).getFunctionId()) || // StringUtils.isBlank() list.get(i).getDiagrams() == null && - StringUtils.isBlank( list.get(i).getTableId() ) || +// StringUtils.isBlank(list.get(i).getTableId()) || // StringUtils.isBlank() list.get(i).getFieldId() == null || - StringUtils.isBlank( list.get(i).getManagerUsers())|| - StringUtils.isBlank(list.get(i).getWorkLevel()) || - StringUtils.isBlank(list.get(i).getWorkStatus()) || + StringUtils.isBlank(list.get(i).getManagerUsers()) || + StringUtils.isBlank(list.get(i).getWorkLevel()) || + StringUtils.isBlank(list.get(i).getWorkStatus()) || // StringUtils.isBlank() list.get(i).getStartTime() == null && // StringUtils.isBlank() list.get(i).getManagerUsers() == null && // StringUtils.isBlank() list.get(i).getDuration() == null && // StringUtils.isBlank() list.get(i).getSubmitTime() == null && - StringUtils.isBlank(list.get(i).getRealDuration()) && - StringUtils.isBlank(list.get(i).getStatus() ) || - StringUtils.isBlank( list.get(i).getVerisonStatus()) || - StringUtils.isBlank(list.get(i).getVerison()) ) { +// StringUtils.isBlank(list.get(i).getRealDuration()) && + StringUtils.isBlank(list.get(i).getStatus()) || + StringUtils.isBlank(list.get(i).getVerisonStatus()) || + StringUtils.isBlank(list.get(i).getVerison())) { - message.put("isError", "true"); - message.put("closeable","true"); - message.put("status","文件导入失败:"+"第"+(i + 1) + "条存在必填数据为空,请核对"); - webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("文件导入失败:"+"第"+(i + 1) + "条不能为空,请核对"); - } - //存入预存表 - iRuleVoService.save(list.get(i)); + message.put("isError", "true"); + message.put("closeable", "true"); + message.put("status", "文件导入失败:" + "第" + (i + 1) + "条存在必填数据为空,请核对"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("文件导入失败:" + "第" + (i + 1) + "条不能为空,请核对"); } + //存入预存表 + iRuleVoService.save(list.get(i)); + } List rulexList; try { //取出预存表校验字段 @@ -339,8 +345,8 @@ public class RulexController extends JeecgController { if (ruleVoList.size() <= 0 || ruleVoList == null) { message.put("isError", "true"); - message.put("closeable","true"); - message.put("status","文件导入失败,模板不匹配有空值"); + message.put("closeable", "true"); + message.put("status", "文件导入失败,模板不匹配有空值"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("文件导入失败,模板不匹配有空值"); } @@ -355,13 +361,24 @@ public class RulexController extends JeecgController { for (int i = 0; i < ruleVoList.size(); i++) { Rulex rulex = new Rulex(); RuleVo ruleVo = ruleVoList.get(i); - + String projectId = ruleVo.getProjectId(); String pModuleId = ruleVo.getModulePid(); String moduleId = ruleVo.getModuleId(); //对应模块 + LambdaQueryWrapper projectxLambdaQueryWrapper =new LambdaQueryWrapper<>(); + projectxLambdaQueryWrapper.eq(Projectx::getProjectName,projectId); + + Projectx projectx = projectxService.getOne(projectxLambdaQueryWrapper); + if (projectx==null){ + message.put("isError", "true"); + message.put("closeable", "true"); + message.put("status", "第" + (i + 1) + "条数据,项目输入错误,请核对"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("第" + (i + 1) + "条数据,项目输入错误,请核对"); + } //判断上级模块是否存在 int n = 0; - if (!StringUtils.isBlank(pModuleId) ) { + if (!StringUtils.isBlank(pModuleId)) { //存在 String pid = ""; for (Modulex modulex : modulexList) { @@ -380,10 +397,20 @@ public class RulexController extends JeecgController { return Result.error("第" + (i + 1) + "条数据,上级模块输入错误,请核对"); } } - //判断上级模块+模块是否存在 + //判断上级模块+模块是否存在且是否属于当前项目下 + for (Modulex modulex : modulexList) { if (modulex.getModuleName().equals(moduleId) && modulex.getPid().equals(pid)) { + if (!modulex.getProjectId().equals(projectx.getId())) + { + message.put("isError", "true"); + message.put("closeable", "true"); + message.put("status", "第" + (i + 1) + "条数据,该模块与项目不对应输入错误,请核对"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("第" + (i + 1) + "条数据,该模块与项目不对应输入错误,请核对"); + } rulex.setModuleId(modulex.getId()); + break; } n++; @@ -397,9 +424,17 @@ public class RulexController extends JeecgController { } } else { n = 0; - //判断模块是否存在 + //判断模块是否存在且是否属于当前项目下 for (Modulex modulex : modulexList) { if (modulex.getModuleName().equals(moduleId) && modulex.getPid() == null) { + if (!modulex.getProjectId().equals(projectx.getId())) + { + message.put("isError", "true"); + message.put("closeable", "true"); + message.put("status", "第" + (i + 1) + "条数据,该模块与项目不对应输入错误,请核对"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("第" + (i + 1) + "条数据,该模块与项目不对应输入错误,请核对"); + } rulex.setModuleId(modulex.getId()); break; } @@ -430,25 +465,28 @@ public class RulexController extends JeecgController { rulex.setFunctionId(functionx.getId()); // //对应实体 + String tableId = ruleVo.getTableId(); - LambdaQueryWrapper tableLambdaQueryWrapper = new LambdaQueryWrapper<>(); - tableLambdaQueryWrapper.eq(Tablex::getTableName, tableId).eq(Tablex::getModuleId, rulex.getModuleId()); - Tablex tablex = iTablexService.getOne(tableLambdaQueryWrapper); - if (tablex == null) { + if (!StringUtils.isBlank(tableId)) { + LambdaQueryWrapper tableLambdaQueryWrapper = new LambdaQueryWrapper<>(); + tableLambdaQueryWrapper.eq(Tablex::getTableName, tableId).eq(Tablex::getModuleId, rulex.getModuleId()); + Tablex tablex = iTablexService.getOne(tableLambdaQueryWrapper); + if (tablex == null) { - iRuleVoService.remove(null); - message.put("isError", "true"); - message.put("closeable", "true"); - message.put("status", "第" + (i + 1) + "条数据,对应实体输入错误,请核对"); - webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("第" + (i + 1) + "条数据,对应实体输入错误,请核对"); + iRuleVoService.remove(null); + message.put("isError", "true"); + message.put("closeable", "true"); + message.put("status", "第" + (i + 1) + "条数据,对应实体输入错误,请核对"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("第" + (i + 1) + "条数据,对应实体输入错误,请核对"); + } + rulex.setTableId(tablex.getId()); } - rulex.setTableId(tablex.getId()); //对应字段 String fieldId = ruleVo.getFieldId(); String tableId1 = rulex.getTableId(); - if (!StringUtils.isBlank(fieldId) ) { + if (!StringUtils.isBlank(fieldId)) { LambdaQueryWrapper rulexLambdaQueryWrapper = new LambdaQueryWrapper<>(); rulexLambdaQueryWrapper.eq(Fieldx::getFieldName, fieldId).eq(Fieldx::getTableId, tableId1); Fieldx fieldx = iFieldxService.getOne(rulexLambdaQueryWrapper); @@ -462,11 +500,17 @@ public class RulexController extends JeecgController { } rulex.setFieldId(fieldx.getId()); } - Double aDouble = null; + Double duration = null; try { - if (aDouble != null) - aDouble = Double.valueOf(ruleVo.getDuration()); - rulex.setDuration(aDouble); + if (duration < 0){ + message.put("isError", "true"); + message.put("closeable", "true"); + message.put("status", "第" + (i + 1) + "条数据,任务时长输入错误,请核对"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("第" + (i + 1) + "条数据,任务时长输入错误,请核对"); + } + duration = Double.valueOf(ruleVo.getDuration()); + rulex.setDuration(duration); } catch (Exception e) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了 message.put("isError", "true"); @@ -477,29 +521,37 @@ public class RulexController extends JeecgController { } Double d; - try { - d = Double.valueOf(ruleVo.getRealDuration()); - } catch (Exception e) { - TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了 - message.put("isError", "true"); - message.put("closeable", "true"); - message.put("status", "第" + (i + 1) + "条数据,实际时长输入错误,请核对"); - webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("第" + (i + 1) + "条数据,实际时长输入错误,请核对"); + String realDuration = ruleVo.getRealDuration(); + if (!StringUtils.isBlank(realDuration)) { + try { + d = Double.valueOf(realDuration); + if (d < 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 (Exception e) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了 + message.put("isError", "true"); + message.put("closeable", "true"); + message.put("status", "第" + (i + 1) + "条数据,实际时长输入错误,请核对"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("第" + (i + 1) + "条数据,实际时长输入错误,请核对"); + } + rulex.setRealDuration(d); } - rulex.setRealDuration(d); - Integer integer; - try { - integer = Integer.valueOf(ruleVo.getWorkLevel()); - } catch (Exception e) { - TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了 + +String workLevel = ruleVo.getWorkLevel(); + if (!workLevel.matches("^[1-5]$")){ message.put("isError", "true"); message.put("closeable", "true"); message.put("status", "第" + (i + 1) + "条数据,任务等级输入错误,请核对"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("第" + (i + 1) + "条数据,任务等级输入错误,请核对"); } - rulex.setWorkLevel(integer); + rulex.setWorkLevel(Integer.valueOf(workLevel)); String workStatus = ruleVo.getWorkStatus(); // LambdaQueryWrapper sysDictItemLambdaQueryWrapper = new LambdaQueryWrapper<>(); // sysDictItemLambdaQueryWrapper.eq(SysDictItem::getItemText, workStatus).eq(SysDictItem::getDictId, "1645268542514421762"); @@ -576,7 +628,7 @@ public class RulexController extends JeecgController { } } String submitTime = ruleVo.getSubmitTime(); - if (!StringUtils.isBlank(submitTime)){ + if (!StringUtils.isBlank(submitTime)) { String submitTimeT = getTime(submitTime); try { date = simpleDateFormat.parse(submitTimeT); @@ -591,9 +643,7 @@ public class RulexController extends JeecgController { } } - //规则序号 - String ruleNo = ruleVo.getRuleNo(); - rulex.setRuleNo(ruleNo); + //规则编码 String ruleCode = ruleVo.getRuleCode(); String functionCode1 = functionx.getFunctionCode(); @@ -632,96 +682,109 @@ public class RulexController extends JeecgController { return Result.error("第" + (i + 1) + "条数据,规则编码错误,请核对"); } rulex.setRuleCode(ruleCode); - //规则描述 - String pmDescribe = ruleVo.getPmDescribe(); - if (pmDescribe != null) - rulex.setPmDescribe(pmDescribe); - //分析图 - String diagrams = ruleVo.getDiagrams(); - if (diagrams != null) - rulex.setDiagrams(diagrams); - //版本号 - String verison = ruleVo.getVerison(); - if (ruleVo.getVerison() == null || verison.length() >= 5) { + //规则序号 + String ruleNo = ruleVo.getRuleNo(); + String c = ruleCode.substring(ruleCode.length() - ruleNo.length()); +//三位数整数且与编码后三位相同 + if (!(c.equals(ruleNo) && ruleNo.matches("^[0-9]*[1-9][0-9]*$") && (Integer.valueOf(ruleNo) < 1000))) { message.put("isError", "true"); message.put("closeable", "true"); - message.put("status", "第" + (i + 1) + "条数据,版本号错误,请核对"); + message.put("status", "第" + (i + 1) + "条数据,规则序号错误,请核对"); webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("第" + (i + 1) + "条数据,版本号错误,请核对"); + return Result.error("第" + (i + 1) + "条数据,规则序号错误,请核对"); } - try { - Integer integer2 = Integer.valueOf(verison); - if (integer2 > 0) - rulex.setVerison(String.valueOf(integer2)); - else { + rulex.setRuleNo(ruleNo); + { + + //规则描述 + String pmDescribe = ruleVo.getPmDescribe(); + if (pmDescribe != null) + rulex.setPmDescribe(pmDescribe); + //版本号 + 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("status", "第" + (i + 1) + "条数据,版本号错误,请核对"); webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("第" + (i + 1) + "条数据,版本号输入错误,请核对"); + 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) { - LambdaQueryWrapper sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); - String[] split = managerUsers.split(","); - sysUserLambdaQueryWrapper.in(SysUser::getUsername, split); - List iSysUserServiceOne = iSysUserService.list(sysUserLambdaQueryWrapper); - if (iSysUserServiceOne == null) { + 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("status", "导入失败,责任人信息查询不到"); message.put("closeable", "true"); + message.put("status", "第" + (i + 1) + "条数据,版本号输入错误,请核对"); webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("导入失败,责任人信息查询不到"); + return Result.error("第" + (i + 1) + "条数据,版本号输入错误,请核对"); } - if (iSysUserServiceOne.size() > 1) { - List list3 = iSysUserServiceOne.stream().map(SysUser::getId).collect(Collectors.toList()); - if (list3 == null) { + + + //责任人 + String managerUsers = ruleVo.getManagerUsers(); + if (!StringUtils.isBlank(managerUsers)) { + 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("导入失败,责任人信息查询不到"); } - rulex.setManagerUsers(Joiner.on(",").join(list3)); - } else if (iSysUserServiceOne.size() == 1) { - String id = iSysUserServiceOne.get(0).getId(); - rulex.setManagerUsers(id); + 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); + //存入集合待存真实表 + rulexList.add(rulex); } + } + } finally{ + //清理预存表 + iRuleVoService.remove(null); + } + //存入真实表 + Boolean aBoolean = rulexService.saveRule(rulexList, loginUser, message); - message.put("status", "正在读取数据"); + if (aBoolean) { + message.put("status", "导入成功"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); - //存入集合待存真实表 - rulexList.add(rulex); + return Result.ok("文件导入成功!"); + } else { + return Result.error("文件导入失败!"); } - } finally { - //清理预存表 - iRuleVoService.remove(null); - } - //存入真实表 - Boolean aBoolean = rulexService.saveRule(rulexList, loginUser, message); - if (aBoolean) { - message.put("status", "导入成功"); - message.put("closeable", "true"); - webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.ok("文件导入成功!"); - }else { - return Result.error("文件导入失败!"); - } } + @GetMapping(value = "/sort") public Result sort(@RequestParam(name = "id", required = true) String id) { return rulexService.sort(id); diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/entity/RuleVo.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/entity/RuleVo.java index 853fd93..f9af013 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/entity/RuleVo.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/entity/RuleVo.java @@ -63,12 +63,14 @@ public class RuleVo implements Serializable { @ApiModelProperty(value = "更新日期") private String updateTime; + @Excel(name = "对应项目", width = 15) + @ApiModelProperty(value = "对应项目") + private java.lang.String projectId; /** * 对应模块父id */ - @TableField(exist = false) - @Excel(name = "对应模块父模块", width = 15) - @ApiModelProperty(value = "对应模块") + @Excel(name = "上级模块", width = 15) + @ApiModelProperty(value = "上级模块") private java.lang.String modulePid; /** * 对应模块id @@ -77,6 +79,7 @@ public class RuleVo implements Serializable { @ApiModelProperty(value = "对应模块") @Dict(dictTable = "modulex", dicCode = "id", dicText = "module_name") private java.lang.String moduleId; + /** * 对应功能id */ @@ -102,12 +105,6 @@ public class RuleVo implements Serializable { @Excel(name = "规则描述", width = 15) @ApiModelProperty(value = "规则描述") private java.lang.String pmDescribe; - /** - * 分析图 - */ - @Excel(name = "分析图", width = 15) - @ApiModelProperty(value = "分析图") - private java.lang.String diagrams; /** * 对应实体id */ diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/entity/Rulex.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/entity/Rulex.java index e340ffb..37567d4 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/entity/Rulex.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/entity/Rulex.java @@ -6,6 +6,7 @@ import java.util.Date; import java.math.BigDecimal; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; @@ -99,6 +100,7 @@ public class Rulex implements Serializable { */ @Excel(name = "分析图", width = 15) @ApiModelProperty(value = "分析图") + @TableField(exist = false) private java.lang.String diagrams; /** * 对应实体id diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/controller/FieldxController.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/controller/FieldxController.java index 634d727..57492f5 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/controller/FieldxController.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/controller/FieldxController.java @@ -366,7 +366,7 @@ public class FieldxController extends JeecgController { } - if(!"序号".equals(row.getCell(0).getStringCellValue())||!"表名".equals(row.getCell(1).getStringCellValue()) + if(!"项目名称".equals(row.getCell(0).getStringCellValue())||!"表名".equals(row.getCell(1).getStringCellValue()) ||!"中文名称".equals(row.getCell(2).getStringCellValue())||!"英文名称".equals(row.getCell(3).getStringCellValue()) ||!"数据类型".equals(row.getCell(4).getStringCellValue())||!"数据长度".equals(row.getCell(5).getStringCellValue()) ||!"浮点精度".equals(row.getCell(6).getStringCellValue())||!"显示形式".equals(row.getCell(7).getStringCellValue()) @@ -426,43 +426,51 @@ public class FieldxController extends JeecgController { for (int i=0;i< numberofSheets;i++) { Sheet Sheet=workbook.getSheetAt(i); + int physicalNumberOfRows = Sheet.getPhysicalNumberOfRows(); - for(int r=3;r<=Sheet.getLastRowNum();r++) { + for(int r=3;r<=physicalNumberOfRows;r++) { Row cells = Sheet.getRow(r); FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator(); - Cell cell = cells.getCell(0); - if (cell==null||String.valueOf(cell).equals("")) { - break; - } ExcelInfo excelInfo = new ExcelInfo(); excelInfo.setcells(cells,workbook); Fieldx222 fieldx222 = new Fieldx222(); + if(StringUtil.isBlank(excelInfo.getproject())&&StringUtil.isBlank(excelInfo.getTableId())&&StringUtil.isBlank(excelInfo.getFieldName())) + break; + if(StringUtil.isBlank(excelInfo.getproject())){ + message.put("isError", "true"); + message.put("status","序号为" + (r + 1) + "的”项目名称”不能为空或是此项目不存在"); + webSocketUtils.sendMessage(loginUser.getId(), message); + fieldx222Service.remove(null); + return Result.error("序号为" + (r + 1) + "的项目名称不能为空或是此项目不纯在"); + } if (StringUtil.isBlank(excelInfo.getTableId())) { message.put("isError", "true"); - message.put("status","序号为" + (r - 2) + "的”表名”不能为空或是此表不存在"); + message.put("status","序号为" + (r + 1) + "的”表名”不能为空或是此表不存在"); webSocketUtils.sendMessage(loginUser.getId(), message); fieldx222Service.remove(null); - return Result.error("序号为" + (r - 2) + "的表名不能为空或是此表不纯在"); + return Result.error("序号为" + (r + 1) + "的表名不能为空或是此表不纯在"); } fieldx222.setTableId(excelInfo.getTableId()); if (StringUtil.isBlank(excelInfo.getFieldName())) { message.put("isError", "true"); - message.put("status","序号为 "+ (r - 2) + "的”中文名称”不能为空"); + message.put("status","序号为 "+ (r + 1) + "的”中文名称”不能为空"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); fieldx222Service.remove(null); - return Result.error("序号为" + (r - 2) + "的中文名称不能为空"); + return Result.error("序号为" + (r + 1) + "的中文名称不能为空"); } fieldx222.setFieldName(excelInfo.getFieldName()); - Fieldx222 fieldx2221=fieldx222Service.query().eq("field_name",excelInfo.getFieldName()).one(); + + Fieldx222 fieldx2221=fieldx222Service.query().eq("field_name", + excelInfo.getFieldName()).eq("table_id",excelInfo.getTableId()).one(); if(fieldx2221!=null){ message.put("isError", "true"); - message.put("status","序号为 "+ (r - 2) + "的”中文名称”与表中数据已重复"); + message.put("status","序号为 "+ (r + 1) + "的”中文名称”与表中数据已重复"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); fieldx222Service.remove(null); - return Result.error("序号为" + (r - 2) + "的中文名称与表中数据已重复"); + return Result.error("序号为" + (r + 1) + "的中文名称与表中数据已重复"); } fieldx222.setFieldName(excelInfo.getFieldName()); @@ -471,45 +479,46 @@ public class FieldxController extends JeecgController { List list=fieldxService.list(queryWrapper); if(list!=null&&list.size()!=0){ message.put("isError", "true"); - message.put("status","序号为" + (r - 2) + "的字段名此表已存在不能重复"); + message.put("status","序号为" + (r + 1) + "的字段名此表已存在不能重复"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); fieldx222Service.remove(null); - return Result.error("序号为" + (r - 2) + "的字段名此表已存在不能重复"); + return Result.error("序号为" + (r + 1) + "的字段名此表已存在不能重复"); } if (StringUtil.isBlank(excelInfo.getFieldEnName())) { message.put("isError", "true"); - message.put("status","序号为" + (r - 2) + "的”英文名称”不能为空"); + message.put("status","序号为" + (r + 1) + "的”英文名称”不能为空"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); fieldx222Service.remove(null); - return Result.error("序号为" + (r - 2) + "的英文名称不能为空"); + return Result.error("序号为" + (r + 1) + "的英文名称不能为空"); } - Fieldx222 fieldx2222=fieldx222Service.query().eq("field_en_name",excelInfo.getFieldEnName()).one(); + Fieldx222 fieldx2222=fieldx222Service.query().eq("field_en_name",excelInfo.getFieldEnName()) + .eq("table_id",excelInfo.getTableId()).one(); if(fieldx2222!=null){ message.put("isError", "true"); - message.put("status","序号为" + (r - 2) +" 的”英文名称”与表中数据已重复"); + message.put("status","序号为" + (r + 1) +" 的”英文名称”与表中数据已重复"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); fieldx222Service.remove(null); - return Result.error("序号为" + (r - 2) + "的英文名称与表中数据已重复"); + return Result.error("序号为" + (r + 1) + "的英文名称与表中数据已重复"); } fieldx222.setFieldEnName(excelInfo.getFieldEnName()); if (StringUtil.isBlank(excelInfo.getType())) { message.put("isError", "true"); - message.put("status","序号为" + (r - 2) + "的”数据类型”不能为空"); + message.put("status","序号为" + (r + 1) + "的”数据类型”不能为空"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); fieldx222Service.remove(null); - return Result.error("序号为" + (r - 2) + "的数据类型不能为空"); + return Result.error("序号为" + (r + 1) + "的数据类型不能为空"); } else if(!sjlx.contains(excelInfo.getType())){ message.put("isError", "true"); - message.put("status","序号为" + (r - 2) + "的”数据类型”输入格式不正确"); + message.put("status","序号为" + (r + 1) + "的”数据类型”输入格式不正确"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); fieldx222Service.remove(null); - return Result.error("序号为" + (r - 2) + "的数据类型输入格式不正确"); + return Result.error("序号为" + (r + 1) + "的数据类型输入格式不正确"); } fieldx222.setType(excelInfo.getType()); @@ -518,11 +527,11 @@ public class FieldxController extends JeecgController { } else if(!sf.contains(excelInfo.getIsPk())){ message.put("isError", "true"); - message.put("status","序号为" + (r - 2) + "的”是否主键”输入格式不正确"); + message.put("status","序号为" + (r + 1) + "的”是否主键”输入格式不正确"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); fieldx222Service.remove(null); - return Result.error("序号为" + (r - 2) + "的是否主键输入格式不正确"); + return Result.error("序号为" + (r + 1) + "的是否主键输入格式不正确"); } fieldx222.setIsPk(excelInfo.getIsPk()); if (StringUtil.isBlank(excelInfo.getIsFk())) { @@ -530,79 +539,79 @@ public class FieldxController extends JeecgController { } else if(!sf.contains(excelInfo.getIsFk())){ message.put("isError", "true"); - message.put("status","序号为" + (r - 2) + "的”是否外键”输入格式不正确"); + message.put("status","序号为" + (r + 1) + "的”是否外键”输入格式不正确"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); fieldx222Service.remove(null); - return Result.error("序号为" + (r - 2) + "的是否外键输入格式不正确"); + return Result.error("序号为" + (r + 1) + "的是否外键输入格式不正确"); } fieldx222.setIsFk(excelInfo.getIsFk()); if (StringUtil.isBlank(excelInfo.getIsNull())) { message.put("isError", "true"); - message.put("status","序号为" + (r - 2) + "的”是否为空”不能为空"); + message.put("status","序号为" + (r + 1) + "的”是否为空”不能为空"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); fieldx222Service.remove(null); - return Result.error("序号为" + (r - 2) + "的是否为空不能为空"); + return Result.error("序号为" + (r + 1) + "的是否为空不能为空"); } else if(!sf.contains(excelInfo.getIsNull())){ message.put("isError", "true"); - message.put("status","序号为" + (r - 2) + "的”是否为空”输入格式不正确"); + message.put("status","序号为" + (r + 1)+ "的”是否为空”输入格式不正确"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); fieldx222Service.remove(null); - return Result.error("序号为" + (r - 2) + "的是否为空输入格式不正确"); + return Result.error("序号为" + (r + 1) + "的是否为空输入格式不正确"); } fieldx222.setIsNull(excelInfo.getIsNull()); if (StringUtil.isBlank(excelInfo.getIsUniqueness())) { message.put("isError", "true"); - message.put("status","序号为" + (r - 2) + "的”是否重复”不能为空"); + message.put("status","序号为" + (r + 1) + "的”是否重复”不能为空"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); fieldx222Service.remove(null); - return Result.error("序号为" + (r - 2) + "的是否重复不能为空"); + return Result.error("序号为" + (r + 1)+ "的是否重复不能为空"); } else if(!sf.contains(excelInfo.getIsUniqueness())){ message.put("isError", "true"); - message.put("status","序号为" + (r - 2) + "的”是否重复”输入格式不正确"); + message.put("status","序号为" + (r + 1) + "的”是否重复”输入格式不正确"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); fieldx222Service.remove(null); - return Result.error("序号为" + (r - 2) + "的是否重复输入格式不正确"); + return Result.error("序号为" + (r + 1) + "的是否重复输入格式不正确"); } fieldx222.setIsUniqueness(excelInfo.getIsUniqueness()); if (StringUtil.isBlank(excelInfo.getStatus())) { message.put("isError", "true"); - message.put("status","序号为" + (r - 2) + "的”字段状态”不能为空"); + message.put("status","序号为" + (r + 1)+ "的”字段状态”不能为空"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); fieldx222Service.remove(null); - return Result.error("序号为" + (r - 2) + "的”字段状态”不能为空"); + return Result.error("序号为" + (r + 1) + "的”字段状态”不能为空"); } else if(!zt.contains(excelInfo.getStatus())){ message.put("isError", "true"); - message.put("status","序号为" + (r - 2) + "的”字段状态”输入格式不正确"); + message.put("status","序号为" + (r + 1) + "的”字段状态”输入格式不正确"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); fieldx222Service.remove(null); - return Result.error("序号为" + (r - 2) + "的字段状态输入格式不正确"); + return Result.error("序号为" + (r + 1) + "的字段状态输入格式不正确"); } fieldx222.setStatus(excelInfo.getStatus()); if (StringUtil.isBlank(excelInfo.getVerisonStatus())) { message.put("isError", "true"); - message.put("status","序号为" + (r - 2) + "的”版本状态”不能为空"); + message.put("status","序号为" + (r + 1) + "的”版本状态”不能为空"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); fieldx222Service.remove(null); - return Result.error("序号为" + (r - 2) + "的”版本状态”不能为空"); + return Result.error("序号为" + (r + 1) + "的”版本状态”不能为空"); } else if(!sf.contains(excelInfo.getVerisonStatus())){ message.put("isError", "true"); - message.put("status","序号为" + (r - 2) + "的”版本状态”输入格式不正确"); + message.put("status","序号为" + (r + 1) + "的”版本状态”输入格式不正确"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); fieldx222Service.remove(null); - return Result.error("序号为" + (r - 2) + "的版本状态输入格式不正确"); + return Result.error("序号为" + (r + 1) + "的版本状态输入格式不正确"); } fieldx222.setVerisonStatus(excelInfo.getVerisonStatus()); diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/dto/ExcelInfo.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/dto/ExcelInfo.java index 3c78d4f..94baf0b 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/dto/ExcelInfo.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/dto/ExcelInfo.java @@ -2,6 +2,8 @@ package org.jeecg.modules.fieldx.dto; import com.aliyuncs.utils.StringUtils; import org.apache.poi.ss.usermodel.*; +import org.jeecg.modules.projectx.entity.Projectx; +import org.jeecg.modules.projectx.service.impl.ProjectxServiceImpl; import org.jeecg.modules.tablex.entity.Tablex; import org.jeecg.modules.tablex.service.impl.TablexServiceImpl; import org.springframework.beans.factory.annotation.Autowired; @@ -20,6 +22,8 @@ public class ExcelInfo { @Autowired private TablexServiceImpl tablexService; + @Autowired + private ProjectxServiceImpl projectxService; public void setcells(Row cells ,Workbook workbook){ this.cells = cells; @@ -30,11 +34,21 @@ public class ExcelInfo { public void init(){ excelInfo=this; excelInfo.tablexService=this.tablexService; + excelInfo.projectxService=this.projectxService; + } + public String getproject(){ + String value=zhcell((cells.getCell(0))); + if (value==null) + return null; + Projectx projectx=excelInfo.projectxService.query().eq("project_name",value).one(); + if(projectx==null) + return null; + return "1"; } public String getTableId(){ String value=zhcell(cells.getCell(1)); System.out.println("value = ==================================" + value); - if(StringUtils.isEmpty(value)) + if(value==null) return null; List list =excelInfo.tablexService.query().eq("table_name",value).list(); if(list==null||list.size()==0) diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/entity/ModulexTemplate.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/entity/ModulexTemplate.java index 9cfca17..e31a374 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/entity/ModulexTemplate.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/entity/ModulexTemplate.java @@ -71,12 +71,7 @@ public class ModulexTemplate implements Serializable { @Excel(name = "英文名称", width = 15) @ApiModelProperty(value = "英文名称") private String moduleEnName; - /** - * 模块编码 - */ - @Excel(name = "模块编码", width = 15) - @ApiModelProperty(value = "模块编码") - private String moduleCode; + /** * 内容描述 */ diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexServiceImpl.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexServiceImpl.java index d0805df..520effd 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexServiceImpl.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexServiceImpl.java @@ -409,25 +409,24 @@ public class ModulexServiceImpl extends ServiceImpl impl String name = formatter.formatCellValue(cell,evaluator); propertyNames.add(name); } - if(propertyNames.size()!=19 || !propertyNames.get(0).equals("上级模块名称") + if(propertyNames.size()!=18 || !propertyNames.get(0).equals("上级模块名称") || !propertyNames.get(1).equals("项目名称") || !propertyNames.get(2).equals("中文名称") || !propertyNames.get(3).equals("英文名称") - || !propertyNames.get(4).equals("模块编码") - || !propertyNames.get(5).equals("内容描述") - || !propertyNames.get(6).equals("责任人") - || !propertyNames.get(7).equals("任务等级") - || !propertyNames.get(8).equals("任务状态") - || !propertyNames.get(9).equals("发布时间") - || !propertyNames.get(10).equals("任务时长") - || !propertyNames.get(11).equals("开始时间") - || !propertyNames.get(12).equals("提交时间") - || !propertyNames.get(13).equals("实际时长") - || !propertyNames.get(14).equals("用户角色") - || !propertyNames.get(15).equals("关联实体") - || !propertyNames.get(16).equals("模块状态") - || !propertyNames.get(17).equals("版本状态") - || !propertyNames.get(18).equals("版本号")){ + || !propertyNames.get(4).equals("内容描述") + || !propertyNames.get(5).equals("责任人") + || !propertyNames.get(6).equals("任务等级") + || !propertyNames.get(7).equals("任务状态") + || !propertyNames.get(8).equals("发布时间") + || !propertyNames.get(9).equals("任务时长") + || !propertyNames.get(10).equals("开始时间") + || !propertyNames.get(11).equals("提交时间") + || !propertyNames.get(12).equals("实际时长") + || !propertyNames.get(13).equals("用户角色") + || !propertyNames.get(14).equals("关联实体") + || !propertyNames.get(15).equals("模块状态") + || !propertyNames.get(16).equals("版本状态") + || !propertyNames.get(17).equals("版本号")){ message.put("isError", "true"); message.put("status", "模块管理execl表格不规范,请对比模板重新上传"); message.put("closeable","true"); @@ -459,48 +458,52 @@ public class ModulexServiceImpl extends ServiceImpl impl modulexVo.setModuleEnName(value); break; case 4: - modulexVo.setModuleCode(value); - break; - case 5: + if(value.length()>500){ + message.put("isError", "true"); + message.put("status","导入失败,第" + (i+4) +"行" +"内容描述过长"); + message.put("closeable","true"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("内容描述过长,"+"请重新导入"); + } modulexVo.setPmDescribe(value); break; - case 6: + case 5: modulexVo.setManagerUsers(value); break; - case 7: + case 6: modulexVo.setWorkLevel(value); break; - case 8: + case 7: modulexVo.setWorkStatus(value); break; - case 9: + case 8: modulexVo.setPublishTime(value); break; - case 10: + case 9: modulexVo.setDuration(value); break; - case 11: + case 10: modulexVo.setStartTime(value); break; - case 12: + case 11: modulexVo.setSubmitTime(value); break; - case 13: + case 12: modulexVo.setRealDuration(value); break; - case 14: + case 13: modulexVo.setUserRole(value); break; - case 15: + case 14: modulexVo.setRelatedBean(value); break; - case 16: + case 15: modulexVo.setStatus(value); break; - case 17: + case 16: modulexVo.setVerisonStatus(value); break; - case 18: + case 17: modulexVo.setVerison(value); break; default: @@ -660,14 +663,14 @@ public class ModulexServiceImpl extends ServiceImpl impl webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,英文名称不能为空"); }modulex.setModuleEnName(moduleEnName); - String moduleCode = modulexTemplate.getModuleCode(); - if(moduleCode==null||moduleCode.length()>30){ - message.put("isError", "true"); - message.put("status","导入失败,第" + (i+4) +"行" +"模块编码不能为空或者模块编码过长"); - message.put("closeable","true"); - webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("导入失败,模块编码不能为空或者模块编码过长"); - } +// String moduleCode = modulexTemplate.getModuleCode(); +// if(moduleCode==null||moduleCode.length()>30){ +// message.put("isError", "true"); +// message.put("status","导入失败,第" + (i+4) +"行" +"模块编码不能为空或者模块编码过长"); +// message.put("closeable","true"); +// webSocketUtils.sendMessage(loginUser.getId(), message); +// return Result.error("导入失败,模块编码不能为空或者模块编码过长"); +// } String modulecode = null; LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(Projectx::getProjectName,projectId); @@ -676,20 +679,20 @@ public class ModulexServiceImpl extends ServiceImpl impl String projectCode = projectx.getProjectCode(); if(projectCode==null){ message.put("isError", "true"); - message.put("status","导入失败,第" + (i+4) +"行" +"项目编码不存在,请重新填写"); + message.put("status","导入失败,第" + (i+4) +"行" +"模块对应的项目编码不存在,请完善对应项目里的项目编码后,重新导入"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("项目编码不存在,请重新填写"); + return Result.error("导入失败,模块对应的项目编码不存在,请完善对应项目里的项目编码后,重新导入"); } modulecode = projectCode + firstChar; - if(!modulecode.equals(moduleCode)){ - message.put("isError", "true"); - message.put("status","导入失败,第" + (i+4) +"行" +"模块编码不规范,导入失败"); - message.put("closeable","true"); - webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("模块编码不规范,导入失败"); - } - modulex.setModuleCode(moduleCode); +// if(!modulecode.equals(moduleCode)){ +// message.put("isError", "true"); +// message.put("status","导入失败,第" + (i+4) +"行" +"模块编码不规范,导入失败"); +// message.put("closeable","true"); +// webSocketUtils.sendMessage(loginUser.getId(), message); +// return Result.error("模块编码不规范,导入失败"); +// } + modulex.setModuleCode(modulecode); String pmDescribe = modulexTemplate.getPmDescribe(); if(StringUtils.isBlank(pmDescribe)){ modulex.setPmDescribe(null); @@ -829,6 +832,13 @@ public class ModulexServiceImpl extends ServiceImpl impl webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,任务时长不规范"); } + if(parseDouble<0){ + message.put("isError", "true"); + message.put("status","导入失败,第" + (i+4) +"行" +"任务时长不规范"); + message.put("closeable","true"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("导入失败,任务时长不规范"); + } modulex.setDuration(parseDouble); } String startTime = modulexTemplate.getStartTime(); @@ -865,11 +875,7 @@ public class ModulexServiceImpl extends ServiceImpl impl } String realDuration = modulexTemplate.getRealDuration(); if(StringUtils.isBlank(realDuration)){ - message.put("isError", "true"); - message.put("status","导入失败,第" + (i+4) +"行" +"实际时长不能为空"); - message.put("closeable","true"); - webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("导入失败,实际时长不能为空"); + modulex.setRealDuration(null); }else { double parseDouble = 0; try { @@ -883,10 +889,10 @@ public class ModulexServiceImpl extends ServiceImpl impl } if(parseDouble<0.1){ message.put("isError", "true"); - message.put("status","导入失败,第" + (i+4) +"行" +"最小时间0.1小时"); + message.put("status","导入失败,第" + (i+4) +"行" +"实际时长最小时间0.1小时"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("导入失败,最小时间0.1小时"); + return Result.error("导入失败,实际时长最小时间0.1小时"); } modulex.setRealDuration(parseDouble); } @@ -992,6 +998,13 @@ public class ModulexServiceImpl extends ServiceImpl impl webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,版本号不能为空"); } + if(parseInt<0){ + message.put("isError", "true"); + message.put("status","导入失败,第" + (i+4) +"行" + "版本号不能规范"); + message.put("closeable","true"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("导入失败,版本号不规范"); + } modulex.setVerison(parseInt); } modulexList.add(modulex); diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java index e4f86c2..aff48e7 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java @@ -29,6 +29,8 @@ import org.jeecg.modules.fieldx.entity.Fieldx; 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.projectx.entity.Projectx; +import org.jeecg.modules.projectx.service.IProjectxService; import org.jeecg.modules.tablex.entity.Tablex; import org.jeecg.modules.tablex.service.ITablexService; @@ -78,6 +80,10 @@ public class TablexController extends JeecgController { @Autowired private IModulexService modulexService; + + @Autowired + private IProjectxService projectxService; + @Autowired private IFieldxService fieldxService; @@ -337,7 +343,7 @@ public class TablexController extends JeecgController { message.put("status", "数据预读入"); webSocketUtils.sendMessage(loginUser.getId(), message); - Iterator iterator = list.iterator(); + for (TablexVo tablexVo : list) { //判断当前存入条是否为空值 if (StringUtils.isBlank(tablexVo.getModuleId()) && @@ -376,18 +382,49 @@ public class TablexController extends JeecgController { List tablexList = new ArrayList<>(); for (int i = 0; i < voList.size(); i++) { - Tablex tablex = new Tablex(); + //判断对应的项目名称 + String projectId = voList.get(i).getProjectId(); + if (projectId == null || projectId.equals("")){ + message.put("isError", "true"); + message.put("status", "导入失败,第" + (i + 1) + "条项目名称填写不能为空"); + message.put("closeable", "true"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("导入失败,第" + (i + 1) + "条项目名称填写不能为空"); + } + LambdaQueryWrapper queryProjectx = new LambdaQueryWrapper<>(); + queryProjectx.eq(Projectx::getId, projectId); + Projectx projectx = projectxService.getOne(queryProjectx); + if (projectx == null) { + message.put("isError", "true"); + message.put("status", "导入失败,第" + (i + 1) + "条项目名称不存在"); + message.put("closeable", "true"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("导入失败,第" + (i + 1) + "条项目名称不存在"); + } + //判断对应模块是否为空,且对应模块是否存在 String moduleId = voList.get(i).getModuleId(); if (moduleId == null || moduleId.equals("")) { message.put("isError", "true"); - message.put("status", "导入失败,对应模块填写不能为空"); + message.put("status", "导入失败,第" + (i + 1) + "条对应模块填写不能为空"); message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("对应模块填写不能为空"); + return Result.error("导入失败,第" + (i + 1) + "条对应模块填写不能为空"); } + LambdaQueryWrapper queryModulex = new LambdaQueryWrapper<>(); + queryModulex.eq(Modulex::getProjectId,projectId); + queryModulex.eq(Modulex::getId, moduleId); + Modulex modulex = modulexService.getOne(queryModulex); + if (modulex == null) { + message.put("isError", "true"); + message.put("status", "导入失败,第" + (i + 1) + "条对应模块不存在"); + message.put("closeable", "true"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("导入失败,第" + (i + 1) + "条对应模块不存在"); + } + String modulexId = modulex.getId(); //判断实体是否已存在 LambdaQueryWrapper query = new LambdaQueryWrapper<>(); @@ -401,18 +438,6 @@ public class TablexController extends JeecgController { return Result.error("导入失败,第" + (i + 1) + "条的实体已存在"); } - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(Modulex::getId, moduleId); - Modulex modulex = modulexService.getOne(queryWrapper); - if (modulex == null) { - message.put("isError", "true"); - message.put("status", "导入失败,对应模块填写错误"); - message.put("closeable", "true"); - webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("对应模块填写错误"); - } - String modulexId = modulex.getId(); - String status = voList.get(i).getStatus(); String verisonStatus = voList.get(i).getVerisonStatus(); diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/vo/TablexVo.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/vo/TablexVo.java index 10f703c..28d5e49 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/vo/TablexVo.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/vo/TablexVo.java @@ -34,6 +34,11 @@ public class TablexVo implements Serializable { @TableId(type = IdType.ASSIGN_ID) @ApiModelProperty(value = "主键") private java.lang.String id; + /**项目名称*/ + @Excel(name = "项目名称", width = 15, dictTable = "projectx", dicText = "project_name", dicCode = "id") + @Dict(dictTable = "projectx", dicText = "project_name", dicCode = "id") + @ApiModelProperty(value = "项目名称") + private java.lang.String projectId; /**对应模块id*/ @Excel(name = "对应模块", width = 15, dictTable = "modulex", dicText = "module_name", dicCode = "id") @Dict(dictTable = "modulex", dicText = "module_name", dicCode = "id")