瀏覽代碼

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

gez 10 月之前
父節點
當前提交
f7f12a780f

+ 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)

+ 24 - 15
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;
@@ -216,6 +218,11 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
         } else if (totalWorkTime == null || totalWorkTime.equals(BigDecimal.ZERO) || totalWorkTime.compareTo(BigDecimal.ZERO) < 0) {
             throw new BusinessException("工时不能为空!");
         }
+        LambdaQueryWrapper<PmWorkReport> reportWrapper = Wrappers.lambdaQuery();
+        reportWrapper.select(PmWorkReport::getId)
+                .eq(PmWorkReport::getReportDate, pmWorkReport.getReportDate())
+                .last("LIMIT 1");
+        List<PmWorkReport> repeat = this.list(reportWrapper);
         //判断是否携带reportId,不写带则为新增报告,携带则为编辑(更新)项目
         if (pmWorkReport.getId() == null) {
             PmWorkReport newReport = new PmWorkReport();
@@ -260,22 +267,24 @@ 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());
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
             }
-        } else {
+        } else if (repeat.size() > 0) {
             PmWorkReport rp = new PmWorkReport();
             rp.setId(pmWorkReport.getId());
             rp.setReportDate(pmWorkReport.getReportDate());