模块管理导入

dev
lijinyu 1 year ago
parent ee7791a28b
commit d25342e97c
  1. 3
      ant-design-vue-jeecg/src/views/modulex/ModulexList.vue
  2. 24
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/controller/ModulexController.java
  3. 213
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/entity/ModulexTemplate.java
  4. 18
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/mapper/ModulexTemplateMapper.java
  5. 5
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/IModulexService.java
  6. 13
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/ModulexTemplateService.java
  7. 515
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexServiceImpl.java
  8. 22
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexTemplateServiceImpl.java
  9. 42
      jeecg-boot/jeecg-boot-module-system/src/main/resources/mapper/ModulexTemplateMapper.xml

@ -70,7 +70,9 @@
<!-- 操作按钮区域 -->
<div class="table-operator">
<a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
<a-button type="primary" icon="import">导入模块</a-button>
</a-upload>
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="functionImportExcelUrl" @change="handleImportExcel">
<a-button type="primary" icon="import">导入功能</a-button>
</a-upload>
@ -82,7 +84,6 @@
</a-upload>
<a-button type="primary" icon="import">导入字段</a-button>
<a-button @click="fanhui" type="primary" icon="rollback">返回</a-button>
</div>
<!-- table区域-begin -->

@ -8,6 +8,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
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.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
@ -19,14 +25,18 @@ import org.jeecg.modules.demo.requirementitem.service.IRequirementItemService;
import org.jeecg.modules.modulex.entity.Modulex;
import org.jeecg.modules.modulex.mapper.ModulexMapper;
import org.jeecg.modules.modulex.service.IModulexService;
import org.jeecg.modules.modulex.service.ModulexTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.stream.Collectors;
@ -49,6 +59,8 @@ public class ModulexController extends JeecgController<Modulex, IModulexService>
private IRequirementFunService requirementFunService;
@Autowired
private IRequirementItemService requirementItemService;
@Autowired
private ModulexTemplateService modulexTemplateService;
/**
* 分页列表查询
@ -253,13 +265,15 @@ public class ModulexController extends JeecgController<Modulex, IModulexService>
/**
* 通过excel导入数据
*
* @param request
* @param response
* @param
* @param
* @return
*/
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, Modulex.class);
@PostMapping(value = "/importExcel")
public Result<?> importExcel(@RequestParam MultipartFile file) throws Exception {
// return super.importExcel(request, response, Modulex.class);
Result<?> result = modulexService.importExcel(file);
return result;
}
/**

@ -0,0 +1,213 @@
package org.jeecg.modules.modulex.entity;
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 com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
/**
* @Description: 模块管理
* @Author: jeecg-boot
* @Date: 2023-04-10
* @Version: V1.0
*/
@Data
@TableName("modulex_template")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "modulexVo对象", description = "模块管理")
public class ModulexTemplate implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
private String id;
/**
* 上级模块id
* 关联表字段 modulex.id
* 显示上级名称
*/
@Excel(name = "上级模块id", width = 15)
@ApiModelProperty(value = "上级模块名称")
@TableField(value = "pname")
@Dict(dictTable = "modulex", dicText = "module_name", dicCode = "id")
private String pid;
/**
* 项目id
* 关联表字段 modulex.id
* 显示项目名称
*/
@Excel(name = "项目id", width = 15)
@ApiModelProperty(value = "项目名称")
@TableField(value = "projectname")
@Dict(dictTable = "projectx", dicText = "project_name", dicCode = "id")
private String projectId;
/**
* 中文名称
* 相同上级的模块不能重名
*/
@Excel(name = "中文名称", width = 15)
@ApiModelProperty(value = "中文名称")
private String moduleName;
/**
* 英文名称
*/
@Excel(name = "英文名称", width = 15)
@ApiModelProperty(value = "英文名称")
private String moduleEnName;
/**
* 模块编码
*/
@Excel(name = "模块编码", width = 15)
@ApiModelProperty(value = "模块编码")
private String moduleCode;
/**
* 内容描述
*/
@Excel(name = "内容描述", width = 15)
@ApiModelProperty(value = "内容描述")
private String pmDescribe;
/**
* 责任人
* 关联表字段 用户表.id(s)
* 用户id列表模块的开发任务可以分配给多个人员显示用户名称列表
*/
@Excel(name = "责任人", width = 15)
@ApiModelProperty(value = "责任人")
private String managerUsers;
/**
* 上面的字段 本身的数据字典无法翻译 也不能直接把原来的字段替换掉
* 用这个字段代表 翻译后的值 不改变原先的
*/
@TableField(exist = false)
private String managerUsers_dictText;
@TableField(exist = false)
private String copyId;
/**
* 任务等级
* 12345默认2
*/
@Excel(name = "任务等级", width = 15)
@ApiModelProperty(value = "任务等级")
@Dict(dicCode = "work_level")
private String workLevel;
/**
* 任务状态
* 未发布0已发布1开发中2已完成3已审核4DEBUG 9默认 0
*/
@Excel(name = "任务状态", width = 15)
@ApiModelProperty(value = "任务状态")
@Dict(dicCode = "work_status")
private String workStatus;
/**
* 发布时间
*/
@Excel(name = "发布时间", width = 15, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "发布时间")
private String publishTime;
/**
* 任务时长
* 单位小时等于下级模块时长的和默认1小时
*/
@Excel(name = "任务时长", width = 15)
@ApiModelProperty(value = "任务时长")
private String duration;
/**
* 开始时间
*/
@Excel(name = "开始时间", width = 15, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "开始时间")
private String startTime;
/**
* 提交时间
*/
@Excel(name = "提交时间", width = 15, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "提交时间")
private String submitTime;
/**
* 实际时长
*/
@Excel(name = "实际时长", width = 15)
@ApiModelProperty(value = "实际时长")
private String realDuration;
/**
* 用户角色
* 关联表字段 project_user_role.id(s)
* 规则 角色列表哪些用户可以使用该模块即未来系统的权限分配显示角色名列表
*/
@Excel(name = "用户角色", width = 15)
@ApiModelProperty(value = "用户角色")
private String userRole;
/**
* 关联实体
* 关联表字段 tablex.id
* 规则 关联实体表关联的是该模块管理的实体最下级模块有显示表名
*/
@Excel(name = "关联实体", width = 15)
@ApiModelProperty(value = "关联实体")
@Dict(dictTable = "tablex", dicText = "table_name", dicCode = "id")
private String relatedBean;
/**
* 原型图
*/
@Excel(name = "原型图", width = 15)
@ApiModelProperty(value = "原型图")
private String prototypes;
/**
* 分析图
*/
@Excel(name = "分析图", width = 15)
@ApiModelProperty(value = "分析图")
private String diagrams;
/**
* 模块状态
* 正常1停用0废弃9默认1
*/
@Excel(name = "模块状态", width = 15)
@ApiModelProperty(value = "模块状态")
@Dict(dicCode = "a_status")
private String status;
/**
* 版本状态
* "值:当前1、历史0;默认1"
*/
@Excel(name = "版本状态", width = 15)
@ApiModelProperty(value = "版本状态")
@Dict(dicCode = "verison_status")
private String verisonStatus;
/**
* 版本号
* 顺序累加初始值1
*/
@Excel(name = "版本号", width = 15)
@ApiModelProperty(value = "版本号")
private String verison;
//上传人
private String uploadPerson;
}

