Browse Source

修改获取异步任务结果判断2

yusm 5 tháng trước cách đây
mục cha
commit
4c6d1cf74c

+ 46 - 16
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/TaskController.java

@@ -14,6 +14,7 @@ import com.management.platform.entity.dto.TaskDto;
 import com.management.platform.entity.vo.SysRichFunction;
 import com.management.platform.mapper.*;
 import com.management.platform.service.*;
+import com.management.platform.service.impl.WxCorpInfoServiceImpl;
 import com.management.platform.util.DateTimeUtil;
 import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.MessageUtils;
@@ -62,6 +63,12 @@ public class TaskController {
     private InformationService informationService;
     @Resource
     private TaskInformationService taskInformationService;
+    @Resource
+    WxCorpInfoMapper wxCorpInfoMapper;
+    @Resource
+    WxCorpInfoService wxCorpInfoService;
+    @Resource
+    UserMapper userMapper;
 
 
 
@@ -147,6 +154,8 @@ public class TaskController {
     @Scheduled(cron = "0 0 9 * * ?")
     public void InfomationAlerts(){
         log.info("定时执行了11111===========>");
+        User user = userMapper.selectById(request.getHeader("token"));
+        WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
         QueryWrapper<Task> taskQueryWrapper = new QueryWrapper<>();
         taskQueryWrapper.eq("is_delete",0).eq("is_repeat",1).ne("status",2).isNotNull("executor_id");
         List<Task> list = taskService.list(taskQueryWrapper);
@@ -163,18 +172,18 @@ public class TaskController {
                 if (task.getRepeatType()!=null&&task.getRepeatType()==0){
                     //获取任务重复结束 重复永不结束   1:勾选
                     if (task.getRepeatEndNever()!=null&&task.getRepeatEndNever()==1){
-                        saveInformationList(executorIdList,task);
+                        saveInformationListAndSendMsg(executorIdList,task,wxCorpInfo);
                     }else if (task.getRepeatEndCount()!=null&&task.getRepeatEndCount()>0){
                         TaskInformation taskInformation = selectTaskInformation(task);
                         int between = task.getRepeatEndCount();
-                        saveInformationListWithCount(task, taskInformation, between, executorIdList);
+                        saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
                     }else if (task.getRepeatEndDate()!=null){
                         TaskInformation taskInformation = selectTaskInformation(task);
                         if (LocalDateTime.now().isAfter(task.getRepeatEndDate())){
                             continue;
                         }
                         int between = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getRepeatEndDate());
-                        saveInformationListWithCount(task, taskInformation, between, executorIdList);
+                        saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
                     }
                 }
                 //每周
@@ -183,11 +192,11 @@ public class TaskController {
                     //每周一才执行
                     if (LocalDateTime.now().getDayOfWeek().getValue()==1){
                         if (task.getRepeatEndNever()!=null&&task.getRepeatEndNever()==1){
-                            saveInformationList(executorIdList,task);
+                            saveInformationListAndSendMsg(executorIdList,task,wxCorpInfo);
                         }else if (task.getRepeatEndCount()!=null&&task.getRepeatEndCount()>0){
                             TaskInformation taskInformation = selectTaskInformation(task);
                             int between = task.getRepeatEndCount();
-                            saveInformationListWithCount(task, taskInformation, between, executorIdList);
+                            saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
                         }else if (task.getRepeatEndDate()!=null){
                             TaskInformation taskInformation = selectTaskInformation(task);
                             if (LocalDateTime.now().isAfter(task.getRepeatEndDate())){
@@ -195,7 +204,7 @@ public class TaskController {
                             }
                             int between = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getRepeatEndDate());
                             between=between/7;
-                            saveInformationListWithCount(task, taskInformation, between, executorIdList);
+                            saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
                         }
                     }else {
                         continue;
@@ -207,11 +216,11 @@ public class TaskController {
                     //每月一号才执行
                     if (LocalDateTime.now().getDayOfMonth()==1){
                         if (task.getRepeatEndNever()!=null&&task.getRepeatEndNever()==1){
-                            saveInformationList(executorIdList,task);
+                            saveInformationListAndSendMsg(executorIdList,task,wxCorpInfo);
                         }else if (task.getRepeatEndCount()!=null&&task.getRepeatEndCount()>0){
                             TaskInformation taskInformation = selectTaskInformation(task);
                             int between = task.getRepeatEndCount();
-                            saveInformationListWithCount(task, taskInformation, between, executorIdList);
+                            saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
                         }else if (task.getRepeatEndDate()!=null){
                             TaskInformation taskInformation = selectTaskInformation(task);
                             if (LocalDateTime.now().isAfter(task.getRepeatEndDate())){
@@ -219,7 +228,7 @@ public class TaskController {
                             }
                             int between = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getRepeatEndDate());
                             between=between/30;
-                            saveInformationListWithCount(task, taskInformation, between, executorIdList);
+                            saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
                         }
                     }else {
                         continue;
@@ -232,11 +241,11 @@ public class TaskController {
                     int num = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getCreateDate());
                     if (num%task.getRepeatDesignSameday()==0){
                         if (task.getRepeatEndNever()!=null&&task.getRepeatEndNever()==1){
-                            saveInformationList(executorIdList,task);
+                            saveInformationListAndSendMsg(executorIdList,task,wxCorpInfo);
                         }else if (task.getRepeatEndCount()!=null&&task.getRepeatEndCount()>0){
                             TaskInformation taskInformation = selectTaskInformation(task);
                             int between = task.getRepeatEndCount();
-                            saveInformationListWithCount(task, taskInformation, between, executorIdList);
+                            saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
                         }else if (task.getRepeatEndDate()!=null){
                             TaskInformation taskInformation = selectTaskInformation(task);
                             if (LocalDateTime.now().isAfter(task.getRepeatEndDate())){
@@ -244,7 +253,7 @@ public class TaskController {
                             }
                             int between = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getRepeatEndDate());
                             between=between/task.getRepeatDesignSameday();
-                            saveInformationListWithCount(task, taskInformation, between, executorIdList);
+                            saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
                         }
                     }else {
                         continue;
@@ -255,7 +264,7 @@ public class TaskController {
                     //获取任务重复结束 重复永不结束   1:勾选
                     int num = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getCreateDate());
                     if (task.getRepeatDesignDay().contains(num+"")){
-                        saveInformationList(executorIdList,task);
+                        saveInformationListAndSendMsg(executorIdList,task,wxCorpInfo);
                     }else {
                         continue;
                     }
@@ -270,20 +279,20 @@ public class TaskController {
         return taskInformationService.getOne(lqw);
     }
 
-    private void saveInformationListWithCount(Task task, TaskInformation taskInformation, int between, List<String> executorIdList) {
+    private void saveInformationListWithCount(Task task, TaskInformation taskInformation, int between, List<String> executorIdList,WxCorpInfo corpInfo) {
         if (taskInformation ==null){
             TaskInformation taskInformationNew = new TaskInformation();
             taskInformationNew.setTaskId(task.getId())
                     .setCompanyId(task.getCompanyId()).setCount(between -1);
             taskInformationService.save(taskInformationNew);
-            saveInformationList(executorIdList,task);
+            saveInformationListAndSendMsg(executorIdList,task,corpInfo);
         }else {
             Integer count = taskInformation.getCount();
             if (count>0){
                 count -= 1;
                 UpdateWrapper<TaskInformation> updateWrapper = new UpdateWrapper<TaskInformation>().set("count", count).eq("id", taskInformation.getId());
                 taskInformationService.update(updateWrapper);
-                saveInformationList(executorIdList,task);
+                saveInformationListAndSendMsg(executorIdList,task,corpInfo);
             }
         }
     }
@@ -307,5 +316,26 @@ public class TaskController {
         }
     }
 
+    private void saveInformationListAndSendMsg(List<String> executorIdList,Task task,WxCorpInfo corpinfo) {
+        if (!executorIdList.isEmpty()){
+            ArrayList<Information> informationArrayList = new ArrayList<>();
+            String msg="你有新的任务:"+task.getTaskName();
+            if (task.getStatus()!=null&&task.getStatus()==1){
+                msg="你有任务:"+task.getTaskName()+"执行中";
+            } else if (task.getStatus() != null && task.getStatus() == 3) {
+                msg="你有任务:"+task.getTaskName()+"已逾期";
+            }
+            for (String userId : executorIdList) {
+                Information information = new Information();
+                information.setUserId(userId).setMsg(msg)
+                        .setTime(new Date()).setChecked(0);
+                informationArrayList.add(information);
+                User user = userMapper.selectById(userId);
+                wxCorpInfoService.sendWXCorpMsg(corpinfo,user.getCorpwxUserid(),msg,null, WxCorpInfoServiceImpl.TEXT_CARD_MSG_TASK);
+            }
+            informationService.saveBatch(informationArrayList);
+        }
+    }
+
 }
 

+ 5 - 5
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/ExcelExportServiceImpl.java

@@ -97,7 +97,7 @@ public class ExcelExportServiceImpl implements ExcelExportService {
 
 
                 syncTranslationResult = wxCorpInfoService.getSyncTranslationResult(jobId);
-                if (syncTranslationResult != null) {
+                if (syncTranslationResult != null && !syncTranslationResult.equals("")) {
                     long t2 = System.currentTimeMillis();
                     System.out.println("企业微信转译文件后地址是:"+syncTranslationResult+",耗时:" + (t2 - t) + "ms");
                     httpRespMsg.data = syncTranslationResult;
@@ -149,7 +149,7 @@ public class ExcelExportServiceImpl implements ExcelExportService {
                 }
                 i++;
             }
-            if (syncTranslationResult != null) {
+            if (syncTranslationResult != null && !syncTranslationResult.equals("")) {
                 httpRespMsg.data = syncTranslationResult;
             } else {
                 //httpRespMsg.setError("处理超时...");
@@ -197,7 +197,7 @@ public class ExcelExportServiceImpl implements ExcelExportService {
                 }
                 i++;
             }
-            if (syncTranslationResult != null) {
+            if (syncTranslationResult != null && !syncTranslationResult.equals("")) {
                 httpRespMsg.data = syncTranslationResult;
             } else {
                 //httpRespMsg.setError("处理超时...");
@@ -246,7 +246,7 @@ public class ExcelExportServiceImpl implements ExcelExportService {
                 }
                 i++;
             }
-            if (syncTranslationResult != null) {
+            if (syncTranslationResult != null && !syncTranslationResult.equals("")) {
                 httpRespMsg.data = syncTranslationResult;
             } else {
                 //httpRespMsg.setError("处理超时...");
@@ -293,7 +293,7 @@ public class ExcelExportServiceImpl implements ExcelExportService {
                 }
                 i++;
             }
-            if (syncTranslationResult != null) {
+            if (syncTranslationResult != null && !syncTranslationResult.equals("")) {
                 httpRespMsg.data = syncTranslationResult;
             } else {
                 //httpRespMsg.setError("处理超时...");

+ 2 - 2
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/UserServiceImpl.java

@@ -2316,7 +2316,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
                     }
                     i++;
                 }
-                if (syncTranslationResult != null) {
+                if (syncTranslationResult != null && !syncTranslationResult.equals("")) {
                     httpRespMsg.data = syncTranslationResult;
                 } else {
                     //httpRespMsg.setError("处理超时...");
@@ -2533,7 +2533,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
                     }
                     i++;
                 }
-                if (syncTranslationResult != null) {
+                if (syncTranslationResult != null && !syncTranslationResult.equals("")) {
                     httpRespMsg.data = syncTranslationResult;
                 } else {
                     //httpRespMsg.setError("处理超时...");

+ 3 - 2
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/WxCorpInfoServiceImpl.java

@@ -87,6 +87,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
 
     public static final int TEXT_CARD_MSG_EXPENSE_AGREE = 21;//费用报销审核通过
     public static final int TEXT_CARD_MSG_EXPENSE_DENY = 22;//费用报销审核驳回
+    public static final int TEXT_CARD_MSG_TASK = 23;//费用报销审核驳回
 
     private static Object userLock = new Object();
 
@@ -248,8 +249,6 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                 JSONObject result = (JSONObject) json.get("result");
                 JSONObject contact_id_translate = (JSONObject) result.get("contact_id_translate");
                 resultUrl = contact_id_translate.getString("url");
-            }else {
-                throw new Exception(json.toJSONString());
             }
         }else {
             throw new Exception(json.toJSONString());
@@ -288,6 +287,8 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                     title = "日报驳回";
                 } else if (msgType.equals(TEXT_CARD_MSG_REPORT_AGREE)) {
                     title = "日报审核通过";
+                } else if (msgType.equals(TEXT_CARD_MSG_TASK)) {
+                    title = "客户管家:任务信息提醒";
                 }
             } else {
                 jumpUrl = jumpUrl.replace("STATE", pageRouter);