Browse Source

服务方和供应商调查计划, 供应商评价考核评审 推送

xiexh 8 tháng trước cách đây
mục cha
commit
6d272f790a

+ 101 - 0
ibps-provider-root/modules/provider-platform/src/main/java/com/lc/ibps/platform/plan/job/TenMinutesJob.java

@@ -66,7 +66,108 @@ public class TenMinutesJob extends AbstractJob{
         } catch (Exception e) {
             logger.error("执行手工染色法与仪器染色法比对列表流程时发生异常", e);
         }
+        //任务3 服务方和供应商调查计划表推送
+        try {
+            startFwfhgysdcjhbFlow();
+        } catch (Exception e) {
+            logger.error("执行服务方和供应商调查计划表流程时发生异常", e);
+        }
+    }
+
+    private void startFwfhgysdcjhbFlow() throws Exception {
+        //1.0 业务处理,推送未来一个月内数据 flag_ =1 为未推送过
+        String fetchSql = "SELECT * FROM t_fwfhgysdcjhb WHERE shi_fou_guo_shen_='已完成' and flag_='1'";
+        List<Map<String, Object>> qryList = (List<Map<String, Object>>) commonDao.query(fetchSql);
+        if(BeanUtils.isEmpty(qryList))return;
+        for (Map data : qryList){
+            //子表id集合
+            List<String> zbIds = new ArrayList<>();
+
+            String fetchzbSql = "select * from t_fwfhgysdcjhzb where parent_id_ ='"+data.get("id_")+"'";
+            List<Map<String, Object>> zbDatas = (List<Map<String, Object>>) commonDao.query(fetchzbSql);
+            if(BeanUtils.isEmpty(zbDatas)){
+                return;
+            }
+            //推送的数据id集合
+            ArrayList<String> pushIds = new ArrayList<>();
+            for(Map zbdata : zbDatas){
+                insertGyspj(zbdata,zbIds,pushIds);
+            }
+            //ids=存在日期大于当前日期一个月的数据id,ids等于0表示主表的数据已经全部推送,需要更新主表推送标志为2
+            if(zbIds.size()==0){
+                //更新t_fwfhgysdcjhb数据为已处理
+                commonDao.execute("update t_fwfhgysdcjhb set flag_='2' where id_ ='"+data.get("id_")+"'");
+            }
+            //2.0 流程推送
+            startYmWorkflow(pushIds,"gyspj","Process_0mn0evg");
+            logger.warn("执行startFwfhgysdcjhbFlow sucess");
+        }
     }
+
+
+    private void insertGyspj(Map zbdata, List<String> ids , List<String> pushIds) throws Exception {
+        // 检查 ni_wan_cheng_ri_q 是否在未来一个月内
+        String niWanChengRiQ = zbdata.get("ni_wan_cheng_ri_q").toString();
+
+        // 解析日期字符串(格式:2025-08-18)
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Date targetDate = sdf.parse(niWanChengRiQ);
+
+        // 计算当前日期和一个月后的日期
+        Calendar calendar = Calendar.getInstance();
+        calendar.add(Calendar.MONTH, 1); // 一个月后的日期
+        Date oneMonthLater = calendar.getTime();
+
+        // 如果目标日期 <= 一个月后,并且没有插入过 才执行插入
+        if (targetDate.compareTo(oneMonthLater) <= 0
+                && BeanUtils.isEmpty(zbdata.get("flag_zi_"))) {
+            // 深拷贝值
+            Map<String, Object> data = new HashMap<>();
+            String id = UniqueIdUtil.getId();
+
+            data.put("id_", id);
+            data.put("bian_zhi_ren_", zbdata.get("diao_cha_ren_"));
+            data.put("gong_ying_shang_m", zbdata.get("chang_shang_"));
+            data.put("gong_ying_shang_l", zbdata.get("gong_ying_pin_"));
+            data.put("lei_xing_", zbdata.get("id_")); // 用作逻辑关联
+            data.put("cao_zuo_lei_xing_", "评价");
+
+            //存在多个部门,有主部门则赋值主部门,没有配置主部门默认多个里面选一个
+            String deptSql = "select POSITIONS_ from ibps_party_employee where id_ = '" + zbdata.get("diao_cha_ren_") + "'";
+            List<Map<String, Object>> deptData = (List<Map<String, Object>>) commonDao.query(deptSql);
+            if (BeanUtils.isNotEmpty(deptData)) {
+                String[] positions = deptData.get(0).get("POSITIONS_").toString().split(",");
+                if(positions.length==1){
+                    data.put("bian_zhi_bu_men_", positions[0]);
+                }else{
+                    String sql = "select MAIN_PID_ from ibps_party_rel where MAIN_TYPE_='position' and SUB_PID_='"+zbdata.get("diao_cha_ren_")+"' ";
+                    List<Map<String, Object>> mainDept = (List<Map<String, Object>>) commonDao.query(sql);
+                    if(BeanUtils.isNotEmpty(mainDept)){
+                        data.put("bian_zhi_bu_men_", mainDept);
+                    }else{
+                        data.put("bian_zhi_bu_men_", positions[0]);
+                    }
+                }
+            }
+
+            String bianZhiShiJian = niWanChengRiQ + " 06:00";
+            data.put("bian_zhi_shi_jian", bianZhiShiJian);
+
+            String currentTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
+            data.put("create_time_", currentTime);
+
+            commonDao.execute(buildInsertSql(data, "t_gyspj"));
+            //更新t_fwfhgysdcjhzb数据为已处理
+            commonDao.execute("update t_fwfhgysdcjhzb set flag_zi_='1' where id_ ='"+zbdata.get("id_")+"'");
+
+            pushIds.add(id);
+        } else if(BeanUtils.isEmpty(zbdata.get("flag_zi_"))){//存在没有插入的数据
+            ids.add(zbdata.get("id_").toString());
+        }else{
+            //已经处理过的数据
+        }
+    }
+
     public void startPersonnelComparisonFlow(String tableName, String zbTableName) throws Exception {
         //1.0业务处理,只推送比对日期为当日且未推送过的数据
         String fetchSql = "select * FROM "+tableName+" where type='startRecord' and DATE_FORMAT(bi_dui_ri_qi_,'%Y-%m-%d')=CURRENT_DATE and (flag_ is null or flag_=0)";