导入规则修改

dev^2
zjh 1 year ago
parent 9a5f1c11a1
commit 5126e009a2
  1. 17
      ant-design-vue-jeecg/src/views/modulex/ModulexList.vue
  2. 111
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/controller/RulexController.java
  3. 15
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/entity/RuleVo.java
  4. 2
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/entity/Rulex.java

@ -602,22 +602,25 @@ export default {
},
ruleData: function () {
return {
note: ['对应模块(必填):填写正确的模块名称',
note: [
'对应项目(必填):填写正确的项目名称',
'上级模块(非必填):填写正确的上级模块名称',
'对应模块(必填):填写正确的模块名称',
'对应功能(必填):填写正确的功能名称',
'对应实体(必填):填写正确的实体名称',
'顺序号(必填):同功能下不重复',
'对应实体(非必填):填写正确的实体名称',
'对应字段(非必填):填写正确的字段名称',
'顺序号(必填):同功能下不重复,为正整数且与规则编码顺序号相等',
'规则编码(必填):功能编码+顺序号(格式001)',
'规则描述(非必填)',
'分析图(非必填)',
'责任人(非必填):如果有多个值请使用,分割',
'责任人(非必填):如果有多个值请使用逗号分割',
'任务等级(必填):值:1、2、3、4、5个等级',
'任务状态(必填):值:未发布、已发布、开发中、已完成、已撤回、已取消',
'版本状态(必填): 可填入值为[当前、历史]',
'规则状态(必填): 值:正常、停用、废弃',
'开始时间(非必填):时间格式2023-04-11 14:21:22',
'任务时长(非必填)',
'任务时长(非必填):正整数',
'提交时间(非必填):时间格式2023-04-11 14:21:22',
'实际时长(非必填)',
'实际时长(非必填):正整数',
'规则状态(必填):值:正常、停用、废弃',
'版本号(必填):请填写小于五位数的正整数'
],

@ -29,6 +29,8 @@ import org.jeecg.modules.fieldx.entity.Fieldx;
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.projectx.entity.Projectx;
import org.jeecg.modules.projectx.service.impl.ProjectxServiceImpl;
import org.jeecg.modules.system.entity.SysDictItem;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.mapper.SysDictItemMapper;
@ -96,6 +98,9 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
@Autowired
private WebSocketUtils webSocketUtils;
@Autowired
private ProjectxServiceImpl projectxService;
@Value("${jeecg.wordPath}")
private String wordPath;
@ -304,12 +309,13 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
for (int i = 0; i < list.size(); i++) {
if (
StringUtils.isBlank(list.get(i).getRuleNo()) ||
StringUtils.isBlank(list.get(i).getProjectId()) ||
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).getTableId()) ||
// StringUtils.isBlank() list.get(i).getFieldId() == null ||
StringUtils.isBlank(list.get(i).getManagerUsers()) ||
StringUtils.isBlank(list.get(i).getWorkLevel()) ||
@ -318,7 +324,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
// 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).getRealDuration()) &&
StringUtils.isBlank(list.get(i).getStatus()) ||
StringUtils.isBlank(list.get(i).getVerisonStatus()) ||
StringUtils.isBlank(list.get(i).getVerison())) {
@ -355,10 +361,21 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
for (int i = 0; i < ruleVoList.size(); i++) {
Rulex rulex = new Rulex();
RuleVo ruleVo = ruleVoList.get(i);
String projectId = ruleVo.getProjectId();
String pModuleId = ruleVo.getModulePid();
String moduleId = ruleVo.getModuleId();
//对应模块
LambdaQueryWrapper<Projectx> projectxLambdaQueryWrapper =new LambdaQueryWrapper<>();
projectxLambdaQueryWrapper.eq(Projectx::getProjectName,projectId);
Projectx projectx = projectxService.getOne(projectxLambdaQueryWrapper);
if (projectx==null){
message.put("isError", "true");
message.put("closeable", "true");
message.put("status", "第" + (i + 1) + "条数据,项目输入错误,请核对");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (i + 1) + "条数据,项目输入错误,请核对");
}
//判断上级模块是否存在
int n = 0;
if (!StringUtils.isBlank(pModuleId)) {
@ -380,10 +397,20 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
return Result.error("第" + (i + 1) + "条数据,上级模块输入错误,请核对");
}
}
//判断上级模块+模块是否存在
//判断上级模块+模块是否存在且是否属于当前项目下
for (Modulex modulex : modulexList) {
if (modulex.getModuleName().equals(moduleId) && modulex.getPid().equals(pid)) {
if (!modulex.getProjectId().equals(projectx.getId()))
{
message.put("isError", "true");
message.put("closeable", "true");
message.put("status", "第" + (i + 1) + "条数据,该模块与项目不对应输入错误,请核对");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (i + 1) + "条数据,该模块与项目不对应输入错误,请核对");
}
rulex.setModuleId(modulex.getId());
break;
}
n++;
@ -397,9 +424,17 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
}
} else {
n = 0;
//判断模块是否存在
//判断模块是否存在且是否属于当前项目下
for (Modulex modulex : modulexList) {
if (modulex.getModuleName().equals(moduleId) && modulex.getPid() == null) {
if (!modulex.getProjectId().equals(projectx.getId()))
{
message.put("isError", "true");
message.put("closeable", "true");
message.put("status", "第" + (i + 1) + "条数据,该模块与项目不对应输入错误,请核对");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (i + 1) + "条数据,该模块与项目不对应输入错误,请核对");
}
rulex.setModuleId(modulex.getId());
break;
}
@ -430,7 +465,9 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
rulex.setFunctionId(functionx.getId());
//
//对应实体
String tableId = ruleVo.getTableId();
if (!StringUtils.isBlank(tableId)) {
LambdaQueryWrapper<Tablex> tableLambdaQueryWrapper = new LambdaQueryWrapper<>();
tableLambdaQueryWrapper.eq(Tablex::getTableName, tableId).eq(Tablex::getModuleId, rulex.getModuleId());
Tablex tablex = iTablexService.getOne(tableLambdaQueryWrapper);
@ -444,6 +481,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
return Result.error("第" + (i + 1) + "条数据,对应实体输入错误,请核对");
}
rulex.setTableId(tablex.getId());
}
//对应字段
String fieldId = ruleVo.getFieldId();
@ -462,11 +500,17 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
}
rulex.setFieldId(fieldx.getId());
}
Double aDouble = null;
Double duration = null;
try {
if (aDouble != null)
aDouble = Double.valueOf(ruleVo.getDuration());
rulex.setDuration(aDouble);
if (duration < 0){
message.put("isError", "true");
message.put("closeable", "true");
message.put("status", "第" + (i + 1) + "条数据,任务时长输入错误,请核对");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (i + 1) + "条数据,任务时长输入错误,请核对");
}
duration = Double.valueOf(ruleVo.getDuration());
rulex.setDuration(duration);
} catch (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
message.put("isError", "true");
@ -477,8 +521,17 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
}
Double d;
String realDuration = ruleVo.getRealDuration();
if (!StringUtils.isBlank(realDuration)) {
try {
d = Double.valueOf(ruleVo.getRealDuration());
d = Double.valueOf(realDuration);
if (d < 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 (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
message.put("isError", "true");
@ -488,18 +541,17 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
return Result.error("第" + (i + 1) + "条数据,实际时长输入错误,请核对");
}
rulex.setRealDuration(d);
Integer integer;
try {
integer = Integer.valueOf(ruleVo.getWorkLevel());
} catch (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
}
String workLevel = ruleVo.getWorkLevel();
if (!workLevel.matches("^[1-5]$")){
message.put("isError", "true");
message.put("closeable", "true");
message.put("status", "第" + (i + 1) + "条数据,任务等级输入错误,请核对");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (i + 1) + "条数据,任务等级输入错误,请核对");
}
rulex.setWorkLevel(integer);
rulex.setWorkLevel(Integer.valueOf(workLevel));
String workStatus = ruleVo.getWorkStatus();
// LambdaQueryWrapper<SysDictItem> sysDictItemLambdaQueryWrapper = new LambdaQueryWrapper<>();
// sysDictItemLambdaQueryWrapper.eq(SysDictItem::getItemText, workStatus).eq(SysDictItem::getDictId, "1645268542514421762");
@ -591,9 +643,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
}
}
//规则序号
String ruleNo = ruleVo.getRuleNo();
rulex.setRuleNo(ruleNo);
//规则编码
String ruleCode = ruleVo.getRuleCode();
String functionCode1 = functionx.getFunctionCode();
@ -632,14 +682,24 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
return Result.error("第" + (i + 1) + "条数据,规则编码错误,请核对");
}
rulex.setRuleCode(ruleCode);
//规则序号
String ruleNo = ruleVo.getRuleNo();
String c = ruleCode.substring(ruleCode.length() - ruleNo.length());
//三位数整数且与编码后三位相同
if (!(c.equals(ruleNo) && ruleNo.matches("^[0-9]*[1-9][0-9]*$") && (Integer.valueOf(ruleNo) < 1000))) {
message.put("isError", "true");
message.put("closeable", "true");
message.put("status", "第" + (i + 1) + "条数据,规则序号错误,请核对");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (i + 1) + "条数据,规则序号错误,请核对");
}
rulex.setRuleNo(ruleNo);
{
//规则描述
String pmDescribe = ruleVo.getPmDescribe();
if (pmDescribe != null)
rulex.setPmDescribe(pmDescribe);
//分析图
String diagrams = ruleVo.getDiagrams();
if (diagrams != null)
rulex.setDiagrams(diagrams);
//版本号
String verison = ruleVo.getVerison();
if (ruleVo.getVerison() == null || verison.length() >= 5) {
@ -671,7 +731,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
//责任人
String managerUsers = ruleVo.getManagerUsers();
if (managerUsers != null) {
if (!StringUtils.isBlank(managerUsers)) {
LambdaQueryWrapper<SysUser> sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
String[] split = managerUsers.split(",");
sysUserLambdaQueryWrapper.in(SysUser::getUsername, split);
@ -704,6 +764,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
//存入集合待存真实表
rulexList.add(rulex);
}
}
} finally{
//清理预存表
iRuleVoService.remove(null);
@ -720,8 +781,10 @@ public class RulexController extends JeecgController<Rulex, IRulexService> {
return Result.error("文件导入失败!");
}
}
@GetMapping(value = "/sort")
public Result<?> sort(@RequestParam(name = "id", required = true) String id) {
return rulexService.sort(id);

@ -63,12 +63,14 @@ public class RuleVo implements Serializable {
@ApiModelProperty(value = "更新日期")
private String updateTime;
@Excel(name = "对应项目", width = 15)
@ApiModelProperty(value = "对应项目")
private java.lang.String projectId;
/**
* 对应模块父id
*/
@TableField(exist = false)
@Excel(name = "对应模块父模块", width = 15)
@ApiModelProperty(value = "对应模块")
@Excel(name = "上级模块", width = 15)
@ApiModelProperty(value = "上级模块")
private java.lang.String modulePid;
/**
* 对应模块id
@ -77,6 +79,7 @@ public class RuleVo implements Serializable {
@ApiModelProperty(value = "对应模块")
@Dict(dictTable = "modulex", dicCode = "id", dicText = "module_name")
private java.lang.String moduleId;
/**
* 对应功能id
*/
@ -102,12 +105,6 @@ public class RuleVo implements Serializable {
@Excel(name = "规则描述", width = 15)
@ApiModelProperty(value = "规则描述")
private java.lang.String pmDescribe;
/**
* 分析图
*/
@Excel(name = "分析图", width = 15)
@ApiModelProperty(value = "分析图")
private java.lang.String diagrams;
/**
* 对应实体id
*/

@ -6,6 +6,7 @@ import java.util.Date;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@ -99,6 +100,7 @@ public class Rulex implements Serializable {
*/
@Excel(name = "分析图", width = 15)
@ApiModelProperty(value = "分析图")
@TableField(exist = false)
private java.lang.String diagrams;
/**
* 对应实体id

Loading…
Cancel
Save