From 539cf47101f96f96d038377d5187042c9bc49c76 Mon Sep 17 00:00:00 2001 From: yuezhihang Date: Fri, 29 Oct 2021 14:02:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E5=8D=95=20=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E5=9B=9E=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../da/FeignClient/workFlowFeignClient.java | 3 + .../java/com/adc/da/Timer/ProcessTimer.java | 58 +++++++++++++++---- .../controller/WorkFlowController.java | 10 ++++ 3 files changed, 61 insertions(+), 10 deletions(-) diff --git a/adc-da-activiti/src/main/java/com/adc/da/FeignClient/workFlowFeignClient.java b/adc-da-activiti/src/main/java/com/adc/da/FeignClient/workFlowFeignClient.java index 70d5403e..e559943a 100644 --- a/adc-da-activiti/src/main/java/com/adc/da/FeignClient/workFlowFeignClient.java +++ b/adc-da-activiti/src/main/java/com/adc/da/FeignClient/workFlowFeignClient.java @@ -399,4 +399,7 @@ public interface workFlowFeignClient { // @RequestMapping(value = "/bat-wkflow/findProcessNameByPrcNum",method = RequestMethod.POST) // List findProcessNameByPrcNum(@RequestBody String taskId); + + @RequestMapping(value = "/bat-wkflow/datas/bus-process-new/everyDayTenOlock",method = RequestMethod.GET) + List everyDayTenOlock(); } diff --git a/adc-da-activiti/src/main/java/com/adc/da/Timer/ProcessTimer.java b/adc-da-activiti/src/main/java/com/adc/da/Timer/ProcessTimer.java index 9051d48a..fd53ccc8 100644 --- a/adc-da-activiti/src/main/java/com/adc/da/Timer/ProcessTimer.java +++ b/adc-da-activiti/src/main/java/com/adc/da/Timer/ProcessTimer.java @@ -1,10 +1,17 @@ package com.adc.da.Timer; import com.adc.da.FeignClient.workFlowFeignClient; +import com.adc.da.common.BusMes; import com.adc.da.common.BusProcessName; +import com.adc.da.common.BusProcessNew; +import com.adc.da.common.Wrapper; +import com.adc.da.http.ResponseMessage; import com.adc.da.sys.common.EmailUtils; import com.adc.da.sys.entity.UserEO; import com.adc.da.sys.service.IUserEOService; +import com.adc.da.workFlow.controller.WorkFlowController; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.EnableScheduling; @@ -13,6 +20,7 @@ import org.springframework.stereotype.Component; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -34,6 +42,9 @@ public class ProcessTimer { @Autowired private IUserEOService userEOService; + @Autowired + private WorkFlowController workFlowController; + /*** * @Description: 自动催办,任务截至时间前3天开始每天催办 * @Author: yangxuenan @@ -46,14 +57,14 @@ public class ProcessTimer { // @Scheduled(cron = "0/20 * * * * ?") public void urging() { List busProcessNames = workFlowFeignClient.queryBusProcessNameForEnd(null); - if(null != busProcessNames && 0 < busProcessNames.size()){ - for (BusProcessName busProcessName : busProcessNames){ + if (null != busProcessNames && 0 < busProcessNames.size()) { + for (BusProcessName busProcessName : busProcessNames) { String type = busProcessName.getPrcType(); Integer typeInt = 99; - if (StringUtils.isNotEmpty(type)){ + if (StringUtils.isNotEmpty(type)) { typeInt = Integer.valueOf(type); } - type = chooseType(typeInt,type); + type = chooseType(typeInt, type); UserEO userEO = userEOService.selectByPrimaryKey(busProcessName.getCreatUserName()); String[] array = userEO.getEmail().split(","); @@ -64,30 +75,30 @@ public class ProcessTimer { try { dateTime = simpleDateFormat.parse(overTime); Date now = new Date(); - long daysBetween = (dateTime.getTime()-now.getTime()+1000000)/(60*60*24*1000); + long daysBetween = (dateTime.getTime() - now.getTime() + 1000000) / (60 * 60 * 24 * 1000); num = Integer.valueOf(String.valueOf(daysBetween)); } catch (ParseException e) { SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'"); try { dateTime = simpleDateFormat1.parse(overTime); Date now = new Date(); - long daysBetween = (dateTime.getTime()-now.getTime()+1000000)/(60*60*24*1000); + long daysBetween = (dateTime.getTime() - now.getTime() + 1000000) / (60 * 60 * 24 * 1000); num = Integer.valueOf(String.valueOf(daysBetween)); } catch (ParseException e1) { e.getMessage(); } } - String msg = "您好,["+ busProcessName.getPrcNum() +"]-["+ busProcessName.getPrcName() +"] 您有待办任务未及时办理,距离截至日期还有["+ String.valueOf(num) +"]天 请及时办理,请登录全球标准法规管理系统 ( http://39.98.140.126:10005/#/login ) 办理:链接 ( http://39.98.140.126:10005/#/processCenter?tabsName=ProcessCenter ) 。\n" + + String msg = "您好,[" + busProcessName.getPrcNum() + "]-[" + busProcessName.getPrcName() + "] 您有待办任务未及时办理,距离截至日期还有[" + String.valueOf(num) + "]天 请及时办理,请登录全球标准法规管理系统 ( http://39.98.140.126:10005/#/login ) 办理:链接 ( http://39.98.140.126:10005/#/processCenter?tabsName=ProcessCenter ) 。\n" + " ——来自 全球标准法规管理系统"; - String title = "GSRM——【待办任务】["+ type +"] 您有未完成的待办任务"; - mailUtil.sendMsgFeign(array,title,msg); + String title = "GSRM——【待办任务】[" + type + "] 您有未完成的待办任务"; + mailUtil.sendMsgFeign(array, title, msg); } } } - public String chooseType(Integer typeInt,String type) { + public String chooseType(Integer typeInt, String type) { switch (typeInt) { case 1: type = "法规入库及评估流程"; @@ -151,4 +162,31 @@ public class ProcessTimer { } return type; } + + @Scheduled(cron = "0 0 10 * * ? ")//每天十点执行 +// @Scheduled(cron = "*/20 * * * * ? ")//每天十点执行 + public void everyDayTenOlockScan() { + List busProcessNews=new ArrayList<>(); + busProcessNews=workFlowFeignClient.everyDayTenOlock(); + if (!busProcessNews.isEmpty()){ + for (BusProcessNew bus:busProcessNews) { + JSONObject jsonObject= JSON.parseObject(bus.getMesg()); + jsonObject.put("auto","1"); + ResponseMessage responseMessage = workFlowController.startProcessNew("19",jsonObject.getString("revisionId"),null); + BusMes busMes=new BusMes(); + busMes.setTaskIds(String.valueOf(responseMessage.getData())); + busMes.setJson(jsonObject.toJSONString()); + busMes.setUserId(jsonObject.getString("revisionId")); + Wrapper wrapper=workFlowFeignClient.completeTaskByUserId(busMes); + System.out.println("dasda"); + } + } + } + + + public static void main(String[]args){ + ProcessTimer processTimer = new ProcessTimer(); + processTimer.everyDayTenOlockScan(); + } + } diff --git a/adc-da-activiti/src/main/java/com/adc/da/workFlow/controller/WorkFlowController.java b/adc-da-activiti/src/main/java/com/adc/da/workFlow/controller/WorkFlowController.java index d0efa9b9..2dd91c46 100644 --- a/adc-da-activiti/src/main/java/com/adc/da/workFlow/controller/WorkFlowController.java +++ b/adc-da-activiti/src/main/java/com/adc/da/workFlow/controller/WorkFlowController.java @@ -122,6 +122,16 @@ public class WorkFlowController { } } + @ApiOperation(value = "定时任务启动流程-以流程定义id") + @GetMapping("/startProcessNew") + public ResponseMessage startProcessNew(@RequestParam("type") String type, @RequestParam(value="userId",required = false) String userId, @RequestParam(value="id",required = false) String id){ + if(StringUtils.isNotBlank(type)){ + return this.activiti_define_start(ActDefineStartMap.actDefineStartMap(type), userId,id); + }else { + return null; + } + } + @ApiOperation(value = "待办任务详情") @GetMapping("/todotask") public PageInfo todotask(@RequestParam("userId") String userId, @RequestParam("pId") String pId){