|
|
@@ -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¶mString=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.");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|