添加导入实体的项目判断

dev^2
mqh 1 year ago
parent ff8e8754b9
commit c33a3ab60c
  1. 3
      ant-design-vue-jeecg/src/views/modulex/ModulexList.vue
  2. 57
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java
  3. 5
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/vo/TablexVo.java

@ -505,7 +505,8 @@ export default {
}, },
tablexData: function () { tablexData: function () {
return { return {
note: ['对应模块(必填):填写正确的模块名称', note: ['项目名称(必填): 填写已导入的正确的项目名称',
'对应模块(必填):填写已导入的正确的模块名称',
'中文名称(必填):与模块名称相同。', '中文名称(必填):与模块名称相同。',
'英文名称(必填):与模块名称相同,填写模块名称的英文名称。', '英文名称(必填):与模块名称相同,填写模块名称的英文名称。',
'实体状态:可填入值为[正常、停用、废弃],若不填写,默认为“正常”状态。', '实体状态:可填入值为[正常、停用、废弃],若不填写,默认为“正常”状态。',

@ -29,6 +29,8 @@ import org.jeecg.modules.fieldx.entity.Fieldx;
import org.jeecg.modules.fieldx.service.IFieldxService; 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.projectx.entity.Projectx;
import org.jeecg.modules.projectx.service.IProjectxService;
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;
@ -78,6 +80,10 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
@Autowired @Autowired
private IModulexService modulexService; private IModulexService modulexService;
@Autowired
private IProjectxService projectxService;
@Autowired @Autowired
private IFieldxService fieldxService; private IFieldxService fieldxService;
@ -337,7 +343,7 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
message.put("status", "数据预读入"); message.put("status", "数据预读入");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
Iterator<TablexVo> iterator = list.iterator();
for (TablexVo tablexVo : list) { for (TablexVo tablexVo : list) {
//判断当前存入条是否为空值 //判断当前存入条是否为空值
if (StringUtils.isBlank(tablexVo.getModuleId()) && if (StringUtils.isBlank(tablexVo.getModuleId()) &&
@ -376,18 +382,49 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
List<Tablex> tablexList = new ArrayList<>(); List<Tablex> tablexList = new ArrayList<>();
for (int i = 0; i < voList.size(); i++) { for (int i = 0; i < voList.size(); i++) {
Tablex tablex = new Tablex(); Tablex tablex = new Tablex();
//判断对应的项目名称
String projectId = voList.get(i).getProjectId();
if (projectId == null || projectId.equals("")){
message.put("isError", "true");
message.put("status", "导入失败,第" + (i + 1) + "条项目名称填写不能为空");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,第" + (i + 1) + "条项目名称填写不能为空");
}
LambdaQueryWrapper<Projectx> queryProjectx = new LambdaQueryWrapper<>();
queryProjectx.eq(Projectx::getId, projectId);
Projectx projectx = projectxService.getOne(queryProjectx);
if (projectx == null) {
message.put("isError", "true");
message.put("status", "导入失败,第" + (i + 1) + "条项目名称不存在");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,第" + (i + 1) + "条项目名称不存在");
}
//判断对应模块是否为空,且对应模块是否存在 //判断对应模块是否为空,且对应模块是否存在
String moduleId = voList.get(i).getModuleId(); String moduleId = voList.get(i).getModuleId();
if (moduleId == null || moduleId.equals("")) { if (moduleId == null || moduleId.equals("")) {
message.put("isError", "true"); message.put("isError", "true");
message.put("status", "导入失败,对应模块填写不能为空"); message.put("status", "导入失败,第" + (i + 1) + "条对应模块填写不能为空");
message.put("closeable", "true"); message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("对应模块填写不能为空"); return Result.error("导入失败,第" + (i + 1) + "条对应模块填写不能为空");
} }
LambdaQueryWrapper<Modulex> queryModulex = new LambdaQueryWrapper<>();
queryModulex.eq(Modulex::getProjectId,projectId);
queryModulex.eq(Modulex::getId, moduleId);
Modulex modulex = modulexService.getOne(queryModulex);
if (modulex == null) {
message.put("isError", "true");
message.put("status", "导入失败,第" + (i + 1) + "条对应模块不存在");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,第" + (i + 1) + "条对应模块不存在");
}
String modulexId = modulex.getId();
//判断实体是否已存在 //判断实体是否已存在
LambdaQueryWrapper<Tablex> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Tablex> query = new LambdaQueryWrapper<>();
@ -401,18 +438,6 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
return Result.error("导入失败,第" + (i + 1) + "条的实体已存在"); return Result.error("导入失败,第" + (i + 1) + "条的实体已存在");
} }
LambdaQueryWrapper<Modulex> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Modulex::getId, moduleId);
Modulex modulex = modulexService.getOne(queryWrapper);
if (modulex == null) {
message.put("isError", "true");
message.put("status", "导入失败,对应模块填写错误");
message.put("closeable", "true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("对应模块填写错误");
}
String modulexId = modulex.getId();
String status = voList.get(i).getStatus(); String status = voList.get(i).getStatus();
String verisonStatus = voList.get(i).getVerisonStatus(); String verisonStatus = voList.get(i).getVerisonStatus();

@ -34,6 +34,11 @@ public class TablexVo implements Serializable {
@TableId(type = IdType.ASSIGN_ID) @TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键") @ApiModelProperty(value = "主键")
private java.lang.String id; private java.lang.String id;
/**项目名称*/
@Excel(name = "项目名称", width = 15, dictTable = "projectx", dicText = "project_name", dicCode = "id")
@Dict(dictTable = "projectx", dicText = "project_name", dicCode = "id")
@ApiModelProperty(value = "项目名称")
private java.lang.String projectId;
/**对应模块id*/ /**对应模块id*/
@Excel(name = "对应模块", width = 15, dictTable = "modulex", dicText = "module_name", dicCode = "id") @Excel(name = "对应模块", width = 15, dictTable = "modulex", dicText = "module_name", dicCode = "id")
@Dict(dictTable = "modulex", dicText = "module_name", dicCode = "id") @Dict(dictTable = "modulex", dicText = "module_name", dicCode = "id")

Loading…
Cancel
Save