|
@@ -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();
|