|
|
|
@ -247,14 +247,8 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
message.put("isError", "false"); |
|
|
|
|
message.put("closeable","false"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
//判断文件是否为空
|
|
|
|
|
if (file == null) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","文件上传失败,请重新上传"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("文件上传失败,请重新上传"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 判断文件是否是表格
|
|
|
|
|
String originalFilename = file.getOriginalFilename(); |
|
|
|
|
if (StringUtils.isBlank(originalFilename) || |
|
|
|
@ -268,19 +262,22 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
} |
|
|
|
|
//校验时间
|
|
|
|
|
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(); |
|
|
|
|
params.setTitleRows(2);//表格标题行数,默认0
|
|
|
|
|
params.setHeadRows(1);//表头行数,默认1
|
|
|
|
|
params.setNeedSave(true);//是否需要保存上传的Excel,默认为false
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
message.put("status", "数据预读入"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
List<RuleVo> list = null; |
|
|
|
|
try { |
|
|
|
|
list = ExcelImportUtil.importExcel(file.getInputStream(), RuleVo.class, params); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
List<RuleVo> list = ExcelImportUtil.importExcel(file.getInputStream(), RuleVo.class, params); |
|
|
|
|
if (list == null || list.size() <= 0) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
@ -288,9 +285,10 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
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 &&
|
|
|
|
@ -310,21 +308,45 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
list.get(i).getStatus() == null || |
|
|
|
|
list.get(i).getVerisonStatus() == null || |
|
|
|
|
list.get(i).getVerison() == null) { |
|
|
|
|
|
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
num++; |
|
|
|
|
if (num == 0) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","文件导入失败:"+"第"+(i + 1) + "条存在必填数据为空,请核对"); |
|
|
|
|
message.put("status","文件导入失败:导入模板不匹配"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("文件导入失败:"+"第"+(i + 1) + "条不能为空,请核对"); |
|
|
|
|
return Result.error("文件导入失败:导入模板不匹配"); |
|
|
|
|
// } else if (num!=list.size()) {
|
|
|
|
|
// return Result.error("文件导入失败:请检查填写文字");
|
|
|
|
|
} |
|
|
|
|
//存入预存表
|
|
|
|
|
iRuleVoService.save(list.get(i)); |
|
|
|
|
} |
|
|
|
|
List<Rulex> rulexList; |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
//update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示
|
|
|
|
|
String msg = e.getMessage(); |
|
|
|
|
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 { |
|
|
|
|
|
|
|
|
|
return Result.error("文件导入失败:" + e.getMessage()); |
|
|
|
|
} |
|
|
|
|
//update-end-author:taoyan date:20211124 for: 导入数据重复增加提示
|
|
|
|
|
} finally { |
|
|
|
|
try { |
|
|
|
|
//取出预存表校验字段
|
|
|
|
|
List<RuleVo> ruleVoList = iRuleVoService.list(); |
|
|
|
|
file.getInputStream().close(); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<RuleVo> ruleVoList = iRuleVoService.list(); |
|
|
|
|
if (ruleVoList.size() <= 0 || ruleVoList == null) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
@ -335,7 +357,6 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
// 将总的记录数传递给前端
|
|
|
|
|
message.put("records", String.valueOf(ruleVoList.size())); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
rulexList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < ruleVoList.size(); i++) { |
|
|
|
|
Rulex rulex = new Rulex(); |
|
|
|
@ -349,9 +370,9 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
iRuleVoService.remove(null); |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","第"+(i + 1) + "条数据,对应字段输入错误,请核对"); |
|
|
|
|
message.put("status","字段输入错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第"+(i + 1) +"条数据,对应字段输入错误,请核对"); |
|
|
|
|
return Result.error("字段输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
rulex.setFieldId(byId.getId()); |
|
|
|
|
//对应功能
|
|
|
|
@ -363,9 +384,9 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
iRuleVoService.remove(null); |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","第"+(i + 1) +"条数据,对应功能输入错误,请核对"); |
|
|
|
|
message.put("status","功能输入错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第"+(i + 1) +"条数据,对应功能输入错误,请核对"); |
|
|
|
|
return Result.error("功能输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
rulex.setFunctionId(byId1.getId()); |
|
|
|
|
//对应模块
|
|
|
|
@ -378,9 +399,9 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
iRuleVoService.remove(null); |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","第"+(i + 1) +"条数据,对应模块输入错误,请核对"); |
|
|
|
|
message.put("status","模块输入错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第"+(i + 1) +"条数据,对应模块输入错误,请核对"); |
|
|
|
|
return Result.error("模块输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
rulex.setModuleId(byId2.getId()); |
|
|
|
|
//对应实体
|
|
|
|
@ -393,9 +414,9 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
iRuleVoService.remove(null); |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","第"+(i + 1) +"条数据,对应实体输入错误,请核对"); |
|
|
|
|
message.put("status","实体输入错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第"+(i + 1) +"条数据,对应实体输入错误,请核对"); |
|
|
|
|
return Result.error("实体输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
rulex.setTableId(byId3.getId()); |
|
|
|
|
Double aDouble = null; |
|
|
|
@ -407,9 +428,9 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
|
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","第"+(i + 1) +"条数据,任务时长输入错误,请核对"); |
|
|
|
|
message.put("status","任务时长输入错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第"+(i + 1) +"条数据,任务时长输入错误,请核对"); |
|
|
|
|
return Result.error("任务时长输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Double d; |
|
|
|
@ -419,9 +440,9 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
|
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","第"+(i + 1) +"条数据,实际时长输入错误,请核对"); |
|
|
|
|
message.put("status","实际时长输入错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第"+(i + 1) +"条数据,实际时长输入错误,请核对"); |
|
|
|
|
return Result.error("实际时长输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
rulex.setRealDuration(d); |
|
|
|
|
Integer integer; |
|
|
|
@ -431,15 +452,15 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
|
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","第"+(i + 1) +"条数据,任务等级输入错误,请核对"); |
|
|
|
|
message.put("status","任务等级输入错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第"+(i + 1) +"条数据,任务等级输入错误,请核对"); |
|
|
|
|
return Result.error("任务等级输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
rulex.setWorkLevel(integer); |
|
|
|
|
String workStatus = ruleVo.getWorkStatus(); |
|
|
|
|
// LambdaQueryWrapper<SysDictItem> sysDictItemLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
// sysDictItemLambdaQueryWrapper.eq(SysDictItem::getItemText, workStatus).eq(SysDictItem::getDictId, "1645268542514421762");
|
|
|
|
|
// SysDictItem sysDictItem = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper);
|
|
|
|
|
// LambdaQueryWrapper<SysDictItem> sysDictItemLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
// sysDictItemLambdaQueryWrapper.eq(SysDictItem::getItemText, workStatus).eq(SysDictItem::getDictId, "1645268542514421762");
|
|
|
|
|
// SysDictItem sysDictItem = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper);
|
|
|
|
|
|
|
|
|
|
if (workStatus.equals("未发布")) |
|
|
|
|
rulex.setWorkStatus(0); |
|
|
|
@ -457,14 +478,14 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
iRuleVoService.remove(null); |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","第"+(i + 1) +"条数据,任务状态输入错误,请核对"); |
|
|
|
|
message.put("status","任务状态输入错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第"+(i + 1) +"条数据,任务状态输入错误,请核对"); |
|
|
|
|
return Result.error("任务状态输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
String status = ruleVo.getStatus(); |
|
|
|
|
// LambdaQueryWrapper<SysDictItem> sysDictItemLambdaQueryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
|
|
// sysDictItemLambdaQueryWrapper2.eq(SysDictItem::getItemText, status).eq(SysDictItem::getDictId, "1645264493205491713");
|
|
|
|
|
// SysDictItem sysDictItem2 = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper2);
|
|
|
|
|
// LambdaQueryWrapper<SysDictItem> sysDictItemLambdaQueryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
|
|
// sysDictItemLambdaQueryWrapper2.eq(SysDictItem::getItemText, status).eq(SysDictItem::getDictId, "1645264493205491713");
|
|
|
|
|
// SysDictItem sysDictItem2 = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper2);
|
|
|
|
|
if (status.equals("正常")) |
|
|
|
|
rulex.setStatus(1); |
|
|
|
|
else if (status.equals("停用")) |
|
|
|
@ -475,9 +496,9 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
iRuleVoService.remove(null); |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","第"+(i + 1) +"条数据,规则状态输入错误,请核对"); |
|
|
|
|
message.put("status","规则状态输入错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第"+(i + 1) +"条数据,规则状态输入错误,请核对"); |
|
|
|
|
return Result.error("规则状态输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
String verisonStatus = ruleVo.getVerisonStatus(); |
|
|
|
|
LambdaQueryWrapper<SysDictItem> sysDictItemLambdaQueryWrapper3 = new LambdaQueryWrapper<>(); |
|
|
|
@ -487,9 +508,9 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
iRuleVoService.remove(null); |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","第"+(i + 1) +"条数据,版本状态输入错误,请核对"); |
|
|
|
|
message.put("status","版本状态输入错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第"+(i + 1) +"条数据,版本状态输入错误,请核对"); |
|
|
|
|
return Result.error("版本状态输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
rulex.setVerisonStatus(Integer.valueOf(sysDictItem3.getItemValue())); |
|
|
|
@ -504,9 +525,9 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
|
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","第"+(i + 1) +"条数据,开始时间输入错误"); |
|
|
|
|
message.put("status","开始时间输入错误"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第"+(i + 1) +"条数据,开始时间输入错误"); |
|
|
|
|
return Result.error("开始时间输入错误"); |
|
|
|
|
} else { |
|
|
|
|
Date date = simpleDateFormat.parse(startTime); |
|
|
|
|
rulex.setStartTime(date); |
|
|
|
@ -517,9 +538,9 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
|
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","第"+(i + 1) +"条数据,提交时间输入错误"); |
|
|
|
|
message.put("status","提交时间输入错误"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第"+(i + 1) +"条数据,提交时间输入错误"); |
|
|
|
|
return Result.error("提交时间输入错误"); |
|
|
|
|
} else { |
|
|
|
|
Date date1 = simpleDateFormat.parse(submitTime); |
|
|
|
|
rulex.setSubmitTime(date1); |
|
|
|
@ -527,13 +548,25 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
} catch (ParseException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
rulex.setRuleNo(ruleVo.getRuleNo()); |
|
|
|
|
|
|
|
|
|
//规则序号
|
|
|
|
|
String ruleNo = ruleVo.getRuleNo(); |
|
|
|
|
List<String> 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); |
|
|
|
|
//规则编码
|
|
|
|
|
String ruleCode = ruleVo.getRuleCode(); |
|
|
|
|
Functionx functionxServiceById = functionxService.getById(byId1.getId()); |
|
|
|
|
String functionCode = functionxServiceById.getFunctionCode(); |
|
|
|
|
// if (!ruleCode.matches(functionCode))
|
|
|
|
|
// return Result.error("规则编码错误");
|
|
|
|
|
// if (!ruleCode.matches(functionCode))
|
|
|
|
|
// return Result.error("规则编码错误");
|
|
|
|
|
rulex.setRuleCode(functionCode); |
|
|
|
|
//规则描述
|
|
|
|
|
String pmDescribe = ruleVo.getPmDescribe(); |
|
|
|
@ -551,36 +584,25 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
|
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","第"+(i + 1) +"条数据,版本号输入错误,请核对"); |
|
|
|
|
message.put("status","版本号输入错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第"+(i + 1) +"条数据,版本号输入错误,请核对"); |
|
|
|
|
return Result.error("版本号输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
rulex.setVerison(String.valueOf(integer1)); |
|
|
|
|
//责任人
|
|
|
|
|
//责任人、
|
|
|
|
|
String managerUsers = ruleVo.getManagerUsers(); |
|
|
|
|
if (managerUsers != null) |
|
|
|
|
rulex.setManagerUsers(managerUsers); |
|
|
|
|
message.put("status", "正在读取数据"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
//存入集合待存真实表
|
|
|
|
|
rulexList.add(rulex); |
|
|
|
|
} |
|
|
|
|
} finally { |
|
|
|
|
//清理预存表
|
|
|
|
|
//存入真实表
|
|
|
|
|
rulexService.saveRule(rulex, loginUser, message, i + 1); |
|
|
|
|
iRuleVoService.remove(null); |
|
|
|
|
} |
|
|
|
|
//存入真实表
|
|
|
|
|
Boolean aBoolean = rulexService.saveRule(rulexList, loginUser, message); |
|
|
|
|
|
|
|
|
|
if (aBoolean) { |
|
|
|
|
message.put("status", "导入成功"); |
|
|
|
|
message.put("closeable", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.ok("文件导入成功!"); |
|
|
|
|
}else { |
|
|
|
|
return Result.error("文件导入失败!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/sort") |
|
|
|
|