diff --git a/equip/src/main/java/com/foreverwin/mesnac/equip/mapper/ResourceInspectTaskMapper.java b/equip/src/main/java/com/foreverwin/mesnac/equip/mapper/ResourceInspectTaskMapper.java index c20fc4e9..4144b9d0 100644 --- a/equip/src/main/java/com/foreverwin/mesnac/equip/mapper/ResourceInspectTaskMapper.java +++ b/equip/src/main/java/com/foreverwin/mesnac/equip/mapper/ResourceInspectTaskMapper.java @@ -3,6 +3,7 @@ package com.foreverwin.mesnac.equip.mapper; import com.foreverwin.mesnac.equip.dto.ResourceInspectTaskDto; import com.foreverwin.mesnac.equip.model.ResourceInspectTask; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; import java.time.LocalDateTime; @@ -46,4 +47,7 @@ public interface ResourceInspectTaskMapper extends BaseMapper resourceColl = new ArrayList<>(); + StringBuffer resInfo = new StringBuffer("["); for (ResourceInspectResource equip: equips) { equip.setResourceInspectPlanBo(handle); equip.setCreateUser(user); equip.setCreatedDateTime(LocalDateTime.now()); String resourceNo = equip.getResourceNo(); + Integer cnt = resourceInspectTaskMapper.findResourceTaskByResrceAndCategory(site, category, resourceNo); + if (cnt > 0){ + resInfo.append(resourceNo+","); + } String resourceHandle = HandleEnum.RESOURCE.getHandle(site, resourceNo); equip.setHandle(HandleEnum.RESOURCE_INSPECT_RESOURCE.getHandle(site,handle,resourceHandle)); resourceColl.add(equip); } + if (!resInfo.equals("")){ + throw BusinessException.build("设备编号" + resInfo.append("]") + "已经维护了相同点检类型的点检计划!"); + } resourceInspectResourceService.saveBatch(resourceColl); // 保存用户组清单 List userGroups = resourceInspectPlan.getInspectPlanUserGroupList(); @@ -380,6 +389,9 @@ public class ResourceInspectPlanServiceImpl extends ServiceImpl inspectTaskList = resourceInspectTaskMapper.getInspectTaskList(resourceInspectTask); + for (ResourceInspectTask inspectTask: inspectTaskList) { + resourceInspectPlanService.autoCreateTaskByResourceInspectTask(inspectTask); + inspectTask.setModifyUser(user); + inspectTask.setModifiedDateTime(LocalDateTime.now()); + } + if (inspectTaskList.size() > 0){ + resourceInspectTaskService.updateBatchById(inspectTaskList); + } + } +} diff --git a/equip/src/main/resources/mapper/ResourceInspectTaskMapper.xml b/equip/src/main/resources/mapper/ResourceInspectTaskMapper.xml index 30a34cd2..f15de7a5 100644 --- a/equip/src/main/resources/mapper/ResourceInspectTaskMapper.xml +++ b/equip/src/main/resources/mapper/ResourceInspectTaskMapper.xml @@ -717,9 +717,24 @@ AND ZRIT.RESOURCE_INSPECT_PLAN_BO = #{resourceInspectPlanBo} - AND ZRIT.resrce = #{resrce} + AND ZRIT.RESRCE = #{resrce} + + + AND ZRIT.CATEGORY = #{category} + + + AND ZRIT.TASK_CREATE_DATE <= #{planCompleteDate} + + + AND ZRIT.TASK_CREATE_DATE >= #{planStartDate} + + + diff --git a/quartz/src/main/java/com/foreverwin/mesnac/quartz/job/ResourceInspectTaskJob.java b/quartz/src/main/java/com/foreverwin/mesnac/quartz/job/ResourceInspectTaskJob.java new file mode 100644 index 00000000..b4fa0021 --- /dev/null +++ b/quartz/src/main/java/com/foreverwin/mesnac/quartz/job/ResourceInspectTaskJob.java @@ -0,0 +1,44 @@ +package com.foreverwin.mesnac.quartz.job; + +import com.foreverwin.mesnac.common.util.StringUtil; +import com.foreverwin.mesnac.equip.service.ResourceInspectTaskJobService; +import com.foreverwin.mesnac.equip.service.ResourceInspectTaskService; +import com.foreverwin.modular.core.exception.BaseException; +import org.quartz.DisallowConcurrentExecution; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * @Description TODO + * @Author zhaojiawei + * @Since 2021-07-22 + */ +@DisallowConcurrentExecution +public class ResourceInspectTaskJob implements Job { + private static final String SITE_UPPERCASE = "SITE"; + private static final String SITE_LOWERCASE = "site"; + + @Autowired + private ResourceInspectTaskJobService resourceInspectTaskJobService; + + @Override + public void execute(JobExecutionContext context) throws JobExecutionException { + //获取站点,若站点为空则抛出异常 + String site = getSite(context); + if (StringUtil.isBlank(site)) { + throw new BaseException("equip.quartz.task.not.site", null); + } + + resourceInspectTaskJobService.resourceInspectTaskJobProcess(site); + } + + private String getSite(JobExecutionContext context) { + String site = context.getJobDetail().getJobDataMap().getString(SITE_LOWERCASE); + if (StringUtil.isBlank(site)) { + site = context.getJobDetail().getJobDataMap().getString(SITE_UPPERCASE); + } + return site; + } +}