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. 929
      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,528 +20,484 @@ 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 io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
import javax.servlet.http.HttpServletRequest; /**
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @Description: 规则管理 * @Description: 规则管理
* @Author: jeecg-boot * @Author: jeecg-boot
* @Date: 2023-04-10 * @Date: 2023-04-10
* @Version: V1.0 * @Version: V1.0
*/ */
@Api(tags = "规则管理") @Api(tags="规则管理")
@RestController @RestController
@RequestMapping("/rulex/rulex") @RequestMapping("/rulex/rulex")
@Slf4j @Slf4j
public class RulexController extends JeecgController<Rulex, IRulexService> { public class RulexController extends JeecgController<Rulex, IRulexService> {
@Autowired @Autowired
FunctionxMapper functionxMapper; private IRulexService rulexService;
@Autowired @Autowired
IFunctionxService functionxService; private IRuleVoService iRuleVoService;
@Autowired @Autowired
RulexMapper rulexMapper; FunctionxMapper functionxMapper;
@Autowired @Autowired
IFieldxService iFieldxService; IFunctionxService functionxService;
@Autowired @Autowired
ITablexService iTablexService; RulexMapper rulexMapper;
@Autowired @Autowired
IModulexService iModulexService; IFieldxService iFieldxService;
@Autowired @Autowired
RulexController rulexController; ITablexService iTablexService;
@Autowired @Autowired
private IRulexService rulexService; IModulexService iModulexService;
@Autowired
private IRuleVoService iRuleVoService; @Autowired
@Autowired RulexController rulexController;
private SysDictItemMapper sysDictItemMapper;
@Autowired
@Autowired private SysDictItemMapper sysDictItemMapper;
private WebSocketUtils webSocketUtils;
/**
/** * 分页列表查询
* 分页列表查询 *
* * @param rulex
* @param rulex * @param pageNo
* @param pageNo * @param pageSize
* @param pageSize * @param req
* @param req * @return
* @return */
*/ @AutoLog(value = "规则管理-分页列表查询")
@AutoLog(value = "规则管理-分页列表查询") @ApiOperation(value="规则管理-分页列表查询", notes="规则管理-分页列表查询")
@ApiOperation(value = "规则管理-分页列表查询", notes = "规则管理-分页列表查询") @GetMapping(value = "/list")
@GetMapping(value = "/list") public Result<?> queryPageList(Rulex rulex,
public Result<?> queryPageList(Rulex rulex, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
HttpServletRequest req) {
// QueryWrapper<Rulex> queryWrapper = QueryGenerator.initQueryWrapper(rulex, req.getParameterMap()); // QueryWrapper<Rulex> queryWrapper = QueryGenerator.initQueryWrapper(rulex, req.getParameterMap());
QueryWrapper<Rulex> queryWrapper = new QueryWrapper<>(); QueryWrapper<Rulex> queryWrapper=new QueryWrapper<>();
queryWrapper.eq("function_id", rulex.getFunctionId()); queryWrapper.eq("function_id",rulex.getFunctionId());
queryWrapper.orderByDesc("work_level"); queryWrapper.orderByDesc("work_level");
if (rulex.getRuleCode() != null) { if(rulex.getRuleCode()!=null){
queryWrapper.eq("rule_code", rulex.getRuleCode()); queryWrapper.eq("rule_code",rulex.getRuleCode());
} }
if (rulex.getTableId() != null) { if(rulex.getTableId()!=null){
queryWrapper.eq("table_id", rulex.getTableId()); queryWrapper.eq("table_id",rulex.getTableId());
} }
if (rulex.getFieldId() != null) { if(rulex.getFieldId()!=null){
queryWrapper.eq("field_id", rulex.getFieldId()); queryWrapper.eq("field_id",rulex.getFieldId());
} }
Page<Rulex> page = new Page<Rulex>(pageNo, pageSize); Page<Rulex> page = new Page<Rulex>(pageNo, pageSize);
IPage<Rulex> pageList = rulexService.page(page, queryWrapper); IPage<Rulex> pageList = rulexService.page(page, queryWrapper);
return Result.OK(pageList); return Result.OK(pageList);
} }
/** /**
* 添加 * 添加
* *
* @param rulex * @param rulex
* @return * @return
*/ */
@AutoLog(value = "规则管理-添加") @AutoLog(value = "规则管理-添加")
@ApiOperation(value = "规则管理-添加", notes = "规则管理-添加") @ApiOperation(value="规则管理-添加", notes="规则管理-添加")
@PostMapping(value = "/add") @PostMapping(value = "/add")
public Result<?> add(@RequestBody Rulex rulex) { public Result<?> add(@RequestBody Rulex rulex) {
if (rulex.getFunctionId() == null) { if(rulex.getFunctionId()==null){
return Result.error("功能点错误!!!"); return Result.error("功能点错误!!!");
} }
Functionx functionx = functionxMapper.selectById(rulex.getFunctionId()); Functionx functionx = functionxMapper.selectById(rulex.getFunctionId());
if (functionx.getStartTime() != null) { if(functionx.getStartTime()!=null){
rulex.setStartTime(functionx.getStartTime()); rulex.setStartTime(functionx.getStartTime());
} }
if (functionx.getSubmitTime() != null) { if(functionx.getSubmitTime()!=null){
rulex.setSubmitTime(functionx.getSubmitTime()); rulex.setSubmitTime(functionx.getSubmitTime());
} }
if (functionx.getRealDuration() != null) { if(functionx.getRealDuration()!=null){
rulex.setRealDuration(functionx.getRealDuration()); rulex.setRealDuration(functionx.getRealDuration());
} }
rulex.setManagerUsers(functionx.getManagerUsers()); rulex.setManagerUsers(functionx.getManagerUsers());
rulex.setWorkStatus(functionx.getWorkStatus()); rulex.setWorkStatus(functionx.getWorkStatus());
rulexService.save(rulex); rulexService.save(rulex);
return Result.OK("添加成功!"); return Result.OK("添加成功!");
} }
/** /**
* 编辑 * 编辑
* *
* @param rulex * @param rulex
* @return * @return
*/ */
@AutoLog(value = "规则管理-编辑") @AutoLog(value = "规则管理-编辑")
@ApiOperation(value = "规则管理-编辑", notes = "规则管理-编辑") @ApiOperation(value="规则管理-编辑", notes="规则管理-编辑")
@PutMapping(value = "/edit") @PutMapping(value = "/edit")
public Result<?> edit(@RequestBody Rulex rulex) { public Result<?> edit(@RequestBody Rulex rulex) {
rulexService.updateById(rulex); rulexService.updateById(rulex);
return Result.OK("编辑成功!"); return Result.OK("编辑成功!");
} }
/** /**
* 通过id删除 * 通过id删除
* *
* @param id * @param id
* @return * @return
*/ */
@AutoLog(value = "规则管理-通过id删除") @AutoLog(value = "规则管理-通过id删除")
@ApiOperation(value = "规则管理-通过id删除", notes = "规则管理-通过id删除") @ApiOperation(value="规则管理-通过id删除", notes="规则管理-通过id删除")
@DeleteMapping(value = "/delete") @DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name = "id", required = true) String id) { public Result<?> delete(@RequestParam(name="id",required=true) String id) {
rulexService.removeById(id); rulexService.removeById(id);
return Result.OK("删除成功!"); return Result.OK("删除成功!");
} }
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "规则管理-批量删除")
@ApiOperation(value="规则管理-批量删除", notes="规则管理-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.rulexService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
@AutoLog(value = "规则管理-通过id查询")
@ApiOperation(value="规则管理-通过id查询", notes="规则管理-通过id查询")
@GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
Rulex rulex = rulexService.getById(id);
if(rulex==null) {
return Result.error("未找到对应数据");
}
return Result.OK(rulex);
}
/** /**
* 批量删除 * 导出excel
* *
* @param ids * @param request
* @return * @param rulex
*/ */
@AutoLog(value = "规则管理-批量删除")
@ApiOperation(value = "规则管理-批量删除", notes = "规则管理-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
this.rulexService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
@AutoLog(value = "规则管理-通过id查询")
@ApiOperation(value = "规则管理-通过id查询", notes = "规则管理-通过id查询")
@GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
Rulex rulex = rulexService.getById(id);
if (rulex == null) {
return Result.error("未找到对应数据");
}
return Result.OK(rulex);
}
/**
* 导出excel
*
* @param request
* @param rulex
*/
@RequestMapping(value = "/exportXls") @RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, Rulex rulex) { public ModelAndView exportXls(HttpServletRequest request, Rulex rulex) {
return super.exportXls(request, rulex, Rulex.class, "规则管理"); return super.exportXls(request, rulex, Rulex.class, "规则管理");
} }
/** /**
* 通过excel导入数据 * 通过excel导入数据
* *
* * @param request
* @return * @param response
*/ * @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(HttpServletRequest request) {
public Result<?> preImportAndExcel(MultipartFile file) { //return super.importExcel(request, response, ScTeams.class);
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
Map<String, String> message = new HashMap<>(); //校验时间
message.put("isVisible", "true"); final DateValidator validator = new DateValidatorUsingDateFormat("yyyy-MM-dd hh:mm:ss");
message.put("uploaded", "0"); for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
message.put("status", "判断文件结构"); System.err.println("----------------------------------------------");
webSocketUtils.sendMessage(loginUser.getId(), message); // 获取上传文件对象
MultipartFile file = entity.getValue();
if (file==null){
// 判断文件是否是表格 return Result.error("文件上传失败,请重新上传");
String originalFilename = file.getOriginalFilename(); }
if (StringUtils.isBlank(originalFilename) || ImportParams params = new ImportParams();
(!originalFilename.endsWith("xls") && params.setTitleRows(2);//表格标题行数,默认0
!originalFilename.endsWith("xlsx"))) { params.setHeadRows(1);//表头行数,默认1
message.put("isVisible", "false"); params.setNeedSave(true);//是否需要保存上传的Excel,默认为false
webSocketUtils.sendMessage(loginUser.getId(), message); try {
return Result.error("文件格式不正确"); // List<ScTeamsDr> list = ExcelImportUtil.importExcel(file.getInputStream(), ScTeamsDr.class, params);
} List<RuleVo> list = ExcelImportUtil.importExcel(file.getInputStream(), RuleVo.class, params);
//校验时间 if (list == null || list.size() <= 0) {
final DateValidator validator = new DateValidatorUsingDateFormat("yyyy-MM-dd hh:mm:ss"); return Result.error("文件导入失败:模板中暂无数据");
}
if (file == null) { System.err.println("----------------------------------------------");
return Result.error("文件上传失败,请重新上传"); System.out.println("List<ScTeams> list = ExcelImportUtil.importExcel: " + list);
} int num = 0;
ImportParams params = new ImportParams(); for (int i = 0; i < list.size(); i++) {
params.setTitleRows(2);//表格标题行数,默认0 if (
params.setHeadRows(1);//表头行数,默认1 //excel出现必要值未填该行直接跳过
params.setNeedSave(true);//是否需要保存上传的Excel,默认为false list.get(i).getRuleNo() == null ||
try { list.get(i).getRuleCode() == null ||
message.put("status", "数据预读入");
webSocketUtils.sendMessage(loginUser.getId(), message);
List<RuleVo> list = ExcelImportUtil.importExcel(file.getInputStream(), RuleVo.class, params);
if (list == null || list.size() <= 0) {
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("文件导入失败:模板中暂无数据");
}
int num = 0;
for (int i = 0; i < list.size(); i++) {
if (
//excel出现必要值未填该行直接跳过
list.get(i).getRuleNo() == null ||
list.get(i).getRuleCode() == null ||
// list.get(i).getPmDescribe() == null && // list.get(i).getPmDescribe() == null &&
list.get(i).getModuleId() == null || list.get(i).getModuleId() == null ||
list.get(i).getFunctionId() == null || list.get(i).getFunctionId() == null ||
// list.get(i).getDiagrams() == null && // list.get(i).getDiagrams() == null &&
list.get(i).getTableId() == null || list.get(i).getTableId() == null ||
list.get(i).getFieldId() == null || list.get(i).getFieldId() == null ||
list.get(i).getManagerUsers() == null || list.get(i).getManagerUsers() == null ||
list.get(i).getWorkLevel() == null || list.get(i).getWorkLevel() == null ||
list.get(i).getWorkStatus() == null || list.get(i).getWorkStatus() == null ||
// list.get(i).getStartTime() == null && // list.get(i).getStartTime() == null &&
// list.get(i).getManagerUsers() == null && // list.get(i).getManagerUsers() == null &&
// list.get(i).getDuration() == null && // list.get(i).getDuration() == null &&
// list.get(i).getSubmitTime() == null && // list.get(i).getSubmitTime() == null &&
list.get(i).getRealDuration() == null && list.get(i).getRealDuration() == null&&
list.get(i).getStatus() == null || list.get(i).getStatus() == null||
list.get(i).getVerisonStatus() == null || list.get(i).getVerisonStatus() == null||
list.get(i).getVerison() == null) { list.get(i).getVerison() == null) {
continue; continue;
} }
num++; num++;
if (num == 0) { if (num == 0) {
message.put("isVisible", "false"); return Result.error("文件导入失败:导入模板不匹配");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("文件导入失败:导入模板不匹配");
// } else if (num!=list.size()) { // } else if (num!=list.size()) {
// return Result.error("文件导入失败:请检查填写文字"); // return Result.error("文件导入失败:请检查填写文字");
} }
iRuleVoService.save(list.get(i)); iRuleVoService.save(list.get(i));
} }
} catch (Exception e) { }catch (Exception e) {
//update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示 //update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示
String msg = e.getMessage(); String msg = e.getMessage();
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"); return Result.error("文件导入失败:有重复数据!");
webSocketUtils.sendMessage(loginUser.getId(), message); } else {
return Result.error("文件导入失败:有重复数据!"); return Result.error("文件导入失败:" + e.getMessage());
} else { }
message.put("isVisible", "false"); //update-end-author:taoyan date:20211124 for: 导入数据重复增加提示
webSocketUtils.sendMessage(loginUser.getId(), message); } finally {
return Result.error("文件导入失败:" + e.getMessage()); try {
} file.getInputStream().close();
//update-end-author:taoyan date:20211124 for: 导入数据重复增加提示 } catch (IOException e) {
} finally { e.printStackTrace();
try { }
file.getInputStream().close(); }
} catch (IOException e) { }
e.printStackTrace(); List<RuleVo> ruleVoList = iRuleVoService.list();
} if (ruleVoList.size()<=0||ruleVoList==null){
} return Result.error("文件导入失败,模板不匹配");
}
List<RuleVo> ruleVoList = iRuleVoService.list(); for (int i = 0; i < ruleVoList.size(); i++) {
if (ruleVoList.size() <= 0 || ruleVoList == null) { Rulex rulex = new Rulex();
message.put("isVisible", "false"); RuleVo ruleVo = ruleVoList.get(i);
webSocketUtils.sendMessage(loginUser.getId(), message); //对应字段
return Result.error("文件导入失败,模板不匹配"); String fieldId = ruleVo.getFieldId();
} LambdaQueryWrapper<Fieldx> rulexLambdaQueryWrapper = new LambdaQueryWrapper<>();
// 将总的记录数传递给前端 rulexLambdaQueryWrapper.eq(Fieldx::getFieldName, fieldId);
message.put("records", String.valueOf(ruleVoList.size())); Fieldx byId = iFieldxService.getOne(rulexLambdaQueryWrapper);
webSocketUtils.sendMessage(loginUser.getId(), message); if (byId == null) {
iRuleVoService.remove(null);
for (int i = 0; i < ruleVoList.size(); i++) { return Result.error("字段输入错误,请核对");
Rulex rulex = new Rulex(); }
RuleVo ruleVo = ruleVoList.get(i); rulex.setFieldId(byId.getId());
//对应字段 //对应功能
String fieldId = ruleVo.getFieldId(); String functionName = ruleVo.getFunctionId();
LambdaQueryWrapper<Fieldx> rulexLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Functionx> functionxLambdaQueryWrapper = new LambdaQueryWrapper<Functionx>();
rulexLambdaQueryWrapper.eq(Fieldx::getFieldName, fieldId); functionxLambdaQueryWrapper.eq(Functionx::getFunctionName, functionName);
Fieldx byId = iFieldxService.getOne(rulexLambdaQueryWrapper); Functionx byId1 = functionxService.getOne(functionxLambdaQueryWrapper);
if (byId == null) { if (byId1 == null) {
iRuleVoService.remove(null); iRuleVoService.remove(null);
message.put("isVisible", "false"); return Result.error("功能输入错误,请核对");
webSocketUtils.sendMessage(loginUser.getId(), message); }
return Result.error("字段输入错误,请核对"); rulex.setFunctionId(byId1.getId());
} //对应模块
rulex.setFieldId(byId.getId()); String moduleName = ruleVo.getModuleId();
//对应功能 LambdaQueryWrapper<Modulex> modulexLambdaQueryWrapper = new LambdaQueryWrapper<>();
String functionName = ruleVo.getFunctionId(); modulexLambdaQueryWrapper.eq(Modulex::getModuleName, moduleName);
LambdaQueryWrapper<Functionx> functionxLambdaQueryWrapper = new LambdaQueryWrapper<Functionx>(); Modulex byId2 = iModulexService.getOne(modulexLambdaQueryWrapper);
functionxLambdaQueryWrapper.eq(Functionx::getFunctionName, functionName); if (byId2 == null) {
Functionx byId1 = functionxService.getOne(functionxLambdaQueryWrapper); iRuleVoService.remove(null);
if (byId1 == null) {
iRuleVoService.remove(null); return Result.error("模块输入错误,请核对");
message.put("isVisible", "false"); }
webSocketUtils.sendMessage(loginUser.getId(), message); rulex.setModuleId(byId2.getId());
return Result.error("功能输入错误,请核对"); //对应实体
} String tableId = ruleVo.getTableId();
rulex.setFunctionId(byId1.getId()); LambdaQueryWrapper<Tablex> tableLambdaQueryWrapper = new LambdaQueryWrapper<>();
//对应模块 tableLambdaQueryWrapper.eq(Tablex::getTableName, tableId);
String moduleName = ruleVo.getModuleId(); Tablex byId3 = iTablexService.getOne(tableLambdaQueryWrapper);
LambdaQueryWrapper<Modulex> modulexLambdaQueryWrapper = new LambdaQueryWrapper<>(); if (byId3 == null) {
modulexLambdaQueryWrapper.eq(Modulex::getModuleName, moduleName); iRuleVoService.remove(null);
Modulex byId2 = iModulexService.getOne(modulexLambdaQueryWrapper);
if (byId2 == null) { return Result.error("实体输入错误,请核对");
message.put("isVisible", "false"); }
webSocketUtils.sendMessage(loginUser.getId(), message); rulex.setTableId(byId3.getId());
iRuleVoService.remove(null); Double aDouble = null;
try {
return Result.error("模块输入错误,请核对"); if (aDouble != null)
} aDouble = Double.valueOf(ruleVo.getDuration());
rulex.setModuleId(byId2.getId()); rulex.setDuration(aDouble);
//对应实体 } catch (Exception e) {
String tableId = ruleVo.getTableId(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
LambdaQueryWrapper<Tablex> tableLambdaQueryWrapper = new LambdaQueryWrapper<>();
tableLambdaQueryWrapper.eq(Tablex::getTableName, tableId); return Result.error("任务时长输入错误,请核对");
Tablex byId3 = iTablexService.getOne(tableLambdaQueryWrapper); }
if (byId3 == null) {
message.put("isVisible", "false"); Double d;
webSocketUtils.sendMessage(loginUser.getId(), message); try {
iRuleVoService.remove(null); d = Double.valueOf(ruleVo.getRealDuration());
} catch (Exception e) {
return Result.error("实体输入错误,请核对"); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
}
rulex.setTableId(byId3.getId()); return Result.error("实际时长输入错误,请核对");
Double aDouble = null; }
try { rulex.setRealDuration(d);
if (aDouble != null) Integer integer;
aDouble = Double.valueOf(ruleVo.getDuration()); try {
rulex.setDuration(aDouble); 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);
String workStatus = ruleVo.getWorkStatus();
Double d; LambdaQueryWrapper<SysDictItem> sysDictItemLambdaQueryWrapper = new LambdaQueryWrapper<>();
try { sysDictItemLambdaQueryWrapper.eq(SysDictItem::getItemText, workStatus).eq(SysDictItem::getDictId,"1645268542514421762");
d = Double.valueOf(ruleVo.getRealDuration()); SysDictItem sysDictItem = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper);
} catch (Exception e) { if (sysDictItem == null){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了 iRuleVoService.remove(null);
message.put("isVisible", "false"); return Result.error("任务状态输入错误,请核对");
webSocketUtils.sendMessage(loginUser.getId(), message); }
return Result.error("实际时长输入错误,请核对");
} rulex.setWorkStatus(Integer.valueOf(sysDictItem.getItemValue()));
rulex.setRealDuration(d);
Integer integer; String status = ruleVo.getStatus();
try { LambdaQueryWrapper<SysDictItem> sysDictItemLambdaQueryWrapper2 = new LambdaQueryWrapper<>();
integer = Integer.valueOf(ruleVo.getWorkLevel()); sysDictItemLambdaQueryWrapper2.eq(SysDictItem::getItemText, status).eq(SysDictItem::getDictId,"1645264493205491713");
} catch (Exception e) { SysDictItem sysDictItem2 = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper2);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了 if (sysDictItem2 == null){
message.put("isVisible", "false"); iRuleVoService.remove(null);
webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("规则状态输入错误,请核对");
return Result.error("任务等级输入错误,请核对"); }
}
rulex.setWorkLevel(integer);
String workStatus = ruleVo.getWorkStatus(); rulex.setStatus(Integer.valueOf(sysDictItem2.getItemValue()));
LambdaQueryWrapper<SysDictItem> sysDictItemLambdaQueryWrapper = new LambdaQueryWrapper<>(); String verisonStatus = ruleVo.getVerisonStatus();
sysDictItemLambdaQueryWrapper.eq(SysDictItem::getItemText, workStatus).eq(SysDictItem::getDictId, "1645268542514421762"); LambdaQueryWrapper<SysDictItem> sysDictItemLambdaQueryWrapper3 = new LambdaQueryWrapper<>();
SysDictItem sysDictItem = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper); sysDictItemLambdaQueryWrapper3.eq(SysDictItem::getItemText, verisonStatus);
if (sysDictItem == null) { SysDictItem sysDictItem3 = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper3);
iRuleVoService.remove(null); if (sysDictItem3 == null) {
message.put("isVisible", "false"); iRuleVoService.remove(null);
webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("版本状态输入错误,请核对");
return Result.error("任务状态输入错误,请核对"); }
}
rulex.setVerisonStatus(Integer.valueOf(sysDictItem3.getItemValue()));
rulex.setWorkStatus(Integer.valueOf(sysDictItem.getItemValue()));
//String转Date
String status = ruleVo.getStatus(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
LambdaQueryWrapper<SysDictItem> sysDictItemLambdaQueryWrapper2 = new LambdaQueryWrapper<>();
sysDictItemLambdaQueryWrapper2.eq(SysDictItem::getItemText, status).eq(SysDictItem::getDictId, "1645264493205491713"); try {
SysDictItem sysDictItem2 = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper2); String startTime = ruleVo.getStartTime();
if (sysDictItem2 == null) { if (startTime != null)
iRuleVoService.remove(null); if (!validator.isValid(startTime)){
message.put("isVisible", "false"); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("开始时间输入错误");
return Result.error("规则状态输入错误,请核对"); }
}
else {
Date date = simpleDateFormat.parse(startTime);
rulex.setStatus(Integer.valueOf(sysDictItem2.getItemValue())); rulex.setStartTime(date);
String verisonStatus = ruleVo.getVerisonStatus(); }
LambdaQueryWrapper<SysDictItem> sysDictItemLambdaQueryWrapper3 = new LambdaQueryWrapper<>(); String submitTime = ruleVo.getSubmitTime();
sysDictItemLambdaQueryWrapper3.eq(SysDictItem::getItemText, verisonStatus); if (submitTime != null)
SysDictItem sysDictItem3 = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper3); if (!validator.isValid(submitTime)){
if (sysDictItem3 == null) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
iRuleVoService.remove(null); return Result.error("提交时间输入错误");
message.put("isVisible", "false"); }
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("版本状态输入错误,请核对"); else {
} Date date1 = simpleDateFormat.parse(submitTime);
rulex.setSubmitTime(date1);
rulex.setVerisonStatus(Integer.valueOf(sysDictItem3.getItemValue())); }
} catch (ParseException e) {
//String转Date e.printStackTrace();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); }
try { //规则序号
String startTime = ruleVo.getStartTime(); String ruleNo = ruleVo.getRuleNo();
if (startTime != null) List<String> list = rulexMapper.checkRuleNo(byId1.getId());
if (!validator.isValid(startTime)) { if (list.contains(ruleNo)) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了 iRuleVoService.remove(null);
message.put("isVisible", "false"); return Result.error("规则序号已存在");
webSocketUtils.sendMessage(loginUser.getId(), message); }
return Result.error("开始时间输入错误"); rulex.setRuleNo(ruleNo);
} else { //规则编码
Date date = simpleDateFormat.parse(startTime); String ruleCode = ruleVo.getRuleCode();
rulex.setStartTime(date); Functionx functionxServiceById = functionxService.getById(byId1.getId());
} String functionCode = functionxServiceById.getFunctionCode();
String submitTime = ruleVo.getSubmitTime();
if (submitTime != null)
if (!validator.isValid(submitTime)) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("提交时间输入错误");
} else {
Date date1 = simpleDateFormat.parse(submitTime);
rulex.setSubmitTime(date1);
}
} catch (ParseException e) {
e.printStackTrace();
}
//规则序号
String ruleNo = ruleVo.getRuleNo();
List<String> list = rulexMapper.checkRuleNo(byId1.getId());
if (list.contains(ruleNo)) {
iRuleVoService.remove(null);
message.put("isVisible", "false");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("规则序号已存在");
}
rulex.setRuleNo(ruleNo);
//规则编码
String ruleCode = ruleVo.getRuleCode();
Functionx functionxServiceById = functionxService.getById(byId1.getId());
String functionCode = functionxServiceById.getFunctionCode();
// if (!ruleCode.matches(functionCode)) // if (!ruleCode.matches(functionCode))
// return Result.error("规则编码错误"); // return Result.error("规则编码错误");
rulex.setRuleCode(functionCode); rulex.setRuleCode(functionCode);
//规则描述 //规则描述
String pmDescribe = ruleVo.getPmDescribe(); String pmDescribe = ruleVo.getPmDescribe();
if (pmDescribe != null) if (pmDescribe != null)
rulex.setPmDescribe(pmDescribe); rulex.setPmDescribe(pmDescribe);
//分析图 //分析图
String diagrams = ruleVo.getDiagrams(); String diagrams = ruleVo.getDiagrams();
if (diagrams != null) if (diagrams != null)
rulex.setDiagrams(diagrams); rulex.setDiagrams(diagrams);
//版本号 //版本号
Integer integer1; Integer integer1;
try { try {
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)); //责任人、
//责任人、 String managerUsers = ruleVo.getManagerUsers();
String managerUsers = ruleVo.getManagerUsers(); if (managerUsers != null)
if (managerUsers != null) rulex.setManagerUsers(managerUsers);
rulex.setManagerUsers(managerUsers); //存入真实表
message.put("status", "正在读取数据"); rulexService.save(rulex);
webSocketUtils.sendMessage(loginUser.getId(), message); iRuleVoService.remove(null);
//存入真实表 }
rulexService.saveRule(rulex,loginUser,message,i+1); return Result.ok("文件导入成功!");
iRuleVoService.remove(null);
} }
message.put("isVisible", "false"); @GetMapping(value = "/sort")
webSocketUtils.sendMessage(loginUser.getId(), message); public Result<?> sort(@RequestParam(name="id",required=true) String id) {
return Result.ok("文件导入成功!"); return rulexService.sort(id);
} }
@GetMapping(value = "/sort") }
public Result<?> sort(@RequestParam(name = "id", required = true) String 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