|
|
|
@ -1,9 +1,11 @@ |
|
|
|
|
package org.jeecg.modules.demo.rulex.controller; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.NumberUtil; |
|
|
|
|
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 com.google.common.base.Joiner; |
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
@ -28,7 +30,9 @@ import org.jeecg.modules.fieldx.service.IFieldxService; |
|
|
|
|
import org.jeecg.modules.modulex.entity.Modulex; |
|
|
|
|
import org.jeecg.modules.modulex.service.IModulexService; |
|
|
|
|
import org.jeecg.modules.system.entity.SysDictItem; |
|
|
|
|
import org.jeecg.modules.system.entity.SysUser; |
|
|
|
|
import org.jeecg.modules.system.mapper.SysDictItemMapper; |
|
|
|
|
import org.jeecg.modules.system.service.ISysUserService; |
|
|
|
|
import org.jeecg.modules.tablex.entity.Tablex; |
|
|
|
|
import org.jeecg.modules.tablex.service.ITablexService; |
|
|
|
|
import org.jeecg.modules.tablex.ws.WebSocketUtils; |
|
|
|
@ -49,9 +53,13 @@ import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
import java.io.File; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.text.ParseException; |
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.regex.Matcher; |
|
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @Description: 规则管理 |
|
|
|
@ -91,6 +99,11 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
@Value("${jeecg.wordPath}") |
|
|
|
|
private String wordPath; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private ISysUserService iSysUserService; |
|
|
|
|
|
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 分页列表查询 |
|
|
|
|
* |
|
|
|
@ -267,7 +280,6 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
return Result.error("文件格式不正确"); |
|
|
|
|
} |
|
|
|
|
//校验时间
|
|
|
|
|
final DateValidator validator = new DateValidatorUsingDateFormat("yyyy-MM-dd hh:mm:ss"); |
|
|
|
|
ImportParams params = new ImportParams(); |
|
|
|
|
params.setTitleRows(2);//表格标题行数,默认0
|
|
|
|
|
params.setHeadRows(1);//表头行数,默认1
|
|
|
|
@ -291,25 +303,25 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
//必要字段判断空值
|
|
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
|
if ( |
|
|
|
|
list.get(i).getRuleNo() == null || |
|
|
|
|
list.get(i).getRuleCode() == null || |
|
|
|
|
// list.get(i).getPmDescribe() == null &&
|
|
|
|
|
list.get(i).getModuleId() == null || |
|
|
|
|
list.get(i).getFunctionId() == null || |
|
|
|
|
// list.get(i).getDiagrams() == null &&
|
|
|
|
|
list.get(i).getTableId() == null || |
|
|
|
|
// list.get(i).getFieldId() == null ||
|
|
|
|
|
list.get(i).getManagerUsers() == null || |
|
|
|
|
list.get(i).getWorkLevel() == null || |
|
|
|
|
list.get(i).getWorkStatus() == null || |
|
|
|
|
// list.get(i).getStartTime() == null &&
|
|
|
|
|
// list.get(i).getManagerUsers() == null &&
|
|
|
|
|
// list.get(i).getDuration() == null &&
|
|
|
|
|
// list.get(i).getSubmitTime() == null &&
|
|
|
|
|
list.get(i).getRealDuration() == null && |
|
|
|
|
list.get(i).getStatus() == null || |
|
|
|
|
list.get(i).getVerisonStatus() == null || |
|
|
|
|
list.get(i).getVerison() == null) { |
|
|
|
|
StringUtils.isBlank(list.get(i).getRuleNo()) || |
|
|
|
|
StringUtils.isBlank(list.get(i).getRuleCode()) || |
|
|
|
|
// StringUtils.isBlank() list.get(i).getPmDescribe() == null &&
|
|
|
|
|
StringUtils.isBlank(list.get(i).getModuleId() ) || |
|
|
|
|
StringUtils.isBlank(list.get(i).getFunctionId()) || |
|
|
|
|
// StringUtils.isBlank() list.get(i).getDiagrams() == null &&
|
|
|
|
|
StringUtils.isBlank( list.get(i).getTableId() ) || |
|
|
|
|
// StringUtils.isBlank() list.get(i).getFieldId() == null ||
|
|
|
|
|
StringUtils.isBlank( list.get(i).getManagerUsers())|| |
|
|
|
|
StringUtils.isBlank(list.get(i).getWorkLevel()) || |
|
|
|
|
StringUtils.isBlank(list.get(i).getWorkStatus()) || |
|
|
|
|
// StringUtils.isBlank() list.get(i).getStartTime() == null &&
|
|
|
|
|
// StringUtils.isBlank() list.get(i).getManagerUsers() == null &&
|
|
|
|
|
// StringUtils.isBlank() list.get(i).getDuration() == null &&
|
|
|
|
|
// StringUtils.isBlank() list.get(i).getSubmitTime() == null &&
|
|
|
|
|
StringUtils.isBlank(list.get(i).getRealDuration()) && |
|
|
|
|
StringUtils.isBlank(list.get(i).getStatus() ) || |
|
|
|
|
StringUtils.isBlank( list.get(i).getVerisonStatus()) || |
|
|
|
|
StringUtils.isBlank(list.get(i).getVerison()) ) { |
|
|
|
|
|
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
@ -337,70 +349,119 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
rulexList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//判断模块输入是否错误
|
|
|
|
|
List<Modulex> modulexList = iModulexService.list(); |
|
|
|
|
for (int i = 0; i < ruleVoList.size(); i++) { |
|
|
|
|
Rulex rulex = new Rulex(); |
|
|
|
|
RuleVo ruleVo = ruleVoList.get(i); |
|
|
|
|
//对应字段
|
|
|
|
|
String fieldId = ruleVo.getFieldId(); |
|
|
|
|
if(fieldId!=null){ |
|
|
|
|
LambdaQueryWrapper<Fieldx> rulexLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
rulexLambdaQueryWrapper.eq(Fieldx::getFieldName, fieldId); |
|
|
|
|
Fieldx byId = iFieldxService.getOne(rulexLambdaQueryWrapper); |
|
|
|
|
if (byId == null) { |
|
|
|
|
iRuleVoService.remove(null); |
|
|
|
|
|
|
|
|
|
String pModuleId = ruleVo.getModulePid(); |
|
|
|
|
String moduleId = ruleVo.getModuleId(); |
|
|
|
|
//对应模块
|
|
|
|
|
//判断上级模块是否存在
|
|
|
|
|
int n = 0; |
|
|
|
|
if (!StringUtils.isBlank(pModuleId) ) { |
|
|
|
|
//存在
|
|
|
|
|
String pid = ""; |
|
|
|
|
for (Modulex modulex : modulexList) { |
|
|
|
|
//判断表中是否存在
|
|
|
|
|
if (modulex.getModuleName().equals(pModuleId)) { |
|
|
|
|
|
|
|
|
|
pid = modulex.getId(); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
n++; |
|
|
|
|
if (n == modulexList.size()) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","第"+(i + 1) + "条数据,对应字段输入错误,请核对"); |
|
|
|
|
message.put("closeable", "true"); |
|
|
|
|
message.put("status", "第" + (i + 1) + "条数据,上级模块输入错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第"+(i + 1) +"条数据,对应字段输入错误,请核对"); |
|
|
|
|
return Result.error("第" + (i + 1) + "条数据,上级模块输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//判断上级模块+模块是否存在
|
|
|
|
|
for (Modulex modulex : modulexList) { |
|
|
|
|
if (modulex.getModuleName().equals(moduleId) && modulex.getPid().equals(pid)) { |
|
|
|
|
rulex.setModuleId(modulex.getId()); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
n++; |
|
|
|
|
if (n == modulexList.size()) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable", "true"); |
|
|
|
|
message.put("status", "第" + (i + 1) + "条数据,模块输入错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第" + (i + 1) + "条数据,模块输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
n = 0; |
|
|
|
|
//判断模块是否存在
|
|
|
|
|
for (Modulex modulex : modulexList) { |
|
|
|
|
if (modulex.getModuleName().equals(moduleId) && modulex.getPid() == null) { |
|
|
|
|
rulex.setModuleId(modulex.getId()); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
n++; |
|
|
|
|
if (n == modulexList.size()) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable", "true"); |
|
|
|
|
message.put("status", "第" + (i + 1) + "条数据,模块输入错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第" + (i + 1) + "条数据,模块输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
rulex.setFieldId(byId.getId()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//对应功能
|
|
|
|
|
String functionName = ruleVo.getFunctionId(); |
|
|
|
|
LambdaQueryWrapper<Functionx> functionxLambdaQueryWrapper = new LambdaQueryWrapper<Functionx>(); |
|
|
|
|
functionxLambdaQueryWrapper.eq(Functionx::getFunctionName, functionName); |
|
|
|
|
Functionx byId1 = functionxService.getOne(functionxLambdaQueryWrapper); |
|
|
|
|
if (byId1 == null) { |
|
|
|
|
functionxLambdaQueryWrapper.eq(Functionx::getFunctionName, functionName).eq(Functionx::getModuleId, rulex.getModuleId()); |
|
|
|
|
Functionx functionx = functionxService.getOne(functionxLambdaQueryWrapper); |
|
|
|
|
if (functionx == null) { |
|
|
|
|
iRuleVoService.remove(null); |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","第"+(i + 1) +"条数据,对应功能输入错误,请核对"); |
|
|
|
|
message.put("closeable", "true"); |
|
|
|
|
message.put("status", "第" + (i + 1) + "条数据,对应功能输入错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第"+(i + 1) +"条数据,对应功能输入错误,请核对"); |
|
|
|
|
return Result.error("第" + (i + 1) + "条数据,对应功能输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
rulex.setFunctionId(byId1.getId()); |
|
|
|
|
//对应模块
|
|
|
|
|
String moduleName = ruleVo.getModuleId(); |
|
|
|
|
LambdaQueryWrapper<Modulex> modulexLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
modulexLambdaQueryWrapper.eq(Modulex::getModuleName, moduleName); |
|
|
|
|
Modulex byId2 = iModulexService.getOne(modulexLambdaQueryWrapper); |
|
|
|
|
if (byId2 == null) { |
|
|
|
|
rulex.setFunctionId(functionx.getId()); |
|
|
|
|
//
|
|
|
|
|
//对应实体
|
|
|
|
|
String tableId = ruleVo.getTableId(); |
|
|
|
|
LambdaQueryWrapper<Tablex> tableLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
tableLambdaQueryWrapper.eq(Tablex::getTableName, tableId).eq(Tablex::getModuleId, rulex.getModuleId()); |
|
|
|
|
Tablex tablex = iTablexService.getOne(tableLambdaQueryWrapper); |
|
|
|
|
if (tablex == null) { |
|
|
|
|
|
|
|
|
|
iRuleVoService.remove(null); |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","第"+(i + 1) +"条数据,对应模块输入错误,请核对"); |
|
|
|
|
message.put("closeable", "true"); |
|
|
|
|
message.put("status", "第" + (i + 1) + "条数据,对应实体输入错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第"+(i + 1) +"条数据,对应模块输入错误,请核对"); |
|
|
|
|
return Result.error("第" + (i + 1) + "条数据,对应实体输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
rulex.setModuleId(byId2.getId()); |
|
|
|
|
//对应实体
|
|
|
|
|
String tableId = ruleVo.getTableId(); |
|
|
|
|
LambdaQueryWrapper<Tablex> tableLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
tableLambdaQueryWrapper.eq(Tablex::getTableName, tableId); |
|
|
|
|
Tablex byId3 = iTablexService.getOne(tableLambdaQueryWrapper); |
|
|
|
|
if (byId3 == null) { |
|
|
|
|
rulex.setTableId(tablex.getId()); |
|
|
|
|
|
|
|
|
|
//对应字段
|
|
|
|
|
String fieldId = ruleVo.getFieldId(); |
|
|
|
|
String tableId1 = rulex.getTableId(); |
|
|
|
|
if (!StringUtils.isBlank(fieldId) ) { |
|
|
|
|
LambdaQueryWrapper<Fieldx> rulexLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
rulexLambdaQueryWrapper.eq(Fieldx::getFieldName, fieldId).eq(Fieldx::getTableId, tableId1); |
|
|
|
|
Fieldx fieldx = iFieldxService.getOne(rulexLambdaQueryWrapper); |
|
|
|
|
if (fieldx == null) { |
|
|
|
|
iRuleVoService.remove(null); |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","第"+(i + 1) +"条数据,对应实体输入错误,请核对"); |
|
|
|
|
message.put("closeable", "true"); |
|
|
|
|
message.put("status", "第" + (i + 1) + "条数据,对应字段输入错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第"+(i + 1) +"条数据,对应实体输入错误,请核对"); |
|
|
|
|
return Result.error("第" + (i + 1) + "条数据,对应字段输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
rulex.setFieldId(fieldx.getId()); |
|
|
|
|
} |
|
|
|
|
rulex.setTableId(byId3.getId()); |
|
|
|
|
Double aDouble = null; |
|
|
|
|
try { |
|
|
|
|
if (aDouble != null) |
|
|
|
@ -409,10 +470,10 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
|
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","第"+(i + 1) +"条数据,任务时长输入错误,请核对"); |
|
|
|
|
message.put("closeable", "true"); |
|
|
|
|
message.put("status", "第" + (i + 1) + "条数据,任务时长输入错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第"+(i + 1) +"条数据,任务时长输入错误,请核对"); |
|
|
|
|
return Result.error("第" + (i + 1) + "条数据,任务时长输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Double d; |
|
|
|
@ -421,10 +482,10 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
|
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","第"+(i + 1) +"条数据,实际时长输入错误,请核对"); |
|
|
|
|
message.put("closeable", "true"); |
|
|
|
|
message.put("status", "第" + (i + 1) + "条数据,实际时长输入错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第"+(i + 1) +"条数据,实际时长输入错误,请核对"); |
|
|
|
|
return Result.error("第" + (i + 1) + "条数据,实际时长输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
rulex.setRealDuration(d); |
|
|
|
|
Integer integer; |
|
|
|
@ -433,10 +494,10 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
|
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","第"+(i + 1) +"条数据,任务等级输入错误,请核对"); |
|
|
|
|
message.put("closeable", "true"); |
|
|
|
|
message.put("status", "第" + (i + 1) + "条数据,任务等级输入错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第"+(i + 1) +"条数据,任务等级输入错误,请核对"); |
|
|
|
|
return Result.error("第" + (i + 1) + "条数据,任务等级输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
rulex.setWorkLevel(integer); |
|
|
|
|
String workStatus = ruleVo.getWorkStatus(); |
|
|
|
@ -459,10 +520,10 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
else { |
|
|
|
|
iRuleVoService.remove(null); |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","第"+(i + 1) +"条数据,任务状态输入错误,请核对"); |
|
|
|
|
message.put("closeable", "true"); |
|
|
|
|
message.put("status", "第" + (i + 1) + "条数据,任务状态输入错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第"+(i + 1) +"条数据,任务状态输入错误,请核对"); |
|
|
|
|
return Result.error("第" + (i + 1) + "条数据,任务状态输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
String status = ruleVo.getStatus(); |
|
|
|
|
// LambdaQueryWrapper<SysDictItem> sysDictItemLambdaQueryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
|
@ -477,10 +538,10 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
else { |
|
|
|
|
iRuleVoService.remove(null); |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","第"+(i + 1) +"条数据,规则状态输入错误,请核对"); |
|
|
|
|
message.put("closeable", "true"); |
|
|
|
|
message.put("status", "第" + (i + 1) + "条数据,规则状态输入错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第"+(i + 1) +"条数据,规则状态输入错误,请核对"); |
|
|
|
|
return Result.error("第" + (i + 1) + "条数据,规则状态输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
String verisonStatus = ruleVo.getVerisonStatus(); |
|
|
|
|
LambdaQueryWrapper<SysDictItem> sysDictItemLambdaQueryWrapper3 = new LambdaQueryWrapper<>(); |
|
|
|
@ -489,55 +550,88 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
if (sysDictItem3 == null) { |
|
|
|
|
iRuleVoService.remove(null); |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","第"+(i + 1) +"条数据,版本状态输入错误,请核对"); |
|
|
|
|
message.put("closeable", "true"); |
|
|
|
|
message.put("status", "第" + (i + 1) + "条数据,版本状态输入错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第"+(i + 1) +"条数据,版本状态输入错误,请核对"); |
|
|
|
|
return Result.error("第" + (i + 1) + "条数据,版本状态输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
rulex.setVerisonStatus(Integer.valueOf(sysDictItem3.getItemValue())); |
|
|
|
|
|
|
|
|
|
Date date; |
|
|
|
|
//String转Date
|
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
String startTime = ruleVo.getStartTime(); |
|
|
|
|
if (!StringUtils.isBlank(startTime)) { |
|
|
|
|
String time = getTime(startTime); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
String startTime = ruleVo.getStartTime(); |
|
|
|
|
if (startTime != null) |
|
|
|
|
if (!validator.isValid(startTime)) { |
|
|
|
|
date = simpleDateFormat.parse(time); |
|
|
|
|
rulex.setStartTime(date); |
|
|
|
|
} catch (ParseException e) { |
|
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
|
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","第"+(i + 1) +"条数据,开始时间输入错误"); |
|
|
|
|
message.put("closeable", "true"); |
|
|
|
|
message.put("status", "第" + (i + 1) + "条数据,开始时间输入错误"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第"+(i + 1) +"条数据,开始时间输入错误"); |
|
|
|
|
} else { |
|
|
|
|
Date date = simpleDateFormat.parse(startTime); |
|
|
|
|
rulex.setStartTime(date); |
|
|
|
|
return Result.error("第" + (i + 1) + "条数据,开始时间输入错误"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
String submitTime = ruleVo.getSubmitTime(); |
|
|
|
|
if (submitTime != null) |
|
|
|
|
if (!validator.isValid(submitTime)) { |
|
|
|
|
if (!StringUtils.isBlank(submitTime)){ |
|
|
|
|
String submitTimeT = getTime(submitTime); |
|
|
|
|
try { |
|
|
|
|
date = simpleDateFormat.parse(submitTimeT); |
|
|
|
|
rulex.setSubmitTime(date); |
|
|
|
|
} catch (ParseException e) { |
|
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
|
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","第"+(i + 1) +"条数据,提交时间输入错误"); |
|
|
|
|
message.put("closeable", "true"); |
|
|
|
|
message.put("status", "第" + (i + 1) + "条数据,开始时间输入错误"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第"+(i + 1) +"条数据,提交时间输入错误"); |
|
|
|
|
} else { |
|
|
|
|
Date date1 = simpleDateFormat.parse(submitTime); |
|
|
|
|
rulex.setSubmitTime(date1); |
|
|
|
|
return Result.error("第" + (i + 1) + "条数据,开始时间输入错误"); |
|
|
|
|
} |
|
|
|
|
} catch (ParseException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
rulex.setRuleNo(ruleVo.getRuleNo()); |
|
|
|
|
|
|
|
|
|
//规则序号
|
|
|
|
|
String ruleNo = ruleVo.getRuleNo(); |
|
|
|
|
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 functionCode1 = functionx.getFunctionCode(); |
|
|
|
|
if (ruleCode == null) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable", "true"); |
|
|
|
|
message.put("status", "第" + (i + 1) + "条数据,规则编码错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第" + (i + 1) + "条数据,规则编码错误,请核对"); |
|
|
|
|
} |
|
|
|
|
//截取到功能编码校验(去除后三位)
|
|
|
|
|
if (!ruleCode.substring(0, ruleCode.length() - 3).equals(functionCode1)) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable", "true"); |
|
|
|
|
message.put("status", "第" + (i + 1) + "条数据,规则编码错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第" + (i + 1) + "条数据,规则编码错误,请核对"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//后三位
|
|
|
|
|
String substring = ruleCode.substring(ruleCode.length() - 3); |
|
|
|
|
try { |
|
|
|
|
Integer integer1 = Integer.valueOf(substring); |
|
|
|
|
if (integer1 < 0) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable", "true"); |
|
|
|
|
message.put("status", "第" + (i + 1) + "条数据,规则编码错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第" + (i + 1) + "条数据,规则编码错误,请核对"); |
|
|
|
|
} |
|
|
|
|
} catch (NumberFormatException e) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable", "true"); |
|
|
|
|
message.put("status", "第" + (i + 1) + "条数据,规则编码错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第" + (i + 1) + "条数据,规则编码错误,请核对"); |
|
|
|
|
} |
|
|
|
|
rulex.setRuleCode(ruleCode); |
|
|
|
|
//规则描述
|
|
|
|
|
String pmDescribe = ruleVo.getPmDescribe(); |
|
|
|
|
if (pmDescribe != null) |
|
|
|
@ -547,22 +641,64 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
if (diagrams != null) |
|
|
|
|
rulex.setDiagrams(diagrams); |
|
|
|
|
//版本号
|
|
|
|
|
Integer integer1; |
|
|
|
|
String verison = ruleVo.getVerison(); |
|
|
|
|
if (ruleVo.getVerison() == null || verison.length() >= 5) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable", "true"); |
|
|
|
|
message.put("status", "第" + (i + 1) + "条数据,版本号错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第" + (i + 1) + "条数据,版本号错误,请核对"); |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
integer1 = Integer.valueOf(ruleVo.getVerison()); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
|
|
|
|
|
Integer integer2 = Integer.valueOf(verison); |
|
|
|
|
if (integer2 > 0) |
|
|
|
|
rulex.setVerison(String.valueOf(integer2)); |
|
|
|
|
else { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","第"+(i + 1) +"条数据,版本号输入错误,请核对"); |
|
|
|
|
message.put("closeable", "true"); |
|
|
|
|
message.put("status", "第" + (i + 1) + "条数据,版本号输入错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第" + (i + 1) + "条数据,版本号输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
} catch (NumberFormatException e) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("closeable", "true"); |
|
|
|
|
message.put("status", "第" + (i + 1) + "条数据,版本号输入错误,请核对"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("第"+(i + 1) +"条数据,版本号输入错误,请核对"); |
|
|
|
|
return Result.error("第" + (i + 1) + "条数据,版本号输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
rulex.setVerison(String.valueOf(integer1)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//责任人
|
|
|
|
|
String managerUsers = ruleVo.getManagerUsers(); |
|
|
|
|
if (managerUsers != null) |
|
|
|
|
rulex.setManagerUsers(managerUsers); |
|
|
|
|
if (managerUsers != null) { |
|
|
|
|
LambdaQueryWrapper<SysUser> sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
String[] split = managerUsers.split(","); |
|
|
|
|
sysUserLambdaQueryWrapper.in(SysUser::getUsername, split); |
|
|
|
|
List<SysUser> iSysUserServiceOne = iSysUserService.list(sysUserLambdaQueryWrapper); |
|
|
|
|
if (iSysUserServiceOne == null) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("status", "导入失败,责任人信息查询不到"); |
|
|
|
|
message.put("closeable", "true"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("导入失败,责任人信息查询不到"); |
|
|
|
|
} |
|
|
|
|
if (iSysUserServiceOne.size() > 1) { |
|
|
|
|
List<String> list3 = iSysUserServiceOne.stream().map(SysUser::getId).collect(Collectors.toList()); |
|
|
|
|
if (list3 == null) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("status", "导入失败,责任人信息查询不到"); |
|
|
|
|
message.put("closeable", "true"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("导入失败,责任人信息查询不到"); |
|
|
|
|
} |
|
|
|
|
rulex.setManagerUsers(Joiner.on(",").join(list3)); |
|
|
|
|
} else if (iSysUserServiceOne.size() == 1) { |
|
|
|
|
String id = iSysUserServiceOne.get(0).getId(); |
|
|
|
|
rulex.setManagerUsers(id); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
message.put("status", "正在读取数据"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
//存入集合待存真实表
|
|
|
|
@ -617,5 +753,51 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 将日期数字转为时间格式 |
|
|
|
|
* daysDuration = 44745 |
|
|
|
|
* |
|
|
|
|
* @param daysDuration |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public String getTime(String daysDuration) { |
|
|
|
|
//如果不是数字
|
|
|
|
|
if(!isNumeric(daysDuration)){ |
|
|
|
|
return daysDuration; |
|
|
|
|
} |
|
|
|
|
//如果是数字
|
|
|
|
|
BigDecimal bd = new BigDecimal(daysDuration); |
|
|
|
|
int days = bd.intValue();//天数
|
|
|
|
|
int mills = (int) Math.round(bd.subtract(new BigDecimal(days)).doubleValue() * 24 * 3600); |
|
|
|
|
|
|
|
|
|
//获取时间
|
|
|
|
|
Calendar c = Calendar.getInstance(); |
|
|
|
|
c.set(1900, 0, 1); |
|
|
|
|
c.add(Calendar.DATE, days); |
|
|
|
|
int hour = mills / 3600; |
|
|
|
|
int minute = (mills - hour * 3600) / 60; |
|
|
|
|
int second = mills - hour * 3600 - minute * 60; |
|
|
|
|
c.set(Calendar.HOUR_OF_DAY, hour); |
|
|
|
|
c.set(Calendar.MINUTE, minute); |
|
|
|
|
c.set(Calendar.SECOND, second); |
|
|
|
|
|
|
|
|
|
return simpleDateFormat.format(c.getTime()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 校验是否数据含小数点 |
|
|
|
|
* |
|
|
|
|
* @param str |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private static boolean isNumeric(String str){ |
|
|
|
|
Pattern pattern = Pattern.compile("[0-9]+\\.*[0-9]*"); |
|
|
|
|
Matcher isNum = pattern.matcher(str); |
|
|
|
|
if(!isNum.matches()){ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|