|
|
|
@ -1,8 +1,19 @@ |
|
|
|
|
package org.jeecg.modules.modulex.service.impl; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
|
|
import com.baomidou.mybatisplus.extension.api.R; |
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
|
|
|
|
import org.apache.poi.ss.usermodel.Cell; |
|
|
|
|
import org.apache.poi.ss.usermodel.Row; |
|
|
|
|
import org.apache.poi.ss.usermodel.Sheet; |
|
|
|
|
import org.apache.poi.ss.usermodel.Workbook; |
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
|
|
|
import org.apache.shiro.SecurityUtils; |
|
|
|
|
import org.checkerframework.checker.units.qual.A; |
|
|
|
|
import org.jeecg.common.api.vo.Result; |
|
|
|
|
import org.jeecg.common.system.vo.LoginUser; |
|
|
|
|
import org.jeecg.modules.demo.functionx.entity.Functionx; |
|
|
|
|
import org.jeecg.modules.demo.functionx.mapper.FunctionxMapper; |
|
|
|
|
import org.jeecg.modules.demo.functionx.service.IFunctionxService; |
|
|
|
@ -11,6 +22,7 @@ import org.jeecg.modules.demo.rulex.service.IRulexService; |
|
|
|
|
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.entity.ModulexTemplate; |
|
|
|
|
import org.jeecg.modules.modulex.mapper.ModulexMapper; |
|
|
|
|
import org.jeecg.modules.modulex.service.IModulexService; |
|
|
|
|
import org.jeecg.modules.modulex.vo.ModuleFunctionRule; |
|
|
|
@ -20,6 +32,14 @@ import org.jeecg.modules.system.entity.SysRole; |
|
|
|
|
import org.jeecg.modules.system.entity.SysUser; |
|
|
|
|
import org.jeecg.modules.system.service.ISysRoleService; |
|
|
|
|
import org.jeecg.modules.system.service.ISysUserService; |
|
|
|
|
import org.jeecg.modules.modulex.service.ModulexTemplateService; |
|
|
|
|
import org.jeecg.modules.projectx.entity.Projectx; |
|
|
|
|
import org.jeecg.modules.projectx.service.IProjectxService; |
|
|
|
|
import org.jeecg.modules.projectx.service.impl.ProjectxServiceImpl; |
|
|
|
|
import org.jeecg.modules.system.entity.SysRole; |
|
|
|
|
import org.jeecg.modules.system.entity.SysUser; |
|
|
|
|
import org.jeecg.modules.system.service.ISysRoleService; |
|
|
|
|
import org.jeecg.modules.system.service.ISysUserService; |
|
|
|
|
import org.jeecg.modules.tablex.entity.Tablex; |
|
|
|
|
import org.jeecg.modules.tablex.service.ITablexService; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
@ -27,6 +47,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
@ -34,6 +55,9 @@ import javax.validation.constraints.NotNull; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.function.Function; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
import java.io.InputStream; |
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @Description: 模块管理 |
|
|
|
@ -71,6 +95,18 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl |
|
|
|
|
@Autowired |
|
|
|
|
private IProjectxService iProjectxService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private ModulexTemplateService modulexTemplateService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private IProjectxService projectxService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private ISysRoleService iSysRoleService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private ISysUserService iSysUserService; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 得到最大的版本号 |
|
|
|
|
*/ |
|
|
|
@ -287,6 +323,485 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Result<?> importExcel(MultipartFile file) throws Exception { |
|
|
|
|
// 获取当前操作用户
|
|
|
|
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
|
String username = loginUser.getUsername(); |
|
|
|
|
if (file.isEmpty()) { |
|
|
|
|
return Result.error("上传为空"); |
|
|
|
|
} |
|
|
|
|
String filename = file.getOriginalFilename(); |
|
|
|
|
String fileSuffix = filename.substring(filename.lastIndexOf(".")); |
|
|
|
|
if (!fileSuffix.equals(".xls") && !fileSuffix.equals(".xlsx")) { |
|
|
|
|
return Result.error("文件类型不对"); |
|
|
|
|
} |
|
|
|
|
List<ModulexTemplate> modulexVoList = new ArrayList<>(); |
|
|
|
|
InputStream inputStream = file.getInputStream(); |
|
|
|
|
Workbook wb = null; |
|
|
|
|
if (fileSuffix.equals(".xls")) { |
|
|
|
|
wb = new HSSFWorkbook(inputStream); |
|
|
|
|
} else { |
|
|
|
|
wb = new XSSFWorkbook(inputStream); |
|
|
|
|
} |
|
|
|
|
List<String> propertyNames = new ArrayList<>(); |
|
|
|
|
// 获取excel的sheet页
|
|
|
|
|
int numberOfSheets = wb.getNumberOfSheets(); |
|
|
|
|
for (int i = 0; i < numberOfSheets; i++) { |
|
|
|
|
Sheet sheet = wb.getSheetAt(i); |
|
|
|
|
//获取行数
|
|
|
|
|
int physicalNumberOfRows = sheet.getPhysicalNumberOfRows(); |
|
|
|
|
for (int j = 2; j < physicalNumberOfRows; j++) { |
|
|
|
|
//标题需要单独处理
|
|
|
|
|
//获取页行数
|
|
|
|
|
Row row = sheet.getRow(j); |
|
|
|
|
//获取单行单元格数
|
|
|
|
|
Integer physicalNumberOfCells = null; |
|
|
|
|
if (row == null) { |
|
|
|
|
break; |
|
|
|
|
} else { |
|
|
|
|
physicalNumberOfCells = row.getPhysicalNumberOfCells(); |
|
|
|
|
} |
|
|
|
|
if (j == 2) { |
|
|
|
|
for (int k = 0; k < physicalNumberOfCells; k++) { |
|
|
|
|
Cell cell = row.getCell(k); |
|
|
|
|
String name = cell.getStringCellValue(); |
|
|
|
|
propertyNames.add(name); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
ModulexTemplate modulexVo = new ModulexTemplate(); |
|
|
|
|
//处理数据
|
|
|
|
|
int annual = 0; |
|
|
|
|
for (int k = 0; k < physicalNumberOfCells; k++) { |
|
|
|
|
Cell cell = row.getCell(k); |
|
|
|
|
String value = cell.getStringCellValue(); |
|
|
|
|
switch (k){ |
|
|
|
|
case 0: |
|
|
|
|
modulexVo.setPid(value); |
|
|
|
|
break; |
|
|
|
|
case 1: |
|
|
|
|
if (value == null || value == "") { |
|
|
|
|
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "项目名称为空"); |
|
|
|
|
} |
|
|
|
|
modulexVo.setProjectId(value); |
|
|
|
|
break; |
|
|
|
|
case 2: |
|
|
|
|
if (value == null || value == "") { |
|
|
|
|
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "中文名称为空"); |
|
|
|
|
} |
|
|
|
|
modulexVo.setModuleName(value); |
|
|
|
|
break; |
|
|
|
|
case 3: |
|
|
|
|
if (value == null || value == "") { |
|
|
|
|
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "英文名称为空"); |
|
|
|
|
} |
|
|
|
|
modulexVo.setModuleEnName(value); |
|
|
|
|
break; |
|
|
|
|
case 4: |
|
|
|
|
if (value == null || value == "") { |
|
|
|
|
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "模块编码为空"); |
|
|
|
|
} |
|
|
|
|
modulexVo.setModuleCode(value); |
|
|
|
|
break; |
|
|
|
|
case 5: |
|
|
|
|
modulexVo.setPmDescribe(value); |
|
|
|
|
break; |
|
|
|
|
case 6: |
|
|
|
|
modulexVo.setManagerUsers(value); |
|
|
|
|
break; |
|
|
|
|
case 7: |
|
|
|
|
if (value == null || value == "") { |
|
|
|
|
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "任务等级为空"); |
|
|
|
|
} |
|
|
|
|
modulexVo.setWorkLevel(value); |
|
|
|
|
break; |
|
|
|
|
case 8: |
|
|
|
|
if (value == null || value == "") { |
|
|
|
|
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "开发状态为空"); |
|
|
|
|
} |
|
|
|
|
modulexVo.setWorkStatus(value); |
|
|
|
|
break; |
|
|
|
|
case 9: |
|
|
|
|
modulexVo.setPublishTime(value); |
|
|
|
|
break; |
|
|
|
|
case 10: |
|
|
|
|
if (value == null || value == "") { |
|
|
|
|
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "任务时长为空"); |
|
|
|
|
} |
|
|
|
|
modulexVo.setDuration(value); |
|
|
|
|
break; |
|
|
|
|
case 11: |
|
|
|
|
modulexVo.setStartTime(value); |
|
|
|
|
break; |
|
|
|
|
case 12: |
|
|
|
|
modulexVo.setSubmitTime(value); |
|
|
|
|
break; |
|
|
|
|
case 13: |
|
|
|
|
if (value == null || value == "") { |
|
|
|
|
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "实际时长为空"); |
|
|
|
|
} |
|
|
|
|
modulexVo.setRealDuration(value); |
|
|
|
|
break; |
|
|
|
|
case 14: |
|
|
|
|
modulexVo.setUserRole(value); |
|
|
|
|
break; |
|
|
|
|
case 15: |
|
|
|
|
modulexVo.setRelatedBean(value); |
|
|
|
|
break; |
|
|
|
|
case 16: |
|
|
|
|
modulexVo.setPrototypes(value); |
|
|
|
|
break; |
|
|
|
|
case 17: |
|
|
|
|
modulexVo.setDiagrams(value); |
|
|
|
|
break; |
|
|
|
|
case 18: |
|
|
|
|
if (value == null || value == "") { |
|
|
|
|
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "模块状态为空"); |
|
|
|
|
} |
|
|
|
|
modulexVo.setStatus(value); |
|
|
|
|
break; |
|
|
|
|
case 19: |
|
|
|
|
if (value == null || value == "") { |
|
|
|
|
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "版本状态为空"); |
|
|
|
|
} |
|
|
|
|
modulexVo.setVerisonStatus(value); |
|
|
|
|
break; |
|
|
|
|
case 20: |
|
|
|
|
if (value == null || value == "") { |
|
|
|
|
return Result.error("第" + (j + 1) + "行" + propertyNames.get(k) + "版本号为空"); |
|
|
|
|
}else if(value.length()<=0||value.length()>50){ |
|
|
|
|
return Result.error("版本号不符合规范"); |
|
|
|
|
}else { |
|
|
|
|
modulexVo.setVerison(value); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
return Result.error("未知错误"); |
|
|
|
|
} |
|
|
|
|
modulexVo.setUploadPerson(username); |
|
|
|
|
} |
|
|
|
|
modulexVoList.add(modulexVo); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
modulexTemplateService.saveBatch(modulexVoList); |
|
|
|
|
List<Modulex> modulexList = new ArrayList<>(); |
|
|
|
|
List<ModulexTemplate> modulexTemplates = this.SelectModulex(); |
|
|
|
|
List<String> ids = new ArrayList<>(); |
|
|
|
|
if(modulexTemplates==null||modulexTemplates.size()==0){ |
|
|
|
|
return Result.error("导入失败"); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
for (ModulexTemplate modulexTemplate : modulexTemplates) { |
|
|
|
|
String modulexTemplateId = modulexTemplate.getId(); |
|
|
|
|
ids.add(modulexTemplateId); |
|
|
|
|
} |
|
|
|
|
boolean isTure = modulexTemplateService.removeByIds(ids); |
|
|
|
|
if(!isTure){ |
|
|
|
|
return Result.error("临时表删除失败"); |
|
|
|
|
} |
|
|
|
|
for (ModulexTemplate modulexTemplate : modulexTemplates) { |
|
|
|
|
Modulex modulex = new Modulex(); |
|
|
|
|
String pid = modulexTemplate.getPid(); |
|
|
|
|
if(StringUtils.isBlank(pid)){ |
|
|
|
|
modulex.setPid(null); |
|
|
|
|
}else { |
|
|
|
|
LambdaQueryWrapper<Modulex> queryWrapper = new LambdaQueryWrapper(); |
|
|
|
|
queryWrapper.eq(Modulex::getModuleName,pid); |
|
|
|
|
List<Modulex> list = this.list(queryWrapper); |
|
|
|
|
if(list==null ||list.size()==0){ |
|
|
|
|
return Result.error("导入失败,此模块不存在上级"); |
|
|
|
|
} |
|
|
|
|
Modulex one =list.get(0); |
|
|
|
|
if(one==null){ |
|
|
|
|
return Result.error("导入失败,此模块不存在上级"); |
|
|
|
|
}String pid1 = one.getId(); |
|
|
|
|
if(pid1==null){ |
|
|
|
|
return Result.error("导入失败,此模块不存在上级"); |
|
|
|
|
} |
|
|
|
|
modulex.setPid(pid1); |
|
|
|
|
} |
|
|
|
|
String projectId = modulexTemplate.getProjectId(); |
|
|
|
|
if(projectId==null){ |
|
|
|
|
return Result.error("导入失败,项目名称不能为空"); |
|
|
|
|
}else { |
|
|
|
|
LambdaQueryWrapper<Projectx> projectxLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
projectxLambdaQueryWrapper.eq(Projectx::getProjectName,projectId); |
|
|
|
|
Projectx projectx = projectxService.getOne(projectxLambdaQueryWrapper); |
|
|
|
|
if(projectx==null){ |
|
|
|
|
return Result.error("项目名称不存在"); |
|
|
|
|
} else { |
|
|
|
|
String projectxId = projectx.getId(); |
|
|
|
|
modulex.setProjectId(projectxId); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
String moduleName = modulexTemplate.getModuleName(); |
|
|
|
|
String pid1 = modulex.getPid(); |
|
|
|
|
if(moduleName==null){ |
|
|
|
|
return Result.error("导入失败,中文名称不能为空"); |
|
|
|
|
}else if(pid1==null){ |
|
|
|
|
modulex.setModuleName(moduleName); |
|
|
|
|
} |
|
|
|
|
LambdaQueryWrapper<Modulex> modulexLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
modulexLambdaQueryWrapper.eq(Modulex::getPid,pid1).eq(Modulex::getModuleName,moduleName); |
|
|
|
|
Modulex modulex1 = this.getOne(modulexLambdaQueryWrapper); |
|
|
|
|
if(modulex1!=null){ |
|
|
|
|
return Result.error("相同的上级模块不能重名"); |
|
|
|
|
}modulex.setModuleName(moduleName); |
|
|
|
|
String moduleEnName = modulexTemplate.getModuleEnName(); |
|
|
|
|
if(moduleEnName==null){ |
|
|
|
|
return Result.error("导入失败,英文名称不能为空"); |
|
|
|
|
}modulex.setModuleEnName(moduleEnName); |
|
|
|
|
String moduleCode = modulexTemplate.getModuleCode(); |
|
|
|
|
if(moduleCode==null||moduleCode.length()>30){ |
|
|
|
|
return Result.error("导入失败,模块编码不能为空或者模块编码过长"); |
|
|
|
|
} |
|
|
|
|
modulex.setModuleCode(moduleCode); |
|
|
|
|
String pmDescribe = modulexTemplate.getPmDescribe(); |
|
|
|
|
if(StringUtils.isBlank(pmDescribe)){ |
|
|
|
|
modulex.setPmDescribe(null); |
|
|
|
|
}modulex.setPmDescribe(pmDescribe); |
|
|
|
|
String managerUsers = modulexTemplate.getManagerUsers(); |
|
|
|
|
if(StringUtils.isBlank(managerUsers)){ |
|
|
|
|
modulex.setManagerUsers(null); |
|
|
|
|
}else { |
|
|
|
|
LambdaQueryWrapper<SysUser> sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
sysUserLambdaQueryWrapper.eq(SysUser::getUsername,managerUsers); |
|
|
|
|
SysUser iSysUserServiceOne = iSysUserService.getOne(sysUserLambdaQueryWrapper); |
|
|
|
|
if(iSysUserServiceOne==null){ |
|
|
|
|
return Result.error("导入失败,责任人信息查询不到"); |
|
|
|
|
}else { |
|
|
|
|
String id = iSysUserServiceOne.getId(); |
|
|
|
|
if (id == null) { |
|
|
|
|
return Result.error("导入失败,责任人信息查询不到"); |
|
|
|
|
} |
|
|
|
|
modulex.setManagerUsers(id); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
String workLevel = modulexTemplate.getWorkLevel(); |
|
|
|
|
if(StringUtils.isBlank(workLevel)){ |
|
|
|
|
return Result.error("导入失败,任务等级不能为空"); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
Integer integer = Integer.valueOf(workLevel); |
|
|
|
|
if(integer<=0&&integer>=6){ |
|
|
|
|
return Result.error("导入失败,任务等级不规范"); |
|
|
|
|
} |
|
|
|
|
modulex.setWorkLevel(integer); |
|
|
|
|
} |
|
|
|
|
String workStatus = modulexTemplate.getWorkStatus(); |
|
|
|
|
if(StringUtils.isBlank(workStatus)){ |
|
|
|
|
return Result.error("导入失败,工作状态不能为空"); |
|
|
|
|
}else { |
|
|
|
|
Integer integer = 100; |
|
|
|
|
switch (workStatus){ |
|
|
|
|
case "未发布": integer = 0; |
|
|
|
|
break; |
|
|
|
|
case "已发布": integer = 1; |
|
|
|
|
break; |
|
|
|
|
case "开发中": integer = 2; |
|
|
|
|
break; |
|
|
|
|
case "已完成": integer = 3; |
|
|
|
|
break; |
|
|
|
|
case "已撤回": integer = 4; |
|
|
|
|
break; |
|
|
|
|
case "已取出": integer = 9; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
return Result.error("导入失败,开发状态不规范"); |
|
|
|
|
} |
|
|
|
|
modulex.setWorkStatus(integer); |
|
|
|
|
} |
|
|
|
|
String publishTime = modulexTemplate.getPublishTime(); |
|
|
|
|
if(StringUtils.isBlank(publishTime)){ |
|
|
|
|
modulex.setPublishTime(null); |
|
|
|
|
}else { |
|
|
|
|
Boolean result = this.checkTime(publishTime); |
|
|
|
|
if(!result){ |
|
|
|
|
return Result.error("日期格式不规范"); |
|
|
|
|
}else { |
|
|
|
|
Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(publishTime); |
|
|
|
|
modulex.setPublishTime(date); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
String duration = modulexTemplate.getDuration(); |
|
|
|
|
if(StringUtils.isBlank(duration)){ |
|
|
|
|
return Result.error("任务时长不能为空"); |
|
|
|
|
}else { |
|
|
|
|
double parseDouble = Double.parseDouble(duration); |
|
|
|
|
modulex.setDuration(parseDouble); |
|
|
|
|
} |
|
|
|
|
String startTime = modulexTemplate.getStartTime(); |
|
|
|
|
if(StringUtils.isBlank(startTime)){ |
|
|
|
|
modulex.setStartTime(null); |
|
|
|
|
}else { |
|
|
|
|
Boolean result = this.checkTime(startTime); |
|
|
|
|
if(!result){ |
|
|
|
|
return Result.error("开始时间不规范"); |
|
|
|
|
}else { |
|
|
|
|
Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(startTime); |
|
|
|
|
modulex.setStartTime(date); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
String submitTime = modulexTemplate.getSubmitTime(); |
|
|
|
|
if(StringUtils.isBlank(submitTime)){ |
|
|
|
|
modulex.setSubmitTime(null); |
|
|
|
|
}else { |
|
|
|
|
Boolean result = this.checkTime(submitTime); |
|
|
|
|
if(!result){ |
|
|
|
|
return Result.error("提交时间不规范"); |
|
|
|
|
}else { |
|
|
|
|
Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(submitTime); |
|
|
|
|
modulex.setSubmitTime(date); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
String realDuration = modulexTemplate.getRealDuration(); |
|
|
|
|
if(StringUtils.isBlank(realDuration)){ |
|
|
|
|
return Result.error("实际时长不能为空"); |
|
|
|
|
}else { |
|
|
|
|
double parseDouble = Double.parseDouble(realDuration); |
|
|
|
|
if(parseDouble<0.1){ |
|
|
|
|
return Result.error("最小时间0.1小时"); |
|
|
|
|
} |
|
|
|
|
modulex.setRealDuration(parseDouble); |
|
|
|
|
} |
|
|
|
|
String userRole = modulexTemplate.getUserRole(); |
|
|
|
|
if(StringUtils.isBlank(userRole)){ |
|
|
|
|
modulex.setUserRole(null); |
|
|
|
|
}else { |
|
|
|
|
LambdaQueryWrapper<SysRole> sysRoleLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
sysRoleLambdaQueryWrapper.eq(SysRole::getRoleName,userRole); |
|
|
|
|
SysRole one = iSysRoleService.getOne(sysRoleLambdaQueryWrapper); |
|
|
|
|
if(one==null){ |
|
|
|
|
return Result.error("导入失败"); |
|
|
|
|
} |
|
|
|
|
String useRole = one.getId(); |
|
|
|
|
if(useRole==null){ |
|
|
|
|
return Result.error("导入失败"); |
|
|
|
|
} modulex.setUserRole(useRole); |
|
|
|
|
} |
|
|
|
|
String relatedBean = modulexTemplate.getRelatedBean(); |
|
|
|
|
if(StringUtils.isBlank(relatedBean)){ |
|
|
|
|
modulex.setRelatedBean(null); |
|
|
|
|
}else { |
|
|
|
|
Boolean extracted = extracted(modulex, relatedBean); |
|
|
|
|
if(!extracted){ |
|
|
|
|
return Result.error("关联实体不存在"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
String prototypes = modulexTemplate.getPrototypes(); |
|
|
|
|
if(StringUtils.isBlank(prototypes)){ |
|
|
|
|
modulex.setPrototypes(null); |
|
|
|
|
}modulex.setPrototypes(prototypes); |
|
|
|
|
String diagrams = modulexTemplate.getDiagrams(); |
|
|
|
|
if(StringUtils.isBlank(diagrams)){ |
|
|
|
|
modulex.setDiagrams(null); |
|
|
|
|
}modulex.setDiagrams(diagrams); |
|
|
|
|
String status = modulexTemplate.getStatus(); |
|
|
|
|
if(StringUtils.isBlank(status)){ |
|
|
|
|
return Result.error("导入失败"); |
|
|
|
|
}else { |
|
|
|
|
Integer integer = 100; |
|
|
|
|
switch (status){ |
|
|
|
|
case "正常": integer = 1; |
|
|
|
|
break; |
|
|
|
|
case "停用": integer = 0; |
|
|
|
|
break; |
|
|
|
|
case "废弃": integer = 9; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
return Result.error("导入失败"); |
|
|
|
|
} |
|
|
|
|
modulex.setStatus(integer); |
|
|
|
|
} |
|
|
|
|
String verisonStatus = modulexTemplate.getVerisonStatus(); |
|
|
|
|
if(StringUtils.isBlank(verisonStatus)){ |
|
|
|
|
return Result.error("导入失败"); |
|
|
|
|
}else { |
|
|
|
|
Integer integer = 100; |
|
|
|
|
switch (verisonStatus){ |
|
|
|
|
case "当前": integer = 1; |
|
|
|
|
break; |
|
|
|
|
case "历史": integer = 0; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
Result.error("未知错误"); |
|
|
|
|
} |
|
|
|
|
modulex.setVerisonStatus(integer); |
|
|
|
|
} |
|
|
|
|
String verison = modulexTemplate.getVerison(); |
|
|
|
|
if(StringUtils.isBlank(verison)){ |
|
|
|
|
return Result.error("导入失败"); |
|
|
|
|
}else { |
|
|
|
|
int parseInt = Integer.parseInt(verison); |
|
|
|
|
modulex.setVerison(parseInt); |
|
|
|
|
} |
|
|
|
|
modulexList.add(modulex); |
|
|
|
|
} |
|
|
|
|
boolean result = this.saveBatch(modulexList); |
|
|
|
|
if(!result){ |
|
|
|
|
return Result.error("导入失败"); |
|
|
|
|
} |
|
|
|
|
return Result.OK("导入成功"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private Boolean extracted(Modulex modulex, String relatedBean) { |
|
|
|
|
LambdaQueryWrapper<Tablex> tablexLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
tablexLambdaQueryWrapper.eq(Tablex::getTableName, relatedBean); |
|
|
|
|
Tablex tablex = iTablexService.getOne(tablexLambdaQueryWrapper); |
|
|
|
|
if(tablex==null){ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
String tablexId = tablex.getId(); |
|
|
|
|
if(tablexId==null){ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
modulex.setRelatedBean(tablexId); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 检查时间格式,是否有效 |
|
|
|
|
*/ |
|
|
|
|
private Boolean checkTime(String date){ |
|
|
|
|
// 使用日期解析方式校验日期逻辑有效性
|
|
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
try { |
|
|
|
|
Date parsedDate = dateFormat.parse(date); |
|
|
|
|
// 检查年份是否合法(例如:不能小于1900)
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
calendar.setTime(parsedDate); |
|
|
|
|
int year = calendar.get(Calendar.YEAR); |
|
|
|
|
if (year < 1900) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
// 检查日期的逻辑有效性(例如:2月30日是无效的)
|
|
|
|
|
int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH); |
|
|
|
|
int month = calendar.get(Calendar.MONTH) + 1; |
|
|
|
|
int maxDayOfMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); |
|
|
|
|
if (dayOfMonth > maxDayOfMonth) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<ModulexTemplate> SelectModulex(){ |
|
|
|
|
// 获取当前操作用户
|
|
|
|
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
|
String username = loginUser.getUsername(); |
|
|
|
|
LambdaQueryWrapper<ModulexTemplate> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
queryWrapper.eq(ModulexTemplate::getUploadPerson,username); |
|
|
|
|
List<ModulexTemplate> modulexTemplateList = modulexTemplateService.list(queryWrapper); |
|
|
|
|
return modulexTemplateList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void handleStatus(String id, Integer a) { |
|
|
|
|
//先查字模块 先查询父id 等于 这个 id 的数据
|
|
|
|
|
List<Modulex> modulexs = this.list(new LambdaQueryWrapper<Modulex>().eq(Modulex::getPid, id)); |
|
|
|
|