Compare commits

..

No commits in common. '87ac2235563dcd68b8f04a8ccca081a3b67ff456' and 'd948e6008ff7bd443ffe1f6e6b2f905ea5acebda' have entirely different histories.

  1. 22
      ant-design-vue-jeecg/src/views/modulex/ModulexList.vue
  2. 159
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/controller/RulexController.java
  3. 3
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/service/IRulexService.java
  4. 27
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/service/impl/RulexServiceImpl.java

@ -77,28 +77,8 @@
<a-button type="primary" icon="import">导入功能</a-button> <a-button type="primary" icon="import">导入功能</a-button>
</a-upload> </a-upload>
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="ruleImportExcelUrl" @change="handleImportExcel"> <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="ruleImportExcelUrl" @change="handleImportExcel">
<a-button type="primary" icon="import">导入规则</a-button>
<a-button type="primary" icon="import" @click="showProcess">导入规则</a-button>
<a-modal
title="正在上传..."
:visible="ModalData.isVisible==='true'"
:confirm-loading="false"
:mask="true"
:maskClosable="false"
:keyboard="false"
:closable="false"
:footer="false"
>
<p>当前状态{{ ModalData.status }}</p>
<p>总记录数{{ ModalData.records }}</p>
<p>已上传{{ ModalData.uploaded }}</p>
<a-progress
:percent="parseInt(String(ModalData.uploaded/ModalData.records*100))"
title="上传进度:"
status="active" :steps="ModalData.records"/>
</a-modal>
</a-upload> </a-upload>
<a-upload name="file" :showUploadList="false" :multiple="false" <a-upload name="file" :showUploadList="false" :multiple="false"
:headers="tokenHeader" :action="tablexImportExcelUrl" @change="handleImportExcel"> :headers="tokenHeader" :action="tablexImportExcelUrl" @change="handleImportExcel">
<a-button type="primary" icon="import" @click="showProcess">导入实体</a-button> <a-button type="primary" icon="import" @click="showProcess">导入实体</a-button>

