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 04ce932..19d3e33 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 @@ -244,6 +244,8 @@ public class RulexController extends JeecgController { message.put("isVisible", "true"); message.put("uploaded", "0"); message.put("status", "判断文件结构"); + message.put("isError", "false"); + message.put("closeable","false"); webSocketUtils.sendMessage(loginUser.getId(), message); @@ -252,13 +254,20 @@ public class RulexController extends JeecgController { if (StringUtils.isBlank(originalFilename) || (!originalFilename.endsWith("xls") && !originalFilename.endsWith("xlsx"))) { - + message.put("isError", "true"); + message.put("closeable","true"); + message.put("status","文件格式不正确"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("文件格式不正确"); } //校验时间 final DateValidator validator = new DateValidatorUsingDateFormat("yyyy-MM-dd hh:mm:ss"); if (file == null) { + message.put("isError", "true"); + message.put("closeable","true"); + message.put("status","文件上传失败,请重新上传"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("文件上传失败,请重新上传"); } ImportParams params = new ImportParams(); @@ -270,7 +279,10 @@ public class RulexController extends JeecgController { webSocketUtils.sendMessage(loginUser.getId(), message); List list = ExcelImportUtil.importExcel(file.getInputStream(), RuleVo.class, params); 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("文件导入失败:模板中暂无数据"); } int num = 0; @@ -300,7 +312,10 @@ public class RulexController extends JeecgController { } num++; if (num == 0) { - + message.put("isError", "true"); + message.put("closeable","true"); + message.put("status","文件导入失败:导入模板不匹配"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("文件导入失败:导入模板不匹配"); // } else if (num!=list.size()) { // return Result.error("文件导入失败:请检查填写文字"); @@ -313,7 +328,10 @@ public class RulexController extends JeecgController { log.error(msg, e); //if(msg!=null && msg.contains("Duplicate entry")) if (msg != null && msg.indexOf("Duplicate entry") >= 0) { - + message.put("isError", "true"); + message.put("closeable","true"); + message.put("status","文件导入失败:有重复数据"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("文件导入失败:有重复数据!"); } else { @@ -330,7 +348,10 @@ public class RulexController extends JeecgController { List ruleVoList = iRuleVoService.list(); if (ruleVoList.size() <= 0 || ruleVoList == null) { - + message.put("isError", "true"); + message.put("closeable","true"); + message.put("status","文件导入失败,模板不匹配有空值"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("文件导入失败,模板不匹配有空值"); } // 将总的记录数传递给前端 @@ -347,7 +368,10 @@ public class RulexController extends JeecgController { Fieldx byId = iFieldxService.getOne(rulexLambdaQueryWrapper); if (byId == null) { iRuleVoService.remove(null); - + message.put("isError", "true"); + message.put("closeable","true"); + message.put("status","字段输入错误,请核对"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("字段输入错误,请核对"); } rulex.setFieldId(byId.getId()); @@ -358,7 +382,10 @@ public class RulexController extends JeecgController { Functionx byId1 = functionxService.getOne(functionxLambdaQueryWrapper); if (byId1 == null) { iRuleVoService.remove(null); - + message.put("isError", "true"); + message.put("closeable","true"); + message.put("status","功能输入错误,请核对"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("功能输入错误,请核对"); } rulex.setFunctionId(byId1.getId()); @@ -370,7 +397,10 @@ public class RulexController extends JeecgController { if (byId2 == null) { iRuleVoService.remove(null); - + message.put("isError", "true"); + message.put("closeable","true"); + message.put("status","模块输入错误,请核对"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("模块输入错误,请核对"); } rulex.setModuleId(byId2.getId()); @@ -382,7 +412,10 @@ public class RulexController extends JeecgController { if (byId3 == null) { iRuleVoService.remove(null); - + message.put("isError", "true"); + message.put("closeable","true"); + message.put("status","实体输入错误,请核对"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("实体输入错误,请核对"); } rulex.setTableId(byId3.getId()); @@ -393,7 +426,10 @@ public class RulexController extends JeecgController { rulex.setDuration(aDouble); } catch (Exception e) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了 - + message.put("isError", "true"); + message.put("closeable","true"); + message.put("status","任务时长输入错误,请核对"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("任务时长输入错误,请核对"); } @@ -402,7 +438,10 @@ public class RulexController extends JeecgController { d = Double.valueOf(ruleVo.getRealDuration()); } catch (Exception e) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了 - + message.put("isError", "true"); + message.put("closeable","true"); + message.put("status","实际时长输入错误,请核对"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("实际时长输入错误,请核对"); } rulex.setRealDuration(d); @@ -411,7 +450,10 @@ public class RulexController extends JeecgController { integer = Integer.valueOf(ruleVo.getWorkLevel()); } catch (Exception e) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了 - + message.put("isError", "true"); + message.put("closeable","true"); + message.put("status","任务等级输入错误,请核对"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("任务等级输入错误,请核对"); } rulex.setWorkLevel(integer); @@ -434,7 +476,10 @@ public class RulexController extends JeecgController { rulex.setWorkStatus(9); else { iRuleVoService.remove(null); - + message.put("isError", "true"); + message.put("closeable","true"); + message.put("status","任务状态输入错误,请核对"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("任务状态输入错误,请核对"); } String status = ruleVo.getStatus(); @@ -449,7 +494,10 @@ public class RulexController extends JeecgController { rulex.setStatus(9); else { iRuleVoService.remove(null); - + message.put("isError", "true"); + message.put("closeable","true"); + message.put("status","规则状态输入错误,请核对"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("规则状态输入错误,请核对"); } String verisonStatus = ruleVo.getVerisonStatus(); @@ -458,7 +506,10 @@ public class RulexController extends JeecgController { SysDictItem sysDictItem3 = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper3); if (sysDictItem3 == null) { iRuleVoService.remove(null); - + message.put("isError", "true"); + message.put("closeable","true"); + message.put("status","版本状态输入错误,请核对"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("版本状态输入错误,请核对"); } @@ -472,7 +523,10 @@ public class RulexController extends JeecgController { if (startTime != null) if (!validator.isValid(startTime)) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了 - + message.put("isError", "true"); + message.put("closeable","true"); + message.put("status","开始时间输入错误"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("开始时间输入错误"); } else { Date date = simpleDateFormat.parse(startTime); @@ -482,7 +536,10 @@ public class RulexController extends JeecgController { if (submitTime != null) if (!validator.isValid(submitTime)) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了 - + message.put("isError", "true"); + message.put("closeable","true"); + message.put("status","提交时间输入错误"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("提交时间输入错误"); } else { Date date1 = simpleDateFormat.parse(submitTime); @@ -497,7 +554,10 @@ public class RulexController extends JeecgController { List list = rulexMapper.checkRuleNo(byId1.getId()); if (list.contains(ruleNo)) { iRuleVoService.remove(null); - + message.put("isError", "true"); + message.put("closeable","true"); + message.put("status","规则序号已存在"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("规则序号已存在"); } rulex.setRuleNo(ruleNo); @@ -522,7 +582,10 @@ public class RulexController extends JeecgController { integer1 = Integer.valueOf(ruleVo.getVerison()); } catch (Exception e) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了 - + message.put("isError", "true"); + message.put("closeable","true"); + message.put("status","版本号输入错误,请核对"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("版本号输入错误,请核对"); } rulex.setVerison(String.valueOf(integer1)); @@ -534,11 +597,11 @@ public class RulexController extends JeecgController { webSocketUtils.sendMessage(loginUser.getId(), message); //存入真实表 rulexService.saveRule(rulex, loginUser, message, i + 1); - message.put("status", "导入成功"); - webSocketUtils.sendMessage(loginUser.getId(), message); iRuleVoService.remove(null); } - + message.put("status", "导入成功"); + message.put("closeable","true"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.ok("文件导入成功!"); } diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/mapper/RulexMapper.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/mapper/RulexMapper.java index 7f8e5e6..f06c10c 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/mapper/RulexMapper.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/mapper/RulexMapper.java @@ -2,11 +2,13 @@ package org.jeecg.modules.demo.rulex.mapper; import java.util.List; +import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; import org.jeecg.modules.demo.rulex.entity.Rulex; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.springframework.stereotype.Repository; /** * @Description: 规则管理 @@ -14,6 +16,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; * @Date: 2023-04-10 * @Version: V1.0 */ +@Repository public interface RulexMapper extends BaseMapper { @Select("select rule_no from rulex where function_id=#{id} order by rule_no desc limit 0,1") diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/service/impl/RulexServiceImpl.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/service/impl/RulexServiceImpl.java index b68794e..07a2259 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/service/impl/RulexServiceImpl.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/service/impl/RulexServiceImpl.java @@ -88,9 +88,10 @@ public class RulexServiceImpl extends ServiceImpl implements webSocketUtils.sendMessage(loginUser.getId(), message); } catch (InterruptedException e) { - message.put("isVisible", "false"); + message.put("isError", "true"); + message.put("closeable","true"); + message.put("status","导入失败"); webSocketUtils.sendMessage(loginUser.getId(), message); - log.error(e.getMessage(), e); }