|
@@ -1,188 +0,0 @@
|
|
|
-package com.platform.service.work.impl;
|
|
|
-
|
|
|
-import cn.hutool.core.util.ObjectUtil;
|
|
|
-import com.github.pagehelper.PageHelper;
|
|
|
-import com.platform.common.bean.AbstractPageResultBean;
|
|
|
-import com.platform.common.model.UserInfo;
|
|
|
-import com.platform.common.util.DateUtils;
|
|
|
-import com.platform.common.util.IdGeneratorUtils;
|
|
|
-import com.platform.common.util.SecurityUtils;
|
|
|
-import com.platform.dao.bean.MyPage;
|
|
|
-import com.platform.dao.dto.check.CheckJobDTO;
|
|
|
-import com.platform.dao.dto.check.CheckPlanDTO;
|
|
|
-import com.platform.dao.dto.check.CheckProjectPlanRelationDTO;
|
|
|
-import com.platform.dao.entity.work.WorkJob;
|
|
|
-import com.platform.dao.entity.work.WorkPlan;
|
|
|
-import com.platform.dao.entity.work.WorkProjectPlanRelation;
|
|
|
-import com.platform.dao.enums.CheckJobSbStatusEnum;
|
|
|
-import com.platform.dao.enums.CheckJobStatusEnum;
|
|
|
-import com.platform.dao.enums.CheckPlanPeriodTypeEnum;
|
|
|
-import com.platform.dao.enums.YesNoEnum;
|
|
|
-import com.platform.dao.mapper.check.*;
|
|
|
-import com.platform.dao.mapper.work.*;
|
|
|
-import com.platform.dao.vo.query.check.CheckJobVO;
|
|
|
-import com.platform.dao.vo.query.check.CheckPlanVO;
|
|
|
-import com.platform.dao.vo.query.check.CheckProjectVO;
|
|
|
-import com.platform.dao.vo.query.check.CheckStandardVO;
|
|
|
-import com.platform.service.base.impl.BaseServiceImpl;
|
|
|
-import com.platform.service.check.CheckJobService;
|
|
|
-import com.platform.service.work.WorkJobService;
|
|
|
-import lombok.AllArgsConstructor;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import tk.mybatis.mapper.weekend.Weekend;
|
|
|
-import tk.mybatis.mapper.weekend.WeekendCriteria;
|
|
|
-
|
|
|
-import java.time.LocalDate;
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.time.LocalTime;
|
|
|
-import java.time.temporal.ChronoUnit;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-/**
|
|
|
- * @Description 点检记录 service 实现类
|
|
|
- * @Author liuyu
|
|
|
- * @Date 2020-05-29 10:39:40
|
|
|
- * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
|
|
|
- */
|
|
|
-@AllArgsConstructor
|
|
|
-@Service("workJobService")
|
|
|
-public class WorkJobServiceImpl extends BaseServiceImpl<WorkJobMapper, WorkJob, CheckJobDTO> implements WorkJobService {
|
|
|
- private WorkPlanMapper planMapper;
|
|
|
- private WorkProjectPlanRelationMapper checkProjectPlanRelationMapper;
|
|
|
- private WorkProjectMapper projectMapper;
|
|
|
- private WorkStandardMapper standardMapper;
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- public int batchDelete(List<String> ids) {
|
|
|
- Weekend<WorkJob> weekend = new Weekend<>(WorkJob.class);
|
|
|
- WeekendCriteria<WorkJob, Object> weekendCriteria = weekend.weekendCriteria();
|
|
|
- weekendCriteria.andIn(WorkJob::getId, ids);
|
|
|
- mapper.deleteByExample(weekend);
|
|
|
- return 1;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public AbstractPageResultBean<CheckJobVO> selectPageList(CheckJobDTO record, int pageNum, int pageSize) {
|
|
|
- PageHelper.startPage(pageNum, pageSize);
|
|
|
- return new MyPage(mapper.selectList(record));
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public AbstractPageResultBean<WorkJob> selectPageInfo(CheckJobDTO record, int pageNum, int pageSize) {
|
|
|
- PageHelper.startPage(pageNum, pageSize);
|
|
|
- AbstractPageResultBean<WorkJob> pageInfo = new MyPage(mapper.selectList(record));
|
|
|
- return pageInfo;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void genTask(int checkType) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void checkJobStatus() {
|
|
|
- // 1.查询状态为未执行和执行中的任务
|
|
|
- Weekend<WorkJob> weekend = new Weekend<>(WorkJob.class);
|
|
|
- Integer[] status = {1, 2};
|
|
|
- weekend.weekendCriteria().andIn(WorkJob::getStatus, Arrays.asList(status));
|
|
|
- List<WorkJob> checkJobs = mapper.selectByExample(weekend);
|
|
|
- // 2.判断当前时间是否大于结束时间是则设置状态未已过期
|
|
|
- LocalDateTime now = LocalDateTime.now();
|
|
|
- checkJobs.forEach(job -> {
|
|
|
- LocalDateTime endTime = job.getEndTime();
|
|
|
- if(now.isAfter(endTime)){
|
|
|
- job.setStatus(CheckJobStatusEnum.OUT_OF_DATE.getValue());
|
|
|
- mapper.updateByPrimaryKeySelective(job);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 判断是否今日生成任务
|
|
|
- *
|
|
|
- * @param lastGeneratedTime
|
|
|
- * @param period
|
|
|
- * @param periodType
|
|
|
- * @return
|
|
|
- */
|
|
|
- private boolean isGenTask(LocalDateTime lastGeneratedTime, LocalDate currentDate, int period, int periodType) {
|
|
|
- if (ObjectUtil.isNull(lastGeneratedTime)) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- LocalDate endDate = null;
|
|
|
- LocalDate lastGenerateDate = lastGeneratedTime.toLocalDate();
|
|
|
- if (CheckPlanPeriodTypeEnum.DAY.getValue() == periodType) {
|
|
|
- endDate = DateUtils.plus(lastGenerateDate, period, ChronoUnit.DAYS);
|
|
|
- }
|
|
|
- if (CheckPlanPeriodTypeEnum.WEEK.getValue() == periodType) {
|
|
|
- endDate = DateUtils.plus(lastGenerateDate, periodType * 7, ChronoUnit.DAYS);
|
|
|
- }
|
|
|
- if (CheckPlanPeriodTypeEnum.MONTH.getValue() == periodType) {
|
|
|
- endDate = DateUtils.plus(lastGenerateDate, period, ChronoUnit.MONTHS);
|
|
|
- }
|
|
|
- if (CheckPlanPeriodTypeEnum.SEASON.getValue() == periodType) {
|
|
|
- endDate = DateUtils.plus(lastGenerateDate, period * 3, ChronoUnit.MONTHS);
|
|
|
- }
|
|
|
- if (CheckPlanPeriodTypeEnum.YEAR.getValue() == periodType) {
|
|
|
- endDate = DateUtils.plus(lastGenerateDate, period, ChronoUnit.YEARS);
|
|
|
- }
|
|
|
- return currentDate.isAfter(endDate);
|
|
|
- }
|
|
|
-
|
|
|
- private void calcTime(WorkJob checkJob, LocalDate currentDate, int validaTime, int validTimeType) {
|
|
|
- LocalDate endDate = null;
|
|
|
- checkJob.setStartTime(LocalDateTime.of(currentDate, LocalTime.of(9, 0)));
|
|
|
- if (CheckPlanPeriodTypeEnum.DAY.getValue() == validTimeType) {
|
|
|
- endDate = DateUtils.plus(currentDate, validaTime, ChronoUnit.DAYS);
|
|
|
- }
|
|
|
- if (CheckPlanPeriodTypeEnum.WEEK.getValue() == validTimeType) {
|
|
|
- endDate = DateUtils.plus(currentDate, validaTime * 7, ChronoUnit.DAYS);
|
|
|
- }
|
|
|
- if (CheckPlanPeriodTypeEnum.MONTH.getValue() == validTimeType) {
|
|
|
- endDate = DateUtils.plus(currentDate, validaTime, ChronoUnit.MONTHS);
|
|
|
- }
|
|
|
- if (CheckPlanPeriodTypeEnum.SEASON.getValue() == validTimeType) {
|
|
|
- endDate = DateUtils.plus(currentDate, validaTime * 3, ChronoUnit.MONTHS);
|
|
|
- }
|
|
|
- if (CheckPlanPeriodTypeEnum.YEAR.getValue() == validTimeType) {
|
|
|
- endDate = DateUtils.plus(currentDate, validaTime, ChronoUnit.YEARS);
|
|
|
- }
|
|
|
- endDate = DateUtils.plus(endDate, -1, ChronoUnit.DAYS);
|
|
|
- checkJob.setEndTime(LocalDateTime.of(endDate, LocalTime.of(18, 0)));
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public CheckJobVO getDetail(Object id) {
|
|
|
- return mapper.selectDetail(id);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void executeJob(Object id) {
|
|
|
- WorkJob checkJob = mapper.selectByPrimaryKey(id);
|
|
|
- checkJob.setStatus(CheckJobStatusEnum.EXECUTING.getValue());
|
|
|
- checkJob.setActualStartTime(LocalDateTime.now());
|
|
|
- UserInfo userInfo = SecurityUtils.getUser().getUserInfo();
|
|
|
- checkJob.setUpdateTime(LocalDateTime.now());
|
|
|
- checkJob.setUpdateUserId(userInfo.getUserId());
|
|
|
- checkJob.setUpdateUserName(userInfo.getUsername());
|
|
|
- mapper.updateByPrimaryKeySelective(checkJob);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void finishJob(CheckJobDTO dto) {
|
|
|
- WorkJob checkJob = mapper.selectByPrimaryKey(dto.getId());
|
|
|
- checkJob.setStatus(CheckJobStatusEnum.FINISHED.getValue());
|
|
|
- checkJob.setActualEndTime(LocalDateTime.now());
|
|
|
- UserInfo userInfo = SecurityUtils.getUser().getUserInfo();
|
|
|
- checkJob.setUpdateTime(LocalDateTime.now());
|
|
|
- checkJob.setUpdateUserId(userInfo.getUserId());
|
|
|
- checkJob.setUpdateUserName(userInfo.getUsername());
|
|
|
- checkJob.setSbStatus(dto.getSbStatus());
|
|
|
- checkJob.setFeedback(dto.getFeedback());
|
|
|
- mapper.updateByPrimaryKeySelective(checkJob);
|
|
|
- }
|
|
|
-}
|