From ff8faf7606e85413ccc98b81faabb66984736c31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E5=85=B6=E5=85=B5?= Date: Tue, 4 Mar 2025 10:21:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E6=8A=A5=E6=9C=88=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/sa/zentao/ZentaoApplication.java | 69 +- .../zentao/conf/JwtAuthenticationFilter.java | 5 +- .../zentao/controller/CommonsController.java | 11 +- .../sa/zentao/controller/ZtBugController.java | 3 +- .../zentao/controller/ZtCountController.java | 15 +- .../controller/ZtProjectController.java | 26 +- .../controller/ZtStoryUserController.java | 9 + .../zentao/controller/ZtUserController.java | 9 + src/main/java/com/sa/zentao/dao/DkInfo.java | 22 + .../java/com/sa/zentao/dao/ItApproval.java | 22 + .../com/sa/zentao/dao/PerformanceDTO.java | 4 + .../com/sa/zentao/dao/WorkDetailsDTO.java | 7 + .../java/com/sa/zentao/dao/ZtTaskDTO.java | 8 + .../java/com/sa/zentao/dao/ZtUserDTO.java | 5 + .../java/com/sa/zentao/entity/ZtTask.java | 23 +- .../com/sa/zentao/mapper/ZtProjectMapper.java | 1 + .../com/sa/zentao/mapper/ZtTaskMapper.java | 4 + .../com/sa/zentao/mapper/ZtUserMapper.java | 5 + .../sa/zentao/service/IZtProjectService.java | 11 +- .../zentao/service/IZtStoryUserService.java | 3 + .../com/sa/zentao/service/IZtTaskService.java | 5 + .../com/sa/zentao/service/IZtUserService.java | 7 + .../zentao/service/impl/IZtCountService.java | 480 ++++- .../zentao/service/impl/ZtBugServiceImpl.java | 18 + .../service/impl/ZtMeetingServiceImpl.java | 12 +- .../service/impl/ZtProductServiceImpl.java | 7 +- .../service/impl/ZtProjectServiceImpl.java | 1600 +++++++++++------ .../service/impl/ZtReleaseServiceImpl.java | 9 +- .../impl/ZtStoryFeedbackServiceImpl.java | 3 +- .../service/impl/ZtStoryServiceImpl.java | 26 +- .../service/impl/ZtStoryUserServiceImpl.java | 19 + .../service/impl/ZtTaskServiceImpl.java | 600 ++++--- .../service/impl/ZtUserServiceImpl.java | 32 +- .../java/com/sa/zentao/utils/CryptoUtils.java | 130 ++ .../java/com/sa/zentao/utils/DateUtils.java | 3 +- .../java/com/sa/zentao/utils/ExcelUtil.java | 182 ++ .../mapper/ZtStoryFeedbackMapper.xml | 6 + src/main/resources/mapper/ZtStoryMapper.xml | 1 + src/main/resources/mapper/ZtTaskMapper.xml | 397 ++-- src/main/resources/mapper/ZtUserMapper.xml | 17 + 40 files changed, 2717 insertions(+), 1099 deletions(-) create mode 100644 src/main/java/com/sa/zentao/dao/DkInfo.java create mode 100644 src/main/java/com/sa/zentao/dao/ItApproval.java create mode 100644 src/main/java/com/sa/zentao/utils/CryptoUtils.java create mode 100644 src/main/java/com/sa/zentao/utils/ExcelUtil.java diff --git a/src/main/java/com/sa/zentao/ZentaoApplication.java b/src/main/java/com/sa/zentao/ZentaoApplication.java index 39febbc..e747ecc 100644 --- a/src/main/java/com/sa/zentao/ZentaoApplication.java +++ b/src/main/java/com/sa/zentao/ZentaoApplication.java @@ -1,17 +1,49 @@ package com.sa.zentao; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.write.metadata.WriteSheet; +import com.tencentcloudapi.ses.v20201002.models.EmailSender; +import lombok.SneakyThrows; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.context.annotation.ComponentScan; import org.springframework.scheduling.annotation.EnableScheduling; + +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.util.Iterator; + +import org.apache.poi.ss.usermodel.DateUtil; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + //,exclude = DataSourceAutoConfiguration.class @SpringBootApplication(scanBasePackages = {"com.sa.zentao"}) @MapperScan({"com.sa.zentao.mapper","com.sa.**.mapper"}) @EnableScheduling public class ZentaoApplication { - +// public static void main(String[] args) { @@ -19,4 +51,39 @@ public class ZentaoApplication { } +// public static void main(String[] args) { +// // 定义数据 +// Map dataMap = new HashMap<>(); +// dataMap.put("name", "张三"); +// dataMap.put("age", "28"); +// +// // 读取模板 +// try (FileInputStream templateFile =(FileInputStream)ZentaoApplication.class.getClassLoader().getResourceAsStream("templates/scope测试.xlsx")) { +// Workbook workbook = WorkbookFactory.create(templateFile); +// Sheet sheet = workbook.getSheetAt(0); +// +// // 替换占位符 +// for (Row row : sheet) { +// for (Cell cell : row) { +// if (cell.getCellType() == CellType.STRING) { +// String cellValue = cell.getStringCellValue(); +// for (Map.Entry entry : dataMap.entrySet()) { +// cellValue = cellValue.replace("${" + entry.getKey() + "}", entry.getValue()); +// } +// cell.setCellValue(cellValue); +// } +// } +// } +// +// // 生成新文件 +// try (FileOutputStream outputStream = new FileOutputStream("output.xlsx")) { +// workbook.write(outputStream); +// } +// workbook.close(); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// +// } + } diff --git a/src/main/java/com/sa/zentao/conf/JwtAuthenticationFilter.java b/src/main/java/com/sa/zentao/conf/JwtAuthenticationFilter.java index 63d0482..9a170e2 100644 --- a/src/main/java/com/sa/zentao/conf/JwtAuthenticationFilter.java +++ b/src/main/java/com/sa/zentao/conf/JwtAuthenticationFilter.java @@ -29,9 +29,6 @@ import java.util.Objects; public class JwtAuthenticationFilter implements jakarta.servlet.Filter { - public void init(FilterConfig filterConfig) throws ServletException { - - } public void doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse servletResponse @@ -69,6 +66,8 @@ public class JwtAuthenticationFilter implements jakarta.servlet.Filter { RiskUserThreadLocal.set(u); RiskUserThreadLocal.risk.set(u); } + }else{ + RiskUserThreadLocal.risk.set(null); } filterChain.doFilter(request,servletResponse); } diff --git a/src/main/java/com/sa/zentao/controller/CommonsController.java b/src/main/java/com/sa/zentao/controller/CommonsController.java index 0c6e90f..e511a65 100644 --- a/src/main/java/com/sa/zentao/controller/CommonsController.java +++ b/src/main/java/com/sa/zentao/controller/CommonsController.java @@ -1,6 +1,7 @@ package com.sa.zentao.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.sa.zentao.ZentaoApplication; import com.sa.zentao.conf.RiskUserThreadLocal; import com.sa.zentao.dao.BusinessException; import com.sa.zentao.dao.Code; @@ -14,6 +15,7 @@ import com.sa.zentao.utils.UploadUtil; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; +import org.apache.poi.ss.usermodel.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; @@ -134,9 +136,14 @@ public class CommonsController { @GetMapping("/test") public Result upload(){ - downLoad("http://192.168.1.161:8088/file-download-1.html"); +// downLoad("http://192.168.1.161:8088/file-download-1.html"); + +// vxxervice.sendMessageToVx("GuoQiBing","测试消息",new Date()); + // 定义数据 + + // 定义数据 + - vxxervice.sendMessageToVx("GuoQiBing","测试消息",new Date()); return Result.success(); diff --git a/src/main/java/com/sa/zentao/controller/ZtBugController.java b/src/main/java/com/sa/zentao/controller/ZtBugController.java index 2523a0f..b16516e 100644 --- a/src/main/java/com/sa/zentao/controller/ZtBugController.java +++ b/src/main/java/com/sa/zentao/controller/ZtBugController.java @@ -55,6 +55,7 @@ public class ZtBugController { return Result.success(); } + //批量新增bug @RequestMapping(value = "/batchAddBug", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") public Result batchAddBug(@RequestBody ZtBugDTO dto){ bugService.batchAddBug(dto); @@ -99,7 +100,7 @@ public class ZtBugController { return Result.success(ztBugDTO); } - //完成 + //完成 @RequestMapping(value = "/resolved", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") public Result resolved(@RequestBody ZtBugDTO dto){ bugService.resolved(dto); diff --git a/src/main/java/com/sa/zentao/controller/ZtCountController.java b/src/main/java/com/sa/zentao/controller/ZtCountController.java index 990a584..fdd71f4 100644 --- a/src/main/java/com/sa/zentao/controller/ZtCountController.java +++ b/src/main/java/com/sa/zentao/controller/ZtCountController.java @@ -15,6 +15,7 @@ import com.sa.zentao.service.IZtStoryService; import com.sa.zentao.service.IZtTaskService; import com.sa.zentao.service.impl.IZtCountService; import com.sa.zentao.utils.DateUtils; +import jakarta.servlet.http.HttpServletResponse; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestBody; @@ -22,8 +23,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import java.math.BigDecimal; import java.util.Date; import java.util.HashMap; @@ -98,7 +97,14 @@ public class ZtCountController { public void exportProjectCount(@RequestBody ZtCountQo qo, jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response){ countService.exportProjectCount(qo,request,response) ; } - // + + //导出员工绩效 + @RequestMapping(value = "/exportScope", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") + public void exportScope(@RequestBody ZtCountQo qo, jakarta.servlet.ServletRequest request, HttpServletResponse response){ + countService.exportScope(qo,request,response) ; + } + + @RequestMapping(value = "/projectList", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") public Result projectList(@RequestBody ZtCaseDTO dto){ @@ -112,7 +118,10 @@ public class ZtCountController { @RequestMapping(value = "/projectListAsc", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") public Result projectListAsc(@RequestBody ZtCaseDTO dto){ + List authList = this.projectService.authList(); + List project = projectService.list(new QueryWrapper().lambda().eq(ZtProject::getType, "program") + .in(ZtProject::getId,authList) .eq(ZtProject::getStatus,"doing") .eq(ZtProject::getDeleted,"0") .orderByAsc(ZtProject::getId) diff --git a/src/main/java/com/sa/zentao/controller/ZtProjectController.java b/src/main/java/com/sa/zentao/controller/ZtProjectController.java index c8bfea2..3b882ef 100644 --- a/src/main/java/com/sa/zentao/controller/ZtProjectController.java +++ b/src/main/java/com/sa/zentao/controller/ZtProjectController.java @@ -227,9 +227,14 @@ public class ZtProjectController { //执行列表 @RequestMapping(value = "/implementPageList", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") public Result> implementPageList(@RequestBody ZtProjectQo qo){ - return Result.success(ztProjectService.implementPageList(qo)); } + //执行下拉列表 包含本人且 未完成的迭代 + @RequestMapping(value = "/myProgressImplementPageList", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") + public Result> myProgressImplementPageList(@RequestBody ZtProjectQo qo){ + return Result.success(ztProjectService.myProgressImplementPageList(qo)); + } + //执行下拉 @RequestMapping(value = "/implementList", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") public Result> implementList(@RequestBody ZtProjectQo qo){ @@ -314,6 +319,25 @@ public class ZtProjectController { return Result.success(this.ztProjectService.projectTeamTimeWork(qo)); } + //产品集工时项目工时 每个人 按月份 工时统计 日报 + @RequestMapping(value = "/pageDaysTimeWorkCount", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") + public Result pageDaysTimeWorkCount(@RequestBody ZtProjectQo qo){ + return Result.success(this.ztProjectService.pageDaysTimeWorkCount(qo)); + } + + //迭代工时 每个人 + @RequestMapping(value = "/execWorkCount", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") + public Result execWorkCount(@RequestBody ZtProjectQo qo){ + return Result.success(this.ztProjectService.execWorkCount(qo)); + } + + //项目统计 每个人 按月份 工时统计 月报 + @RequestMapping(value = "/pageMonthReport", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") + public Result pageMonthReport(@RequestBody ZtProjectQo qo){ + return Result.success(this.ztProjectService.pageMonthReport(qo)); + } + + //迭代列表根据项目 @RequestMapping(value = "/executionByProject", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") public Result executionByProject(@RequestBody ZtProjectQo qo){ diff --git a/src/main/java/com/sa/zentao/controller/ZtStoryUserController.java b/src/main/java/com/sa/zentao/controller/ZtStoryUserController.java index 3add87b..cbd34b5 100644 --- a/src/main/java/com/sa/zentao/controller/ZtStoryUserController.java +++ b/src/main/java/com/sa/zentao/controller/ZtStoryUserController.java @@ -11,6 +11,7 @@ import com.sa.zentao.qo.StoryQo; import com.sa.zentao.qo.ZtProjectQo; import com.sa.zentao.service.IZtStoryUserService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -104,4 +105,12 @@ public class ZtStoryUserController { storyUserService.addRemark(dto); return Result.success(); } + + @RequestMapping(value = "/myWaitYsStory", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") + public Result myWaitYsStory(@RequestBody ZtStoryDTO dto){ + List list = storyUserService.myWaitYsStory(dto); + return Result.success(CollectionUtils.isEmpty(list)?list:list.get(0)); + } + + } diff --git a/src/main/java/com/sa/zentao/controller/ZtUserController.java b/src/main/java/com/sa/zentao/controller/ZtUserController.java index 05adc42..ef753d1 100644 --- a/src/main/java/com/sa/zentao/controller/ZtUserController.java +++ b/src/main/java/com/sa/zentao/controller/ZtUserController.java @@ -20,6 +20,7 @@ import com.sa.zentao.service.IZtActionService; import com.sa.zentao.service.IZtTeamService; import com.sa.zentao.service.IZtUserService; import com.sa.zentao.utils.ChineseUtil; +import com.sa.zentao.utils.CryptoUtils; import com.sa.zentao.utils.JwtUtil; import com.tencentcloudapi.common.Credential; import com.tencentcloudapi.common.exception.TencentCloudSDKException; @@ -149,6 +150,9 @@ public class ZtUserController { } ztUser.setPinyin(ChineseUtil.getFirst(ztUser.getNickname())); + if(!StringUtils.isEmpty(ztUser.getVx())){ + ztUser.setVx(CryptoUtils.aesEncryptForFront(ztUser.getVx(), CryptoUtils.KEY_DES)); + } this.userService.save(ztUser); this.actionService.addAction(ActionType.USER, ActionStatus.XJ,ztUser.getId(),null,null,null, RiskUserThreadLocal.get().getName(),null,ztUser.getAccount()); @@ -194,6 +198,11 @@ public class ZtUserController { if(!ztUser.getNickname().equals(user.getNickname())){ ztUser.setPinyin(ChineseUtil.getFirst(ztUser.getNickname())); } + + if(!StringUtils.isEmpty(user.getVx())){ + ztUser.setVx(CryptoUtils.aesEncryptForFront(user.getVx(), CryptoUtils.KEY_DES)); + } + ztUser.setAccount(user.getAccount()); ztUser.setPassword(user.getPassword()); diff --git a/src/main/java/com/sa/zentao/dao/DkInfo.java b/src/main/java/com/sa/zentao/dao/DkInfo.java new file mode 100644 index 0000000..2c37470 --- /dev/null +++ b/src/main/java/com/sa/zentao/dao/DkInfo.java @@ -0,0 +1,22 @@ +package com.sa.zentao.dao; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.Date; + +@Data +@EqualsAndHashCode(callSuper = false) +public class DkInfo implements Serializable { + + private String account; + + private String name; + + private String dateStr; + + private Date startDate; + + private Date endDate; +} diff --git a/src/main/java/com/sa/zentao/dao/ItApproval.java b/src/main/java/com/sa/zentao/dao/ItApproval.java new file mode 100644 index 0000000..23b6a9c --- /dev/null +++ b/src/main/java/com/sa/zentao/dao/ItApproval.java @@ -0,0 +1,22 @@ +package com.sa.zentao.dao; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.Date; + +@Data +@EqualsAndHashCode(callSuper = false) +public class ItApproval implements Serializable { + + private String name; + + private Integer applyDays; + + private Date applyTimeStart; + + private Date applyTimeEnd; + + +} diff --git a/src/main/java/com/sa/zentao/dao/PerformanceDTO.java b/src/main/java/com/sa/zentao/dao/PerformanceDTO.java index 2c68b4c..670cc9e 100644 --- a/src/main/java/com/sa/zentao/dao/PerformanceDTO.java +++ b/src/main/java/com/sa/zentao/dao/PerformanceDTO.java @@ -1,5 +1,6 @@ package com.sa.zentao.dao; +import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelProperty; import lombok.Data; import lombok.EqualsAndHashCode; @@ -19,6 +20,9 @@ public class PerformanceDTO implements Serializable { //需求总工时 @ExcelProperty(value = "天数",index =2) private BigDecimal days; + // 小时 + @ExcelIgnore + private BigDecimal approvalDays; //实际产出工时 @ExcelProperty(value = "可用工时",index =3) private BigDecimal totalTime; diff --git a/src/main/java/com/sa/zentao/dao/WorkDetailsDTO.java b/src/main/java/com/sa/zentao/dao/WorkDetailsDTO.java index 9db68fe..6250f1d 100644 --- a/src/main/java/com/sa/zentao/dao/WorkDetailsDTO.java +++ b/src/main/java/com/sa/zentao/dao/WorkDetailsDTO.java @@ -1,5 +1,6 @@ package com.sa.zentao.dao; +import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelProperty; import lombok.Data; import lombok.EqualsAndHashCode; @@ -16,6 +17,12 @@ public class WorkDetailsDTO implements Serializable { //任务总量 @ExcelProperty(value = "任务总量",index =1) private BigDecimal taskCount; + //任务延期 + @ExcelIgnore + private BigDecimal taskDelayCount; + //任务准时完成率 + @ExcelIgnore + private BigDecimal taskFinishOnTimeRate; //需求总工时 @ExcelProperty(value = "需求总工时",index =2) private BigDecimal storyTotalTime; diff --git a/src/main/java/com/sa/zentao/dao/ZtTaskDTO.java b/src/main/java/com/sa/zentao/dao/ZtTaskDTO.java index c8a1513..dc8b6c3 100644 --- a/src/main/java/com/sa/zentao/dao/ZtTaskDTO.java +++ b/src/main/java/com/sa/zentao/dao/ZtTaskDTO.java @@ -7,6 +7,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import java.io.Serializable; +import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.Date; @@ -187,8 +188,15 @@ public class ZtTaskDTO implements Serializable { //0 否 1 是 private Integer finishedFlag=0; + //0 否 1 是 + private Integer draftFlag; + private String implementName; private Integer implementId; private Integer product; private String productName; + + private Date applyDate; + + private BigDecimal useTime; } diff --git a/src/main/java/com/sa/zentao/dao/ZtUserDTO.java b/src/main/java/com/sa/zentao/dao/ZtUserDTO.java index 751d53d..7ca86e0 100644 --- a/src/main/java/com/sa/zentao/dao/ZtUserDTO.java +++ b/src/main/java/com/sa/zentao/dao/ZtUserDTO.java @@ -136,4 +136,9 @@ public class ZtUserDTO implements Serializable { private String color; + private String vx; + + private Date startDate; + + private Date endDate; } diff --git a/src/main/java/com/sa/zentao/entity/ZtTask.java b/src/main/java/com/sa/zentao/entity/ZtTask.java index 98f53a1..2508b1c 100644 --- a/src/main/java/com/sa/zentao/entity/ZtTask.java +++ b/src/main/java/com/sa/zentao/entity/ZtTask.java @@ -1,6 +1,8 @@ package com.sa.zentao.entity; import com.baomidou.mybatisplus.annotation.IdType; + +import java.math.BigDecimal; import java.time.LocalDate; import com.baomidou.mybatisplus.annotation.TableId; import java.time.LocalDateTime; @@ -75,7 +77,7 @@ public class ZtTask implements Serializable { //deadline 预计完成 estStarted预计开始 private Date deadline; - //pause 暂停 cancel取消 closed 关闭 done 完成 wait reviewing待评审 doing + //pause 暂停 cancel取消 closed 关闭 done 完成 wait reviewing待评审 doing 草稿 draft @TableField("`status`") private String status; @@ -93,13 +95,19 @@ public class ZtTask implements Serializable { @TableField("openedBy") private String openedby; - + @TableField(exist = false) + private String openedbyAccount; + @TableField(exist = false) + private String openedbyName; @TableField("openedDate") private Date openeddate; @TableField("assignedTo") private String assignedTo; - + @TableField(exist = false) + private String assignedToAccount; + @TableField(exist = false) + private String assignedToName; @TableField("assignedDate") private Date assignedDate; //预计开始 @@ -111,7 +119,7 @@ public class ZtTask implements Serializable { @TableField("finishedBy") private String finishedby; - //完成日期 + //真实完成日期 @TableField("finishedDate") private Date finishedDate; @@ -175,4 +183,11 @@ public class ZtTask implements Serializable { private Long deadlineTime; private Integer product; + // 0否 1.是 +// @TableField(exist = false) + private Integer finishedFlag; +// @TableField(exist = false) + private Date applyDate; +// @TableField(exist = false) + private BigDecimal useTime; } diff --git a/src/main/java/com/sa/zentao/mapper/ZtProjectMapper.java b/src/main/java/com/sa/zentao/mapper/ZtProjectMapper.java index 7424be7..e96fff1 100644 --- a/src/main/java/com/sa/zentao/mapper/ZtProjectMapper.java +++ b/src/main/java/com/sa/zentao/mapper/ZtProjectMapper.java @@ -29,6 +29,7 @@ public interface ZtProjectMapper extends BaseMapper { List implementPageList(@Param("qo")ZtProjectQo qo); + List getProjectByProduct(@Param("qo") ZtProjectQo qo); List executionListByProduct(@Param("qo")ZtProjectQo qo); diff --git a/src/main/java/com/sa/zentao/mapper/ZtTaskMapper.java b/src/main/java/com/sa/zentao/mapper/ZtTaskMapper.java index 1a21457..154fa12 100644 --- a/src/main/java/com/sa/zentao/mapper/ZtTaskMapper.java +++ b/src/main/java/com/sa/zentao/mapper/ZtTaskMapper.java @@ -1,12 +1,14 @@ package com.sa.zentao.mapper; import com.baomidou.dynamic.datasource.annotation.DS; +import com.sa.zentao.dao.ItApproval; import com.sa.zentao.dao.ZtTaskDTO; import com.sa.zentao.entity.ZtTask; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.sa.zentao.qo.ZtProjectQo; import org.apache.ibatis.annotations.Param; +import java.util.Date; import java.util.List; /** @@ -23,4 +25,6 @@ public interface ZtTaskMapper extends BaseMapper { @DS("slave") List taskListPrd(@Param("id") Integer id); + + List itApprovalByUserName(@Param("name") String name,@Param("startDate") Date firstDayOfMonth, @Param("endDate") Date lastDayOfMonth); } diff --git a/src/main/java/com/sa/zentao/mapper/ZtUserMapper.java b/src/main/java/com/sa/zentao/mapper/ZtUserMapper.java index 2fa2f75..ca4ca4c 100644 --- a/src/main/java/com/sa/zentao/mapper/ZtUserMapper.java +++ b/src/main/java/com/sa/zentao/mapper/ZtUserMapper.java @@ -1,6 +1,7 @@ package com.sa.zentao.mapper; import com.baomidou.dynamic.datasource.annotation.DS; +import com.sa.zentao.dao.DkInfo; import com.sa.zentao.dao.ZtUserDTO; import com.sa.zentao.entity.ZtUser; import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -8,6 +9,7 @@ import com.sa.zentao.qo.ZtUserQo; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; +import java.util.Date; import java.util.List; /** @@ -22,6 +24,7 @@ public interface ZtUserMapper extends BaseMapper { List pageList(@Param("qo") ZtUserQo qo); + List dkList(@Param("ids") List account, @Param("startDate") Date startDate, @Param("endDate")Date endDate); @DS("slave") @Select("select * from zt_user") @@ -30,4 +33,6 @@ public interface ZtUserMapper extends BaseMapper { @DS("slave") ZtUser selectPrdByName(@Param("name")String userName); + + } diff --git a/src/main/java/com/sa/zentao/service/IZtProjectService.java b/src/main/java/com/sa/zentao/service/IZtProjectService.java index 74c0acd..c39dd2c 100644 --- a/src/main/java/com/sa/zentao/service/IZtProjectService.java +++ b/src/main/java/com/sa/zentao/service/IZtProjectService.java @@ -73,7 +73,7 @@ public interface IZtProjectService extends IService { void executionSyncStory(ZtProjectDTO dto); - //产品集权限 + //产品权限 List authProductList(); //产品集权限 List authList(); @@ -113,4 +113,13 @@ public interface IZtProjectService extends IService { List performanceCount(Date startDate, Date endDate); ZtProjectDTO projectProductByExecution(String execution); + + PageInfo< Map> pageDaysTimeWorkCount(ZtProjectQo qo); + + + PageInfo pageMonthReport(ZtProjectQo qo); + + List> execWorkCount(ZtProjectQo qo); + + PageInfo myProgressImplementPageList(ZtProjectQo qo); } diff --git a/src/main/java/com/sa/zentao/service/IZtStoryUserService.java b/src/main/java/com/sa/zentao/service/IZtStoryUserService.java index a217314..2645ded 100644 --- a/src/main/java/com/sa/zentao/service/IZtStoryUserService.java +++ b/src/main/java/com/sa/zentao/service/IZtStoryUserService.java @@ -38,4 +38,7 @@ public interface IZtStoryUserService extends IService { void addRemark(ZtStoryDTO dto); void closedStory(ZtStoryUserDTO dto); + + List myWaitYsStory(ZtStoryDTO dto); + } diff --git a/src/main/java/com/sa/zentao/service/IZtTaskService.java b/src/main/java/com/sa/zentao/service/IZtTaskService.java index cde19b4..bc4f0f9 100644 --- a/src/main/java/com/sa/zentao/service/IZtTaskService.java +++ b/src/main/java/com/sa/zentao/service/IZtTaskService.java @@ -1,6 +1,7 @@ package com.sa.zentao.service; import com.github.pagehelper.PageInfo; +import com.sa.zentao.dao.ItApproval; import com.sa.zentao.dao.ZtProjectDTO; import com.sa.zentao.dao.ZtTaskDTO; import com.sa.zentao.dao.ZtYwTaskDTO; @@ -8,6 +9,7 @@ import com.sa.zentao.entity.ZtTask; import com.baomidou.mybatisplus.extension.service.IService; import com.sa.zentao.qo.ZtProjectQo; +import java.util.Date; import java.util.List; /** @@ -53,4 +55,7 @@ public interface IZtTaskService extends IService { ZtTaskDTO getTaskById(Integer id); List taskListPrd(Integer id); + + List itApprovalByUserName(String s, Date firstDayOfMonth, Date lastDayOfMonth); + } diff --git a/src/main/java/com/sa/zentao/service/IZtUserService.java b/src/main/java/com/sa/zentao/service/IZtUserService.java index a15a730..6eabe17 100644 --- a/src/main/java/com/sa/zentao/service/IZtUserService.java +++ b/src/main/java/com/sa/zentao/service/IZtUserService.java @@ -1,12 +1,15 @@ package com.sa.zentao.service; import com.github.pagehelper.PageInfo; +import com.sa.zentao.dao.DkInfo; import com.sa.zentao.dao.ZtProjectDTO; import com.sa.zentao.dao.ZtUserDTO; import com.sa.zentao.entity.ZtUser; import com.baomidou.mybatisplus.extension.service.IService; import com.sa.zentao.qo.ZtUserQo; +import org.apache.ibatis.annotations.Param; +import java.util.Date; import java.util.List; import java.util.Map; @@ -29,6 +32,8 @@ public interface IZtUserService extends IService { Map userMapByIds(List accounts); + Map userMapByIdsOrderByType(List accounts); + void sendCode(ZtUser user); ZtUser login(ZtUser user); @@ -36,4 +41,6 @@ public interface IZtUserService extends IService { ZtUser selectPrdByName(String userName); ZtUser getbyVxId(String vx); + + List dkList(@Param("ids") List account, @Param("startDate") Date startDate, @Param("endDate")Date endDate); } diff --git a/src/main/java/com/sa/zentao/service/impl/IZtCountService.java b/src/main/java/com/sa/zentao/service/impl/IZtCountService.java index cd2b79f..07cf358 100644 --- a/src/main/java/com/sa/zentao/service/impl/IZtCountService.java +++ b/src/main/java/com/sa/zentao/service/impl/IZtCountService.java @@ -3,6 +3,7 @@ package com.sa.zentao.service.impl; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.ExcelWriter; import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.read.listener.PageReadListener; import com.alibaba.excel.write.builder.ExcelWriterSheetBuilder; import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.excel.write.metadata.WriteTable; @@ -11,6 +12,7 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.pagehelper.PageInfo; +import com.mysql.cj.x.protobuf.MysqlxCrud; import com.sa.zentao.conf.LoginRiskUser; import com.sa.zentao.conf.RiskUserThreadLocal; import com.sa.zentao.dao.*; @@ -24,16 +26,19 @@ import com.sa.zentao.qo.ZtProjectQo; import com.sa.zentao.qo.ZtUserQo; import com.sa.zentao.service.*; import com.sa.zentao.utils.DateUtils; +import com.sa.zentao.utils.ExcelUtil; import jakarta.servlet.ServletOutputStream; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.ByteArrayOutputStream; +import java.io.*; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; @@ -355,13 +360,15 @@ public class IZtCountService { .filter(o -> o.getStage().equals("wait")) .map(o->o.getId()+"").collect(Collectors.joining(","))); result.setJxzCount(ztStory.stream().filter(o -> "active".equals(o.getStatus())) - .filter(o -> o.getStage().equals("developing")) .map(o->o.getId()+"").collect(Collectors.joining(","))); + .filter(o -> Arrays.asList("tested","testing","developed","developing").contains(o.getStage()) + ) .map(o->o.getId()+"").collect(Collectors.joining(","))); result.setCswbCount(ztStory.stream().filter(o -> "active".equals(o.getStatus())) .filter(o -> o.getStage().equals("tested")) .map(o->o.getId()+"").collect(Collectors.joining(","))); result.setDysCount(ztStory.stream().filter(o -> "active".equals(o.getStatus())) .filter(o -> o.getStage().equals("released")) + .filter(o->o.getYsUser().equals(RiskUserThreadLocal.get().getName())) .map(o->o.getId()+"").collect(Collectors.joining(","))); result.setYsNoCount(ztStory.stream().filter(o -> "active".equals(o.getStatus())) .filter(o -> o.getStage().equals("verified")) @@ -520,24 +527,97 @@ public class IZtCountService { // @Autowired // private IZtBugService bugService; + public void exportScope(ZtCountQo qo, ServletRequest request, HttpServletResponse response) { + try { + + + + List perList =performanceCount(qo); + if(CollectionUtils.isEmpty(perList)){ + throw new BusinessException("未查询到数据"); + } + + response.setContentType("application/vnd.ms-excel;charset=UTF-8"); + + + Map userMap = userService.userMapByIds(null); + + + //生成模板 + for (int i = 0; i < perList.size(); i++) { + PerformanceDTO performanceDTO = perList.get(i); + ZtUser ztUser = userMap.get(performanceDTO.getAccount()); + + if(ztUser.getUserType()==UserType.CS){ + generatorTestExcel(performanceDTO.getUserName(),performanceDTO,qo.getDate()); + }else if(ztUser.getUserType()==UserType.KFZ){ + generatorDevlopExcel(performanceDTO.getUserName(),performanceDTO,qo.getDate()); + }else if(ztUser.getUserType()==UserType.XMGLY){ + }else{ + } + } + //生成多sheetexcel + + List list = new ArrayList<>(); + for (int i = 0; i < perList.size(); i++) { + PerformanceDTO performanceDTO = perList.get(i); + ZtUser ztUser = userMap.get(performanceDTO.getAccount()); + + + if(ztUser.getUserType()==UserType.CS){ + list.add(performanceDTO.getUserName()+"测试.xlsx"); + + generatorTestExcel(performanceDTO.getUserName(),performanceDTO,qo.getDate()); + }else if(ztUser.getUserType()==UserType.KFZ){ + list.add(performanceDTO.getUserName()+"开发.xlsx"); + generatorDevlopExcel(performanceDTO.getUserName(),performanceDTO,qo.getDate()); + } + } + String excelName=DateUtils.formatDate(qo.getDate(),"yyyy-MM-dd")+"绩效"+".xlsx"; + String dir=System.getProperty("user.dir")+"/"; + ExcelUtil.mergexcel(list,excelName, dir); + + + + File f = new File(dir+excelName); + InputStream fis = new BufferedInputStream(new FileInputStream(f)); +// InputStream fis = new BufferedInputStream(new FileInputStream("D:\\1.bmp")); + byte[] buffer = new byte[fis.available()]; + + fis.read(buffer); + fis.close(); + // 清空response + response.reset(); + // 设置response的Header + response.addHeader("Content-Disposition", "attachment;filename=" + new String("1.xlsx")); + response.addHeader("Content-Length", "" + f.length()); + + + OutputStream toClient = new BufferedOutputStream(response.getOutputStream()); + response.setContentType("application/octet-stream"); + toClient.write(buffer); + toClient.flush(); + toClient.close(); +// ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()) +// . registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) +// .needHead(Boolean.TRUE).build(); +// excelWriter.finish(); + response.getOutputStream().close(); + response.flushBuffer(); + + }catch (Exception e){ + log.error("",e); + } + + } public void exportProjectCount(ZtCountQo qo,jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response) { - - try { List workDetailsDTOS = projectWorkCount(qo,request,response); ByteArrayOutputStream os = new ByteArrayOutputStream(); -// ExcelWriter excelWriter = EasyExcel.write(os).build(); - -// WriteSheet 统计 = EasyExcel.writerSheet("统计"). -// registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) -// .needHead(Boolean.TRUE) -// .build(); - - List workDetailsDTOS1 = workDetailsCount(qo); @@ -545,17 +625,9 @@ public class IZtCountService { List perList =performanceCount(qo); -// excelWriter.write(workDetailsDTOS, 统计, accountInfo); -// excelWriter.write(workDetailsDTOS1, 统计, tweetInfo); - -// EasyExcel.write(os, ProjectWorkDetailsDTO.class) -// .sheet("统计").doWrite(workDetailsDTOS); response.setContentType("application/vnd.ms-excel;charset=UTF-8"); -// response.("Access-Control-Expose-Headers","Content-Disposition");//不设置该参数前端(vue)接收不到文件名 -// response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); - ServletOutputStream outputStream = response.getOutputStream(); ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()) @@ -594,10 +666,6 @@ public class IZtCountService { excelWriter.finish(); - - - - response.getOutputStream().close(); response.flushBuffer(); @@ -630,15 +698,237 @@ public class IZtCountService { if (CollectionUtils.isEmpty(projectproducts)) { return new ArrayList<>(); } - List list = executionprojectService.list(new QueryWrapper().lambda() + List execList = executionprojectService.list(new QueryWrapper().lambda() .in(ZtExecutionproject::getProject, projectproducts.stream().map(o->o.getProject()).collect(Collectors.toList()))); - if (CollectionUtils.isEmpty(list)) { + if (CollectionUtils.isEmpty(execList)) { return new ArrayList<>(); } + List taskList = this.taskService.list(new QueryWrapper().lambda() + .and(o->o.between(ZtTask::getDeadline, firstDayOfMonth,lastDayOfMonth) + .or() + .between(ZtTask::getFinishedDate, firstDayOfMonth,lastDayOfMonth) + ) + .in(ZtTask::getExecution, execList.stream().map(o -> o.getExecution()) + .collect(Collectors.toList()))); + if (CollectionUtils.isEmpty(taskList)) { + return new ArrayList<>(); + } + List ztProjects = this.projectService.listByIds(execList.stream().map(o -> o.getExecution()).collect(Collectors.toList())); -// this.teamService.list(new QueryWrapper<>().lambda().eq()); + List teams = this.teamService.list(new QueryWrapper().lambda().eq(ZtTeam::getType, "execution") + .in(ZtTeam::getRoot, ztProjects.stream().map(o -> o.getId()).collect(Collectors.toList()))); - return this.projectService.performanceCount(firstDayOfMonth,lastDayOfMonth); + List accountIds = teams.stream().map(o -> o.getAccount()).distinct().collect(Collectors.toList()); + if (CollectionUtils.isEmpty(accountIds)) { + return new ArrayList<>(); + } + //accountIds 成员 + + List ztUsers = this.userService.list(new QueryWrapper().lambda().in(ZtUser::getAccount,accountIds)); + + + List result =new ArrayList<>(); + + for (ZtUser u:ztUsers) { + + List approvalList = this.taskService.itApprovalByUserName(u.getNickname(),firstDayOfMonth, lastDayOfMonth); + + if(u.getUserType()==UserType.CS){ + + }else if(u.getUserType()==UserType.KFZ){ + + }else if(u.getUserType()==UserType.XMGLY){ + + } + + PerformanceDTO dto=new PerformanceDTO(); + dto.setUserName(u.getNickname()); + dto.setAccount(u.getAccount()); + //本月天数 + int workDaysInCurrentMonth = DateUtils.getWorkDaysInCurrentMonth(d); + //获取本月请假 + Integer applyTime=0; + if(!CollectionUtils.isEmpty(approvalList)){ + for (ItApproval a:approvalList) { + //分钟 + applyTime=getApprovalTime(approvalList,firstDayOfMonth);; + } + } + //本月天数 + dto.setDays(BigDecimal.valueOf(workDaysInCurrentMonth)); + //本月天数 请假天数 + dto.setApprovalDays(applyTime<1?BigDecimal.ZERO:BigDecimal.valueOf(applyTime).divide(BigDecimal.valueOf(60),2,BigDecimal.ROUND_HALF_UP)); + //可用工时 6小时算 + dto.setTotalTime( + dto.getApprovalDays().intValue()==0?dto.getDays().multiply(BigDecimal.valueOf(8)).setScale(2,BigDecimal.ROUND_HALF_UP) + :dto.getDays().multiply(BigDecimal.valueOf(8)).subtract(dto.getApprovalDays()).setScale(2,BigDecimal.ROUND_HALF_UP)); + //达标工时 + dto.setExamineTime(dto.getTotalTime().multiply(BigDecimal.valueOf(0.75))); + //产出工时 算task + List taskTimeList = taskList.stream().filter(o->o.getFinishedDate()!=null&& + o.getFinishedDate().getTime()<=lastDayOfMonth.getTime() &&firstDayOfMonth.getTime()<=o.getFinishedDate().getTime() + ).map(o -> o.getConsumed()).collect(Collectors.toList()); + + //分配总工时 + taskTimeList = taskList.stream().filter(o->u.getAccount().equals(o.getAssignedTo())).map(o -> o.getEstimate()).collect(Collectors.toList()); + dto.setAllocationTime(floatBatchAdd(taskTimeList)); + + dto.setWorkTime(floatBatchAdd(taskList.stream().filter(o->u.getAccount().equals(o.getAssignedTo())).map(o -> o.getConsumed()).collect(Collectors.toList()))); + + //工作饱和度 + dto.setSaturation(dto.getTotalTime().floatValue()==0?BigDecimal.ZERO:dto.getAllocationTime().divide(dto.getExamineTime(),2,BigDecimal.ROUND_HALF_UP)); + float saturation = dto.getSaturation().floatValue(); + //完成准时率 TODO 延期 / 总完成 + List delayTaskList = taskList.stream().filter(o->u.getAccount().equals(o.getAssignedTo())).filter(o -> o.getFinishedDate() != null + && DateUtils.getDayLast(o.getFinishedDate()).getTime() > DateUtils.getDayLast(o.getDeadline()).getTime()).collect(Collectors.toList()); + dto.setFinishTask(BigDecimal.valueOf(taskTimeList.size())); + dto.setDelayTask(BigDecimal.valueOf(delayTaskList.size())); + //准时完成率 + dto.setFinishPunctuality(taskTimeList.size()==0?BigDecimal.valueOf(0): + CollectionUtils.isEmpty(delayTaskList)?BigDecimal.valueOf(1): + BigDecimal.valueOf(1).subtract(BigDecimal.valueOf(delayTaskList.size()) + .divide(BigDecimal.valueOf(taskTimeList.size()),2,BigDecimal.ROUND_HALF_UP))); + //工作饱和度 + if(saturation<0.7){ + // = 0 + dto.setSaturationScore(BigDecimal.ZERO); + }else{ + if(saturation<0.9){ + dto.setSaturationScore(BigDecimal.valueOf(40 - ( 0.9 - saturation ) * 100 * 1).setScale(2,BigDecimal.ROUND_HALF_UP)); + }else{ + dto.setSaturationScore(BigDecimal.valueOf(40)); + } + } + BigDecimal finishPunctuality = dto.getFinishPunctuality(); + // 准时率得分 ( `完成准时率` < 1 , 25 - (1 - `完成准时率`) * 100 * 1, 25 )) `准时率得分`, + if(finishPunctuality.floatValue()<1){ + //TODO 完成准时率 0.8 + if(finishPunctuality.floatValue()<0.8){ + dto.setPunctualityScore(BigDecimal.ZERO); + }else{ + dto.setPunctualityScore(BigDecimal.valueOf(25 - (1 - finishPunctuality.floatValue()) * 100 * 1).setScale(2,BigDecimal.ROUND_HALF_UP)); + + } + }else{ + //饱和率得分 + dto.setPunctualityScore(BigDecimal.valueOf(25)); + } + List bugList = this.bugService.list(new QueryWrapper().lambda().between(ZtBug::getOpeneddate, firstDayOfMonth, lastDayOfMonth) + .in(ZtBug::getSeverity, 1, 2).eq(ZtBug::getResolvedby,u.getAccount())); + + + if(CollectionUtils.isEmpty(bugList)){ + dto.setSeriousBug(BigDecimal.ZERO); + dto.setSlightBug(BigDecimal.ZERO); + dto.setBugScore(BigDecimal.valueOf(10)); + }else{ + Long seriousBug = bugList.stream().filter(o -> o.getSeverity() == 1).count(); + dto.setSeriousBug(BigDecimal.valueOf(seriousBug)); + Long slightBug = bugList.stream().filter(o -> o.getSeverity() == 1).count(); + dto.setSlightBug(BigDecimal.valueOf(slightBug)); + + + //测试 if(`线上严重bug` = 0 AND `线上普通bug` = 0, 20, 20 - `线上严重bug` * 20 - `线上普通bug` * 5 ) + if(u.getUserType()==UserType.CS){ + dto.setBugScore( + (seriousBug==0l&&slightBug==0l)?BigDecimal.valueOf(20):BigDecimal.valueOf(20).subtract(BigDecimal.valueOf(seriousBug).multiply(BigDecimal.valueOf(20).subtract(BigDecimal.valueOf(slightBug).multiply(BigDecimal.valueOf(5))))) + ); + }else{ + dto.setBugScore((seriousBug==0l&&slightBug==0l)?BigDecimal.valueOf(10):BigDecimal.valueOf(10).subtract(BigDecimal.valueOf(seriousBug).multiply(BigDecimal.valueOf(10).subtract(BigDecimal.valueOf(slightBug).multiply(BigDecimal.valueOf(3)))))); + } + //其余 if(`线上严重bug` = 0 AND `线上普通bug` = 0, 10, 10 - `线上严重bug` * 10 - `线上普通bug` * 3 ) + } + if(u.getUserType()==UserType.CS){ + //算绩效 `线上bug得分` + `准时率得分` + 50, + dto.setScore(dto.getBugScore() .add(dto.getPunctualityScore()).add(BigDecimal.valueOf(50)) ); + }else{ + //`饱和率得分`+ `线上bug得分` + `准时率得分` + 25 + dto.setScore(dto.getSaturationScore() .add(dto.getBugScore()).add(dto.getPunctualityScore()).add(BigDecimal.valueOf(25))); + } + + result.add(dto); + } + + + + return result; +// return this.projectService.performanceCount(firstDayOfMonth,lastDayOfMonth); + } + + //分钟 请假 + private Integer getApprovalTime(List approvalList,Date d) { + String dFormat = DateUtils.formatDate(d, "yyyyMM"); + Integer value=0; + for (ItApproval approval:approvalList) { + + Date applyTimeEnd = approval.getApplyTimeEnd(); + Date applyTimeStart = approval.getApplyTimeStart(); + String startStr = DateUtils.formatDate(applyTimeEnd, "yyyyMM"); + String endStr = DateUtils.formatDate(applyTimeStart, "yyyyMM"); + + int intStart = Integer.valueOf(DateUtils.formatDate(applyTimeEnd, "yyyyMMdd")); + int intEnd = Integer.valueOf(DateUtils.formatDate(applyTimeStart, "yyyyMMdd")); + if((intEnd-intStart)==0){ + value+=approval.getApplyDays(); + }else{ + // 情况 1 1月27 -2 2 + //情况2 2.月28 -3.1 + int days = DateUtils.daysBetween(applyTimeStart, applyTimeEnd)+1; + for (int i =0;i workTaskCounts(ZtCountQo qo) { @@ -871,12 +1161,12 @@ public class IZtCountService { if(size==0){ dto.setYsYesRate(BigDecimal.ZERO); }else{ - dto.setYsYesRate(BigDecimal.valueOf(size).divide(BigDecimal.valueOf(ysVerified.size()),2,BigDecimal.ROUND_HALF_UP)); + dto.setYsYesRate(BigDecimal.valueOf(size).divide(BigDecimal.valueOf(ysVerified.size()),2,BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100))); } if(CollectionUtils.isEmpty(ysVerified)){ dto.setYsNoRate(BigDecimal.ZERO); }else{ - dto.setYsNoRate(BigDecimal.valueOf(1).subtract(dto.getYsYesRate())); + dto.setYsNoRate(BigDecimal.valueOf(ysVerified.stream().filter(o -> o.getStage().equals("verified")&&o.getYsFlag()==2).collect(Collectors.toList()).size())); } } @@ -1018,9 +1308,15 @@ public class IZtCountService { // return zeroMap(map,objMap); // } - List releases = this.releaseService.list(new QueryWrapper().lambda() - .eq(ZtRelease::getStatus,"released") - .in(ZtRelease::getProject, projectList.stream().map(o -> o.getProject()).collect(Collectors.toList()))); + List releases =null; + if(CollectionUtils.isEmpty(projectList)){ + releases=new ArrayList<>(); + }else{ + releases=this.releaseService.list(new QueryWrapper().lambda() + .eq(ZtRelease::getStatus,"released") + .in(ZtRelease::getProject, projectList.stream().map(o -> o.getProject()).collect(Collectors.toList()))); + + } @@ -1090,6 +1386,7 @@ public class IZtCountService { if(!CollectionUtils.isEmpty(releases)){ long relaese= this.releaseDetailsService.count(new QueryWrapper().lambda() .in(ZtReleaseDetails::getReleaseId, releases.stream().map(o -> o.getId()).collect(Collectors.toList())) + .ne(ZtReleaseDetails::getStatus,"closed") .eq(ZtReleaseDetails::getObjectType, "story")); objMap.put("online",relaese); }else{ @@ -1234,5 +1531,118 @@ public class IZtCountService { return cronDevopsService.pageList(dto).getList(); } + void generatorDevlopExcel(String name,PerformanceDTO performanceDTO,Date d){ + try (FileInputStream templateFile =new FileInputStream("scope开发.xlsx")) { + Map dataMap = new HashMap<>(); + dataMap.put("name", name); + dataMap.put("date", DateUtils.formatDate(new Date(),"yyyy-MM")); + dataMap.put("准时率得分", performanceDTO.getPunctualityScore().toString()); + dataMap.put("代码质量", "10"); + dataMap.put("文档质量", "10"); + dataMap.put("饱和度得分", performanceDTO.getSaturationScore().toString()); + dataMap.put("线上bug得分", performanceDTO.getBugScore().toString()); + dataMap.put("工作态度", "5"); + dataMap.put("创新贡献", "0"); + dataMap.put("总分", devlopTotal( + dataMap.get("准时率得分"), + dataMap.get("线上bug得分"), + dataMap.get("代码质量"), + dataMap.get("文档质量"), + dataMap.get("饱和度得分"), + dataMap.get("工作态度") + )); + //测试方案 + // 读取模板 + + Workbook workbook = WorkbookFactory.create(templateFile); + workbook.setSheetName(0,name); + Sheet sheet = workbook.getSheetAt(0); + + // 替换占位符 + for (Row row : sheet) { + for (Cell cell : row) { + if (cell.getCellType() == CellType.STRING) { + String cellValue = cell.getStringCellValue(); + for (Map.Entry entry : dataMap.entrySet()) { + cellValue = cellValue.replace("${" + entry.getKey() + "}", entry.getValue()); + } + cell.setCellValue(cellValue); + } + } + } + + // 生成新文件 + try (FileOutputStream outputStream = new FileOutputStream(name+"开发.xlsx")) { + workbook.write(outputStream); + } + workbook.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + String devlopTotal(String ...args){ + int i =0; + for (String s:args) { + try { + i+=new BigDecimal(s).intValue(); + }catch (Exception e){ + log.error("",e); + } + + } + return i+""; + } + void generatorTestExcel(String name,PerformanceDTO performanceDTO,Date d){ + try (FileInputStream templateFile =new FileInputStream("scope测试.xlsx")) { + Map dataMap = new HashMap<>(); + dataMap.put("name", name); + dataMap.put("date", DateUtils.formatDate(d,"yyyy-MM")); + dataMap.put("准时率得分",performanceDTO.getPunctualityScore().toString()); + dataMap.put("测试方案", "20"); + dataMap.put("缺陷管理", "10"); + + dataMap.put("线上bug得分", performanceDTO.getBugScore().toString()); + dataMap.put("测试报告编写", "10"); + dataMap.put("测试技能", "5"); + dataMap.put("态度", "5"); + dataMap.put("创新贡献", "0"); + dataMap.put("总分", devlopTotal(dataMap.get("准时率得分") + ,dataMap.get("缺陷管理") + ,dataMap.get("线上bug得分") + ,dataMap.get("线上bug得分") + ,dataMap.get("测试技能") + ,dataMap.get("态度") + ,dataMap.get("创新贡献") )); + //测试方案 + // 读取模板 + + Workbook workbook = WorkbookFactory.create(templateFile); + Sheet sheet = workbook.getSheetAt(0); + workbook.setSheetName(0,name); + // 替换占位符 + for (Row row : sheet) { + for (Cell cell : row) { + if (cell.getCellType() == CellType.STRING) { + String cellValue = cell.getStringCellValue(); + for (Map.Entry entry : dataMap.entrySet()) { + cellValue = cellValue.replace("${" + entry.getKey() + "}", entry.getValue()); + } + cell.setCellValue(cellValue); + } + } + } + + // 生成新文件 + try (FileOutputStream outputStream = new FileOutputStream(name+"测试.xlsx")) { + workbook.write(outputStream); + } + workbook.close(); + } catch (Exception e) { + e.printStackTrace(); + } + + + + } } \ No newline at end of file diff --git a/src/main/java/com/sa/zentao/service/impl/ZtBugServiceImpl.java b/src/main/java/com/sa/zentao/service/impl/ZtBugServiceImpl.java index 250c8e1..c0e4f15 100644 --- a/src/main/java/com/sa/zentao/service/impl/ZtBugServiceImpl.java +++ b/src/main/java/com/sa/zentao/service/impl/ZtBugServiceImpl.java @@ -224,10 +224,28 @@ public class ZtBugServiceImpl extends ServiceImpl implements @Override @Transactional public void assignedTo(ZtBugQo qo) { + + LoginRiskUser loginRiskUser = RiskUserThreadLocal.get(); + if(loginRiskUser==null){ + throw new BusinessException("未查询到数据"); + } ZtBug ztBug = this.baseMapper.selectById(qo.getId()); + + if(!ztBug.getOpenedby().equals(loginRiskUser.getName())){ + if(!ztBug.getAssignedTo().equals(loginRiskUser.getName())){ + if(loginRiskUser.getUserType()!=UserType.XMGLY||loginRiskUser.getUserType()!=UserType.GSGC){ + throw new BusinessException("当前无法指派请联系管理员"); + } + } + } + + + if(ztBug==null){ throw new BusinessException("未查询到"); } + + ztBug.setAssignedTo(qo.getAssignedTo()); ztBug.setLasteditedby(RiskUserThreadLocal.get().getName()); ztBug.setLastediteddate(new Date()); diff --git a/src/main/java/com/sa/zentao/service/impl/ZtMeetingServiceImpl.java b/src/main/java/com/sa/zentao/service/impl/ZtMeetingServiceImpl.java index 81d1892..713af6e 100644 --- a/src/main/java/com/sa/zentao/service/impl/ZtMeetingServiceImpl.java +++ b/src/main/java/com/sa/zentao/service/impl/ZtMeetingServiceImpl.java @@ -205,6 +205,7 @@ public class ZtMeetingServiceImpl extends ServiceImpl{meetType}记录 {titleDate} \n" + "\n" + + "
会议名称: {name}
\n" + "
会议时间: {meetingDate}
\n" + "
会议地点: {address}
\n" + "
参会人员: {usersName}
\n" + @@ -214,14 +215,14 @@ public class ZtMeetingServiceImpl extends ServiceImpl textMap = new LinkedHashMap<>(); - textMap.put("titleDate", DateUtils.formatDate(ztMeeting.getMeetingDate(),"YYYY-MM-DD")); - + textMap.put("titleDate", DateUtils.formatDate(ztMeeting.getMeetingDate(),"yyyy-MM-dd")); + textMap.put("name", ztMeeting.getName()); pfdStr=pfdStr.replace("{meetType}",ztMeeting.getType().getValue()); - pfdStr=pfdStr.replace("{titleDate}",DateUtils.formatDate(ztMeeting.getMeetingDate(),"YYYY-MM-DD ")); + pfdStr=pfdStr.replace("{titleDate}",DateUtils.formatDate(ztMeeting.getMeetingDate(),"yyyy-MM-dd ")); - textMap.put("meetingDate", DateUtils.formatDate(ztMeeting.getMeetingDate(),"YYYY/MM/DD")); - pfdStr= pfdStr.replace("{meetingDate}",DateUtils.formatDate(ztMeeting.getMeetingDate(),"YYYY/MM/DD HH:mm")); + textMap.put("meetingDate", DateUtils.formatDate(ztMeeting.getMeetingDate(),"yyyy/MM/dd")); + pfdStr= pfdStr.replace("{meetingDate}",DateUtils.formatDate(ztMeeting.getMeetingDate(),"yyyy/MM/dd HH:mm")); textMap.put("address",ztMeeting.getAddress()); pfdStr= pfdStr.replace("{address}",ztMeeting.getAddress()); StringBuilder b=new StringBuilder(); @@ -252,6 +253,7 @@ public class ZtMeetingServiceImpl extends ServiceImpl productList(ZtProjectQo qo) { + List pIds = this.ztProjectService.authProductList(); + if(CollectionUtils.isEmpty(pIds)){ + return new ArrayList<>(); + } + List ztProducts = this.baseMapper.selectList(new QueryWrapper() .lambda().eq(ZtProduct::getDeleted,"0") - .notIn(ZtProduct::getStatus, Arrays.asList("closed")) + .notIn(ZtProduct::getStatus, Arrays.asList("closed")).in(ZtProduct::getId,pIds) ); if(CollectionUtils.isEmpty(ztProducts)){ return new ArrayList<>(); diff --git a/src/main/java/com/sa/zentao/service/impl/ZtProjectServiceImpl.java b/src/main/java/com/sa/zentao/service/impl/ZtProjectServiceImpl.java index 6178cdf..f3d39a1 100644 --- a/src/main/java/com/sa/zentao/service/impl/ZtProjectServiceImpl.java +++ b/src/main/java/com/sa/zentao/service/impl/ZtProjectServiceImpl.java @@ -1,15 +1,13 @@ package com.sa.zentao.service.impl; +import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.sa.zentao.conf.RiskUserThreadLocal; -import com.sa.zentao.dao.BusinessException; -import com.sa.zentao.dao.PerformanceDTO; -import com.sa.zentao.dao.ZtProjectDTO; -import com.sa.zentao.dao.ZtStoryDTO; +import com.sa.zentao.dao.*; import com.sa.zentao.entity.*; import com.sa.zentao.enums.ActionStatus; import com.sa.zentao.enums.ActionType; @@ -20,6 +18,7 @@ import com.sa.zentao.qo.ZtProjectQo; import com.sa.zentao.service.*; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.sa.zentao.utils.BeanCopyUtil; +import com.sa.zentao.utils.Constant; import com.sa.zentao.utils.DateUtils; import com.sa.zentao.utils.KanBanConstant; import org.apache.commons.lang3.StringUtils; @@ -37,7 +36,7 @@ import java.util.stream.Stream; /** *

