Browse Source

Merge branch 'fu-normal-push' of uskycloud/usky-modules into master

gez 1 month ago
parent
commit
f73a56b7d3

+ 5 - 0
service-iot/service-iot-biz/src/main/java/com/usky/iot/controller/api/PmTimedSendingApi.java

@@ -26,4 +26,9 @@ public class PmTimedSendingApi implements RemotePmService {
         pmWorkReportService.timedSending(now);
     }
 
+    @Override
+    public void reportSubmissionReminder() {
+        pmWorkReportService.reportSubmissionReminder();
+    }
+
 }

+ 4 - 0
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/PmWorkReportService.java

@@ -59,4 +59,8 @@ public interface PmWorkReportService extends CrudService<PmWorkReport> {
      */
     List<PmWorkReport> timedReportQuery();
 
+    /**
+     * 报告提交定时提醒
+     */
+    void reportSubmissionReminder();
 }

+ 2 - 1
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/impl/DmpDeviceInfoServiceImpl.java

@@ -317,7 +317,8 @@ public class DmpDeviceInfoServiceImpl extends AbstractCrudService<DmpDeviceInfoM
      */
     private List<DmpProductAttribute> getProductAttributeList(Integer productId) {
         LambdaQueryWrapper<DmpProductAttribute> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(DmpProductAttribute::getProductId, productId);
+        queryWrapper.eq(DmpProductAttribute::getProductId, productId)
+                .eq(DmpProductAttribute::getDeleteFlag, 0);
         return dmpProductAttributeMapper.selectList(queryWrapper);
     }
 

+ 52 - 0
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/impl/PmWorkReportServiceImpl.java

@@ -1,8 +1,10 @@
 package com.usky.iot.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.aliyuncs.exceptions.ClientException;
 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.mybatis.core.AbstractCrudService;
 import com.usky.common.security.utils.SecurityUtils;
@@ -13,12 +15,14 @@ import com.usky.iot.domain.PmWorkReport;
 import com.usky.iot.mapper.PmReceiveMapper;
 import com.usky.iot.mapper.PmWorkContentMapper;
 import com.usky.iot.mapper.PmWorkReportMapper;
+import com.usky.iot.mapper.SysUserMapper;
 import com.usky.iot.service.PmProjectService;
 import com.usky.iot.service.PmWorkContentService;
 import com.usky.iot.service.PmWorkReportService;
 import com.usky.iot.service.config.DingTalkAndMessage;
 import com.usky.iot.service.vo.PmProjectTotalWorkTimeVo;
 import com.usky.iot.service.vo.PmProjectWorkTimeVo;
+import com.usky.system.RemoteMceService;
 import com.usky.system.domain.SysUser;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -71,6 +75,16 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
     @Autowired
     private PmReceiveMapper pmReceiveMapper;
 
+    @Autowired
+    private SysUserMapper sysUserMapper;
+
+    @Autowired
+    private RemoteMceService remoteMceService;
+
+    private static final String INFO_TITLE = "日报未提交提醒";
+    private static final String INFO_CONTENT = "您今天的日报还未提交,别忘记哦~";
+    private static final int INFO_TYPE = 5;
+
     /**
      * 获取时间内工作报告
      *
@@ -586,6 +600,7 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
      * @param: [time] 开始时间
      * @return: void
      **/
+    @Async
     @Override
     public void timedSending(LocalDateTime time) {
         log.info("定时报告任务开始---------------------------");
@@ -724,5 +739,42 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
         return timedReports;
     }
 
+    @Async
+    @Override
+    public void reportSubmissionReminder() {
+        Integer tenantId = SecurityUtils.getTenantId();
+        List<Long> userIds = new ArrayList<>();
+        LambdaQueryWrapper<PmWorkReport> todayReports = Wrappers.lambdaQuery();
+        todayReports.eq(PmWorkReport::getReportStatus, 1)
+                .eq(PmWorkReport::getReportDate, LocalDate.now())
+                .eq(PmWorkReport::getTenantId, tenantId);
+        List<PmWorkReport> todayReportsList = pmWorkReportMapper.selectList(todayReports);
+        if (!todayReportsList.isEmpty()) {
+            userIds = todayReportsList.stream().map(PmWorkReport::getSubmitterId).collect(Collectors.toList());
+        }
 
+        LambdaQueryWrapper<SysUser> userQueryWrapper = Wrappers.lambdaQuery();
+        userQueryWrapper.select(SysUser::getUserId, SysUser::getNickName)
+                .eq(SysUser::getTenantId, tenantId)
+                .eq(SysUser::getStatus, 0)
+                .eq(SysUser::getDelFlag, 0)
+                .notIn(!userIds.isEmpty(), SysUser::getUserId, userIds);
+        userIds =  sysUserMapper.selectList(userQueryWrapper).stream().map(SysUser::getUserId).collect(Collectors.toList());
+
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("infoTitle", INFO_TITLE);
+        jsonObject.put("infoContent", INFO_CONTENT);
+        jsonObject.put("infoType", INFO_TYPE);
+        jsonObject.put("id", 0);
+        jsonObject.put("infoTypeName", INFO_TITLE);
+        jsonObject.put("userName", "报告提醒通知");
+        jsonObject.put("userIds", userIds);
+
+        // 推送消息中心
+        try {
+            remoteMceService.addMce(jsonObject.toString());
+        } catch (Exception e) {
+            throw new BusinessException("报告提醒通知失败" + e);
+        }
+    }
 }