Prechádzať zdrojové kódy

材料提交拒绝后通知提交人

dzx 1 týždeň pred
rodič
commit
794d1b8f18

+ 35 - 1
src/main/java/com/xjrsoft/module/material/service/impl/MaterialTaskAssignServiceImpl.java

@@ -1,5 +1,6 @@
 package com.xjrsoft.module.material.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.yulichang.base.MPJBaseServiceImpl;
@@ -13,10 +14,16 @@ import com.xjrsoft.module.material.mapper.MaterialTaskAppendixMapper;
 import com.xjrsoft.module.material.mapper.MaterialTaskAssignMapper;
 import com.xjrsoft.module.material.mapper.MaterialTaskMapper;
 import com.xjrsoft.module.material.service.IMaterialTaskAssignService;
+import com.xjrsoft.module.organization.dto.WeChatSendMessageDto;
+import com.xjrsoft.module.organization.entity.User;
+import com.xjrsoft.module.organization.service.IUserService;
+import com.xjrsoft.module.organization.service.IWeChatService;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.List;
 import java.util.Optional;
 
@@ -26,6 +33,8 @@ public class MaterialTaskAssignServiceImpl extends MPJBaseServiceImpl<MaterialTa
     private final MaterialTaskAssignMapper materialTaskAssignMapper;
     private final MaterialTaskMapper materialTaskMapper;
     private final MaterialTaskAppendixMapper appendixMapper;
+    private final IWeChatService weChatService;
+    private final IUserService userService;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -84,6 +93,7 @@ public class MaterialTaskAssignServiceImpl extends MPJBaseServiceImpl<MaterialTa
     @Transactional(rollbackFor = Exception.class)
     public Boolean approved(List<MaterialTaskAssignApprovedDto> dtos) {
         MaterialTask materialTask = null;
+        String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
         for (MaterialTaskAssignApprovedDto dto : dtos) {
             MaterialTaskAssign materialTaskAssign = materialTaskAssignMapper.selectByIdDeep(dto.getId());
             if (materialTaskAssign != null && materialTaskAssign.getStatus() == 2) {
@@ -104,12 +114,36 @@ public class MaterialTaskAssignServiceImpl extends MPJBaseServiceImpl<MaterialTa
 //                        }
                     }
                     if (dto.getStatus() == 2) {//重做
-                        materialTaskAssign.setStatus(4);
+                        materialTaskAssign.setStatus(1);
 
                         appendixMapper.delete(
                                 new QueryWrapper<MaterialTaskAppendix>().lambda()
                                         .eq(MaterialTaskAppendix::getMaterialTaskId, materialTaskAssign.getId())
                         );
+
+                        User user = userService.getById(materialTaskAssign.getUserId());
+                        if(user.getOpenId() != null){
+                            WeChatSendMessageDto weChatSendMessageDto = new WeChatSendMessageDto();
+                            weChatSendMessageDto.setUserId(user.getOpenId());
+                            weChatSendMessageDto.setTemplateId("qmpXORPM1Cocqn503Qa4On6BJhR92UZ00eod2-6IcGo");
+                            //weChatSendMessageDto.setUrl(StrUtil.format("{}/pages/message/notice/detail?id={}", commonPropertiesConfig.getDomainApp(), id));
+                            weChatSendMessageDto.setMsgId(materialTask.getId().toString());
+                            JSONObject data = new JSONObject();
+
+                            JSONObject data1 = new JSONObject();
+                            data1.put("value", materialTask.getName() + "提交材料被拒绝");
+                            data.put("thing23", data1);
+
+                            JSONObject data2 = new JSONObject();
+                            data2.put("value", user.getName());
+                            data.put("thing29", data2);
+
+                            JSONObject data3 = new JSONObject();
+                            data3.put("value", time);
+                            data.put("time17", data3);
+                            weChatSendMessageDto.setContent(data);
+                            weChatService.sendTemplateMessage(weChatSendMessageDto);
+                        }
                     }
 
                     materialTaskAssignMapper.updateById(materialTaskAssign);