Merge remote-tracking branch 'origin/master'

master
philip 3 years ago
commit 9b51db95ec

@ -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<ResourceInspectTas
* @return
*/
LocalDateTime getMaxCreateTimeByStatus(ResourceInspectTask resourceInspectTask);
Integer findResourceTaskByResrceAndCategory(@Param("site") String site,@Param("category") String category, @Param("resrce") String resrce);
}

@ -0,0 +1,6 @@
package com.foreverwin.mesnac.equip.service;
public interface ResourceInspectTaskJobService {
void resourceInspectTaskJobProcess(String site);
}

@ -86,6 +86,7 @@ public class ResourceInspectPlanServiceImpl extends ServiceImpl<ResourceInspectP
if (inspectionItem == null){
throw BusinessException.build("检验项目清单不存在!!!");
}
String category = resourceInspectPlan.getCategory();
//查询设备计划是否存在
String site = CommonMethods.getSite();
resourceInspectPlan.setSite(site);
@ -134,15 +135,23 @@ public class ResourceInspectPlanServiceImpl extends ServiceImpl<ResourceInspectP
throw BusinessException.build("未添加设备!!!");
}
Collection<ResourceInspectResource> 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<InspectPlanUserGroup> userGroups = resourceInspectPlan.getInspectPlanUserGroupList();
@ -380,6 +389,9 @@ public class ResourceInspectPlanServiceImpl extends ServiceImpl<ResourceInspectP
return;
}
ResourceInspectResource resource = resourceInspectResourceService.getById(HandleEnum.RESOURCE_INSPECT_RESOURCE.getHandle(site,planHandle,resourceBo));
if (resource == null){
return;
}
String resourceStatus = resource.getStatus();
// 设备非启用状态
if (!resourceStatus.equals("301")){
@ -436,7 +448,7 @@ public class ResourceInspectPlanServiceImpl extends ServiceImpl<ResourceInspectP
minutes = Math.round(frequency*60*24*7);
break;
case "M":
minutes = Math.round(frequency*60*24*7*30);
minutes = Math.round(frequency*60*24*30);
break;
default:
throw BusinessException.build("周期时间不存在!");

@ -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<ResourceInspectTask> 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);
}
}
}

@ -717,9 +717,24 @@
AND ZRIT.RESOURCE_INSPECT_PLAN_BO = #{resourceInspectPlanBo}
</if>
<if test="resrce != null and resrce != ''">
AND ZRIT.resrce = #{resrce}
AND ZRIT.RESRCE = #{resrce}
</if>
<if test="category != null and category != ''">
AND ZRIT.CATEGORY = #{category}
</if>
<if test="planCompleteDate != null">
AND ZRIT.TASK_CREATE_DATE &lt;= #{planCompleteDate}
</if>
<if test="planStartDate != null">
AND ZRIT.TASK_CREATE_DATE &gt;= #{planStartDate}
</if>
</select>
<select id="findResourceTaskByResrceAndCategory" resultType="Integer">
SELECT COUNT(*) FROM Z_RESOURCE_INSPECT_TASK ZRIT
WHERE ZRIT.SITE = #{site} AND ZRIT.RESRCE = #{resrce} AND ZRIT.CATEGORY = #{category}
</select>
<!--自定义sql-->

@ -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;
}
}
Loading…
Cancel
Save