فهرست منبع

Merge branch 'fu-dev' of uskycloud/usky-modules into server-165

fuyuchuan 9 ماه پیش
والد
کامیت
c39e7ac76a

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

@@ -44,9 +44,6 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
     @Autowired
     private SysUserMapper sysUserMapper;
 
-    @Autowired
-    private PmProjectMapper pmProjectMapper;
-
     @Autowired
     private PmProjectService pmProjectService;
 
@@ -92,6 +89,7 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
     public List<PmWorkReport> workReportQuery(String startDate, String endDate, String projectName, Integer projectAscription, Integer reportId) {
         List<PmWorkReport> reportList = new ArrayList<>();
         List<PmWorkContent> pmWorkContentList = new ArrayList<>();
+        List<Long> userIds = new ArrayList<>();
         if (reportId != null && reportId != 0) {
             LambdaQueryWrapper<PmWorkReport> reportQuery = Wrappers.lambdaQuery();
             reportQuery.select(PmWorkReport::getId, PmWorkReport::getCoordinateWork, PmWorkReport::getTomorrowPlan, PmWorkReport::getCcTo, PmWorkReport::getSubmitterId,
@@ -104,7 +102,10 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
             pmWorkContentList = this.list(contentQuery);
             report.setWorkContents(pmWorkContentList);
             reportList.add(report);
-        }else{
+            for (PmWorkReport c : reportList) {
+                userIds.add(c.getSubmitterId());
+            }
+        } else {
             LocalDate start = LocalDate.parse(startDate);
             LocalDate end = LocalDate.parse(endDate);
             String subQueryReports = "SELECT id FROM pm_work_report WHERE report_date BETWEEN '" + start + "' AND '" + end + "' AND tenant_id = " + SecurityUtils.getTenantId();
@@ -136,17 +137,16 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
                     .in(PmWorkReport::getId, reportIds)
                     .orderByDesc(PmWorkReport::getCreateTime);
             reportList = pmWorkReportMapper.selectList(reportQuery);
-        }
-        List<Long> userIds = new ArrayList<>();
-        for (PmWorkReport c : reportList) {
-            List<PmWorkContent> contents = new ArrayList<>();
-            for (PmWorkContent b : pmWorkContentList) {
-                if (b.getReportId() == c.getId()) {
-                    contents.add(b);
+            for (PmWorkReport c : reportList) {
+                List<PmWorkContent> contents = new ArrayList<>();
+                for (PmWorkContent b : pmWorkContentList) {
+                    if (b.getReportId() == c.getId()) {
+                        contents.add(b);
+                    }
                 }
+                c.setWorkContents(contents);
+                userIds.add(c.getSubmitterId());
             }
-            c.setWorkContents(contents);
-            userIds.add(c.getSubmitterId());
         }
         LambdaQueryWrapper<SysUser> usersQuery = Wrappers.lambdaQuery();
         usersQuery.select(SysUser::getUserId, SysUser::getNickName)

+ 19 - 14
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/impl/PmWorkReportServiceImpl.java

@@ -1,6 +1,7 @@
 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;
@@ -20,6 +21,7 @@ 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;
@@ -260,20 +262,23 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
                 newContent.setTenantId(SecurityUtils.getTenantId());
                 pmWorkContentMapper.insert(newContent);
                 //推送消息中心
-                String infoContent = SecurityUtils.getLoginUser().getSysUser().getNickName() + "的工作报告";
-                String[] strArr = newReport.getCcTo().split(",");
-                List<Long> ids = Arrays.stream(strArr)
-                        .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);
-                String jsonStr = jsonObject.toString();
-                remoteMceService.addMce(jsonStr);
-                System.out.println("Serialized JSON: " + jsonStr);
+                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();