Jelajahi Sumber

[bug-2353]培训通知定时任务改成接口调用

szjbdgzl 1 tahun lalu
induk
melakukan
ea6361570f

+ 31 - 6
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/business/service/impl/AuditServiceImpl.java

@@ -24,6 +24,11 @@ import java.util.*;
 @Service
 public class AuditServiceImpl implements AuditService {
 
+    private final String  TRAIN_REMIND_NOTICE = "RYPXZBTZ";
+
+    private final String  TRAIN_NOTICE = "RYPXTZ";
+
+    private final String  T_RYPXCJB = "t_rypxcjb";
 
     @Resource
     private ICommonDao<?> commonDao;
@@ -144,9 +149,19 @@ public class AuditServiceImpl implements AuditService {
         data.put("emergency_state_", "2");
         data.put("serial_num_", "");
         data.put("data_source_id_", id);
-        data.put("data_info_", "t_rypxcjb");
-        data.put("type_", "");
-        commonDao.execute(buildInsertSql(data,"ibps_party_user_calendar"));
+        data.put("data_info_", T_RYPXCJB);
+        data.put("type_", TRAIN_REMIND_NOTICE); // 人员培训准备通知
+        String sql = "select id_ from ibps_party_user_calendar where data_info_='%s' and data_source_id_='%s' and user_id_='%s' and type_='%s' limit 1";
+        sql = String.format(sql,T_RYPXCJB, id, userId, TRAIN_REMIND_NOTICE);
+        Map<String,Object> map = commonDao.queryOne(sql);
+        if (BeanUtils.isEmpty(map)){
+            commonDao.execute(buildInsertSql(data,"ibps_party_user_calendar"));
+        }else {
+            String updSQL= "update ibps_party_user_calendar set di_dian_='%s',user_id_='%s',title_='%s',content_='%s',start_time_='%s',end_time_='%s', " +
+                    "update_by_='1',update_time_=now() where data_info_='%s' and data_source_id_='%s' and user_id_='%s' and type_='%s'";
+            updSQL = String.format(updSQL,diDian,userId,title,peiXunNeiRong,starDate,endDate,T_RYPXCJB, id, userId, TRAIN_REMIND_NOTICE);
+            commonDao.execute(updSQL);
+        }
     }
 
     //培训通知
@@ -170,9 +185,19 @@ public class AuditServiceImpl implements AuditService {
         data.put("emergency_state_", "2");
         data.put("serial_num_", "");
         data.put("data_source_id_", id);
-        data.put("data_info_", "t_rypxcjb");
-        data.put("type_", "");
-        commonDao.execute(buildInsertSql(data,"ibps_party_user_calendar"));
+        data.put("data_info_", T_RYPXCJB);
+        data.put("type_", TRAIN_NOTICE); // 人员培训通知
+        String sql = "select id_ from ibps_party_user_calendar where data_info_='%s' and data_source_id_='%s' and user_id_='%s' and type_='%s' limit 1";
+        sql = String.format(sql,T_RYPXCJB, id, userId, TRAIN_NOTICE);
+        Map<String,Object> map = commonDao.queryOne(sql);
+        if (BeanUtils.isEmpty(map)){
+            commonDao.execute(buildInsertSql(data,"ibps_party_user_calendar"));
+        }else {
+            String updSQL= "update ibps_party_user_calendar set di_dian_='%s',user_id_='%s',title_='%s',content_='%s',start_time_='%s',end_time_='%s', " +
+                    "update_by_='1',update_time_=now() where data_info_='%s' and data_source_id_='%s' and user_id_='%s' and type_='%s'";
+            updSQL = String.format(updSQL,diDian,userId,title,neiRong,starDate,endDate,T_RYPXCJB, id, userId, TRAIN_NOTICE);
+            commonDao.execute(updSQL);
+        }
 
         List<String> receiver = new ArrayList<>();
         receiver.add(userId);