Commit 53b3350e authored by zhangwanglin's avatar zhangwanglin

定时任务

parent c5a7d765
......@@ -8,6 +8,7 @@ import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;
public class DateUtils {
......@@ -916,4 +917,17 @@ public class DateUtils {
return false;
}
public static String getNextDay(){
Date date=new Date();//取时间
Calendar calendar = new GregorianCalendar();
calendar.setTime(date);
// 1表示明天,-1表示昨天
calendar.add(Calendar.DATE,1);
date=calendar.getTime();
// 这个时间就是明天
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String dateString = formatter.format(date);
return dateString;
}
}
package com.hungraim.ltc.governance.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -17,7 +15,6 @@ import com.hungraim.ltc.pojo.entity.SysConfig.ChFndAttach;
import com.hungraim.ltc.pojo.entity.governance.ChSrvPlan;
import com.hungraim.ltc.pojo.entity.serviceManage.ChSrvTask;
import com.hungraim.ltc.pojo.entity.serviceManage.ChSrvTaskDetail;
import com.hungraim.ltc.pojo.entity.serviceManage.ChSrvTaskFinishItem;
import com.hungraim.ltc.pojo.vo.governance.*;
import com.hungraim.ltc.pojo.vo.system.AttachUpdateVo;
import com.hungraim.ltc.util.AttachType;
......@@ -144,6 +141,7 @@ public class SrvTaskServiceImpl implements SrvTaskService {
chSrvTask.setDisabInfoId(Long.parseLong(disabInfoId)); // 失能人员id
chSrvTask.setSrvEmpId(Long.parseLong(srvTaskInfoVO.getSrvEmpId()));//服务人员id
chSrvTask.setStatus((short) 1);//状态 未分配:0;已分配:1;已终止2
chSrvTask.setSrvDate(DateUtils.strToDate(taskDetails.get(0)));
srvTaskMapper.insert(chSrvTask);
//添加服务计划详情
Long newSrvTaskId = chSrvTask.getSrvTaskId();
......@@ -212,10 +210,12 @@ public class SrvTaskServiceImpl implements SrvTaskService {
// 生成计划任务 CH_SRV_TASK_DETAIL
for (AllocationSrvTaskVO chSrvTask : chSrvTasks) {
Long srvTaskId = chSrvTask.getSrvTaskId();
String nextDay = DateUtils.getNextDay();
// 根据任务id和服务时间查询是否已经生成过计划,已经生成了就不需要再生成了,已退出
List<ChSrvTaskDetail> chSrvTaskDetailList = chSrvTaskDetailMapper.selectList(new QueryWrapper<ChSrvTaskDetail>().eq("srv_task_id", srvTaskId));
if(CollectionUtil.isNotEmpty(chSrvTaskDetailList)){
int chSrvTaskDetailCount = chSrvTaskDetailMapper
.getSrvTaskDetail(String.valueOf(srvTaskId), nextDay);
if (chSrvTaskDetailCount > 0) {
return;
}
ChSrvTaskDetail chSrvTaskDetail = new ChSrvTaskDetail();
chSrvTaskDetail.setSrvTaskId(srvTaskId);//taskId
......
......@@ -58,6 +58,7 @@
</sql>
<select id="getSrvTaskDetail">
select count(*) from CH_SRV_TASK_DETAIL t where t.SRV_TASK_ID = #{srvTaskId} and to_char(t.SRV_DATE) = #{srvDate}
select count(*) from CH_SRV_TASK_DETAIL t where t.SRV_TASK_ID = #{srvTaskId}
and to_char(t.SRV_DATE,'yyyy-MM-dd') = #{srvDate}
</select>
</mapper>
\ No newline at end of file
......@@ -214,9 +214,10 @@
</where>
</select>
<select id="getAllocationSrvTask" resultType="com.hungraim.ltc.pojo.vo.governance.AllocationSrvTaskVO">
select t.SRV_TASK_ID,t.SRV_DATE,sysdate,info.EXIT_TIME,info.EXIT_FLAG,info.EXIT_REASON_ID from CH_SRV_TASK t
select t.SRV_TASK_ID,t.SRV_DATE,info.EXIT_TIME,info.EXIT_FLAG,info.EXIT_REASON_ID from CH_SRV_TASK t
left join CH_DISABLE_INFO info on t.DISAB_INFO_ID = info.DISAB_INFO_ID
where t.STATUS =1 and info.DISAB_INFO_ID = '327' and sysdate > t.SRV_DATE
where t.SRV_DATE <![CDATA[ < ]]> sysdate and
(info.EXIT_TIME <![CDATA[ > ]]> sysdate or info.EXIT_TIME is null)
</select>
</mapper>
\ No newline at end of file
......@@ -21,7 +21,7 @@ public class SrvTaskScheduledController {
private final SrvTaskFeignService srvTaskFeignService;
// 表示每天3点5分执行
@Scheduled(cron = "30 50 15 * * ?")
@Scheduled(cron = "30 41 17 * * ?")
public void timeAllocationSrvTask() {
Result result = srvTaskFeignService.timeAllocationSrvTask();
System.out.println();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment