|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
|
package org.springblade.desk.produce.service.impl; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
@ -23,8 +24,11 @@ import org.springblade.desk.device.service.IEquipmentService; |
|
|
|
|
import org.springblade.desk.device.service.IFeiBaSetService; |
|
|
|
|
import org.springblade.desk.device.service.IRackSetService; |
|
|
|
|
import org.springblade.desk.energy.pojo.entity.BsEpciuPatrolInspectionEntity; |
|
|
|
|
import org.springblade.desk.energy.pojo.entity.BsSafeInspectionPointEntity; |
|
|
|
|
import org.springblade.desk.energy.pojo.entity.BsSafePatrolInspectionEntity; |
|
|
|
|
import org.springblade.desk.energy.service.IBsEpciuPatrolInspectionService; |
|
|
|
|
import org.springblade.desk.energy.service.IBsSafeInspectionPointService; |
|
|
|
|
import org.springblade.desk.energy.service.IBsSafePatrolInspectionService; |
|
|
|
|
import org.springblade.desk.order.pojo.entity.YieldOrder; |
|
|
|
|
import org.springblade.desk.order.service.IYieldOrderService; |
|
|
|
|
import org.springblade.desk.produce.mapper.WorkPlanMapper; |
|
|
|
|
@ -38,6 +42,8 @@ import org.springblade.desk.quality.pojo.entity.InspectionTask; |
|
|
|
|
import org.springblade.desk.quality.service.IInspectionTaskService; |
|
|
|
|
import org.springblade.desk.quality.service.IWorkPlanItemService; |
|
|
|
|
import org.springblade.scheduling.pojo.entity.CraftAbilityEntity; |
|
|
|
|
import org.springblade.system.feign.IUserClient; |
|
|
|
|
import org.springblade.system.pojo.entity.User; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
@ -90,6 +96,10 @@ public class PdaLoadServiceImpl extends BaseServiceImpl<WorkPlanMapper, WorkPlan |
|
|
|
|
|
|
|
|
|
private final IBsEpciuPatrolInspectionService bsEpciuPatrolInspectionService; |
|
|
|
|
|
|
|
|
|
private final IBsSafePatrolInspectionService inspectionService; |
|
|
|
|
private final IUserClient userClient; |
|
|
|
|
private final IBsSafeInspectionPointService bsSafeInspectionPointService; |
|
|
|
|
|
|
|
|
|
// @Value("${request.device.prefixId}")
|
|
|
|
|
private String prefixId; |
|
|
|
|
|
|
|
|
|
@ -438,9 +448,10 @@ public class PdaLoadServiceImpl extends BaseServiceImpl<WorkPlanMapper, WorkPlan |
|
|
|
|
if (StringUtils.isBlank(code) || flag == null) { |
|
|
|
|
throw new RuntimeException("pda.dataFormat.incorrect", null); |
|
|
|
|
} |
|
|
|
|
List<BsEpciuPatrolInspectionEntity> piList = bsEpciuPatrolInspectionService.ListPi(code, userId); |
|
|
|
|
//安全 - 巡检
|
|
|
|
|
List<BsSafePatrolInspectionEntity> piList = inspectionService.getByCode(code); |
|
|
|
|
piList = piList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> |
|
|
|
|
new TreeSet<>(Comparator.comparing(BsEpciuPatrolInspectionEntity::getEpcId))), ArrayList::new)); |
|
|
|
|
new TreeSet<>(Comparator.comparing(BsSafePatrolInspectionEntity::getIpId))), ArrayList::new)); |
|
|
|
|
if (piList == null || piList.size() == 0) { |
|
|
|
|
if (flag) { |
|
|
|
|
throw new RuntimeException("product.noPatrolCheckTask", null); |
|
|
|
|
@ -450,7 +461,66 @@ public class PdaLoadServiceImpl extends BaseServiceImpl<WorkPlanMapper, WorkPlan |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void saveByInspection(JSONObject data, boolean b) { |
|
|
|
|
public void saveSafetyInspection(String code, String man, String memo) { |
|
|
|
|
// 根据编码去拿未检验的数据
|
|
|
|
|
List<BsSafePatrolInspectionEntity> spiList = inspectionService.getByCode(code); |
|
|
|
|
if (spiList == null || spiList.size() == 0) { |
|
|
|
|
throw new RuntimeException("根据编码未找到需要处理数据"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<User> users = userClient.listByNameNolike(man); |
|
|
|
|
|
|
|
|
|
if (CollUtil.isEmpty(users)) { |
|
|
|
|
throw new RuntimeException("根据域账号未找到对应的处理人"); |
|
|
|
|
} |
|
|
|
|
User user = users.get(0); |
|
|
|
|
|
|
|
|
|
Date date = new Date(); |
|
|
|
|
|
|
|
|
|
for (BsSafePatrolInspectionEntity safePatrolInspection : spiList) { |
|
|
|
|
// 不超过一个小时算正常检验
|
|
|
|
|
if (new Date().getTime() - safePatrolInspection.getLaunchTime().getTime() <= 60 * 60 * 1000) { |
|
|
|
|
safePatrolInspection.setTaskStatus(BsSafePatrolInspectionEntity.CHECKED.toString()); |
|
|
|
|
} else { |
|
|
|
|
// 超过一个小时但是下个任务并没有触发
|
|
|
|
|
int hours = safePatrolInspection.getLaunchTime().getHours(); |
|
|
|
|
int hours1 = new Date().getHours(); |
|
|
|
|
if (hours == 0 && hours1 < 2) { |
|
|
|
|
safePatrolInspection.setTaskStatus(BsSafePatrolInspectionEntity.NOT_ON_TIME.toString()); |
|
|
|
|
} else if (hours == 2 && hours1 < 5) { |
|
|
|
|
safePatrolInspection.setTaskStatus(BsSafePatrolInspectionEntity.NOT_ON_TIME.toString()); |
|
|
|
|
} else if (hours == 5 && hours1 < 7) { |
|
|
|
|
safePatrolInspection.setTaskStatus(BsSafePatrolInspectionEntity.NOT_ON_TIME.toString()); |
|
|
|
|
} else if (hours == 7 && hours1 < 8) { |
|
|
|
|
safePatrolInspection.setTaskStatus(BsSafePatrolInspectionEntity.NOT_ON_TIME.toString()); |
|
|
|
|
} else { |
|
|
|
|
// 超过一个小时但是下个任务已触发
|
|
|
|
|
safePatrolInspection.setTaskStatus(BsSafePatrolInspectionEntity.NO_CHECK.toString()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
safePatrolInspection.setTestTime(date); |
|
|
|
|
safePatrolInspection.setInsMan(man); |
|
|
|
|
safePatrolInspection.setParMemo(memo); |
|
|
|
|
BsSafeInspectionPointEntity safeInspectionPoint = bsSafeInspectionPointService.getByKey(safePatrolInspection.getIpId()); |
|
|
|
|
safeInspectionPoint.setLastInsCycle(date); |
|
|
|
|
inspectionService.updateOldPatrol(safePatrolInspection.getIpId(), safePatrolInspection.getLaunchTime(), user.getId()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object getInspectionBySan(String code, Short eipType) { |
|
|
|
|
return bsEpciuPatrolInspectionService.ListPi(code, eipType); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void savePatrolIns(BsEpciuPatrolInspectionEntity epPatrolInspection) { |
|
|
|
|
//if (epPatrolInspection.getEpiId() != null) {
|
|
|
|
|
//
|
|
|
|
|
//}
|
|
|
|
|
if (Objects.isNull(epPatrolInspection.getId())) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
bsEpciuPatrolInspectionService.savePatrolIns(epPatrolInspection); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|