Преглед изворни кода

[task-3214] 【后端】提供一个新的接口,去修改ibps_bpm_approval_his表中的时间戳信息,并生成新的快照

Li Yuan пре 1 година
родитељ
комит
0a1f758b76

+ 22 - 0
ibps-provider-root/modules/provider-platform/src/main/java/com/lc/ibps/platform/api/IPlatformPatchService.java

@@ -0,0 +1,22 @@
+package com.lc.ibps.platform.api;
+
+import com.lc.ibps.bpmn.persistence.entity.BpmApprovePo;
+import com.lc.ibps.cloud.entity.APIResult;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.validation.Valid;
+import java.util.List;
+
+@Validated
+@RequestMapping(value = "/platform/patch")
+@RestController
+public interface IPlatformPatchService {
+
+    @RequestMapping(value = "/changCompleteTime", method = RequestMethod.POST)
+    public APIResult<Void> changCompleteTime(
+            @RequestBody(required = true)  @Valid List<BpmApprovePo> approvals);
+}

+ 3 - 61
ibps-provider-root/modules/provider-platform/src/main/java/com/lc/ibps/platform/plan/job/ReplenishSnapshotJob.java

@@ -13,6 +13,7 @@ import com.lc.ibps.components.quartz.BaseJob2;
 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.platform.service.PatchService;
 import org.quartz.JobDataMap;
 import org.quartz.JobExecutionContext;
 import org.slf4j.Logger;
@@ -38,67 +39,8 @@ public class ReplenishSnapshotJob extends BaseJob2 {
                 context.getJobDetail().getKey().getGroup(),
                 context.getJobDetail().getKey().getName(),
                 context.getTrigger().getKey().getName());