@ -1,18 +1,17 @@
package org.jeecg.modules.demo.rulex.controller; package org.jeecg.modules.demo.rulex.controller;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result; import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.demo.functionx.entity.Functionx; import org.jeecg.modules.demo.functionx.entity.Functionx;
import org.jeecg.modules.demo.functionx.mapper.FunctionxMapper; import org.jeecg.modules.demo.functionx.mapper.FunctionxMapper;
import org.jeecg.modules.demo.functionx.service.IFunctionxService; import org.jeecg.modules.demo.functionx.service.IFunctionxService;
@ -21,31 +20,37 @@ import org.jeecg.modules.demo.rulex.entity.Rulex;
import org.jeecg.modules.demo.rulex.mapper.RulexMapper; import org.jeecg.modules.demo.rulex.mapper.RulexMapper;
import org.jeecg.modules.demo.rulex.service.IRuleVoService; import org.jeecg.modules.demo.rulex.service.IRuleVoService;
import org.jeecg.modules.demo.rulex.service.IRulexService; import org.jeecg.modules.demo.rulex.service.IRulexService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.demo.rulex.util.DateValidator; import org.jeecg.modules.demo.rulex.util.DateValidator;
import org.jeecg.modules.demo.rulex.util.DateValidatorUsingDateFormat; import org.jeecg.modules.demo.rulex.util.DateValidatorUsingDateFormat;
import org.jeecg.modules.fieldx.entity.Fieldx; import org.jeecg.modules.fieldx.entity.Fieldx;
import org.jeecg.modules.fieldx.service.IFieldxService; import org.jeecg.modules.fieldx.service.IFieldxService;
import org.jeecg.modules.modulex.entity.Modulex; import org.jeecg.modules.modulex.entity.Modulex;
import org.jeecg.modules.modulex.service.IModulexService; import org.jeecg.modules.modulex.service.IModulexService;
import org.jeecg.modules.system.entity.SysDict;
import org.jeecg.modules.system.entity.SysDictItem; import org.jeecg.modules.system.entity.SysDictItem;
import org.jeecg.modules.system.mapper.SysDictItemMapper; import org.jeecg.modules.system.mapper.SysDictItemMapper;
import org.jeecg.modules.tablex.entity.Tablex; import org.jeecg.modules.tablex.entity.Tablex;
import org.jeecg.modules.tablex.service.ITablexService; import org.jeecg.modules.tablex.service.ITablexService;
import org.jeecg.modules.tablex.ws.WebSocketUtils;
import org.jeecgframework.poi.excel.ExcelImportUtil; import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.entity.ImportParams; import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import io.swagger.annotations.Api;
import javax.servlet.http.HttpServletRequest; import io.swagger.annotations.ApiOperation;
import java.io.IOException; import org.jeecg.common.aspect.annotation.AutoLog;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/** /**
* @Description: 规则管理 * @Description: 规则管理
@ -58,6 +63,10 @@ import java.util.*;
@RequestMapping("/rulex/rulex") @RequestMapping("/rulex/rulex")
@Slf4j @Slf4j
public class RulexController extends JeecgController<Rulex, IRulexService> { public class RulexController extends JeecgController<Rulex, IRulexService> {
@Autowired
private IRulexService rulexService;
@Autowired
private IRuleVoService iRuleVoService;
@Autowired @Autowired
FunctionxMapper functionxMapper; FunctionxMapper functionxMapper;
@Autowired @Autowired
@ -70,17 +79,12 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
ITablexService iTablexService; ITablexService iTablexService;
@Autowired @Autowired
IModulexService iModulexService; IModulexService iModulexService;
@Autowired @Autowired
RulexController rulexController; RulexController rulexController;
@Autowired
private IRulexService rulexService;
@Autowired
private IRuleVoService iRuleVoService;
@Autowired
private SysDictItemMapper sysDictItemMapper;
@Autowired @Autowired
private WebSocketUtils webSocketUtils; private SysDictItemMapper sysDictItemMapper;
/** /**
@ -219,38 +223,26 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
/** /**
* 通过excel导入数据 * 通过excel导入数据
* *
* * @param request
* @param response
* @return * @return
*/ */
@RequestMapping(value = "/importExcel", method = RequestMethod.POST) @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(MultipartFile file) { public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return rulexController.preImportAndExcel(file); return rulexController.preImportAndExcel(request);
} }
@Transactional @Transactional
public Result<?> preImportAndExcel(MultipartFile file) { public Result<?> preImportAndExcel(HttpServletRequest request) {
//return super.importExcel(request, response, ScTeams.class);
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, String> message = new HashMap<>(); Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
message.put("isVisible", "true");
message.put("uploaded", "0");
message.put("status", "判断文件结构");
webSocketUtils.sendMessage(loginUser.getId(), message);
// 判断文件是否是表格
String originalFilename = file.getOriginalFilename();
if (StringUtils.isBlank(originalFilename) ||
(!originalFilename.endsWith("xls") &&
!originalFilename.endsWith("xlsx"))) {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("文件格式不正确");
}
//校验时间 //校验时间
final DateValidator validator = new DateValidatorUsingDateFormat("yyyy-MM-dd hh:mm:ss"); final DateValidator validator = new DateValidatorUsingDateFormat("yyyy-MM-dd hh:mm:ss");
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
System.err.println("----------------------------------------------");
// 获取上传文件对象
MultipartFile file = entity.getValue();
if (file==null){ if (file==null){
return Result.error("文件上传失败,请重新上传"); return Result.error("文件上传失败,请重新上传");
} }
@ -259,14 +251,13 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
params.setHeadRows(1);//表头行数,默认1 params.setHeadRows(1);//表头行数,默认1
params.setNeedSave(true);//是否需要保存上传的Excel,默认为false params.setNeedSave(true);//是否需要保存上传的Excel,默认为false
try { try {
message.put("status", "数据预读入"); // List<ScTeamsDr> list = ExcelImportUtil.importExcel(file.getInputStream(), ScTeamsDr.class, params);
webSocketUtils.sendMessage(loginUser.getId(), message);
List<RuleVo> list = ExcelImportUtil.importExcel(file.getInputStream(), RuleVo.class, params); List<RuleVo> list = ExcelImportUtil.importExcel(file.getInputStream(), RuleVo.class, params);
if (list == null || list.size() <= 0) { if (list == null || list.size() <= 0) {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("文件导入失败:模板中暂无数据"); return Result.error("文件导入失败:模板中暂无数据");
} }
System.err.println("----------------------------------------------");
System.out.println("List<ScTeams> list = ExcelImportUtil.importExcel: " + list);
int num = 0; int num = 0;
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
if ( if (
@ -294,8 +285,6 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
} }
num++; num++;
if (num == 0) { if (num == 0) {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("文件导入失败:导入模板不匹配"); return Result.error("文件导入失败:导入模板不匹配");
// } else if (num!=list.size()) { // } else if (num!=list.size()) {
// return Result.error("文件导入失败:请检查填写文字"); // return Result.error("文件导入失败:请检查填写文字");
@ -308,12 +297,8 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
log.error(msg, e); log.error(msg, e);
//if(msg!=null && msg.contains("Duplicate entry")) //if(msg!=null && msg.contains("Duplicate entry"))
if (msg != null && msg.indexOf("Duplicate entry") >= 0) { if (msg != null && msg.indexOf("Duplicate entry") >= 0) {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("文件导入失败:有重复数据!"); return Result.error("文件导入失败:有重复数据!");
} else { } else {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("文件导入失败:" + e.getMessage()); return Result.error("文件导入失败:" + e.getMessage());
} }
//update-end-author:taoyan date:20211124 for: 导入数据重复增加提示 //update-end-author:taoyan date:20211124 for: 导入数据重复增加提示
@ -324,17 +309,11 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
e.printStackTrace(); e.printStackTrace();
} }
} }
}
List<RuleVo> ruleVoList = iRuleVoService.list(); List<RuleVo> ruleVoList = iRuleVoService.list();
if (ruleVoList.size()<=0||ruleVoList==null){ if (ruleVoList.size()<=0||ruleVoList==null){
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("文件导入失败,模板不匹配"); return Result.error("文件导入失败,模板不匹配");
} }
// 将总的记录数传递给前端
message.put("records", String.valueOf(ruleVoList.size()));
webSocketUtils.sendMessage(loginUser.getId(), message);
for (int i = 0; i < ruleVoList.size(); i++) { for (int i = 0; i < ruleVoList.size(); i++) {
Rulex rulex = new Rulex(); Rulex rulex = new Rulex();
RuleVo ruleVo = ruleVoList.get(i); RuleVo ruleVo = ruleVoList.get(i);
@ -345,8 +324,6 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
Fieldx byId = iFieldxService.getOne(rulexLambdaQueryWrapper); Fieldx byId = iFieldxService.getOne(rulexLambdaQueryWrapper);
if (byId == null) { if (byId == null) {
iRuleVoService.remove(null); iRuleVoService.remove(null);
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("字段输入错误,请核对"); return Result.error("字段输入错误,请核对");
} }
rulex.setFieldId(byId.getId()); rulex.setFieldId(byId.getId());
@ -357,8 +334,6 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
Functionx byId1 = functionxService.getOne(functionxLambdaQueryWrapper); Functionx byId1 = functionxService.getOne(functionxLambdaQueryWrapper);
if (byId1 == null) { if (byId1 == null) {
iRuleVoService.remove(null); iRuleVoService.remove(null);
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("功能输入错误,请核对"); return Result.error("功能输入错误,请核对");
} }
rulex.setFunctionId(byId1.getId()); rulex.setFunctionId(byId1.getId());
@ -368,8 +343,6 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
modulexLambdaQueryWrapper.eq(Modulex::getModuleName, moduleName); modulexLambdaQueryWrapper.eq(Modulex::getModuleName, moduleName);
Modulex byId2 = iModulexService.getOne(modulexLambdaQueryWrapper); Modulex byId2 = iModulexService.getOne(modulexLambdaQueryWrapper);
if (byId2 == null) { if (byId2 == null) {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
iRuleVoService.remove(null); iRuleVoService.remove(null);
return Result.error("模块输入错误,请核对"); return Result.error("模块输入错误,请核对");
@ -381,8 +354,6 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
tableLambdaQueryWrapper.eq(Tablex::getTableName, tableId); tableLambdaQueryWrapper.eq(Tablex::getTableName, tableId);
Tablex byId3 = iTablexService.getOne(tableLambdaQueryWrapper); Tablex byId3 = iTablexService.getOne(tableLambdaQueryWrapper);
if (byId3 == null) { if (byId3 == null) {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
iRuleVoService.remove(null); iRuleVoService.remove(null);
return Result.error("实体输入错误,请核对"); return Result.error("实体输入错误,请核对");
@ -395,8 +366,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
rulex.setDuration(aDouble); rulex.setDuration(aDouble);
} catch (Exception e) { } catch (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("任务时长输入错误,请核对"); return Result.error("任务时长输入错误,请核对");
} }
@ -405,8 +375,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
d = Double.valueOf(ruleVo.getRealDuration()); d = Double.valueOf(ruleVo.getRealDuration());
} catch (Exception e) { } catch (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("实际时长输入错误,请核对"); return Result.error("实际时长输入错误,请核对");
} }
rulex.setRealDuration(d); rulex.setRealDuration(d);
@ -415,8 +384,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
integer = Integer.valueOf(ruleVo.getWorkLevel()); integer = Integer.valueOf(ruleVo.getWorkLevel());
} catch (Exception e) { } catch (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("任务等级输入错误,请核对"); return Result.error("任务等级输入错误,请核对");
} }
rulex.setWorkLevel(integer); rulex.setWorkLevel(integer);
@ -426,8 +394,6 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
SysDictItem sysDictItem = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper); SysDictItem sysDictItem = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper);
if (sysDictItem == null){ if (sysDictItem == null){
iRuleVoService.remove(null); iRuleVoService.remove(null);
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("任务状态输入错误,请核对"); return Result.error("任务状态输入错误,请核对");
} }
@ -439,8 +405,6 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
SysDictItem sysDictItem2 = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper2); SysDictItem sysDictItem2 = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper2);
if (sysDictItem2 == null){ if (sysDictItem2 == null){
iRuleVoService.remove(null); iRuleVoService.remove(null);
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("规则状态输入错误,请核对"); return Result.error("规则状态输入错误,请核对");
} }
@ -452,8 +416,6 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
SysDictItem sysDictItem3 = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper3); SysDictItem sysDictItem3 = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper3);
if (sysDictItem3 == null) { if (sysDictItem3 == null) {
iRuleVoService.remove(null); iRuleVoService.remove(null);
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("版本状态输入错误,请核对"); return Result.error("版本状态输入错误,请核对");
} }
@ -467,10 +429,10 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
if (startTime != null) if (startTime != null)
if (!validator.isValid(startTime)){ if (!validator.isValid(startTime)){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("开始时间输入错误"); return Result.error("开始时间输入错误");
} else { }
else {
Date date = simpleDateFormat.parse(startTime); Date date = simpleDateFormat.parse(startTime);
rulex.setStartTime(date); rulex.setStartTime(date);
} }
@ -478,10 +440,10 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
if (submitTime != null) if (submitTime != null)
if (!validator.isValid(submitTime)){ if (!validator.isValid(submitTime)){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("提交时间输入错误"); return Result.error("提交时间输入错误");
} else { }
else {
Date date1 = simpleDateFormat.parse(submitTime); Date date1 = simpleDateFormat.parse(submitTime);
rulex.setSubmitTime(date1); rulex.setSubmitTime(date1);
} }
@ -494,8 +456,6 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
List<String> list = rulexMapper.checkRuleNo(byId1.getId()); List<String> list = rulexMapper.checkRuleNo(byId1.getId());
if (list.contains(ruleNo)) { if (list.contains(ruleNo)) {
iRuleVoService.remove(null); iRuleVoService.remove(null);
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("规则序号已存在"); return Result.error("规则序号已存在");
} }
rulex.setRuleNo(ruleNo); rulex.setRuleNo(ruleNo);
@ -520,8 +480,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
integer1 = Integer.valueOf(ruleVo.getVerison()); integer1 = Integer.valueOf(ruleVo.getVerison());
} catch (Exception e) { } catch (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("版本号输入错误,请核对"); return Result.error("版本号输入错误,请核对");
} }
rulex.setVerison(String.valueOf(integer1)); rulex.setVerison(String.valueOf(integer1));
@ -529,17 +488,13 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
String managerUsers = ruleVo.getManagerUsers(); String managerUsers = ruleVo.getManagerUsers();
if (managerUsers != null) if (managerUsers != null)
rulex.setManagerUsers(managerUsers); rulex.setManagerUsers(managerUsers);
message.put("status", "正在读取数据");
webSocketUtils.sendMessage(loginUser.getId(), message);
//存入真实表 //存入真实表
rulexService.saveRule(rulex,loginUser,message,i+1); rulexService.save(rulex);
iRuleVoService.remove(null); iRuleVoService.remove(null);
} }
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.ok("文件导入成功!"); return Result.ok("文件导入成功!");
}
}
@GetMapping(value = "/sort") @GetMapping(value = "/sort")
public Result<?> sort(@RequestParam(name="id",required=true) String id) { public Result<?> sort(@RequestParam(name="id",required=true) String id) {
return rulexService.sort(id); return rulexService.sort(id);

@ -1,13 +1,11 @@
package org.jeecg.modules.demo.rulex.service; package org.jeecg.modules.demo.rulex.service;
import org.jeecg.common.api.vo.Result; import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.demo.functionx.entity.Functionx; import org.jeecg.modules.demo.functionx.entity.Functionx;
import org.jeecg.modules.demo.rulex.entity.Rulex; import org.jeecg.modules.demo.rulex.entity.Rulex;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @Description: 规则管理 * @Description: 规则管理
@ -22,7 +20,6 @@ public interface IRulexService extends IService<Rulex> {
List<Rulex> queryRuleListByFunctionId(Functionx functionx); List<Rulex> queryRuleListByFunctionId(Functionx functionx);
void saveRule(Rulex rulex, LoginUser loginUser, Map<String, String> message,int i);
void saveRulex(Functionx functionx); void saveRulex(Functionx functionx);
} }

@ -5,24 +5,20 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result; import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.demo.functionx.entity.Functionx; import org.jeecg.modules.demo.functionx.entity.Functionx;
import org.jeecg.modules.demo.rulex.entity.Rulex; import org.jeecg.modules.demo.rulex.entity.Rulex;
import org.jeecg.modules.demo.rulex.mapper.RulexMapper; import org.jeecg.modules.demo.rulex.mapper.RulexMapper;
import org.jeecg.modules.demo.rulex.service.IRulexService; import org.jeecg.modules.demo.rulex.service.IRulexService;
import org.jeecg.modules.fieldx.entity.Fieldx; import org.jeecg.modules.fieldx.entity.Fieldx;
import org.jeecg.modules.fieldx.service.IFieldxService; import org.jeecg.modules.fieldx.service.IFieldxService;
import org.jeecg.modules.message.controller.SysMessageTemplateController;
import org.jeecg.modules.tablex.entity.Tablex; import org.jeecg.modules.tablex.entity.Tablex;
import org.jeecg.modules.tablex.service.ITablexService; import org.jeecg.modules.tablex.service.ITablexService;
import org.jeecg.modules.tablex.ws.WebSocketUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @Description: 规则管理 * @Description: 规则管理
@ -38,9 +34,6 @@ public class RulexServiceImpl extends ServiceImpl<RulexMapper, Rulex> implements
@Autowired @Autowired
RulexMapper rulexMapper; RulexMapper rulexMapper;
@Autowired
private WebSocketUtils webSocketUtils;
@Autowired @Autowired
private ITablexService iTablexService; private ITablexService iTablexService;
@ -77,26 +70,6 @@ public class RulexServiceImpl extends ServiceImpl<RulexMapper, Rulex> implements
return this.list(ruleWrapper); return this.list(ruleWrapper);
} }
@Override
public void saveRule(Rulex rulex, LoginUser loginUser, Map<String, String> message,int i) {
try {
Thread.sleep(1000L);
this.save(rulex);
message.put("uploaded", String.valueOf(i ));
webSocketUtils.sendMessage(loginUser.getId(), message);
} catch (InterruptedException e) {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
log.error(e.getMessage(), e);
}
}
/** /**
* 功能管理新增规则操作时如果功能类型是新增修改自动根据实体对应的字段自动生成若干条记录根据实体的字段生成多条规则 * 功能管理新增规则操作时如果功能类型是新增修改自动根据实体对应的字段自动生成若干条记录根据实体的字段生成多条规则
* *

Loading…
Cancel
Save