فهرست منبع

优化项目管理-工作报告

fuyuhchuan 9 ماه پیش
والد
کامیت
6dff098012

+ 1 - 1
service-iot/service-iot-biz/src/main/java/com/usky/iot/controller/web/PmWorkReportController.java

@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.*;
 
 import java.time.DayOfWeek;
 import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.time.temporal.TemporalAdjusters;
 import java.util.List;
 import java.util.Map;
@@ -45,7 +46,6 @@ public class PmWorkReportController {
     public ApiResult<List<Map<String, List<PmWorkReport>>>> weekWork(@RequestParam(required = false) String startDate,
                                                   @RequestParam(required = false) String endDate,
                                                   @RequestParam(required = false, defaultValue = "0") Integer id) {
-
         return ApiResult.success(pmWorkReportService.weekWork(startDate, endDate, id));
     }
 

+ 3 - 0
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/impl/PmWorkContentServiceImpl.java

@@ -111,6 +111,7 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
             String subQueryReports = "SELECT id FROM pm_work_report WHERE report_date BETWEEN '" + start + "' AND '" + end + "' AND tenant_id = " + SecurityUtils.getTenantId();
             String subQueryReport = "SELECT id FROM pm_work_report WHERE FIND_IN_SET('" + SecurityUtils.getUserId() + "', cc_to) > 0 AND tenant_id = " + SecurityUtils.getTenantId();
             String subQueryProjects = "SELECT id FROM pm_project WHERE project_head = '" + SecurityUtils.getUserId() + "' AND tenant_id = " + SecurityUtils.getTenantId();
+            String sentOut = "SELECT id FROM pm_work_report WHERE create_by = '" + SecurityUtils.getUsername() + "' AND tenant_id = " + SecurityUtils.getTenantId();
             String reportIdList = "SELECT report_id FROM pm_work_content WHERE project_name = '" + projectName + "' AND tenant_id = " + SecurityUtils.getTenantId();
             LambdaQueryWrapper<PmWorkContent> contentLambdaQuery = Wrappers.lambdaQuery();
             contentLambdaQuery.select(PmWorkContent::getReportId, PmWorkContent::getWorkContent, PmWorkContent::getWorkTime, PmWorkContent::getProjectName)
@@ -119,6 +120,8 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
                 contentLambdaQuery.inSql(PmWorkContent::getProjectId, subQueryProjects);
             } else if (projectAscription == 2) {
                 contentLambdaQuery.inSql(PmWorkContent::getReportId, subQueryReport);
+            } else if(projectAscription==3){
+                contentLambdaQuery.inSql(PmWorkContent::getReportId, sentOut);
             }
             if (StringUtils.isNotBlank(projectName)) {
                 contentLambdaQuery.inSql(PmWorkContent::getReportId, reportIdList);

+ 33 - 41
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/impl/PmWorkReportServiceImpl.java

@@ -1,10 +1,8 @@
 package com.usky.iot.service.impl;
 
 import com.alibaba.fastjson.JSONObject;
-import com.alibaba.nacos.shaded.com.google.gson.JsonObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.usky.common.core.bean.ApiResult;
 import com.usky.common.core.exception.BusinessException;
 import com.usky.common.security.utils.SecurityUtils;
 import com.usky.iot.domain.PmProject;
@@ -21,7 +19,6 @@ import com.usky.system.RemoteMceService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.time.DayOfWeek;
@@ -29,6 +26,7 @@ import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.temporal.TemporalAdjusters;
 import java.util.*;
+import java.util.concurrent.CompletableFuture;
 import java.util.stream.Collectors;
 
 
@@ -87,6 +85,17 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
             dates.add(tempDate);
             tempDate = tempDate.plusDays(1);
         }
