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