@ -0,0 +1,18 @@
package org.jeecg.modules.modulex.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.modulex.entity.ModulexTemplate;
/**
* @author 我在人间讲故事
* @description 针对表modulex_template的数据库操作Mapper
* @createDate 2023-07-10 15:25:43
* @Entity generator.domain.ModulexTemplate
*/
public interface ModulexTemplateMapper extends BaseMapper<ModulexTemplate> {
}

@ -4,6 +4,9 @@ package org.jeecg.modules.modulex.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.modulex.entity.Modulex;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
/**
* @Description: 模块管理
@ -31,4 +34,6 @@ public interface IModulexService extends IService<Modulex> {
void setmodule(String id, String moduleId);
void copy(Modulex modulex);
Result<?> importExcel(MultipartFile file) throws Exception;
}

@ -0,0 +1,13 @@
package org.jeecg.modules.modulex.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.modulex.entity.ModulexTemplate;
/**
* @author 我在人间讲故事
* @description 针对表modulex_template的数据库操作Service
* @createDate 2023-07-10 15:25:43
*/
public interface ModulexTemplateService extends IService<ModulexTemplate> {
}

@ -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,8 +22,17 @@ 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.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;
@ -20,11 +40,15 @@ 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 java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @Description: 模块管理
@ -53,6 +77,18 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
@Autowired
private IFieldxService iFieldxService;
@Autowired
private ModulexTemplateService modulexTemplateService;
@Autowired
private IProjectxService projectxService;
@Autowired
private ISysRoleService iSysRoleService;
@Autowired
private ISysUserService iSysUserService;
/**
* 得到最大的版本号
*/
@ -269,6 +305,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));

