|
|
@@ -0,0 +1,134 @@
|
|
|
+package com.lc.ibps.platform.plan.job;
|
|
|
+
|
|
|
+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.core.util.string.StringUtil;
|
|
|
+import com.lc.ibps.base.framework.id.UniqueIdUtil;
|
|
|
+import com.lc.ibps.base.framework.table.ICommonDao;
|
|
|
+import com.lc.ibps.components.quartz.BaseJob2;
|
|
|
+import org.quartz.JobDataMap;
|
|
|
+import org.quartz.JobExecutionContext;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author gaozl
|
|
|
+ */
|
|
|
+public class AddNoFlowDataJob extends BaseJob2 {
|
|
|
+
|
|
|
+ public static final String PLAN_DATE = "plan-date";
|
|
|
+
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(AddNoFlowDataJob.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()));
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
|
+ String planDateParam = dataMap.getString(PLAN_DATE);
|
|
|
+ if(StringUtil.isNotBlank(planDateParam)){
|
|
|
+ localDate = LocalDate.parse(planDateParam);
|
|
|
+ }
|
|
|
+ String planDate = localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+
|
|
|
+ ICommonDao<?> commonDao = AppUtil.getBean(ICommonDao.class);
|
|
|
+
|
|
|
+ List<Map<String, Object>> list = (List<Map<String, Object>>) commonDao.query(" select yi_wang_shu_ju_,wen_jian_ming_,bao_biao_lu_jing_,ye_wu_biao_ming_ from t_wlcsckzpzb ");
|
|
|
+
|
|
|
+ for (Map<String, Object> map : list){
|
|
|
+
|
|
|
+ String tableName = map.get("ye_wu_biao_ming_").toString();
|
|
|
+ String prefix = map.get("wen_jian_ming_").toString();
|
|
|
+ String url = map.get("bao_biao_lu_jing_").toString();
|
|
|
+ String yi_wang_shu_ju_ =map.get("yi_wang_shu_ju_").toString();
|
|
|
+
|
|
|
+ String sql = "";
|
|
|
+ if ("1".equals(yi_wang_shu_ju_)){
|
|
|
+ sql = " SELECT " +
|
|
|
+ " b.id_ biz_key_, " +
|
|
|
+ " b.bian_zhi_ren_, " +
|
|
|
+ " b.create_time_, " +
|
|
|
+ " b.update_time_, " +
|
|
|
+ " e.id_ user_id_, " +
|
|
|
+ " e.name_ user_name_, " +
|
|
|
+ " u.account_ , " +
|
|
|
+ " e1.position_id_, " +
|
|
|
+ " SUBSTRING_INDEX(p.PATH_,'.', 1) AS org_id_ " +
|
|
|
+ "FROM " +
|
|
|
+ " t_mraqjcjlb b " +
|
|
|
+ " LEFT JOIN ibps_party_employee e ON e.id_ = b.bian_zhi_ren_ " +
|
|
|
+ " LEFT JOIN ibps_party_user u ON e.id_ = u.id_ " +
|
|
|
+ " LEFT JOIN (SELECT id_, SUBSTRING_INDEX(POSITIONS_, ',', 1) AS position_id_ FROM ibps_party_employee) e1 ON e.id_ = e1.id_ " +
|
|
|
+ " LEFT JOIN ibps_party_entity p ON e1.position_id_ = p.id_ " +
|
|
|
+ " where b.shi_fou_guo_shen_='已完成' ";
|
|
|
+ }else {
|
|
|
+ sql = " SELECT " +
|
|
|
+ " b.id_ biz_key_, " +
|
|
|
+ " b.bian_zhi_ren_, " +
|
|
|
+ " b.create_time_, " +
|
|
|
+ " b.update_time_, " +
|
|
|
+ " e.id_ user_id_, " +
|
|
|
+ " e.name_ user_name_, " +
|
|
|
+ " u.account_, " +
|
|
|
+ " e1.position_id_, " +
|
|
|
+ " SUBSTRING_INDEX(p.PATH_,'.', 1) AS org_id_ " +
|
|
|
+ "FROM " +
|
|
|
+ " t_mraqjcjlb b " +
|
|
|
+ " LEFT JOIN ibps_party_employee e ON e.id_ = b.bian_zhi_ren_ " +
|
|
|
+ " LEFT JOIN ibps_party_user u ON e.id_ = u.id_ " +
|
|
|
+ " LEFT JOIN (SELECT id_, SUBSTRING_INDEX(POSITIONS_, ',', 1) AS position_id_ FROM ibps_party_employee) e1 ON e.id_ = e1.id_ " +
|
|
|
+ " LEFT JOIN ibps_party_entity p ON e1.position_id_ = p.id_ " +
|
|
|
+ "WHERE " +
|
|
|
+ " date_format( b.create_time_, '%Y-%m-%d' )= CURRENT_DATE " +
|
|
|
+ " OR date_format( b.update_time_, '%Y-%m-%d' )= CURRENT_DATE " +
|
|
|
+ " and b.shi_fou_guo_shen_='已完成' ";
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> boList = (List<Map<String, Object>>) commonDao.query(sql);
|
|
|
+
|
|
|
+ if (BeanUtils.isNotEmpty(boList)) {
|
|
|
+ int error = 0;
|
|
|
+ logger.warn("添加无流程快照数据总数:{}, 业务表名=={}", boList.size(), prefix +":"+tableName);
|
|
|
+ for (Map<String, Object> boMap : boList){
|
|
|
+ boMap.put("bo_code_", tableName);
|
|
|
+ boMap.put("proc_def_name_", prefix);
|
|
|
+ boMap.put("bao_biao_lu_jing_", url);
|
|
|
+ boMap.put("id_", UniqueIdUtil.getId());
|
|
|
+ boMap.put("end_time_", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((BeanUtils.isEmpty(boMap.get("update_time_"))?boMap.get("create_time_"):boMap.get("update_time_"))));
|
|
|
+ boMap.put("create_time_", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
+ boMap.put("update_time_", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
+
|
|
|
+ try{
|
|
|
+ commonDao.execute(this.buildInsertSql(boMap,"t_bckzsjb"));
|
|
|
+ }catch (Exception e){
|
|
|
+ error = error + 1;
|
|
|
+ logger.error("无流程快照数据插入异常:{}",boMap);
|
|
|
+ e.printStackTrace();
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String msg = "无流程快照数据添加f_gen_snapshot表异常数:"+error;
|
|
|
+ logger.warn(msg);
|
|
|
+ if (error>0){
|
|
|
+ throw new Exception(msg);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ logger.warn("未查询到无流程补充快照的数据");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|