Compare commits

..

No commits in common. 'f5d717febda5ade9542a3543947d7f7230f7a2e1' and 'ab15bf85cf383e092f60bdf70c1f3c177be38e17' have entirely different histories.

  1. 11
      ant-design-vue-jeecg/src/views/modulex/ModulexList.vue
  2. 2
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/JeecgSystemApplication.java
  3. 257
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/controller/RulexController.java

@ -397,8 +397,7 @@ export default {
deleteBatch: "/modulex/modulex/deleteBatch", deleteBatch: "/modulex/modulex/deleteBatch",
exportXlsUrl: "/modulex/modulex/exportXls", exportXlsUrl: "/modulex/modulex/exportXls",
importExcelUrl: "modulex/modulex/importExcel", importExcelUrl: "modulex/modulex/importExcel",
tablexImportExcelUrl: "tablex/tablex/importExcel",
ruleImportExcelUrl: "rulex/rulex/importExcel",
}, },
dictOptions: {}, dictOptions: {},
superFieldList: [], superFieldList: [],
@ -423,13 +422,7 @@ export default {
// columnsdataIndex // columnsdataIndex
checkColumn: function () { checkColumn: function () {
return this.columns.map(item => item.title) return this.columns.map(item => item.title)
}, }
tablexImportExcelUrl: function(){
return `${window._CONFIG['domianURL']}/${this.url.tablexImportExcelUrl}`;
},
ruleImportExcelUrl: function () {
return `${window._CONFIG['domianURL']}/${this.url.ruleImportExcelUrl}`
},
}, },
methods: { methods: {
// //

@ -14,7 +14,7 @@ import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
/** /**
* 单体启动类采用此类启动为单体模式 想笑 别叫 有用 别想 别叫 别用 * 单体启动类采用此类启动为单体模式 想笑 别叫 有用
*/ */
@Slf4j @Slf4j
@SpringBootApplication @SpringBootApplication

@ -1,23 +1,16 @@
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.Arrays;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.io.IOException; import java.io.IOException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.jeecg.common.api.vo.Result; import org.jeecg.common.api.vo.Result;
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.rulex.entity.RuleVo; import org.jeecg.modules.demo.rulex.entity.RuleVo;
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.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;
@ -26,24 +19,16 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.demo.rulex.util.DateValidator;
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.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.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.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.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.multipart.MultipartHttpServletRequest;
@ -69,10 +54,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
private IRuleVoService iRuleVoService; private IRuleVoService iRuleVoService;
@Autowired @Autowired
FunctionxMapper functionxMapper; FunctionxMapper functionxMapper;
@Autowired
IFunctionxService functionxService;
@Autowired
RulexMapper rulexMapper;
@Autowired @Autowired
IFieldxService iFieldxService; IFieldxService iFieldxService;
@Autowired @Autowired
@ -80,12 +62,6 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
@Autowired @Autowired
IModulexService iModulexService; IModulexService iModulexService;
@Autowired
RulexController rulexController;
@Autowired
private SysDictItemMapper sysDictItemMapper;
/** /**
* 分页列表查询 * 分页列表查询
@ -229,16 +205,13 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
*/ */
@RequestMapping(value = "/importExcel", method = RequestMethod.POST) @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, Rulex.class);
return rulexController.preImportAndExcel(request);
} }
@Transactional public Result<?> preImportAndExcel(HttpServletRequest request) {
public Result<?> preImportAndExcel(HttpServletRequest request) {
//return super.importExcel(request, response, ScTeams.class); //return super.importExcel(request, response, ScTeams.class);
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
//校验时间
final DateValidator validator = new DateValidatorUsingDateFormat("yyyy-MM-dd hh:mm:ss");
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
System.err.println("----------------------------------------------"); System.err.println("----------------------------------------------");
// 获取上传文件对象 // 获取上传文件对象
@ -260,37 +233,37 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
System.out.println("List<ScTeams> list = ExcelImportUtil.importExcel: " + list); 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 (list.size() > 0 &&
//excel出现必要值未填该行直接跳过 list.get(i).getRuleNo() == null &&
list.get(i).getRuleNo() == null || list.get(i).getRuleCode() == 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++; iRuleVoService.save(list.get(i));
if (num == 0) { if (num == 0) {
return Result.error("文件导入失败:导入模板不匹配"); return Result.error("文件导入失败:导入模板不匹配");
// } else if (num!=list.size()) { } else {
// return Result.error("文件导入失败:请检查填写文字"); return Result.ok("文件导入成功!");
} }
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();
@ -312,187 +285,69 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
} }
List<RuleVo> ruleVoList = iRuleVoService.list(); List<RuleVo> ruleVoList = iRuleVoService.list();
if (ruleVoList.size()<=0||ruleVoList==null){ if (ruleVoList.size()<=0||ruleVoList==null){
return Result.error("文件导入失败,模板不匹配"); return Result.error("文件导入失败");
} }
for (int i = 0; i < ruleVoList.size(); i++) { for (int i = 0; i < ruleVoList.size(); i++) {
Rulex rulex = new Rulex();
RuleVo ruleVo = ruleVoList.get(i); RuleVo ruleVo = ruleVoList.get(i);
//对应字段 //对应字段
String fieldId = ruleVo.getFieldId(); String fieldId = ruleVo.getFieldId();
LambdaQueryWrapper<Fieldx> rulexLambdaQueryWrapper = new LambdaQueryWrapper<>(); Fieldx byId = iFieldxService.getById(fieldId);
rulexLambdaQueryWrapper.eq(Fieldx::getFieldName, fieldId); if (byId==null){
Fieldx byId = iFieldxService.getOne(rulexLambdaQueryWrapper);
if (byId == null) {
iRuleVoService.remove(null);
return Result.error("字段输入错误,请核对"); return Result.error("字段输入错误,请核对");
} }
rulex.setFieldId(byId.getId());
//对应功能 //对应功能
String functionName = ruleVo.getFunctionId(); String functionId = ruleVo.getFunctionId();
LambdaQueryWrapper<Functionx> functionxLambdaQueryWrapper = new LambdaQueryWrapper<Functionx>(); Fieldx byId1 = iFieldxService.getById(functionId);
functionxLambdaQueryWrapper.eq(Functionx::getFunctionName, functionName); if (byId1==null){
Functionx byId1 = functionxService.getOne(functionxLambdaQueryWrapper);
if (byId1 == null) {
iRuleVoService.remove(null);
return Result.error("功能输入错误,请核对"); return Result.error("功能输入错误,请核对");
} }
rulex.setFunctionId(byId1.getId());
//对应模块 //对应模块
String moduleName = ruleVo.getModuleId(); String moduleId = ruleVo.getModuleId();
LambdaQueryWrapper<Modulex> modulexLambdaQueryWrapper = new LambdaQueryWrapper<>(); Modulex byId2 = iModulexService.getById(moduleId);
modulexLambdaQueryWrapper.eq(Modulex::getModuleName, moduleName); if (byId2==null){
Modulex byId2 = iModulexService.getOne(modulexLambdaQueryWrapper);
if (byId2 == null) {
iRuleVoService.remove(null);
return Result.error("模块输入错误,请核对"); return Result.error("模块输入错误,请核对");
} }
rulex.setModuleId(byId2.getId());
//对应实体 //对应实体
String tableId = ruleVo.getTableId(); String tableId = ruleVo.getTableId();
LambdaQueryWrapper<Tablex> tableLambdaQueryWrapper = new LambdaQueryWrapper<>(); Tablex byId3 = iTablexService.getById(tableId);
tableLambdaQueryWrapper.eq(Tablex::getTableName, tableId); if (byId3==null){
Tablex byId3 = iTablexService.getOne(tableLambdaQueryWrapper);
if (byId3 == null) {
iRuleVoService.remove(null);
return Result.error("实体输入错误,请核对"); return Result.error("实体输入错误,请核对");
} }
rulex.setTableId(byId3.getId());
Double aDouble = null;
try { try {
if (aDouble != null) Double.valueOf(ruleVo.getDuration());
aDouble = Double.valueOf(ruleVo.getDuration()); }catch (Exception e){
rulex.setDuration(aDouble);
} catch (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
return Result.error("任务时长输入错误,请核对"); return Result.error("任务时长输入错误,请核对");
} }
Double d;
try { try {
d = Double.valueOf(ruleVo.getRealDuration()); Integer.valueOf(ruleVo.getRealDuration());
} catch (Exception e) { }catch (Exception e){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
return Result.error("实际时长输入错误,请核对"); return Result.error("实际时长输入错误,请核对");
} }
rulex.setRealDuration(d);
Integer integer;
try {
integer = Integer.valueOf(ruleVo.getWorkLevel());
} catch (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
try {
Integer.valueOf(ruleVo.getWorkLevel());
}catch (Exception e){
return Result.error("任务等级输入错误,请核对"); return Result.error("任务等级输入错误,请核对");
} }
rulex.setWorkLevel(integer); try {
String workStatus = ruleVo.getWorkStatus(); Double.valueOf(ruleVo.getWorkStatus());
LambdaQueryWrapper<SysDictItem> sysDictItemLambdaQueryWrapper = new LambdaQueryWrapper<>(); }catch (Exception e){
sysDictItemLambdaQueryWrapper.eq(SysDictItem::getItemText, workStatus).eq(SysDictItem::getDictId,"1645268542514421762");
SysDictItem sysDictItem = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper);
if (sysDictItem == null){
iRuleVoService.remove(null);
return Result.error("任务状态输入错误,请核对"); return Result.error("任务状态输入错误,请核对");
} }
rulex.setWorkStatus(Integer.valueOf(sysDictItem.getItemValue()));
String status = ruleVo.getStatus();
LambdaQueryWrapper<SysDictItem> sysDictItemLambdaQueryWrapper2 = new LambdaQueryWrapper<>();
sysDictItemLambdaQueryWrapper2.eq(SysDictItem::getItemText, status).eq(SysDictItem::getDictId,"1645264493205491713");
SysDictItem sysDictItem2 = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper2);
if (sysDictItem2 == null){
iRuleVoService.remove(null);
return Result.error("规则状态输入错误,请核对");
}
rulex.setStatus(Integer.valueOf(sysDictItem2.getItemValue()));
String verisonStatus = ruleVo.getVerisonStatus();
LambdaQueryWrapper<SysDictItem> sysDictItemLambdaQueryWrapper3 = new LambdaQueryWrapper<>();
sysDictItemLambdaQueryWrapper3.eq(SysDictItem::getItemText, verisonStatus);
SysDictItem sysDictItem3 = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper3);
if (sysDictItem3 == null) {
iRuleVoService.remove(null);
return Result.error("版本状态输入错误,请核对");
}
rulex.setVerisonStatus(Integer.valueOf(sysDictItem3.getItemValue()));
//String转Date
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try { try {
String startTime = ruleVo.getStartTime(); Integer.valueOf(ruleVo.getStatus());
if (startTime != null) }catch (Exception e){
if (!validator.isValid(startTime)){ return Result.error("规则输入错误,请核对");
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
return Result.error("开始时间输入错误");
}
else {
Date date = simpleDateFormat.parse(startTime);
rulex.setStartTime(date);
}
String submitTime = ruleVo.getSubmitTime();
if (submitTime != null)
if (!validator.isValid(submitTime)){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
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);
return Result.error("规则序号已存在");
}
rulex.setRuleNo(ruleNo);
//规则编码
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 pmDescribe = ruleVo.getPmDescribe();
if (pmDescribe != null)
rulex.setPmDescribe(pmDescribe);
//分析图
String diagrams = ruleVo.getDiagrams();
if (diagrams != null)
rulex.setDiagrams(diagrams);
//版本号
Integer integer1;
try { try {
integer1 = Integer.valueOf(ruleVo.getVerison()); Double.valueOf(ruleVo.getVerisonStatus());
} catch (Exception e) { }catch (Exception e){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了 return Result.error("版本状态输入错误,请核对");
return Result.error("版本号输入错误,请核对");
} }
rulex.setVerison(String.valueOf(integer1));
//责任人、
String managerUsers = ruleVo.getManagerUsers();
if (managerUsers != null)
rulex.setManagerUsers(managerUsers);
//存入真实表
rulexService.save(rulex);
iRuleVoService.remove(null);
} }
return Result.ok("文件导入成功!"); return Result.error("文件导入失败!");
} }
@GetMapping(value = "/sort") @GetMapping(value = "/sort")

Loading…
Cancel
Save