Commit 55d03cdc authored by tianyiming's avatar tianyiming

更新索引--涉及任务下发、定时器修改、任务执行

parent 9e326fe7
package com.yeejoin.amos.patrol.dao.entity;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import java.util.List;
/**
* @Author cpp
* @Description
* @Date 2023/6/5
*/
@Data
@Accessors(chain = true)
@Document(indexName = "web_app_plan_task_list", shards = 6, replicas = 2)
public class ESPlanTaskListDto {
@Id
private String planTaskId;
@Field(type = FieldType.Text)
private String OrgCode;
@Field(type = FieldType.Text)
private String planId;
@Field(type = FieldType.Text)
private String useCode;
@Field(type = FieldType.Text)
private String taskName;
@Field(type = FieldType.Text)
private String beginTime;
@Field(type = FieldType.Text)
private String endTime;
@Field(type = FieldType.Text)
private String checkDate;
@Field(type = FieldType.Text)
private String finshNum;
@Field(type = FieldType.Text)
private String taskPlanNum;
@Field(type = FieldType.Text)
private String finishStatus;
@Field(type = FieldType.Text)
private String batchNo;
@Field(type = FieldType.Text)
private String executiveName;
@Field(type = FieldType.Text)
private String userName;
@Field(type = FieldType.Text)
private String userDept;
@Field(type = FieldType.Text)
private String unplan;
@Field(type = FieldType.Text)
private String userId;
@Field(type = FieldType.Text)
private String unqualified;
@Field(type = FieldType.Text)
private String inOrder;
@Field(type = FieldType.Text)
private String omission;
@Field(type = FieldType.Object)
private List points;
}
package com.yeejoin.amos.patrol.dao.entity;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import java.util.List;
/**
* @Author cpp
* @Description
* @Date 2023/6/5
*/
@Data
@Accessors(chain = true)
@Document(indexName = "web_app_task_detail", shards = 6, replicas = 2)
public class ESTaskDetailDto {
@Id
private String pointId;
@Field(type = FieldType.Text)
private String pointName;
@Field(type = FieldType.Text)
private String pointNo;
@Field(type = FieldType.Text)
private String shortMinNumber;
@Field(type = FieldType.Text)
private String shortMaxNumber;
@Field(type = FieldType.Text)
private String checkTime;
@Field(type = FieldType.Text)
private String beginTime;
@Field(type = FieldType.Text)
private String endTime;
@Field(type = FieldType.Text)
private String pointStatus;
@Field(type = FieldType.Text)
private String planName;
@Field(type = FieldType.Text)
private String taskStatus;
@Field(type = FieldType.Text)
private String departmentName;
@Field(type = FieldType.Text)
private String username;
@Field(type = FieldType.Text)
private String strCheckTime;
@Field(type = FieldType.Text)
private String checkId;
@Field(type = FieldType.Text)
private String remark;
@Field(type = FieldType.Text)
private String score;
@Field(type = FieldType.Text)
private List<String> pointImgUrls;
@Field(type = FieldType.Text)
private JSONObject appCheckInput;
}
...@@ -7,6 +7,7 @@ import com.yeejoin.amos.boot.module.common.api.feign.EquipFeignClient; ...@@ -7,6 +7,7 @@ import com.yeejoin.amos.boot.module.common.api.feign.EquipFeignClient;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.patrol.business.constants.XJConstant; import com.yeejoin.amos.patrol.business.constants.XJConstant;
import com.yeejoin.amos.patrol.business.dao.mapper.CheckMapper; import com.yeejoin.amos.patrol.business.dao.mapper.CheckMapper;
import com.yeejoin.amos.patrol.business.dao.mapper.PlanTaskMapper;
import com.yeejoin.amos.patrol.business.dao.mapper.PointMapper; import com.yeejoin.amos.patrol.business.dao.mapper.PointMapper;
import com.yeejoin.amos.patrol.business.dao.repository.ICheckInputDao; import com.yeejoin.amos.patrol.business.dao.repository.ICheckInputDao;
import com.yeejoin.amos.patrol.business.dto.*; import com.yeejoin.amos.patrol.business.dto.*;
...@@ -30,6 +31,7 @@ import com.yeejoin.amos.patrol.core.util.StringUtil; ...@@ -30,6 +31,7 @@ import com.yeejoin.amos.patrol.core.util.StringUtil;
import com.yeejoin.amos.patrol.dao.entity.PlanTask; import com.yeejoin.amos.patrol.dao.entity.PlanTask;
import com.yeejoin.amos.patrol.feign.RemoteSecurityService; import com.yeejoin.amos.patrol.feign.RemoteSecurityService;
import com.yeejoin.amos.patrol.mqtt.WebMqttComponent; import com.yeejoin.amos.patrol.mqtt.WebMqttComponent;
import com.yeejoin.amos.patrol.quartz.JobService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
...@@ -57,10 +59,7 @@ import javax.xml.transform.*; ...@@ -57,10 +59,7 @@ import javax.xml.transform.*;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
import java.io.*; import java.io.*;
import java.util.Date; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -130,6 +129,11 @@ public class CheckController extends AbstractBaseController { ...@@ -130,6 +129,11 @@ public class CheckController extends AbstractBaseController {
@Autowired @Autowired
PointMapper pointMapper; PointMapper pointMapper;
@Autowired
JobService jobService;
@Autowired
PlanTaskMapper planTaskMapper;
/** /**
* *
* 巡查记录列表 * 巡查记录列表
...@@ -245,6 +249,12 @@ public class CheckController extends AbstractBaseController { ...@@ -245,6 +249,12 @@ public class CheckController extends AbstractBaseController {
requestParam.setOrgCode(orgCode); requestParam.setOrgCode(orgCode);
requestParam.setUserId(getUserId()); requestParam.setUserId(getUserId());
CheckDto checkDto = checkService.saveCheckRecordNew(requestParam, planTask); CheckDto checkDto = checkService.saveCheckRecordNew(requestParam, planTask);
Long planTaskId = requestParam.getPlanTaskId();
List<String> ids = new ArrayList<>();
ids.add(String.valueOf(planTaskId));
int status = planTaskMapper.selectTaskStatus(planTaskId);
jobService.updateEsPlanTaskList(ids, status);
return ResponseHelper.buildResponse(checkDto); return ResponseHelper.buildResponse(checkDto);
} else { } else {
return ResponseHelperUtil.buildErrorResponse("无需重新巡检"); return ResponseHelperUtil.buildErrorResponse("无需重新巡检");
......
...@@ -10,6 +10,7 @@ import com.yeejoin.amos.patrol.business.vo.LeavePlanTaskVo; ...@@ -10,6 +10,7 @@ import com.yeejoin.amos.patrol.business.vo.LeavePlanTaskVo;
import com.yeejoin.amos.patrol.business.vo.PlanTaskVo; import com.yeejoin.amos.patrol.business.vo.PlanTaskVo;
import com.yeejoin.amos.patrol.dao.entity.Plan; import com.yeejoin.amos.patrol.dao.entity.Plan;
import com.yeejoin.amos.patrol.dao.entity.PlanTask; import com.yeejoin.amos.patrol.dao.entity.PlanTask;
import com.yeejoin.amos.patrol.dao.entity.PlanTaskDetail;
import com.yeejoin.amos.patrol.dao.entity.PointInputItem; import com.yeejoin.amos.patrol.dao.entity.PointInputItem;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -235,5 +236,11 @@ public interface PlanTaskMapper extends BaseMapper { ...@@ -235,5 +236,11 @@ public interface PlanTaskMapper extends BaseMapper {
List<PlanTask> getInitPlanTaskList(); List<PlanTask> getInitPlanTaskList();
void updatePlanTaskList(long planId, int oldStatus, int newStatus); void updatePlanTaskList(List<String> ids, int newStatus);
List<String> selectPlanTaskIdList(long planId, int oldStatus);
List<PlanTaskDetail> selectTaskDetails(String id);
int selectTaskStatus(Long planTaskId);
} }
package com.yeejoin.amos.patrol.business.dao.repository;
import com.yeejoin.amos.patrol.dao.entity.ESPlanTaskListDto;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface ESPlanTaskList extends PagingAndSortingRepository<ESPlanTaskListDto, String> {
}
package com.yeejoin.amos.patrol.business.dao.repository;
import com.yeejoin.amos.patrol.dao.entity.ESPlanTaskListDto;
import com.yeejoin.amos.patrol.dao.entity.ESTaskDetailDto;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface ESTaskDetail extends PagingAndSortingRepository<ESTaskDetailDto, String> {
}
...@@ -74,6 +74,7 @@ import java.io.File; ...@@ -74,6 +74,7 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.sql.Timestamp;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
...@@ -83,9 +84,15 @@ import java.util.*; ...@@ -83,9 +84,15 @@ import java.util.*;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.alibaba.fastjson.JSON.toJSONString;
@Service("planTaskService") @Service("planTaskService")
public class PlanTaskServiceImpl implements IPlanTaskService { public class PlanTaskServiceImpl implements IPlanTaskService {
private final Logger log = LoggerFactory.getLogger(PlanTaskServiceImpl.class); private final Logger log = LoggerFactory.getLogger(PlanTaskServiceImpl.class);
@Autowired
ESPlanTaskList esPlanTaskList;
@Autowired @Autowired
PlanTaskMapper planTaskMapper; PlanTaskMapper planTaskMapper;
@Autowired @Autowired
...@@ -375,13 +382,14 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -375,13 +382,14 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
} }
//3.删除planTask表,按照计划id+日期 //3.删除planTask表,按照计划id+日期
deletePlanTaskAndDet(param); List<ESPlanTaskListDto> oldEsPlanTaskListDtos = deletePlanTaskAndDet(param);
//5.执行数据生成(具体时间 + 人员) //5.执行数据生成(具体时间 + 人员)
List<HashMap<String, Object>> list = genAllExeDate(plan, vo, XJConstant.REGEN_FLAG); List<HashMap<String, Object>> list = genAllExeDate(plan, vo, XJConstant.REGEN_FLAG);
//6.插入planTask及planTaskDetail //6.插入planTask及planTaskDetail
insertPlanTaskAndDetNew(list, plan, flag, new Date()); insertPlanTaskAndDetNew(list, plan, flag, new Date(),oldEsPlanTaskListDtos);
} }
...@@ -634,7 +642,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -634,7 +642,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
} }
//2.5.插入planTask及planTaskDetail //2.5.插入planTask及planTaskDetail
insertPlanTaskAndDetNew(list, plan, XJConstant.SCHED_FLAG, now); insertPlanTaskAndDetNew(list, plan, XJConstant.SCHED_FLAG, now, null);
} }
} }
...@@ -644,14 +652,18 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -644,14 +652,18 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
* *
* @param param * @param param
*/ */
public void deletePlanTaskAndDet(HashMap<String, Object> param) { public List<ESPlanTaskListDto> deletePlanTaskAndDet(HashMap<String, Object> param) {
param.put("beginDate", param.get("beginDate") + " " + "00:00:00"); param.put("beginDate", param.get("beginDate") + " " + "00:00:00");
param.put("endDate", param.get("endDate") + " " + "23:59:59"); param.put("endDate", param.get("endDate") + " " + "23:59:59");
List<Long> ids = planTaskMapper.getGenPlanTask(param); List<Long> ids = planTaskMapper.getGenPlanTask(param);
List<ESPlanTaskListDto> planTaskList = new ArrayList<>();
for (long id : ids) { for (long id : ids) {
iplanTaskDao.deleteById(id); iplanTaskDao.deleteById(id);
ESPlanTaskListDto esPlanTaskListDto = new ESPlanTaskListDto();
esPlanTaskListDto.setPlanTaskId(String.valueOf(id));
planTaskList.add(esPlanTaskListDto);
} }
return planTaskList;
} }
/** /**
...@@ -699,7 +711,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -699,7 +711,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
* @param flag 是否初始状态0-初始 1-非初始 * @param flag 是否初始状态0-初始 1-非初始
*/ */
@Async("asyncServiceExecutor") @Async("asyncServiceExecutor")
public void insertPlanTaskAndDetNew(List<HashMap<String, Object>> list, Plan plan, String flag, Date now) { public void insertPlanTaskAndDetNew(List<HashMap<String, Object>> list, Plan plan, String flag, Date now, List<ESPlanTaskListDto> oldEsPlanTaskListDtos) {
if (list == null || list.size() <= 0) { if (list == null || list.size() <= 0) {
HashMap<String, Object> paramMap = new HashMap<String, Object>(); HashMap<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("id", plan.getId()); paramMap.put("id", plan.getId());
...@@ -715,6 +727,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -715,6 +727,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
List<PlanTaskDetail> planTaskDetailListSync = new ArrayList<>(); List<PlanTaskDetail> planTaskDetailListSync = new ArrayList<>();
PlanTask planTask = new PlanTask(); PlanTask planTask = new PlanTask();
List<PlanTask> taskList = new ArrayList<>(); List<PlanTask> taskList = new ArrayList<>();
List<ESPlanTaskListDto> esPlanTaskListDtos = new ArrayList<>();
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String startTime = list.get(i).get("BEGIN_TIME").toString(); String startTime = list.get(i).get("BEGIN_TIME").toString();
...@@ -795,13 +808,27 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -795,13 +808,27 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
//// planTaskDetail.saveAndFlush(planTaskDetailInstance); //// planTaskDetail.saveAndFlush(planTaskDetailInstance);
planTaskDetailListSync.add(planTaskDetailInstance); planTaskDetailListSync.add(planTaskDetailInstance);
} }
ESPlanTaskListDto esPlanTaskListDto = JSONObject.parseObject(toJSONString(planTask),
ESPlanTaskListDto.class);
esPlanTaskListDto.setPlanTaskId(String.valueOf(planTask.getId()));
esPlanTaskListDto.setPlanId(String.valueOf(plan.getId()));
esPlanTaskListDtos.add(esPlanTaskListDto);
} }
em.flush(); em.flush();
em.clear(); em.clear();
// mybatisService.saveBatch(taskList); // mybatisService.saveBatch(taskList);
// repositoryTs.batchSave(taskList); // repositoryTs.batchSave(taskList);
repositoryTs.batchSave(planTaskDetailListSync);
Iterable<PlanTaskDetail> planTaskDetails = repositoryTs.batchSave(planTaskDetailListSync);
List<PlanTaskDetail> planTaskDetailList = new ArrayList<>();
planTaskDetails.forEach(single ->planTaskDetailList.add(single));
for (ESPlanTaskListDto esPlanTaskListDto : esPlanTaskListDtos) {
esPlanTaskListDto.setPoints(planTaskDetailList);
}
saveEsPlanTaskList(esPlanTaskListDtos, oldEsPlanTaskListDtos);
// 定时任务监控 // 定时任务监控
log.error("计划重做开始添加定时任务监控========"); log.error("计划重做开始添加定时任务监控========");
jobService.planTaskAddJob(planTask); jobService.planTaskAddJob(planTask);
...@@ -835,8 +862,12 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -835,8 +862,12 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
} }
public void saveEsPlanTaskList(List<ESPlanTaskListDto> esPlanTaskListDtos, List<ESPlanTaskListDto> oldEsPlanTaskListDtos) {
if (!ValidationUtil.isEmpty(oldEsPlanTaskListDtos)) {
esPlanTaskList.deleteAll(oldEsPlanTaskListDtos);
}
esPlanTaskList.saveAll(esPlanTaskListDtos);
}
/** /**
...@@ -1132,13 +1163,18 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -1132,13 +1163,18 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
iplanTaskDao.saveAndFlush(planTask); iplanTaskDao.saveAndFlush(planTask);
List<PlanTaskDetail> planTaskDetails = iPlanTaskDetailDao.findAllByTaskNoAndStatus(planTask.getId(), PlanTaskDetailStatusEnum.NOTSTARTED.getValue()); List<PlanTaskDetail> planTaskDetails = iPlanTaskDetailDao.findAllByTaskNoAndStatus(planTask.getId(), PlanTaskDetailStatusEnum.NOTSTARTED.getValue());
if (!planTaskDetails.isEmpty()) { if (!planTaskDetails.isEmpty()) {
planTaskDetails.stream().forEach(action -> { planTaskDetails = planTaskDetails.stream().map(action -> {
action.setStatus(PlanTaskDetailStatusEnum.QUALIFIED.getValue()); action.setStatus(PlanTaskDetailStatusEnum.QUALIFIED.getValue());
iPlanTaskDetailDao.saveAndFlush(action); iPlanTaskDetailDao.saveAndFlush(action);
planTaskDetailMapper.finishTaskDetail(action.getId(), action.getPointId(), planTaskDetailMapper.finishTaskDetail(action.getId(), action.getPointId(),
action.getPlanTask().getId(), userId); action.getPlanTask().getId(), userId);
}); return action;
}).collect(Collectors.toList());
} }
ESPlanTaskListDto esPlanTaskListDto = JSONObject.parseObject(toJSONString(planTask),
ESPlanTaskListDto.class);
esPlanTaskListDto.setPoints(planTaskDetails);
esPlanTaskList.save(esPlanTaskListDto);
// 生成巡检记录 // 生成巡检记录
jobService.createCheckRecord(planTask, userId); jobService.createCheckRecord(planTask, userId);
} }
......
...@@ -23,7 +23,7 @@ public class RepositoryTImpl implements RepositoryTs { ...@@ -23,7 +23,7 @@ public class RepositoryTImpl implements RepositoryTs {
@Override @Override
@Transactional @Transactional
@Async("asyncServiceExecutor") // @Async("asyncServiceExecutor")
public <S> Iterable<S> batchSave(Iterable<S> var1) { public <S> Iterable<S> batchSave(Iterable<S> var1) {
Iterator<S> iterator = var1.iterator(); Iterator<S> iterator = var1.iterator();
int index = 0; int index = 0;
......
...@@ -114,7 +114,7 @@ public interface IPlanTaskService { ...@@ -114,7 +114,7 @@ public interface IPlanTaskService {
* @param params * @param params
* @return * @return
*/ */
Page<Map<String, Object>> getPlanTasks(String toke,String product,String appKey,HashMap<String, Object> params); Page<Map<String, Object>> getPlanTasks(String toke,String product,String appKey,HashMap<String, Object> params);
/** /**
* 根据计划任务Id获取计划任务信息 * 根据计划任务Id获取计划任务信息
......
...@@ -58,6 +58,9 @@ public class JobService implements IJobService { ...@@ -58,6 +58,9 @@ public class JobService implements IJobService {
private final Logger log = LoggerFactory.getLogger(JobService.class); private final Logger log = LoggerFactory.getLogger(JobService.class);
@Autowired @Autowired
ESPlanTaskList esPlanTaskList;
@Autowired
private ITaskDao iTaskDao; private ITaskDao iTaskDao;
@Autowired @Autowired
...@@ -109,6 +112,9 @@ public class JobService implements IJobService { ...@@ -109,6 +112,9 @@ public class JobService implements IJobService {
@Autowired @Autowired
IInputItemDao inputItemDao; IInputItemDao inputItemDao;
@Autowired
IRoutePointDao iRoutePointDao;
@Autowired @Autowired
JcsFeignClient jcsFeignClient; JcsFeignClient jcsFeignClient;
...@@ -169,13 +175,17 @@ public class JobService implements IJobService { ...@@ -169,13 +175,17 @@ public class JobService implements IJobService {
Date beginTime = sdf.parse(planTask.getBeginTime()); Date beginTime = sdf.parse(planTask.getBeginTime());
Date endTime = sdf.parse(planTask.getEndTime()); Date endTime = sdf.parse(planTask.getEndTime());
long timestamp = new Date().getTime(); long timestamp = new Date().getTime();
List<String> ids = new ArrayList<>();
if (PlanTaskFinishStatusEnum.NOTSTARTED.getValue() == planTask.getFinishStatus()) { if (PlanTaskFinishStatusEnum.NOTSTARTED.getValue() == planTask.getFinishStatus()) {
if (beginTime.getTime() > timestamp) { if (beginTime.getTime() > timestamp) {
planTaskAddJob(planTask); planTaskAddJob(planTask);
log.error("项目初始化未开始监听器任务监控========"); log.error("项目初始化未开始监听器任务监控========");
} else if (beginTime.getTime() < timestamp && endTime.getTime() > timestamp) { } else if (beginTime.getTime() < timestamp && endTime.getTime() > timestamp) {
log.error("项目初始化进行中监听器任务监控========"); log.error("项目初始化进行中监听器任务监控========");
planTaskMapper.updatePlanTaskList(planTask.getPlanId(), PlanTaskFinishStatusEnum.NOTSTARTED.getValue(), PlanTaskFinishStatusEnum.UNDERWAY.getValue()); ids = planTaskMapper.selectPlanTaskIdList(planTask.getPlanId(), PlanTaskFinishStatusEnum.NOTSTARTED.getValue());
if(!ObjectUtils.isEmpty(ids)){
planTaskMapper.updatePlanTaskList(ids, PlanTaskFinishStatusEnum.UNDERWAY.getValue());
}
planTaskAddJob(planTask); planTaskAddJob(planTask);
} else if (endTime.getTime() < timestamp) { } else if (endTime.getTime() < timestamp) {
log.error("修改为漏检生成记录========"); log.error("修改为漏检生成记录========");
...@@ -184,13 +194,21 @@ public class JobService implements IJobService { ...@@ -184,13 +194,21 @@ public class JobService implements IJobService {
} else { } else {
if (endTime.getTime() < timestamp) { if (endTime.getTime() < timestamp) {
log.error("项目初始化进行中监听器任务监控2222========"); log.error("项目初始化进行中监听器任务监控2222========");
planTaskMapper.updatePlanTaskList(planTask.getPlanId(), PlanTaskFinishStatusEnum.NOTSTARTED.getValue(), PlanTaskFinishStatusEnum.UNDERWAY.getValue()); ids = planTaskMapper.selectPlanTaskIdList(planTask.getPlanId(), PlanTaskFinishStatusEnum.NOTSTARTED.getValue());
if(!ObjectUtils.isEmpty(ids)){
planTaskMapper.updatePlanTaskList(ids, PlanTaskFinishStatusEnum.UNDERWAY.getValue());
}
planTaskAddJob(planTask); planTaskAddJob(planTask);
} else { } else {
log.error("修改为漏检生成记录2222========"); log.error("修改为漏检生成记录2222========");
updatePlanTaskAndDetailStatus(planTask); updatePlanTaskAndDetailStatus(planTask);
} }
} }
if (!ObjectUtils.isEmpty(ids)) {
updateEsPlanTaskList(ids, PlanTaskFinishStatusEnum.NOTSTARTED.getValue());
}
} catch (ParseException e) { } catch (ParseException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
log.debug(e.getMessage()); log.debug(e.getMessage());
...@@ -200,11 +218,26 @@ public class JobService implements IJobService { ...@@ -200,11 +218,26 @@ public class JobService implements IJobService {
} }
public void updateEsPlanTaskList(List<String> ids, int status) {
List<ESPlanTaskListDto> esPlanTaskListDtos = new ArrayList<>();
for (String id : ids) {
ESPlanTaskListDto esPlanTaskListDto = new ESPlanTaskListDto();
esPlanTaskListDto.setPlanTaskId(id);
esPlanTaskListDto.setFinishStatus(String.valueOf(status));
List<PlanTaskDetail> planTaskDetailList = planTaskMapper.selectTaskDetails(id);
esPlanTaskListDto.setPoints(planTaskDetailList);
esPlanTaskListDtos.add(esPlanTaskListDto);
}
esPlanTaskList.saveAll(esPlanTaskListDtos);
}
private void updatePlanTaskAndDetailStatus(PlanTask planTask) { private void updatePlanTaskAndDetailStatus(PlanTask planTask) {
planTaskMapper.updatePlanTaskList(planTask.getPlanId(), PlanTaskFinishStatusEnum.UNDERWAY.getValue(), PlanTaskFinishStatusEnum.OVERTIME.getValue()); List<String> esIds = planTaskMapper.selectPlanTaskIdList(planTask.getPlanId(), PlanTaskFinishStatusEnum.UNDERWAY.getValue());
planTaskMapper.updatePlanTaskList(esIds, PlanTaskFinishStatusEnum.OVERTIME.getValue());
List<Long> ids = new ArrayList<>(); List<Long> ids = new ArrayList<>();
ids.add(planTask.getId()); ids.add(planTask.getId());
planTaskMapper.updatePlanTaskDetailsByPlanId(ids); planTaskMapper.updatePlanTaskDetailsByPlanId(ids);
updateEsPlanTaskList(esIds, PlanTaskFinishStatusEnum.OVERTIME.getValue());
createOmissionCheckRecord(planTask); createOmissionCheckRecord(planTask);
} }
...@@ -609,7 +642,9 @@ public class JobService implements IJobService { ...@@ -609,7 +642,9 @@ public class JobService implements IJobService {
log.error("开始执行定时任务添加的任务==========>>{}", JSON.toJSONString(planTask)); log.error("开始执行定时任务添加的任务==========>>{}", JSON.toJSONString(planTask));
if (XJConstant.STATUS_MONITOR_START.equals(jobType)) { if (XJConstant.STATUS_MONITOR_START.equals(jobType)) {
if (!ValidationUtil.isEmpty(notStartPlanTaskList)) { if (!ValidationUtil.isEmpty(notStartPlanTaskList)) {
planTaskMapper.updatePlanTaskByPlanId(notStartPlanTaskList,PlanTaskFinishStatusEnum.UNDERWAY.getValue()); planTaskMapper.updatePlanTaskByPlanId(notStartPlanTaskList, PlanTaskFinishStatusEnum.UNDERWAY.getValue());
} else {
} }
} else if (XJConstant.STATUS_MONITOR_END.equals(jobType)) { } else if (XJConstant.STATUS_MONITOR_END.equals(jobType)) {
if (!ValidationUtil.isEmpty(StartPlanTaskList)) { if (!ValidationUtil.isEmpty(StartPlanTaskList)) {
......
...@@ -1626,7 +1626,32 @@ ...@@ -1626,7 +1626,32 @@
set set
finish_status = #{newStatus} finish_status = #{newStatus}
where where
plan_id = #{planId} id in
and finish_status = #{oldStatus} <foreach item="id" collection="ids" index="index" open="(" separator="," close=")">
#{id}
</foreach>
</update> </update>
<select id="selectPlanTaskIdList" resultType="java.lang.String">
SELECT
id
FROM
"p_plan_task"
WHERE
plan_id = #{planId}
AND finish_status = #{oldStatus}
</select>
<select id="selectTaskDetails" resultType="com.yeejoin.amos.patrol.dao.entity.PlanTaskDetail">
select
*
from
"p_plan_task_detail"
where
task_no = #{id}
</select>
<select id="selectTaskStatus" resultType="java.lang.Integer">
select finish_status from "p_plan_task" where plan_id = #{planTaskId}
</select>
</mapper> </mapper>
\ No newline at end of file
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