@ -0,0 +1,22 @@
package org.jeecg.modules.modulex.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.modulex.entity.ModulexTemplate;
import org.jeecg.modules.modulex.mapper.ModulexTemplateMapper;
import org.jeecg.modules.modulex.service.ModulexTemplateService;
import org.springframework.stereotype.Service;
/**
* @author 我在人间讲故事
* @description 针对表modulex_template的数据库操作Service实现
* @createDate 2023-07-10 15:25:43
*/
@Service
public class ModulexTemplateServiceImpl extends ServiceImpl<ModulexTemplateMapper, ModulexTemplate>
implements ModulexTemplateService {
}

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="generator.mapper.ModulexTemplateMapper">
<resultMap id="BaseResultMap" type="generator.domain.ModulexTemplate">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="pid" column="pid" jdbcType="VARCHAR"/>
<result property="projectId" column="project_id" jdbcType="VARCHAR"/>
<result property="moduleName" column="module_name" jdbcType="VARCHAR"/>
<result property="moduleEnName" column="module_en_name" jdbcType="VARCHAR"/>
<result property="moduleCode" column="module_code" jdbcType="VARCHAR"/>
<result property="pmDescribe" column="pm_describe" jdbcType="VARCHAR"/>
<result property="managerUsers" column="manager_users" jdbcType="VARCHAR"/>
<result property="workLevel" column="work_level" jdbcType="INTEGER"/>
<result property="workStatus" column="work_status" jdbcType="INTEGER"/>
<result property="publishTime" column="publish_time" jdbcType="TIMESTAMP"/>
<result property="duration" column="duration" jdbcType="DOUBLE"/>
<result property="startTime" column="start_time" jdbcType="TIMESTAMP"/>
<result property="submitTime" column="submit_time" jdbcType="TIMESTAMP"/>
<result property="realDuration" column="real_duration" jdbcType="DOUBLE"/>
<result property="userRole" column="user_role" jdbcType="VARCHAR"/>
<result property="relatedBean" column="related_bean" jdbcType="VARCHAR"/>
<result property="prototypes" column="prototypes" jdbcType="VARCHAR"/>
<result property="diagrams" column="diagrams" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="INTEGER"/>
<result property="verisonStatus" column="verison_status" jdbcType="INTEGER"/>
<result property="verison" column="verison" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
id,pid,project_id,
module_name,module_en_name,module_code,
pm_describe,manager_users,work_level,
work_status,publish_time,duration,
start_time,submit_time,real_duration,
user_role,related_bean,prototypes,
diagrams,status,verison_status,
verison
</sql>
</mapper>
Loading…
Cancel
Save