- * 服务实现类 + * 服务实现类 *

* * @author gqb @@ -87,23 +86,22 @@ public class ZtProjectServiceImpl extends ServiceImpl pLis=new ArrayList<>(){{ + List pLis = new ArrayList<>() {{ add("develop"); add("test"); add("resolving"); }}; - @Override @Transactional public void addProject(ZtProjectDTO dto) { ZtProject ztProject = new ZtProject(); - BeanUtils.copyProperties(dto,ztProject); + BeanUtils.copyProperties(dto, ztProject); ztProject.setFirstEnd(ztProject.getEnd()); ztProject.setRealBegan(ztProject.getBegin()); - ztProject.setDays((dto.getDays()!=null&&dto.getDays()!=0)?dto.getDays():DateUtils.getbetweenDays(ztProject.getBegin(),ztProject.getEnd())); + ztProject.setDays((dto.getDays() != null && dto.getDays() != 0) ? dto.getDays() : DateUtils.getbetweenDays(ztProject.getBegin(), ztProject.getEnd())); ztProject.setStatus("wait"); ztProject.setPri("1"); ztProject.setType(dto.getType()); @@ -121,81 +119,80 @@ public class ZtProjectServiceImpl extends ServiceImpl productIds = dto.getProductIds(); - for (Integer i :productIds) { - ZtProjectproduct p=new ZtProjectproduct(); + for (Integer i : productIds) { + ZtProjectproduct p = new ZtProjectproduct(); p.setProject(ztProject.getId()); p.setProduct(i); projectproductService.save(p); - product=p.getProduct()+""; + product = p.getProduct() + ""; } } - type=ActionType.XM; - project=ztProject.getId(); + type = ActionType.XM; + project = ztProject.getId(); //执行 要加看板 - if("sprint".equalsIgnoreCase(ztProject.getType())){ + if ("sprint".equalsIgnoreCase(ztProject.getType())) { //执行手动加 关联产品 List projectList = new ArrayList<>(Arrays.asList(dto.getProject())); - List saveList=new ArrayList(); - for (Integer pId :projectList) { - ZtExecutionproject p=new ZtExecutionproject(); + List saveList = new ArrayList(); + for (Integer pId : projectList) { + ZtExecutionproject p = new ZtExecutionproject(); p.setExecution(ztProject.getId()); p.setProject(pId); saveList.add(p); } this.executionprojectService.saveBatch(saveList); - int index=5; + int index = 5; - for (int i=0;i< 3;i++) { + for (int i = 0; i < 3; i++) { List list = KanBanConstant.LANEMAP.get(i); ZtKanbanlane ztKanbanlane = new ZtKanbanlane(); ztKanbanlane.setExecution(ztProject.getId()); @@ -203,38 +200,38 @@ public class ZtProjectServiceImpl extends ServiceImpl cMap = KanBanConstant.columnMap.get(i); + Map cMap = KanBanConstant.columnMap.get(i); - int pIndex=0; - int pId=0; - for (Map.Entry e :cMap.entrySet()) { + int pIndex = 0; + int pId = 0; + for (Map.Entry e : cMap.entrySet()) { String key = e.getKey(); String value = e.getValue(); - if(pLis.contains(key)){ + if (pLis.contains(key)) { ZtKanbancolumn ztKanbancolumn = new ZtKanbancolumn(); ztKanbancolumn.setParent(-1); ztKanbancolumn.setType(key); ztKanbancolumn.setName(value); kanbancolumnService.save(ztKanbancolumn); - pIndex=2; - pId=ztKanbancolumn.getId(); - }else{ + pIndex = 2; + pId = ztKanbancolumn.getId(); + } else { ZtKanbancolumn ztKanbancolumn = new ZtKanbancolumn(); ztKanbancolumn.setParent(pId); ztKanbancolumn.setType(key); ztKanbancolumn.setName(value); kanbancolumnService.save(ztKanbancolumn); - if(pIndex!=0){ - pIndex=pIndex-1; - if(pIndex==0){ - pId=0; + if (pIndex != 0) { + pIndex = pIndex - 1; + if (pIndex == 0) { + pId = 0; } } - ZtKanbancell cell=new ZtKanbancell(); + ZtKanbancell cell = new ZtKanbancell(); cell.setKanban(ztProject.getId()); cell.setLane(ztKanbanlane.getId()); cell.setColumn(ztKanbancolumn.getId()); @@ -246,16 +243,16 @@ public class ZtProjectServiceImpl extends ServiceImpl )dto.getTeamList()) { + for (String user : (List) dto.getTeamList()) { ZtTeam ztTeam = new ZtTeam(); ztTeam.setRoot(ztProject.getId()); ztTeam.setAccount(user); @@ -291,7 +288,7 @@ public class ZtProjectServiceImpl extends ServiceImpl().lambda().eq(ZtProjectproduct::getProject, ztProject.getId())); - if(projectproduct!=null){ - product=projectproduct.getProduct()+""; - project=projectproduct.getProject(); + if (projectproduct != null) { + product = projectproduct.getProduct() + ""; + project = projectproduct.getProject(); } - }else if("execution".equalsIgnoreCase(ztProject.getType())){ - type=ActionType.ZX; - project=ztProject.getProject(); - exection=ztProject.getId(); + } else if ("execution".equalsIgnoreCase(ztProject.getType())) { + type = ActionType.ZX; + project = ztProject.getProject(); + exection = ztProject.getId(); } - actionService.addAction(type,ActionStatus.GB,ztProject.getId(),product,project,exection,RiskUserThreadLocal.get().getName(),dto.getDesc(),null); + actionService.addAction(type, ActionStatus.GB, ztProject.getId(), product, project, exection, RiskUserThreadLocal.get().getName(), dto.getDesc(), null); } @@ -327,133 +324,133 @@ public class ZtProjectServiceImpl extends ServiceImpl().lambda().eq(ZtProjectproduct::getProject, ztProject.getId())); - if(projectproduct!=null){ - product=projectproduct.getProduct()+""; - project=projectproduct.getProject(); + if (projectproduct != null) { + product = projectproduct.getProduct() + ""; + project = projectproduct.getProject(); } - }else if("execution".equalsIgnoreCase(ztProject.getType())){ - type=ActionType.ZX; - project=ztProject.getProject(); - exection=ztProject.getId(); + } else if ("execution".equalsIgnoreCase(ztProject.getType())) { + type = ActionType.ZX; + project = ztProject.getProject(); + exection = ztProject.getId(); } - actionService.addAction(type,ActionStatus.KS,ztProject.getId(),product,project,exection,RiskUserThreadLocal.get().getName(),dto.getDesc(),null); + actionService.addAction(type, ActionStatus.KS, ztProject.getId(), product, project, exection, RiskUserThreadLocal.get().getName(), dto.getDesc(), null); } @Override public void projectDeleted(ZtProjectDTO dto) { ZtProject ztProject = this.baseMapper.selectById(dto.getId()); - if(ztProject==null||"1".equalsIgnoreCase(ztProject.getDeleted())){ + if (ztProject == null || "1".equalsIgnoreCase(ztProject.getDeleted())) { throw new BusinessException("未查询到"); } ztProject.setDeleted("1"); ztProject.setLastEditedBy(RiskUserThreadLocal.get().getName()); ztProject.setLastEditedDate(new Date()); this.baseMapper.updateById(ztProject); - ActionType type=null; - String product=null; - Integer project=null; - Integer exection=null; - if("program".equalsIgnoreCase(ztProject.getType())){ - type=ActionType.XMJ; - }else if("project".equalsIgnoreCase(ztProject.getType())){ - type=ActionType.XM; + ActionType type = null; + String product = null; + Integer project = null; + Integer exection = null; + if ("program".equalsIgnoreCase(ztProject.getType())) { + type = ActionType.XMJ; + } else if ("project".equalsIgnoreCase(ztProject.getType())) { + type = ActionType.XM; ZtProjectproduct projectproduct = this.projectproductService.getOne(new QueryWrapper().lambda().eq(ZtProjectproduct::getProject, ztProject.getId())); - if(projectproduct!=null){ - product=projectproduct.getProduct()+""; - project=projectproduct.getProject(); + if (projectproduct != null) { + product = projectproduct.getProduct() + ""; + project = projectproduct.getProject(); } - }else if("execution".equalsIgnoreCase(ztProject.getType())){ - type=ActionType.ZX; - project=ztProject.getProject(); - exection=ztProject.getId(); + } else if ("execution".equalsIgnoreCase(ztProject.getType())) { + type = ActionType.ZX; + project = ztProject.getProject(); + exection = ztProject.getId(); } - actionService.addAction(type,ActionStatus.SC,ztProject.getId(),product,project,exection,RiskUserThreadLocal.get().getName(),dto.getDesc(),null); + actionService.addAction(type, ActionStatus.SC, ztProject.getId(), product, project, exection, RiskUserThreadLocal.get().getName(), dto.getDesc(), null); } @Override public void projectActivated(ZtProjectDTO dto) { ZtProject ztProject = this.baseMapper.selectById(dto.getId()); - if(ztProject==null||!"closed".equalsIgnoreCase(ztProject.getStatus())){ + if (ztProject == null || !"closed".equalsIgnoreCase(ztProject.getStatus())) { throw new BusinessException("未查询到"); } ztProject.setStatus("doing"); ztProject.setLastEditedBy(RiskUserThreadLocal.get().getName()); this.baseMapper.updateById(ztProject); - ActionType type=null; - String product=null; - Integer project=null; - Integer exection=null; - if("program".equalsIgnoreCase(ztProject.getType())){ - type=ActionType.XMJ; - }else if("project".equalsIgnoreCase(ztProject.getType())){ - type=ActionType.XM; + ActionType type = null; + String product = null; + Integer project = null; + Integer exection = null; + if ("program".equalsIgnoreCase(ztProject.getType())) { + type = ActionType.XMJ; + } else if ("project".equalsIgnoreCase(ztProject.getType())) { + type = ActionType.XM; ZtProjectproduct projectproduct = this.projectproductService.getOne(new QueryWrapper().lambda().eq(ZtProjectproduct::getProject, ztProject.getId())); - if(projectproduct!=null){ - product=projectproduct.getProduct()+""; - project=projectproduct.getProject(); + if (projectproduct != null) { + product = projectproduct.getProduct() + ""; + project = projectproduct.getProject(); } - }else if("execution".equalsIgnoreCase(ztProject.getType())){ - type=ActionType.ZX; - project=ztProject.getProject(); - exection=ztProject.getId(); + } else if ("execution".equalsIgnoreCase(ztProject.getType())) { + type = ActionType.ZX; + project = ztProject.getProject(); + exection = ztProject.getId(); } - actionService.addAction(type,ActionStatus.JH,ztProject.getId(),product,project,exection,RiskUserThreadLocal.get().getName(),dto.getDesc(),null); + actionService.addAction(type, ActionStatus.JH, ztProject.getId(), product, project, exection, RiskUserThreadLocal.get().getName(), dto.getDesc(), null); } @Override public void projectSuspended(ZtProjectDTO dto) { ZtProject ztProject = this.baseMapper.selectById(dto.getId()); - if(ztProject==null||!"wait".equalsIgnoreCase(ztProject.getStatus())){ + if (ztProject == null || !"wait".equalsIgnoreCase(ztProject.getStatus())) { throw new BusinessException("未查询到"); } ztProject.setStatus("suspended"); ztProject.setLastEditedBy(RiskUserThreadLocal.get().getName()); this.baseMapper.updateById(ztProject); - ActionType type=null; - String product=null; - Integer project=null; - Integer exection=null; - if("program".equalsIgnoreCase(ztProject.getType())){ - type=ActionType.XMJ; - }else if("project".equalsIgnoreCase(ztProject.getType())){ - type=ActionType.XM; + ActionType type = null; + String product = null; + Integer project = null; + Integer exection = null; + if ("program".equalsIgnoreCase(ztProject.getType())) { + type = ActionType.XMJ; + } else if ("project".equalsIgnoreCase(ztProject.getType())) { + type = ActionType.XM; ZtProjectproduct projectproduct = this.projectproductService.getOne(new QueryWrapper().lambda().eq(ZtProjectproduct::getProject, ztProject.getId())); - if(projectproduct!=null){ - product=projectproduct.getProduct()+""; - project=projectproduct.getProject(); + if (projectproduct != null) { + product = projectproduct.getProduct() + ""; + project = projectproduct.getProject(); } - }else if("execution".equalsIgnoreCase(ztProject.getType())){ - type=ActionType.ZX; - project=ztProject.getProject(); - exection=ztProject.getId(); + } else if ("execution".equalsIgnoreCase(ztProject.getType())) { + type = ActionType.ZX; + project = ztProject.getProject(); + exection = ztProject.getId(); } - actionService.addAction(type,ActionStatus.GQ,ztProject.getId(),product,project,exection,RiskUserThreadLocal.get().getName(),dto.getDesc(),null); + actionService.addAction(type, ActionStatus.GQ, ztProject.getId(), product, project, exection, RiskUserThreadLocal.get().getName(), dto.getDesc(), null); } @@ -461,14 +458,6 @@ public class ZtProjectServiceImpl extends ServiceImpl getStoryByImplementId(ZtProjectDTO dto) { - - - - - - - - Integer id = dto.getId(); LambdaQueryWrapper eq1 = new QueryWrapper().lambda() @@ -476,7 +465,7 @@ public class ZtProjectServiceImpl extends ServiceImpl products = this.projectproductService.list(eq1); - if(CollectionUtils.isEmpty(products)){ + if (CollectionUtils.isEmpty(products)) { return new ArrayList<>(); } @@ -487,7 +476,7 @@ public class ZtProjectServiceImpl extends ServiceImpl pStoryList = this.projectstoryService.list(new QueryWrapper().lambda().eq(ZtProjectstory::getProject, pject)); - if(CollectionUtils.isEmpty(pStoryList)){ + if (CollectionUtils.isEmpty(pStoryList)) { return new ArrayList<>(); } //忽略掉有的 @@ -496,14 +485,14 @@ public class ZtProjectServiceImpl extends ServiceImpl eq = new QueryWrapper().lambda() .eq(ZtStory::getDeleted, "0") - .in(ZtStory::getId, pStoryList.stream().map(o->o.getStory()).collect(Collectors.toList())); + .in(ZtStory::getId, pStoryList.stream().map(o -> o.getStory()).collect(Collectors.toList())); - if(dto.getStatus()!=null){ + if (dto.getStatus() != null) { eq.eq(ZtStory::getStatus, dto.getStatus()); } - if(!CollectionUtils.isEmpty(list)){ - eq.notIn(ZtStory::getId,list.stream().map(o->o.getStory()).collect(Collectors.toList())); + if (!CollectionUtils.isEmpty(list)) { + eq.notIn(ZtStory::getId, list.stream().map(o -> o.getStory()).collect(Collectors.toList())); } List active = this.storyService.list( @@ -511,12 +500,10 @@ public class ZtProjectServiceImpl extends ServiceImpl(); - }else{ - return BeanCopyUtil.copyListProperties(active,ZtStoryDTO::new); + } else { + return BeanCopyUtil.copyListProperties(active, ZtStoryDTO::new); } } @@ -528,30 +515,30 @@ public class ZtProjectServiceImpl extends ServiceImpl saveList=new ArrayList(); - List storyIds= dto.getStoryIds(); + List saveList = new ArrayList(); + List storyIds = dto.getStoryIds(); List list = projectstoryService.list(new QueryWrapper().lambda() .eq(ZtProjectstory::getProject, dto.getId())); - Integer order=0; - if(!CollectionUtils.isEmpty(list)){ - order=list.stream().map(o->o.getOrder()).sorted((p1,p2)->p1-p2).collect(Collectors.toList()).get(0); + Integer order = 0; + if (!CollectionUtils.isEmpty(list)) { + order = list.stream().map(o -> o.getOrder()).sorted((p1, p2) -> p1 - p2).collect(Collectors.toList()).get(0); } List projectstoryList = projectstoryService.list(new QueryWrapper().lambda() - .eq(ZtProjectstory::getProject, ztProject.getId()).in(ZtProjectstory::getStory,storyIds)); - if(!CollectionUtils.isEmpty(projectstoryList)){ + .eq(ZtProjectstory::getProject, ztProject.getId()).in(ZtProjectstory::getStory, storyIds)); + if (!CollectionUtils.isEmpty(projectstoryList)) { throw new BusinessException("请勿重复添加"); } List ztStories = this.storyService.listByIds(storyIds); - for (ZtStory i:ztStories) { + for (ZtStory i : ztStories) { ZtProjectstory ztProjectstory = new ZtProjectstory(); ztProjectstory.setProject(ztProject.getId()); ztProjectstory.setProduct(i.getProduct()); ztProjectstory.setStory(i.getId()); ztProjectstory.setVersion(1); ztProjectstory.setOrder(order); - order +=1; + order += 1; saveList.add(ztProjectstory); } @@ -561,7 +548,7 @@ public class ZtProjectServiceImpl extends ServiceImpl list = this.projectproductService.list(new QueryWrapper() .lambda().eq(ZtProjectproduct::getProject, ztProject.getId())); - if(!CollectionUtils.isEmpty(list)){ + if (!CollectionUtils.isEmpty(list)) { throw new BusinessException("重复添加"); } List productIds = dto.getProductIds(); - for (Integer i:productIds) { + for (Integer i : productIds) { ZtProjectproduct ztProjectproduct = new ZtProjectproduct(); ztProjectproduct.setProduct(i); ztProjectproduct.setProject(ztProject.getId()); @@ -590,6 +577,7 @@ public class ZtProjectServiceImpl extends ServiceImpl getProjectByProduct(ZtProjectQo qo) { @@ -615,34 +603,34 @@ public class ZtProjectServiceImpl extends ServiceImpl().lambda() .eq(ZtProjectstory::getProject, project) ); - int order=0; - if(!CollectionUtils.isEmpty(list)){ + int order = 0; + if (!CollectionUtils.isEmpty(list)) { ZtProjectstory ztProjectstory = list.get(list.size() - 1); - order=ztProjectstory.getOrder()+5; + order = ztProjectstory.getOrder() + 5; } - List saveList=new ArrayList(); - Map sMap = getStoryMap(storyIds); + List saveList = new ArrayList(); + Map sMap = getStoryMap(storyIds); - for (Integer sId:storyIds) { + for (Integer sId : storyIds) { ZtProjectstory ztProjectstory = new ZtProjectstory(); ztProjectstory.setOrder(order); ztProjectstory.setStory(sId); ZtStory ztStory = sMap.get(sId); - if(ztStory!=null){ + if (ztStory != null) { ztProjectstory.setProduct(ztStory.getProduct()); } ztProjectstory.setType(ProjectTypeEnums.project.getValue()); ztProjectstory.setProject(project); saveList.add(ztProjectstory); - order+=5; + order += 5; } this.projectstoryService.saveBatch(saveList); @@ -650,14 +638,14 @@ public class ZtProjectServiceImpl extends ServiceImpl getStoryMap(List storyIds) { - if(CollectionUtils.isEmpty(storyIds)){ + if (CollectionUtils.isEmpty(storyIds)) { return new HashMap<>(); } List storyList = this.storyService.listByIds(storyIds); - if(CollectionUtils.isEmpty(storyList)){ + if (CollectionUtils.isEmpty(storyList)) { return new HashMap<>(); - }else{ - return storyList.stream().collect(Collectors.toMap(ZtStory::getId,o->o)); + } else { + return storyList.stream().collect(Collectors.toMap(ZtStory::getId, o -> o)); } } @@ -666,40 +654,39 @@ public class ZtProjectServiceImpl extends ServiceImpl list = this.executionprojectService.list(new QueryWrapper().lambda() .eq(ZtExecutionproject::getProject, qo.getId())); - if(CollectionUtils.isEmpty(list)){ + if (CollectionUtils.isEmpty(list)) { return new ArrayList<>(); - }else{ + } else { List pList = this.baseMapper.selectBatchIds(list.stream().map(o -> o.getExecution()).collect(Collectors.toList())); List result = BeanCopyUtil.copyListProperties(pList, ZtProjectDTO::new); - Map> projectMap =null; + Map> projectMap = null; Map userMap = this.userService.userMapByIds(null); - if(CollectionUtils.isEmpty(list)){ - projectMap=new HashMap<>(); - }else{ - projectMap=getProjectMapByExec(list,this.baseMapper + if (CollectionUtils.isEmpty(list)) { + projectMap = new HashMap<>(); + } else { + projectMap = getProjectMapByExec(list, this.baseMapper .selectBatchIds(list.stream().map(o -> o.getProject()).collect(Collectors.toList()))); } Map> ztProjectproductMap = getZtProjectproductMap(result); - Map> taskMap= execTaskMap(result); + Map> taskMap = execTaskMap(result); - - for (ZtProjectDTO d:result ) { + for (ZtProjectDTO d : result) { List ztProjects = projectMap.get(d.getId()); - if(!CollectionUtils.isEmpty(ztProjects)){ - d.setProjectName(StringUtils.join(ztProjects.stream().map(o->o.getName()).collect(Collectors.toList()), ",")); + if (!CollectionUtils.isEmpty(ztProjects)) { + d.setProjectName(StringUtils.join(ztProjects.stream().map(o -> o.getName()).collect(Collectors.toList()), ",")); } List ztProjectproducts = ztProjectproductMap.get(d.getId()); - if(!CollectionUtils.isEmpty(ztProjectproducts)){ - d.setProductIds(ztProjectproducts.stream().map(o->o.getProject()).collect(Collectors.toList())); + if (!CollectionUtils.isEmpty(ztProjectproducts)) { + d.setProductIds(ztProjectproducts.stream().map(o -> o.getProject()).collect(Collectors.toList())); } List tasks = taskMap.get(d.getId()); - if(!CollectionUtils.isEmpty(tasks)){ + if (!CollectionUtils.isEmpty(tasks)) { List leftList = tasks.stream().map(o -> o.getLeft()).collect(Collectors.toList()); List consumedList = tasks.stream().map(o -> o.getConsumed()).collect(Collectors.toList()); List planList = tasks.stream().map(o -> o.getEstimate()).collect(Collectors.toList()); @@ -710,7 +697,7 @@ public class ZtProjectServiceImpl extends ServiceImpl> countProject(ZtProjectQo qo) { Integer id = qo.getId(); + Map> result = new HashMap>(); - Map> result=new HashMap>(); - - Map story=new HashMap<>(); + Map story = new HashMap<>(); List list = projectstoryService.list(new QueryWrapper().lambda().eq(ZtProjectstory::getProject, id)); - if(CollectionUtils.isEmpty(list)){ - story.put("total",0); - story.put("finish",0); - story.put("residue",0); - }else{ + if (CollectionUtils.isEmpty(list)) { + story.put("total", 0); + story.put("finish", 0); + story.put("residue", 0); + } else { List ztStories = storyService.listByIds(list.stream().map(o -> o.getStory()).collect(Collectors.toList())); - story.put("total",ztStories.size()); + story.put("total", ztStories.size()); long developed = ztStories.stream().filter(o -> o.getStage().equalsIgnoreCase("developed")).count(); - story.put("finish",(int)developed); - story.put("residue",ztStories.size()-(int)developed); + story.put("finish", (int) developed); + story.put("residue", ztStories.size() - (int) developed); } - result.put("story",story); + result.put("story", story); //投入 List execList = this.executionprojectService.list(new QueryWrapper().lambda().eq(ZtExecutionproject::getProject, id)); - long trCount =0; - if(!CollectionUtils.isEmpty(execList)){ - trCount = this.teamService.count(new QueryWrapper().lambda().in(ZtTeam::getRoot, execList.stream().map(o->o.getExecution()).collect(Collectors.toList())).eq(ZtTeam::getType, "execution")); + long trCount = 0; + if (!CollectionUtils.isEmpty(execList)) { + trCount = this.teamService.count(new QueryWrapper().lambda().in(ZtTeam::getRoot, execList.stream().map(o -> o.getExecution()).collect(Collectors.toList())).eq(ZtTeam::getType, "execution")); } List tList = this.taskService.list(new QueryWrapper().lambda().eq(ZtTask::getProject, id)); - Map tr=new HashMap<>(); - tr.put("total",Integer.valueOf(trCount+"")); + Map tr = new HashMap<>(); + tr.put("total", Integer.valueOf(trCount + "")); // List planList = tasks.stream().map(o -> o.getEstimate()).collect(Collectors.toList()); // @@ -764,43 +748,43 @@ public class ZtProjectServiceImpl extends ServiceImpl planList = tList.stream().map(o -> o.getEstimate()).collect(Collectors.toList()); List consumeList = tList.stream().map(o -> o.getEstimate()).collect(Collectors.toList()); - tr.put("beExpectedTo",floatBatchAdd(planList).intValue()); - tr.put("consume",floatBatchAdd(consumeList).intValue()); - result.put("tr",tr); + tr.put("beExpectedTo", floatBatchAdd(planList).intValue()); + tr.put("consume", floatBatchAdd(consumeList).intValue()); + result.put("tr", tr); - Map task=new HashMap<>(); + Map task = new HashMap<>(); List taskList = taskService.list(new QueryWrapper().lambda().eq(ZtTask::getProject, id)); - if(CollectionUtils.isEmpty(taskList)){ - task.put("noStart",0); - task.put("process",0); - task.put("finish",0); - }else{ - int finish = (int)taskList.stream().filter(o -> o.getStatus().equalsIgnoreCase("done")).count(); - int process = (int)taskList.stream().filter(o -> o.getStatus().equalsIgnoreCase("doing")).count(); - int wait = (int)taskList.stream().filter(o -> o.getStatus().equalsIgnoreCase("wait")).count(); - task.put("noStart",wait); - task.put("process",process); - task.put("finish",finish); + if (CollectionUtils.isEmpty(taskList)) { + task.put("noStart", 0); + task.put("process", 0); + task.put("finish", 0); + } else { + int finish = (int) taskList.stream().filter(o -> o.getStatus().equalsIgnoreCase("done")).count(); + int process = (int) taskList.stream().filter(o -> o.getStatus().equalsIgnoreCase("doing")).count(); + int wait = (int) taskList.stream().filter(o -> o.getStatus().equalsIgnoreCase("wait")).count(); + task.put("noStart", wait); + task.put("process", process); + task.put("finish", finish); } - result.put("task",task); + result.put("task", task); - Map bug=new HashMap<>(); + Map bug = new HashMap<>(); List bugList = bugService.list(new QueryWrapper().lambda().eq(ZtBug::getProject, id)); - if(CollectionUtils.isEmpty(bugList)){ - bug.put("total",0); - bug.put("solve",0); - bug.put("noSolve",0); - }else{ - int solve = (int)bugList.stream().filter(o -> o.getStatus().equalsIgnoreCase("resolved")).count(); - int noSolve = (int)bugList.stream().filter(o -> o.getStatus().equalsIgnoreCase("active")).count(); + if (CollectionUtils.isEmpty(bugList)) { + bug.put("total", 0); + bug.put("solve", 0); + bug.put("noSolve", 0); + } else { + int solve = (int) bugList.stream().filter(o -> o.getStatus().equalsIgnoreCase("resolved")).count(); + int noSolve = (int) bugList.stream().filter(o -> o.getStatus().equalsIgnoreCase("active")).count(); - bug.put("total",bugList.size()); - bug.put("solve",solve); - bug.put("noSolve",noSolve); + bug.put("total", bugList.size()); + bug.put("solve", solve); + bug.put("noSolve", noSolve); } - result.put("bug",bug); + result.put("bug", bug); return result; } @@ -819,56 +803,56 @@ public class ZtProjectServiceImpl extends ServiceImpl authProductList(){ + public List authProductList() { List authList = authList(); - if(CollectionUtils.isEmpty(authList)){ + if (CollectionUtils.isEmpty(authList)) { return authList; } List list = this.productService.list(new QueryWrapper().lambda().in(ZtProduct::getProgram, authList)); - if(CollectionUtils.isEmpty(list)){ + if (CollectionUtils.isEmpty(list)) { return authList; - }else{ - return list.stream().map(o->o.getId()).collect(Collectors.toList()); + } else { + return list.stream().map(o -> o.getId()).collect(Collectors.toList()); } } @Override public List authList() { ZtUser user = userService.selectByName(RiskUserThreadLocal.get().getName()); - if(user.getAccount().equals("admin")){ + if (user.getAccount().equals("admin")) { return this.baseMapper.selectList(new QueryWrapper() - .lambda().eq(ZtProject::getType,"program")).stream().map(o->o.getId()).collect(Collectors.toList()); + .lambda().eq(ZtProject::getType, "program")).stream().map(o -> o.getId()).collect(Collectors.toList()); } String productIds = user.getProductIds(); - if(StringUtils.isEmpty(productIds)){ + if (StringUtils.isEmpty(productIds)) { return new ArrayList<>(); - }else{ + } else { String[] split = productIds.split(","); - List result=new ArrayList(); - for (String s:split) { + List result = new ArrayList(); + for (String s : split) { result.add(Integer.valueOf(s)); } - return result; + return result; } } @@ -878,29 +862,29 @@ public class ZtProjectServiceImpl extends ServiceImpl projectAuthList() { ZtUser user = userService.selectByName(RiskUserThreadLocal.get().getName()); - if(user.getAccount().equals("admin")){ + if (user.getAccount().equals("admin")) { return this.baseMapper.selectList(new QueryWrapper() - .lambda().eq(ZtProject::getType,"project")).stream().map(o->o.getId()).collect(Collectors.toList()); + .lambda().eq(ZtProject::getType, "project")).stream().map(o -> o.getId()).collect(Collectors.toList()); } String productIds = user.getProductIds(); - if(StringUtils.isEmpty(productIds)){ + if (StringUtils.isEmpty(productIds)) { return new ArrayList<>(); - }else{ + } else { String[] split = productIds.split(","); - List result=new ArrayList(); - for (String s:split) { + List result = new ArrayList(); + for (String s : split) { result.add(Integer.valueOf(s)); } List list = this.productService.list(new QueryWrapper().lambda().in(ZtProduct::getProgram, result)); - if(CollectionUtils.isEmpty(list)){ + if (CollectionUtils.isEmpty(list)) { return new ArrayList<>(); } List projectList = this.projectproductService.list(new QueryWrapper().lambda() .in(ZtProjectproduct::getProduct, list.stream().map(o -> o.getId()).collect(Collectors.toList()))); - if(CollectionUtils.isEmpty(projectList)){ + if (CollectionUtils.isEmpty(projectList)) { return new ArrayList<>(); } - return projectList.stream().map(o->o.getProject()).collect(Collectors.toList()); + return projectList.stream().map(o -> o.getProject()).collect(Collectors.toList()); } } @@ -908,41 +892,41 @@ public class ZtProjectServiceImpl extends ServiceImpl execAuthList() { ZtUser user = userService.selectByName(RiskUserThreadLocal.get().getName()); - if(user.getAccount().equals("admin")){ + if (user.getAccount().equals("admin")) { return this.baseMapper.selectList(new QueryWrapper() - .lambda().eq(ZtProject::getType,"sprint")).stream().map(o->o.getId()).collect(Collectors.toList()); + .lambda().eq(ZtProject::getType, "sprint")).stream().map(o -> o.getId()).collect(Collectors.toList()); } - List ids =null; + List ids = null; String productIds = user.getProductIds(); - if(StringUtils.isEmpty(productIds)){ + if (StringUtils.isEmpty(productIds)) { return new ArrayList<>(); - }else{ + } else { String[] split = productIds.split(","); - List result=new ArrayList(); - for (String s:split) { + List result = new ArrayList(); + for (String s : split) { result.add(Integer.valueOf(s)); } List list = this.productService.list(new QueryWrapper().lambda().in(ZtProduct::getProgram, result)); - if(CollectionUtils.isEmpty(list)){ + if (CollectionUtils.isEmpty(list)) { return new ArrayList<>(); } List projectList = this.projectproductService.list(new QueryWrapper().lambda() .in(ZtProjectproduct::getProduct, list.stream().map(o -> o.getId()).collect(Collectors.toList()))); - if(CollectionUtils.isEmpty(projectList)){ + if (CollectionUtils.isEmpty(projectList)) { return new ArrayList<>(); } - ids= projectList.stream().map(o->o.getProject()).collect(Collectors.toList()); + ids = projectList.stream().map(o -> o.getProject()).collect(Collectors.toList()); } - if(CollectionUtils.isEmpty(ids)){ + if (CollectionUtils.isEmpty(ids)) { return ids; } List list = this.executionprojectService.list(new QueryWrapper().lambda().in(ZtExecutionproject::getProject, ids)); - if(CollectionUtils.isEmpty(list)){ + if (CollectionUtils.isEmpty(list)) { return new ArrayList<>(); } - return list.stream().map(o->o.getExecution()).collect(Collectors.toList()); + return list.stream().map(o -> o.getExecution()).collect(Collectors.toList()); } @@ -951,50 +935,50 @@ public class ZtProjectServiceImpl extends ServiceImpl list = executionprojectService.list(new QueryWrapper().lambda().eq(ZtExecutionproject::getProject, id)); - if(CollectionUtils.isEmpty(list)){ + if (CollectionUtils.isEmpty(list)) { return new ArrayList<>(); } return this.baseMapper.selectList(new QueryWrapper().lambda() - .ne(ZtProject::getStatus,"closed") - .in(ZtProject::getId,list.stream().map(o->o.getExecution()).collect(Collectors.toList()))); + .ne(ZtProject::getStatus, "closed") + .in(ZtProject::getId, list.stream().map(o -> o.getExecution()).collect(Collectors.toList()))); } @Override public List execTeamById(ZtProjectQo qo) { List execution = this.teamService.list(new QueryWrapper().lambda().eq(ZtTeam::getType, "execution").eq(ZtTeam::getRoot, qo.getId())); - if(CollectionUtils.isEmpty(execution)){ + if (CollectionUtils.isEmpty(execution)) { return new ArrayList<>(); } - return execution.stream().map(o->o.getAccount()).collect(Collectors.toList()); + return execution.stream().map(o -> o.getAccount()).collect(Collectors.toList()); } @Override @Transactional public void execTeamUpdate(ZtProjectQo qo) { List teamList = qo.getTeamList(); - if(CollectionUtils.isEmpty(teamList)){ + if (CollectionUtils.isEmpty(teamList)) { throw new BusinessException("请选择"); } - List saveList=new ArrayList(); + List saveList = new ArrayList(); List oldTeam = this.teamService.list(new QueryWrapper() .lambda().eq(ZtTeam::getRoot, qo.getId()) .eq(ZtTeam::getType, "execution")); - for (ZtTeam t:oldTeam) { - if(!teamList.contains(t.getAccount())){ + for (ZtTeam t : oldTeam) { + if (!teamList.contains(t.getAccount())) { this.teamService.removeById(t.getId()); } } - for (String s:teamList) { + for (String s : teamList) { List execution = this.teamService.list(new QueryWrapper() .lambda().eq(ZtTeam::getAccount, s).eq(ZtTeam::getRoot, qo.getId()) .eq(ZtTeam::getType, "execution")); - if(CollectionUtils.isEmpty(execution)){ - ZtTeam t=new ZtTeam(); + if (CollectionUtils.isEmpty(execution)) { + ZtTeam t = new ZtTeam(); t.setType("execution"); t.setAccount(s); t.setRoot(qo.getId()); @@ -1002,7 +986,7 @@ public class ZtProjectServiceImpl extends ServiceImpl teamList = this.teamService.list(new QueryWrapper().lambda().eq(ZtTeam::getRoot, qo.getId()) .eq(ZtTeam::getType, "execution")); - if(CollectionUtils.isEmpty(teamList)){ + if (CollectionUtils.isEmpty(teamList)) { return new ArrayList<>(); } - return this.userService.list(new QueryWrapper().lambda().in(ZtUser::getAccount,teamList.stream().map(o->o.getAccount()).collect(Collectors.toList())) - ); + return this.userService.list(new QueryWrapper().lambda().in(ZtUser::getAccount, teamList.stream().map(o -> o.getAccount()).collect(Collectors.toList())) + ); } @Autowired @@ -1027,60 +1011,59 @@ public class ZtProjectServiceImpl extends ServiceImpl>> projectTeamTimeWork(ZtProjectQo qo) { - Map>> map=new HashMap<>(); + public Map>> projectTeamTimeWork(ZtProjectQo qo) { + Map>> map = new HashMap<>(); - Date date = qo.getDate(); + Date date = qo.getDate()==null?new Date():qo.getDate(); Date firstDayOfMonth = DateUtils.getFirstDayOfMonth(date); - Date lastDayOfMonth = new Date(DateUtils.getLastDayOfMonth(date).getTime()+1000*2); + Date lastDayOfMonth = new Date(DateUtils.getLastDayOfMonth(date).getTime() + 1000 * 2); //产品集 Integer project = qo.getProject(); //产品 List products = this.productService.list(new QueryWrapper().lambda().eq(ZtProduct::getProgram, project)); - if(CollectionUtils.isEmpty(products)){ + if (CollectionUtils.isEmpty(products)) { return new HashMap<>(); } //项目列表 List projectList = this.projectproductService.list(new QueryWrapper().lambda() .in(ZtProjectproduct::getProduct, products.stream().map(o -> o.getId()).collect(Collectors.toList()))); - if(CollectionUtils.isEmpty(projectList)){ + if (CollectionUtils.isEmpty(projectList)) { return new HashMap<>(); } List execList = this.executionprojectService.list(new QueryWrapper().lambda() .in(ZtExecutionproject::getProject, projectList.stream().map(o -> o.getProject()).collect(Collectors.toList()))); - if(CollectionUtils.isEmpty(execList)){ + if (CollectionUtils.isEmpty(execList)) { return new HashMap<>(); } - List list = this.taskService.list(new QueryWrapper().lambda().in(ZtTask::getExecution, execList.stream().map(o->o.getExecution()).collect(Collectors.toList()))); - if(CollectionUtils.isEmpty(list)){ + List list = this.taskService.list(new QueryWrapper().lambda().in(ZtTask::getExecution, execList.stream().map(o -> o.getExecution()).collect(Collectors.toList()))); + if (CollectionUtils.isEmpty(list)) { return new HashMap<>(); } //工时 List efforts = this.effortService.list(new QueryWrapper().lambda() .eq(ZtEffort::getObjecttype, "task") - .in(ZtEffort::getObjectid, list.stream().map(o->o.getId()).collect(Collectors.toList())) + .in(ZtEffort::getObjectid, list.stream().map(o -> o.getId()).collect(Collectors.toList())) .gt(ZtEffort::getDate, new Date(firstDayOfMonth.getTime() - 2000)).lt(ZtEffort::getDate, lastDayOfMonth) ); - - if(CollectionUtils.isEmpty(execList)){ + if (CollectionUtils.isEmpty(execList)) { return new HashMap<>(); } // 时间 T1 T2 // 任务 T3 T4 List ztProjects = this.listByIds(execList.stream().map(o -> o.getExecution()).collect(Collectors.toList())); - ztProjects=ztProjects.stream().filter(o-> - ( firstDayOfMonth .getTime()>=o.getBegin().getTime() &&lastDayOfMonth.getTime()>o.getEnd().getTime())|| - ( firstDayOfMonth .getTime()<=o.getBegin().getTime() &&lastDayOfMonth.getTime()>=o.getEnd().getTime())|| - ( firstDayOfMonth .getTime()<=o.getBegin().getTime() &&lastDayOfMonth.getTime()<=o.getEnd().getTime()) + ztProjects = ztProjects.stream().filter(o -> + (firstDayOfMonth.getTime() >= o.getBegin().getTime() && lastDayOfMonth.getTime() > o.getEnd().getTime()) || + (firstDayOfMonth.getTime() <= o.getBegin().getTime() && lastDayOfMonth.getTime() >= o.getEnd().getTime()) || + (firstDayOfMonth.getTime() <= o.getBegin().getTime() && lastDayOfMonth.getTime() <= o.getEnd().getTime()) ).collect(Collectors.toList()); - if(CollectionUtils.isEmpty(ztProjects)){ + if (CollectionUtils.isEmpty(ztProjects)) { return map; } List teams = this.teamService.list(new QueryWrapper().lambda().eq(ZtTeam::getType, "execution") @@ -1091,8 +1074,8 @@ public class ZtProjectServiceImpl extends ServiceImpl userList = this.userService.list(); Map uMap = userList.stream().collect(Collectors.toMap(ZtUser::getAccount, O -> O)); - for (ZtTask t:list ) { - if(t.getDeadline()!=null){ + for (ZtTask t : list) { + if (t.getDeadline() != null) { t.setDeadline(DateUtils.getDayLast(t.getDeadline())); } ZtUser ztUser = uMap.get(t.getAssignedTo()); @@ -1100,51 +1083,50 @@ public class ZtProjectServiceImpl extends ServiceImpl> l=new ArrayList<>(); - for (String s:accountIds) { + for (int i = 0; i < DateUtils.getDays(date); i++) { + Date d = DateUtils.dateAddDay(firstDayOfMonth, i); + List> l = new ArrayList<>(); + for (String s : accountIds) { ZtUser ztUser = uMap.get(s); // List fList = efforts.stream().filter(o -> o.getAccount().equals(s)) // .filter(o->DateUtils.formatDate(o.getDate()).equals(DateUtils.formatDate(d))) // .collect(Collectors.toList()); List taskList = list.stream().filter(o -> o.getEstStarted() != null && DateUtils.formatDate(o.getEstStarted()).equals(DateUtils.formatDate(d))) - .filter(o->o.getAssignedTo().equals(ztUser.getAccount())) + .filter(o -> o.getAssignedTo().equals(ztUser.getAccount())) .collect(Collectors.toList()); - - Map m=new HashMap<>(); - if(!CollectionUtils.isEmpty(taskList)){ - m.put("name",ztUser.getNickname()); + Map m = new HashMap<>(); + if (!CollectionUtils.isEmpty(taskList)) { + m.put("name", ztUser.getNickname()); //分配 - m.put("allocation",taskList.stream().map(o->o.getEstimate()).mapToDouble(e -> Double.valueOf(e)).sum()+""); + m.put("allocation", BigDecimal.valueOf(taskList.stream().map(o -> o.getEstimate()).mapToDouble(e -> Double.valueOf(e)).sum()).setScale(2, BigDecimal.ROUND_HALF_UP)); - m.put("task",taskList); - }else{ - m.put("name",ztUser.getNickname()); + m.put("task", taskList); + } else { + m.put("name", ztUser.getNickname()); //分配 - m.put("allocation",""); + m.put("allocation", ""); - m.put("task",""); + m.put("task", ""); } //使用 // double sum = fList.stream().mapToDouble(o -> o.getConsumed()).sum(); @@ -1156,41 +1138,9 @@ public class ZtProjectServiceImpl extends ServiceImpl effortList = this.effortService -// .list(new QueryWrapper().lambda().in(ZtEffort::getExecution, execList.stream().map(o -> o.getExecution()).collect(Collectors.toList())) -// .gt(ZtEffort::getDate, startDate).lt(ZtEffort::getDate, endDate)); -// if(CollectionUtils.isEmpty(effortList)){ -// return new ArrayList<>(); -// } -// List> result=new ArrayList<>(); -// -// for (String account:accountIds){ -// Map m=new HashMap<>(); -// List fList = effortList.stream().filter(o -> o.getAccount().equals(account)).collect(Collectors.toList()); -// if(CollectionUtils.isEmpty(fList)){ -// m.put(account,0+""); -// }else{ -// double sum = fList.stream().mapToDouble(o -> o.getConsumed()).sum(); -// m.put(account,sum+""); -// } -// result.add(m); -// } -// return result; } @Override @@ -1203,7 +1153,7 @@ public class ZtProjectServiceImpl extends ServiceImpl().lambda().eq(ZtTask::getExecution, ztProject.getId())); - if(count>0&&dto.getStatus().equals("wait")){ + if (count > 0 && dto.getStatus().equals("wait")) { throw new BusinessException("当前已开始无法更改"); } ztProject.setStatus( @@ -1231,14 +1181,14 @@ public class ZtProjectServiceImpl extends ServiceImpl integers = execAuthList(); - if(CollectionUtils.isEmpty(integers)){ + if (CollectionUtils.isEmpty(integers)) { return new ArrayList<>(); } List sprint = this.list( - new QueryWrapper().lambda().in(ZtProject::getId,integers).ne(ZtProject::getStatus,"closed") - ); + new QueryWrapper().lambda().in(ZtProject::getId, integers).ne(ZtProject::getStatus, "closed") + ); - if(CollectionUtils.isEmpty(sprint)){ + if (CollectionUtils.isEmpty(sprint)) { return new ArrayList<>(); } List ztProjectDTOS = BeanCopyUtil.copyListProperties(sprint, ZtProjectDTO::new); @@ -1251,18 +1201,18 @@ public class ZtProjectServiceImpl extends ServiceImpl execution = this.teamService.list(new QueryWrapper().lambda().eq(ZtTeam::getRoot, ztProject.getId()).eq(ZtTeam::getType, "execution")); - if(CollectionUtils.isEmpty(execution)){ + if (CollectionUtils.isEmpty(execution)) { objectZtProjectDTO.setTeamList(new ArrayList<>()); - }else{ - objectZtProjectDTO.setTeamList(execution.stream().map(o->o.getAccount()).collect(Collectors.toList())); + } else { + objectZtProjectDTO.setTeamList(execution.stream().map(o -> o.getAccount()).collect(Collectors.toList())); } List list = this.executionprojectService.list(new QueryWrapper().lambda().eq(ZtExecutionproject::getExecution, objectZtProjectDTO.getId())); - objectZtProjectDTO.setProjectList(list.stream().map(o->o.getProject()).collect(Collectors.toList())); + objectZtProjectDTO.setProjectList(list.stream().map(o -> o.getProject()).collect(Collectors.toList())); return objectZtProjectDTO; } @@ -1287,7 +1237,7 @@ public class ZtProjectServiceImpl extends ServiceImpl list = this.executionprojectService.list(new QueryWrapper().lambda() .eq(ZtExecutionproject::getProject, project)); - if(CollectionUtils.isEmpty(list)){ + if (CollectionUtils.isEmpty(list)) { return new ArrayList<>(); } List ids = list.stream().map(o -> o.getExecution()).collect(Collectors.toList()); @@ -1298,7 +1248,7 @@ public class ZtProjectServiceImpl extends ServiceImpl execList) { + public void removeExecutionStory(Integer storyId, List execList) { List list = projectstoryService.list(new QueryWrapper().lambda() .eq(ZtProjectstory::getType, ProjectTypeEnums.execution.getValue()) @@ -1307,13 +1257,13 @@ public class ZtProjectServiceImpl extends ServiceImpl().lambda() - .eq(ZtProjectstory::getStory,storyId).eq(ZtProjectstory::getProject,d.getProject())); + .eq(ZtProjectstory::getStory, storyId).eq(ZtProjectstory::getProject, d.getProject())); //删除看板 - this.kanbanlaneService.removeExecutionStory(d.getProject(),storyId); + this.kanbanlaneService.removeExecutionStory(d.getProject(), storyId); } } @@ -1327,12 +1277,12 @@ public class ZtProjectServiceImpl extends ServiceImpl performanceCount(Date startDate, Date endDate) { - return this.baseMapper.performanceCount(startDate,endDate); + return this.baseMapper.performanceCount(startDate, endDate); } @Override public ZtProjectDTO projectProductByExecution(String execution) { - if(StringUtils.isEmpty(execution)){ + if (StringUtils.isEmpty(execution)) { return null; } ZtExecutionproject executionproject = this.executionprojectService.getOne(new QueryWrapper().lambda() @@ -1346,7 +1296,7 @@ public class ZtProjectServiceImpl extends ServiceImpl> execWorkCount(ZtProjectQo qo) { +// Map>> map = new HashMap<>(); + + Date date = qo.getDate()==null?new Date():qo.getDate(); + + Date firstDayOfMonth = DateUtils.getDayStartDate(qo.getStartDate()==null?DateUtils.getMonthStartDate(date):qo.getStartDate()); + Date lastDayOfMonth = new Date(DateUtils.getDayEndDate(qo.getEndDate()==null?DateUtils.getMonthEndDate(date):qo.getEndDate()).getTime() + 1000 * 2); + //产品集 + String execution = qo.getExecution(); + + + List list = this.taskService.list(new QueryWrapper().lambda() + .gt(ZtTask::getOpeneddate, firstDayOfMonth) + .lt(ZtTask::getOpeneddate, lastDayOfMonth) + .eq(ZtTask::getExecution, execution)); + + if (CollectionUtils.isEmpty(list)) { + return new ArrayList<>(); + } + List effList = this.effortService.list(new QueryWrapper().lambda() + .in(ZtEffort::getObjectid, list.stream().map(o -> o.getId()).collect(Collectors.toList()))); + + List teams = this.teamService.list(new QueryWrapper().lambda().eq(ZtTeam::getType, "execution") + .eq(ZtTeam::getRoot, execution)); + + List accountIds = teams.stream().map(o -> o.getAccount()).distinct().collect(Collectors.toList()); + if (CollectionUtils.isEmpty(accountIds)) { + return new ArrayList<>(); + } + + + List uList = this.userService.list(new QueryWrapper().lambda().in(ZtUser::getAccount, accountIds).orderByDesc(ZtUser::getUserType)); + + + Map uMap = this.userService.userMapByIdsOrderByType(null); + if (CollectionUtils.isEmpty(uMap.values())) { + return new ArrayList<>(); + } + + + return workBuildResult(firstDayOfMonth,lastDayOfMonth, uList,list,effList,uMap); + } + + + + List> workBuildResult(Date firstDayOfMonth,Date lastDayOfMonth,List uList,List list,List effList,Map uMap){ + for (ZtTask t : list) { + if (t.getDeadline() != null) { + t.setDeadline(DateUtils.getDayLast(t.getDeadline())); + } + ZtUser ztUser = uMap.get(t.getAssignedTo()); + if(ztUser!=null){ + t.setAssignedToAccount(t.getAssignedTo()); + t.setAssignedToName(ztUser.getNickname()); +// t.setAssignedTo(ztUser.getNickname()); + } + ztUser = uMap.get(t.getOpenedby()); + if (ztUser != null) { + t.setOpenedbyAccount(t.getOpenedby()); + t.setOpenedby(ztUser.getNickname()); + t.setOpenedbyName(ztUser.getNickname()); + } + ztUser = uMap.get(t.getFinishedby()); + if (ztUser != null) { + t.setFinishedby(ztUser.getNickname()); + } + ztUser = uMap.get(t.getCanceledby()); + if (ztUser != null) { + t.setCanceledby(ztUser.getNickname()); + } + ztUser = uMap.get(t.getClosedby()); + if (ztUser != null) { + t.setClosedby(ztUser.getNickname()); + } + } + + List> result = new ArrayList<>(); + + + List userList =orderByUserype(uList); + + + //打卡数据 + Map> dkMap= getDkMap(uList,firstDayOfMonth,lastDayOfMonth); + + + + for (ZtUser ztUser : userList) { + List itApprovals = this.taskService.itApprovalByUserName(ztUser.getNickname(), DateUtils.getDayStartDate(firstDayOfMonth), DateUtils.getDayEndDate(lastDayOfMonth)); + + Map m = new HashMap<>(); + m.put("name", ztUser.getNickname()); + List dkInfos = dkMap.get(ztUser.getAccount()); + for (int i = 0; i < DateUtils.daysBetween(firstDayOfMonth,lastDayOfMonth); i++) { + Date d = DateUtils.dateAddDay(firstDayOfMonth, i); + List taskList = list.stream().filter(o -> o.getEstStarted() != null && DateUtils.formatDate(o.getEstStarted()).equals(DateUtils.formatDate(d))) + .filter(o -> o.getAssignedTo().equals(ztUser.getAccount())) + .collect(Collectors.toList()); + +// //假期 +// String s = Constant.vacationDateMap.get(DateUtils.formatDate(d, "yyyy-MM-dd")); +// //补班 +// s = Constant.vacationDateMap.get(DateUtils.formatDate(d, "yyyy-MM-dd")); +// //假期 +// s = Constant.legalRepairDateMap.get(DateUtils.formatDate(d, "yyyy-MM-dd")); + JSONObject obj=new JSONObject(); + boolean work = DateUtils.isWork(d); + if(CollectionUtils.isEmpty(dkInfos)){ + obj.put("workCount","0"); + }else{ + List dayDkList = dkInfos.stream().filter(o -> DateUtils.formatDate(d).equals(o.getDateStr())).collect(Collectors.toList()); + if(CollectionUtils.isEmpty(dayDkList)){ + obj.put("workCount","0"); + }else{ + DkInfo dkInfo = dayDkList.get(0); + Date endDate = dkInfo.getEndDate(); + Date startDate = dkInfo.getStartDate(); + BigDecimal workcount = (endDate.getTime() - startDate.getTime()) < 1000?BigDecimal.ZERO:BigDecimal.valueOf((endDate.getTime() - startDate.getTime()) / 1000).divide(BigDecimal.valueOf(60),2,BigDecimal.ROUND_HALF_UP).divide(BigDecimal.valueOf(60), 2, BigDecimal.ROUND_HALF_UP); + Integer fTime = Integer.valueOf(DateUtils.formatDate(startDate, "HHmmss")); + if(workcount.floatValue()>0){ + if(fTime>130000){ + //大于下午一点点 + }else{ + workcount=workcount.subtract(BigDecimal.valueOf(1)); + } + } + obj.put("workCount",workcount.floatValue()); + } + } + if(work){ + obj.put("work","班"); + }else{ + obj.put("work","假"); + } + //如果请假 + List fitApprovals=itApprovals.stream().filter(o->o.getName().equals(ztUser.getNickname())).filter(o->( + o.getApplyTimeStart().getTime() >=DateUtils.getDayStartDate(d).getTime() && o.getApplyTimeStart().getTime() <=DateUtils.getDayEndDate(d).getTime() ) + || + (o.getApplyTimeEnd().getTime() >=DateUtils.getDayStartDate(d).getTime() && o.getApplyTimeEnd().getTime() <=DateUtils.getDayEndDate(d).getTime() ) + ).collect(Collectors.toList()); + if(!CollectionUtils.isEmpty(fitApprovals)){ + obj.put("leave","1"); + }else{ + obj.put("leave","0"); + } + if (!CollectionUtils.isEmpty(taskList)) { + //分配 + obj.put("allocation",BigDecimal.valueOf(taskList.stream() + .map(o -> o.getEstimate()).mapToDouble(e -> Double.valueOf(e)) + .sum()).setScale(2, BigDecimal.ROUND_HALF_UP)); + obj.put("selfAllocation",BigDecimal.valueOf(taskList.stream() + .filter(o->o.getOpenedbyAccount().equals(o.getAssignedToAccount())) + .map(o -> o.getUseTime()).mapToDouble(e -> e==null?0:e.floatValue()) + .sum()).setScale(2, BigDecimal.ROUND_HALF_UP)); + obj.put("task",taskList); + if(CollectionUtils.isEmpty(taskList)){ + obj.put("consume",0); + }else{ + List efforts = effList.stream().filter(o->DateUtils.formatDate(o.getDate()).equals(DateUtils.formatDate(d))).filter(o -> "task".equals(o.getObjecttype())).filter(o -> taskList.stream().map(x -> x.getId()).collect(Collectors.toList()).contains(o.getObjectid())).collect(Collectors.toList()); + if(!CollectionUtils.isEmpty(efforts)){ + obj.put("consume",floatBatchAdd(efforts.stream().map(o->o.getConsumed()).collect(Collectors.toList())) ); + }else { + obj.put("consume",0); + } + } + m.put(DateUtils.formatDate(d,"dd").toString(),obj); + } else { + //分配 + obj.put("consume",""); + obj.put("allocation",""); + obj.put("task",new ArrayList<>()); + m.put(DateUtils.formatDate(d,"dd").toString(),obj); + } + } + + result.add(m); + } + return result; + } + + private List orderByUserype(List uList) { + List userList =new ArrayList<>(); + userList.addAll(uList.stream().filter(o->o.getUserType()==UserType.KFZ).collect(Collectors.toList())); + userList.addAll(uList.stream().filter(o->o.getUserType()==UserType.CS).collect(Collectors.toList())); + userList.addAll(uList.stream().filter(o->o.getUserType()==UserType.XMGLY).collect(Collectors.toList())); + userList.addAll(uList.stream().filter(o->o.getUserType()==UserType.GSGC).collect(Collectors.toList())); + return userList; + } + + private Map> getDkMap(List uList, Date firstDayOfMonth, Date lastDayOfMonth) { + List dkInfos = this.userService.dkList(uList.stream().map(o -> o.getAccount()).collect(Collectors.toList()), firstDayOfMonth, lastDayOfMonth); + Map> dkMap=new HashMap<>(); + if(!CollectionUtils.isEmpty(dkInfos)){ + dkMap=dkInfos.stream().collect(Collectors.groupingBy(DkInfo::getAccount)); + } + return dkMap; + } + + @Override + public PageInfo< Map> pageDaysTimeWorkCount(ZtProjectQo qo) { + qo.setPageSize(1000); + Map>> map = new HashMap<>(); + + Date date = qo.getDate()==null?new Date():qo.getDate(); + + Date firstDayOfMonth = DateUtils.getDayStartDate(qo.getStartDate()==null?DateUtils.getMonthStartDate(date):qo.getStartDate()); + Date lastDayOfMonth = new Date(DateUtils.getDayEndDate(qo.getEndDate()==null?DateUtils.getMonthEndDate(date):qo.getEndDate()).getTime() + 1000 * 2); + //产品集 + Integer project = qo.getProject(); + + //产品 + List products = this.productService.list(new QueryWrapper().lambda().eq(ZtProduct::getProgram, project)); + if (CollectionUtils.isEmpty(products)) { + return new PageInfo<>(); + } + //项目列表 + List projectList = this.projectproductService.list(new QueryWrapper().lambda() + .in(ZtProjectproduct::getProduct, products.stream().map(o -> o.getId()).collect(Collectors.toList()))); + if (CollectionUtils.isEmpty(projectList)) { + return new PageInfo<>(); + } + + List execList = this.executionprojectService.list(new QueryWrapper().lambda() + .in(ZtExecutionproject::getProject, projectList.stream().map(o -> o.getProject()).collect(Collectors.toList()))); + if (CollectionUtils.isEmpty(execList)) { + return new PageInfo<>(); + } + + + List list = this.taskService.list(new QueryWrapper().lambda() + .gt(ZtTask::getOpeneddate, firstDayOfMonth) + .lt(ZtTask::getOpeneddate, lastDayOfMonth) + .in(ZtTask::getExecution, execList.stream().map(o -> o.getExecution()) + .collect(Collectors.toList()))); + + if (CollectionUtils.isEmpty(list)) { + return new PageInfo<>(); + } + List effList = this.effortService.list(new QueryWrapper().lambda() + .in(ZtEffort::getObjectid, list.stream().map(o -> o.getId()).collect(Collectors.toList()))); +// 时间 T1 T2 +// 任务 T3 T4 + List ztProjects = this.listByIds(execList.stream().map(o -> o.getExecution()).collect(Collectors.toList())); +// ztProjects=ztProjects.stream().filter(o-> +// ( firstDayOfMonth .getTime()>=o.getBegin().getTime() &&lastDayOfMonth.getTime()>o.getEnd().getTime())|| +// ( firstDayOfMonth .getTime()<=o.getBegin().getTime() &&lastDayOfMonth.getTime()>=o.getEnd().getTime())|| +// ( firstDayOfMonth .getTime()<=o.getBegin().getTime() &&lastDayOfMonth.getTime()<=o.getEnd().getTime()) +// ).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(ztProjects)) { + return new PageInfo<>(); + } + + List teams = this.teamService.list(new QueryWrapper().lambda().eq(ZtTeam::getType, "execution") + .in(ZtTeam::getRoot, ztProjects.stream().map(o -> o.getId()).collect(Collectors.toList()))); + + List accountIds = teams.stream().map(o -> o.getAccount()).distinct().collect(Collectors.toList()); + if (CollectionUtils.isEmpty(accountIds)) { + return new PageInfo<>(); + } + Page page = PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize()); + + + List uList = this.userService.list(new QueryWrapper().lambda().in(ZtUser::getAccount, accountIds).orderByDesc(ZtUser::getUserType)); + + + Map uMap = this.userService.userMapByIdsOrderByType(null); + if (CollectionUtils.isEmpty(uMap.values())) { + return new PageInfo<>(); + } + + + + return new PageInfo< Map>(workBuildResult(firstDayOfMonth,lastDayOfMonth, uList,list,effList,uMap)); + } + + @Override + public PageInfo pageMonthReport(ZtProjectQo qo) { + qo.setPageSize(10000); + Map>> map = new HashMap<>(); + + Date date = qo.getDate()==null?new Date():qo.getDate(); + + Date firstDayOfMonth = DateUtils.getFirstDayOfMonth(date); + Date lastDayOfMonth = new Date(DateUtils.getLastDayOfMonth(date).getTime() + 1000 * 2); + //产品集 + Integer project = qo.getProject(); + List products =null; + if(project==null||project==0){ + List productIds = authProductList(); + products=this.productService.listByIds(productIds); + }else{ + //产品 + products = this.productService.list(new QueryWrapper().lambda().eq(ZtProduct::getProgram, project)); + } + + if (CollectionUtils.isEmpty(products)) { + return new PageInfo<>(); + } + //项目列表 + List projectList = this.projectproductService.list(new QueryWrapper().lambda() + .in(ZtProjectproduct::getProduct, products.stream().map(o -> o.getId()).collect(Collectors.toList()))); + if (CollectionUtils.isEmpty(projectList)) { + return new PageInfo<>(); + } + + List execList = this.executionprojectService.list(new QueryWrapper().lambda() + .in(ZtExecutionproject::getProject, projectList.stream().map(o -> o.getProject()).collect(Collectors.toList()))); + if (CollectionUtils.isEmpty(execList)) { + return new PageInfo<>(); + } + + + List list = this.taskService.list(new QueryWrapper().lambda() + .between(ZtTask::getEstStarted, firstDayOfMonth, lastDayOfMonth) + .in(ZtTask::getExecution, execList.stream().map(o -> o.getExecution()) + .collect(Collectors.toList()))); + if (CollectionUtils.isEmpty(list)) { + return new PageInfo<>(); + } + //工时 + List efforts = this.effortService.list(new QueryWrapper().lambda() + .eq(ZtEffort::getObjecttype, "task") + .in(ZtEffort::getObjectid, list.stream().map(o -> o.getId()).collect(Collectors.toList())) + .gt(ZtEffort::getDate, new Date(firstDayOfMonth.getTime() - 2000)).lt(ZtEffort::getDate, lastDayOfMonth) + ); + + + if (CollectionUtils.isEmpty(execList)) { + return new PageInfo<>(); + } +// 时间 T1 T2 +// 任务 T3 T4 + List ztProjects = this.listByIds(execList.stream().map(o -> o.getExecution()).collect(Collectors.toList())); + if (CollectionUtils.isEmpty(ztProjects)) { + return new PageInfo<>(); + } + + List teams = this.teamService.list(new QueryWrapper().lambda().eq(ZtTeam::getType, "execution") + .in(ZtTeam::getRoot, ztProjects.stream().map(o -> o.getId()).collect(Collectors.toList()))); + + List accountIds = teams.stream().map(o -> o.getAccount()).distinct().collect(Collectors.toList()); + if (CollectionUtils.isEmpty(accountIds)) { + return new PageInfo<>(); + } + Page page = PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize()); + + Map uMap = this.userService.userMapByIds(null); + if (CollectionUtils.isEmpty(uMap.values())) { + return new PageInfo<>(); + } + + List result =new ArrayList(); + + + for (String account :accountIds) { + + List taskList = list.stream().filter(o->account.equals(o.getAssignedTo())) + .filter(o -> + ( + o.getFinishedDate()!=null + && (o.getFinishedDate().getTime() >= firstDayOfMonth.getTime() + && o.getFinishedDate().getTime() <= lastDayOfMonth.getTime())) + || + (o.getEstStarted()!=null&&o.getDeadline()!=null)&& + (( o.getDeadline().getTime()<=lastDayOfMonth.getTime()&& o.getDeadline().getTime()>=firstDayOfMonth.getTime()) + || + ( o.getEstStarted().getTime()<=lastDayOfMonth.getTime()&& o.getEstStarted().getTime()>=firstDayOfMonth.getTime())) + ).filter(o->o.getStatus().equals("done")) + .collect(Collectors.toList()); + + var d=new WorkDetailsDTO(); + ZtUser ztUser = uMap.get(account); + d.setUserName(ztUser.getNickname()); + //需求总工时 + d.setStoryTotalTime(floatToBigDecimal(floatBatchAdd(taskList.stream().map(o -> o.getEstimate()).collect(Collectors.toList())))); + //实际产出工时 + d.setWorkTime(floatToBigDecimal(floatBatchAdd(taskList.stream().map(o -> o.getConsumed()).collect(Collectors.toList())))); + //可用工时 + d.setHaveTime(BigDecimal.valueOf(DateUtils.getWorkDaysInCurrentMonth(date) * 6)); + //工作饱和度 + d.setSaturation(d.getWorkTime().compareTo(BigDecimal.ZERO)==0?BigDecimal.ZERO:d.getWorkTime().divide(d.getHaveTime(),2,BigDecimal.ROUND_HALF_UP)); + // 任务总量 + List taskCountList = list.stream().filter(o->account.equals(o.getAssignedTo())) + .filter(o -> + ( o.getFinishedDate()!=null&& (o.getFinishedDate().getTime() >= firstDayOfMonth.getTime() + && o.getFinishedDate().getTime() <= lastDayOfMonth.getTime())) + || + (o.getEstStarted()!=null&&o.getDeadline()!=null)&& + (( DateUtils.getDayLast(o.getDeadline()).getTime()<=lastDayOfMonth.getTime()&& DateUtils.getDayLast(o.getDeadline()).getTime()>=firstDayOfMonth.getTime()) + || + ( o.getEstStarted().getTime()<=lastDayOfMonth.getTime()&& o.getEstStarted().getTime()>=firstDayOfMonth.getTime())) + ).filter(o->!o.getStatus().equals("closed")) + .collect(Collectors.toList()); + d.setTaskCount(BigDecimal.valueOf(taskCountList.size())); + + List delayList = list.stream().filter(o->account.equals(o.getAssignedTo())) + .filter(o -> + ( o.getFinishedDate()!=null&& (o.getFinishedDate().getTime() >= firstDayOfMonth.getTime() + && o.getFinishedDate().getTime() <= lastDayOfMonth.getTime())) + || + (o.getEstStarted()!=null&&o.getDeadline()!=null)&& + (( o.getDeadline().getTime()<=lastDayOfMonth.getTime()&& o.getDeadline().getTime()>=firstDayOfMonth.getTime()) + || + ( o.getEstStarted().getTime()<=lastDayOfMonth.getTime()&& o.getEstStarted().getTime()>=firstDayOfMonth.getTime())) + ) + .filter(o-> + ((o.getFinishedDate()!=null &&DateUtils.getDayLast(o.getFinishedDate()).getTime()>DateUtils.getDayLast(o.getDeadline()).getTime()) ) //实际完成大于预计完成 延期 + ||o.getFinishedDate()==null &&lastDayOfMonth.getTime()>DateUtils.getDayLast(o.getDeadline()).getTime() + ) + .filter(o->!o.getStatus().equals("closed")) + .collect(Collectors.toList()); + //任务延期量 + d.setTaskDelayCount(BigDecimal.valueOf(delayList.size())); + //任务及时完成率 + d.setTaskFinishOnTimeRate(delayList.size()==0?BigDecimal.valueOf(100):BigDecimal.valueOf(100).subtract(BigDecimal.valueOf(delayList.size()).divide(d.getTaskCount(),2,BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100)))); + + List bugList = this.bugService.list(new QueryWrapper().lambda().in(ZtBug::getProduct, products.stream().map(o -> o.getId()).collect(Collectors.toList())) + .between(ZtBug::getOpenedby, firstDayOfMonth, lastDayOfMonth).eq(ZtBug::getResolvedby, account)); + + d.setBugCount(BigDecimal.valueOf(bugList.size())); + result.add(d); + } + + + + + return new PageInfo(result); + } + + //修改项目集 @Override @Transactional public void modifyProgram(ZtProjectDTO dto) { ZtProject ztProject = this.baseMapper.selectById(dto); - BeanUtils.copyProperties(dto,ztProject); - if(ztProject.getParent()==null||ztProject.getParent()==0){ - ztProject.setPath(String.format(",%d,",ztProject.getId())); + BeanUtils.copyProperties(dto, ztProject); + if (ztProject.getParent() == null || ztProject.getParent() == 0) { + ztProject.setPath(String.format(",%d,", ztProject.getId())); ztProject.setGrade(1); ztProject.setLeft(0f); ztProject.setConsumed(0f); ztProject.setOrder(0); ztProject.setParent(0); - }else{ + } else { ZtProject pProject = this.baseMapper.selectById(ztProject.getParent()); - ztProject.setPath(pProject.getPath()+""+String.format("%d,",ztProject.getId())); - ztProject.setGrade(pProject.getGrade()+1); + ztProject.setPath(pProject.getPath() + "" + String.format("%d,", ztProject.getId())); + ztProject.setGrade(pProject.getGrade() + 1); ztProject.setLeft(2f); ztProject.setConsumed(4f); - ztProject.setOrder(pProject.getOrder()+5); + ztProject.setOrder(pProject.getOrder() + 5); } - if(!CollectionUtils.isEmpty(dto.getAuthList())){ - ztProject.setWhitelist(","+StringUtils.join(dto.getAuthList(),",")); + if (!CollectionUtils.isEmpty(dto.getAuthList())) { + ztProject.setWhitelist("," + StringUtils.join(dto.getAuthList(), ",")); } this.baseMapper.updateById(ztProject); - actionService.addAction(ActionType.XMJ,ActionStatus.BJ,ztProject.getId(),null,null,ztProject.getId(),RiskUserThreadLocal.get().getName(),null,null); + actionService.addAction(ActionType.XMJ, ActionStatus.BJ, ztProject.getId(), null, null, ztProject.getId(), RiskUserThreadLocal.get().getName(), null, null); } @@ -1395,58 +1776,57 @@ public class ZtProjectServiceImpl extends ServiceImpl().lambda().eq(ZtProjectproduct::getProject,dto.getId())); + this.projectproductService.remove(new QueryWrapper().lambda().eq(ZtProjectproduct::getProject, dto.getId())); - if(!CollectionUtils.isEmpty(dto.getProductIds())){ - for (Integer i:(List)dto.getProductIds()) { - ZtProjectproduct p=new ZtProjectproduct(); + if (!CollectionUtils.isEmpty(dto.getProductIds())) { + for (Integer i : (List) dto.getProductIds()) { + ZtProjectproduct p = new ZtProjectproduct(); p.setProject(ztProject.getId()); p.setProduct(i); projectproductService.save(p); } } - if(!CollectionUtils.isEmpty(dto.getAuthList())){ - ztProject.setWhitelist(","+StringUtils.join(dto.getAuthList(),",")); + if (!CollectionUtils.isEmpty(dto.getAuthList())) { + ztProject.setWhitelist("," + StringUtils.join(dto.getAuthList(), ",")); } this.baseMapper.updateById(ztProject); - actionService.addAction(ActionType.XM,ActionStatus.BJ,ztProject.getId(),null,null,ztProject.getId(),RiskUserThreadLocal.get().getName(),null,null); + actionService.addAction(ActionType.XM, ActionStatus.BJ, ztProject.getId(), null, null, ztProject.getId(), RiskUserThreadLocal.get().getName(), null, null); } - @Override public List parentList(ZtProjectDTO dto) { List pIds = authList(); List ztProjects = this.baseMapper.selectList(new QueryWrapper().lambda() - .eq(ZtProject::getType,"program") - .eq(ZtProject::getDeleted,"0") - .in(ZtProject::getId,pIds) + .eq(ZtProject::getType, "program") + .eq(ZtProject::getDeleted, "0") + .in(ZtProject::getId, pIds) ); - if(CollectionUtils.isEmpty(ztProjects)){ + if (CollectionUtils.isEmpty(ztProjects)) { return new ArrayList<>(); - }else{ - return BeanCopyUtil.copyListProperties(ztProjects,ZtProjectDTO::new); + } else { + return BeanCopyUtil.copyListProperties(ztProjects, ZtProjectDTO::new); } } @@ -1454,37 +1834,36 @@ public class ZtProjectServiceImpl extends ServiceImpl groupPageList(ZtProjectQo qo) { qo.setProductIds(authList()); - if(CollectionUtils.isEmpty(qo.getProductIds())){ + if (CollectionUtils.isEmpty(qo.getProductIds())) { return new PageInfo(); } Page page = PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize()); - if(CollectionUtils.isEmpty(qo.getProductIds())){ + if (CollectionUtils.isEmpty(qo.getProductIds())) { return new PageInfo(); } List result = this.baseMapper.groupPageList(qo); - if(!CollectionUtils.isEmpty(result)){ + if (!CollectionUtils.isEmpty(result)) { Map userMap = this.userService.userMapByIds(null); - Map> m= getChildrenMap(result,qo); + Map> m = getChildrenMap(result, qo); - - for (ZtProjectDTO d:result) { - if(!StringUtils.isEmpty(d.getPm())){ + for (ZtProjectDTO d : result) { + if (!StringUtils.isEmpty(d.getPm())) { ZtUser ztUser = userMap.get(d.getPm()); - if(ztUser!=null){ + if (ztUser != null) { d.setPoValue(ztUser.getNickname()); } } - d.setChildren( getChild(d.getId(),m)); - if(!CollectionUtils.isEmpty(d.getChildren())){ + d.setChildren(getChild(d.getId(), m)); + if (!CollectionUtils.isEmpty(d.getChildren())) { // d.setHasChildren(true); } } @@ -1492,17 +1871,18 @@ public class ZtProjectServiceImpl extends ServiceImpl(result); } - List getChild(Integer id,Map> m){ + + List getChild(Integer id, Map> m) { List ztProjectDTOS = m.get(id); - if(CollectionUtils.isEmpty(ztProjectDTOS)){ + if (CollectionUtils.isEmpty(ztProjectDTOS)) { return new ArrayList(); } - for (ZtProjectDTO d:ztProjectDTOS) { + for (ZtProjectDTO d : ztProjectDTOS) { List ztProjectDTOS1 = m.get(d.getId()); - if(CollectionUtils.isEmpty(ztProjectDTOS1)){ + if (CollectionUtils.isEmpty(ztProjectDTOS1)) { continue; - }else { - d.setChildren(getChild(d.getId(),m)); + } else { + d.setChildren(getChild(d.getId(), m)); // d.setHasChildren(true); } } @@ -1514,51 +1894,50 @@ public class ZtProjectServiceImpl extends ServiceImpl implementPageList(ZtProjectQo qo) { List pIds = execAuthList(); - if(CollectionUtils.isEmpty(pIds)){ + if (CollectionUtils.isEmpty(pIds)) { return new PageInfo(); } qo.setProjectIds(pIds); Page page = PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize()); - if(!"admin".equals(RiskUserThreadLocal.get().getName())){ + if (!"admin".equals(RiskUserThreadLocal.get().getName())) { qo.setUserName(RiskUserThreadLocal.get().getName()); } List result = this.baseMapper.implementPageList(qo); - if(!CollectionUtils.isEmpty(result)){ + if (!CollectionUtils.isEmpty(result)) { Map userMap = this.userService.userMapByIds(null); List list = executionprojectService.list(new QueryWrapper().lambda() .in(ZtExecutionproject:: - getExecution, result.stream().map(o -> o.getId()).collect(Collectors.toList()) - )); - Map> projectMap =null; - if(CollectionUtils.isEmpty(list)){ - projectMap=new HashMap<>(); - }else{ - projectMap=getProjectMapByExec(list,this.baseMapper + getExecution, result.stream().map(o -> o.getId()).collect(Collectors.toList()) + )); + Map> projectMap = null; + if (CollectionUtils.isEmpty(list)) { + projectMap = new HashMap<>(); + } else { + projectMap = getProjectMapByExec(list, this.baseMapper .selectBatchIds(list.stream().map(o -> o.getProject()).collect(Collectors.toList()))); } Map> ztProjectproductMap = getZtProjectproductMap(result); - Map> taskMap= execTaskMap(result); + Map> taskMap = execTaskMap(result); - - for (ZtProjectDTO d:result ) { + for (ZtProjectDTO d : result) { List ztProjects = projectMap.get(d.getId()); - if(!CollectionUtils.isEmpty(ztProjects)){ - d.setProjectName(StringUtils.join(ztProjects.stream().map(o->o.getName()).collect(Collectors.toList()), ",")); + if (!CollectionUtils.isEmpty(ztProjects)) { + d.setProjectName(StringUtils.join(ztProjects.stream().map(o -> o.getName()).collect(Collectors.toList()), ",")); } List ztProjectproducts = ztProjectproductMap.get(d.getId()); - if(!CollectionUtils.isEmpty(ztProjectproducts)){ - d.setProductIds(ztProjectproducts.stream().map(o->o.getProject()).collect(Collectors.toList())); + if (!CollectionUtils.isEmpty(ztProjectproducts)) { + d.setProductIds(ztProjectproducts.stream().map(o -> o.getProject()).collect(Collectors.toList())); } List tasks = taskMap.get(d.getId()); - if(!CollectionUtils.isEmpty(tasks)){ + if (!CollectionUtils.isEmpty(tasks)) { List leftList = tasks.stream().map(o -> o.getLeft()).collect(Collectors.toList()); List consumedList = tasks.stream().map(o -> o.getConsumed()).collect(Collectors.toList()); List planList = tasks.stream().map(o -> o.getEstimate()).collect(Collectors.toList()); @@ -1569,7 +1948,88 @@ public class ZtProjectServiceImpl extends ServiceImpl(result); + } + + @Override + public PageInfo myProgressImplementPageList(ZtProjectQo qo) { + List pIds = execAuthList(); + if (CollectionUtils.isEmpty(pIds)) { + return new PageInfo(); + } + + List doingImplements = this.baseMapper.selectList(new QueryWrapper().lambda().eq(ZtProject::getStatus, "doing").in(ZtProject::getId, pIds)); + if(CollectionUtils.isEmpty(doingImplements)){ + return new PageInfo(); + } + + List teamImplements = this.teamService.list(new QueryWrapper().lambda().eq(ZtTeam::getAccount, RiskUserThreadLocal.get().getName()) + .in(ZtTeam::getRoot,doingImplements.stream().map(o->o.getId()).collect(Collectors.toList())) + .eq(ZtTeam::getType, "execution").groupBy(ZtTeam::getRoot)); + if(CollectionUtils.isEmpty(teamImplements)){ + return new PageInfo(); + } + + + qo.setProjectIds(teamImplements.stream().map(o->o.getRoot()).collect(Collectors.toList())); + Page page = PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize()); + if (!"admin".equals(RiskUserThreadLocal.get().getName())) { + qo.setUserName(RiskUserThreadLocal.get().getName()); + } + + + + List result = this.baseMapper.implementPageList(qo); + if (!CollectionUtils.isEmpty(result)) { + + Map userMap = this.userService.userMapByIds(null); + + List list = executionprojectService.list(new QueryWrapper().lambda() + .in(ZtExecutionproject:: + getExecution, result.stream().map(o -> o.getId()).collect(Collectors.toList()) + )); + Map> projectMap = null; + if (CollectionUtils.isEmpty(list)) { + projectMap = new HashMap<>(); + } else { + projectMap = getProjectMapByExec(list, this.baseMapper + .selectBatchIds(list.stream().map(o -> o.getProject()).collect(Collectors.toList()))); + } + + Map> ztProjectproductMap = getZtProjectproductMap(result); + + + Map> taskMap = execTaskMap(result); + + + for (ZtProjectDTO d : result) { + List ztProjects = projectMap.get(d.getId()); + if (!CollectionUtils.isEmpty(ztProjects)) { + d.setProjectName(StringUtils.join(ztProjects.stream().map(o -> o.getName()).collect(Collectors.toList()), ",")); + } + + List ztProjectproducts = ztProjectproductMap.get(d.getId()); + if (!CollectionUtils.isEmpty(ztProjectproducts)) { + d.setProductIds(ztProjectproducts.stream().map(o -> o.getProject()).collect(Collectors.toList())); + } + List tasks = taskMap.get(d.getId()); + if (!CollectionUtils.isEmpty(tasks)) { + List leftList = tasks.stream().map(o -> o.getLeft()).collect(Collectors.toList()); + List consumedList = tasks.stream().map(o -> o.getConsumed()).collect(Collectors.toList()); + List planList = tasks.stream().map(o -> o.getEstimate()).collect(Collectors.toList()); + + + d.setLeft(floatBatchAdd(leftList)); + d.setPlan(floatBatchAdd(planList)); + d.setConsumed(floatBatchAdd(consumedList)); + } + ZtUser ztUser = userMap.get(d.getPm()); + if (ztUser != null) { d.setPoValue(ztUser.getNickname()); } } @@ -1580,7 +2040,7 @@ public class ZtProjectServiceImpl extends ServiceImpl> execTaskMap(List result) { List list = this.taskService.list(new QueryWrapper().lambda().in(ZtTask::getExecution, result.stream().map(o -> o.getId()).collect(Collectors.toList()))); - if(CollectionUtils.isEmpty(list)){ + if (CollectionUtils.isEmpty(list)) { return new HashMap<>(); } return list.stream().collect(Collectors.groupingBy(ZtTask::getExecution)); @@ -1590,41 +2050,41 @@ public class ZtProjectServiceImpl extends ServiceImpl pageProject(ZtProjectQo qo) { List pIds = projectAuthList(); - if(CollectionUtils.isEmpty(pIds)){ + if (CollectionUtils.isEmpty(pIds)) { return new PageInfo<>(); } qo.setProjectIds(pIds); Page page = PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize()); List result = this.baseMapper.pageProject(qo); - if(!CollectionUtils.isEmpty(result)){ + if (!CollectionUtils.isEmpty(result)) { - Map> p =getZtProjectproductMap(result); - List ids=new ArrayList(); - for (List item:p.values()) { - ids.addAll(item.stream().map(o->o.getProduct()).collect(Collectors.toList())); + Map> p = getZtProjectproductMap(result); + List ids = new ArrayList(); + for (List item : p.values()) { + ids.addAll(item.stream().map(o -> o.getProduct()).collect(Collectors.toList())); } - List listProduct =new ArrayList<>(); - if(!CollectionUtils.isEmpty(ids)){ - listProduct=productService.listByIds(ids); + List listProduct = new ArrayList<>(); + if (!CollectionUtils.isEmpty(ids)) { + listProduct = productService.listByIds(ids); } Map pMap = listProduct.stream().collect(Collectors.toMap(ZtProduct::getId, o -> o)); Map userMap = this.userService.userMapByIds(null); - for (ZtProjectDTO d:result) { + for (ZtProjectDTO d : result) { String pm = d.getPm(); ZtUser ztUser = userMap.get(pm); - if(ztUser!=null){ + if (ztUser != null) { d.setPoValue(ztUser.getNickname()); } List ppList = p.get(d.getId()); - if(!CollectionUtils.isEmpty(ppList)){ + if (!CollectionUtils.isEmpty(ppList)) { ZtProjectproduct ztProjectproduct = ppList.get(0); d.setProductId(ztProjectproduct.getProduct()); ZtProduct ztProduct = pMap.get(ztProjectproduct.getProduct()); - if(ztProduct!=null){ + if (ztProduct != null) { d.setProductName(ztProduct.getName()); } } @@ -1642,10 +2102,10 @@ public class ZtProjectServiceImpl extends ServiceImpl> getZtProjectproductMap(List result) { List list = this.projectproductService.list(new QueryWrapper() .lambda().in(ZtProjectproduct::getProject, result.stream().map(o -> o.getId()).collect(Collectors.toList()))); - if(CollectionUtils.isEmpty(list)){ + if (CollectionUtils.isEmpty(list)) { return new HashMap<>(); - }else{ - return list.stream().collect(Collectors.groupingBy(ZtProjectproduct::getProject)); + } else { + return list.stream().collect(Collectors.groupingBy(ZtProjectproduct::getProject)); } } @@ -1655,100 +2115,100 @@ public class ZtProjectServiceImpl extends ServiceImpl lambda = new QueryWrapper().lambda(); + lambda.eq(ZtProject::getType, "program"); + lambda.eq(ZtProject::getDeleted, "0"); - lambda.eq(ZtProject::getType,"program"); - lambda.eq(ZtProject::getDeleted,"0"); - - if(dto.getExcludeId()!=null){ + if (dto.getExcludeId() != null) { List program = this.baseMapper.selectList(new QueryWrapper().lambda() .eq(ZtProject::getDeleted, "0").eq(ZtProject::getType, "program")); - if(CollectionUtils.isEmpty(program)){ + if (CollectionUtils.isEmpty(program)) { return new ArrayList<>(); } Map> map = program.stream().collect(Collectors.groupingBy(ZtProject::getParent)); - List ids=new ArrayList<>(); + List ids = new ArrayList<>(); ids.add(dto.getExcludeId()); - ids=programChildListIds(ids,map,dto.getExcludeId()); + ids = programChildListIds(ids, map, dto.getExcludeId()); - lambda.notIn(ZtProject::getId,ids); + lambda.notIn(ZtProject::getId, ids); } List ztProjects = this.baseMapper.selectList( lambda ); - if(CollectionUtils.isEmpty(ztProjects)){ + if (CollectionUtils.isEmpty(ztProjects)) { return new ArrayList<>(); } - List result=new ArrayList(); - Map map = getProjectMap(ztProjects); - for (ZtProject p:ztProjects) { + List result = new ArrayList(); + Map map = getProjectMap(ztProjects); + for (ZtProject p : ztProjects) { ZtProjectDTO ztProjectDTO = new ZtProjectDTO(); - BeanUtils.copyProperties(p,ztProjectDTO); + BeanUtils.copyProperties(p, ztProjectDTO); List split = Arrays.asList(ztProjectDTO.getPath().split(",")); - split=split.stream().filter(o-> !StringUtils.isEmpty(o)).filter(o->!p.getId().toString().equalsIgnoreCase(o)).collect(Collectors.toList()); - if(!CollectionUtils.isEmpty(split)){ + split = split.stream().filter(o -> !StringUtils.isEmpty(o)).filter(o -> !p.getId().toString().equalsIgnoreCase(o)).collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(split)) { String name = ztProjectDTO.getName(); ztProjectDTO.setName(""); - for (String s:split) { + for (String s : split) { ZtProject ztProject = map.get(Integer.valueOf(s)); - if(ztProject!=null){ - ztProjectDTO.setName(ztProjectDTO.getName()+"/"+ztProject.getName()); + if (ztProject != null) { + ztProjectDTO.setName(ztProjectDTO.getName() + "/" + ztProject.getName()); } } - ztProjectDTO.setName(ztProjectDTO.getName()+"/"+name); + ztProjectDTO.setName(ztProjectDTO.getName() + "/" + name); } result.add(ztProjectDTO); } return result; } + @Override public List authTreeParentList(ZtProjectDTO dto) { LambdaQueryWrapper lambda = new QueryWrapper().lambda(); - lambda.eq(ZtProject::getGrade,"1"); - lambda.eq(ZtProject::getType,"program"); - lambda.eq(ZtProject::getDeleted,"0"); + lambda.eq(ZtProject::getGrade, "1"); + lambda.eq(ZtProject::getType, "program"); + lambda.eq(ZtProject::getDeleted, "0"); - if(dto.getExcludeId()!=null){ + if (dto.getExcludeId() != null) { List program = this.baseMapper.selectList(new QueryWrapper().lambda() .eq(ZtProject::getDeleted, "0").eq(ZtProject::getType, "program")); - if(CollectionUtils.isEmpty(program)){ + if (CollectionUtils.isEmpty(program)) { return new ArrayList<>(); } Map> map = program.stream().collect(Collectors.groupingBy(ZtProject::getParent)); - List ids=new ArrayList<>(); + List ids = new ArrayList<>(); ids.add(dto.getExcludeId()); - ids=programChildListIds(ids,map,dto.getExcludeId()); + ids = programChildListIds(ids, map, dto.getExcludeId()); - lambda.notIn(ZtProject::getId,ids); + lambda.notIn(ZtProject::getId, ids); } List ztProjects = this.baseMapper.selectList( lambda ); - if(CollectionUtils.isEmpty(ztProjects)){ + if (CollectionUtils.isEmpty(ztProjects)) { return new ArrayList<>(); } - return BeanCopyUtil.copyListProperties(ztProjects,ZtProjectDTO::new); + return BeanCopyUtil.copyListProperties(ztProjects, ZtProjectDTO::new); } - private List programChildListIds(List list, Map> map,Integer id){ + private List programChildListIds(List list, Map> map, Integer id) { List ztProjects = map.get(id); - if(CollectionUtils.isEmpty(ztProjects)){ + if (CollectionUtils.isEmpty(ztProjects)) { return list; } - for (ZtProject i:ztProjects) { + for (ZtProject i : ztProjects) { list.add(i.getId()); List ztProjects1 = map.get(i.getId()); - if(CollectionUtils.isEmpty(ztProjects1)){ + if (CollectionUtils.isEmpty(ztProjects1)) { continue; - }else{ - for (ZtProject p:ztProjects1) { + } else { + for (ZtProject p : ztProjects1) { list.add(p.getId()); - programChildListIds(list,map,p.getId()); + programChildListIds(list, map, p.getId()); } } @@ -1760,33 +2220,41 @@ public class ZtProjectServiceImpl extends ServiceImpl typeProductList(ZtProjectQo qo) { - LambdaQueryWrapper eq = new QueryWrapper().lambda() - .eq(ZtProject::getType, "project") - .eq(ZtProject::getDeleted, "0"); +// LambdaQueryWrapper eq = new QueryWrapper().lambda() +// .eq(ZtProject::getType, "project") +// .eq(ZtProject::getDeleted, "0"); +// +// if (qo.getStatus() != null) { +// eq.eq(ZtProject::getStatus, qo.getStatus()); +// } +// +// List project = this.baseMapper.selectList( +// eq +// ); +// +// +// +// if (CollectionUtils.isEmpty(project)) { +// return new ArrayList<>(); +// } +// +// List listAuth = project.stream().map(o -> o.getPath()).collect(Collectors.toList()); +// List ids = new ArrayList<>(); +// for (String str : listAuth) { +// ids.add(Integer.valueOf(Arrays.asList(str.split(",")).stream().filter(o -> !StringUtils.isEmpty(o)).collect(Collectors.toList()).get(0))); +// } - if(qo.getStatus()!=null){ - eq.eq(ZtProject::getStatus,qo.getStatus()); - } + List authList = projectAuthList(); + List pList = this.baseMapper.selectList( + new QueryWrapper().lambda().in(ZtProject::getId, authList).eq(ZtProject::getDeleted,"0").ne(ZtProject::getStatus, "closed")); - List project = this.baseMapper.selectList( - eq - ); - if(CollectionUtils.isEmpty(project)){ - return new ArrayList<>(); - } - List listAuth = project.stream().map(o -> o.getPath()).collect(Collectors.toList()); - List ids =new ArrayList<>(); - for (String str:listAuth) { - ids.add(Integer.valueOf(Arrays.asList(str.split(",")).stream().filter(o->!StringUtils.isEmpty(o)).collect(Collectors.toList()).get(0))); - } - Map projectMap = getProjectMap(this.baseMapper.selectList( - new QueryWrapper().lambda().in(ZtProject::getId,ids).ne(ZtProject::getStatus,"closed"))); - List ztProjectDTOS = BeanCopyUtil.copyListProperties(project, ZtProjectDTO::new); - for (ZtProjectDTO p:ztProjectDTOS ) { + Map projectMap = getProjectMap(pList); + List ztProjectDTOS = BeanCopyUtil.copyListProperties(pList, ZtProjectDTO::new); + for (ZtProjectDTO p : ztProjectDTOS) { ZtProject ztProject = projectMap.get(Integer.valueOf(Arrays.asList(p.getPath().split(",")).stream().filter(o -> !StringUtils.isEmpty(o)).collect(Collectors.toList()).get(0))); - if(ztProject.getId().intValue()!=p.getId().intValue()){ - p.setName(ztProject.getName()+"/"+p.getName()); + if (ztProject.getId().intValue() != p.getId().intValue()) { + p.setName(ztProject.getName() + "/" + p.getName()); } } @@ -1795,37 +2263,36 @@ public class ZtProjectServiceImpl extends ServiceImpl getProjectMap(List ztProjects) { - if(CollectionUtils.isEmpty(ztProjects)){ + if (CollectionUtils.isEmpty(ztProjects)) { return new HashMap<>(); } - return ztProjects.stream().collect(Collectors.toMap(ZtProject::getId,o->o)); + return ztProjects.stream().collect(Collectors.toMap(ZtProject::getId, o -> o)); } - private Map> getProjectMapByExec(List list,List ztProjects) { - if(CollectionUtils.isEmpty(ztProjects)){ + private Map> getProjectMapByExec(List list, List ztProjects) { + if (CollectionUtils.isEmpty(ztProjects)) { return new HashMap<>(); } - Map> result=new HashMap<>(); - for (ZtExecutionproject e:list) { + Map> result = new HashMap<>(); + for (ZtExecutionproject e : list) { List collect = list.stream().filter(o -> o.getExecution().intValue() == e.getExecution()).collect(Collectors.toList()); - if(CollectionUtils.isEmpty(collect)){ + if (CollectionUtils.isEmpty(collect)) { continue; } List list1 = collect.stream().map(o -> o.getProject().intValue()).collect(Collectors.toList()); - result.put(e.getExecution(),ztProjects.stream().filter(o->list1.contains(o.getId())).collect(Collectors.toList())); + result.put(e.getExecution(), ztProjects.stream().filter(o -> list1.contains(o.getId())).collect(Collectors.toList())); } return result; } - private Map> getChildrenMap(List result,ZtProjectQo qo) { + private Map> getChildrenMap(List result, ZtProjectQo qo) { List ztProjects = this.baseMapper.selectList( - new QueryWrapper().lambda().eq(ZtProject::getDeleted,"0") - .eq(ZtProject::getType,"program").ne(ZtProject::getParent,0) + new QueryWrapper().lambda().eq(ZtProject::getDeleted, "0") + .eq(ZtProject::getType, "program").ne(ZtProject::getParent, 0) ); - if(CollectionUtils.isEmpty(ztProjects)){ + if (CollectionUtils.isEmpty(ztProjects)) { return new HashMap<>(); } List ztProjectDTOS = BeanCopyUtil.copyListProperties(ztProjects, ZtProjectDTO::new); @@ -1833,11 +2300,20 @@ public class ZtProjectServiceImpl extends ServiceImpl list){ - BigDecimal f=BigDecimal.ZERO; - for (Float i:list ) { - f=f.add(BigDecimal.valueOf(i)); + BigDecimal floatToBigDecimal(Float f){ + if(f==null){ + return BigDecimal.ZERO; } + BigDecimal decimal = BigDecimal.valueOf(f); + return decimal.setScale(2,BigDecimal.ROUND_HALF_UP); + } + + private Float floatBatchAdd(List list) { + BigDecimal f = BigDecimal.ZERO; + for (Float i : list) { + f = f.add(BigDecimal.valueOf(i)); + } + f = f.setScale(1, BigDecimal.ROUND_HALF_UP); return f.floatValue(); } diff --git a/src/main/java/com/sa/zentao/service/impl/ZtReleaseServiceImpl.java b/src/main/java/com/sa/zentao/service/impl/ZtReleaseServiceImpl.java index a3640c9..eef9cb6 100644 --- a/src/main/java/com/sa/zentao/service/impl/ZtReleaseServiceImpl.java +++ b/src/main/java/com/sa/zentao/service/impl/ZtReleaseServiceImpl.java @@ -63,6 +63,7 @@ public class ZtReleaseServiceImpl extends ServiceImpl releaseStoryList = this.releaseDetailsService.list(new QueryWrapper().lambda() + .ne(ZtReleaseDetails::getStatus,"closed") .in(ZtReleaseDetails::getObjectId, sList.stream().map(o -> o.getId()).collect(Collectors.toList()))); List sIds = releaseStoryList.stream().map(o -> o.getObjectId().intValue()).collect(Collectors.toList()); @@ -116,7 +118,12 @@ public class ZtReleaseServiceImpl extends ServiceImpl details = this.releaseDetailsService.list(new QueryWrapper().lambda().eq(ZtReleaseDetails::getReleaseId, ztRelease.getId()).eq(ZtReleaseDetails::getObjectType, "story")); + List details = this.releaseDetailsService.list(new QueryWrapper().lambda().eq(ZtReleaseDetails::getReleaseId, ztRelease.getId()).ne(ZtReleaseDetails::getStatus,"closed").eq(ZtReleaseDetails::getObjectType, "story")); List storyList=new ArrayList(); for (ZtReleaseDetails d:details ) { diff --git a/src/main/java/com/sa/zentao/service/impl/ZtStoryFeedbackServiceImpl.java b/src/main/java/com/sa/zentao/service/impl/ZtStoryFeedbackServiceImpl.java index a383e6e..3bbcbe1 100644 --- a/src/main/java/com/sa/zentao/service/impl/ZtStoryFeedbackServiceImpl.java +++ b/src/main/java/com/sa/zentao/service/impl/ZtStoryFeedbackServiceImpl.java @@ -112,7 +112,8 @@ public class ZtStoryFeedbackServiceImpl extends ServiceImpl impl BeanUtils.copyProperties(dto, ztStory,"stage"); if("draft".equalsIgnoreCase(ztStory.getStatus())){ - ztStory.setStatus("reviewing"); + ztStory.setStatus("active"); if (ztStory.getProduct() != null&&ztStory.getProduct()!=0) { ZtProduct product = productService.getById(ztStory.getProduct()); product.setDraftStories(product.getDraftStories() - 1); - product.setReviewingStories(product.getReviewingStories() + 1); + product.setActiveStories(product.getReviewingStories() + 1); this.productService.updateById(product); } } @@ -423,7 +423,10 @@ public class ZtStoryServiceImpl extends ServiceImpl impl spec.setSpec(dto.getSpec()); spec.setVerify(dto.getVerify()); spec.setFiles(dto.getFileUrl()); - storyspecService.update(new UpdateWrapper().lambda().eq(ZtStoryspec::getStory,id).set(ZtStoryspec::getFiles,dto.getFileUrl()) + storyspecService.update(new UpdateWrapper().lambda().eq(ZtStoryspec::getStory,id) + .set(ZtStoryspec::getSpec,dto.getSpec()) + .set(ZtStoryspec::getVerify,dto.getVerify()) + .set(ZtStoryspec::getFiles,dto.getFileUrl()) ); } @@ -779,6 +782,7 @@ public class ZtStoryServiceImpl extends ServiceImpl impl } LambdaQueryWrapper lambda = new QueryWrapper().lambda(); lambda.eq(ZtStory::getStatus, "active"); + lambda.notIn(ZtStory::getStage,"released","verified"); lambda.in(ZtStory::getId,resultIds); List ztStories = this.baseMapper.selectList(lambda); if (CollectionUtils.isEmpty(ztStories)) { @@ -917,6 +921,9 @@ public class ZtStoryServiceImpl extends ServiceImpl impl } ztStory.setStage("developed"); + if(ztStory.getStartDate()==null){ + ztStory.setStartDate(new Date()); + } this.baseMapper.updateById(ztStory); List executionId = this.getExecutionId(ztStory); for (Integer execution:executionId ) { @@ -974,6 +981,10 @@ public class ZtStoryServiceImpl extends ServiceImpl impl actionService.addAction(ActionType.XQ, ActionStatus.CSWC, ztStory.getId(), ztStory.getProduct() + "", ztStory.getProject(), null, RiskUserThreadLocal.get().getName(), null, ""); } + if(ztStory.getStartDate()==null){ + ztStory.setStartDate(new Date()); + } + ztStory.setEndDate(new Date()); this.baseMapper.updateById(ztStory); for (Integer execId : execIds) { @@ -1037,6 +1048,9 @@ public class ZtStoryServiceImpl extends ServiceImpl impl String newStatus ="released"; ztStory.setStage(newStatus); + if(ztStory.getEndDate()==null){ + ztStory.setEndDate(new Date()); + } this.baseMapper.updateById(ztStory); for (Integer execId : execIds) { @@ -1095,6 +1109,9 @@ public class ZtStoryServiceImpl extends ServiceImpl impl actionService.addAction(ActionType.XQ, ActionStatus.KSCE, ztStory.getId(), ztStory.getProduct() + "", ztStory.getProject(), null, RiskUserThreadLocal.get().getName(), null, ""); } + if(ztStory.getStartDate()==null){ + ztStory.setStartDate(new Date()); + } this.baseMapper.updateById(ztStory); for (Integer execId : execIds) { @@ -1604,9 +1621,6 @@ public class ZtStoryServiceImpl extends ServiceImpl impl } - List userIds = new ArrayList<>(); - userIds.add(ztStory.getAssignedTo()); - userIds.add(ztStory.getOpenedby()); Map userMap = this.userService.userMapByIds(null); diff --git a/src/main/java/com/sa/zentao/service/impl/ZtStoryUserServiceImpl.java b/src/main/java/com/sa/zentao/service/impl/ZtStoryUserServiceImpl.java index a176463..1854e89 100644 --- a/src/main/java/com/sa/zentao/service/impl/ZtStoryUserServiceImpl.java +++ b/src/main/java/com/sa/zentao/service/impl/ZtStoryUserServiceImpl.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import com.sa.zentao.conf.LoginRiskUser; import com.sa.zentao.conf.RiskUserThreadLocal; import com.sa.zentao.dao.*; import com.sa.zentao.entity.*; @@ -427,6 +428,24 @@ public class ZtStoryUserServiceImpl extends ServiceImpl released = this.storyService.list(new QueryWrapper().lambda() + .eq(ZtStory::getProduct, dto.getProductId()) + .eq(ZtStory::getYsUser, loginRiskUser.getName()) + .eq(ZtStory::getStage, "released") + ); + + + + return released; + } + private Map> getStoryUserMap(List list) { List ids = list.stream().map(o -> o.getId()).collect(Collectors.toList()); diff --git a/src/main/java/com/sa/zentao/service/impl/ZtTaskServiceImpl.java b/src/main/java/com/sa/zentao/service/impl/ZtTaskServiceImpl.java index 3ec660d..760dc1a 100644 --- a/src/main/java/com/sa/zentao/service/impl/ZtTaskServiceImpl.java +++ b/src/main/java/com/sa/zentao/service/impl/ZtTaskServiceImpl.java @@ -31,7 +31,7 @@ import java.util.stream.Collectors; /** *

- * 服务实现类 + * 服务实现类 *

* * @author gqb @@ -75,22 +75,22 @@ public class ZtTaskServiceImpl extends ServiceImpl impleme Page page = PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize()); qo.setUserName(RiskUserThreadLocal.get().getName()); List list = this.baseMapper.taskPageList(qo); - if(!CollectionUtils.isEmpty(list)){ + if (!CollectionUtils.isEmpty(list)) { List userIds = list.stream().map(o -> o.getFinishedby()).collect(Collectors.toList()); userIds.addAll(list.stream().map(o -> o.getAssignedTo()).collect(Collectors.toList())); Map userMap = this.userService.userMapByIds(null); - for (ZtTaskDTO task:list) { + for (ZtTaskDTO task : list) { ZtUser ztUser = userMap.get(task.getFinishedby()); - if(ztUser!=null){ + if (ztUser != null) { task.setFinishedbyName(ztUser.getNickname()); } ztUser = userMap.get(task.getAssignedTo()); - if(ztUser!=null){ + if (ztUser != null) { task.setAssignedToName(ztUser.getNickname()); } - if(task.getDeadline()!=null){ + if (task.getDeadline() != null) { task.setDeadline(DateUtils.getDayLast(task.getDeadline())); } } @@ -103,7 +103,7 @@ public class ZtTaskServiceImpl extends ServiceImpl impleme public void assignedTo(ZtTaskDTO dto) { ZtTask ztTask = this.baseMapper.selectById(dto.getId()); - if(ztTask==null){ + if (ztTask == null) { throw new BusinessException("未查询到数据"); } ztTask.setAssignedTo(dto.getAssignedTo()); @@ -115,9 +115,9 @@ public class ZtTaskServiceImpl extends ServiceImpl impleme ZtProjectproduct projectproduct = projectproductService.getOne(new QueryWrapper().lambda().eq(ZtProjectproduct::getProject, ztTask.getProject())); - actionService.addAction(ActionType.RW, ActionStatus.FP,ztTask.getId() - ,projectproduct==null?null:projectproduct.getProduct().toString(),projectproduct==null?null:projectproduct.getProject(),ztTask.getExecution(), - RiskUserThreadLocal.get().getName(),null,dto.getAssignedTo()); + actionService.addAction(ActionType.RW, ActionStatus.FP, ztTask.getId() + , projectproduct == null ? null : projectproduct.getProduct().toString(), projectproduct == null ? null : projectproduct.getProject(), ztTask.getExecution(), + RiskUserThreadLocal.get().getName(), null, dto.getAssignedTo()); } @Override @@ -125,22 +125,22 @@ public class ZtTaskServiceImpl extends ServiceImpl impleme public void batchApproval(ZtTaskDTO dto) { List idList = dto.getIdList(); - if(CollectionUtils.isEmpty(idList)){ + if (CollectionUtils.isEmpty(idList)) { throw new BusinessException("请检查"); } List ztTasks = this.listByIds(idList); List reviewingList = ztTasks.stream().filter(o -> !"reviewing".equals(o.getStatus())).collect(Collectors.toList()); - if(!CollectionUtils.isEmpty(reviewingList)){ - throw new BusinessException(reviewingList.get(0).getName()+"当前状态无法评审"); + if (!CollectionUtils.isEmpty(reviewingList)) { + throw new BusinessException(reviewingList.get(0).getName() + "当前状态无法评审"); } List tList = reviewingList.stream().filter(o -> !RiskUserThreadLocal.get().getName().equals(o.getReviewingUser())).collect(Collectors.toList()); - if(!CollectionUtils.isEmpty(tList)){ - throw new BusinessException(tList.get(0).getName()+"当前评审人错误"); + if (!CollectionUtils.isEmpty(tList)) { + throw new BusinessException(tList.get(0).getName() + "当前评审人错误"); } - for (ZtTask t:ztTasks) { - if(dto.getApprovalStatus()==1){ + for (ZtTask t : ztTasks) { + if (dto.getApprovalStatus() == 1) { t.setStatus("wait"); - }else{ + } else { t.setStatus("closed"); } @@ -153,12 +153,12 @@ public class ZtTaskServiceImpl extends ServiceImpl impleme ZtProjectproduct projectproduct = projectproductService.getOne(new QueryWrapper().lambda().eq(ZtProjectproduct::getProject, t.getProject())); - if(dto.getApprovalStatus()==1){ - actionService.addAction(ActionType.RW, ActionStatus.PSTG,t.getId(),projectproduct==null?null:projectproduct.getProduct().toString(),projectproduct==null?null:projectproduct.getProject(),t.getExecution(), - RiskUserThreadLocal.get().getName(),dto.getApprovalRemark(),null); - }else if(dto.getApprovalStatus()==2){ - actionService.addAction(ActionType.RW, ActionStatus.PSBTG,t.getId(),projectproduct==null?null:projectproduct.getProduct().toString(),projectproduct==null?null:projectproduct.getProject(),t.getExecution(), - RiskUserThreadLocal.get().getName(),dto.getApprovalRemark(),null); + if (dto.getApprovalStatus() == 1) { + actionService.addAction(ActionType.RW, ActionStatus.PSTG, t.getId(), projectproduct == null ? null : projectproduct.getProduct().toString(), projectproduct == null ? null : projectproduct.getProject(), t.getExecution(), + RiskUserThreadLocal.get().getName(), dto.getApprovalRemark(), null); + } else if (dto.getApprovalStatus() == 2) { + actionService.addAction(ActionType.RW, ActionStatus.PSBTG, t.getId(), projectproduct == null ? null : projectproduct.getProduct().toString(), projectproduct == null ? null : projectproduct.getProject(), t.getExecution(), + RiskUserThreadLocal.get().getName(), dto.getApprovalRemark(), null); } } } @@ -171,58 +171,57 @@ public class ZtTaskServiceImpl extends ServiceImpl impleme .orderByDesc(ZtTask::getDeadline) .orderByDesc(ZtTask::getId) ); - if(CollectionUtils.isEmpty(closed)){ + if (CollectionUtils.isEmpty(closed)) { return new ArrayList<>(); } - return BeanCopyUtil.copyListProperties(closed,ZtTaskDTO::new); + return BeanCopyUtil.copyListProperties(closed, ZtTaskDTO::new); } - @Override public void addRemark(ZtTaskDTO dto) { ZtTask task = this.baseMapper.selectById(dto.getId()); - Integer productId=null; - Integer projectId=null; - Integer execution=null; - if(task.getStory()!=null&&task.getStory()!=0){ + Integer productId = null; + Integer projectId = null; + Integer execution = null; + if (task.getStory() != null && task.getStory() != 0) { - execution=task.getExecution(); - projectId=task.getProject(); - if(task.getStory()!=null&&task.getStory()!=0){ + execution = task.getExecution(); + projectId = task.getProject(); + if (task.getStory() != null && task.getStory() != 0) { ZtStory story = this.storyService.getById(task.getStory()); - if(story!=null){ - productId=story.getProduct(); + if (story != null) { + productId = story.getProduct(); } } } - actionService.addAction(ActionType.RW, ActionStatus.TJBZ, dto.getId(), productId==null?"":productId+"", projectId, task.getExecution(), + actionService.addAction(ActionType.RW, ActionStatus.TJBZ, dto.getId(), productId == null ? "" : productId + "", projectId, task.getExecution(), RiskUserThreadLocal.get().getName(), dto.getRemark(), ""); } @Override public ZtTaskDTO getTaskById(Integer id) { ZtTask ztTask = this.baseMapper.selectById(id); - if(ztTask==null){ + if (ztTask == null) { throw new BusinessException("未查询到数据"); } Map userMap = this.userService.userMapByIds(null); - ZtTaskDTO dto=new ZtTaskDTO(); - BeanUtils.copyProperties(ztTask,dto); - if(ztTask.getExecution()!=null&&ztTask.getExecution()!=0){ + ZtTaskDTO dto = new ZtTaskDTO(); + BeanUtils.copyProperties(ztTask, dto); + if (ztTask.getExecution() != null && ztTask.getExecution() != 0) { ZtProject project = this.ztProjectService.getById(ztTask.getExecution()); dto.setImplementId(project.getId()); dto.setImplementName(project.getName()); } - if(dto.getDeadline()!=null){ + if (dto.getDeadline() != null) { dto.setDeadline(DateUtils.getDayLast(ztTask.getDeadline())); } ZtUser ztUser = userMap.get(ztTask.getAssignedTo()); - if(ztUser!=null){ + if (ztUser != null) { dto.setAssignedToName(ztUser.getNickname()); } @@ -234,6 +233,11 @@ public class ZtTaskServiceImpl extends ServiceImpl impleme return this.baseMapper.taskListPrd(id); } + @Override + public List itApprovalByUserName(String s, Date firstDayOfMonth, Date lastDayOfMonth) { + return this.baseMapper.itApprovalByUserName(s, firstDayOfMonth, lastDayOfMonth); + } + @Override public PageInfo myTaskPageList(ZtProjectQo qo) { @@ -241,67 +245,66 @@ public class ZtTaskServiceImpl extends ServiceImpl impleme qo.setUserName(RiskUserThreadLocal.get().getName()); LoginRiskUser loginRiskUser = RiskUserThreadLocal.get(); //执行ids - List projectAuthList=new ArrayList<>(); - if(UserType.GSGC!=loginRiskUser.getUserType()){ + List projectAuthList = new ArrayList<>(); - //自己有权限的 产品集 - List integers = this.ztProjectService.authList(); + //自己有权限的 产品集 + List authList = this.ztProjectService.authList(); - if(!CollectionUtils.isEmpty(integers)){ - List pList = this.productService.list(new QueryWrapper().lambda().in(ZtProduct::getProgram, integers)); - //所有的产品 - if(!CollectionUtils.isEmpty(pList)){ - List list = this.projectproductService.list(new QueryWrapper().lambda().in(ZtProjectproduct::getProduct, pList.stream().map(o -> o.getId()).collect(Collectors.toList()))); + if (!CollectionUtils.isEmpty(authList)) { + List pList = this.productService.list(new QueryWrapper().lambda().in(ZtProduct::getProgram, authList)); + //所有的产品 + if (!CollectionUtils.isEmpty(pList)) { + List list = this.projectproductService.list(new QueryWrapper().lambda().in(ZtProjectproduct::getProduct, pList.stream().map(o -> o.getId()).collect(Collectors.toList()))); - if(!CollectionUtils.isEmpty(list)){ - List projectList = executionprojectService.list(new QueryWrapper().lambda().in(ZtExecutionproject::getProject, list.stream().map(o -> o.getProject()).collect(Collectors.toList()))); - projectAuthList=projectList.stream().map(o->o.getExecution()).collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(list)) { + List projectList = executionprojectService.list(new QueryWrapper().lambda().in(ZtExecutionproject::getProject, list.stream().map(o -> o.getProject()).collect(Collectors.toList()))); + projectAuthList = projectList.stream().map(o -> o.getExecution()).collect(Collectors.toList()); - } } } } - if(UserType.GSGC!=loginRiskUser.getUserType()&&CollectionUtils.isEmpty(projectAuthList)){ + + if (CollectionUtils.isEmpty(projectAuthList)) { return new PageInfo(); } Page page = PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize()); qo.setProjectIds(projectAuthList); - if(!StringUtils.isEmpty(qo.getIds())){ + if (!StringUtils.isEmpty(qo.getIds())) { String[] split = qo.getIds().split(","); qo.setObjIds(new ArrayList<>(Arrays.asList(split))); } - if(!StringUtils.isEmpty(qo.getProductName())){ + if (!StringUtils.isEmpty(qo.getProductName())) { List pList = this.productService.selectProductByName(qo.getProductName()); - if(!CollectionUtils.isEmpty(pList)){ + if (!CollectionUtils.isEmpty(pList)) { List list = this.projectproductService.list(new QueryWrapper() .lambda().in(ZtProjectproduct::getProduct, pList.stream().map(o -> o.getId()).collect(Collectors.toList()))); - if(CollectionUtils.isEmpty(list)){ + if (CollectionUtils.isEmpty(list)) { return new PageInfo<>(); - }else{ - qo.setProjectList(list.stream().map(o->o.getProject()).collect(Collectors.toList())); + } else { + qo.setProjectList(list.stream().map(o -> o.getProject()).collect(Collectors.toList())); } } } List list = this.baseMapper.taskPageList(qo); - if(!CollectionUtils.isEmpty(list)){ + if (!CollectionUtils.isEmpty(list)) { List userIds = list.stream().map(o -> o.getFinishedby()).collect(Collectors.toList()); userIds.addAll(list.stream().map(o -> o.getAssignedTo()).collect(Collectors.toList())); Map userMap = this.userService.userMapByIds(null); - for (ZtTaskDTO task:list) { + for (ZtTaskDTO task : list) { ZtUser ztUser = userMap.get(task.getFinishedby()); - if(ztUser!=null){ + if (ztUser != null) { task.setFinishedbyName(ztUser.getNickname()); } ztUser = userMap.get(task.getAssignedTo()); - if(ztUser!=null){ + if (ztUser != null) { task.setAssignedToName(ztUser.getNickname()); } - if(task.getDeadline()!=null){ + if (task.getDeadline() != null) { task.setDeadline(DateUtils.getDayLast(task.getDeadline())); } @@ -312,7 +315,6 @@ public class ZtTaskServiceImpl extends ServiceImpl impleme } - @Autowired private IZtProjectstoryService projectstoryService; @@ -323,33 +325,30 @@ public class ZtTaskServiceImpl extends ServiceImpl impleme @Transactional public void addTask(ZtTaskDTO dto) { ZtTask ztTask = new ZtTask(); - BeanUtils.copyProperties(dto,ztTask); + BeanUtils.copyProperties(dto, ztTask); ztTask.setOpenedby(RiskUserThreadLocal.get().getName()); ztTask.setOpeneddate(new Date()); ztTask.setEstimate(dto.getLeft()); - - - //getExecution()执行 //项目 Integer story = ztTask.getStory(); - if(story!=null&&story!=0){ + if (story != null && story != 0) { ZtStory ztStory = this.storyService.getById(story); - ztStory.setTaskCount(ztStory.getTaskCount()+1); + ztStory.setTaskCount(ztStory.getTaskCount() + 1); this.storyService.updateById(ztStory); List list = projectstoryService.list(new QueryWrapper().lambda().eq(ZtProjectstory::getStory, story) - .ne(ZtProjectstory::getProject,0) + .ne(ZtProjectstory::getProject, 0) ); - if(!CollectionUtils.isEmpty(list)){ + if (!CollectionUtils.isEmpty(list)) { ztTask.setProject(list.get(0).getProject()); - }else{ + } else { List execList = this.executionprojectService.list(new QueryWrapper().lambda().eq(ZtExecutionproject::getExecution, ztTask.getExecution())); ztTask.setProject(execList.get(0).getExecution()); } - }else{ + } else { Integer execution = dto.getExecution(); //迭代 ZtExecutionproject executionproject = this.executionprojectService.getOne(new QueryWrapper().lambda().eq(ZtExecutionproject::getExecution, execution)); @@ -362,103 +361,161 @@ public class ZtTaskServiceImpl extends ServiceImpl impleme } //如果是开发人员 需要评审 UserType userType = RiskUserThreadLocal.get().getUserType(); - if(userType==UserType.KFZ){ - ZtProject ztProject = this.ztProjectService.getById(ztTask.getExecution()); - ztTask.setStatus("reviewing"); - ztTask.setReviewingUser(ztProject.getPm()); - }else{ - ztTask.setStatus("wait"); - ztTask.setReviewingUser(null); + + if (dto.getDraftFlag() != null && dto.getDraftFlag() == 1) { + ztTask.setStatus("draft"); + } else { + if (userType == UserType.KFZ) { + ZtProject ztProject = this.ztProjectService.getById(ztTask.getExecution()); + ztTask.setStatus("reviewing"); + ztTask.setReviewingUser(ztProject.getPm()); + } else { + ztTask.setStatus("wait"); + ztTask.setReviewingUser(null); + } } - - if(ztTask.getDeadline()!=null){ - ztTask.setDeadlineTime(ztTask.getDeadline().getTime()/1000); + if (ztTask.getDeadline() != null) { + ztTask.setDeadlineTime(ztTask.getDeadline().getTime() / 1000); } Integer project = ztTask.getProject(); ZtProjectproduct ztProjectproduct = this.projectproductService.getOne(new QueryWrapper().lambda() .eq(ZtProjectproduct::getProject, project)); - if(ztProjectproduct!=null){ + if (ztProjectproduct != null) { ztTask.setProduct(ztProjectproduct.getProduct()); } + if(dto.getFinishedFlag()==null||dto.getFinishedFlag()==0){ + //不完成任务 + }else{ + //完成修补数据 + ztTask.setRealstarted(new Date(ztTask.getApplyDate().getTime()-ztTask.getUseTime() + .multiply(BigDecimal.valueOf(60*60*1000)).longValue())); + ztTask.setEstStarted(ztTask.getRealstarted()); + ztTask.setDeadline(new Date(DateUtils.getDayEndDate(ztTask.getApplyDate()).getTime()-1000*60*5)); + ztTask.setEstimate(ztTask.getUseTime().floatValue()); + ztTask.setLeft(ztTask.getUseTime().floatValue()); + } + this.baseMapper.insert(ztTask); - fileService.updateFile(dto.getFiles(),ztTask.getId(), FileTypes.task); - if(ztTask.getExecution()!=null&&ztTask.getExecution()!=0){ - kanbanlaneService.addTask( dto.getExecution(), Arrays.asList(ztTask)); + fileService.updateFile(dto.getFiles(), ztTask.getId(), FileTypes.task); + if (ztTask.getExecution() != null && ztTask.getExecution() != 0) { + kanbanlaneService.addTask(dto.getExecution(), Arrays.asList(ztTask)); } ZtProjectproduct projectproduct = projectproductService.getOne(new QueryWrapper().lambda().eq(ZtProjectproduct::getProject, ztTask.getProject())); + actionService.addAction(ActionType.RW, ActionStatus.XJ, ztTask.getId() + , projectproduct == null ? null : projectproduct.getProduct().toString(), projectproduct == null ? null : projectproduct.getProject(), ztTask.getExecution(), + RiskUserThreadLocal.get().getName(), dto.getDesc(), null); + + + if(dto.getFinishedFlag()!=null&&dto.getFinishedFlag()==1){ + //如果选了完成并且不需要审核那么直接完成 + if((userType==UserType.XMGLY||userType==UserType.GSGC)&&!ztTask.getStatus().equals("draft")){ + dto.setId(ztTask.getId()); + dto.setConsumed(ztTask.getUseTime().floatValue()); + dto.setLeft(ztTask.getUseTime().floatValue()); + this.startTask(dto); + } + } - actionService.addAction(ActionType.RW, ActionStatus.XJ,ztTask.getId() - ,projectproduct==null?null:projectproduct.getProduct().toString(),projectproduct==null?null:projectproduct.getProject(),ztTask.getExecution(), - RiskUserThreadLocal.get().getName(),dto.getDesc(),null); } @Override @Transactional public void modifyTask(ZtTaskDTO dto) { ZtTask ztTask = this.baseMapper.selectById(dto.getId()); - if(ztTask==null){ + if (ztTask == null) { throw new BusinessException("未查询到数据"); } String desc = ztTask.getDesc(); - - BeanUtils.copyProperties(dto,ztTask,"left","consumed"); - ztTask.setEstimate(dto.getLeft()); + String status = ztTask.getStatus(); + BeanUtils.copyProperties(dto, ztTask, "left", "consumed"); + ztTask.setEstimate(dto.getEstimate()); //剩余 - ztTask.setLeft(BigDecimal.valueOf(dto.getLeft()).subtract(BigDecimal.valueOf(ztTask.getConsumed())).setScale(2,BigDecimal.ROUND_HALF_UP).floatValue()); + ztTask.setLeft(BigDecimal.valueOf(dto.getEstimate()).subtract(BigDecimal.valueOf(ztTask.getConsumed())).setScale(2, BigDecimal.ROUND_HALF_UP).floatValue()); ztTask.setLastediteddate(new Date()); ztTask.setLasteditedby(RiskUserThreadLocal.get().getName()); - if(ztTask.getDeadline()!=null){ - ztTask.setDeadlineTime(ztTask.getDeadline().getTime()/1000); + if (ztTask.getDeadline() != null) { + ztTask.setDeadlineTime(ztTask.getDeadline().getTime() / 1000); } + + if (dto.getDraftFlag() != null && dto.getDraftFlag() == 1) { + ztTask.setStatus("draft"); + }else{ + if(status.equals("draft")){ + //如果是开发人员 需要评审 + UserType userType = RiskUserThreadLocal.get().getUserType(); + if (userType == UserType.KFZ) { + ZtProject ztProject = this.ztProjectService.getById(ztTask.getExecution()); + ztTask.setStatus("reviewing"); + ztTask.setReviewingUser(ztProject.getPm()); + } else { + ztTask.setStatus("wait"); + ztTask.setReviewingUser(null); + } + }else{ + ztTask.setStatus("reviewing"); + ZtProject ztProject = this.ztProjectService.getById(ztTask.getExecution()); + ztTask.setReviewingUser(ztProject.getPm()); + } + } + if(dto.getFinishedFlag()==null||dto.getFinishedFlag()==0){ + //不完成任务 + }else{ + //完成修补数据 + ztTask.setRealstarted(new Date(ztTask.getApplyDate().getTime()-ztTask.getUseTime() + .multiply(BigDecimal.valueOf(60*60*1000)).longValue())); + ztTask.setEstStarted(ztTask.getRealstarted()); + ztTask.setDeadline(new Date(DateUtils.getDayEndDate(ztTask.getApplyDate()).getTime()-1000*60*5)); + ztTask.setEstimate(ztTask.getUseTime().floatValue()); + ztTask.setLeft(ztTask.getUseTime().floatValue()); + } + this.baseMapper.updateById(ztTask); - fileService.updateFile(dto.getFiles(),ztTask.getId(), FileTypes.task); + fileService.updateFile(dto.getFiles(), ztTask.getId(), FileTypes.task); Integer storyId = ztTask.getStory(); - if(storyId!=null&&storyId!=0){ + if (storyId != null && storyId != 0) { ZtStory story = this.storyService.getById(storyId); - actionService.addAction(ActionType.RW, ActionStatus.BJ,ztTask.getId(),story.getProduct()==null?"":story.getProduct().toString(),ztTask.getProject(),ztTask.getExecution(), - RiskUserThreadLocal.get().getName(),(!StringUtils.isEmpty(desc)&&!desc.equals(dto.getDesc()))?dto.getDesc():null,null); - if(!StringUtils.isEmpty(dto.getRemark())){ - actionService.addAction(ActionType.RW, ActionStatus.TJBZ,ztTask.getId(),story.getProduct()==null?"":story.getProduct().toString(),ztTask.getProject(),ztTask.getExecution(), - RiskUserThreadLocal.get().getName(),dto.getRemark(),null); + actionService.addAction(ActionType.RW, ActionStatus.BJ, ztTask.getId(), story.getProduct() == null ? "" : story.getProduct().toString(), ztTask.getProject(), ztTask.getExecution(), + RiskUserThreadLocal.get().getName(), (!StringUtils.isEmpty(desc) && !desc.equals(dto.getDesc())) ? dto.getDesc() : null, null); + if (!StringUtils.isEmpty(dto.getRemark())) { + actionService.addAction(ActionType.RW, ActionStatus.TJBZ, ztTask.getId(), story.getProduct() == null ? "" : story.getProduct().toString(), ztTask.getProject(), ztTask.getExecution(), + RiskUserThreadLocal.get().getName(), dto.getRemark(), null); } - }else{ - actionService.addAction(ActionType.RW, ActionStatus.BJ,ztTask.getId(),"",ztTask.getProject(),ztTask.getExecution(), - RiskUserThreadLocal.get().getName(),(!StringUtils.isEmpty(desc)&&!desc.equals(dto.getDesc()))?dto.getDesc():null,null); - if(!StringUtils.isEmpty(dto.getRemark())){ - actionService.addAction(ActionType.RW, ActionStatus.TJBZ,ztTask.getId(),"",ztTask.getProject(),ztTask.getExecution(), - RiskUserThreadLocal.get().getName(),dto.getRemark(),null); + } else { + actionService.addAction(ActionType.RW, ActionStatus.BJ, ztTask.getId(), "", ztTask.getProject(), ztTask.getExecution(), + RiskUserThreadLocal.get().getName(), (!StringUtils.isEmpty(desc) && !desc.equals(dto.getDesc())) ? dto.getDesc() : null, null); + if (!StringUtils.isEmpty(dto.getRemark())) { + actionService.addAction(ActionType.RW, ActionStatus.TJBZ, ztTask.getId(), "", ztTask.getProject(), ztTask.getExecution(), + RiskUserThreadLocal.get().getName(), dto.getRemark(), null); } } - - - } @Override @Transactional public void startTask(ZtTaskDTO dto) { - if(dto.getLeft() impleme ztTask.setLasteditedby(RiskUserThreadLocal.get().getName()); ztTask.setLastediteddate(new Date()); ztTask.setConsumed(dto.getConsumed()); - ztTask.setLeft(dto.getLeft()-dto.getConsumed()); + ztTask.setLeft(dto.getLeft() - dto.getConsumed()); this.baseMapper.updateById(ztTask); - if(dto.getConsumed()>0){ - ZtEffortDTO e=new ZtEffortDTO(); - BeanUtils.copyProperties(ztTask,e); + if (dto.getConsumed() > 0) { + ZtEffortDTO e = new ZtEffortDTO(); + BeanUtils.copyProperties(ztTask, e); e.setWork(dto.getRemark()); e.setObjectid(ztTask.getId()); this.effortService.add(e); @@ -481,12 +538,12 @@ public class ZtTaskServiceImpl extends ServiceImpl impleme ZtProjectproduct projectproduct = projectproductService.getOne(new QueryWrapper().lambda() .eq(ZtProjectproduct::getProject, ztTask.getProject())); - actionService.addAction(ActionType.RW, ActionStatus.KS,dto.getId(),projectproduct==null?null:projectproduct.getProduct().toString(),projectproduct==null?null:projectproduct.getProject(),ztTask.getExecution(), - RiskUserThreadLocal.get().getName(),dto.getRemark(),null); + actionService.addAction(ActionType.RW, ActionStatus.KS, dto.getId(), projectproduct == null ? null : projectproduct.getProduct().toString(), projectproduct == null ? null : projectproduct.getProject(), ztTask.getExecution(), + RiskUserThreadLocal.get().getName(), dto.getRemark(), null); - if(ztTask.getExecution()!=null&&ztTask.getExecution()!=0){ - if(StringUtils.isEmpty(dto.getTabType())){ - KanbanQo qo =new KanbanQo(); + if (ztTask.getExecution() != null && ztTask.getExecution() != 0) { + if (StringUtils.isEmpty(dto.getTabType())) { + KanbanQo qo = new KanbanQo(); qo.setStatusType("wait"); qo.setTabType("task"); qo.setId(dto.getId()); @@ -495,17 +552,17 @@ public class ZtTaskServiceImpl extends ServiceImpl impleme qo.setFromId(ztKanbanlane.getColumn()); //查 - if(dto.getFinishedFlag()==0){ + if (dto.getFinishedFlag() == 0) { ztKanbanlane = this.kanbanlaneService.getZtKanbanlane("task", "developing", ztTask.getExecution()); - }else{ + } else { ztKanbanlane = this.kanbanlaneService.getZtKanbanlane("task", "developed", ztTask.getExecution()); } qo.setToId(ztKanbanlane.getColumn()); kanbanlaneService.changeStatus(qo); - }else{ - KanbanQo qo =new KanbanQo(); + } else { + KanbanQo qo = new KanbanQo(); qo.setStatusType(dto.getStatusType()); qo.setTabType(dto.getTabType()); qo.setId(dto.getId()); @@ -514,20 +571,20 @@ public class ZtTaskServiceImpl extends ServiceImpl impleme kanbanlaneService.changeStatus(qo); } } - if("devel".equals(ztTask.getType())){ + if ("devel".equals(ztTask.getType())) { //处理需求 - if("done".equals(ztTask.getStatus())){ + if ("done".equals(ztTask.getStatus())) { this.storyService.finishStory(ztTask.getStory()); - }else if("doing".equals(ztTask.getStatus())){ + } else if ("doing".equals(ztTask.getStatus())) { this.storyService.startStory(ztTask.getStory()); } } - if("test".equals(ztTask.getType())){ + if ("test".equals(ztTask.getType())) { //处理需求 - if("done".equals(ztTask.getStatus())){ + if ("done".equals(ztTask.getStatus())) { this.storyService.testedStory(ztTask.getStory()); - }else if("doing".equals(ztTask.getStatus())){ + } else if ("doing".equals(ztTask.getStatus())) { this.storyService.testingStory(ztTask.getStory()); } @@ -536,17 +593,16 @@ public class ZtTaskServiceImpl extends ServiceImpl impleme Integer execution = ztTask.getExecution(); ZtProject project = this.ztProjectService.getById(execution); - if(project!=null&&"wait".equalsIgnoreCase(project.getStatus())){ + if (project != null && "wait".equalsIgnoreCase(project.getStatus())) { project.setStatus("doing"); this.ztProjectService.updateById(project); } - if(dto.getFinishedFlag()==1){ + if (dto.getFinishedFlag() == 1) { String type = ztTask.getType(); - if(ztTask.getStory()!=null&&ztTask.getStory()!=0){ - if("test".equals(type)){ + if (ztTask.getStory() != null && ztTask.getStory() != 0) { + if ("test".equals(type)) { this.storyService.testedStory(ztTask.getStory()); - }else - if("devel".equals(type)){ + } else if ("devel".equals(type)) { //开发 this.storyService.finishStory(ztTask.getStory()); } @@ -560,21 +616,25 @@ public class ZtTaskServiceImpl extends ServiceImpl impleme @Transactional public void finishTask(ZtTaskDTO dto) { ZtTask ztTask = this.baseMapper.selectById(dto.getId()); - if("done".equalsIgnoreCase(ztTask.getStatus())){ + if ("done".equalsIgnoreCase(ztTask.getStatus())) { throw new BusinessException("未查询到数据"); } - ztTask.setConsumed(dto.getConsumed()+ztTask.getConsumed()); - ztTask.setLeft(ztTask.getEstimate()-ztTask.getConsumed()); + ztTask.setConsumed(dto.getConsumed() + ztTask.getConsumed()); + ztTask.setLeft(ztTask.getEstimate() - ztTask.getConsumed()); ztTask.setStatus("done"); - ztTask.setRealstarted(dto.getRealstarted()); - ztTask.setFinishedby(RiskUserThreadLocal.get().getName()); - ztTask.setFinishedDate(dto.getFinishedDate()); + if(ztTask.getFinishedFlag()!=null&&ztTask.getFinishedFlag()==1){ + ztTask.setFinishedby(ztTask.getAssignedTo()); + }else{ + ztTask.setFinishedby(RiskUserThreadLocal.get().getName()); + } + + ztTask.setFinishedDate(new Date()); ztTask.setLasteditedby(RiskUserThreadLocal.get().getName()); ztTask.setLastediteddate(new Date()); this.baseMapper.updateById(ztTask); - ZtEffortDTO e=new ZtEffortDTO(); - BeanUtils.copyProperties(ztTask,e); + ZtEffortDTO e = new ZtEffortDTO(); + BeanUtils.copyProperties(ztTask, e); e.setObjectid(ztTask.getId()); e.setLeft(0F); e.setConsumed(dto.getConsumed()); @@ -582,24 +642,24 @@ public class ZtTaskServiceImpl extends ServiceImpl impleme //添加action ZtProjectproduct projectproduct = projectproductService.getOne(new QueryWrapper().lambda().eq(ZtProjectproduct::getProject, ztTask.getProject())); - actionService.addAction(ActionType.RW, ActionStatus.WC,dto.getId(),projectproduct==null?null:projectproduct.getProduct().toString(),projectproduct==null?null:projectproduct.getProject(),ztTask.getExecution(), - RiskUserThreadLocal.get().getName(),dto.getRemark(),null); - if(ztTask.getExecution()!=null&&ztTask.getExecution()!=0){ - if(StringUtils.isEmpty(dto.getTabType())){ - KanbanQo qo =new KanbanQo(); - qo.setStatusType("developed"); - qo.setTabType("task"); - qo.setId(dto.getId()); - //查 - ZtKanbancell ztKanbanlane = this.kanbanlaneService.getZtKanbanlane("task", "developing", ztTask.getExecution()); - - qo.setFromId(ztKanbanlane.getColumn()); - //查 - ztKanbanlane = this.kanbanlaneService.getZtKanbanlane("task", "developed", ztTask.getExecution()); - qo.setToId(ztKanbanlane.getColumn()); - kanbanlaneService.changeStatus(qo); - }else{ - KanbanQo qo =new KanbanQo(); + actionService.addAction(ActionType.RW, ActionStatus.WC, dto.getId(), projectproduct == null ? null : projectproduct.getProduct().toString(), projectproduct == null ? null : projectproduct.getProject(), ztTask.getExecution(), + RiskUserThreadLocal.get().getName(), dto.getRemark(), null); + if (ztTask.getExecution() != null && ztTask.getExecution() != 0) { + if (StringUtils.isEmpty(dto.getTabType())) { +// KanbanQo qo = new KanbanQo(); +// qo.setStatusType("developed"); +// qo.setTabType("task"); +// qo.setId(dto.getId()); +// //查 +// ZtKanbancell ztKanbanlane = this.kanbanlaneService.getZtKanbanlane("task", "developing", ztTask.getExecution()); +// +// qo.setFromId(ztKanbanlane.getColumn()); +// //查 +// ztKanbanlane = this.kanbanlaneService.getZtKanbanlane("task", "developed", ztTask.getExecution()); +// qo.setToId(ztKanbanlane.getColumn()); + kanbanlaneService.changeStatus(ztTask.getExecution(),ztTask.getId(),"task","developed"); + } else { + KanbanQo qo = new KanbanQo(); qo.setStatusType(dto.getStatusType()); qo.setTabType(dto.getTabType()); qo.setId(dto.getId()); @@ -608,8 +668,6 @@ public class ZtTaskServiceImpl extends ServiceImpl impleme kanbanlaneService.changeStatus(qo); } } - - // devel 开发 request 需求 test //如果有一个开发任务进行中,并且所有的测试任务还没有开始,需求的研发阶段为“研发中” //如果所有的开发任务已经完成,并且所有的测试任务还没有开始,则为“研发完毕" @@ -619,23 +677,14 @@ public class ZtTaskServiceImpl extends ServiceImpl impleme // pause 暂停 cancel取消 closed 关闭 done 完成 wait reviewing待评审 doing // devel 开发 request 需求 test String type = ztTask.getType(); - if(ztTask.getStory()!=null&&ztTask.getStory()!=0){ - if("test".equals(type)){ + if (ztTask.getStory() != null && ztTask.getStory() != 0) { + if ("test".equals(type)) { this.storyService.testedStory(ztTask.getStory()); - }else - if("devel".equals(type)){ + } else if ("devel".equals(type)) { //开发 this.storyService.finishStory(ztTask.getStory()); } - } - - - -// if(ztTask.getStory()!=null&&ztTask.getStory()!=0){ -// this.storyService.finishStory(ztTask.getStory(),ztTask.getExecution()); -// } - } @Override @@ -643,7 +692,7 @@ public class ZtTaskServiceImpl extends ServiceImpl impleme public void closeTask(ZtTaskDTO dto) { ZtTask ztTask = this.baseMapper.selectById(dto.getId()); String status = ztTask.getStatus(); - if("closed".equalsIgnoreCase(ztTask.getStatus())){ + if ("closed".equalsIgnoreCase(ztTask.getStatus())) { throw new BusinessException("未查询到数据"); } ztTask.setLeft(0f); @@ -654,25 +703,13 @@ public class ZtTaskServiceImpl extends ServiceImpl impleme ZtProjectproduct projectproduct = projectproductService.getOne(new QueryWrapper().lambda().eq(ZtProjectproduct::getProject, ztTask.getProject())); //添加action - actionService.addAction(ActionType.RW, ActionStatus.QX,dto.getId(),projectproduct==null?null:projectproduct.getProduct().toString(),ztTask.getProject(),ztTask.getExecution(), - RiskUserThreadLocal.get().getName(),dto.getDesc(),null); - if(ztTask.getExecution()!=null&&ztTask.getExecution()!=0){ - if(StringUtils.isEmpty(dto.getTabType())){ -// KanbanQo qo =new KanbanQo(); -// qo.setStatusType("developed"); -// qo.setTabType("task"); -// qo.setId(dto.getId()); -// // 完成才能取消 -// String cellStatus="developed"; -// ZtKanbancell ztKanbanlane = this.kanbanlaneService.getZtKanbanlane("task", cellStatus, ztTask.getExecution()); -// -// qo.setFromId(ztKanbanlane.getColumn()); -// //查 -// ztKanbanlane = this.kanbanlaneService.getZtKanbanlane("task", "closed", ztTask.getExecution()); -// qo.setToId(ztKanbanlane.getColumn()); - kanbanlaneService.changeStatus(ztTask.getExecution(),ztTask.getId(),"task","closed"); - }else{ - KanbanQo qo =new KanbanQo(); + actionService.addAction(ActionType.RW, ActionStatus.QX, dto.getId(), projectproduct == null ? null : projectproduct.getProduct().toString(), ztTask.getProject(), ztTask.getExecution(), + RiskUserThreadLocal.get().getName(), dto.getDesc(), null); + if (ztTask.getExecution() != null && ztTask.getExecution() != 0) { + if (StringUtils.isEmpty(dto.getTabType())) { + kanbanlaneService.changeStatus(ztTask.getExecution(), ztTask.getId(), "task", "closed"); + } else { + KanbanQo qo = new KanbanQo(); qo.setStatusType(dto.getStatusType()); qo.setTabType(dto.getTabType()); qo.setId(dto.getId()); @@ -690,9 +727,12 @@ public class ZtTaskServiceImpl extends ServiceImpl impleme public void cancelTask(ZtTaskDTO dto) { ZtTask ztTask = this.baseMapper.selectById(dto.getId()); String status = ztTask.getStatus(); - if("cancel".equalsIgnoreCase(ztTask.getStatus())){ + if ("cancel".equalsIgnoreCase(ztTask.getStatus())) { throw new BusinessException("未查询到数据"); } + if("done".equals(status)||"closed".equals(status)){ + throw new BusinessException("当前状态无法取消"); + } ztTask.setLeft(0f); ztTask.setStatus("cancel"); ztTask.setLasteditedby(RiskUserThreadLocal.get().getName()); @@ -701,28 +741,15 @@ public class ZtTaskServiceImpl extends ServiceImpl impleme ZtProjectproduct projectproduct = projectproductService.getOne(new QueryWrapper().lambda().eq(ZtProjectproduct::getProject, ztTask.getProject())); //添加action - actionService.addAction(ActionType.RW, ActionStatus.QX,dto.getId(),projectproduct==null?null:projectproduct.getProduct().toString(),ztTask.getProject(),ztTask.getExecution(), - RiskUserThreadLocal.get().getName(),dto.getDesc(),null); + actionService.addAction(ActionType.RW, ActionStatus.QX, dto.getId(), projectproduct == null ? null : projectproduct.getProduct().toString(), ztTask.getProject(), ztTask.getExecution(), + RiskUserThreadLocal.get().getName(), dto.getDesc(), null); - if(ztTask.getExecution()!=null&&ztTask.getExecution()!=0){ - if(StringUtils.isEmpty(dto.getTabType())){ + if (ztTask.getExecution() != null && ztTask.getExecution() != 0) { + if (StringUtils.isEmpty(dto.getTabType())) { - String cellStatus = KanBanConstant.TaskMap.get(status); - - - KanbanQo qo =new KanbanQo(); - qo.setStatusType("canceled"); - qo.setTabType("task"); - qo.setId(dto.getId()); - ZtKanbancell ztKanbanlane = this.kanbanlaneService.getZtKanbanlane("task", cellStatus, ztTask.getExecution()); - - qo.setFromId(ztKanbanlane.getColumn()); - //查 - ztKanbanlane = this.kanbanlaneService.getZtKanbanlane("task", "canceled", ztTask.getExecution()); - qo.setToId(ztKanbanlane.getColumn()); - kanbanlaneService.changeStatus(qo); - }else{ - KanbanQo qo =new KanbanQo(); + kanbanlaneService.changeStatus(ztTask.getExecution(),ztTask.getId(),"task","canceled"); + } else { + KanbanQo qo = new KanbanQo(); qo.setStatusType(dto.getStatusType()); qo.setTabType(dto.getTabType()); qo.setId(dto.getId()); @@ -738,71 +765,70 @@ public class ZtTaskServiceImpl extends ServiceImpl impleme @Override @Transactional public void batchAddTask(ZtTaskDTO dto) { - if(CollectionUtils.isEmpty(dto.getList())){ + if (CollectionUtils.isEmpty(dto.getList())) { throw new BusinessException("请检查数据"); } long count = dto.getList().stream().filter(o -> StringUtils.isEmpty(o.getName())).count(); - if(count>0){ + if (count > 0) { throw new BusinessException("请检查数据"); } Integer storyId = dto.getList().get(0).getStory(); ZtProjectstory projectstory = projectstoryService.getOne(new QueryWrapper().lambda().eq(ZtProjectstory::getStory, storyId) - .eq(ZtProjectstory::getType,ProjectTypeEnums.project.getValue()) + .eq(ZtProjectstory::getType, ProjectTypeEnums.project.getValue()) ); // //如果是开发人员 需要评审 UserType userType = RiskUserThreadLocal.get().getUserType(); List list = dto.getList(); - List saveList =new ArrayList(); - for (ZtTaskDTO d:list) { - if(d.getEstimate()==null){ + List saveList = new ArrayList(); + for (ZtTaskDTO d : list) { + if (d.getEstimate() == null) { throw new BusinessException("请检查工时"); } ZtTask ztTask = new ZtTask(); - BeanUtils.copyProperties(d,ztTask); + BeanUtils.copyProperties(d, ztTask); ztTask.setProject(projectstory.getProject()); ztTask.setOpenedby(RiskUserThreadLocal.get().getName()); ztTask.setOpeneddate(new Date()); - if(userType==UserType.KFZ){ - ZtProject ztProject = this.ztProjectService.getById(ztTask.getExecution()); - ztTask.setStatus("reviewing"); - ztTask.setReviewingUser(ztProject.getPm()); - }else{ - ztTask.setStatus("wait"); - ztTask.setReviewingUser(null); - } + if (userType == UserType.KFZ) { + ZtProject ztProject = this.ztProjectService.getById(ztTask.getExecution()); + ztTask.setStatus("reviewing"); + ztTask.setReviewingUser(ztProject.getPm()); + } else { + ztTask.setStatus("wait"); + ztTask.setReviewingUser(null); + } ztTask.setLeft(ztTask.getEstimate()); ztTask.setConsumed(0f); - if(ztTask.getDeadline()!=null){ - ztTask.setDeadlineTime(ztTask.getDeadline().getTime()/1000); + if (ztTask.getDeadline() != null) { + ztTask.setDeadlineTime(ztTask.getDeadline().getTime() / 1000); } Integer project = ztTask.getProject(); ZtProjectproduct ztProjectproduct = this.projectproductService.getOne(new QueryWrapper().lambda() .eq(ZtProjectproduct::getProject, project)); - if(ztProjectproduct!=null){ + if (ztProjectproduct != null) { ztTask.setProduct(ztProjectproduct.getProduct()); } saveList.add(ztTask); } - this.saveBatch(saveList); - kanbanlaneService.addTask( list.get(0).getExecution(),saveList); + kanbanlaneService.addTask(list.get(0).getExecution(), saveList); ZtStory story = storyService.getById(list.get(0).getStory()); ZtProjectstory projectStory = this.projectstoryService.getOne(new QueryWrapper().lambda().eq(ZtProjectstory::getStory, story.getId()).eq(ZtProjectstory::getType, ProjectTypeEnums.project.getValue())); - for (ZtTask t:saveList) { + for (ZtTask t : saveList) { ZtProjectproduct projectproduct = projectproductService.getOne(new QueryWrapper().lambda().eq(ZtProjectproduct::getProject, projectStory.getProject())); - actionService.addAction(ActionType.RW, ActionStatus.XJ,t.getId(),projectproduct==null?null:projectproduct.getProduct().toString(),projectproduct==null?null:projectproduct.getProject(),t.getExecution(), - RiskUserThreadLocal.get().getName(),dto.getDesc(),null); + actionService.addAction(ActionType.RW, ActionStatus.XJ, t.getId(), projectproduct == null ? null : projectproduct.getProduct().toString(), projectproduct == null ? null : projectproduct.getProject(), t.getExecution(), + RiskUserThreadLocal.get().getName(), dto.getDesc(), null); } } @@ -810,53 +836,83 @@ public class ZtTaskServiceImpl extends ServiceImpl impleme @Override @Transactional public void approval(ZtTaskDTO dto) { + + + LoginRiskUser loginRiskUser = RiskUserThreadLocal.get(); + if(loginRiskUser==null){ + throw new BusinessException("请登录"); + } + String account = loginRiskUser.getName(); + + + + ZtTask t = this.baseMapper.selectById(dto.getId()); - if(!t.getStatus().equals("reviewing")){ + + if (!t.getStatus().equals("reviewing")) { throw new BusinessException("未查询到数据"); } - if(dto.getApprovalStatus()==1){ + if(!account.equals(t.getReviewingUser())){ + throw new BusinessException("当前无法评审"); + } + if (dto.getApprovalStatus() == 1) { t.setStatus("wait"); - }else{ - t.setStatus("closed"); + //完成任务 + + + } else { + t.setStatus("draft"); +// if(t.getFinishedFlag()!=null&&t.getFinishedFlag()==1){ +// t.setStatus("draft"); +// }else{ +// t.setStatus("closed"); +// } } t.setApprovalRemark(dto.getApprovalRemark()); t.setLastediteddate(new Date()); t.setLasteditedby(RiskUserThreadLocal.get().getName()); - this.baseMapper.updateById(t); + if (dto.getApprovalStatus() == 1) { + if(t.getFinishedFlag()!=null&&t.getFinishedFlag()==1){ + dto.setConsumed(t.getEstimate()); + dto.setRealstarted(t.getRealstarted()); + dto.setFinishedDate(t.getFinishedDate()); + this.finishTask(dto); + } + } + this.baseMapper.updateById(t); ZtProjectproduct projectproduct = projectproductService.getOne(new QueryWrapper().lambda().eq(ZtProjectproduct::getProject, t.getProject())); - if(dto.getApprovalStatus()==1){ - actionService.addAction(ActionType.RW, ActionStatus.PSTG,t.getId(),projectproduct==null?null:projectproduct.getProduct().toString(),projectproduct==null?null:projectproduct.getProject(),t.getExecution(), - RiskUserThreadLocal.get().getName(),dto.getApprovalRemark(),null); - }else{ - actionService.addAction(ActionType.RW, ActionStatus.PSBTG,t.getId(),projectproduct==null?null:projectproduct.getProduct().toString(),projectproduct==null?null:projectproduct.getProject(),t.getExecution(), - RiskUserThreadLocal.get().getName(),dto.getApprovalRemark(),null); + if (dto.getApprovalStatus() == 1) { + actionService.addAction(ActionType.RW, ActionStatus.PSTG, t.getId(), projectproduct == null ? null : projectproduct.getProduct().toString(), projectproduct == null ? null : projectproduct.getProject(), t.getExecution(), + RiskUserThreadLocal.get().getName(), dto.getApprovalRemark(), null); + } else { + actionService.addAction(ActionType.RW, ActionStatus.PSBTG, t.getId(), projectproduct == null ? null : projectproduct.getProduct().toString(), projectproduct == null ? null : projectproduct.getProject(), t.getExecution(), + RiskUserThreadLocal.get().getName(), dto.getApprovalRemark(), null); } } - @Override public List taskListByExecution(ZtTaskDTO dto) { LambdaQueryWrapper eq = new QueryWrapper().lambda(); - if(dto.getExecution()!=null){ - eq.eq(ZtTask::getExecution, dto.getExecution()); + if (dto.getExecution() != null) { + eq.eq(ZtTask::getExecution, dto.getExecution()); } - if(dto.getStory()!=null){ - eq.eq(ZtTask::getStory,dto.getStory()); + if (dto.getStory() != null) { + eq.eq(ZtTask::getStory, dto.getStory()); } List ztTasks = this.baseMapper.selectList(eq); - if(CollectionUtils.isEmpty(ztTasks)){ + if (CollectionUtils.isEmpty(ztTasks)) { return new ArrayList<>(); - }else{ + } else { return BeanCopyUtil.copyListProperties(ztTasks, ZtTaskDTO::new); } } diff --git a/src/main/java/com/sa/zentao/service/impl/ZtUserServiceImpl.java b/src/main/java/com/sa/zentao/service/impl/ZtUserServiceImpl.java index 157a4e1..8b165d8 100644 --- a/src/main/java/com/sa/zentao/service/impl/ZtUserServiceImpl.java +++ b/src/main/java/com/sa/zentao/service/impl/ZtUserServiceImpl.java @@ -5,10 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; -import com.sa.zentao.dao.BusinessException; -import com.sa.zentao.dao.ZtProjectDTO; -import com.sa.zentao.dao.ZtStoryDTO; -import com.sa.zentao.dao.ZtUserDTO; +import com.sa.zentao.dao.*; import com.sa.zentao.entity.VerificationCode; import com.sa.zentao.entity.ZtProduct; import com.sa.zentao.entity.ZtProject; @@ -18,6 +15,7 @@ import com.sa.zentao.qo.ZtUserQo; import com.sa.zentao.service.*; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.sa.zentao.utils.BeanCopyUtil; +import com.sa.zentao.utils.CryptoUtils; import com.tencentcloudapi.common.Credential; import com.tencentcloudapi.common.exception.TencentCloudSDKException; import com.tencentcloudapi.sms.v20190711.SmsClient; @@ -74,6 +72,10 @@ public class ZtUserServiceImpl extends ServiceImpl impleme PageInfo ztUserDTOPageInfo = new PageInfo<>(ztUserDTOS); ztUserDTOPageInfo.setTotal(page.getTotal()); for (ZtUserDTO dto:ztUserDTOS) { + if(!StringUtils.isEmpty(dto.getVx())){ + dto.setVx(CryptoUtils.aesDecryptForFront(dto.getVx(), CryptoUtils.KEY_DES)); + } + if(dto.getUserType()!=null){ dto.setUserTypeValue(dto.getUserType().getValue()); } @@ -133,6 +135,20 @@ public class ZtUserServiceImpl extends ServiceImpl impleme return ztUsers.stream().collect(Collectors.toMap(ZtUser::getAccount,o->o)); } } + @Override + public Map userMapByIdsOrderByType(List accounts) { + List ztUsers =null; + if(CollectionUtils.isEmpty(accounts)){ + ztUsers = this.baseMapper.selectList(new QueryWrapper().lambda().orderByDesc(ZtUser::getUserType)); + }else{ + ztUsers = this.baseMapper.selectList(new QueryWrapper().lambda().in(ZtUser::getAccount, accounts).orderByDesc(ZtUser::getUserType)); + } + if(CollectionUtils.isEmpty(ztUsers)){ + return new HashMap<>(); + }else{ + return ztUsers.stream().collect(Collectors.toMap(ZtUser::getAccount,o->o)); + } + } @Override @Transactional @@ -210,13 +226,19 @@ public class ZtUserServiceImpl extends ServiceImpl impleme if(StringUtils.isEmpty(vx)){ return null; } - List ztUsers = this.baseMapper.selectList(new QueryWrapper().lambda().eq(ZtUser::getVx, vx)); + List ztUsers = this.baseMapper.selectList(new QueryWrapper().lambda().eq(ZtUser::getVx, CryptoUtils.aesEncryptForFront(vx,CryptoUtils.KEY_DES))); if(CollectionUtils.isEmpty(ztUsers)){ return null; } return ztUsers.get(0); } + @Override + public List dkList(List account, Date startDate, Date endDate) { + + return this.baseMapper.dkList(account,startDate,endDate); + } + public boolean sendSms(String phoneNumber, String verificationCode) { try { // 初始化腾讯云短信服务客户端 diff --git a/src/main/java/com/sa/zentao/utils/CryptoUtils.java b/src/main/java/com/sa/zentao/utils/CryptoUtils.java new file mode 100644 index 0000000..7cd4a60 --- /dev/null +++ b/src/main/java/com/sa/zentao/utils/CryptoUtils.java @@ -0,0 +1,130 @@ +package com.sa.zentao.utils; + +import org.springframework.util.StringUtils; + +import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.util.Base64; + +public class CryptoUtils { + + //这个密钥需要是16位 + public static final String KEY_DES = "aaaaaaaabbbbbbbb"; + + public static void main(String[] args) throws Exception { + String old = "12345678"; + String target ="hy+A8P/oEYPdOpwfRVpgwg=="; // 加密后的字符串 + + //解密 + System.out.println(CryptoUtils.aesDecryptForFront(target, CryptoUtils.KEY_DES)); + + //加密 + System.out.println(CryptoUtils.aesEncryptForFront(old, CryptoUtils.KEY_DES)); + + File file = new File("C:\\111.txt"); + // 以 byte 的形式读取,不改变文件数据的编码格式 + byte[] bytes = Files.readAllBytes(file.toPath()); + + byte[] outFile = CryptoUtils.aesEncryptForFront(bytes, CryptoUtils.KEY_DES); + OutputStream out = new BufferedOutputStream(new FileOutputStream("C:\\model1.zm")); + out.write(outFile); + +// // 这里生成加密后的文件后缀可以自定义 +// File file = new File("C:\\\\model.zm"); +// // 以 byte 的形式读取,不改变文件数据的编码格式 +// byte[] bytes = Files.readAllBytes(file.toPath()); +// byte[] outFile = CryptoUtils.aesDecryptForFront(bytes, CryptoUtils.KEY_DES); +// OutputStream out = new BufferedOutputStream(new FileOutputStream("C:\\model2.glb")); +// out.write(outFile); + + } + + + /** + * AES解密 + * @param encryptStr 密文 + * @param decryptKey 秘钥,必须为16个字符组成 + * @return 明文 + * @throws Exception + */ + public static String aesDecryptForFront(String encryptStr, String decryptKey) { + if (StringUtils.isEmpty(encryptStr) || StringUtils.isEmpty(decryptKey)) { + return null; + } + try { + byte[] encryptByte = Base64.getDecoder().decode(encryptStr); + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(decryptKey.getBytes(), "AES")); + byte[] decryptBytes = cipher.doFinal(encryptByte); + return new String(decryptBytes); + + } catch (Exception var3) { + var3.printStackTrace(); + return null; + } + } + // AES解密文件 + public static byte[] aesDecryptForFront(byte[] bytes, String decryptKey) { + if (StringUtils.isEmpty(bytes) || StringUtils.isEmpty(decryptKey)) { + return null; + } + try { + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(decryptKey.getBytes(), "AES")); + return cipher.doFinal(bytes); + + } catch (Exception var3) { + var3.printStackTrace(); + return null; + } + } + /** + * AES加密文本 + * @param content 明文 + * @param encryptKey 秘钥,必须为16个字符组成 + * @return 密文 + * @throws Exception + */ + public static String aesEncryptForFront(String content, String encryptKey) { + if (StringUtils.isEmpty(content) || StringUtils.isEmpty(encryptKey)) { + return null; + } + try { + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(encryptKey.getBytes(), "AES")); + + byte[] encryptStr = cipher.doFinal(content.getBytes(StandardCharsets.UTF_8)); + return Base64.getEncoder().encodeToString(encryptStr); + + } catch (Exception var3) { + var3.printStackTrace(); + return null; + } + + } + // AES加密文件 + public static byte[] aesEncryptForFront(byte[] bytes, String encryptKey) { + if (StringUtils.isEmpty(bytes) || StringUtils.isEmpty(encryptKey)) { + return null; + } + try { + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(encryptKey.getBytes(), "AES")); + + byte[] encryptStr = cipher.doFinal(bytes); + return encryptStr; + + } catch (Exception var3) { + var3.printStackTrace(); + return null; + } + + } + +} diff --git a/src/main/java/com/sa/zentao/utils/DateUtils.java b/src/main/java/com/sa/zentao/utils/DateUtils.java index f0fb12d..5f466a8 100644 --- a/src/main/java/com/sa/zentao/utils/DateUtils.java +++ b/src/main/java/com/sa/zentao/utils/DateUtils.java @@ -114,7 +114,8 @@ public class DateUtils { } public static String formatDate(Date smdate) { - return smdate == null ? null : sdf.format(smdate); + //todo s Index 14 out of bounds for length 13 + return smdate == null ? "" : sdf.format(smdate); } public static Date parseDate(String smdate, String f) { SimpleDateFormat sdf = new SimpleDateFormat(f); diff --git a/src/main/java/com/sa/zentao/utils/ExcelUtil.java b/src/main/java/com/sa/zentao/utils/ExcelUtil.java new file mode 100644 index 0000000..7e1e511 --- /dev/null +++ b/src/main/java/com/sa/zentao/utils/ExcelUtil.java @@ -0,0 +1,182 @@ +package com.sa.zentao.utils; + +import lombok.extern.slf4j.Slf4j; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.DateUtil; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.*; + +import java.io.*; +import java.util.*; + +/** + * @description: 多个Excel合并Sheet + * @author: wyj + * @time: 2020/9/18 15:28 + */ +@Slf4j +public class ExcelUtil { + + public static void main(String[] args) { + String currentDir = System.getProperty("user.dir"); + System.out.println("Current Directory: " + currentDir); + List list = Arrays.asList( + new File("scope测试.xlsx").toString(), + new File("scope开发.xlsx").toString() + ); + + mergexcel(list,"杨洪-家庭贷-20190908(报告).xlsx", System.getProperty("user.dir")+"\\"); + System.out.println("OJBK"); + } + + /** + * * 合并多个ExcelSheet + * + * @param files 文件字符串(file.toString)集合,按顺序进行合并,合并的Excel中Sheet名称不可重复 + * @param excelName 合并后Excel名称(包含后缀.xslx) + * @param dirPath 存储目录 + * @return + * @Date: 2020/9/18 15:31 + */ + public static void mergexcel(List files, String excelName, String dirPath) { + XSSFWorkbook newExcelCreat = new XSSFWorkbook(); + // 遍历每个源excel文件,TmpList为源文件的名称集合 + for (String fromExcelName : files) { + try (InputStream in = new FileInputStream(fromExcelName)) { + XSSFWorkbook fromExcel = new XSSFWorkbook(in); + int length = fromExcel.getNumberOfSheets(); + if (length <= 1) { //长度为1时 + XSSFSheet oldSheet = fromExcel.getSheetAt(0); +// XSSFSheet newSheet = newExcelCreat.createSheet(oldSheet.getSheetName()); + XSSFSheet newSheet = newExcelCreat.createSheet(oldSheet.getSheetName()); + copySheet(newExcelCreat, oldSheet, newSheet); + } else { + for (int i = 0; i < length; i++) {// 遍历每个sheet + XSSFSheet oldSheet = fromExcel.getSheetAt(i); + XSSFSheet newSheet = newExcelCreat.createSheet(oldSheet.getSheetName()); + copySheet(newExcelCreat, oldSheet, newSheet); + } + } + } catch (IOException e) { + e.printStackTrace(); + } + } + // 定义新生成的xlxs表格文件 + String allFileName = dirPath + File.separator + excelName; + try (FileOutputStream fileOut = new FileOutputStream(allFileName)) { + newExcelCreat.write(fileOut); + fileOut.flush(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + newExcelCreat.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + /** + * 合并单元格 + * + * @param fromSheet + * @param toSheet + */ + private static void mergeSheetAllRegion(XSSFSheet fromSheet, XSSFSheet toSheet) { + int num = fromSheet.getNumMergedRegions(); + CellRangeAddress cellR = null; + for (int i = 0; i < num; i++) { + cellR = fromSheet.getMergedRegion(i); + toSheet.addMergedRegion(cellR); + } + } + + /** + * 复制单元格 + * + * @param wb + * @param fromCell + * @param toCell + */ + private static void copyCell(XSSFWorkbook wb, XSSFCell fromCell, XSSFCell toCell) { + XSSFCellStyle newstyle = wb.createCellStyle(); + // 复制单元格样式 + try { + newstyle.cloneStyleFrom(fromCell.getCellStyle()); + }catch (Exception e){ + System.out.print(""+e); + } + + // 样式 + toCell.setCellStyle(newstyle); + if (fromCell.getCellComment() != null) { + toCell.setCellComment(fromCell.getCellComment()); + } + // 不同数据类型处理 + CellType fromCellType = fromCell.getCellType(); + toCell.setCellType(fromCellType); + if (fromCellType == CellType.NUMERIC) { + if (DateUtil.isCellDateFormatted(fromCell)) { + toCell.setCellValue(fromCell.getDateCellValue()); + } else { + toCell.setCellValue(fromCell.getNumericCellValue()); + } + } else if (fromCellType == CellType.STRING) { + toCell.setCellValue(fromCell.getRichStringCellValue()); + } else if (fromCellType == CellType.BLANK) { + // nothing21 + } else if (fromCellType == CellType.BOOLEAN) { + toCell.setCellValue(fromCell.getBooleanCellValue()); + } else if (fromCellType == CellType.ERROR) { + toCell.setCellErrorValue(fromCell.getErrorCellValue()); + } else if (fromCellType == CellType.FORMULA) { + toCell.setCellFormula(fromCell.getCellFormula()); + } else { + // nothing29 + } + } + + /** + * 行复制功能 + * + * @param wb + * @param oldRow + * @param toRow + */ + private static void copyRow(XSSFWorkbook wb, XSSFRow oldRow, XSSFRow toRow) { + toRow.setHeight(oldRow.getHeight()); + for (Iterator cellIt = oldRow.cellIterator(); cellIt.hasNext(); ) { + XSSFCell tmpCell = (XSSFCell) cellIt.next(); + XSSFCell newCell = toRow.createCell(tmpCell.getColumnIndex()); + copyCell(wb, tmpCell, newCell); + } + } + + /** + * Sheet复制 + * + * @param wb + * @param fromSheet + * @param toSheet + */ + private static void copySheet(XSSFWorkbook wb, XSSFSheet fromSheet, XSSFSheet toSheet) { + mergeSheetAllRegion(fromSheet, toSheet); + // 设置列宽 + int length =0; + try { + length = fromSheet.getRow(fromSheet.getFirstRowNum()).getLastCellNum(); + }catch (Exception e){ + length=10; + } + + for (int i = 0; i <= length; i++) { + toSheet.setColumnWidth(i, fromSheet.getColumnWidth(i)); + } + for (Iterator rowIt = fromSheet.rowIterator(); rowIt.hasNext(); ) { + XSSFRow oldRow = (XSSFRow) rowIt.next(); + XSSFRow newRow = toSheet.createRow(oldRow.getRowNum()); + copyRow(wb, oldRow, newRow); + } + } +} \ No newline at end of file diff --git a/src/main/resources/mapper/ZtStoryFeedbackMapper.xml b/src/main/resources/mapper/ZtStoryFeedbackMapper.xml index 2b78fa6..6116edc 100644 --- a/src/main/resources/mapper/ZtStoryFeedbackMapper.xml +++ b/src/main/resources/mapper/ZtStoryFeedbackMapper.xml @@ -17,6 +17,12 @@ SELECT * from zt_story_feedback s WHERE 1 = 1 + + + + and s.product = #{qo.productId} + + diff --git a/src/main/resources/mapper/ZtStoryMapper.xml b/src/main/resources/mapper/ZtStoryMapper.xml index 3114b27..6dca255 100644 --- a/src/main/resources/mapper/ZtStoryMapper.xml +++ b/src/main/resources/mapper/ZtStoryMapper.xml @@ -70,6 +70,7 @@ where 1=1 and product = #{qo.productId} + diff --git a/src/main/resources/mapper/ZtTaskMapper.xml b/src/main/resources/mapper/ZtTaskMapper.xml index 767ae1c..bb7664c 100644 --- a/src/main/resources/mapper/ZtTaskMapper.xml +++ b/src/main/resources/mapper/ZtTaskMapper.xml @@ -2,227 +2,223 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -230,6 +226,19 @@ select * from zt_task where execution = #{id} + + diff --git a/src/main/resources/mapper/ZtUserMapper.xml b/src/main/resources/mapper/ZtUserMapper.xml index 90730b1..442b6ed 100644 --- a/src/main/resources/mapper/ZtUserMapper.xml +++ b/src/main/resources/mapper/ZtUserMapper.xml @@ -65,5 +65,22 @@ +