浏览代码

收文通知

dzx 6 月之前
父节点
当前提交
bde7d3db54

+ 91 - 0
src/main/java/com/xjrsoft/module/liteflow/node/OfficialDocumentReceivedNode.java

@@ -0,0 +1,91 @@
+package com.xjrsoft.module.liteflow.node;
+
+import cn.hutool.core.convert.Convert;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.xjrsoft.common.enums.RoomApplicantTypeEnum;
+import com.xjrsoft.common.enums.StudyStatusEnum;
+import com.xjrsoft.common.enums.WorkflowApproveType;
+import com.xjrsoft.module.asset.service.IWfAssetManageInventoryService;
+import com.xjrsoft.module.hikvision.entity.HikvisionData;
+import com.xjrsoft.module.hikvision.util.DataUtil;
+import com.xjrsoft.module.oa.service.IOfficialDocumentReceivedService;
+import com.xjrsoft.module.room.entity.WfRoomApplicant;
+import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
+import com.xjrsoft.module.workflow.entity.WorkflowRecord;
+import com.xjrsoft.module.workflow.mapper.WorkflowRecordMapper;
+import com.xjrsoft.module.workflow.service.IWorkflowExecuteService;
+import com.yomahub.liteflow.core.NodeComponent;
+import org.apache.commons.lang.StringUtils;
+import org.camunda.bpm.engine.history.HistoricProcessInstance;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.support.TransactionSynchronization;
+import org.springframework.transaction.support.TransactionSynchronizationManager;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * 收文规则提示
+ */
+@Component("official_document_received_node")
+public class OfficialDocumentReceivedNode extends NodeComponent {
+
+    @Autowired
+    private IOfficialDocumentReceivedService documentReceivedService;
+
+    @Autowired
+    private IWorkflowExecuteService workflowExecuteService;
+    @Autowired
+    private WorkflowRecordMapper workflowRecordMapper;
+
+    @Override
+    public void process() throws Exception {
+        // 获取表单中数据编号
+        Map<String, Object> params = this.getFirstContextBean();
+        Object value = util.getFormDatKey(params, "id");
+        Long formId = Convert.toLong(value);
+        Object processInstanceId = params.get("processInstanceId");
+        if (processInstanceId == null) {
+            return;
+        }
+        String processInstanceIdStr = Convert.toStr(processInstanceId);
+        if (formId != null && StringUtils.isNotEmpty(processInstanceIdStr)) {
+            TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
+                @Override
+                public void afterCommit() {
+                    CompletableFuture.runAsync(() -> {
+                        Optional<HistoricProcessInstance> historicProcessInstanceOptional = workflowExecuteService.getHistoricProcessInstance(processInstanceId.toString());
+
+                        if (historicProcessInstanceOptional.isEmpty()) {
+                            return;
+                        }
+                        HistoricProcessInstance historicProcessInstance = historicProcessInstanceOptional.get();
+                        if (!historicProcessInstance.getState().equals(HistoricProcessInstance.STATE_ACTIVE)) {
+                            // 获取流程记录中的非正常结束
+                            LambdaQueryWrapper<WorkflowRecord> workflowRecordLambdaQueryWrapper = new LambdaQueryWrapper<>();
+                            workflowRecordLambdaQueryWrapper
+                                    .and(wq -> wq.eq(WorkflowRecord::getWorkflowApproveType, WorkflowApproveType.DISAGREE.getCode())
+                                            .or()
+                                            .eq(WorkflowRecord::getWorkflowApproveType, WorkflowApproveType.WITHDRAW.getCode())
+                                    )
+                                    .eq(WorkflowRecord::getProcessId, processInstanceId)
+                            ;
+                            List<WorkflowRecord> workflowRecordList = workflowRecordMapper.selectList(workflowRecordLambdaQueryWrapper);
+
+                            if (!workflowRecordList.isEmpty()) {
+                                return;
+                            }
+                        }
+                        documentReceivedService.noticeHandleDutyUser(formId);
+
+                    });
+                }
+            });
+        }
+    }
+}

+ 2 - 0
src/main/java/com/xjrsoft/module/oa/service/IOfficialDocumentReceivedService.java

@@ -17,4 +17,6 @@ public interface IOfficialDocumentReceivedService extends MPJBaseService<Officia
     String getMaxReceivedNumber();
 
     String getMaxMeetingNumber();
+
+    Boolean noticeHandleDutyUser(Long formId);
 }

+ 43 - 0
src/main/java/com/xjrsoft/module/oa/service/impl/OfficialDocumentReceivedServiceImpl.java

@@ -1,13 +1,22 @@
 package com.xjrsoft.module.oa.service.impl;
 
+import cn.hutool.core.util.IdUtil;
+import com.alibaba.fastjson.JSONObject;
 import com.github.yulichang.base.MPJBaseServiceImpl;
 import com.xjrsoft.module.oa.entity.OfficialDocumentReceived;
 import com.xjrsoft.module.oa.mapper.OfficialDocumentReceivedMapper;
 import com.xjrsoft.module.oa.service.IOfficialDocumentReceivedService;
 import com.xjrsoft.module.oa.utils.PostNumberUtil;
+import com.xjrsoft.module.organization.dto.WeChatSendMessageDto;
+import com.xjrsoft.module.organization.entity.User;
+import com.xjrsoft.module.organization.mapper.UserMapper;
+import com.xjrsoft.module.organization.service.IWeChatService;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+
 /**
  * @title: 公文收文
  * @Author szs
@@ -19,6 +28,9 @@ import org.springframework.stereotype.Service;
 public class OfficialDocumentReceivedServiceImpl extends MPJBaseServiceImpl<OfficialDocumentReceivedMapper, OfficialDocumentReceived> implements IOfficialDocumentReceivedService {
     private final OfficialDocumentReceivedMapper officialDocumentReceivedMapper;
 
+    private final IWeChatService weChatService;
+    private final UserMapper userMapper;
+
     @Override
     public String getMaxReceivedNumber() {
         Integer maxReceivedNumber = officialDocumentReceivedMapper.getMaxReceivedNumber();
@@ -30,4 +42,35 @@ public class OfficialDocumentReceivedServiceImpl extends MPJBaseServiceImpl<Offi
         Integer maxReceivedNumber = officialDocumentReceivedMapper.getMaxMeetingNumber();
         return PostNumberUtil.initMaxPostNumber(maxReceivedNumber, 3);
     }
+
+    @Override
+    public Boolean noticeHandleDutyUser(Long formId) {
+
+        OfficialDocumentReceived documentReceived = this.getById(formId);
+        if(documentReceived.getHandleDutyUserId() != null){
+            User user = userMapper.selectById(documentReceived.getHandleDutyUserId());
+
+            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(IdUtil.getSnowflakeNextIdStr());
+            JSONObject data = new JSONObject();
+
+            JSONObject thing23 = new JSONObject();
+            thing23.put("value", "您有一个行政收文待处理");
+            data.put("thing23", thing23);
+
+            JSONObject data2 = new JSONObject();
+            data2.put("value", user.getName());
+            data.put("thing29", data2);
+
+            JSONObject data3 = new JSONObject();
+            data3.put("value", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+            data.put("time17", data3);
+            weChatSendMessageDto.setContent(data);
+            weChatService.sendTemplateMessage(weChatSendMessageDto);
+        }
+        return true;
+    }
 }