|
|
@ -1,9 +1,11 @@ |
|
|
|
package org.jeecg.modules.demo.rulex.controller; |
|
|
|
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.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
|
|
|
import com.google.common.base.Joiner; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
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.entity.Modulex; |
|
|
|
import org.jeecg.modules.modulex.service.IModulexService; |
|
|
|
import org.jeecg.modules.modulex.service.IModulexService; |
|
|
|
import org.jeecg.modules.system.entity.SysDictItem; |
|
|
|
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.mapper.SysDictItemMapper; |
|
|
|
|
|
|
|
import org.jeecg.modules.system.service.ISysUserService; |
|
|
|
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.jeecg.modules.tablex.ws.WebSocketUtils; |
|
|
@ -52,6 +56,7 @@ import java.io.IOException; |
|
|
|
import java.text.ParseException; |
|
|
|
import java.text.ParseException; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @Description: 规则管理 |
|
|
|
* @Description: 规则管理 |
|
|
@ -91,6 +96,9 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
@Value("${jeecg.wordPath}") |
|
|
|
@Value("${jeecg.wordPath}") |
|
|
|
private String wordPath; |
|
|
|
private String wordPath; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private ISysUserService iSysUserService; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 分页列表查询 |
|
|
|
* 分页列表查询 |
|
|
|
* |
|
|
|
* |
|
|
@ -533,11 +541,42 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
rulex.setRuleNo(ruleVo.getRuleNo()); |
|
|
|
rulex.setRuleNo(ruleVo.getRuleNo()); |
|
|
|
//规则编码
|
|
|
|
//规则编码
|
|
|
|
String ruleCode = ruleVo.getRuleCode(); |
|
|
|
String ruleCode = ruleVo.getRuleCode(); |
|
|
|
Functionx functionxServiceById = functionxService.getById(byId1.getId()); |
|
|
|
String functionCode1 = byId1.getFunctionCode(); |
|
|
|
String functionCode = functionxServiceById.getFunctionCode(); |
|
|
|
if (ruleCode == null) { |
|
|
|
// if (!ruleCode.matches(functionCode))
|
|
|
|
message.put("isError", "true"); |
|
|
|
// return Result.error("规则编码错误");
|
|
|
|
message.put("closeable", "true"); |
|
|
|
rulex.setRuleCode(functionCode); |
|
|
|
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(); |
|
|
|
String pmDescribe = ruleVo.getPmDescribe(); |
|
|
|
if (pmDescribe != null) |
|
|
|
if (pmDescribe != null) |
|
|
@ -547,22 +586,64 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
if (diagrams != null) |
|
|
|
if (diagrams != null) |
|
|
|
rulex.setDiagrams(diagrams); |
|
|
|
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 { |
|
|
|
try { |
|
|
|
integer1 = Integer.valueOf(ruleVo.getVerison()); |
|
|
|
Integer integer2 = Integer.valueOf(verison); |
|
|
|
} catch (Exception e) { |
|
|
|
if (integer2>0) |
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
|
|
|
|
rulex.setVerison(String.valueOf(integer2)); |
|
|
|
|
|
|
|
else { |
|
|
|
message.put("isError", "true"); |
|
|
|
message.put("isError", "true"); |
|
|
|
message.put("closeable","true"); |
|
|
|
message.put("closeable", "true"); |
|
|
|
message.put("status","第"+(i + 1) +"条数据,版本号输入错误,请核对"); |
|
|
|
message.put("status", "第" + (i + 1) + "条数据,版本号输入错误,请核对"); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
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(); |
|
|
|
String managerUsers = ruleVo.getManagerUsers(); |
|
|
|
if (managerUsers != null) |
|
|
|
if (managerUsers != null){ |
|
|
|
rulex.setManagerUsers(managerUsers); |
|
|
|
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", "正在读取数据"); |
|
|
|
message.put("status", "正在读取数据"); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
//存入集合待存真实表
|
|
|
|
//存入集合待存真实表
|
|
|
|