浏览代码

消息修改

tudc 3 年之前
父节点
当前提交
004fc3df50

+ 5 - 7
flowable/src/main/java/com/huyi/flowable/api/FlowTask.java

@@ -168,13 +168,11 @@ public class FlowTask extends FlowableConfig {
             taskService.complete(taskId);
 
             // 消息通知
-            try {
-                ProcessInstance instance = runtimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult();
-                messageService.addStartFlowMessage(instance);
-            } catch (Exception e) {
-                e.printStackTrace();
-                throw new FlowableException("任务处理失败!");
-            }
+            ProcessInstance instance = runtimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult();
+            // 消息通知完成状态修改
+            messageService.completeMessage(instance);
+            // 新增消息通知
+            messageService.addStartFlowMessage(instance);
         } catch (Exception e) {
             e.printStackTrace();
             return new BaseResult("500", "任务处理失败!", null);

+ 30 - 2
flowable/src/main/java/com/huyi/flowable/message/MessageService.java

@@ -1,10 +1,13 @@
 package com.huyi.flowable.message;
 
+import com.huyi.flowable.api.FlowProcess;
 import com.huyi.flowable.mapper.MeHistoryMapper;
 import com.huyi.flowable.server.mapper.MessageMapper;
 import net.sf.json.JSONObject;
 import org.apache.commons.lang3.StringUtils;
 import org.flowable.engine.IdentityService;
+import org.flowable.engine.ProcessEngine;
+import org.flowable.engine.RuntimeService;
 import org.flowable.engine.TaskService;
 import org.flowable.engine.runtime.ProcessInstance;
 import org.flowable.identitylink.api.IdentityLink;
@@ -26,13 +29,16 @@ public class MessageService {
     protected IdentityService identityService;
     @Autowired
     protected MeHistoryMapper meHistoryMapper;
+    @Autowired
+    protected RuntimeService runtimeService;
 
     //TODO 不同项目不适用
     public void addStartFlowMessage(ProcessInstance instance){
         if (instance == null) {
             return;
         }
-        Map<String, Object> paras = instance.getProcessVariables();
+        Map<String, Object> paras = runtimeService.getVariables(instance.getId());
+//        Map<String, Object> paras = instance.getProcessVariables();
         System.out.println("paras======>"+paras);
         // 获取公司ID
         Map<String, Object> map = new HashMap<>();
@@ -49,7 +55,7 @@ public class MessageService {
         param.put("openType", "01");
         // 融资审批
         if ("1000000006".equals(menuId)) {
-            param.put("workType", "03");
+            param.put("workType", "08");
             //TODO 加标题
             param.put("title","加标题");
         // 融信审批
@@ -110,4 +116,26 @@ public class MessageService {
             System.out.println("消息增加失败");
         }
     }
+
+    public void completeMessage(ProcessInstance instance){
+        Map<String, Object> param = new HashMap<>();
+        String businessKey = instance.getBusinessKey();
+        param.put("tableId", businessKey);
+
+        // 获取公司ID
+        Map<String, Object> map = new HashMap<>();
+        map.put("procdefId", instance.getProcessDefinitionId());
+        List<Map<String, Object>> historyList = meHistoryMapper.queryMeHistory(map);
+        // 1000000006 为融资审批,其他为融信审批
+        String menuId = historyList.get(0).get("menuId").toString();
+
+        // 融资审批
+        if ("1000000006".equals(menuId)) {
+            param.put("workType", "08");
+        // 融信审批
+        } else {
+            param.put("workType", "00");
+        }
+        messageMapper.updateNotice(param);
+    }
 }

+ 1 - 0
flowable/src/main/java/com/huyi/flowable/server/mapper/MessageMapper.java

@@ -10,6 +10,7 @@ import java.util.Map;
 public interface MessageMapper {
     int insertMessage(Map d);
     int insertNoticeUserRel(Map d);
+    int updateNotice(Map d);
     Map<String, String> queryUser(String userId);
     Map<String, Object> queryFinanceInf(String id);
 }

+ 4 - 1
flowable/src/main/java/com/huyi/flowable/server/mapper/MessageMapper.xml

@@ -3,7 +3,7 @@
 <mapper namespace="com.huyi.flowable.server.mapper.MessageMapper">
     <insert id="insertMessage">
         insert into sys_notice(notice_id, company_id, table_id, notice_title, type, notice_type, work_type,
-        status, message_send, message_id, message_code, message_status, remark, create_time) values (#{id}, #{companyId}, #{tableId}, #{title}, '00', null, #{workType}, '0', '0', null, null, null, '审批自动生成', now());
+        status, message_send, message_id, message_code, message_status, open_type, open_url, remark, create_time) values (#{id}, #{companyId}, #{tableId}, #{title}, '00', null, #{workType}, '0', '0', null, null, null, '01', #{openUrl}, '审批自动生成', now());
     </insert>
     <insert id="insertNoticeUserRel">
         insert into sys_notice_user_rel values
@@ -11,6 +11,9 @@
             (#{noticeId}, #{item}, '0')
         </foreach>
     </insert>
+    <update id="updateNotice">
+        update sys_notice set status = '1' where type = '00' and work_type = #{workType} and table_id = #{tableId};
+    </update>
     <select id = "queryUser" resultType="java.util.Map" parameterType="java.lang.String">
         select nick_name nickName from sys_user where user_id = #{id}
     </select>