|
|
@@ -1,14 +1,24 @@
|
|
|
package com.mokamrp.privates.service.pangu.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.mokamrp.privates.entity.PostBasePageHandle;
|
|
|
+import com.mokamrp.privates.help.AjaxResult;
|
|
|
+import com.mokamrp.privates.mapper.pangu.FosterTaskListMapper;
|
|
|
import com.mokamrp.privates.mapper.pangu.FosterTaskScheduleMapper;
|
|
|
+import com.mokamrp.privates.mapper.pangu.FosterwxStationMapper;
|
|
|
+import com.mokamrp.privates.mapper.pangu.pojo.FosterTaskList;
|
|
|
import com.mokamrp.privates.mapper.pangu.pojo.FosterTaskSchedule;
|
|
|
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
|
|
|
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxStation;
|
|
|
+import com.mokamrp.privates.mapper.pojo.User;
|
|
|
import com.mokamrp.privates.service.pangu.FosterTaskScheduleService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
@@ -27,6 +37,12 @@ public class FosterTaskScheduleServiceImpl extends ServiceImpl<FosterTaskSchedul
|
|
|
@Autowired
|
|
|
public FosterTaskScheduleMapper fosterTaskScheduleMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private FosterwxStationMapper fosterwxStationMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FosterTaskListMapper fosterTaskListMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 获取数据列表 支持分页
|
|
|
* @param handle
|
|
|
@@ -42,4 +58,90 @@ public class FosterTaskScheduleServiceImpl extends ServiceImpl<FosterTaskSchedul
|
|
|
resMap.put("total", pageObj.getTotal());
|
|
|
return resMap;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据开始任务时间生成排期
|
|
|
+ * @param fosterwxMobile
|
|
|
+ * @param authUser
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public AjaxResult insertByTaskDate(FosterwxMobile fosterwxMobile, User authUser) {
|
|
|
+ // 获取站点信息
|
|
|
+ FosterwxStation fosterwxStation = fosterwxStationMapper.selectById(fosterwxMobile.getStationId());
|
|
|
+
|
|
|
+ if (fosterwxStation == null) return AjaxResult.error(fosterwxMobile.getStationId() + "站点不存在!");
|
|
|
+
|
|
|
+ LocalDate startDate = fosterwxMobile.getTaskStartAt().toLocalDate();
|
|
|
+
|
|
|
+ // 根据站点绑定的任务模板获取模板列表
|
|
|
+ LambdaQueryWrapper<FosterTaskList> fosterTaskListLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ fosterTaskListLambdaQueryWrapper.eq(FosterTaskList::getTemplateId, fosterwxStation.getTaskTemplateId());
|
|
|
+ List<FosterTaskList> fosterTaskLists = fosterTaskListMapper.selectList(fosterTaskListLambdaQueryWrapper);
|
|
|
+
|
|
|
+ for (FosterTaskList fosterTaskList : fosterTaskLists) {
|
|
|
+ FosterTaskSchedule fosterTaskSchedule = new FosterTaskSchedule();
|
|
|
+ fosterTaskSchedule.setStationId(fosterwxStation.getId());
|
|
|
+ fosterTaskSchedule.setStationName(fosterwxStation.getStationName());
|
|
|
+ fosterTaskSchedule.setMobileCode(fosterwxMobile.getMobileCode());
|
|
|
+ fosterTaskSchedule.setTemplateId(fosterwxStation.getTaskTemplateId());
|
|
|
+ fosterTaskSchedule.setTaskId(fosterTaskList.getId());
|
|
|
+ fosterTaskSchedule.setTaskStatus(0);
|
|
|
+ fosterTaskSchedule.setTaskSendStatus(0);
|
|
|
+ fosterTaskSchedule.setSendDate(startDate);
|
|
|
+ fosterTaskSchedule.setSendTime(null);
|
|
|
+ fosterTaskSchedule.setErrMsg("");
|
|
|
+ fosterTaskSchedule.setMark("");
|
|
|
+ fosterTaskSchedule.setDelFlg(1);
|
|
|
+ fosterTaskSchedule.setCreateUid(authUser.getId());
|
|
|
+ fosterTaskSchedule.setUpdateUid(authUser.getId());
|
|
|
+ fosterTaskSchedule.setCreateAt(LocalDateTime.now());
|
|
|
+ fosterTaskSchedule.setUpdateAt(LocalDateTime.now());
|
|
|
+
|
|
|
+ fosterTaskScheduleMapper.insert(fosterTaskSchedule);
|
|
|
+
|
|
|
+ startDate = startDate.plusDays(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ return AjaxResult.success("新增账号成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据当天时间删除后续任务
|
|
|
+ * @param fosterwxMobileService
|
|
|
+ * @param authUser
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public AjaxResult deleteByDate(FosterwxMobile fosterwxMobile, User authUser) {
|
|
|
+ LocalDate today = LocalDate.now();
|
|
|
+ LocalDateTime localDateTime = LocalDateTime.now();
|
|
|
+
|
|
|
+ // 获取站点信息
|
|
|
+ FosterwxStation fosterwxStation = fosterwxStationMapper.selectById(fosterwxMobile.getStationId());
|
|
|
+
|
|
|
+ if (fosterwxStation == null) return AjaxResult.error(fosterwxMobile.getStationId() + "站点不存在!");
|
|
|
+
|
|
|
+ // 根据站点id 手机编号 模板id 获取今天之后的任务
|
|
|
+ LambdaQueryWrapper<FosterTaskSchedule> fosterTaskScheduleLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ fosterTaskScheduleLambdaQueryWrapper.eq(FosterTaskSchedule::getStationId, fosterwxStation.getId());
|
|
|
+ fosterTaskScheduleLambdaQueryWrapper.eq(FosterTaskSchedule::getMobileCode, fosterwxMobile.getMobileCode());
|
|
|
+ fosterTaskScheduleLambdaQueryWrapper.eq(FosterTaskSchedule::getTemplateId, fosterwxStation.getTaskTemplateId());
|
|
|
+ fosterTaskScheduleLambdaQueryWrapper.ge(FosterTaskSchedule::getSendDate, today);
|
|
|
+ fosterTaskScheduleLambdaQueryWrapper.orderByAsc(FosterTaskSchedule::getId);
|
|
|
+
|
|
|
+ List<FosterTaskSchedule> fosterTaskScheduleList = fosterTaskScheduleMapper.selectList(fosterTaskScheduleLambdaQueryWrapper);
|
|
|
+
|
|
|
+ for (FosterTaskSchedule fosterTaskSchedule : fosterTaskScheduleList) {
|
|
|
+ // 需要单独判断今天的发送时间是不是已经过去了 没有过去需要删除任务
|
|
|
+ if (fosterTaskSchedule.getSendDate().equals(today) && localDateTime.isAfter(fosterTaskSchedule.getSendTime()))
|
|
|
+ continue;
|
|
|
+
|
|
|
+ FosterTaskSchedule updateVO = new FosterTaskSchedule();
|
|
|
+ updateVO.setId(fosterTaskSchedule.getId());
|
|
|
+ updateVO.setDelFlg(0);
|
|
|
+ fosterTaskScheduleMapper.updateById(updateVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ return AjaxResult.success("修改成功");
|
|
|
+ }
|
|
|
}
|