diff --git a/ant-design-vue-jeecg/src/mixins/JeecgListMixin.js b/ant-design-vue-jeecg/src/mixins/JeecgListMixin.js index a20a414..c4362d2 100644 --- a/ant-design-vue-jeecg/src/mixins/JeecgListMixin.js +++ b/ant-design-vue-jeecg/src/mixins/JeecgListMixin.js @@ -349,6 +349,8 @@ export const JeecgListMixin = { this.$refs.modalForm.edit(record); this.$refs.modalForm.title = "复制"; this.$refs.modalForm.disableSubmit = false; + // 重载列表 + this.loadData(); }, // 任务管理-任务-分解 fengjieRenwu: function (record) { diff --git a/ant-design-vue-jeecg/src/views/functiontemple/FunctionTemplateList.vue b/ant-design-vue-jeecg/src/views/functiontemple/FunctionTemplateList.vue index c81cb85..02a0acf 100644 --- a/ant-design-vue-jeecg/src/views/functiontemple/FunctionTemplateList.vue +++ b/ant-design-vue-jeecg/src/views/functiontemple/FunctionTemplateList.vue @@ -40,7 +40,7 @@
新增 导出 - + 导入 diff --git a/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue b/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue index d0fe0d8..7f9412c 100644 --- a/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue +++ b/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue @@ -475,7 +475,6 @@ export default { deleteBatch: "/modulex/modulex/deleteBatch", exportXlsUrl: "/modulex/modulex/exportXls", importExcelUrlf: "fieldx/fieldx/importExcel", - importExcelUrl: "modulex/modulex/importExcel", functionImportExcelUrl: "/functionx/functionx/importExcel", tablexImportExcelUrl: "tablex/tablex/importExcel", diff --git a/ant-design-vue-jeecg/src/views/task/TaskList.vue b/ant-design-vue-jeecg/src/views/task/TaskList.vue index c23913d..ed99163 100644 --- a/ant-design-vue-jeecg/src/views/task/TaskList.vue +++ b/ant-design-vue-jeecg/src/views/task/TaskList.vue @@ -5,7 +5,7 @@ - + - + + + + + + + + + + + + + + + + + + + - + + + + + 查询 diff --git a/jeecg-boot/jeecg-boot-module-system/pom.xml b/jeecg-boot/jeecg-boot-module-system/pom.xml index 47eb4bf..157365a 100644 --- a/jeecg-boot/jeecg-boot-module-system/pom.xml +++ b/jeecg-boot/jeecg-boot-module-system/pom.xml @@ -110,6 +110,13 @@ 3.17 + + + com.belerweb + pinyin4j + 2.5.1 + + org.jeecgframework.boot jeecg-boot-module-cms diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/controller/BugxController.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/controller/BugxController.java index 5145640..fb57e9c 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/controller/BugxController.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/controller/BugxController.java @@ -1,23 +1,19 @@ package org.jeecg.modules.demo.bugx.controller; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.beanutils.PropertyUtils; import org.apache.shiro.SecurityUtils; import org.jeecg.common.api.vo.Result; import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.util.oConvertUtils; import org.jeecg.modules.demo.bugx.entity.Bugx; +import org.jeecg.modules.demo.bugx.entity.BugxExportDto; import org.jeecg.modules.demo.bugx.service.IBugxService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -34,18 +30,14 @@ import org.jeecg.modules.modulex.entity.Modulex; import org.jeecg.modules.modulex.mapper.ModulexMapper; import org.jeecg.modules.projectx.entity.Projectx; import org.jeecg.modules.projectx.mapper.ProjectxMapper; -import org.jeecgframework.poi.excel.ExcelImportUtil; import org.jeecgframework.poi.excel.def.NormalExcelConstants; import org.jeecgframework.poi.excel.entity.ExportParams; -import org.jeecgframework.poi.excel.entity.ImportParams; import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; import org.jeecg.common.system.base.controller.JeecgController; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.servlet.ModelAndView; -import com.alibaba.fastjson.JSON; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.jeecg.common.aspect.annotation.AutoLog; @@ -279,7 +271,92 @@ public class BugxController extends JeecgController { */ @RequestMapping(value = "/exportXls") public ModelAndView exportXls(HttpServletRequest request, Bugx bugx) { - return super.exportXls(request, bugx, Bugx.class, "BUG管理"); + return this.exportXlss(request, bugx, BugxExportDto.class, "BUG管理"); + } + protected ModelAndView exportXlss(HttpServletRequest request, Bugx bugx, Class clazz, String title) { + // Step.1 组装查询条件 + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(bugx, request.getParameterMap()); + LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + + + String getRealname = "佚名"; + if (sysUser != null) { + getRealname = sysUser.getRealname(); + } + + // Step.2 获取导出数据 + List pageList = bugxService.list(queryWrapper); + List exportList = null; + List BugxExportDtoList =new ArrayList<>(); + for (Bugx bugx1 : pageList) { + BugxExportDto BugxExportDto = new BugxExportDto(); + BeanUtils.copyProperties(bugx1,BugxExportDto); + String projectId = bugx1.getProjectId(); + Projectx projectx = projectxMapper.selectById(projectId); + if (projectx!=null) + BugxExportDto.setProjectId(projectx.getProjectName()); + //模块id + String moduleId = bugx1.getModuleId(); + Modulex modulex = modulexMapper.selectById(moduleId); + if (modulex!=null) + BugxExportDto.setModuleId(modulex.getModuleName()); + //功能id + String functionId = bugx1.getFunctionId(); + Functionx functionx = functionxMapper.selectById(functionId); + if (functionx!=null) + BugxExportDto.setFunctionId(functionx.getFunctionName()); + //规则id + String ruleId = bugx1.getRuleId(); + Rulex rulex = rulexMapper.selectById(ruleId); + if (rulex!=null) + BugxExportDto.setRulePm_desc(rulex.getPmDescribe()); + //bug状态 + Integer bugStatus = bugx1.getBugStatus(); + if (bugStatus.equals(1)){ + BugxExportDto.setBugStatusName("已解决"); + } else if (bugStatus.equals(3)) + BugxExportDto.setBugStatusName("待修改"); + else if (bugStatus.equals(0)) + BugxExportDto.setBugStatusName("未解决"); + //bug类型 + Integer type = bugx1.getType(); + if (type.equals(1)){ + BugxExportDto.setTypeName("模块"); + } else if (type.equals(3)) + BugxExportDto.setTypeName("规则"); + else if (type.equals(0)) + BugxExportDto.setTypeName("项目"); + else if (type.equals(2)) + BugxExportDto.setTypeName("功能"); + BugxExportDtoList.add(BugxExportDto); + } + // 过滤选中数据 + String selections = request.getParameter("selections"); + if (oConvertUtils.isNotEmpty(selections)) { + List selectionList = Arrays.asList(selections.split(",")); + exportList = BugxExportDtoList.stream().filter(item -> selectionList.contains(getId(item))).collect(Collectors.toList()); + } else { + exportList = BugxExportDtoList; + } + // Step.3 AutoPoi 导出Excel + ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); + mv.addObject(NormalExcelConstants.FILE_NAME, title); //此处设置的filename无效 ,前端会重更新设置一下 + mv.addObject(NormalExcelConstants.CLASS, clazz); + //update-begin--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置-------------------- + ExportParams exportParams = new ExportParams(title + "报表", "导出人:" + getRealname, title); + exportParams.setImageBasePath(upLoadPath); + //update-end--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置---------------------- + mv.addObject(NormalExcelConstants.PARAMS, exportParams); + mv.addObject(NormalExcelConstants.DATA_LIST, exportList); + return mv; + } + protected String getId(BugxExportDto item) { + try { + return PropertyUtils.getProperty(item, "id").toString(); + } catch (Exception e) { + e.printStackTrace(); + return null; + } } /** diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/entity/Bugx.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/entity/Bugx.java index abdc0dc..3f77da5 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/entity/Bugx.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/entity/Bugx.java @@ -63,23 +63,24 @@ public class Bugx implements Serializable { /**项目id*/ @Excel(name = "项目id", width = 15) @ApiModelProperty(value = "项目id") - @Dict(dicText = "project_code",dicCode = "id",dictTable = "projectx") + @Dict(dicCode = "id",dicText = "project_code",dictTable = "projectx") private java.lang.String projectId; /**对应模块id*/ @Excel(name = "对应模块id", width = 15) @ApiModelProperty(value = "对应模块id") - @Dict(dicText = "module_code",dicCode = "id",dictTable = "modulex") + @Dict(dicCode = "id",dicText = "module_code",dictTable = "modulex") private java.lang.String moduleId; /**对应功能id*/ @Excel(name = "对应功能id", width = 15) @ApiModelProperty(value = "对应功能id") - @Dict(dicText = "function_code",dicCode = "id",dictTable = "functionx") + @Dict(dicCode = "id",dicText = "function_code",dictTable = "functionx") private java.lang.String functionId; /**对应规则id*/ @Excel(name = "对应规则id", width = 15) @ApiModelProperty(value = "对应规则id") - @Dict(dicText = "rule_code",dicCode = "id",dictTable = "rulex") + @Dict(dicCode = "id",dicText = "rule_code",dictTable = "rulex") private java.lang.String ruleId; + /**BUG等级*/ @Excel(name = "BUG等级", width = 15) @ApiModelProperty(value = "BUG等级") diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/entity/BugxExportDto.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/entity/BugxExportDto.java new file mode 100644 index 0000000..ec953d5 --- /dev/null +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/entity/BugxExportDto.java @@ -0,0 +1,143 @@ +package org.jeecg.modules.demo.bugx.entity; + +import java.io.Serializable; + +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 lombok.Data; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.jeecgframework.poi.excel.annotation.ExcelIgnore; +import org.springframework.format.annotation.DateTimeFormat; +import org.jeecgframework.poi.excel.annotation.Excel; +import org.jeecg.common.aspect.annotation.Dict; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * @Description: BUG管理 + * @Author: jeecg-boot + * @Date: 2023-04-11 + * @Version: V1.0 + */ +@Data +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = false) +@ApiModel(value="bugx对象", description="BUG管理") +public class BugxExportDto implements Serializable { + private static final long serialVersionUID = 1L; + + /**主键*/ + @ApiModelProperty(value = "主键") + private java.lang.String id; + /**创建人*/ + @ApiModelProperty(value = "创建人") + private java.lang.String createBy; + /**创建日期*/ + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "创建日期") + private java.util.Date createTime; + /**更新人*/ + @ApiModelProperty(value = "更新人") + private java.lang.String updateBy; + /**更新日期*/ + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "更新日期") + private java.util.Date updateTime; + /**BUG编码*/ + @Excel(name = "BUG编码", width = 15) + @ApiModelProperty(value = "BUG编码") + private java.lang.String bugCode; + /**BUG类型*/ + @ExcelIgnore() + @ApiModelProperty(value = "BUG类型") + @Dict(dicCode = "bug_type") + private java.lang.Integer type; + + @TableField(exist = false) + @Excel(name = "BUG类型", width = 15) + private java.lang.String typeName; + /**项目id*/ + @Excel(name = "项目", width = 15) + @ApiModelProperty(value = "项目id") + @Dict(dicCode = "id",dicText = "project_code",dictTable = "projectx") + private java.lang.String projectId; + /**对应模块id*/ + @Excel(name = "对应模块", width = 15) + @ApiModelProperty(value = "对应模块id") + @Dict(dicCode = "id",dicText = "module_code",dictTable = "modulex") + private java.lang.String moduleId; + /**对应功能id*/ + @Excel(name = "对应功能", width = 15) + @ApiModelProperty(value = "对应功能id") + @Dict(dicCode = "id",dicText = "function_code",dictTable = "functionx") + private java.lang.String functionId; + /**对应规则id*/ + + @ExcelIgnore + @ApiModelProperty(value = "对应规则id") + @Dict(dicCode = "id",dicText = "rule_code",dictTable = "rulex") + private java.lang.String ruleId; + + @Excel(name = "对应规则", width = 15) + @TableField(exist = false) + private java.lang.String rulePm_desc; + /**BUG等级*/ + @Excel(name = "BUG等级", width = 15) + @ApiModelProperty(value = "BUG等级") + @Dict(dicCode = "work_level") + private java.lang.Integer bugLevel; + /**BUG描述*/ + @Excel(name = "BUG描述", width = 15) + @ApiModelProperty(value = "BUG描述") + private java.lang.String pmDesc; + /**BUG图片*/ + @Excel(name = "BUG图片", width = 15) + @ApiModelProperty(value = "BUG图片") + private java.lang.String bugPic; + /**发布时间*/ + @Excel(name = "发布时间", width = 15, format = "yyyy-MM-dd") + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "发布时间") + private java.util.Date publishTime; + /**提交内容*/ + @Excel(name = "提交内容", width = 15) + @ApiModelProperty(value = "提交内容") + private java.lang.String submitContent; + /**提交图片*/ + @Excel(name = "提交图片", width = 15) + @ApiModelProperty(value = "提交图片") + private java.lang.String submitPic; + /**责任人*/ + @Excel(name = "责任人", width = 15) + @ApiModelProperty(value = "责任人") + private java.lang.String managerUsers; + /**BUG状态*/ + @ExcelIgnore + @ApiModelProperty(value = "BUG状态") + @Dict(dicCode = "bug_status") + private java.lang.Integer bugStatus; + + @TableField(exist = false) + @Excel(name = "BUG状态", width = 15) + private java.lang.String bugStatusName; + + /**提交时间*/ + @Excel(name = "提交时间", width = 15, format = "yyyy-MM-dd") + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "提交时间") + private java.util.Date submitTime; + /**审核时间*/ + @Excel(name = "审核时间", width = 15, format = "yyyy-MM-dd") + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "审核时间") + private java.util.Date auditTime; +} diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/mapper/BugxMapper.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/mapper/BugxMapper.java index 49d9b7a..dff4f73 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/mapper/BugxMapper.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/mapper/BugxMapper.java @@ -1,12 +1,12 @@ package org.jeecg.modules.demo.bugx.mapper; import java.util.Date; -import java.util.List; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; import org.jeecg.modules.demo.bugx.entity.Bugx; +import org.jeecg.modules.demo.bugx.entity.BugxExportDto; import com.baomidou.mybatisplus.core.mapper.BaseMapper; /** diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/service/IBugxService.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/service/IBugxService.java index 2a173c9..2571cfe 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/service/IBugxService.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/service/IBugxService.java @@ -2,6 +2,7 @@ package org.jeecg.modules.demo.bugx.service; import org.jeecg.common.api.vo.Result; import org.jeecg.modules.demo.bugx.entity.Bugx; +import org.jeecg.modules.demo.bugx.entity.BugxExportDto; import com.baomidou.mybatisplus.extension.service.IService; /** diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/service/impl/BugxServiceImpl.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/service/impl/BugxServiceImpl.java index 52c2106..fa90f99 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/service/impl/BugxServiceImpl.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/bugx/service/impl/BugxServiceImpl.java @@ -2,6 +2,7 @@ package org.jeecg.modules.demo.bugx.service.impl; import org.jeecg.common.api.vo.Result; import org.jeecg.modules.demo.bugx.entity.Bugx; +import org.jeecg.modules.demo.bugx.entity.BugxExportDto; import org.jeecg.modules.demo.bugx.mapper.BugxMapper; import org.jeecg.modules.demo.bugx.service.IBugxService; import org.springframework.beans.factory.annotation.Autowired; diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/functionx/entity/FunctionxTest.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/functionx/entity/FunctionxTest.java index 7ac0734..daa02f1 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/functionx/entity/FunctionxTest.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/functionx/entity/FunctionxTest.java @@ -52,11 +52,6 @@ public class FunctionxTest implements Serializable { */ private String pmDescribe; - /** - * 分析图 - */ - private String diagrams; - /** * 用户角色 */ diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/functionx/service/impl/FunctionXTestServiceImpl.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/functionx/service/impl/FunctionXTestServiceImpl.java index 3d0031b..b11e5fb 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/functionx/service/impl/FunctionXTestServiceImpl.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/functionx/service/impl/FunctionXTestServiceImpl.java @@ -101,19 +101,18 @@ public class FunctionXTestServiceImpl extends ServiceImpl queryWrapperUser = new LambdaQueryWrapper<>(); queryWrapperUser.eq(ProjectUserRole::getUserRole,userRole); // 是否匹配项目id? diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/requirementtype/entity/RequirementType.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/requirementtype/entity/RequirementType.java index 3a76744..65e445f 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/requirementtype/entity/RequirementType.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/requirementtype/entity/RequirementType.java @@ -57,12 +57,12 @@ public class RequirementType implements Serializable { @ApiModelProperty(value = "所属部门") private java.lang.String sysOrgCode; /**项目id*/ - @Excel(name = "项目id", width = 15, dictTable = "projectx", dicText = "project_name", dicCode = "id") + @Excel(name = "项目", width = 15, dictTable = "projectx", dicText = "project_name", dicCode = "id") @Dict(dictTable = "projectx", dicText = "project_name", dicCode = "id") @ApiModelProperty(value = "项目id") private java.lang.String projectId; /**上级类型id*/ - @Excel(name = "上级类型id", width = 15, dictTable = "requirement_type", dicText = "type_name", dicCode = "id") + @Excel(name = "上级类型", width = 15, dictTable = "requirement_type", dicText = "type_name", dicCode = "id") @Dict(dictTable = "requirement_type", dicText = "type_name", dicCode = "id") @ApiModelProperty(value = "上级类型id") private java.lang.String upperId; diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/controller/RulexController.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/controller/RulexController.java index 26646d4..a1ab599 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/controller/RulexController.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/controller/RulexController.java @@ -329,7 +329,7 @@ public class RulexController extends JeecgController { if (ruleVoList.size() <= 0 || ruleVoList == null) { message.put("isVisible", "false"); webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("文件导入失败,模板不匹配"); + return Result.error("文件导入失败,模板不匹配有空值"); } // 将总的记录数传递给前端 message.put("records", String.valueOf(ruleVoList.size())); @@ -421,31 +421,44 @@ public class RulexController extends JeecgController { } rulex.setWorkLevel(integer); String workStatus = ruleVo.getWorkStatus(); - LambdaQueryWrapper sysDictItemLambdaQueryWrapper = new LambdaQueryWrapper<>(); - sysDictItemLambdaQueryWrapper.eq(SysDictItem::getItemText, workStatus).eq(SysDictItem::getDictId, "1645268542514421762"); - SysDictItem sysDictItem = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper); - if (sysDictItem == null) { +// LambdaQueryWrapper sysDictItemLambdaQueryWrapper = new LambdaQueryWrapper<>(); +// sysDictItemLambdaQueryWrapper.eq(SysDictItem::getItemText, workStatus).eq(SysDictItem::getDictId, "1645268542514421762"); +// SysDictItem sysDictItem = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper); + + if (workStatus.equals("未发布")) + rulex.setWorkStatus(0); + else if (workStatus.equals("已发布")) + rulex.setWorkStatus(1); + else if (workStatus.equals("开发中")) + rulex.setWorkStatus(2); + else if(workStatus.equals("已完成")) + rulex.setWorkStatus(3); + else if(workStatus.equals("已撤回")) + rulex.setWorkStatus(4); + else if(workStatus.equals("DEBUG")) + rulex.setWorkStatus(9); + else { iRuleVoService.remove(null); message.put("isVisible", "false"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("任务状态输入错误,请核对"); } - - rulex.setWorkStatus(Integer.valueOf(sysDictItem.getItemValue())); - String status = ruleVo.getStatus(); - LambdaQueryWrapper sysDictItemLambdaQueryWrapper2 = new LambdaQueryWrapper<>(); - sysDictItemLambdaQueryWrapper2.eq(SysDictItem::getItemText, status).eq(SysDictItem::getDictId, "1645264493205491713"); - SysDictItem sysDictItem2 = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper2); - if (sysDictItem2 == null) { +// LambdaQueryWrapper sysDictItemLambdaQueryWrapper2 = new LambdaQueryWrapper<>(); +// sysDictItemLambdaQueryWrapper2.eq(SysDictItem::getItemText, status).eq(SysDictItem::getDictId, "1645264493205491713"); +// SysDictItem sysDictItem2 = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper2); + if (status.equals("正常")) + rulex.setStatus(1); + else if (status.equals("停用")) + rulex.setStatus(0); + else if (status.equals("废弃")) + rulex.setStatus(9); + else { iRuleVoService.remove(null); message.put("isVisible", "false"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("规则状态输入错误,请核对"); } - - - rulex.setStatus(Integer.valueOf(sysDictItem2.getItemValue())); String verisonStatus = ruleVo.getVerisonStatus(); LambdaQueryWrapper sysDictItemLambdaQueryWrapper3 = new LambdaQueryWrapper<>(); sysDictItemLambdaQueryWrapper3.eq(SysDictItem::getItemText, verisonStatus); diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/entity/RuleVo.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/entity/RuleVo.java index 7645c11..a72aed4 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/entity/RuleVo.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/entity/RuleVo.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import com.fasterxml.jackson.annotation.JsonFormat; +import org.jeecg.common.aspect.annotation.Dict; import org.springframework.format.annotation.DateTimeFormat; import org.jeecgframework.poi.excel.annotation.Excel; //import org.jeecg.common.aspect.annotation.Dict; @@ -61,15 +62,15 @@ public class RuleVo implements Serializable { /** * 对应模块id */ - @Excel(name = "对应模块id", width = 15) - @ApiModelProperty(value = "对应模块id") -// /*@Dict(dictTable = "modulex", dicCode = "id", dicText = "module_name")*/ + @Excel(name = "对应模块", width = 15) + @ApiModelProperty(value = "对应模块") + @Dict(dictTable = "modulex", dicCode = "id", dicText = "module_name") private java.lang.String moduleId; /** * 对应功能id */ - @Excel(name = "对应功能id", width = 15) - @ApiModelProperty(value = "对应功能id") + @Excel(name = "对应功能", width = 15) + @ApiModelProperty(value = "对应功能") // /*@Dict(dictTable = "functionx", dicCode = "id", dicText = "function_name")*/ private java.lang.String functionId; /** @@ -99,8 +100,8 @@ public class RuleVo implements Serializable { /** * 对应实体id */ - @Excel(name = "对应实体id", width = 15) - @ApiModelProperty(value = "对应实体id") + @Excel(name = "对应实体", width = 15) + @ApiModelProperty(value = "对应实体") // @Dict(dictTable = "tablex", dicText = "table_name", dicCode = "id") private java.lang.String tableId; /** diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/entity/Rulex.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/entity/Rulex.java index 9fb343e..e340ffb 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/entity/Rulex.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/rulex/entity/Rulex.java @@ -66,14 +66,14 @@ public class Rulex implements Serializable { * 对应模块id */ @Excel(name = "对应模块id", width = 15) - @ApiModelProperty(value = "对应模块id") + @ApiModelProperty(value = "对应模块") @Dict(dictTable = "modulex", dicCode = "id", dicText = "module_name") private java.lang.String moduleId; /** * 对应功能id */ @Excel(name = "对应功能id", width = 15) - @ApiModelProperty(value = "对应功能id") + @ApiModelProperty(value = "对应功能") @Dict(dictTable = "functionx", dicCode = "id", dicText = "function_name") private java.lang.String functionId; /** @@ -104,7 +104,7 @@ public class Rulex implements Serializable { * 对应实体id */ @Excel(name = "对应实体id", width = 15) - @ApiModelProperty(value = "对应实体id") + @ApiModelProperty(value = "对应实体") @Dict(dictTable = "tablex", dicText = "table_name", dicCode = "id") private java.lang.String tableId; /** diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/controller/FieldxController.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/controller/FieldxController.java index ef5344e..b290aba 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/controller/FieldxController.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/controller/FieldxController.java @@ -11,7 +11,10 @@ import com.aliyuncs.utils.StringUtils; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; 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.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; @@ -31,6 +34,7 @@ import lombok.extern.slf4j.Slf4j; import org.jeecg.modules.tablex.entity.Tablex; import org.jeecg.modules.tablex.service.ITablexService; import org.jeecg.common.system.base.controller.JeecgController; +import org.jsoup.helper.StringUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -301,15 +305,97 @@ public class FieldxController extends JeecgController { return Result.error("文件格式上传有误"); } //根据格式读取 + InputStream inputStream=file.getInputStream(); + Workbook workbook=null; + if (path.endsWith(".xls")) { + workbook=new HSSFWorkbook(inputStream); + } + else { + workbook = new XSSFWorkbook(inputStream); + } + //读取表 List list = new ArrayList<>(); + //获取excel的所有页 + int numberofSheets= workbook.getNumberOfSheets(); + for (int i=0;i< numberofSheets;i++) + { + Sheet Sheet=workbook.getSheetAt(i); + //判断表结构 + Row row=Sheet.getRow(3); + if(row==null) + return Result.error("表结构不能为空"); - if (path.endsWith(".xls")) { - list = readXLS(file); - } else list = readXLSX(file); + for(int r=3;r<=Sheet.getLastRowNum();r++) { + Row cells = Sheet.getRow(r); + String cell = cells.getCell(0).getStringCellValue(); + if (StringUtils.isEmpty(cell)) { + break; + } + ExcelInfo excelInfo = new ExcelInfo(); + excelInfo.setcells(cells); + Fieldx222 fieldx222 = new Fieldx222(); + if (StringUtil.isBlank(excelInfo.getTableId())) { + return Result.error("序号为" + (r - 2) + "的表名不能为空"); + } + fieldx222.setTableId(excelInfo.getTableId()); + if (StringUtil.isBlank(excelInfo.getFieldName())) { + return Result.error("序号为" + (r - 2) + "的中文名称不能为空"); + } + fieldx222.setFieldName(excelInfo.getFieldName()); + if (StringUtil.isBlank(excelInfo.getFieldEnName())) { + return Result.error("序号为" + (r - 2) + "的英文名称不能为空"); + } + fieldx222.setFieldEnName(excelInfo.getFieldEnName()); + if (StringUtil.isBlank(excelInfo.getType())) { + return Result.error("序号为" + (r - 2) + "的数据类型不能为空"); + } + fieldx222.setType(excelInfo.getType()); + if (StringUtil.isBlank(excelInfo.getLength())) { + return Result.error("序号为" + (r - 2) + "的数据长度不能为空"); + } + fieldx222.setLength(excelInfo.getLength()); + if (StringUtil.isBlank(excelInfo.getIsPk())) { + return Result.error("序号为" + (r - 2) + "的是否主键不能为空"); + } + fieldx222.setIsPk(excelInfo.getIsPk()); + if (StringUtil.isBlank(excelInfo.getIsFk())) { + return Result.error("序号为" + (r - 2) + "的是否外键不能为空"); + } + fieldx222.setIsFk(excelInfo.getIsFk()); + if (StringUtil.isBlank(excelInfo.getIsNull())) { + return Result.error("序号为" + (r - 2) + "的是否为空不能为空"); + } + fieldx222.setIsNull(excelInfo.getIsNull()); + if (StringUtil.isBlank(excelInfo.getIsUniqueness())) { + return Result.error("序号为" + (r - 2) + "的是否重复不能为空"); + } + fieldx222.setIsUniqueness(excelInfo.getIsUniqueness()); + if (StringUtil.isBlank(excelInfo.getVerisonStatus())) { + return Result.error("序号为" + (r - 2) + "的字段状态不能为空"); + } + fieldx222.setVerisonStatus(excelInfo.getVerisonStatus()); + if (StringUtil.isBlank(excelInfo.getVerison())) { + return Result.error("序号为" + (r - 2) + "的版本状态不能为空"); + } + fieldx222.setVerison(excelInfo.getVerison()); + if (!StringUtils.isEmpty(excelInfo.getAccuracy())) + fieldx222.setAccuracy(excelInfo.getAccuracy()); + if (!StringUtils.isEmpty(excelInfo.getFormat())) + fieldx222.setFormat(excelInfo.getFormat()); + if (!StringUtils.isEmpty(excelInfo.getAssociateTable())) + fieldx222.setAssociateTable(excelInfo.getAssociateTable()); + if (!StringUtils.isEmpty(excelInfo.getAssociateField())) + fieldx222.setAssociateField(excelInfo.getAssociateField()); + if (!StringUtils.isEmpty(excelInfo.getRule())) + fieldx222.setRull(excelInfo.getRule()); + list.add(fieldx222); + } + } fieldx222Service.saveBatch(list); List list222 = fieldx222Service.list(); + fieldx222Service.remove(null); if(list222==null) return Result.error("文件上传失败"); List list1= list222.stream().map((item)->{ @@ -338,86 +424,10 @@ public class FieldxController extends JeecgController { fieldx.setRule(item.getRull()); return fieldx; }).collect(Collectors.toList()); - fieldx222Service.remove(null); fieldxService.saveBatch(list1); return Result.OK("文件上传成功"); - } - public List readXLS(MultipartFile file) throws IOException { - List list=new ArrayList<>(); - InputStream inputStream=file.getInputStream(); - HSSFWorkbook workbook=new HSSFWorkbook(inputStream); - //读取表 - HSSFSheet hssfSheet=workbook.getSheetAt(0); - for(int r=3;r<=hssfSheet.getLastRowNum();r++){ - HSSFRow cells =hssfSheet.getRow(r); - String cell=cells.getCell(0).getStringCellValue(); - if(StringUtils.isEmpty(cell)){ - break; - } - ExcelInfo excelInfo = new ExcelInfo(); - excelInfo.setcells(cells); - Fieldx222 fieldx=copy(excelInfo); - list.add(fieldx); - } - return list; - } - public List readXLSX(MultipartFile file) throws IOException { - List list=new ArrayList<>(); - InputStream inputStream=file.getInputStream(); - XSSFWorkbook workbook=new XSSFWorkbook(inputStream); - //读取表 - XSSFSheet hssfSheet=workbook.getSheetAt(0); - for(int r=3;r<=hssfSheet.getLastRowNum();r++){ - XSSFRow cells =hssfSheet.getRow(r); - String cell=cells.getCell(0).getStringCellValue(); - if(StringUtils.isEmpty(cell)){ - break; - } - ExcelInfo excelInfo=new ExcelInfo(); - excelInfo.setcells(cells); - Fieldx222 fieldx=copy(excelInfo); - list.add(fieldx); - } - return list; - } - private Fieldx222 copy(ExcelInfo excelInfo){ - Fieldx222 fieldx222=new Fieldx222(); - if(pdNull(excelInfo.getTableId())||pdNull((excelInfo.getFieldName()))||pdNull((excelInfo.getFieldEnName()))|| - pdNull((excelInfo.getType()))||pdNull((excelInfo.getLength()))||pdNull((excelInfo.getIsPk()))|| - pdNull((excelInfo.getIsFk()))||pdNull((excelInfo.getIsNull()))||pdNull((excelInfo.getIsUniqueness()))|| - pdNull((excelInfo.getVerison()))||pdNull((excelInfo.getVerison()))) - return null; - fieldx222.setTableId(excelInfo.getTableId()); - fieldx222.setFieldName(excelInfo.getFieldName()); - fieldx222.setFieldEnName(excelInfo.getFieldEnName()); - fieldx222.setType(excelInfo.getType()); - fieldx222.setLength(excelInfo.getLength()); - fieldx222.setIsPk(excelInfo.getIsPk()); - fieldx222.setIsFk(excelInfo.getIsFk()); - fieldx222.setIsNull(excelInfo.getIsNull()); - fieldx222.setIsUniqueness(excelInfo.getIsUniqueness()); - fieldx222.setVerisonStatus(excelInfo.getVerisonStatus()); - fieldx222.setVerison(excelInfo.getVerison()); - if(!StringUtils.isEmpty(excelInfo.getAccuracy())) - fieldx222.setAccuracy(excelInfo.getAccuracy()); - if(!StringUtils.isEmpty(excelInfo.getFormat())) - fieldx222.setFormat(excelInfo.getFormat()); - if(!StringUtils.isEmpty(excelInfo.getAssociateTable())) - fieldx222.setAssociateTable(excelInfo.getAssociateTable()); - if(!StringUtils.isEmpty(excelInfo.getAssociateField())) - fieldx222.setAssociateField(excelInfo.getAssociateField()); - if(!StringUtils.isEmpty(excelInfo.getRule())) - fieldx222.setRull(excelInfo.getRule()); - return fieldx222; - } - public boolean pdNull(Object object){ - if (object == null) - return true; - else - return false; - } // 生成sql public String createSql(String tableId){ diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/dto/ExcelInfo.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/dto/ExcelInfo.java index 9b98666..163cef2 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/dto/ExcelInfo.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/dto/ExcelInfo.java @@ -121,7 +121,7 @@ public class ExcelInfo { return "1"; if(value.equals("SMALLINT")) return "2"; - if(value.equals("MEDIUMINT")||value.equals("废弃")) + if(value.equals("MEDIUMINT")) return "3"; if(value.equals("INT")) return "4"; @@ -133,7 +133,7 @@ public class ExcelInfo { return "7"; if(value.equals("DECIMAL")) return "8"; - if(value.equals("YEAR")) + if(value.equals("YEAR")||value.equals("废弃")) return "9"; if(value.equals("TIME")) return "10"; 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 index 328efab..9cfca17 100644 --- 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 @@ -171,18 +171,7 @@ public class ModulexTemplate implements Serializable { @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 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 485d49d..ab443a0 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 @@ -42,4 +42,5 @@ public interface IModulexService extends IService { List exportXlslist(HttpServletRequest request, String selections,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/impl/ModulexServiceImpl.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexServiceImpl.java index 5f596a7..d941267 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 @@ -4,6 +4,11 @@ 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 net.sourceforge.pinyin4j.PinyinHelper; +import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType; +import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; +import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; +import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; @@ -479,12 +484,6 @@ public class ModulexServiceImpl extends ServiceImpl impl modulexVo.setRelatedBean(value); break; case 16: - modulexVo.setPrototypes(value); - break; - case 17: - modulexVo.setDiagrams(value); - break; - case 18: if (value == null || value == "") { message.put("isVisible", "false"); webSocketUtils.sendMessage(loginUser.getId(), message); @@ -492,7 +491,7 @@ public class ModulexServiceImpl extends ServiceImpl impl } modulexVo.setStatus(value); break; - case 19: + case 17: if (value == null || value == "") { message.put("isVisible", "false"); webSocketUtils.sendMessage(loginUser.getId(), message); @@ -500,7 +499,7 @@ public class ModulexServiceImpl extends ServiceImpl impl } modulexVo.setVerisonStatus(value); break; - case 20: + case 18: if (value == null || value == "") { message.put("isVisible", "false"); webSocketUtils.sendMessage(loginUser.getId(), message); @@ -621,6 +620,23 @@ public class ModulexServiceImpl extends ServiceImpl impl webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,模块编码不能为空或者模块编码过长"); } + String modulecode = null; + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Projectx::getProjectName,projectId); + Projectx projectx = projectxService.getOne(queryWrapper); + String firstChar = this.toFirstChar(moduleName); + String projectCode = projectx.getProjectCode(); + if(projectCode==null){ + message.put("isVisible", "false"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("项目编码不存在,请重新填写"); + } + modulecode = projectCode + firstChar; + if(!modulecode.equals(moduleCode)){ + message.put("isVisible", "false"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("模块编码不规范,导入失败"); + } modulex.setModuleCode(moduleCode); String pmDescribe = modulexTemplate.getPmDescribe(); if(StringUtils.isBlank(pmDescribe)){ @@ -631,20 +647,23 @@ public class ModulexServiceImpl extends ServiceImpl impl modulex.setManagerUsers(null); }else { LambdaQueryWrapper sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); - sysUserLambdaQueryWrapper.eq(SysUser::getUsername,managerUsers); - SysUser iSysUserServiceOne = iSysUserService.getOne(sysUserLambdaQueryWrapper); + String[] split = managerUsers.split(","); +// sysUserLambdaQueryWrapper.eq(SysUser::getUsername,managerUsers); + sysUserLambdaQueryWrapper.in(SysUser::getUsername,split); + List iSysUserServiceOne = iSysUserService.list(sysUserLambdaQueryWrapper); if(iSysUserServiceOne==null){ message.put("isVisible", "false"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,责任人信息查询不到"); }else { - String id = iSysUserServiceOne.getId(); - if (id == null) { + List list = iSysUserServiceOne.stream().map(SysUser::getId).collect(Collectors.toList()); +// String id = iSysUserServiceOne.getId(); + if (list == null) { message.put("isVisible", "false"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,责任人信息查询不到"); } - modulex.setManagerUsers(id); + modulex.setManagerUsers(String.valueOf(list)); } } String workLevel = modulexTemplate.getWorkLevel(); @@ -784,14 +803,6 @@ public class ModulexServiceImpl extends ServiceImpl impl 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)){ message.put("isVisible", "false"); @@ -1179,4 +1190,32 @@ public class ModulexServiceImpl extends ServiceImpl impl moduleFunctionRule.setVerison(x.getVerison()); return moduleFunctionRule; } + + /** + * 获取字符串拼音的第一个字母 + * @param chinese + * @return + */ + public static String toFirstChar(String chinese){ + String pinyinStr = ""; + char[] newChar = chinese.toCharArray(); //转为单个字符 + HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat(); + defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE); + defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE); + for (int i = 0; i < newChar.length; i++) { + if (newChar[i] > 128) { + try { + pinyinStr += PinyinHelper.toHanyuPinyinStringArray(newChar[i], defaultFormat)[0].charAt(0); + } catch (BadHanyuPinyinOutputFormatCombination e) { + e.printStackTrace(); + } + }else{ + pinyinStr += newChar[i]; + } + } + return pinyinStr; + } + + + } diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java index 7b0296c..50d0f3a 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java @@ -298,7 +298,7 @@ public class TablexController extends JeecgController { //获取上传文件对象 ImportParams params = new ImportParams(); - params.setTitleRows(2);//表格标题行数,默认0 + params.setTitleRows(1);//表格标题行数,默认0 params.setHeadRows(1);//表头行数,默认1 params.setNeedSave(true);//是否需要保存上传的Excel,默认为false List list = null; diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/task/controller/TaskController.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/task/controller/TaskController.java index b405c25..f378790 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/task/controller/TaskController.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/task/controller/TaskController.java @@ -39,11 +39,10 @@ import org.springframework.web.servlet.ModelAndView; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; +import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.Optional; +import java.util.*; /** * @Description: 任务管理 @@ -62,6 +61,14 @@ public class TaskController extends JeecgController { private static final String ADMIN = "admin"; private static final String FORMAT = "yyyy/MM/dd HH:mm:ss"; + private static final long DAYWORKTIME = 35*60*60*100*2; + private static final long DAYTIME = 24*60*60*1000; + + private static final String MORINGSTART = " 08:30:00"; + private static final String MORINGEND = " 12:00:00"; + private static final String AFTERNOONSTART = " 14:30:00"; + private static final String AFTERNOONEND= " 18:00:00"; + @Resource private IProjectxService iProjectxService; @@ -91,17 +98,178 @@ public class TaskController extends JeecgController { @ApiOperation(value = "任务管理-分页列表查询", notes = "任务管理-分页列表查询") @GetMapping(value = "/list") public Result queryPageList(Task task, + @RequestParam(name = "type", required = false) List type, + @RequestParam(name = "userName", defaultValue = "") String userName, + @RequestParam(name = "time", required = false) Integer time, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, - HttpServletRequest req) { - QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(task, req.getParameterMap()); + HttpServletRequest req) throws ParseException { + QueryWrapper queryWrapper = new QueryWrapper<>(); Page page = new Page(pageNo, pageSize); LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); if (!StringUtils.equals(ADMIN, user.getUsername())) { queryWrapper.like("manager_users", user.getId()); } - queryWrapper.orderByDesc("create_time"); + if (type != null && type.size() > 0) + queryWrapper.and(qw -> { + for (int i = 0; i < type.size(); i++) { + qw.eq("type_id", type.get(i)); + if (i != type.size() - 1) + qw.or(); + } + }); +// projectId + Calendar now = Calendar.getInstance(); + int year = now.get(Calendar.YEAR); + int month = now.get(Calendar.MONTH) + 1; + int day = now.get(Calendar.DAY_OF_MONTH); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + if (time != null) { + switch (time) { + case 1: {//当前天 + Date startTime = sdf.parse(year + "-" + month + "-" + day + " 00:00:00"); + Date endTime = sdf.parse(year + "-" + month + "-" + day + " 23:59:59"); + queryWrapper.ge("start_time", startTime); + queryWrapper.le("start_time", endTime); + break; + } + case 2: {//当前周 + Calendar now1 = Calendar.getInstance(); + now1.set(Calendar.DAY_OF_WEEK, 2); + int year1 = now1.get(Calendar.YEAR); + int month1 = now1.get(Calendar.MONTH) + 1; + int day1 = now1.get(Calendar.DAY_OF_MONTH); + now1.set(Calendar.DATE, now1.get(Calendar.DATE) + 6); + int year2 = now1.get(Calendar.YEAR); + int month2 = now1.get(Calendar.MONTH) + 1; + int day2 = now1.get(Calendar.DAY_OF_MONTH); + Date startTime = sdf.parse(year1 + "-" + month1 + "-" + day1 + " 00:00:00"); + Date endTime = sdf.parse(year2 + "-" + month2 + "-" + day2 + " 23:59:59"); + queryWrapper.ge("start_time", startTime); + queryWrapper.le("start_time", endTime); + } + case 3: {//当前月 + int minDay = now.getActualMinimum(Calendar.DAY_OF_MONTH); + int lastDay = now.getActualMaximum(Calendar.DAY_OF_MONTH); + Date startTime = sdf.parse(year + "-" + month + "-" + minDay + " 00:00:00"); + Date endTime = sdf.parse(year + "-" + month + "-" + lastDay + " 23:59:59"); + queryWrapper.ge("start_time", startTime); + queryWrapper.le("start_time", endTime); + break; + } +// case 4: { +// Date startTime = sdf.parse(year + "-" + month + "-" + day + " 00:00:00"); +// Date endTime = sdf.parse(year + "-" + month + "-" + day + " 23:59:59"); +// queryWrapper.ge("create_time", startTime); +// queryWrapper.le("create_time", endTime); +// break; +// } + } + } + if (task != null && StringUtils.isNotBlank(task.getModuleId())) { + String moduleId = task.getModuleId(); + queryWrapper.like("module_id", moduleId); + } + if (task != null && StringUtils.isNotBlank(task.getProjectId())) { + String projectId = task.getProjectId(); + queryWrapper.like("project_id", projectId); + } + if (task != null && StringUtils.isNotBlank(task.getTypeId())) { + String typeId = task.getTypeId(); + queryWrapper.like("type_id", typeId); + } + + if (task != null && StringUtils.isNotBlank(task.getManagerUsers())) { + String managerUsers = task.getManagerUsers(); + queryWrapper.like("manager_users", managerUsers); + } +// List sysUsers = taskService.UserIdByUserName(userName); +// queryWrapper.and(qw -> { +// for (int i = 0; i < sysUsers.size(); i++) { +// qw.like("manager_users", sysUsers.get(i).getId()); +// if (i != sysUsers.size() - 1) +// qw.or(); +// } +// }); + if (task != null && StringUtils.isNotBlank(task.getTaskName())) { + String tas = task.getTaskName(); + if (tas.startsWith("*") && tas.endsWith("*")) + tas = tas.substring(1, tas.length() - 1); + queryWrapper.like("task_name", tas); + } + if (task != null && task.getWorkStatus() != null && (task.getWorkStatus() == 0 || task.getWorkStatus() == 1)) { + queryWrapper.in("work_status", 0, 1); + } else if (task != null && task.getWorkStatus() != null && (task.getWorkStatus() == 2 || task.getWorkStatus() == 9)) { + queryWrapper.in("work_status", 2, 9); + } else if (task != null && task.getWorkStatus() != null) { + queryWrapper.eq("work_status", task.getWorkStatus()); + } + queryWrapper.orderByDesc("update_time"); + IPage pageList = taskService.page(page, queryWrapper); + pageList.getRecords().stream().forEach(e -> { + String startDate = DateUtils.date2Str(e.getStartTime(), new SimpleDateFormat(FORMAT)); + String endDate = DateUtils.date2Str(e.getExpectedEndTime(), new SimpleDateFormat(FORMAT)); + String startEndTime = startDate + "-" + endDate; + e.setStartEndTime(startEndTime); + Projectx projectx = iProjectxService.getById(e.getProjectId()); + e.setUnion(projectx.getProjectName()); + if (StringUtils.isNotBlank(e.getModuleId())) { + Modulex modulex = iModulexService.getById(e.getModuleId()); + e.setUnion(e.getUnion() + "-" + modulex.getModuleName()); + } + if (StringUtils.isNotBlank(e.getFunctionId())) { + Functionx functionx = iFunctionxService.getById(e.getFunctionId()); + e.setUnion(e.getUnion() + "-" + functionx.getFunctionName()); + } + if (StringUtils.isNotBlank(e.getRuleId())) { + Rulex rulex = iRulexService.getById(e.getRuleId()); + e.setUnion(e.getUnion() + "-" + rulex.getRuleCode()); + } + if (StringUtils.isNotBlank(e.getUpperId())) { + Task taskUpper = taskService.getById(e.getUpperId()); + if (ObjectUtils.isNotEmpty(taskUpper)) { + e.setUpperTaskName(taskUpper.getTaskName()); + } + } + if (e.getTaskFile() != null && !e.getTaskFile().equals("")) { + e.setContentType("file"); + } else if (e.getTaskPic() != null && !e.getTaskPic().equals("")) { + e.setContentType("image"); + } else { + e.setContentType("text"); + } + String managerUsers = e.getManagerUsers(); + if (managerUsers != null && !managerUsers.equals("")) { + String[] managerUsers1 = managerUsers.split(","); + StringBuilder avatars = new StringBuilder(); + for (String managerUser : managerUsers1) { + SysUser byId = iSysUserService.getById(managerUser); + if (byId != null) + + avatars.append(byId.getAvatar()).append(","); + } + avatars = new StringBuilder(avatars.substring(0, avatars.length() - 1)); + e.setHeadpic(avatars.toString()); + } + + }); + return Result.OK(pageList); + } + + @AutoLog(value = "任务管理-分页列表查询") + @ApiOperation(value = "任务管理-分页列表查询", notes = "任务管理-分页列表查询") + @GetMapping(value = "/list1") + public Result queryPageList1(Task task, + @RequestParam(name = "userId") String userId, + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, + HttpServletRequest req) { + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(task, req.getParameterMap()); + Page page = new Page(pageNo, pageSize); + queryWrapper.like("manager_users", userId); + queryWrapper.like("work_status", 3); + queryWrapper.orderByDesc("update_time"); IPage pageList = taskService.page(page, queryWrapper); pageList.getRecords().stream().forEach(e -> { String startDate = DateUtils.date2Str(e.getStartTime(), new SimpleDateFormat(FORMAT)); @@ -128,18 +296,25 @@ public class TaskController extends JeecgController { e.setUpperTaskName(taskUpper.getTaskName()); } } - if (e.getTaskFile()!=null&& !e.getTaskFile().equals("")){ + if (e.getTaskFile() != null && !e.getTaskFile().equals("")) { e.setContentType("file"); - }else if(e.getTaskPic()!=null&& !e.getTaskPic().equals("")){ + } else if (e.getTaskPic() != null && !e.getTaskPic().equals("")) { e.setContentType("image"); - }else{ + } else { e.setContentType("text"); } String managerUsers = e.getManagerUsers(); - if (managerUsers!=null&&!managerUsers.equals("")) { - SysUser byId = iSysUserService.getById(managerUsers); - if (byId!=null) - e.setHeadpic(byId.getAvatar()); + if (managerUsers != null && !managerUsers.equals("")) { + String[] managerUsers1 = managerUsers.split(","); + StringBuilder avatars = new StringBuilder(); + for (String managerUser : managerUsers1) { + SysUser byId = iSysUserService.getById(managerUser); + if (byId != null) + + avatars.append(byId.getAvatar()).append(","); + } + avatars = new StringBuilder(avatars.substring(0, avatars.length() - 1)); + e.setHeadpic(avatars.toString()); } }); @@ -174,31 +349,138 @@ public class TaskController extends JeecgController { @ApiOperation(value = "任务管理-编辑", notes = "任务管理-编辑") @PutMapping(value = "/edit") public Result edit(@RequestBody Task task) { + String taskDescribe = task.getTaskDescribe(); + boolean st = taskDescribe.contains("data:image/png;base64"); + if (st) + return Result.error("不能直接将图片放入任务描述中,因为图片将会进行base64转码,数据库中text字段不一定存下"); taskService.updateById(task); + return Result.OK("编辑成功!"); } /** * 提交任务,更新状态,同时计算实际任务时长 - * 计算一整天、一上午、一下午的工作时间;计算有多个个这样的整段时间,之后算头和尾时间 + * 计算一整天,之后算头和尾时间 * @param task * @return */ @ApiOperation(value = "任务管理-更新状态", notes = "任务管理-更新状态") @PutMapping(value = "/updateWorkStatus") public Result updateWorkStatus(@RequestBody Task task) { - //获取数据 - Task oldTask = taskService.query().eq("id", task.getId()).one(); - Date startTime = oldTask.getStartTime(); - Date endTime = new Date(); - - //更新数据 - task.setUpdateTime(endTime); - task.setSubmitTime(endTime); + Date time = new Date(); + + if (task.getWorkStatus() == 3){ + //获取数据 + Task oldTask = taskService.query().eq("id", task.getId()).one(); + Date startTime = oldTask.getStartTime(); + long realTime = 0; + try { + realTime = realDuration(startTime, time); + } catch (ParseException e) { + throw new RuntimeException(e); + } + + //设置更新数据 + double realTimeHour = (double)realTime/(60*60*1000); + realTimeHour = new BigDecimal(realTimeHour).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue(); + task.setRealDuration(realTimeHour); + task.setSubmitTime(time); + } + + task.setUpdateTime(time); taskService.updateById(task); return Result.OK("编辑成功!"); } + //计算真实时间, 单位:小时 + private long realDuration(Date startTime, Date endTime) throws ParseException { + long workTime = 0; + long millisecond = endTime.getTime() - startTime.getTime(); + //统计整天时间 + workTime += (millisecond / DAYTIME) * DAYWORKTIME; + millisecond = millisecond % DAYTIME; + + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); + SimpleDateFormat sdf1 = new SimpleDateFormat("HH:mm:ss"); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); + String time = dateFormat.format(new Date()); + String start = sdf1.format(startTime); + String time0 = time + " " + start; + + startTime = sdf.parse(time0); + String time1 = time + MORINGSTART; + String time2 = time + MORINGEND; + String time3 = time + AFTERNOONSTART; + String time4 = time + AFTERNOONEND; + Date date3 = sdf.parse(time3); + Date date2 = sdf.parse(time2); + Date date1 = sdf.parse(time1); + Date date4 = sdf.parse(time4); + + //从start往后推到end,要判断大量情况 + if (startTime.compareTo(endTime) > 0){ + //时间跨度两天,但总时间不超过24小时 + if (startTime.compareTo(date1) <= 0) + startTime = date1; //任务发布在8点前,从8点开始算 + if (startTime.compareTo(date2) <= 0){ + //早上有工作时间 + workTime += date2.getTime() - startTime.getTime(); + //跨度两天,下午必有任务时间 + workTime += DAYWORKTIME/2; + //第二天下午必没有工作时间,判断第二天早上是否有部分工作时间 + if (endTime.compareTo(date1) > 0) + workTime += endTime.getTime() - date1.getTime(); //第二天早上有工作时间 + return workTime; //计算完成,返回结果 + } + + //上午没有工作时间 + if (startTime.compareTo(date3) <= 0) + startTime = date3; //任务发布时间在12点后,14点前 + if (startTime.compareTo(date4) <= 0) //下午有工作时间 + workTime += date4.getTime() - startTime.getTime(); + if (endTime.compareTo(date1) <= 0) + return workTime; //第二天没有工作时间 + if (endTime.compareTo(date2) <= 0){ + workTime += endTime.getTime() - date1.getTime(); //第二天上午有部分工作时间 + return workTime; //必然下午没有工作时间 + } + workTime += DAYWORKTIME/2; //第二天上午工作时间占满 + if (endTime.compareTo(date3) <= 0) + return workTime; //下午没有工作时间 + if (endTime.compareTo(date4) >= 0) + endTime = date4; //下午干满了 + workTime += endTime.getTime() - date3.getTime(); + return workTime; + }else { + //时间跨度没有超过两天 + if (startTime.compareTo(date1) <= 0) + startTime = date1; //发布任务在8点之前 + if (startTime.compareTo(date2) <= 0){ + //上午发布的任务 + if (endTime.compareTo(date2) <= 0){ + //上午提交的任务 + workTime += endTime.getTime() - startTime.getTime(); + return workTime; + } + workTime += date2.getTime() - startTime.getTime(); //上午没有提交任务 + if (endTime.compareTo(date3) <= 0) + return workTime; //中午12点后14点前提交任务 + if (endTime.compareTo(date4) >= 0) + endTime = date4; //时间偏移 + workTime += endTime.getTime() - date3.getTime(); //下午工作时间 + return workTime; + }else { + //下午发布的任务 + if (startTime.compareTo(date3) <= 0) + startTime = date3; //12点之后,14点之前发布任务 + if (endTime.compareTo(date4) >= 0) + endTime = date4; //时间偏移 + workTime += endTime.getTime() - startTime.getTime(); + return workTime; + } + } + } + /** * 通过id删除 * diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/task/entity/Task.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/task/entity/Task.java index c7f4af9..e75d257 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/task/entity/Task.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/task/entity/Task.java @@ -97,6 +97,7 @@ public class Task implements Serializable { */ @Excel(name = "模块id", width = 15) @ApiModelProperty(value = "模块id") + @Dict(dictTable = "modulex", dicText = "module_name",dicCode = "id") private java.lang.String moduleId; /** * 功能id diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/task/service/ITaskService.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/task/service/ITaskService.java index 52aae34..1cc1fb4 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/task/service/ITaskService.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/task/service/ITaskService.java @@ -2,8 +2,11 @@ package org.jeecg.modules.task.service; import com.baomidou.mybatisplus.extension.service.IService; import org.jeecg.common.api.vo.Result; +import org.jeecg.modules.system.entity.SysUser; import org.jeecg.modules.task.entity.Task; +import java.util.List; + /** * @Description: 任务管理 * @Author: jeecg-boot @@ -26,4 +29,6 @@ public interface ITaskService extends IService { Result fabu(String id); String fillTaskName(String projectId, String typeId); + +// List UserIdByUserName(String userName); } diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/task/service/impl/TaskServiceImpl.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/task/service/impl/TaskServiceImpl.java index 2a63008..ec6f254 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/task/service/impl/TaskServiceImpl.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/task/service/impl/TaskServiceImpl.java @@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.jeecg.common.api.vo.Result; import org.jeecg.modules.projectx.entity.Projectx; import org.jeecg.modules.projectx.service.IProjectxService; +import org.jeecg.modules.system.entity.SysUser; +import org.jeecg.modules.system.service.ISysUserService; import org.jeecg.modules.task.entity.Task; import org.jeecg.modules.task.mapper.TaskMapper; import org.jeecg.modules.task.service.ITaskService; @@ -35,7 +37,10 @@ public class TaskServiceImpl extends ServiceImpl implements IT @Resource private ITaskTypeService iTaskTypeService; +// @Resource +// private ISysUserService sysUserService; /** + * 责任人回显 * 责任人回显 */ @Override @@ -145,4 +150,14 @@ public class TaskServiceImpl extends ServiceImpl implements IT String fillName = taskType.getTypeName() + "-" + projectx.getProjectName(); return fillName; } +// @Override +// public List UserIdByUserName(String userName) { +// if (userName==null) +// return null; +// LambdaQueryWrapper wrapper=new LambdaQueryWrapper<>(); +// if(userName.startsWith("*")&&userName.endsWith("*")) +// userName = userName.substring(1, userName.length() - 1); +// wrapper.eq(SysUser::getUsername,userName); +// return sysUserService.list(wrapper); +// } }