|
|
|
@ -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; |
|
|
|
@ -52,6 +56,7 @@ import java.io.IOException; |
|
|
|
|
import java.text.ParseException; |
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @Description: 规则管理 |
|
|
|
@ -91,6 +96,9 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
@Value("${jeecg.wordPath}") |
|
|
|
|
private String wordPath; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private ISysUserService iSysUserService; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 分页列表查询 |
|
|
|
|
* |
|
|
|
@ -533,11 +541,42 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
rulex.setRuleNo(ruleVo.getRuleNo()); |
|
|
|
|
//规则编码
|
|
|
|
|
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 = byId1.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 +586,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) +"条数据,版本号输入错误,请核对"); |
|
|
|
|
return Result.error("第" + (i + 1) + "条数据,版本号输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
rulex.setVerison(String.valueOf(integer1)); |
|
|
|
|
} 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) + "条数据,版本号输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//责任人
|
|
|
|
|
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); |
|
|
|
|
//存入集合待存真实表
|
|
|
|
|