From 5bea448de0bd33d294a39665f6160ad2214c37bb Mon Sep 17 00:00:00 2001 From: zjh <10930829+zheng-jinhao1209@user.noreply.gitee.com> Date: Mon, 24 Jul 2023 17:12:59 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E8=A7=84=E5=88=99?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/modulex/ModulexList.vue | 36 +++--- .../rulex/controller/RulexController.java | 113 +++++++++++++++--- 2 files changed, 115 insertions(+), 34 deletions(-) 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); //存入集合待存真实表 From 65a5b1723764b80d4a1bc1fb90acce4bb643984b Mon Sep 17 00:00:00 2001 From: zjh <10930829+zheng-jinhao1209@user.noreply.gitee.com> Date: Tue, 25 Jul 2023 21:34:06 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E8=A7=84=E5=88=99?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rulex/controller/RulexController.java | 367 +++++++++++------- .../modules/demo/rulex/entity/RuleVo.java | 11 + 2 files changed, 245 insertions(+), 133 deletions(-) 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 67cc313..6c33279 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 @@ -53,9 +53,12 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.IOException; +import java.math.BigDecimal; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.stream.Collectors; /** @@ -99,6 +102,8 @@ public class RulexController extends JeecgController { @Autowired private ISysUserService iSysUserService; + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + /** * 分页列表查询 * @@ -275,7 +280,6 @@ public class RulexController extends JeecgController { return Result.error("文件格式不正确"); } //校验时间 - final DateValidator validator = new DateValidatorUsingDateFormat("yyyy-MM-dd hh:mm:ss"); ImportParams params = new ImportParams(); params.setTitleRows(2);//表格标题行数,默认0 params.setHeadRows(1);//表头行数,默认1 @@ -345,70 +349,119 @@ public class RulexController extends JeecgController { webSocketUtils.sendMessage(loginUser.getId(), message); rulexList = new ArrayList<>(); + + //判断模块输入是否错误 + List modulexList = iModulexService.list(); for (int i = 0; i < ruleVoList.size(); i++) { Rulex rulex = new Rulex(); RuleVo ruleVo = ruleVoList.get(i); - //对应字段 - String fieldId = ruleVo.getFieldId(); - if(fieldId!=null){ - LambdaQueryWrapper rulexLambdaQueryWrapper = new LambdaQueryWrapper<>(); - rulexLambdaQueryWrapper.eq(Fieldx::getFieldName, fieldId); - Fieldx byId = iFieldxService.getOne(rulexLambdaQueryWrapper); - if (byId == 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) +"条数据,对应字段输入错误,请核对"); + + String pModuleId = ruleVo.getModulePid(); + String moduleId = ruleVo.getModuleId(); + //对应模块 + //判断上级模块是否存在 + int n = 0; + if (pModuleId != null) { + //存在 + String pid = ""; + for (Modulex modulex : modulexList) { + //判断表中是否存在 + if (modulex.getModuleName().equals(pModuleId)) { + + pid = modulex.getId(); + break; + } + n++; + if (n == modulexList.size()) { + message.put("isError", "true"); + message.put("closeable", "true"); + message.put("status", "第" + (i + 1) + "条数据,上级模块输入错误,请核对"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("第" + (i + 1) + "条数据,上级模块输入错误,请核对"); + } + } + //判断上级模块+模块是否存在 + for (Modulex modulex : modulexList) { + if (modulex.getModuleName().equals(moduleId) && modulex.getPid().equals(pid)) { + rulex.setModuleId(modulex.getId()); + break; + } + n++; + if (n == modulexList.size()) { + message.put("isError", "true"); + message.put("closeable", "true"); + message.put("status", "第" + (i + 1) + "条数据,模块输入错误,请核对"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("第" + (i + 1) + "条数据,模块输入错误,请核对"); + } + } + } else { + n = 0; + //判断模块是否存在 + for (Modulex modulex : modulexList) { + if (modulex.getModuleName().equals(moduleId) && modulex.getPid() == null) { + rulex.setModuleId(modulex.getId()); + break; + } + n++; + if (n == modulexList.size()) { + message.put("isError", "true"); + message.put("closeable", "true"); + message.put("status", "第" + (i + 1) + "条数据,模块输入错误,请核对"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("第" + (i + 1) + "条数据,模块输入错误,请核对"); + } } - rulex.setFieldId(byId.getId()); } //对应功能 String functionName = ruleVo.getFunctionId(); LambdaQueryWrapper functionxLambdaQueryWrapper = new LambdaQueryWrapper(); - functionxLambdaQueryWrapper.eq(Functionx::getFunctionName, functionName); - Functionx byId1 = functionxService.getOne(functionxLambdaQueryWrapper); - if (byId1 == null) { + functionxLambdaQueryWrapper.eq(Functionx::getFunctionName, functionName).eq(Functionx::getModuleId, rulex.getModuleId()); + Functionx functionx = functionxService.getOne(functionxLambdaQueryWrapper); + if (functionx == 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) +"条数据,对应功能输入错误,请核对"); - } - rulex.setFunctionId(byId1.getId()); - //对应模块 - String moduleName = ruleVo.getModuleId(); - LambdaQueryWrapper modulexLambdaQueryWrapper = new LambdaQueryWrapper<>(); - modulexLambdaQueryWrapper.eq(Modulex::getModuleName, moduleName); - Modulex byId2 = iModulexService.getOne(modulexLambdaQueryWrapper); - if (byId2 == null) { - - iRuleVoService.remove(null); - 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.setModuleId(byId2.getId()); + rulex.setFunctionId(functionx.getId()); +// //对应实体 String tableId = ruleVo.getTableId(); LambdaQueryWrapper tableLambdaQueryWrapper = new LambdaQueryWrapper<>(); - tableLambdaQueryWrapper.eq(Tablex::getTableName, tableId); - Tablex byId3 = iTablexService.getOne(tableLambdaQueryWrapper); - if (byId3 == null) { + 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) +"条数据,对应实体输入错误,请核对"); + 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.setTableId(tablex.getId()); + + //对应字段 + String fieldId = ruleVo.getFieldId(); + String tableId1 = rulex.getTableId(); + if (fieldId != null) { + LambdaQueryWrapper rulexLambdaQueryWrapper = new LambdaQueryWrapper<>(); + rulexLambdaQueryWrapper.eq(Fieldx::getFieldName, fieldId).eq(Fieldx::getTableId, tableId1); + Fieldx fieldx = iFieldxService.getOne(rulexLambdaQueryWrapper); + if (fieldx == 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) + "条数据,对应字段输入错误,请核对"); + } + rulex.setFieldId(fieldx.getId()); } - rulex.setTableId(byId3.getId()); Double aDouble = null; try { if (aDouble != null) @@ -417,10 +470,10 @@ public class RulexController extends JeecgController { } catch (Exception e) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了 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) + "条数据,任务时长输入错误,请核对"); } Double d; @@ -429,10 +482,10 @@ public class RulexController extends JeecgController { } catch (Exception e) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了 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.setRealDuration(d); Integer integer; @@ -441,16 +494,16 @@ public class RulexController extends JeecgController { } catch (Exception e) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了 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.setWorkLevel(integer); String workStatus = ruleVo.getWorkStatus(); - // LambdaQueryWrapper sysDictItemLambdaQueryWrapper = new LambdaQueryWrapper<>(); - // sysDictItemLambdaQueryWrapper.eq(SysDictItem::getItemText, workStatus).eq(SysDictItem::getDictId, "1645268542514421762"); - // SysDictItem sysDictItem = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper); + // LambdaQueryWrapper sysDictItemLambdaQueryWrapper = new LambdaQueryWrapper<>(); + // sysDictItemLambdaQueryWrapper.eq(SysDictItem::getItemText, workStatus).eq(SysDictItem::getDictId, "1645268542514421762"); + // SysDictItem sysDictItem = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper); if (workStatus.equals("未发布")) rulex.setWorkStatus(0); @@ -467,15 +520,15 @@ public class RulexController extends JeecgController { else { iRuleVoService.remove(null); 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) + "条数据,任务状态输入错误,请核对"); } String status = ruleVo.getStatus(); - // LambdaQueryWrapper sysDictItemLambdaQueryWrapper2 = new LambdaQueryWrapper<>(); - // sysDictItemLambdaQueryWrapper2.eq(SysDictItem::getItemText, status).eq(SysDictItem::getDictId, "1645264493205491713"); - // SysDictItem sysDictItem2 = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper2); + // LambdaQueryWrapper sysDictItemLambdaQueryWrapper2 = new LambdaQueryWrapper<>(); + // sysDictItemLambdaQueryWrapper2.eq(SysDictItem::getItemText, status).eq(SysDictItem::getDictId, "1645264493205491713"); + // SysDictItem sysDictItem2 = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper2); if (status.equals("正常")) rulex.setStatus(1); else if (status.equals("停用")) @@ -485,10 +538,10 @@ public class RulexController extends JeecgController { else { iRuleVoService.remove(null); 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) + "条数据,规则状态输入错误,请核对"); } String verisonStatus = ruleVo.getVerisonStatus(); LambdaQueryWrapper sysDictItemLambdaQueryWrapper3 = new LambdaQueryWrapper<>(); @@ -497,51 +550,53 @@ public class RulexController extends JeecgController { if (sysDictItem3 == null) { iRuleVoService.remove(null); 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.setVerisonStatus(Integer.valueOf(sysDictItem3.getItemValue())); - + Date date; //String转Date - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - - try { - String startTime = ruleVo.getStartTime(); - if (startTime != null) - if (!validator.isValid(startTime)) { - 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) +"条数据,开始时间输入错误"); - } else { - Date date = simpleDateFormat.parse(startTime); - rulex.setStartTime(date); - } - String submitTime = ruleVo.getSubmitTime(); - if (submitTime != null) - if (!validator.isValid(submitTime)) { - 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) +"条数据,提交时间输入错误"); - } else { - Date date1 = simpleDateFormat.parse(submitTime); - rulex.setSubmitTime(date1); - } - } catch (ParseException e) { - e.printStackTrace(); + String startTime = ruleVo.getStartTime(); + if (!StringUtils.isBlank(startTime)) { + String time = getTime(startTime); + + try { + date = simpleDateFormat.parse(time); + rulex.setStartTime(date); + } catch (ParseException 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.setRuleNo(ruleVo.getRuleNo()); + String submitTime = ruleVo.getSubmitTime(); + if (!StringUtils.isBlank(submitTime)){ + String submitTimeT = getTime(submitTime); + try { + date = simpleDateFormat.parse(submitTimeT); + rulex.setSubmitTime(date); + } catch (ParseException 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 ruleNo = ruleVo.getRuleNo(); + rulex.setRuleNo(ruleNo); //规则编码 String ruleCode = ruleVo.getRuleCode(); - String functionCode1 = byId1.getFunctionCode(); + String functionCode1 = functionx.getFunctionCode(); if (ruleCode == null) { message.put("isError", "true"); message.put("closeable", "true"); @@ -550,7 +605,7 @@ public class RulexController extends JeecgController { return Result.error("第" + (i + 1) + "条数据,规则编码错误,请核对"); } //截取到功能编码校验(去除后三位) - if (!ruleCode.substring(0,ruleCode.length() - 3).equals(functionCode1)){ + if (!ruleCode.substring(0, ruleCode.length() - 3).equals(functionCode1)) { message.put("isError", "true"); message.put("closeable", "true"); message.put("status", "第" + (i + 1) + "条数据,规则编码错误,请核对"); @@ -559,10 +614,10 @@ public class RulexController extends JeecgController { } //后三位 - String substring = ruleCode.substring(ruleCode.length()-3); + String substring = ruleCode.substring(ruleCode.length() - 3); try { Integer integer1 = Integer.valueOf(substring); - if (integer1<0){ + if (integer1 < 0) { message.put("isError", "true"); message.put("closeable", "true"); message.put("status", "第" + (i + 1) + "条数据,规则编码错误,请核对"); @@ -587,58 +642,58 @@ public class RulexController extends JeecgController { rulex.setDiagrams(diagrams); //版本号 String verison = ruleVo.getVerison(); - if (ruleVo.getVerison()==null||verison.length() >=5){ + if (ruleVo.getVerison() == null || verison.length() >= 5) { message.put("isError", "true"); message.put("closeable", "true"); message.put("status", "第" + (i + 1) + "条数据,版本号错误,请核对"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("第" + (i + 1) + "条数据,版本号错误,请核对"); } - 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) + "条数据,版本号输入错误,请核对"); - } + 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){ + if (managerUsers != null) { LambdaQueryWrapper sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); String[] split = managerUsers.split(","); - sysUserLambdaQueryWrapper.in(SysUser::getUsername,split); + sysUserLambdaQueryWrapper.in(SysUser::getUsername, split); List iSysUserServiceOne = iSysUserService.list(sysUserLambdaQueryWrapper); - if(iSysUserServiceOne==null){ + if (iSysUserServiceOne == null) { message.put("isError", "true"); - message.put("status","导入失败,责任人信息查询不到"); - message.put("closeable","true"); + message.put("status", "导入失败,责任人信息查询不到"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,责任人信息查询不到"); } - if (iSysUserServiceOne.size()>1) { + 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"); + 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){ + } else if (iSysUserServiceOne.size() == 1) { String id = iSysUserServiceOne.get(0).getId(); rulex.setManagerUsers(id); } @@ -698,5 +753,51 @@ public class RulexController extends JeecgController { } return null; } + /** + * 将日期数字转为时间格式 + * daysDuration = 44745 + * + * @param daysDuration + * @return + */ + public String getTime(String daysDuration) { + //如果不是数字 + if(!isNumeric(daysDuration)){ + return daysDuration; + } + //如果是数字 + BigDecimal bd = new BigDecimal(daysDuration); + int days = bd.intValue();//天数 + int mills = (int) Math.round(bd.subtract(new BigDecimal(days)).doubleValue() * 24 * 3600); + + //获取时间 + Calendar c = Calendar.getInstance(); + c.set(1900, 0, 1); + c.add(Calendar.DATE, days); + int hour = mills / 3600; + int minute = (mills - hour * 3600) / 60; + int second = mills - hour * 3600 - minute * 60; + c.set(Calendar.HOUR_OF_DAY, hour); + c.set(Calendar.MINUTE, minute); + c.set(Calendar.SECOND, second); + + return simpleDateFormat.format(c.getTime()); + } + + /** + * 校验是否数据含小数点 + * + * @param str + * @return + */ + private static boolean isNumeric(String str){ + Pattern pattern = Pattern.compile("[0-9]+\\.*[0-9]*"); + Matcher isNum = pattern.matcher(str); + if(!isNum.matches()){ + return false; + } + return true; + } + } 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 a72aed4..853fd93 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 @@ -1,7 +1,10 @@ package org.jeecg.modules.demo.rulex.entity; import java.io.Serializable; +import java.util.Date; + 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; @@ -59,6 +62,14 @@ public class RuleVo implements Serializable { @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @ApiModelProperty(value = "更新日期") private String updateTime; + + /** + * 对应模块父id + */ + @TableField(exist = false) + @Excel(name = "对应模块父模块", width = 15) + @ApiModelProperty(value = "对应模块") + private java.lang.String modulePid; /** * 对应模块id */ From 1a058fb39c0afeb5ad3b7c412db992fa90d29e44 Mon Sep 17 00:00:00 2001 From: itcast Date: Wed, 26 Jul 2023 10:03:35 +0800 Subject: [PATCH 03/10] Changes --- .../fieldx/controller/FieldxController.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 e8fb418..d7dfab5 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 @@ -8,6 +8,7 @@ import java.util.stream.Collectors; import javax.servlet.http.HttpServletRequest; import com.aliyuncs.utils.StringUtils; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; @@ -436,6 +437,7 @@ public class FieldxController extends JeecgController { if (StringUtils.isEmpty(String.valueOf(cell))) { break; } + ExcelInfo excelInfo = new ExcelInfo(); excelInfo.setcells(cells); Fieldx222 fieldx222 = new Fieldx222(); @@ -455,6 +457,7 @@ public class FieldxController extends JeecgController { fieldx222Service.remove(null); return Result.error("序号为" + (r - 2) + "的中文名称不能为空"); } + fieldx222.setFieldName(excelInfo.getFieldName()); Fieldx222 fieldx2221=fieldx222Service.query().eq("field_name",excelInfo.getFieldName()).one(); if(fieldx2221!=null){ message.put("isError", "true"); @@ -466,6 +469,17 @@ public class FieldxController extends JeecgController { } fieldx222.setFieldName(excelInfo.getFieldName()); + LambdaQueryWrapper queryWrapper=new LambdaQueryWrapper<>(); + queryWrapper.eq(Fieldx::getTableId,fieldx222.getTableId()).eq(Fieldx::getFieldName,fieldx222.getFieldName()); + List list=fieldxService.list(queryWrapper); + if(list!=null&&list.size()!=0){ + message.put("isError", "true"); + message.put("status","序号为" + (r - 2) + "的字段名此表已存在不能重复"); + message.put("closeable","true"); + webSocketUtils.sendMessage(loginUser.getId(), message); + fieldx222Service.remove(null); + return Result.error("序号为" + (r - 2) + "的字段名此表已存在不能重复"); + } if (StringUtil.isBlank(excelInfo.getFieldEnName())) { message.put("isError", "true"); message.put("status","序号为" + (r - 2) + "的”英文名称”不能为空"); From 217b41a9b73b2ed9519d39ab44948cd215d228b5 Mon Sep 17 00:00:00 2001 From: lijinyu <3023846734@qq.com> Date: Wed, 26 Jul 2023 10:28:31 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E6=A8=A1=E5=9D=97=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=8A=9F=E8=83=BD=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modulex/service/impl/ModulexServiceImpl.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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 a62b731..a99f21c 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 @@ -390,6 +390,9 @@ public class ModulexServiceImpl extends ServiceImpl impl if (j == 2) { for (int k = 0; k < physicalNumberOfCells; k++) { Cell cell = row.getCell(k); + if(cell==null){ + propertyNames.add(null); + } String name = cell.getStringCellValue(); propertyNames.add(name); } @@ -707,8 +710,14 @@ public class ModulexServiceImpl extends ServiceImpl impl webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,责任人信息查询不到"); } - String strip = org.apache.commons.lang.StringUtils.strip(list.toString(), "[]"); - modulex.setManagerUsers(strip); +// String strip = org.apache.commons.lang.StringUtils.strip(list.toString(), "[]"); + String s = ""; + for (int j = 0; j < list.size(); j++) { + s = s + list.get(j); + if (j < list.size() - 1) + s = s + ","; + } + modulex.setManagerUsers(s); } } String workLevel = modulexTemplate.getWorkLevel(); From e9cc7c6ac8d03fcc96d3e7c36b915997d35ff4c0 Mon Sep 17 00:00:00 2001 From: itcast Date: Wed, 26 Jul 2023 10:33:54 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ant-design-vue-jeecg/src/views/modulex/ModulexList.vue | 2 +- .../src/main/java/org/jeecg/modules/fieldx/entity/Fieldx.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue b/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue index 1642c37..e1c9c7d 100644 --- a/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue +++ b/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue @@ -575,7 +575,7 @@ export default { '表名(非空): 请填写实体表的名称', '中文名称(非空): 请填写字段名称', '英文名称(非空): 请填写字段名称的英语名称', - '数据类型(非空): 请填写数据类型,{char,varchar,int}这些等等,具体可以查看数据字典', + '数据类型(非空): 请填写数据类型,大写{CHAR,VARCHAR,INT}这些等等,具体可以查看数据字典', '数据长度: 请填写该字段对应的长度', '浮点精度: 请填写浮点精度', '显示形式: 请填写该字段显示的形式', diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/entity/Fieldx.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/entity/Fieldx.java index d511012..98a281e 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/entity/Fieldx.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/entity/Fieldx.java @@ -41,7 +41,7 @@ public class Fieldx implements Serializable { @Dict(dictTable="tablex",dicText = "table_name",dicCode = "id") private java.lang.String tableId; /**中文名称*/ - @Excel(name = "中文名称", width = 15) + @Excel(name = "中文名称", width = 15,dicCode = "field_name") @ApiModelProperty(value = "中文名称") private java.lang.String fieldName; /**英文名称*/ From 67e31657d244d1fe86d7afe7c27f5f7282a172b6 Mon Sep 17 00:00:00 2001 From: lijinyu <3023846734@qq.com> Date: Wed, 26 Jul 2023 10:49:20 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E6=A8=A1=E5=9D=97=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=8A=9F=E8=83=BD=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/modulex/service/impl/ModulexServiceImpl.java | 7 +++++++ 1 file changed, 7 insertions(+) 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 a99f21c..0245d2a 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 @@ -428,6 +428,13 @@ public class ModulexServiceImpl extends ServiceImpl impl int annual = 0; for (int k = 0; k < physicalNumberOfCells; k++) { Cell cell = row.getCell(k); + if(cell==null){ + message.put("isError", "true"); + message.put("status","表格中有空白单元格,"+"请重新导入"); + message.put("closeable","true"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("数据匹配读取失败,"+"请重新导入"); + } String value = cell.getStringCellValue(); switch (k){ case 0: From 4fb7fe4a8cab4e5cf0ada02ae03f7cb8334d871e Mon Sep 17 00:00:00 2001 From: mqh <1571896045@qq.com> Date: Wed, 26 Jul 2023 11:09:24 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E5=AE=9E=E4=BD=93=E8=A1=A8=E7=BB=93=E6=9E=84=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tablex/controller/TablexController.java | 151 +++++++++--------- 1 file changed, 76 insertions(+), 75 deletions(-) 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 7f15e51..ba44718 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 @@ -281,7 +281,7 @@ public class TablexController extends JeecgController { * 通过excel导入数据 * * @param file - * @return + * @return */ @RequestMapping(value = "/importExcel", method = RequestMethod.POST) public Result importExcel(MultipartFile file) { @@ -293,7 +293,7 @@ public class TablexController 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); try { @@ -303,8 +303,8 @@ public class TablexController extends JeecgController { (!originalFilename.endsWith("xls") && !originalFilename.endsWith("xlsx"))) { message.put("isError", "true"); - message.put("status","文件格式不正确"); - message.put("closeable","true"); + message.put("status", "文件格式不正确"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("文件格式不正确"); } @@ -320,16 +320,16 @@ public class TablexController extends JeecgController { list = ExcelImportUtil.importExcel(file.getInputStream(), TablexVo.class, params); } catch (Exception e) { message.put("isError", "true"); - message.put("status","文件读取失败"); - message.put("closeable","true"); + message.put("status", "文件读取失败"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("文件读取失败"); } //判断文件中是否存在数据 if (list == null || list.size() == 0) { message.put("isError", "true"); - message.put("status","Excel数据为空"); - message.put("closeable","true"); + message.put("status", "Excel数据为空"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("Excel数据为空"); } @@ -363,8 +363,8 @@ public class TablexController extends JeecgController { if (voList.size() == 0) { message.put("isError", "true"); - message.put("status","导入失败,数据为空"); - message.put("closeable","true"); + message.put("status", "导入失败,数据为空"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,数据为空"); } @@ -382,20 +382,20 @@ public class TablexController extends JeecgController { String moduleId = voList.get(i).getModuleId(); if (moduleId == null || moduleId.equals("")) { message.put("isError", "true"); - message.put("status","导入失败,对应模块填写不能为空"); - message.put("closeable","true"); + message.put("status", "导入失败,对应模块填写不能为空"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("对应模块填写不能为空"); } //判断实体是否已存在 LambdaQueryWrapper query = new LambdaQueryWrapper<>(); - query.eq(Tablex::getModuleId,voList.get(i).getModuleId()); + query.eq(Tablex::getModuleId, voList.get(i).getModuleId()); Tablex tablex1 = tablexService.getOne(query); - if (tablex1 != null){ + if (tablex1 != null) { message.put("isError", "true"); - message.put("status","导入失败,第" + (i + 1) + "条的实体已存在"); - message.put("closeable","true"); + message.put("status", "导入失败,第" + (i + 1) + "条的实体已存在"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,第" + (i + 1) + "条的实体已存在"); } @@ -405,8 +405,8 @@ public class TablexController extends JeecgController { Modulex modulex = modulexService.getOne(queryWrapper); if (modulex == null) { message.put("isError", "true"); - message.put("status","导入失败,对应模块填写错误"); - message.put("closeable","true"); + message.put("status", "导入失败,对应模块填写错误"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("对应模块填写错误"); } @@ -421,19 +421,19 @@ public class TablexController extends JeecgController { //int verisonStatusInt = verisonStatus.equals("当前") ? 1 : verisonStatus.equals("历史") ? 0 : 3; //判断版本号 - if(voList.get(i).getVerison() == null || voList.get(i).getVerison().equals("")){ + if (voList.get(i).getVerison() == null || voList.get(i).getVerison().equals("")) { message.put("isError", "true"); - message.put("status","导入失败,第" + (i + 1) + "条的版本号填写不能为空!"); - message.put("closeable","true"); + message.put("status", "导入失败,第" + (i + 1) + "条的版本号填写不能为空!"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,第" + (i + 1) + "条的版本号填写不能为空!"); } //判断版本号是否为正整数且长度不能大于5 - if (!voList.get(i).getVerison().matches("^[0-9]*[1-9][0-9]*$") || voList.get(i).getVerison().length() > 5){ + if (!voList.get(i).getVerison().matches("^[0-9]*[1-9][0-9]*$") || voList.get(i).getVerison().length() > 5) { message.put("isError", "true"); - message.put("status","导入失败,第" + (i + 1) + "条的版本状态填写错误!"); - message.put("closeable","true"); + message.put("status", "导入失败,第" + (i + 1) + "条的版本状态填写错误!"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,第" + (i + 1) + "条的版本状态填写错误!"); } @@ -449,52 +449,53 @@ public class TablexController extends JeecgController { //判断版本状态 if (verisonStatus.equals("1") || verisonStatus.equals("0")) { - message.put("status", "数据校验成功"); - webSocketUtils.sendMessage(loginUser.getId(), message); + message.put("status", "数据校验成功"); + webSocketUtils.sendMessage(loginUser.getId(), message); - tablex.setModuleId(voList.get(i).getModuleId()); - tablex.setTableName(voList.get(i).getTableName()); - tablex.setTableEnName(voList.get(i).getTableEnName()); - tablex.setTableStructure(voList.get(i).getTableStructure()); - tablex.setStructuralDiagram(voList.get(i).getStructuralDiagram()); - tablex.setCreateBy(loginUser.getRealname()); - tablex.setStatus(Integer.valueOf(voList.get(i).getStatus())); - tablex.setVerisonStatus(Integer.valueOf(voList.get(i).getVerisonStatus())); + tablex.setModuleId(voList.get(i).getModuleId()); + tablex.setTableName(voList.get(i).getTableName()); + tablex.setTableEnName(voList.get(i).getTableEnName()); + tablex.setTableStructure(voList.get(i).getTableStructure()); + tablex.setStructuralDiagram(voList.get(i).getStructuralDiagram()); + tablex.setCreateBy(loginUser.getRealname()); + tablex.setStatus(Integer.valueOf(voList.get(i).getStatus())); + tablex.setVerisonStatus(Integer.valueOf(voList.get(i).getVerisonStatus())); + tablex.setTableStructure("CREATE TABLE '" + voList.get(i).getTableEnName() + "' ();"); - tablexList.add(tablex); + tablexList.add(tablex); } else { message.put("isError", "true"); - message.put("status","导入失败,第" + (i + 1) + "条的版本状态填写错误!"); - message.put("closeable","true"); + message.put("status", "导入失败,第" + (i + 1) + "条的版本状态填写错误!"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,第" + (i + 1) + "条的版本状态填写错误!"); } } else { message.put("isError", "true"); - message.put("status","导入失败,第" + (i + 1) + "条的实体状态填写错误!"); - message.put("closeable","true"); + message.put("status", "导入失败,第" + (i + 1) + "条的实体状态填写错误!"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,第" + (i + 1) + "条的实体状态填写错误!"); } } else { message.put("isError", "true"); - message.put("status","导入失败,第" + (i + 1) + "条的英文名称填写错误!"); - message.put("closeable","true"); + message.put("status", "导入失败,第" + (i + 1) + "条的英文名称填写错误!"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,第" + (i + 1) + "条的英文名称填写错误!"); } } else { message.put("isError", "true"); - message.put("status","导入失败,第" + (i + 1) + "条的中文名称填写错误!"); - message.put("closeable","true"); + message.put("status", "导入失败,第" + (i + 1) + "条的中文名称填写错误!"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,第" + (i + 1) + "条的中文名称填写错误!"); } } else { message.put("isError", "true"); - message.put("status","导入失败,第" + (i + 1) + "条的对应模块填写错误!"); - message.put("closeable","true"); + message.put("status", "导入失败,第" + (i + 1) + "条的对应模块填写错误!"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,第" + (i + 1) + "条的对应模块填写错误!"); } @@ -506,44 +507,44 @@ public class TablexController extends JeecgController { tablexService.saveSingleBatch(tablexList, loginUser, message); message.put("status", "上传成功"); - message.put("closeable","true"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); } catch (Exception e) { message.put("isError", "true"); - message.put("status","文件导入失败"); - message.put("closeable","true"); + message.put("status", "文件导入失败"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); - log.error(e.getMessage(),e); + log.error(e.getMessage(), e); return Result.error("文件导入失败"); } return Result.ok("文件导入成功!"); } - //导出实体标准模板 - @RequestMapping(value = "/templateExcel") - public ModelAndView wbsExcelTemplate(HttpServletRequest request, HttpServletResponse response) { - Map map = new HashMap(); - //设置导出文件名称 - SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); - Date date = new Date(System.currentTimeMillis()); - String currTime = formatter.format(date); - String fileName = currTime + "-" + "模板.xlsx"; - try { - String url = getClass().getClassLoader().getResource("static").getPath(); - // 模板存放地址 这里写的地址根本拿不到 在其他人的电脑上 - String templateUrl = wordPath + File.separator + "实体表模板.xls"; - TemplateExportParams params = new TemplateExportParams( - templateUrl); - ModelAndView mv = new ModelAndView(new JeecgTemplateExcelView()); - mv.addObject(TemplateExcelConstants.FILE_NAME, fileName); - mv.addObject(TemplateExcelConstants.PARAMS, params); - // 添加模板参数 - mv.addObject(TemplateExcelConstants.MAP_DATA, map); //data - return mv; - } catch (Exception e) { - log.error("下载模板异常--》{}", e); - } - return null; - } + //导出实体标准模板 + @RequestMapping(value = "/templateExcel") + public ModelAndView wbsExcelTemplate(HttpServletRequest request, HttpServletResponse response) { + Map map = new HashMap(); + //设置导出文件名称 + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); + Date date = new Date(System.currentTimeMillis()); + String currTime = formatter.format(date); + String fileName = currTime + "-" + "模板.xlsx"; + try { + String url = getClass().getClassLoader().getResource("static").getPath(); + // 模板存放地址 这里写的地址根本拿不到 在其他人的电脑上 + String templateUrl = wordPath + File.separator + "实体表模板.xls"; + TemplateExportParams params = new TemplateExportParams( + templateUrl); + ModelAndView mv = new ModelAndView(new JeecgTemplateExcelView()); + mv.addObject(TemplateExcelConstants.FILE_NAME, fileName); + mv.addObject(TemplateExcelConstants.PARAMS, params); + // 添加模板参数 + mv.addObject(TemplateExcelConstants.MAP_DATA, map); //data + return mv; + } catch (Exception e) { + log.error("下载模板异常--》{}", e); + } + return null; + } } From 89628bd829fd8d3538538b87285d79c060b70262 Mon Sep 17 00:00:00 2001 From: zjh <10930829+zheng-jinhao1209@user.noreply.gitee.com> Date: Wed, 26 Jul 2023 11:13:53 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E8=A7=84=E5=88=99?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rulex/controller/RulexController.java | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) 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 6c33279..88af61d 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 @@ -303,25 +303,25 @@ public class RulexController extends JeecgController { //必要字段判断空值 for (int i = 0; i < list.size(); i++) { if ( - list.get(i).getRuleNo() == null || - list.get(i).getRuleCode() == null || -// list.get(i).getPmDescribe() == null && - list.get(i).getModuleId() == null || - list.get(i).getFunctionId() == null || -// list.get(i).getDiagrams() == null && - list.get(i).getTableId() == null || -// list.get(i).getFieldId() == null || - list.get(i).getManagerUsers() == null || - list.get(i).getWorkLevel() == null || - list.get(i).getWorkStatus() == null || -// list.get(i).getStartTime() == null && -// list.get(i).getManagerUsers() == null && -// list.get(i).getDuration() == null && -// list.get(i).getSubmitTime() == null && - list.get(i).getRealDuration() == null && - list.get(i).getStatus() == null || - list.get(i).getVerisonStatus() == null || - list.get(i).getVerison() == null) { + StringUtils.isBlank(list.get(i).getRuleNo()) || + 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).getDiagrams() == null && + 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).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()) ) { message.put("isError", "true"); message.put("closeable","true"); @@ -361,7 +361,7 @@ public class RulexController extends JeecgController { //对应模块 //判断上级模块是否存在 int n = 0; - if (pModuleId != null) { + if (!StringUtils.isBlank(pModuleId) ) { //存在 String pid = ""; for (Modulex modulex : modulexList) { @@ -448,7 +448,7 @@ public class RulexController extends JeecgController { //对应字段 String fieldId = ruleVo.getFieldId(); String tableId1 = rulex.getTableId(); - if (fieldId != null) { + if (!StringUtils.isBlank(fieldId) ) { LambdaQueryWrapper rulexLambdaQueryWrapper = new LambdaQueryWrapper<>(); rulexLambdaQueryWrapper.eq(Fieldx::getFieldName, fieldId).eq(Fieldx::getTableId, tableId1); Fieldx fieldx = iFieldxService.getOne(rulexLambdaQueryWrapper); From 7e0e5ded4d205bd426968ee31ba33394a2b2b64f Mon Sep 17 00:00:00 2001 From: itcast Date: Wed, 26 Jul 2023 11:31:40 +0800 Subject: [PATCH 09/10] Changes --- .../fieldx/service/impl/FieldxServiceImpl.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/service/impl/FieldxServiceImpl.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/service/impl/FieldxServiceImpl.java index 8f89b33..93a11c1 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/service/impl/FieldxServiceImpl.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/service/impl/FieldxServiceImpl.java @@ -1,10 +1,13 @@ package org.jeecg.modules.fieldx.service.impl; import org.jeecg.common.system.vo.LoginUser; +import org.jeecg.modules.fieldx.controller.FieldxController; import org.jeecg.modules.fieldx.entity.Fieldx; import org.jeecg.modules.fieldx.entity.Fieldx222; import org.jeecg.modules.fieldx.mapper.FieldxMapper; import org.jeecg.modules.fieldx.service.IFieldxService; +import org.jeecg.modules.tablex.entity.Tablex; +import org.jeecg.modules.tablex.service.ITablexService; import org.jeecg.modules.tablex.ws.WebSocketUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -20,10 +23,16 @@ import java.util.Map; * @Date: 2023-04-10 * @Version: V1.0 */ + + @Service public class FieldxServiceImpl extends ServiceImpl implements IFieldxService { @Autowired private WebSocketUtils webSocketUtils; + @Autowired + FieldxController fieldxController; + @Autowired + private ITablexService tablexService; @Override public void saveSingleBatch(List fieldxList, LoginUser loginUser, Map message) { for (int i = 0; i < fieldxList.size(); i++){ @@ -31,6 +40,9 @@ public class FieldxServiceImpl extends ServiceImpl impleme Thread.sleep(500L); message.put("uploaded", String.valueOf(i + 1)); this.save(fieldxList.get(i)); + Tablex tablex = tablexService.getById(fieldxList.get(i).getTableId()); + tablexService.updateVersion(fieldxList.get(i).getTableId(), tablex.getVerison() + 1); + tablexService.updateSql(fieldxList.get(i).getTableId(), fieldxController.createSql(fieldxList.get(i).getTableId())); webSocketUtils.sendMessage(loginUser.getId(), message); } catch (InterruptedException e) { log.error(e.getMessage(), e); From 1bdb937ec2ea44137494cc881f7d6f55014655ee Mon Sep 17 00:00:00 2001 From: lijinyu <3023846734@qq.com> Date: Wed, 26 Jul 2023 11:42:03 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E6=A8=A1=E5=9D=97=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=8A=9F=E8=83=BD=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/modulex/service/impl/ModulexServiceImpl.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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 0245d2a..42ead9e 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 @@ -390,9 +390,6 @@ public class ModulexServiceImpl extends ServiceImpl impl if (j == 2) { for (int k = 0; k < physicalNumberOfCells; k++) { Cell cell = row.getCell(k); - if(cell==null){ - propertyNames.add(null); - } String name = cell.getStringCellValue(); propertyNames.add(name); } @@ -430,7 +427,7 @@ public class ModulexServiceImpl extends ServiceImpl impl Cell cell = row.getCell(k); if(cell==null){ message.put("isError", "true"); - message.put("status","表格中有空白单元格,"+"请重新导入"); + message.put("status","表格中有空白行,"+"请重新导入"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("数据匹配读取失败,"+"请重新导入");