+        //返回最新的一条数据给前端填充
+        LambdaQueryWrapper<PmWorkReport> wrapper2 = Wrappers.lambdaQuery();
+        wrapper2.eq(PmWorkReport::getSubmitterId, SecurityUtils.getUserId())
+                .orderByDesc(PmWorkReport::getSubmitDate)
+                .last("LIMIT 1");
+        report = baseMapper.selectList(wrapper2);
+        Integer pId = report.get(0).getId();
+        LambdaQueryWrapper<PmWorkContent> wrapper = Wrappers.lambdaQuery();
+        wrapper.eq(PmWorkContent::getReportId, pId);
+        List<PmWorkContent> contents1 = pmWorkContentMapper.selectList(wrapper);
+        report.get(0).setWorkContents(contents1);
         //固定返回七条数据,没有内容也要设置时间给前端渲染
         LambdaQueryWrapper<PmWorkReport> queryWrapperR = Wrappers.lambdaQuery();
         queryWrapperR.select(PmWorkReport::getId, PmWorkReport::getReportDate, PmWorkReport::getSubmitDate, PmWorkReport::getUpdateTime, PmWorkReport::getTomorrowPlan, PmWorkReport::getCoordinateWork, PmWorkReport::getCcTo)
@@ -167,25 +176,6 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
                 reportList.add(newReport);
             }
         }
-        //返回最新的一条数据给前端填充
-        LambdaQueryWrapper<PmWorkReport> wrapper2 = Wrappers.lambdaQuery();
-        wrapper2.eq(PmWorkReport::getSubmitterId, SecurityUtils.getUserId())
-                .orderByDesc(PmWorkReport::getSubmitDate)
-                .last("LIMIT 1");
-        List<PmWorkReport> report2 = baseMapper.selectList(wrapper2);
-        report = report2;
-        Integer pId = report.get(0).getId();
-        List<PmWorkContent> pmWorkContentList = new ArrayList<>();
-        LambdaQueryWrapper<PmWorkContent> wrapper = Wrappers.lambdaQuery();
-        wrapper.eq(PmWorkContent::getReportId, pId);
-        List<PmWorkContent> contents1 = pmWorkContentMapper.selectList(wrapper);
-        for (PmWorkContent pmWorkContent : contents1) {
-            Integer pId2 = pmWorkContent.getReportId();
-            if (pId2 == pId) {
-                pmWorkContentList.add(pmWorkContent);
-            }
-        }
-        report.get(0).setWorkContents(pmWorkContentList);
         weekData.put("weekData", reportList);
         newData.put("newData", report);
         returnList.add(0, newData);
@@ -233,7 +223,27 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
             newReport.setTenantId(SecurityUtils.getTenantId());
             newReport.setTotalHours(totalWorkTime);
             pmWorkReportMapper.insert(newReport);
-            Integer id = newReport.getId();
+            //推送消息中心
+            String nickName = SecurityUtils.getLoginUser().getSysUser().getNickName();
+            String infoContent = nickName + "的报告";
+            List<Long> ids = Arrays.stream(newReport.getCcTo().split(","))
+                    .map(Long::parseLong)
+                    .collect(Collectors.toList());
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("infoTitle", "报告提醒");
+            jsonObject.put("infoContent", infoContent);
+            jsonObject.put("infoType", 5);
+            jsonObject.put("id", newReport.getId());
+            jsonObject.put("userIds", ids);
+            // 异步发送消息
+            CompletableFuture.runAsync(() -> {
+                try {
+                    // 推送消息中心
+                    remoteMceService.addMce(jsonObject.toString());
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            });
             //获取报告中所有项目id
             List<Integer> projectIds = new ArrayList<>();
             for (PmWorkContent b1 : pmWorkReport.getWorkContents()) {
@@ -261,24 +271,6 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
                 newContent.setDeptId(SecurityUtils.getLoginUser().getSysUser().getDeptId());
                 newContent.setTenantId(SecurityUtils.getTenantId());
                 pmWorkContentMapper.insert(newContent);
-                //推送消息中心
-                try {
-                    String nickName = SecurityUtils.getLoginUser().getSysUser().getNickName();
-                    String infoContent = nickName + "的工作报告";
-                    List<Long> ids = Arrays.stream(newReport.getCcTo().split(","))
-                            .map(Long::parseLong)
-                            .collect(Collectors.toList());
-                    JSONObject jsonObject = new JSONObject();
-                    jsonObject.put("infoTitle", "工作报告");
-                    jsonObject.put("infoContent", infoContent);
-                    jsonObject.put("infoType", 5);
-                    jsonObject.put("id", id);
-                    jsonObject.put("userIds", ids);
-                    remoteMceService.addMce(jsonObject.toString());
-                    System.out.println(jsonObject);
-                } catch (Exception e) {
-                    e.printStackTrace();
-                }
             }
         } else {
             PmWorkReport rp = new PmWorkReport();