Просмотр исходного кода

[task-1367]目前定时任务是由前端登录后调用接口实现,需要改造成后端job触发

szjbdgzl 2 лет назад
Родитель
Сommit
f235727200

+ 1 - 1
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/sysdata/dao/CronNotifyDao.java

@@ -11,7 +11,7 @@ import java.util.List;
 @Mapper
 public interface CronNotifyDao extends BaseMapper<SysDataContextEntity> {
 
-    List<JSONObject>getCronNotifyData(@Param("jsonObject")JSONObject jsonObject); //获取定时任务数据
+    List<JSONObject>getCronNotifyData(); //获取定时任务数据
 
     Integer insertCronNotifySignData(@Param("list")List<JSONObject> list); //保存签到数据
 

+ 11 - 6
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/sysdata/services/impl/CronNotifyServiceImpl.java

@@ -10,6 +10,7 @@ import com.lc.ibps.cloud.entity.APIRequest;
 import com.lc.ibps.cloud.entity.APIRequestParameter;
 import com.lc.ibps.cloud.entity.APIResult;
 import com.lc.ibps.org.api.IPartyEmployeeService;
+import com.lc.ibps.org.party.persistence.entity.DefaultPartyUserPo;
 import com.lc.ibps.org.party.persistence.entity.PartyEmployeePo;
 import com.lc.ibps.sysdata.dao.CronNotifyDao;
 import com.lc.ibps.sysdata.entity.SysDataContextEntity;
@@ -44,37 +45,41 @@ public class CronNotifyServiceImpl implements CronNotifyService {
     @Override
     @Transactional
     public synchronized List<JSONObject> selectCronNotifyData() {
-        JSONObject jsonObject = new JSONObject();
-        jsonObject.put("userId", ContextUtil.getCurrentUserId()); //当前用户id
-        jsonObject.put("orgId", ContextUtil.getCurrentOrgId()); //当前用户部门id
+        //JSONObject jsonObject = new JSONObject();
+        //jsonObject.put("userId", "1166772226624585728"); //当前用户id
+        //jsonObject.put("orgId", ContextUtil.getCurrentOrgId()); //当前用户部门id
 
-        List<JSONObject>  json = cronNotifyDao.getCronNotifyData(jsonObject); //查询对应人员的任务  && 后期定时任务改全局
+        List<JSONObject>  json = cronNotifyDao.getCronNotifyData(); //查询对应人员的任务  && 后期定时任务改全局
         if(json.size()<=0){
             return  json;
         }
         HashMap<String, List<String>> map = this.getMap(json); //获取id集合  和 task集合
         //根据task开启多个流程任务。
         List<String> task = map.get("task");
-        List<String> subject = map.get("subject");
 
         if(task!=null && task.size()>0) {
 
             for (int i = 0; i < task.size(); i++) {
                     if(task.get(i)!=null && !task.get(i).isEmpty()  ) {
                         int index = i;
+                        String userId =  map.get("userId").get(index);
+                        DefaultPartyUserPo user = new DefaultPartyUserPo();
+                        user.setUserId(userId);
+                        ContextUtil.setCurrentUser(user);
                         APIResult<Void> result = iBpmInstProvider.startAndName(
          this.getParameters(task.get(index),
                             map.get("fieldName").get(index),
                             map.get("fieldValue").get(index),
                             map.get("jsonData").get(index)),
                             map.get("subject").get(index),
-                            map.get("userId").get(index),
+                                userId,
                             map.get("userName").get(index));
                         //devncq
                         String id = map.get("id").get(index);
                         String proInstId = (String)result.getVariable("proInstId");
                         JSONObject jsonObj = new JSONObject();
                         jsonObj.put("id",id);
+                        jsonObj.put("userId", userId);
                         jsonObj.put("proInstId", proInstId);
                         if(proInstId!=null)
                             cronNotifyDao.updateProInstId(jsonObj);

+ 5 - 12
ibps-provider-root/modules/provider-business/src/main/resources/com/lc/ibps/klimsibps/mapping/CronNotifyDao.xml

@@ -6,8 +6,7 @@
     <select id="getCronNotifyData" resultType="com.alibaba.fastjson.JSONObject">
         SELECT m.*
         FROM t_dsrw m
-        WHERE FIND_IN_SET(#{jsonObject.userId,jdbcType=VARCHAR},m.shou_li_ren_yuan_)>0
-          and (m.ren_wu_zhuang_tai != '已完成' and m.ren_wu_zhuang_tai != '不提醒')
+        WHERE  (m.ren_wu_zhuang_tai != '已完成' and m.ren_wu_zhuang_tai != '不提醒')
           AND (
                 (
                         m.ti_xing_zhou_qi_ = ''
@@ -31,15 +30,7 @@
           AND
                 date_format(DATE_SUB(m.ren_wu_shi_jian_, INTERVAL '-30' DAY), '%Y-%m-%d') >= date_format(NOW(), '%Y-%m-%d')
 
-          AND  (m.ti_xing_zhou_qi_ !='' or #{jsonObject.userId,jdbcType=VARCHAR} not in (
-            select q.qian_dao_ren_
-            from t_dsrwqdb q
-            where q.parent_id_ = m.id_
-              AND DATE_FORMAT(q.qian_dao_shi_jian
-                      , '%Y-%m-%d') = DATE_FORMAT(NOW()
-                      , '%Y-%m-%d')
-        )
-            )
+          AND  m.ti_xing_zhou_qi_ !=''
         ORDER BY date_format(ren_wu_shi_jian_, '%Y-%m-%d')
     </select>
 
@@ -97,7 +88,9 @@
     <update id="updateProInstId" parameterType="com.alibaba.fastjson.JSONObject">
         UPDATE t_dsrw
         set proc_inst_id_ = #{jsonObject.proInstId},
-            ren_wu_zhuang_tai='已完成'
+            ren_wu_zhuang_tai='已完成',
+            update_by_=#{jsonObject.userId},
+            update_time_ =now()
         where id_ = #{jsonObject.id}
     </update>