同一设备不能维护相同点检类型的点检计划

master
zpl 3 years ago
parent 1615ec8785
commit 7367cc2773

@ -3,6 +3,7 @@ package com.foreverwin.mesnac.equip.mapper;
import com.foreverwin.mesnac.equip.dto.ResourceInspectTaskDto; import com.foreverwin.mesnac.equip.dto.ResourceInspectTaskDto;
import com.foreverwin.mesnac.equip.model.ResourceInspectTask; import com.foreverwin.mesnac.equip.model.ResourceInspectTask;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -46,4 +47,7 @@ public interface ResourceInspectTaskMapper extends BaseMapper<ResourceInspectTas
* @return * @return
*/ */
LocalDateTime getMaxCreateTimeByStatus(ResourceInspectTask resourceInspectTask); LocalDateTime getMaxCreateTimeByStatus(ResourceInspectTask resourceInspectTask);
Integer findResourceTaskByResrceAndCategory(@Param("site") String site,@Param("category") String category, @Param("resrce") String resrce);
} }

@ -86,6 +86,7 @@ public class ResourceInspectPlanServiceImpl extends ServiceImpl<ResourceInspectP
if (inspectionItem == null){ if (inspectionItem == null){
throw BusinessException.build("检验项目清单不存在!!!"); throw BusinessException.build("检验项目清单不存在!!!");
} }
String category = resourceInspectPlan.getCategory();
//查询设备计划是否存在 //查询设备计划是否存在
String site = CommonMethods.getSite(); String site = CommonMethods.getSite();
resourceInspectPlan.setSite(site); resourceInspectPlan.setSite(site);
@ -134,15 +135,23 @@ public class ResourceInspectPlanServiceImpl extends ServiceImpl<ResourceInspectP
throw BusinessException.build("未添加设备!!!"); throw BusinessException.build("未添加设备!!!");
} }
Collection<ResourceInspectResource> resourceColl = new ArrayList<>(); Collection<ResourceInspectResource> resourceColl = new ArrayList<>();
StringBuffer resInfo = new StringBuffer("[");
for (ResourceInspectResource equip: equips) { for (ResourceInspectResource equip: equips) {
equip.setResourceInspectPlanBo(handle); equip.setResourceInspectPlanBo(handle);
equip.setCreateUser(user); equip.setCreateUser(user);
equip.setCreatedDateTime(LocalDateTime.now()); equip.setCreatedDateTime(LocalDateTime.now());
String resourceNo = equip.getResourceNo(); String resourceNo = equip.getResourceNo();
Integer cnt = resourceInspectTaskMapper.findResourceTaskByResrceAndCategory(site, category, resourceNo);
if (cnt > 0){
resInfo.append(resourceNo+",");
}
String resourceHandle = HandleEnum.RESOURCE.getHandle(site, resourceNo); String resourceHandle = HandleEnum.RESOURCE.getHandle(site, resourceNo);
equip.setHandle(HandleEnum.RESOURCE_INSPECT_RESOURCE.getHandle(site,handle,resourceHandle)); equip.setHandle(HandleEnum.RESOURCE_INSPECT_RESOURCE.getHandle(site,handle,resourceHandle));
resourceColl.add(equip); resourceColl.add(equip);
} }
if (!resInfo.equals("")){
throw BusinessException.build("设备编号" + resInfo.append("]") + "已经维护了相同点检类型的点检计划!");
}
resourceInspectResourceService.saveBatch(resourceColl); resourceInspectResourceService.saveBatch(resourceColl);
// 保存用户组清单 // 保存用户组清单
List<InspectPlanUserGroup> userGroups = resourceInspectPlan.getInspectPlanUserGroupList(); List<InspectPlanUserGroup> userGroups = resourceInspectPlan.getInspectPlanUserGroupList();
@ -380,6 +389,9 @@ public class ResourceInspectPlanServiceImpl extends ServiceImpl<ResourceInspectP
return; return;
} }
ResourceInspectResource resource = resourceInspectResourceService.getById(HandleEnum.RESOURCE_INSPECT_RESOURCE.getHandle(site,planHandle,resourceBo)); ResourceInspectResource resource = resourceInspectResourceService.getById(HandleEnum.RESOURCE_INSPECT_RESOURCE.getHandle(site,planHandle,resourceBo));
if (resource == null){
return;
}
String resourceStatus = resource.getStatus(); String resourceStatus = resource.getStatus();
// 设备非启用状态 // 设备非启用状态
if (!resourceStatus.equals("301")){ if (!resourceStatus.equals("301")){

@ -717,9 +717,24 @@
AND ZRIT.RESOURCE_INSPECT_PLAN_BO = #{resourceInspectPlanBo} AND ZRIT.RESOURCE_INSPECT_PLAN_BO = #{resourceInspectPlanBo}
</if> </if>
<if test="resrce != null and resrce != ''"> <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> </if>
</select> </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--> <!--自定义sql-->

Loading…
Cancel
Save