Quellcode durchsuchen

Merge branch 'Enhance_move_snapshot_to_backend' of wy/zdqy_ibps into matser

李源 vor 2 Jahren
Ursprung
Commit
996ec80e15

+ 3 - 0
ibps-base-root/modules/base-cloud/src/main/java/com/lc/ibps/cloud/provider/GenericProvider.java

@@ -59,6 +59,9 @@ public class GenericProvider {
 	protected HttpServletRequest getRequest() {
 		ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
 		try {
+			if (BeanUtils.isEmpty(attributes)) {
+				return null;
+			}
 			attributes.getRequest().setCharacterEncoding(StringPool.UTF_8);
 		} catch (UnsupportedEncodingException ignore) {
 			return null;

+ 5 - 1
ibps-basic-root/modules/basic-response/src/main/resources/config/application-common.yml

@@ -121,4 +121,8 @@ com:
     config:
       enabled: ${CONFIG_ENABLED:false}
 cache:
-  for-update: ${CACHE_FOR_UPDATE:false}
+  for-update: ${CACHE_FOR_UPDATE:false}
+
+runqian:
+  server: ${RUNQIAN_SERVER:https://www.szjyxt.com}
+  base-path: ${RUNQIAN_BASE_PATH:/demo}

+ 1 - 1
ibps-bpmn-root/modules/bpmn-biz/src/main/java/com/lc/ibps/bpmn/helper/BpmInstBuilder.java

@@ -45,7 +45,7 @@ public class BpmInstBuilder {
 			BpmApproveRepository bpmApproveRepository = AppUtil.getBean(BpmApproveRepository.class);
 			List<BpmApprovePo> approveList = bpmApproveRepository.getByInstId(bpmInst.getId());
 			if(BeanUtils.isEmpty(approveList)) {
-				LOGGER.warn("流程实例不存在任务及审批意见,有可能数据出了问题,请检查数据");
+				LOGGER.warn("流程实例不存在任务及审批意见,有可能数据出了问题,请检查数据。 InstID=" + bpmInst.getId());
 				return;
 			}
 			String curNodeName = "";

+ 41 - 32
ibps-bpmn-root/modules/bpmn-biz/src/main/java/com/lc/ibps/bpmn/listener/ProcEndEventListener.java

@@ -1,31 +1,14 @@
 package com.lc.ibps.bpmn.listener;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.Resource;
-
-import org.activiti.engine.impl.entity.SubProcessStartOrEndEventModel;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationListener;
-import org.springframework.core.Ordered;
-import org.springframework.stereotype.Service;
-
 import com.lc.ibps.api.base.model.User;
 import com.lc.ibps.base.core.exception.BaseException;
 import com.lc.ibps.base.core.util.BeanUtils;
 import com.lc.ibps.base.core.util.string.StringValidator;
+import com.lc.ibps.base.saas.context.TenantContext;
+import com.lc.ibps.base.web.context.ContextUtil;
 import com.lc.ibps.bpmn.api.cmd.ActionCmd;
 import com.lc.ibps.bpmn.api.cmd.TaskFinishCmd;
-import com.lc.ibps.bpmn.api.constant.ActionType;
-import com.lc.ibps.bpmn.api.constant.BpmConstants;
-import com.lc.ibps.bpmn.api.constant.BpmOperTypeEnum;
-import com.lc.ibps.bpmn.api.constant.ProcInstStatus;
-import com.lc.ibps.bpmn.api.constant.TemplateType;
+import com.lc.ibps.bpmn.api.constant.*;
 import com.lc.ibps.bpmn.api.context.BpmnContextUtil;
 import com.lc.ibps.bpmn.api.event.NotifyTaskModel;
 import com.lc.ibps.bpmn.api.event.ProcEndEvent;
@@ -37,21 +20,28 @@ import com.lc.ibps.bpmn.cmd.IbpsTaskFinishCmd;
 import com.lc.ibps.bpmn.domain.BpmApprove;
 import com.lc.ibps.bpmn.domain.BpmInst;
 import com.lc.ibps.bpmn.domain.BpmOperNotify;
-import com.lc.ibps.bpmn.persistence.entity.BpmApprovePo;
-import com.lc.ibps.bpmn.persistence.entity.BpmInstPo;
-import com.lc.ibps.bpmn.persistence.entity.BpmOperLogPo;
-import com.lc.ibps.bpmn.persistence.entity.BpmOperNotifyPo;
-import com.lc.ibps.bpmn.persistence.entity.BpmTaskSignPo;
-import com.lc.ibps.bpmn.repository.BpmApproveRepository;
-import com.lc.ibps.bpmn.repository.BpmInstHisRepository;
-import com.lc.ibps.bpmn.repository.BpmInstRepository;
-import com.lc.ibps.bpmn.repository.BpmOperNotifyRepository;
-import com.lc.ibps.bpmn.repository.BpmTaskSignRepository;
+import com.lc.ibps.bpmn.persistence.entity.*;
+import com.lc.ibps.bpmn.repository.*;
 import com.lc.ibps.bpmn.utils.BpmUtil;
 import com.lc.ibps.bpmn.utils.NotifyUtil;
 import com.lc.ibps.cloud.entity.APIResult;
+import com.lc.ibps.cloud.message.util.MessageQueueProductorUtil;
+import com.lc.ibps.cloud.mq.core.constants.QueueConstants;
+import com.lc.ibps.cloud.mq.core.model.DefaultMessage;
 import com.lc.ibps.org.api.IPartyUserService;
 import com.lc.ibps.org.party.persistence.entity.PartyUserPo;
+import org.activiti.engine.impl.entity.SubProcessStartOrEndEventModel;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationListener;
+import org.springframework.core.Ordered;
+import org.springframework.stereotype.Service;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.util.*;
 
 
 /**
@@ -139,7 +129,7 @@ public class ProcEndEventListener implements ApplicationListener<ProcEndEvent>,O
 	/**
 	 * 
 	 *更新流程实例状态。
-	 * @param bpmnInstId 
+	 * @param execution
 	 * void
 	 */
 	private BpmInstPo updProcessInstance(BpmDelegateExecution execution){
@@ -178,10 +168,29 @@ public class ProcEndEventListener implements ApplicationListener<ProcEndEvent>,O
 		BpmInst bpmInstDomain = bpmInstRepository.newInstance();
 		bpmInstDomain.createHistory(instId);
 		bpmInstDomain.delete(instId);
-		
+		Map<String, Object> var = new HashMap<>();
+		var.put("userId",ContextUtil.getCurrentUserId());
+		var.put("instId",instId);
+		MessageQueueProductorUtil.send(buildSnapshotMessage(var));
 		return instance;
 	}
 
+	private DefaultMessage buildSnapshotMessage(Map<String, Object> var){
+		DefaultMessage<String> message = new DefaultMessage<String>();
+
+		message.setTenantId(TenantContext.getCurrentTenantId());
+
+		message.setRouting(QueueConstants.Message.ROUTING_KEY_MESSAGE_SNAPSHOT);
+		message.setExchange(QueueConstants.Message.EXCHANGE_MESSAGE);
+		message.setQueue(QueueConstants.Message.QUEUE_NAME_SNAPSHOT);
+
+		message.setVariables(var);
+		//message.setData(instId);
+
+
+		return message;
+	}
+
 	/**
 	 * 流程结束通知
 	 *

+ 31 - 29
ibps-comp-root/modules/comp-file-server/src/main/java/com/lc/ibps/cloud/file/provider/UploadProvider.java

@@ -13,6 +13,7 @@ import javax.validation.constraints.NotNull;
 
 import com.lc.ibps.base.core.encrypt.Base64;
 import com.lc.ibps.base.db.util.TableMetaUtil;
+import com.lc.ibps.cloud.entity.APIRequest;
 import org.springframework.http.MediaType;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.mock.web.MockMultipartFile;
@@ -87,14 +88,15 @@ public class UploadProvider extends GenericUploadProvider implements IUploadServ
 			@RequestPart(name = "file", required = true)MultipartFile file) {
 
 		APIResult<AttachmentPo> result = new APIResult<>();
-
-		String uploadFileVoStr = this.getRequest().getParameter("uploadFileVo");
 		UploadFileVo uploadFileVo = null;
-		if(JacksonUtil.isJsonObject(uploadFileVoStr)) {
-			uploadFileVo = JacksonUtil.getDTO(uploadFileVoStr, UploadFileVo.class);
+		Map<String, Object> paramsVo;
+		if (BeanUtils.isNotEmpty(this.getRequest())){
+			String uploadFileVoStr = this.getRequest().getParameter("uploadFileVo");
+			if(JacksonUtil.isJsonObject(uploadFileVoStr)) {
+				uploadFileVo = JacksonUtil.getDTO(uploadFileVoStr, UploadFileVo.class);
+			}
 		}
-
-		Map<String, Object> paramsVo = getUploadParams(uploadFileVo);
+		paramsVo = getUploadParams(uploadFileVo);
 		Map<String, Object> paramsRequest = getUploadParams(this.getRequest());
 		paramsVo.putAll(paramsRequest);
 
@@ -465,34 +467,34 @@ public class UploadProvider extends GenericUploadProvider implements IUploadServ
 	 * @return
 	 */
 	private Map<String, Object> getUploadParams(HttpServletRequest request) {
-		String uploadType = RequestUtil.getString(request, "uploadType", "file"); // 控件的类型
-		String paramJson = RequestUtil.getString(request, "paramJson"); // 自定义参数
-		String fileMd5 = RequestUtil.getString(request, "fileMd5");// 文件唯一标记 MD5
-		Boolean isChunk = RequestUtil.getBoolean(request, "isChunk", true);// 是否分片存储
-		// 当前分块下标
-		String chunk = RequestUtil.getString(request, "chunk");
-		// 当前分块大小
-		String chunkSize = RequestUtil.getString(request, "chunkSize");
-
 		Map<String, Object> params = new HashMap<String, Object>();
-
-		params.put(FileParam.UPLOAD_TYPE, uploadType);
-		params.put(FileParam.FILE_MD5, fileMd5);
-		params.put(FileParam.IS_CHUNK, isChunk);
-		params.put(FileParam.CHUNK, chunk);
-		params.put(FileParam.CHUNK_SIZE, chunkSize);
-
 		params.put(FileParam.CUR_USER_ID, ContextUtil.getCurrentUser().getUserId());
 		params.put(FileParam.CUR_USER_ACCOUNT, ContextUtil.getCurrentUser().getAccount());
 		params.put(FileParam.CUR_USER_NAME, ContextUtil.getCurrentUser().getFullname());
-
-		if (StringUtil.isNotEmpty(paramJson)) {
-			try {
-				Map<String, Object> paramMap = JacksonUtil.toMap(paramJson);
-				if (BeanUtils.isNotEmpty(paramMap)){
-					params.putAll(paramMap);
+		if (BeanUtils.isNotEmpty(request)) {
+			String uploadType = RequestUtil.getString(request, "uploadType", "file"); // 控件的类型
+			String paramJson = RequestUtil.getString(request, "paramJson"); // 自定义参数
+			String fileMd5 = RequestUtil.getString(request, "fileMd5");// 文件唯一标记 MD5
+			Boolean isChunk = RequestUtil.getBoolean(request, "isChunk", true);// 是否分片存储
+			// 当前分块下标
+			String chunk = RequestUtil.getString(request, "chunk");
+			// 当前分块大小
+			String chunkSize = RequestUtil.getString(request, "chunkSize");
+
+			params.put(FileParam.UPLOAD_TYPE, uploadType);
+			params.put(FileParam.FILE_MD5, fileMd5);
+			params.put(FileParam.IS_CHUNK, isChunk);
+			params.put(FileParam.CHUNK, chunk);
+			params.put(FileParam.CHUNK_SIZE, chunkSize);
+
+			if (StringUtil.isNotEmpty(paramJson)) {
+				try {
+					Map<String, Object> paramMap = JacksonUtil.toMap(paramJson);
+					if (BeanUtils.isNotEmpty(paramMap)){
+						params.putAll(paramMap);
+					}
+				} catch (Exception ignore) {
 				}
-			} catch (Exception ignore) {
 			}
 		}
 

+ 3 - 0
ibps-message-producer-root/modules/message-core/src/main/java/com/lc/ibps/cloud/mq/core/constants/QueueConstants.java

@@ -16,6 +16,9 @@ public interface QueueConstants {
 		public static final String EXCHANGE_MESSAGE = "ibps.exchange.message";
 		public static final String ROUTING_KEY_MESSAGE = "ibps.routing.key.message";
 		public static final String QUEUE_NAME = "ibps.queue.message";
+
+		public static final String ROUTING_KEY_MESSAGE_SNAPSHOT = "ibps.routing.key.message.snapshot";
+		public static final String QUEUE_NAME_SNAPSHOT = "ibps.queue.message.snapshot";
 	}
 	
 	public static class Command {

+ 8 - 1
ibps-provider-root/modules/provider-platform/src/main/java/com/lc/ibps/config/InitialConfigure.java

@@ -1,10 +1,17 @@
 package com.lc.ibps.config;
 
+import com.lc.ibps.cloud.mq.consumer.api.consumer.IQueueConsumer;
+import com.lc.ibps.cloud.mq.core.model.DefaultMessage;
+import com.lc.ibps.mq.consumer.rabbit.RabbitSnapshotMessageQueueConsumer;
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
 import com.lc.ibps.cloud.config.AbstractInitialConfigure;
 
 @Configuration("platformInitialConfigure")
 public class InitialConfigure extends AbstractInitialConfigure {
-
+	@Bean
+	public RabbitSnapshotMessageQueueConsumer rabbitSnapshotMessageQueueConsumer() {
+		return new RabbitSnapshotMessageQueueConsumer();
+	}
 }

+ 139 - 0
ibps-provider-root/modules/provider-platform/src/main/java/com/lc/ibps/mq/consumer/rabbit/RabbitSnapshotMessageQueueConsumer.java

@@ -0,0 +1,139 @@
+package com.lc.ibps.mq.consumer.rabbit;
+
+import com.lc.ibps.base.core.constants.StringPool;
+import com.lc.ibps.base.core.util.BeanUtils;
+import com.lc.ibps.base.framework.table.ICommonDao;
+import com.lc.ibps.base.web.context.ContextUtil;
+import com.lc.ibps.cloud.entity.APIResult;
+import com.lc.ibps.cloud.file.provider.UploadProvider;
+import com.lc.ibps.cloud.mq.consumer.api.consumer.IQueueConsumer;
+import com.lc.ibps.cloud.mq.core.constants.QueueConstants;
+import com.lc.ibps.cloud.mq.core.model.Message;
+import com.lc.ibps.common.file.persistence.entity.AttachmentPo;
+import com.lc.ibps.org.party.persistence.entity.DefaultPartyUserPo;
+import com.lc.ibps.org.party.persistence.entity.PartyEmployeePo;
+import com.lc.ibps.org.party.persistence.entity.PartyEntityPo;
+import com.lc.ibps.org.party.repository.PartyEmployeeRepository;
+import com.lc.ibps.org.party.repository.PartyEntityRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.amqp.rabbit.annotation.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+
+import javax.annotation.Resource;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Map;
+
+@RabbitListener(bindings = {
+        @QueueBinding(
+                exchange = @Exchange(value = QueueConstants.Message.EXCHANGE_MESSAGE ),
+                key = QueueConstants.Message.ROUTING_KEY_MESSAGE_SNAPSHOT,
+                value = @Queue(value = QueueConstants.Message.QUEUE_NAME_SNAPSHOT)
+        )
+})
+public class RabbitSnapshotMessageQueueConsumer   {
+
+    private static Logger LOGGER = LoggerFactory.getLogger(RabbitSnapshotMessageQueueConsumer.class);
+    @Autowired
+    private UploadProvider uploadFile;
+
+    @Autowired
+    private ICommonDao<?> commonDao;
+
+    @Resource
+    private PartyEntityRepository partyEntityRepository;
+
+    @Autowired
+    protected PartyEmployeeRepository partyEmployeeRepository;
+
+    @Value("${runqian.server}")
+    protected String runqianServer;
+
+    @Value("${runqian.base-path}")
+    protected String runqianBasePath;
+
+    @RabbitHandler
+    public void popup(Message<String> message) throws Exception {
+        String instId = message.getVariables().get("instId").toString();
+        String userId = message.getVariables().get("userId").toString();
+        LOGGER.warn("processing snapshot with instId= " + instId);
+        Thread.sleep(10000);
+
+        /*
+        Step 1: fetch below sql by instId. if record returned, goto step 2,otherwise goto step 3.
+
+        select ti_jiao_kuai_zhao from t_lcidglbdbb
+        where tablekey_ = 'tsclb'  and gui_dang_lei_xing = 'process'
+        and  liu_cheng_xuan_ze = (select PROC_DEF_KEY_ from ibps_bpm_inst_his where id_ = '1166693885385113602' limit 1)
+
+        Step 2: check ti_jiao_kuai_zhao, if the value is yes, goto step 2.1, otherwise goto step 2.2
+        Step 2.1: call runQianUpload method to get generate pdf file.
+            //https://www.szjyxt.com/ibps/platform/v3/file/upload/runQianUpload?url=https:%2F%2Fwww.szjyxt.com%2Fdemo%2FreportServlet%3Faction%3D6%
+            26file%3D%25E9%2587%2591%25E9%2580%259A%25E5%258C%25BB%25E5%25AD%25A6%25E5%25AE%259E%25E9%25AA%258C%25E5%25AE%25A4%25E7%25AE%25A1%25E7%2590
+            %2586%25E7%25B3%25BB%25E7%25BB%259F%252F%25E6%258A%2595%25E8%25AF%2589%252F%25E6%258A%2595%25E8%25AF%2589%25E5%25A4%2584%25E7%2590%2586%25E8
+            %25A1%25A8.rpx%26print%3D1%26srcType%3Dfile%26paramString%3Did_%253D1166693885385113600%26org_%3D1136828146851512320&name=%E6%8A%95%E8%AF%89
+            %E5%A4%84%E7%90%86%E8%A1%A8202310251105&type=pdf
+            //uploadFile.runQianUpload()
+            and then update table t_tsclb with field: "shi_fou_guo_shen"="已完成"  "kuai_zhao_": "1166694051567632384"
+        Step 2.2: update table t_tsclb with field: "shi_fou_guo_shen"="已完成"
+
+        Step 3: waiting 10s and try it again.
+
+         */
+
+        Map<String, Object> hisMap = commonDao.queryOne("SELECT PROC_DEF_KEY_,BIZ_KEY_,PROC_DEF_NAME_ FROM ibps_bpm_inst_his WHERE id_ = '" + instId + "' ");
+
+        if (BeanUtils.isNotEmpty(hisMap)){
+
+            Map<String, Object> kzMap = commonDao.queryOne(" SELECT ti_jiao_kuai_zhao,bao_biao_lu_jing_,tablekey_ FROM t_lcidglbdbb " +
+                "where liu_cheng_xuan_ze = '" + hisMap.get("PROC_DEF_KEY_") + "' AND gui_dang_lei_xing = 'process'");
+            APIResult<AttachmentPo> result = new APIResult<>();
+
+            if (BeanUtils.isNotEmpty(kzMap.get("ti_jiao_kuai_zhao")) && "是".equals(kzMap.get("ti_jiao_kuai_zhao"))) {
+                PartyEmployeePo employeePo = partyEmployeeRepository.get(userId);
+                String position = employeePo.getPositions().split(",")[0];
+                PartyEntityPo entityPo = partyEntityRepository.get(position);
+                String org = entityPo.getPath().split("\\.")[0];
+                String reportPath = "金通医学实验室管理系统/" + kzMap.get("bao_biao_lu_jing_");
+
+                String baseUrl = runqianServer + runqianBasePath + "/reportServlet?action=6&file=";
+                reportPath = URLEncoder.encode(reportPath, "UTF-8");
+                String url = baseUrl + reportPath + "&print=1&srcType=file&paramString=id_%3D" + hisMap.get("BIZ_KEY_") + "&org_=" + org;
+                String formattedTime = new SimpleDateFormat("yyyyMMddHHmm").format(new Date());
+                String name = hisMap.get("PROC_DEF_NAME_") + formattedTime ;
+
+                DefaultPartyUserPo user = new DefaultPartyUserPo();
+                user.setUserId(userId);
+                user.setFullname(employeePo.getName());
+                user.setAccount(employeePo.getAccount());
+                ContextUtil.setCurrentUser(user);
+
+                result = uploadFile.runQianUpload(url , name , StringPool.FileType.Office.PDF );
+
+            }
+            StringBuilder sql = new StringBuilder();
+            if (BeanUtils.isNotEmpty(kzMap)) {
+                sql.append("update t_").append(kzMap.get("tablekey_")).append(" set shi_fou_guo_shen_ = '已完成' ");
+                if (result.getState() == 200 && BeanUtils.isNotEmpty(result.getData())) {
+                    sql.append(" , kuai_zhao_ = '").append(result.getData().getId()).append("' ");
+                    LOGGER.warn("Generated Snapshot ID=" + result.getData().getId());
+                }
+                sql.append(" where id_ = '").append(hisMap.get("BIZ_KEY_")).append("' ");
+                commonDao.execute(sql.toString());
+            }
+
+        } else{
+            LOGGER.warn("can't find any record. it will be tried it again. instId=" +instId);
+            throw new Exception("can't find any record. it will be tried it again.");
+        }
+
+
+
+
+    }
+
+}