From d3f040aa457ec55db941c96c07a0bff650cb1e87 Mon Sep 17 00:00:00 2001 From: zpl Date: Wed, 25 Aug 2021 11:37:17 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=9C=88=E7=82=B9=E6=A3=80bug=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../equip/service/impl/ResourceInspectPlanServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/equip/src/main/java/com/foreverwin/mesnac/equip/service/impl/ResourceInspectPlanServiceImpl.java b/equip/src/main/java/com/foreverwin/mesnac/equip/service/impl/ResourceInspectPlanServiceImpl.java index 6114482e..2d281b15 100644 --- a/equip/src/main/java/com/foreverwin/mesnac/equip/service/impl/ResourceInspectPlanServiceImpl.java +++ b/equip/src/main/java/com/foreverwin/mesnac/equip/service/impl/ResourceInspectPlanServiceImpl.java @@ -436,7 +436,7 @@ public class ResourceInspectPlanServiceImpl extends ServiceImpl Date: Wed, 25 Aug 2021 17:47:08 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=AF=8F=E6=97=A55=E7=82=B9=EF=BC=8C?= =?UTF-8?q?=E5=B0=86=E8=B7=B3=E8=BF=87=E6=9C=AA=E5=AE=8C=E6=88=90=E7=82=B9?= =?UTF-8?q?=E6=A3=80=E7=9A=84=E4=BB=BB=E5=8A=A1=EF=BC=8C=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E6=96=B0=E7=9A=84=E7=82=B9=E6=A3=80=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ResourceInspectTaskJobService.java | 6 +++ .../ResourceInspectTaskJobServiceImpl.java | 49 +++++++++++++++++++ .../quartz/job/ResourceInspectTaskJob.java | 44 +++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 equip/src/main/java/com/foreverwin/mesnac/equip/service/ResourceInspectTaskJobService.java create mode 100644 equip/src/main/java/com/foreverwin/mesnac/equip/service/impl/ResourceInspectTaskJobServiceImpl.java create mode 100644 quartz/src/main/java/com/foreverwin/mesnac/quartz/job/ResourceInspectTaskJob.java diff --git a/equip/src/main/java/com/foreverwin/mesnac/equip/service/ResourceInspectTaskJobService.java b/equip/src/main/java/com/foreverwin/mesnac/equip/service/ResourceInspectTaskJobService.java new file mode 100644 index 00000000..a2cb4cef --- /dev/null +++ b/equip/src/main/java/com/foreverwin/mesnac/equip/service/ResourceInspectTaskJobService.java @@ -0,0 +1,6 @@ +package com.foreverwin.mesnac.equip.service; + +public interface ResourceInspectTaskJobService { + + void resourceInspectTaskJobProcess(String site); +} diff --git a/equip/src/main/java/com/foreverwin/mesnac/equip/service/impl/ResourceInspectTaskJobServiceImpl.java b/equip/src/main/java/com/foreverwin/mesnac/equip/service/impl/ResourceInspectTaskJobServiceImpl.java new file mode 100644 index 00000000..550324fe --- /dev/null +++ b/equip/src/main/java/com/foreverwin/mesnac/equip/service/impl/ResourceInspectTaskJobServiceImpl.java @@ -0,0 +1,49 @@ +package com.foreverwin.mesnac.equip.service.impl; + +import com.foreverwin.mesnac.common.constant.Constants; +import com.foreverwin.mesnac.equip.mapper.ResourceInspectTaskMapper; +import com.foreverwin.mesnac.equip.model.ResourceInspectTask; +import com.foreverwin.mesnac.equip.service.ResourceInspectPlanService; +import com.foreverwin.mesnac.equip.service.ResourceInspectTaskJobService; +import com.foreverwin.mesnac.equip.service.ResourceInspectTaskService; +import com.foreverwin.modular.core.util.CommonMethods; +import org.apache.tomcat.jni.Local; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDateTime; +import java.util.List; + +@Service +@Transactional(rollbackFor = Exception.class) +public class ResourceInspectTaskJobServiceImpl implements ResourceInspectTaskJobService { + + @Autowired + ResourceInspectTaskMapper resourceInspectTaskMapper; + @Autowired + ResourceInspectPlanService resourceInspectPlanService; + @Autowired + ResourceInspectTaskService resourceInspectTaskService; + + @Override + public void resourceInspectTaskJobProcess(String site) { + String user = CommonMethods.getUser(); + ResourceInspectTask resourceInspectTask = new ResourceInspectTask(); + resourceInspectTask.setSite(site); + resourceInspectTask.setCategory(Constants.INSPECTION_TYPE_DM); + LocalDateTime now = LocalDateTime.now(); + LocalDateTime dateTime = LocalDateTime.now().minusDays(1); + resourceInspectTask.setPlanStartDate(dateTime); + resourceInspectTask.setPlanCompleteDate(now); + List 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/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; + } +} From 7367cc2773210968a656b6fe46ad2b33aa23dd19 Mon Sep 17 00:00:00 2001 From: zpl Date: Wed, 25 Aug 2021 17:52:33 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=90=8C=E4=B8=80=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E7=BB=B4=E6=8A=A4=E7=9B=B8=E5=90=8C=E7=82=B9?= =?UTF-8?q?=E6=A3=80=E7=B1=BB=E5=9E=8B=E7=9A=84=E7=82=B9=E6=A3=80=E8=AE=A1?= =?UTF-8?q?=E5=88=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../equip/mapper/ResourceInspectTaskMapper.java | 4 ++++ .../impl/ResourceInspectPlanServiceImpl.java | 12 ++++++++++++ .../mapper/ResourceInspectTaskMapper.xml | 17 ++++++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) 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 - AND ZRIT.resrce = #{resrce} + AND ZRIT.RESRCE = #{resrce} + + + AND ZRIT.CATEGORY = #{category} + + + AND ZRIT.TASK_CREATE_DATE <= #{planCompleteDate} + + + AND ZRIT.TASK_CREATE_DATE >= #{planStartDate} + + +