模块管理导入功能交互

dev^2
lijinyu 1 year ago
parent 1941280f92
commit cc98e3b7d9
  1. 4
      ant-design-vue-jeecg/src/views/modulex/ModulexList.vue
  2. 203
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexServiceImpl.java

@ -538,8 +538,8 @@ export default {
],
title: '导入模块',
uploadUrl: this.modelImportExcelUrl,
downUrl: "temp/2.xls",
downName: "mokua.xls"
downUrl: "temp/modulex.xls",
downName: "模块管理模板.xls"
}
},

@ -339,14 +339,24 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
message.put("isVisible", "true");
message.put("uploaded", "0");
message.put("status", "判断文件结构");
message.put("isError", "false");
message.put("closeable","false");
webSocketUtils.sendMessage(loginUser.getId(), message);
String username = loginUser.getUsername();
if (file.isEmpty()) {
return Result.error("上传为空");
message.put("isError", "true");
message.put("status","导入失败,上传为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,上传为空");
}
String filename = file.getOriginalFilename();
String fileSuffix = filename.substring(filename.lastIndexOf("."));
if (!fileSuffix.equals(".xls") && !fileSuffix.equals(".xlsx")) {
message.put("isError", "true");
message.put("status","文件类型不对");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("文件类型不对");
}
List<ModulexTemplate> modulexVoList = new ArrayList<>();
@ -396,24 +406,40 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
break;
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);
break;
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);
break;
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);
break;
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);
@ -426,12 +452,20 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
break;
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);
break;
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);
@ -441,6 +475,10 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
break;
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);
@ -453,6 +491,10 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
break;
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);
@ -465,26 +507,46 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
break;
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);
break;
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);
break;
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);
}
break;
default:
message.put("isError", "true");
message.put("status","文件读取失败,"+"未知错误");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("未知错误");
}
modulexVo.setUploadPerson(username);
@ -502,6 +564,10 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
webSocketUtils.sendMessage(loginUser.getId(), message);
List<String> ids = new ArrayList<>();
if(modulexTemplates==null||modulexTemplates.size()==0){
message.put("isError", "true");
message.put("status","导入失败,预读数据失败,获取不到表格中的数据,请重新导入");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,预读数据失败,获取不到表格中的数据,请重新导入");
}
else {
@ -511,6 +577,10 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
}
boolean isTure = modulexTemplateService.removeByIds(ids);
if(!isTure){
message.put("isError", "true");
message.put("status","预读数据删除失败,请重新导入");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("预读数据删除失败,请重新导入");
}
message.put("status", "导入数据中");
@ -524,25 +594,45 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
queryWrapper.eq(Modulex::getModuleName,pid);
List<Modulex> list = this.list(queryWrapper);
if(list==null ||list.size()==0){
message.put("isError", "true");
message.put("status","导入失败,此模块不存在上级");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,此模块不存在上级");
}
Modulex one =list.get(0);
if(one==null){
message.put("isError", "true");
message.put("status","导入失败,此模块不存在上级");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,此模块不存在上级");
}String pid1 = one.getId();
if(pid1==null){
message.put("isError", "true");
message.put("status","导入失败,此模块不存在上级");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,此模块不存在上级");
}
modulex.setPid(pid1);
}
String projectId = modulexTemplate.getProjectId();
if(projectId==null){
message.put("isError", "true");
message.put("status","导入失败,项目名称不能为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,项目名称不能为空");
}else {
LambdaQueryWrapper<Projectx> projectxLambdaQueryWrapper = new LambdaQueryWrapper<>();
projectxLambdaQueryWrapper.eq(Projectx::getProjectName,projectId);
Projectx projectx = projectxService.getOne(projectxLambdaQueryWrapper);
if(projectx==null){
message.put("isError", "true");
message.put("status","导入失败,项目名称不存在");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,项目名称不存在");
} else {
String projectxId = projectx.getId();
@ -552,6 +642,10 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
String moduleName = modulexTemplate.getModuleName();
String pid1 = modulex.getPid();
if(moduleName==null){
message.put("isError", "true");
message.put("status","导入失败,中文名称不能为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,中文名称不能为空");
}else if(pid1==null){
modulex.setModuleName(moduleName);
@ -560,14 +654,26 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
modulexLambdaQueryWrapper.eq(Modulex::getPid,pid1).eq(Modulex::getModuleName,moduleName);
Modulex modulex1 = this.getOne(modulexLambdaQueryWrapper);
if(modulex1!=null){
message.put("isError", "true");
message.put("status","导入失败,相同的上级模块不能重名");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,相同的上级模块不能重名");
}modulex.setModuleName(moduleName);
String moduleEnName = modulexTemplate.getModuleEnName();
if(moduleEnName==null){
message.put("isError", "true");
message.put("status","导入失败,英文名称不能为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,英文名称不能为空");
}modulex.setModuleEnName(moduleEnName);
String moduleCode = modulexTemplate.getModuleCode();
if(moduleCode==null||moduleCode.length()>30){
message.put("isError", "true");
message.put("status","导入失败,模块编码不能为空或者模块编码过长");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,模块编码不能为空或者模块编码过长");
}
String modulecode = null;
@ -577,10 +683,18 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
String firstChar = this.toFirstChar(moduleName);
String projectCode = projectx.getProjectCode();
if(projectCode==null){
message.put("isError", "true");
message.put("status","项目编码不存在,请重新填写");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("项目编码不存在,请重新填写");
}
modulecode = projectCode + firstChar;
if(!modulecode.equals(moduleCode)){
message.put("isError", "true");
message.put("status","模块编码不规范,导入失败");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("模块编码不规范,导入失败");
}
modulex.setModuleCode(moduleCode);
@ -597,10 +711,18 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
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("导入失败,责任人信息查询不到");
}else {
List<String> list = iSysUserServiceOne.stream().map(SysUser::getId).collect(Collectors.toList());
if (list == null) {
message.put("isError", "true");
message.put("status","导入失败,责任人信息查询不到");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,责任人信息查询不到");
}
modulex.setManagerUsers(String.valueOf(list));
@ -608,17 +730,29 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
}
String workLevel = modulexTemplate.getWorkLevel();
if(StringUtils.isBlank(workLevel)){
message.put("isError", "true");
message.put("status","导入失败,任务等级不能为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,任务等级不能为空");
}
else {
Integer integer = Integer.valueOf(workLevel);
if(integer<=0&&integer>=6){
message.put("isError", "true");
message.put("status","导入失败,任务等级不规范");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,任务等级不规范");
}
modulex.setWorkLevel(integer);
}
String workStatus = modulexTemplate.getWorkStatus();
if(StringUtils.isBlank(workStatus)){
message.put("isError", "true");
message.put("status","导入失败,工作状态不能为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,工作状态不能为空");
}else {
Integer integer = 100;
@ -636,6 +770,10 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
case "已取出": integer = 9;
break;
default:
message.put("isError", "true");
message.put("status","导入失败,开发状态不规范");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,开发状态不规范");
}
modulex.setWorkStatus(integer);
@ -646,6 +784,10 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
}else {
Boolean result = this.checkTime(publishTime);
if(!result){
message.put("isError", "true");
message.put("status","导入失败,日期格式不规范");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,日期格式不规范");
}else {
Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(publishTime);
@ -654,6 +796,10 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
}
String duration = modulexTemplate.getDuration();
if(StringUtils.isBlank(duration)){
message.put("isError", "true");
message.put("status","导入失败,任务时长不能为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,任务时长不能为空");
}else {
double parseDouble = Double.parseDouble(duration);
@ -665,6 +811,10 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
}else {
Boolean result = this.checkTime(startTime);
if(!result){
message.put("isError", "true");
message.put("status","导入失败,开始时间不规范");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,开始时间不规范");
}else {
Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(startTime);
@ -677,6 +827,10 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
}else {
Boolean result = this.checkTime(submitTime);
if(!result){
message.put("isError", "true");
message.put("status","导入失败,提交时间不规范");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,提交时间不规范");
}else {
Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(submitTime);
@ -685,10 +839,18 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
}
String realDuration = modulexTemplate.getRealDuration();
if(StringUtils.isBlank(realDuration)){
message.put("isError", "true");
message.put("status","导入失败,实际时长不能为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,实际时长不能为空");
}else {
double parseDouble = Double.parseDouble(realDuration);
if(parseDouble<0.1){
message.put("isError", "true");
message.put("status","导入失败,最小时间0.1小时");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,最小时间0.1小时");
}
modulex.setRealDuration(parseDouble);
@ -701,10 +863,18 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
sysRoleLambdaQueryWrapper.eq(SysRole::getRoleName,userRole);
SysRole one = iSysRoleService.getOne(sysRoleLambdaQueryWrapper);
if(one==null){
message.put("isError", "true");
message.put("status","导入失败,用户角色不存在");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,用户角色不存在");
}
String useRole = one.getId();
if(useRole==null){
message.put("isError", "true");
message.put("status","导入失败,用户角色不存在");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,用户角色不存在");
} modulex.setUserRole(useRole);
}
@ -714,11 +884,19 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
}else {
Boolean extracted = extracted(modulex, relatedBean);
if(!extracted){
message.put("isError", "true");
message.put("status","关联实体不存在");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("关联实体不存在");
}
}
String status = modulexTemplate.getStatus();
if(StringUtils.isBlank(status)){
message.put("isError", "true");
message.put("status","导入失败,模块状态不能为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,模块状态不能为空");
}else {
Integer integer = 100;
@ -730,12 +908,20 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
case "废弃": integer = 9;
break;
default:
message.put("isError", "true");
message.put("status","导入失败,模块状态不规范匹配不到");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,模块状态不规范匹配不到");
}
modulex.setStatus(integer);
}
String verisonStatus = modulexTemplate.getVerisonStatus();
if(StringUtils.isBlank(verisonStatus)){
message.put("isError", "true");
message.put("status","导入失败,版本状态不能为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,版本状态不能为空");
}else {
Integer integer = 100;
@ -745,12 +931,20 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
case "历史": integer = 0;
break;
default:
message.put("isError", "true");
message.put("status","导入失败,版本状态不规范,匹配失败");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
Result.error("导入失败,版本状态不规范,匹配失败");
}
modulex.setVerisonStatus(integer);
}
String verison = modulexTemplate.getVerison();
if(StringUtils.isBlank(verison)){
message.put("isError", "true");
message.put("status","导入失败,版本号不能为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,版本号不能为空");
}else {
int parseInt = Integer.parseInt(verison);
@ -760,8 +954,15 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
}
boolean result = this.saveSingleBatch(modulexList, loginUser, message);
if(!result){
message.put("isError", "true");
message.put("status","未知错误导入失败,请重新导入");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("未知错误导入失败,请重新导入");
}
message.put("status", "导入成功");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.OK("导入成功");
}
}

Loading…
Cancel
Save