|
|
@@ -1,8 +1,15 @@
|
|
|
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.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.components.quartz.BaseJob2;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.quartz.JobExecutionContext;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
@@ -17,32 +24,116 @@ public class RiskIdentificationJob extends BaseJob2 {
|
|
|
|
|
|
@Override
|
|
|
public void executeJob(JobExecutionContext context) throws Exception {
|
|
|
- //step1: update status
|
|
|
- updateStatusStep();
|
|
|
+ //step1: update status to 识别中
|
|
|
+ updateStatusToShibieStep();
|
|
|
//step2. add data to 降低风险项目登记表_子表(djbzb)
|
|
|
- addDateToDjbzbStep();
|
|
|
- //step3. start flow by djbzb id
|
|
|
+ addDataToDjbzbStep();
|
|
|
+ //step3. 风险改进记录表(bmfxgjjl)
|
|
|
+ addDataToBmfxgjjlStep();
|
|
|
+ //step4. update status to 改进中
|
|
|
+ updateStatusToGaijingStep();
|
|
|
+ //step5. start flow by djbzb id
|
|
|
startFlowStep();
|
|
|
}
|
|
|
|
|
|
+ private void updateStatusToGaijingStep() {
|
|
|
+
|
|
|
+ String fetchSql = "SELECT zong_id_ FROM t_fxssb WHERE zhuang_tai_='已识别'";
|
|
|
+
|
|
|
+ String fetchSql2 = "SELECT a.zong_id_ FROM t_fxssb a,t_fxsbpgb b,t_fxsbpgbzb c " +
|
|
|
+ " WHERE a.zong_id_= #{p0} AND a.zong_id_=b.zong_id_ AND a.zhuang_tai_='已识别' AND b.id_=c.parent_id_ " +
|
|
|
+ " AND feng_xian_ying_du='风险降低' AND c.id_ NOT IN (SELECT parent_id_ FROM t_bmfxgjjl)";
|
|
|
+ String execSql = "UPDATE t_fxssb SET zhuang_tai_='改进中' WHERE zong_id_=#{p0}";
|
|
|
+
|
|
|
+ List<Map<String, Object>> list = (List<Map<String, Object>>) commonDao.query(fetchSql);
|
|
|
+ if (BeanUtils.isEmpty(list)) return;
|
|
|
+ for (Map<String, Object> map : list) {
|
|
|
+ String[] zongIdS = {(String)map.get("zong_id_")};
|
|
|
+ List zong_id_ = (List<Map<String, Object>>)commonDao.query(fetchSql2, zongIdS);
|
|
|
+ if(BeanUtils.isEmpty(zong_id_)){
|
|
|
+ commonDao.execute(execSql,zongIdS);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void startFlowStep() {
|
|
|
+ String fetchSql = "SELECT id_ FROM t_bmfxgjjl WHERE shi_fou_guo_shen_ IS NULL";
|
|
|
+ List<Map<String, Object>> list = (List<Map<String, Object>>) commonDao.query(fetchSql);
|
|
|
+ if (BeanUtils.isEmpty(list)) return;
|
|
|
+ IBpmInstService bpmInstService = AppUtil.getBean(IBpmInstService.class);
|
|
|
+ if (StringUtils.isBlank(ContextUtil.getCurrentAccessToken())) {
|
|
|
+ ITenantTokenService tenantTokenService = AppUtil.getBean(ITenantTokenService.class);
|
|
|
+ String accessToken = tenantTokenService.getAccessToken();
|
|
|
+ ContextUtil.setCurrentAccessToken(accessToken);
|
|
|
+ }
|
|
|
+ for (Map<String, Object> objectMap : list) {
|
|
|
+
|
|
|
+ APIResult<String> result = bpmInstService.startFlowFromList(new String[]{(String)objectMap.get("id_")}, "bmfxgjjl", "Process_0jl7e02");
|
|
|
+ result.getState();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addDataToDjbzbStep() throws Exception {
|
|
|
+ //降低风险项目登记表_子表(djbzb)
|
|
|
+ String fetchSql = "SELECT c.id_ AS parent_id_,a.zong_id_,c.di_dian_,b.bian_zhi_ren_,b.bian_zhi_bu_men_,c.yao_su_tiao_kuan_, NOW() AS bian_zhi_shi_jian," +
|
|
|
+ " c.gong_zuo_huan_jie,c.gong_zuo_miao_shu,c.feng_xian_miao_sh,c.feng_xian_zhi_shu, b.bian_zhi_ren_ AS create_by_, NOW() AS create_time_" +
|
|
|
+ " FROM t_fxssb a,t_fxsbpgb b,t_fxsbpgbzb c " +
|
|
|
+ " WHERE a.zong_id_=b.zong_id_ AND a.zhuang_tai_='已识别' AND b.id_=c.parent_id_ AND feng_xian_ying_du='风险降低' " +
|
|
|
+ " AND c.id_ NOT IN (SELECT parent_id_ FROM t_Djbzb)";
|
|
|
+ List<Map<String, Object>> list = (List<Map<String, Object>>) commonDao.query(fetchSql);
|
|
|
+ if (BeanUtils.isEmpty(list)) return;
|
|
|
+ for (Map<String, Object> map : list) {
|
|
|
+ map.put("id_", UniqueIdUtil.getId());
|
|
|
+ }
|
|
|
+ generateRecords(list, "t_Djbzb");
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- private void addDateToDjbzbStep() {
|
|
|
- String fetchSql = "SELECT c.id_,a.zong_id_ AS parent_id_,c.di_dian_,b.bian_zhi_ren_,b.bian_zhi_bu_men_,c.yao_su_tiao_kuan_," +
|
|
|
- " c.gong_zuo_huan_jie,c.gong_zuo_miao_shu,c.feng_xian_miao_sh,c.feng_xian_zhi_shu " +
|
|
|
+ private void addDataToBmfxgjjlStep() throws Exception {
|
|
|
+ //风险改进记录表(bmfxgjjl)
|
|
|
+
|
|
|
+ String fetchSql = "SELECT c.id_ AS parent_id_,a.zong_id_,a.shi_wu_shuo_ming_,c.di_dian_,b.bian_zhi_ren_,b.bian_zhi_bu_men_,c.yao_su_tiao_kuan_,b.zu_chang_,b.zu_chang_id_, NOW() AS bian_zhi_shi_jian," +
|
|
|
+ " c.gong_zuo_huan_jie,c.gong_zuo_miao_shu,c.feng_xian_miao_sh,c.feng_xian_zhi_shu as yuan_zhi_shu_, b.bian_zhi_ren_ AS create_by_, NOW() AS create_time_" +
|
|
|
" FROM t_fxssb a,t_fxsbpgb b,t_fxsbpgbzb c " +
|
|
|
- " WHERE a.zong_id_=b.zong_id_ AND a.zhuang_tai_='已识别' AND b.id_=c.parent_id_ AND feng_xian_ying_du='风险降低'";
|
|
|
+ " WHERE a.zong_id_=b.zong_id_ AND a.zhuang_tai_='已识别' AND b.id_=c.parent_id_ AND feng_xian_ying_du='风险降低' " +
|
|
|
+ " AND c.id_ NOT IN (SELECT parent_id_ FROM t_bmfxgjjl)";
|
|
|
+ List<Map<String, Object>> list = (List<Map<String, Object>>) commonDao.query(fetchSql);
|
|
|
+ if (BeanUtils.isEmpty(list)) return ;
|
|
|
+ for (Map<String, Object> map : list) {
|
|
|
+ map.put("id_", UniqueIdUtil.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ generateRecords(list, "t_bmfxgjjl");
|
|
|
+ }
|
|
|
+
|
|
|
+ private void generateRecords(List<Map<String, Object>> list, String tableName) throws Exception {
|
|
|
+ int success = 0;
|
|
|
+ int error = 0;
|
|
|
+ for (Map<String, Object> map : list) {
|
|
|
+ try {
|
|
|
+ commonDao.execute(this.buildInsertSql(map, tableName));
|
|
|
+ success = success + 1;
|
|
|
+ } catch (Exception e) {
|
|
|
+ error = error + 1;
|
|
|
+ logger.error("添加数据异常,异常信息 {}", e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String msg = "添加数据正常数:" + success + ",添加数据异常数:" + error;
|
|
|
+ logger.warn(msg);
|
|
|
+ if (error > 0) {
|
|
|
+ throw new Exception(msg);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- private void updateStatusStep() {
|
|
|
+ private void updateStatusToShibieStep() {
|
|
|
String fetchSql = "SELECT id_ FROM t_fxssb a " +
|
|
|
" WHERE shi_fou_guo_shen_ = '已完成' AND zhuang_tai_ = '' AND zong_id_ NOT IN (" +
|
|
|
" SELECT zong_id_ FROM t_fxsbpgb WHERE shi_fou_guo_shen_ <>'已完成' )";
|
|
|
|
|
|
String execSql = "UPDATE t_fxssb SET zhuang_tai_='已识别' WHERE id_=#{id_}";
|
|
|
List<Map<String, Object>> list = (List<Map<String, Object>>) commonDao.query(fetchSql);
|
|
|
- commonDao.executeOfMaps(execSql,list);
|
|
|
+ commonDao.executeOfMaps(execSql, list);
|
|
|
|
|
|
}
|
|
|
}
|