Browse Source

培训定时任务公告提醒修复

wy 1 month ago
parent
commit
eadf39ceca

+ 68 - 8
ibps-provider-root/modules/provider-platform/src/main/java/com/lc/ibps/platform/plan/job/PersonnelTrainJob.java

@@ -5,6 +5,7 @@ import com.lc.ibps.base.core.util.AppUtil;
 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.web.context.ContextUtil;
 import com.lc.ibps.cloud.message.util.MessageQueueProductorUtil;
 import com.lc.ibps.common.api.INewsMgrService;
 import com.lc.ibps.common.system.persistence.entity.NewsPo;
@@ -12,6 +13,7 @@ import com.lc.ibps.components.quartz.BaseJob2;
 import com.lc.ibps.org.party.persistence.dao.PartyUserCalendarDao;
 import com.lc.ibps.org.party.persistence.entity.PartyUserCalendarPo;
 import com.lc.ibps.org.party.repository.PartyEmployeeRepository;
+import org.codehaus.jackson.map.ObjectMapper;
 import org.quartz.JobDataMap;
 import org.quartz.JobExecutionContext;
 import org.slf4j.Logger;
@@ -35,6 +37,16 @@ public class PersonnelTrainJob extends BaseJob2 {
 
     @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()));
+        String version = getPx();
+        String sql ="";
+        String tableName = "";
+        String fixSql = "";
         JobDataMap dataMap = context.getMergedJobDataMap();
         logger.warn("group={} job={} trigger={} is running.",
                 context.getJobDetail().getKey().getGroup(),
@@ -42,13 +54,27 @@ public class PersonnelTrainJob extends BaseJob2 {
                 context.getTrigger().getKey().getName());
         logger.warn("jobDataMap=is {}.", JacksonUtil.toJsonString(dataMap.getWrappedMap()));
 
-        String sql = "select p.id_,p.bian_zhi_ren_,e.name_,p.bian_zhi_bu_men_,d.name_ as dept_name_,p.pei_xun_nei_rong_," +
-                "date_format(p.pei_xun_shi_jian_,'%Y-%m-%d %H:%i') pei_xun_shi_jian_,date_format(p.pei_xun_jie_shu_s,'%Y-%m-%d %H:%i')  " +
-                " pei_xun_jie_shu_s,p.pei_xun_ren_yuan_,p.pei_xun_di_dian_,p.pei_xun_lao_shi_,p.di_dian_ from t_rypxcjb p " +
-                "left join ibps_party_employee e on e.id_=p.bian_zhi_ren_ " +
-                "left join ibps_party_position d on d.id_=p.bian_zhi_bu_men_ " +
-                "where shi_fou_guo_shen_ ='未发布' and pei_xun_shi_jian_ >=CURRENT_DATE " +
-                " and pei_xun_shi_jian_<=DATE_FORMAT(date_add(now(), interval 1 week),'%Y-%m-%d')";
+        if(BeanUtils.isNotEmpty(version) && "1".equals(version)){
+          sql = "select p.id_,p.bian_zhi_ren_,e.name_,p.bian_zhi_bu_men_,d.name_ as dept_name_,p.pei_xun_nei_rong_," +
+                    "date_format(p.pei_xun_shi_jian_,'%Y-%m-%d %H:%i') pei_xun_shi_jian_,date_format(p.pei_xun_jie_shu_s,'%Y-%m-%d %H:%i')  " +
+                    " pei_xun_jie_shu_s,p.pei_xun_ren_yuan_,p.pei_xun_di_dian_,p.pei_xun_lao_shi_,p.di_dian_ from t_lhrypxjlb p " +
+                    "left join ibps_party_employee e on e.id_=p.bian_zhi_ren_ " +
+                    "left join ibps_party_position d on d.id_=p.bian_zhi_bu_men_ " +
+                    "where pei_xun_zhuang_ta ='未发布' and pei_xun_shi_jian_ >=CURRENT_DATE " +
+                    " and pei_xun_shi_jian_<=DATE_FORMAT(date_add(now(), interval 1 week),'%Y-%m-%d') and (tui_song_biao_zhi <>'yes' or p.tui_song_biao_zhi is null)";
+            tableName = "t_lhrypxjlb";
+            fixSql =" ,tui_song_biao_zhi = 'yes' ";
+        }else{
+          sql = "select p.id_,p.bian_zhi_ren_,e.name_,p.bian_zhi_bu_men_,d.name_ as dept_name_,p.pei_xun_nei_rong_," +
+                    "date_format(p.pei_xun_shi_jian_,'%Y-%m-%d %H:%i') pei_xun_shi_jian_,date_format(p.pei_xun_jie_shu_s,'%Y-%m-%d %H:%i')  " +
+                    " pei_xun_jie_shu_s,p.pei_xun_ren_yuan_,p.pei_xun_di_dian_,p.pei_xun_lao_shi_,p.di_dian_ from t_rypxcjb p " +
+                    "left join ibps_party_employee e on e.id_=p.bian_zhi_ren_ " +
+                    "left join ibps_party_position d on d.id_=p.bian_zhi_bu_men_ " +
+                    "where shi_fou_guo_shen_ ='未发布' and pei_xun_shi_jian_ >=CURRENT_DATE " +
+                    " and pei_xun_shi_jian_<=DATE_FORMAT(date_add(now(), interval 1 week),'%Y-%m-%d')";
+            tableName = "t_rypxcjb";
+        }
+
         @SuppressWarnings("unchecked")
         List<Map<String, Object>> pxList = (List<Map<String, Object>>) commonDao.query(sql);
 
@@ -136,7 +162,7 @@ public class PersonnelTrainJob extends BaseJob2 {
                     newsPo.setUserName(userName);
                     newsPo.setType(didian);
                     newsMgrService.save(newsPo);
-                    commonDao.execute("update t_rypxcjb set shi_fou_guo_shen_='未开始' where id_= '"+id+"'");
+                    commonDao.execute("update " + tableName +" set shi_fou_guo_shen_='未开始' " + fixSql +" where id_= '"+id+"'");
                 }
             }
         }
@@ -178,4 +204,38 @@ public class PersonnelTrainJob extends BaseJob2 {
         calendarDao.create(calendarPo);
     }
 
+    public static HashMap<String, Object> getSetting(){
+        HashMap<String, Object> map = new HashMap<>();
+        try {
+            String setting = ContextUtil.getSetting();
+            map =(HashMap) jsonStringToMap(setting);
+        }catch (Exception e){
+            logger.warn("setting获取异常");
+        }
+        return map;
+    }
+
+    public static String getPx(){
+        String version = "";
+        try {
+            HashMap<String, Object> setting = getSetting();
+            HashMap<String, Object> option = (HashMap)setting.get("pxSpectacularsOption");
+            version = option.get("version").toString();
+        }catch (Exception e){
+            logger.warn("version转换异常或没有配置");
+        }
+        return version;
+    }
+
+
+    //转换map方法
+    public static Map<String, Object> jsonStringToMap(String jsonString) {
+        try {
+            ObjectMapper objectMapper = new ObjectMapper();
+            return objectMapper.readValue(jsonString, Map.class);
+        } catch (Exception e) {
+            throw new RuntimeException("JSON转换失败", e);
+        }
+    }
+
 }