模块管理导入功能交互

dev^2
lijinyu 1 year ago
parent 24740d7d44
commit ed181a656e
  1. 275
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexServiceImpl.java

@ -393,6 +393,32 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
String name = cell.getStringCellValue(); String name = cell.getStringCellValue();
propertyNames.add(name); propertyNames.add(name);
} }
if(propertyNames.size()!=19 || !propertyNames.get(0).equals("上级模块名称")
|| !propertyNames.get(1).equals("项目名称")
|| !propertyNames.get(2).equals("中文名称")
|| !propertyNames.get(3).equals("英文名称")
|| !propertyNames.get(4).equals("模块编码")
|| !propertyNames.get(5).equals("内容描述")
|| !propertyNames.get(6).equals("责任人")
|| !propertyNames.get(7).equals("任务等级")
|| !propertyNames.get(8).equals("任务状态")
|| !propertyNames.get(9).equals("发布时间")
|| !propertyNames.get(10).equals("任务时长")
|| !propertyNames.get(11).equals("开始时间")
|| !propertyNames.get(12).equals("提交时间")
|| !propertyNames.get(13).equals("实际时长")
|| !propertyNames.get(14).equals("用户角色")
|| !propertyNames.get(15).equals("关联实体")
|| !propertyNames.get(16).equals("模块状态")
|| !propertyNames.get(17).equals("版本状态")
|| !propertyNames.get(18).equals("版本号")){
message.put("isError", "true");
message.put("status", "模块管理execl表格不规范,请对比模板重新上传");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("模块管理execl表格不规范,请对比模板重新上传");
}
} else { } else {
ModulexTemplate modulexVo = new ModulexTemplate(); ModulexTemplate modulexVo = new ModulexTemplate();
//处理数据 //处理数据
@ -405,43 +431,15 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
modulexVo.setPid(value); modulexVo.setPid(value);
break; break;
case 1: case 1:
if (value == null || value == "") {
message.put("isError", "true");
message.put("status","文件读取失败"+"第" + (j + 1) + "行" + propertyNames.get(k) + "项目名称为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "项目名称为空");
}
modulexVo.setProjectId(value); modulexVo.setProjectId(value);
break; break;
case 2: case 2:
if (value == null || value == "") {
message.put("isError", "true");
message.put("status","文件读取失败"+"第" + (j + 1) + "行" + propertyNames.get(k) + "中文名称为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "中文名称为空");
}
modulexVo.setModuleName(value); modulexVo.setModuleName(value);
break; break;
case 3: case 3:
if (value == null || value == "") {
message.put("isError", "true");
message.put("status","文件读取失败"+"第" + (j + 1) + "行" + propertyNames.get(k) + "英文名称为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "英文名称为空");
}
modulexVo.setModuleEnName(value); modulexVo.setModuleEnName(value);
break; break;
case 4: case 4:
if (value == null || value == "") {
message.put("isError", "true");
message.put("status","文件读取失败"+"第" + (j + 1) + "行" + propertyNames.get(k) + "模块编码为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "模块编码为空");
}
modulexVo.setModuleCode(value); modulexVo.setModuleCode(value);
break; break;
case 5: case 5:
@ -451,36 +449,15 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
modulexVo.setManagerUsers(value); modulexVo.setManagerUsers(value);
break; break;
case 7: case 7:
if (value == null || value == "") {
message.put("isError", "true");
message.put("status","文件读取失败"+"第" + (j + 1) + "行" + propertyNames.get(k) + "任务等级为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "任务等级为空");
}
modulexVo.setWorkLevel(value); modulexVo.setWorkLevel(value);
break; break;
case 8: case 8:
if (value == null || value == "") {
message.put("isError", "true");
message.put("status","文件读取失败"+"第" + (j + 1) + "行" + propertyNames.get(k) + "开发状态为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "开发状态为空");
}
modulexVo.setWorkStatus(value); modulexVo.setWorkStatus(value);
break; break;
case 9: case 9:
modulexVo.setPublishTime(value); modulexVo.setPublishTime(value);
break; break;
case 10: case 10:
if (value == null || value == "") {
message.put("isError", "true");
message.put("status","文件读取失败"+"第" + (j + 1) + "行" + propertyNames.get(k) + "任务时长为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "任务时长为空");
}
modulexVo.setDuration(value); modulexVo.setDuration(value);
break; break;
case 11: case 11:
@ -490,13 +467,6 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
modulexVo.setSubmitTime(value); modulexVo.setSubmitTime(value);
break; break;
case 13: case 13:
if (value == null || value == "") {
message.put("isError", "true");
message.put("status","文件读取失败"+"第" + (j + 1) + "行" + propertyNames.get(k) + "实际时长为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "实际时长为空");
}
modulexVo.setRealDuration(value); modulexVo.setRealDuration(value);
break; break;
case 14: case 14:
@ -506,48 +476,20 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
modulexVo.setRelatedBean(value); modulexVo.setRelatedBean(value);
break; break;
case 16: case 16:
if (value == null || value == "") {
message.put("isError", "true");
message.put("status","文件读取失败"+"第" + (j + 1) + "行" + propertyNames.get(k) + "模块状态为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "模块状态为空");
}
modulexVo.setStatus(value); modulexVo.setStatus(value);
break; break;
case 17: case 17:
if (value == null || value == "") {
message.put("isError", "true");
message.put("status","文件读取失败"+"第" + (j + 1) + "行" + propertyNames.get(k) + "版本状态为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "版本状态为空");
}
modulexVo.setVerisonStatus(value); modulexVo.setVerisonStatus(value);
break; break;
case 18: case 18:
if (value == null || value == "") {
message.put("isError", "true");
message.put("status","文件读取失败"+"第" + (j + 1) + "行" + propertyNames.get(k) + "版本号为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "版本号为空");
}else if(value.length()<=0||value.length()>50){
message.put("isError", "true");
message.put("status","文件读取失败,"+"版本号不符合规范");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("版本号不符合规范");
}else {
modulexVo.setVerison(value); modulexVo.setVerison(value);
}
break; break;
default: default:
message.put("isError", "true"); message.put("isError", "true");
message.put("status","文件读取失败,"+"未知错误"); message.put("status","数据匹配读取失败,"+"请重新导入");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("未知错误"); return Result.error("数据匹配读取失败,"+"请重新导入");
} }
modulexVo.setUploadPerson(username); modulexVo.setUploadPerson(username);
} }
@ -555,6 +497,25 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
} }
} }
} }
List<String> moduleNameList = new ArrayList<>();
List<String> moduleNameAndPidList = new ArrayList<>();
for (ModulexTemplate template : modulexVoList) {
String moduleName = template.getModuleName();
String pid = template.getPid();
String pinName = pid + moduleName;
moduleNameList.add(moduleName);
moduleNameAndPidList.add(pinName);
}
HashSet<String> setList = new HashSet<>(moduleNameList);
HashSet<String> setPid = new HashSet<>(moduleNameAndPidList);
if(moduleNameList.size()!=setList.size()||moduleNameAndPidList.size()!= setPid.size()){
message.put("isError", "true");
message.put("status","导入失败,相同上级的模块不能重名,一级模块也不能重名,请重新导入");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,,相同上级的模块不能重名,一级模块也不能重名,请重新导入");
}
modulexTemplateService.saveBatch(modulexVoList); modulexTemplateService.saveBatch(modulexVoList);
@ -571,6 +532,7 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
return Result.error("导入失败,预读数据失败,获取不到表格中的数据,请重新导入"); return Result.error("导入失败,预读数据失败,获取不到表格中的数据,请重新导入");
} }
else { else {
for (ModulexTemplate modulexTemplate : modulexTemplates) { for (ModulexTemplate modulexTemplate : modulexTemplates) {
String modulexTemplateId = modulexTemplate.getId(); String modulexTemplateId = modulexTemplate.getId();
ids.add(modulexTemplateId); ids.add(modulexTemplateId);
@ -584,7 +546,8 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
return Result.error("预读数据删除失败,请重新导入"); return Result.error("预读数据删除失败,请重新导入");
} }
message.put("status", "导入数据中"); message.put("status", "导入数据中");
for (ModulexTemplate modulexTemplate : modulexTemplates) { for (int i = 0; i < modulexTemplates.size(); i++) {
ModulexTemplate modulexTemplate = modulexTemplates.get(i);
Modulex modulex = new Modulex(); Modulex modulex = new Modulex();
String pid = modulexTemplate.getPid(); String pid = modulexTemplate.getPid();
if(StringUtils.isBlank(pid)){ if(StringUtils.isBlank(pid)){
@ -595,7 +558,7 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
List<Modulex> list = this.list(queryWrapper); List<Modulex> list = this.list(queryWrapper);
if(list==null ||list.size()==0){ if(list==null ||list.size()==0){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败此模块不存在上级"); message.put("status","导入失败,第" + i+4 +"行" +"此模块不存在上级");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,此模块不存在上级"); return Result.error("导入失败,此模块不存在上级");
@ -603,14 +566,14 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
Modulex one =list.get(0); Modulex one =list.get(0);
if(one==null){ if(one==null){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败此模块不存在上级"); message.put("status","导入失败,第" + i+4 +"行" +"此模块不存在上级");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,此模块不存在上级"); return Result.error("导入失败,此模块不存在上级");
}String pid1 = one.getId(); }String pid1 = one.getId();
if(pid1==null){ if(pid1==null){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败此模块不存在上级"); message.put("status","导入失败,第" + i+4 +"行" +"此模块不存在上级");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,此模块不存在上级"); return Result.error("导入失败,此模块不存在上级");
@ -620,7 +583,7 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
String projectId = modulexTemplate.getProjectId(); String projectId = modulexTemplate.getProjectId();
if(projectId==null){ if(projectId==null){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,项目名称不能为空"); message.put("status","导入失败,第" + i+4 +"行" +"项目名称不能为空");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,项目名称不能为空"); return Result.error("导入失败,项目名称不能为空");
@ -630,10 +593,10 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
Projectx projectx = projectxService.getOne(projectxLambdaQueryWrapper); Projectx projectx = projectxService.getOne(projectxLambdaQueryWrapper);
if(projectx==null){ if(projectx==null){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,项目名称不存在"); message.put("status","导入失败,第" + i+4 +"行" +"项目名称不存在");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,项目名称不存在"); return Result.error("导入失败,项目名称不存在");
} else { } else {
String projectxId = projectx.getId(); String projectxId = projectx.getId();
modulex.setProjectId(projectxId); modulex.setProjectId(projectxId);
@ -643,11 +606,21 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
String pid1 = modulex.getPid(); String pid1 = modulex.getPid();
if(moduleName==null){ if(moduleName==null){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,中文名称不能为空"); message.put("status","导入失败,第" + i+4 +"行" +"中文名称不能为空");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,中文名称不能为空"); return Result.error("导入失败,中文名称不能为空");
}else if(pid1==null){ }else if(pid1==null){
LambdaQueryWrapper<Modulex> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Modulex::getModuleName,moduleName);
List<Modulex> modulexes = this.list(queryWrapper);
if(modulexes.size()>0){
message.put("isError", "true");
message.put("status","导入失败,第" + i+4 +"行" +"模块中文名称已存在,请重新输入");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("模块中文名称已存在,请重新输入");
}
modulex.setModuleName(moduleName); modulex.setModuleName(moduleName);
} }
LambdaQueryWrapper<Modulex> modulexLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Modulex> modulexLambdaQueryWrapper = new LambdaQueryWrapper<>();
@ -655,7 +628,7 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
Modulex modulex1 = this.getOne(modulexLambdaQueryWrapper); Modulex modulex1 = this.getOne(modulexLambdaQueryWrapper);
if(modulex1!=null){ if(modulex1!=null){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,相同的上级模块不能重名"); message.put("status","导入失败,第" + i+4 +"行" +"相同的上级模块不能重名");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,相同的上级模块不能重名"); return Result.error("导入失败,相同的上级模块不能重名");
@ -663,7 +636,7 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
String moduleEnName = modulexTemplate.getModuleEnName(); String moduleEnName = modulexTemplate.getModuleEnName();
if(moduleEnName==null){ if(moduleEnName==null){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,英文名称不能为空"); message.put("status","导入失败,第" + i+4 +"行" +"英文名称不能为空");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,英文名称不能为空"); return Result.error("导入失败,英文名称不能为空");
@ -671,7 +644,7 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
String moduleCode = modulexTemplate.getModuleCode(); String moduleCode = modulexTemplate.getModuleCode();
if(moduleCode==null||moduleCode.length()>30){ if(moduleCode==null||moduleCode.length()>30){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,模块编码不能为空或者模块编码过长"); message.put("status","导入失败,第" + i+4 +"行" +"模块编码不能为空或者模块编码过长");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,模块编码不能为空或者模块编码过长"); return Result.error("导入失败,模块编码不能为空或者模块编码过长");
@ -684,15 +657,15 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
String projectCode = projectx.getProjectCode(); String projectCode = projectx.getProjectCode();
if(projectCode==null){ if(projectCode==null){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","项目编码不存在,请重新填写"); message.put("status","导入失败,第" + i+4 +"行" +"项目编码不存在,请重新填写");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("项目编码不存在,请重新填写"); return Result.error("项目编码不存在,请重新填写");
} }
modulecode = projectCode + firstChar; modulecode = projectCode + firstChar;
if(!modulecode.equals(moduleCode)){ if(!modulecode.equals(moduleCode)){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","模块编码不规范,导入失败"); message.put("status","导入失败,第" + i+4 +"行" +"模块编码不规范,导入失败");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("模块编码不规范,导入失败"); return Result.error("模块编码不规范,导入失败");
@ -701,18 +674,27 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
String pmDescribe = modulexTemplate.getPmDescribe(); String pmDescribe = modulexTemplate.getPmDescribe();
if(StringUtils.isBlank(pmDescribe)){ if(StringUtils.isBlank(pmDescribe)){
modulex.setPmDescribe(null); modulex.setPmDescribe(null);
}modulex.setPmDescribe(pmDescribe); }if(pmDescribe.length()>500){
message.put("isError", "true");
message.put("status","导入失败,第" + i+4 +"行" +"内容描述过长,导入失败");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("内容描述过长,导入失败");
}
modulex.setPmDescribe(pmDescribe);
String managerUsers = modulexTemplate.getManagerUsers(); String managerUsers = modulexTemplate.getManagerUsers();
if(StringUtils.isBlank(managerUsers)){ if(StringUtils.isBlank(managerUsers)){
modulex.setManagerUsers(null); modulex.setManagerUsers(null);
}else { }else {
LambdaQueryWrapper<SysUser> sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SysUser> sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
String[] split = managerUsers.split(","); String[] split = managerUsers.split(",");
sysUserLambdaQueryWrapper.in(SysUser::getUsername,split); List<String> managerUserName= Arrays.stream(split).map(String::valueOf).collect(Collectors.toList());
sysUserLambdaQueryWrapper.in(SysUser::getUsername,managerUserName);
List<SysUser> iSysUserServiceOne = iSysUserService.list(sysUserLambdaQueryWrapper); List<SysUser> iSysUserServiceOne = iSysUserService.list(sysUserLambdaQueryWrapper);
if(iSysUserServiceOne==null){ if(iSysUserServiceOne==null){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,责任人信息查询不到"); message.put("status","导入失败,第" + i+4 +"行" +"责任人信息查询不到");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,责任人信息查询不到"); return Result.error("导入失败,责任人信息查询不到");
@ -720,27 +702,37 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
List<String> list = iSysUserServiceOne.stream().map(SysUser::getId).collect(Collectors.toList()); List<String> list = iSysUserServiceOne.stream().map(SysUser::getId).collect(Collectors.toList());
if (list == null) { if (list == null) {
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,责任人信息查询不到"); message.put("status","导入失败,第" + i+4 +"行" +"责任人信息查询不到");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,责任人信息查询不到"); return Result.error("导入失败,责任人信息查询不到");
} }
modulex.setManagerUsers(String.valueOf(list)); String strip = org.apache.commons.lang.StringUtils.strip(list.toString(), "[]");
modulex.setManagerUsers(strip);
} }
} }
String workLevel = modulexTemplate.getWorkLevel(); String workLevel = modulexTemplate.getWorkLevel();
if(StringUtils.isBlank(workLevel)){ if(StringUtils.isBlank(workLevel)){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,任务等级不能为空"); message.put("status","导入失败,第" + i+4 +"行" +"任务等级不能为空");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,任务等级不能为空"); return Result.error("导入失败,任务等级不能为空");
} }
else { else {
Integer integer = Integer.valueOf(workLevel); Integer integer = null;
try {
integer = Integer.valueOf(workLevel);
} catch (Exception e) {
message.put("isError", "true");
message.put("status","导入失败,第" + i+4 +"行" +"任务等级不规范");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,任务等级不规范");
}
if(integer<=0&&integer>=6){ if(integer<=0&&integer>=6){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,任务等级不规范"); message.put("status","导入失败,第" + i+4 +"行" +"任务等级不规范");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,任务等级不规范"); return Result.error("导入失败,任务等级不规范");
@ -750,31 +742,31 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
String workStatus = modulexTemplate.getWorkStatus(); String workStatus = modulexTemplate.getWorkStatus();
if(StringUtils.isBlank(workStatus)){ if(StringUtils.isBlank(workStatus)){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,工作状态不能为空"); message.put("status","导入失败,第" + i+4 +"行" +"任务状态不能为空");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,工作状态不能为空"); return Result.error("导入失败,任务状态不能为空");
}else { }else {
Integer integer = 100; Integer integer = 100;
switch (workStatus){ switch (workStatus){
case "未发布": integer = 0; case "未发布": integer = 0;
break; break;
case "已发布": integer = 1; case "已发布": integer = 1;
break; break;
case "开发中": integer = 2; case "开发中": integer = 2;
break; break;
case "已完成": integer = 3; case "已完成": integer = 3;
break; break;
case "已撤回": integer = 4; case "已撤回": integer = 4;
break; break;
case "已取出": integer = 9; case "已取出": integer = 9;
break; break;
default: default:
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,开发状态不规范"); message.put("status","导入失败,第" + i+4 +"行" +"任务状态不规范");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,开发状态不规范"); return Result.error("导入失败,任务状态不规范");
} }
modulex.setWorkStatus(integer); modulex.setWorkStatus(integer);
} }
@ -785,7 +777,7 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
Boolean result = this.checkTime(publishTime); Boolean result = this.checkTime(publishTime);
if(!result){ if(!result){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,日期格式不规范"); message.put("status","导入失败,第" + i+4 +"行" +"日期格式不规范");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,日期格式不规范"); return Result.error("导入失败,日期格式不规范");
@ -797,7 +789,7 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
String duration = modulexTemplate.getDuration(); String duration = modulexTemplate.getDuration();
if(StringUtils.isBlank(duration)){ if(StringUtils.isBlank(duration)){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,任务时长不能为空"); message.put("status","导入失败,第" + i+4 +"行" +"任务时长不能为空");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,任务时长不能为空"); return Result.error("导入失败,任务时长不能为空");
@ -812,7 +804,7 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
Boolean result = this.checkTime(startTime); Boolean result = this.checkTime(startTime);
if(!result){ if(!result){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,开始时间不规范"); message.put("status","导入失败,第" + i+4 +"行" +"开始时间不规范");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,开始时间不规范"); return Result.error("导入失败,开始时间不规范");
@ -828,7 +820,7 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
Boolean result = this.checkTime(submitTime); Boolean result = this.checkTime(submitTime);
if(!result){ if(!result){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,提交时间不规范"); message.put("status","导入失败,第" + i+4 +"行" +"提交时间不规范");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,提交时间不规范"); return Result.error("导入失败,提交时间不规范");
@ -840,7 +832,7 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
String realDuration = modulexTemplate.getRealDuration(); String realDuration = modulexTemplate.getRealDuration();
if(StringUtils.isBlank(realDuration)){ if(StringUtils.isBlank(realDuration)){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,实际时长不能为空"); message.put("status","导入失败,第" + i+4 +"行" +"实际时长不能为空");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,实际时长不能为空"); return Result.error("导入失败,实际时长不能为空");
@ -848,7 +840,7 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
double parseDouble = Double.parseDouble(realDuration); double parseDouble = Double.parseDouble(realDuration);
if(parseDouble<0.1){ if(parseDouble<0.1){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,最小时间0.1小时"); message.put("status","导入失败,第" + i+4 +"行" +"最小时间0.1小时");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,最小时间0.1小时"); return Result.error("导入失败,最小时间0.1小时");
@ -864,7 +856,7 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
SysRole one = iSysRoleService.getOne(sysRoleLambdaQueryWrapper); SysRole one = iSysRoleService.getOne(sysRoleLambdaQueryWrapper);
if(one==null){ if(one==null){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,用户角色不存在"); message.put("status","导入失败,第" + i+4 +"行" +"用户角色不存在");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,用户角色不存在"); return Result.error("导入失败,用户角色不存在");
@ -872,7 +864,7 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
String useRole = one.getId(); String useRole = one.getId();
if(useRole==null){ if(useRole==null){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,用户角色不存在"); message.put("status","导入失败,第" + i+4 +"行" +"用户角色不存在");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,用户角色不存在"); return Result.error("导入失败,用户角色不存在");
@ -885,7 +877,7 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
Boolean extracted = extracted(modulex, relatedBean); Boolean extracted = extracted(modulex, relatedBean);
if(!extracted){ if(!extracted){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","关联实体不存在"); message.put("status","导入失败,第" + i+4 +"行" +"关联实体不存在");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("关联实体不存在"); return Result.error("关联实体不存在");
@ -894,7 +886,7 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
String status = modulexTemplate.getStatus(); String status = modulexTemplate.getStatus();
if(StringUtils.isBlank(status)){ if(StringUtils.isBlank(status)){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,模块状态不能为空"); message.put("status","导入失败,第" + i+4 +"行" +"模块状态不能为空");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,模块状态不能为空"); return Result.error("导入失败,模块状态不能为空");
@ -902,14 +894,14 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
Integer integer = 100; Integer integer = 100;
switch (status){ switch (status){
case "正常": integer = 1; case "正常": integer = 1;
break; break;
case "停用": integer = 0; case "停用": integer = 0;
break; break;
case "废弃": integer = 9; case "废弃": integer = 9;
break; break;
default: default:
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败模块状态不规范匹配不到"); message.put("status","导入失败,第" + i+4 +"行" +"模块状态不规范匹配不到");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,模块状态不规范匹配不到"); return Result.error("导入失败,模块状态不规范匹配不到");
@ -919,7 +911,7 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
String verisonStatus = modulexTemplate.getVerisonStatus(); String verisonStatus = modulexTemplate.getVerisonStatus();
if(StringUtils.isBlank(verisonStatus)){ if(StringUtils.isBlank(verisonStatus)){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,版本状态不能为空"); message.put("status","导入失败,第" + i+4 +"行" +"版本状态不能为空");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,版本状态不能为空"); return Result.error("导入失败,版本状态不能为空");
@ -927,31 +919,34 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
Integer integer = 100; Integer integer = 100;
switch (verisonStatus){ switch (verisonStatus){
case "当前": integer = 1; case "当前": integer = 1;
break; break;
case "历史": integer = 0; case "历史": integer = 0;
break; break;
default: default:
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,版本状态不规范,匹配失败"); message.put("status","导入失败,第" + i+4 +"行" +"版本状态不规范,匹配失败");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
Result.error("导入失败,版本状态不规范,匹配失败"); return Result.error("导入失败,版本状态不规范,匹配失败");
} }
modulex.setVerisonStatus(integer); modulex.setVerisonStatus(integer);
} }
String verison = modulexTemplate.getVerison(); String verison = modulexTemplate.getVerison();
if(StringUtils.isBlank(verison)){ if(StringUtils.isBlank(verison)){
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,版本号不能为空"); message.put("status","导入失败,第" + i+4 +"行" + "版本号不能为空");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,版本号不能为空"); return Result.error("导入失败,版本号不能为空");
}else { }else {
int parseInt = Integer.parseInt(verison); int parseInt = Integer.parseInt(verison);
modulex.setVerison(parseInt); modulex.setVerison(parseInt);
} }
modulexList.add(modulex); modulexList.add(modulex);
} }
// for (ModulexTemplate modulexTemplate : modulexTemplates) {
//
// }
boolean result = this.saveSingleBatch(modulexList, loginUser, message); boolean result = this.saveSingleBatch(modulexList, loginUser, message);
if(!result){ if(!result){
message.put("isError", "true"); message.put("isError", "true");

Loading…
Cancel
Save