From d25342e97c698c2bfe3a89d5e2eeeaed1ef6f145 Mon Sep 17 00:00:00 2001
From: lijinyu <3023846734@qq.com>
Date: Thu, 13 Jul 2023 11:43:24 +0800
Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E5=9D=97=E7=AE=A1=E7=90=86=E5=AF=BC?=
=?UTF-8?q?=E5=85=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/views/modulex/ModulexList.vue | 5 +-
.../modulex/controller/ModulexController.java | 24 +-
.../modulex/entity/ModulexTemplate.java | 213 ++++++++
.../modulex/mapper/ModulexTemplateMapper.java | 18 +
.../modulex/service/IModulexService.java | 5 +
.../service/ModulexTemplateService.java | 13 +
.../service/impl/ModulexServiceImpl.java | 515 ++++++++++++++++++
.../impl/ModulexTemplateServiceImpl.java | 22 +
.../mapper/ModulexTemplateMapper.xml | 42 ++
9 files changed, 850 insertions(+), 7 deletions(-)
create mode 100644 jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/entity/ModulexTemplate.java
create mode 100644 jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/mapper/ModulexTemplateMapper.java
create mode 100644 jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/ModulexTemplateService.java
create mode 100644 jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexTemplateServiceImpl.java
create mode 100644 jeecg-boot/jeecg-boot-module-system/src/main/resources/mapper/ModulexTemplateMapper.xml
diff --git a/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue b/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue
index 282a86c..a7df83b 100644
--- a/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue
+++ b/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue
@@ -70,7 +70,9 @@
新增
-
导入模块
+
+ 导入模块
+
导入功能
@@ -82,7 +84,6 @@
导入字段
返回
-
diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/controller/ModulexController.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/controller/ModulexController.java
index 5a40f5c..e6e2676 100644
--- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/controller/ModulexController.java
+++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/controller/ModulexController.java
@@ -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
private IRequirementFunService requirementFunService;
@Autowired
private IRequirementItemService requirementItemService;
+ @Autowired
+ private ModulexTemplateService modulexTemplateService;
/**
* 分页列表查询
@@ -253,13 +265,15 @@ public class ModulexController extends JeecgController
/**
* 通过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;
}
/**
diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/entity/ModulexTemplate.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/entity/ModulexTemplate.java
new file mode 100644
index 0000000..328efab
--- /dev/null
+++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/entity/ModulexTemplate.java
@@ -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;
+ /**
+ * 任务等级
+ * 值:1、2、3、4、5,默认2
+ */
+ @Excel(name = "任务等级", width = 15)
+ @ApiModelProperty(value = "任务等级")
+ @Dict(dicCode = "work_level")
+ private String workLevel;
+ /**
+ * 任务状态
+ * 值:未发布0、已发布1、开发中2、已完成3、已审核4、DEBUG 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;
+
+}
diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/mapper/ModulexTemplateMapper.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/mapper/ModulexTemplateMapper.java
new file mode 100644
index 0000000..978d587
--- /dev/null
+++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/mapper/ModulexTemplateMapper.java
@@ -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 {
+
+}
+
+
+
+
diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/IModulexService.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/IModulexService.java
index d6a8ad2..e3d6fbf 100644
--- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/IModulexService.java
+++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/IModulexService.java
@@ -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 {
void setmodule(String id, String moduleId);
void copy(Modulex modulex);
+
+ Result> importExcel(MultipartFile file) throws Exception;
}
diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/ModulexTemplateService.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/ModulexTemplateService.java
new file mode 100644
index 0000000..cc6e20a
--- /dev/null
+++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/ModulexTemplateService.java
@@ -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 {
+
+}
diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexServiceImpl.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexServiceImpl.java
index cfd8dba..e5e5247 100644
--- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexServiceImpl.java
+++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexServiceImpl.java
@@ -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 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 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 modulexVoList = new ArrayList<>();
+ InputStream inputStream = file.getInputStream();
+ Workbook wb = null;
+ if (fileSuffix.equals(".xls")) {
+ wb = new HSSFWorkbook(inputStream);
+ } else {
+ wb = new XSSFWorkbook(inputStream);
+ }
+ List 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 modulexList = new ArrayList<>();
+ List modulexTemplates = this.SelectModulex();
+ List 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 queryWrapper = new LambdaQueryWrapper();
+ queryWrapper.eq(Modulex::getModuleName,pid);
+ List 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 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 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 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 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 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 SelectModulex(){
+ // 获取当前操作用户
+ LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+ String username = loginUser.getUsername();
+ LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>();
+ queryWrapper.eq(ModulexTemplate::getUploadPerson,username);
+ List modulexTemplateList = modulexTemplateService.list(queryWrapper);
+ return modulexTemplateList;
+ }
+
+
private void handleStatus(String id, Integer a) {
//先查字模块 先查询父id 等于 这个 id 的数据
List modulexs = this.list(new LambdaQueryWrapper().eq(Modulex::getPid, id));
diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexTemplateServiceImpl.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexTemplateServiceImpl.java
new file mode 100644
index 0000000..e87fbc9
--- /dev/null
+++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexTemplateServiceImpl.java
@@ -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
+ implements ModulexTemplateService {
+
+}
+
+
+
+
diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/mapper/ModulexTemplateMapper.xml b/jeecg-boot/jeecg-boot-module-system/src/main/resources/mapper/ModulexTemplateMapper.xml
new file mode 100644
index 0000000..998c2b5
--- /dev/null
+++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/mapper/ModulexTemplateMapper.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+