-
-        ICommonDao<?> commonDao = AppUtil.getBean(ICommonDao.class);
-        UploadProvider uploadFile = AppUtil.getBean(UploadProvider.class);
-        String runqianServer = EnvUtil.getProperty("runqian.server", "");
-        String runqianBasePath = EnvUtil.getProperty("runqian.base-path", "");
-        String sql = " select id_,biz_key_,proc_def_name_,bao_biao_lu_jing_,user_id_,user_name_,account_,end_time_,bo_code_,org_id_ from t_bckzsjb " +
-                     " where date_format(create_time_,'%Y-%m-%d')=current_date and  status_='0' and retry_<3 ";
-        @SuppressWarnings("unchecked")
-        List<Map<String, Object>> list = (List<Map<String, Object>>) commonDao.query(sql);
-        if (BeanUtils.isNotEmpty(list)) {
-            logger.warn("补充快照查询数据总数:{}", list.size());
-            int success = 0;int error = 0;
-            for (Map<String, Object> map : list){
-                APIResult<AttachmentPo> result = new APIResult<>();
-                String id = map.get("id_").toString();
-                String userId = map.get("user_id_").toString();
-                String bizKey = map.get("biz_key_").toString();
-                String boCode = map.get("bo_code_").toString();
-                String org = map.get("org_id_").toString();
-                String userName = map.get("user_name_").toString();
-                String account = map.get("account_").toString();
-                try{
-                    String reportPath = "金通医学实验室管理系统/" + map.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" + bizKey + "&org_=" + org;
-                    LocalDateTime dateTime = LocalDateTime.parse(map.get("end_time_").toString(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
-                    String name = map.get("proc_def_name_") + dateTime.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
-
-                    DefaultPartyUserPo user = new DefaultPartyUserPo();
-                    user.setUserId(userId);
-                    user.setFullname(userName);
-                    user.setAccount(account);
-                    ContextUtil.setCurrentUser(user);
-
-                    result = uploadFile.runQianUpload(url , name , StringPool.FileType.Office.PDF );
-
-                    if (result.getState() == 200 && BeanUtils.isNotEmpty(result.getData())) {
-                        String kuaiZhaoId = result.getData().getId();
-                        commonDao.execute("update "+boCode+" set kuai_zhao_='"+kuaiZhaoId+"' where id_='"+bizKey+"' ");
-
-                        commonDao.execute("update t_bckzsjb set status_='1',kuai_zhao_='"+kuaiZhaoId+"' where id_='"+id+"'");
-
-                        logger.warn("Generated Snapshot Success kuaiZhaoId={},id={}" + kuaiZhaoId,id );
-                        success = success + 1;
-                    }
-                }catch (Exception e){
-                    commonDao.execute("update t_bckzsjb set retry_=retry_+1,msg_='"+e.getMessage() +"' where id_='"+id+"'");
-                    error = error + 1;
-                    logger.error("补充快照异常,异常数据id:{} with error message {}",id,e.getMessage());
-                }
-
-            }
-            String msg = "补充快照成功数:"+success+",补充快照异常数:"+error;
-            logger.warn(msg);
-            if (error>0){
-                throw new Exception(msg);
-            }
-        }else {
-            logger.warn("未查询到需要补充快照的数据");
-        }
+        PatchService patchService = AppUtil.getBean(PatchService.class);
+        patchService.replenishSnapshot();
 
     }
 

+ 32 - 0
ibps-provider-root/modules/provider-platform/src/main/java/com/lc/ibps/platform/provider/PlatformPatchProvider.java

@@ -0,0 +1,32 @@
+package com.lc.ibps.platform.provider;
+
+import com.lc.ibps.bpmn.persistence.entity.BpmApprovePo;
+import com.lc.ibps.cloud.entity.APIResult;
+import com.lc.ibps.cloud.provider.GenericProvider;
+import com.lc.ibps.platform.api.IPlatformPatchService;
+import com.lc.ibps.platform.service.PatchService;
+import io.swagger.annotations.Api;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Api(tags = "平台打补丁", value = "平台打补丁")
+@Service
+public class PlatformPatchProvider extends GenericProvider implements IPlatformPatchService {
+    private static final Logger logger = LoggerFactory.getLogger(PlatformPatchProvider.class);
+    @Autowired
+    private PatchService patchService;
+    @Override
+    public APIResult<Void> changCompleteTime(List<BpmApprovePo> approvals) {
+        patchService.changCompleteTime(approvals);
+        try {
+            patchService.replenishSnapshotAsync();
+        } catch (Exception e) {
+            logger.error(e.getMessage(),e);
+        }
+        return null;
+    }
+}

+ 133 - 0
ibps-provider-root/modules/provider-platform/src/main/java/com/lc/ibps/platform/service/PatchService.java

@@ -0,0 +1,133 @@
+package com.lc.ibps.platform.service;
+
+import com.lc.ibps.base.core.constants.StringPool;
+import com.lc.ibps.base.core.util.AppUtil;
+import com.lc.ibps.base.core.util.BeanUtils;
+import com.lc.ibps.base.core.util.Collections;
+import com.lc.ibps.base.core.util.EnvUtil;
+import com.lc.ibps.base.framework.table.ICommonDao;
+import com.lc.ibps.base.web.context.ContextUtil;
+import com.lc.ibps.bpmn.api.cmd.TaskFinishCmd;
+import com.lc.ibps.bpmn.persistence.entity.BpmApprovePo;
+import com.lc.ibps.cloud.entity.APIResult;
+import com.lc.ibps.cloud.file.provider.UploadProvider;
+import com.lc.ibps.common.file.persistence.entity.AttachmentPo;
+import com.lc.ibps.org.party.persistence.entity.DefaultPartyUserPo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.scheduling.annotation.AsyncResult;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.net.URLEncoder;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Future;
+
+@Service
+public class PatchService {
+
+    private static final Logger logger = LoggerFactory.getLogger(PatchService.class);
+
+    @Resource
+    private ICommonDao<?> commonDao;
+    @Autowired
+    private UploadProvider uploadFile;
+
+    public  void changCompleteTime(List<BpmApprovePo> approvals){
+        if(Collections.isEmpty(approvals)) return;
+        String bizKey;
+        String boCode;
+        String kuaiZhao;
+        for (BpmApprovePo po :approvals) {
+            String procInstId = po.getProcInstId();
+            List<Map<String, Object>> query = (List<Map<String, Object>>) commonDao.query("SELECT h.biz_key_ bizKey,CONCAT('t_',f.BO_CODE_) AS boCode FROM ibps_bpm_inst_his h,ibps_bpm_def f \n" +
+                    "    WHERE f.bpmn_def_id_ = h.bpmn_def_id_  AND h.id_ =#{p0}", new String[]{procInstId});
+
+            if(Collections.isNotEmpty(query)){
+                bizKey = (String)query.get(0).get("bizKey");
+                boCode = (String)query.get(0).get("boCode");
+                List<Map<String, Object>> query1 = (List<Map<String, Object>>)commonDao.query("SELECT kuai_zhao_ kuaiZhao FROM " + boCode + " WHERE id_=#{p0}", new String[]{bizKey});
+
+                if(Collections.isNotEmpty(query1)){
+                    kuaiZhao = (String)query1.get(0).get("kuaiZhao");
+                    break;
+                }
+            }
+//                commonDao.execute("update ibps_bpm_approval_his set COMPLETE_TIME_='1',CREATE_TIME_='"+kuaiZhaoId+"' where id_='"+id+"'");
+        }
+
+
+
+    }
+    @Async(value = "addAllApiExecutor")
+    public Future<Void> replenishSnapshotAsync() throws Exception {
+        replenishSnapshot();
+        return new AsyncResult<Void>(null);
+    }
+    public void replenishSnapshot() throws Exception {
+
+        String runqianServer = EnvUtil.getProperty("runqian.server", "");
+        String runqianBasePath = EnvUtil.getProperty("runqian.base-path", "");
+        String sql = " select id_,biz_key_,proc_def_name_,bao_biao_lu_jing_,user_id_,user_name_,account_,end_time_,bo_code_,org_id_ from t_bckzsjb " +
+                " where date_format(create_time_,'%Y-%m-%d')=current_date and  status_='0' and retry_<3 ";
+        @SuppressWarnings("unchecked")
+        List<Map<String, Object>> list = (List<Map<String, Object>>) commonDao.query(sql);
+        if (BeanUtils.isNotEmpty(list)) {
+            logger.warn("补充快照查询数据总数:{}", list.size());
+            int success = 0;int error = 0;
+            for (Map<String, Object> map : list){
+                APIResult<AttachmentPo> result = null;
+                String id = map.get("id_").toString();
+                String userId = map.get("user_id_").toString();
+                String bizKey = map.get("biz_key_").toString();
+                String boCode = map.get("bo_code_").toString();
+                String org = map.get("org_id_").toString();
+                String userName = map.get("user_name_").toString();
+                String account = map.get("account_").toString();
+                try{
+                    String reportPath = "金通医学实验室管理系统/" + map.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" + bizKey + "&org_=" + org;
+                    LocalDateTime dateTime = LocalDateTime.parse(map.get("end_time_").toString(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+                    String name = map.get("proc_def_name_") + dateTime.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
+
+                    DefaultPartyUserPo user = new DefaultPartyUserPo();
+                    user.setUserId(userId);
+                    user.setFullname(userName);
+                    user.setAccount(account);
+                    ContextUtil.setCurrentUser(user);
+
+                    result = uploadFile.runQianUpload(url , name , StringPool.FileType.Office.PDF );
+
+                    if (result.getState() == 200 && BeanUtils.isNotEmpty(result.getData())) {
+                        String kuaiZhaoId = result.getData().getId();
+                        commonDao.execute("update "+boCode+" set kuai_zhao_='"+kuaiZhaoId+"' where id_='"+bizKey+"' ");
+
+                        commonDao.execute("update t_bckzsjb set status_='1',kuai_zhao_='"+kuaiZhaoId+"' where id_='"+id+"'");
+
+                        logger.warn("Generated Snapshot Success kuaiZhaoId={},id={}" + kuaiZhaoId,id );
+                        success = success + 1;
+                    }
+                }catch (Exception e){
+                    commonDao.execute("update t_bckzsjb set retry_=retry_+1,msg_='"+e.getMessage() +"' where id_='"+id+"'");
+                    error = error + 1;
+                    logger.error("补充快照异常,异常数据id:{} with error message {}",id,e.getMessage());
+                }
+
+            }
+            String msg = "补充快照成功数:"+success+",补充快照异常数:"+error;
+            logger.warn(msg);
+            if (error>0){
+                throw new Exception(msg);
+            }
+        }else {
+            logger.warn("未查询到需要补充快照的数据");
+        }
+    }
+}