|
|
@@ -0,0 +1,89 @@
|
|
|
+package com.lc.ibps.platform.plan.job;
|
|
|
+
|
|
|
+import com.lc.ibps.api.base.model.User;
|
|
|
+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.JacksonUtil;
|
|
|
+import com.lc.ibps.base.framework.id.UniqueIdUtil;
|
|
|
+import com.lc.ibps.base.framework.table.ICommonDao;
|
|
|
+import com.lc.ibps.base.saas.token.ITenantTokenService;
|
|
|
+import com.lc.ibps.base.web.context.ContextUtil;
|
|
|
+import com.lc.ibps.bpmn.api.IBpmInstService;
|
|
|
+import com.lc.ibps.cloud.entity.APIResult;
|
|
|
+import com.lc.ibps.org.party.persistence.entity.DefaultPartyUserPo;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.quartz.JobDataMap;
|
|
|
+import org.quartz.JobExecutionContext;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+public class TenMinutesJob extends AbstractJob{
|
|
|
+
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(TenMinutesJob.class);
|
|
|
+ private ICommonDao<?> commonDao = AppUtil.getBean(ICommonDao.class);
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void executeJob(JobExecutionContext context) throws Exception {
|
|
|
+ JobDataMap dataMap = context.getMergedJobDataMap();
|
|
|
+ logger.warn("group={} job={} trigger={} is running.",
|
|
|
+ context.getJobDetail().getKey().getGroup(),
|
|
|
+ context.getJobDetail().getKey().getName(),
|
|
|
+ context.getTrigger().getKey().getName());
|
|
|
+ logger.warn("jobDataMap=is {}.", JacksonUtil.toJsonString(dataMap.getWrappedMap()));
|
|
|
+
|
|
|
+ // 开启 员工建议调查表 流程
|
|
|
+ startYgjydcbFlow();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void startYgjydcbFlow() throws Exception {
|
|
|
+ String fetchSql = "SELECT *from t_ygjydcbz WHERE shi_fou_guo_shen_='未开始' and DATE_FORMAT(diao_cha_shi_jian,'%Y-%m-%d')=CURRENT_DATE";
|
|
|
+ List<Map<String, Object>> list = (List<Map<String, Object>>) commonDao.query(fetchSql);
|
|
|
+ if (BeanUtils.isEmpty(list)) return;
|
|
|
+ IBpmInstService bpmInstService = AppUtil.getBean(IBpmInstService.class);
|
|
|
+ for (Map<String, Object> map : list) {
|
|
|
+ if (BeanUtils.isEmpty(map.get("diao_cha_ren_yuan")))continue;
|
|
|
+ String[] ids = map.get("diao_cha_ren_yuan").toString().split(",");
|
|
|
+ for (String bian_zhi_ren_ : ids) {
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String formattedNow = LocalDateTime.now().format(formatter);
|
|
|
+ Map<String, Object> data = new HashMap<>();
|
|
|
+ String id = UniqueIdUtil.getId();
|
|
|
+ data.put("id_", id);
|
|
|
+ data.put("parent_id_",map.get("id_"));
|
|
|
+ data.put("di_dian_",map.get("di_dian_"));
|
|
|
+ data.put("bian_zhi_bu_men_",map.get("bian_zhi_bu_men_"));
|
|
|
+ data.put("bian_zhi_ren_",bian_zhi_ren_);
|
|
|
+ data.put("create_by_",bian_zhi_ren_);
|
|
|
+ data.put("bian_zhi_shi_jian", formattedNow);
|
|
|
+ commonDao.execute(buildInsertSql(data,"t_ygjydcb"));
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(ContextUtil.getCurrentAccessToken())) {
|
|
|
+ ITenantTokenService tenantTokenService = AppUtil.getBean(ITenantTokenService.class);
|
|
|
+ String accessToken = tenantTokenService.getAccessToken();
|
|
|
+ ContextUtil.setCurrentAccessToken(accessToken);
|
|
|
+ }
|
|
|
+ APIResult<String> result = bpmInstService.startFlowFromList(new String[]{id}, "ygjydcb","Process_1kegx84", StringPool.TRUE);
|
|
|
+ if (result.getState()==200){
|
|
|
+ String updSql = "update t_ygjydcbz set shi_fou_guo_shen_='调查中' where id_ ='"+id+"'";
|
|
|
+ commonDao.execute(updSql);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String idString = list.stream()
|
|
|
+ .map(map -> map.get("id_"))
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .map(Object::toString)
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
+ String updSql = "update t_ygjydcbz set shi_fou_guo_shen_='调查中' where id_ in ("+idString+")";
|
|
|
+ commonDao.execute(updSql);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|