|
|
@ -31,10 +31,8 @@ import com.foreverwin.mesnac.production.mapper.SfcCrossMapper;
|
|
|
|
import com.foreverwin.mesnac.production.mapper.SfcDataAssembleMapper;
|
|
|
|
import com.foreverwin.mesnac.production.mapper.SfcDataAssembleMapper;
|
|
|
|
import com.foreverwin.mesnac.production.model.LoadInventory;
|
|
|
|
import com.foreverwin.mesnac.production.model.LoadInventory;
|
|
|
|
import com.foreverwin.mesnac.production.model.SfcHoldLog;
|
|
|
|
import com.foreverwin.mesnac.production.model.SfcHoldLog;
|
|
|
|
import com.foreverwin.mesnac.production.service.LoadInventoryService;
|
|
|
|
import com.foreverwin.mesnac.production.model.WorkShopTransfer;
|
|
|
|
import com.foreverwin.mesnac.production.service.PodTemplateService;
|
|
|
|
import com.foreverwin.mesnac.production.service.*;
|
|
|
|
import com.foreverwin.mesnac.production.service.SfcCrossService;
|
|
|
|
|
|
|
|
import com.foreverwin.mesnac.production.service.SfcHoldLogService;
|
|
|
|
|
|
|
|
import com.foreverwin.modular.core.exception.BaseException;
|
|
|
|
import com.foreverwin.modular.core.exception.BaseException;
|
|
|
|
import com.foreverwin.modular.core.meext.MEServices;
|
|
|
|
import com.foreverwin.modular.core.meext.MEServices;
|
|
|
|
import com.foreverwin.modular.core.util.CommonMethods;
|
|
|
|
import com.foreverwin.modular.core.util.CommonMethods;
|
|
|
@ -92,6 +90,8 @@ public class PodTemplateServiceImpl implements PodTemplateService {
|
|
|
|
private LoadInventoryService loadInventoryService;
|
|
|
|
private LoadInventoryService loadInventoryService;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private SfcHoldLogService sfcHoldLogService;
|
|
|
|
private SfcHoldLogService sfcHoldLogService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private WorkShopTransferService workShopTransferService;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Map<String, Object> resrceEnter(WorkCenterDto workCenterDto) {
|
|
|
|
public Map<String, Object> resrceEnter(WorkCenterDto workCenterDto) {
|
|
|
@ -208,16 +208,20 @@ public class PodTemplateServiceImpl implements PodTemplateService {
|
|
|
|
String dispatchNo = sfcDto.getDispatchNo();
|
|
|
|
String dispatchNo = sfcDto.getDispatchNo();
|
|
|
|
Sfc sfcServiceById = sfcService.getById(HandleEnum.SFC.getHandle(site, sfc));
|
|
|
|
Sfc sfcServiceById = sfcService.getById(HandleEnum.SFC.getHandle(site, sfc));
|
|
|
|
BigDecimal qty = new BigDecimal(sfcServiceById.getQty().toString());
|
|
|
|
BigDecimal qty = new BigDecimal(sfcServiceById.getQty().toString());
|
|
|
|
//是否有互检检验项目
|
|
|
|
WorkShopTransfer transfer = workShopTransferService.sfcEnter(sfc, "OUT");
|
|
|
|
List<InspectionItemDetail> inspectionItemDetails = inspectionItemService.selectQualityInspection(sfc, operation, stepId, Constants.INSPECTION_TYPE_H);
|
|
|
|
String isOutSource = transfer.getIsOutSource();
|
|
|
|
if (inspectionItemDetails.size() > 0 && inspectionItemDetails.get(0) != null) {
|
|
|
|
if (StringUtil.isBlank(isOutSource)||!isOutSource.equals(Constants.STATUS_Y)){
|
|
|
|
//是否有互检检验任务及已完成
|
|
|
|
//是否有互检检验项目
|
|
|
|
InspectionTask createTask = inspectionTaskService.isCreateTask(site, Constants.INSPECTION_TYPE_H, sfc, operation, stepId);
|
|
|
|
List<InspectionItemDetail> inspectionItemDetails = inspectionItemService.selectQualityInspection(sfc, operation, stepId, Constants.INSPECTION_TYPE_H);
|
|
|
|
if (createTask == null || !createTask.getStatus().equals(Constants.INSPECTION_TASK_STATUS_COMPLETE)) {
|
|
|
|
if (inspectionItemDetails.size() > 0 && inspectionItemDetails.get(0) != null) {
|
|
|
|
throw new BaseException("请完成互检检验任务");
|
|
|
|
//是否有互检检验任务及已完成
|
|
|
|
}
|
|
|
|
InspectionTask createTask = inspectionTaskService.isCreateTask(site, Constants.INSPECTION_TYPE_H, sfc, operation, stepId);
|
|
|
|
if (!createTask.getResult().equals(Constants.RSESULT_OK)) {
|
|
|
|
if (createTask == null || !createTask.getStatus().equals(Constants.INSPECTION_TASK_STATUS_COMPLETE)) {
|
|
|
|
throw new BaseException("互检任务不合格,不能开始请检查");
|
|
|
|
throw new BaseException("请完成互检检验任务");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!createTask.getResult().equals(Constants.RSESULT_OK)) {
|
|
|
|
|
|
|
|
throw new BaseException("互检任务不合格,不能开始请检查");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//是否完成专检
|
|
|
|
//是否完成专检
|
|
|
@ -258,32 +262,35 @@ public class PodTemplateServiceImpl implements PodTemplateService {
|
|
|
|
if (status.equals("404")) {
|
|
|
|
if (status.equals("404")) {
|
|
|
|
throw new BaseException("产品条码" + sfc + "已暂停");
|
|
|
|
throw new BaseException("产品条码" + sfc + "已暂停");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BigDecimal workHour=BigDecimal.ZERO;
|
|
|
|
BigDecimal qty = new BigDecimal(sfcServiceById.getQty().toString());
|
|
|
|
BigDecimal qty = new BigDecimal(sfcServiceById.getQty().toString());
|
|
|
|
//是否有自检检验项目
|
|
|
|
WorkShopTransfer transfer = workShopTransferService.sfcEnter(sfc, "OUT");
|
|
|
|
List<InspectionItemDetail> inspectionItemDetails = inspectionItemService.selectQualityInspection(sfc, operation, stepId, Constants.INSPECTION_TYPE_Z);
|
|
|
|
String isOutSource = transfer.getIsOutSource();
|
|
|
|
if (inspectionItemDetails.size() > 0 && inspectionItemDetails.get(0) != null) {
|
|
|
|
if (StringUtil.isBlank(isOutSource)||!isOutSource.equals(Constants.STATUS_Y)) {
|
|
|
|
//是否有自检检验任务
|
|
|
|
//是否有自检检验项目
|
|
|
|
InspectionTask createTask = inspectionTaskService.isCreateTask(site, Constants.INSPECTION_TYPE_Z, sfc, operation, stepId);
|
|
|
|
List<InspectionItemDetail> inspectionItemDetails = inspectionItemService.selectQualityInspection(sfc, operation, stepId, Constants.INSPECTION_TYPE_Z);
|
|
|
|
if (createTask == null || !createTask.getStatus().equals(Constants.INSPECTION_TASK_STATUS_COMPLETE)) {
|
|
|
|
if (inspectionItemDetails.size() > 0 && inspectionItemDetails.get(0) != null) {
|
|
|
|
throw new BaseException("请完成自检检验任务");
|
|
|
|
//是否有自检检验任务
|
|
|
|
}
|
|
|
|
InspectionTask createTask = inspectionTaskService.isCreateTask(site, Constants.INSPECTION_TYPE_Z, sfc, operation, stepId);
|
|
|
|
if (!createTask.getResult().equals(Constants.RSESULT_OK)) {
|
|
|
|
if (createTask == null || !createTask.getStatus().equals(Constants.INSPECTION_TASK_STATUS_COMPLETE)) {
|
|
|
|
throw new BaseException("自检任务不合格,不能完成请检查");
|
|
|
|
throw new BaseException("请完成自检检验任务");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!createTask.getResult().equals(Constants.RSESULT_OK)) {
|
|
|
|
|
|
|
|
throw new BaseException("自检任务不合格,不能完成请检查");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//是否装配完成
|
|
|
|
//是否装配完成
|
|
|
|
List<Map<String, Object>> assembleList = sfcDataAssembleMapper.querySfcAssemble(HandleEnum.SFC_DISPATCH.getHandle(site, dispatchNo));
|
|
|
|
List<Map<String, Object>> assembleList = sfcDataAssembleMapper.querySfcAssemble(HandleEnum.SFC_DISPATCH.getHandle(site, dispatchNo));
|
|
|
|
if (assembleList != null && assembleList.size() > 0) {
|
|
|
|
if (assembleList != null && assembleList.size() > 0) {
|
|
|
|
for (Map<String, Object> objectMap : assembleList) {
|
|
|
|
for (Map<String, Object> objectMap : assembleList) {
|
|
|
|
String isAssemble = (String) objectMap.get("IS_ASSEMBLE");
|
|
|
|
String isAssemble = (String) objectMap.get("IS_ASSEMBLE");
|
|
|
|
if (!isAssemble.equals("GREEN")) {
|
|
|
|
if (!isAssemble.equals("GREEN")) {
|
|
|
|
throw new BaseException("未装配完成");
|
|
|
|
throw new BaseException("未装配完成");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//物料消耗
|
|
|
|
//物料消耗
|
|
|
|
materialConsumption(site, operation, HandleEnum.SFC.getHandle(site, sfc), stepId, resrce);
|
|
|
|
materialConsumption(site, operation, HandleEnum.SFC.getHandle(site, sfc), stepId, resrce);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
//专检创建
|
|
|
|
//专检创建
|
|
|
|
Map<String, Object> paramMap = new HashMap<>();
|
|
|
|
Map<String, Object> paramMap = new HashMap<>();
|
|
|
|
paramMap.put("SFC", sfc);
|
|
|
|
paramMap.put("SFC", sfc);
|
|
|
@ -312,17 +319,20 @@ public class PodTemplateServiceImpl implements PodTemplateService {
|
|
|
|
//计算工时
|
|
|
|
//计算工时
|
|
|
|
LocalDateTime startTime = sfcService.getSfcStartTime(HandleEnum.SFC.getHandle(site, sfc));
|
|
|
|
LocalDateTime startTime = sfcService.getSfcStartTime(HandleEnum.SFC.getHandle(site, sfc));
|
|
|
|
long workHourSeconds = Duration.between(startTime, LocalDateTime.now()).getSeconds();
|
|
|
|
long workHourSeconds = Duration.between(startTime, LocalDateTime.now()).getSeconds();
|
|
|
|
BigDecimal workHour = new BigDecimal(workHourSeconds).divide(BigDecimal.valueOf(3600), 2, RoundingMode.HALF_UP);
|
|
|
|
workHour = new BigDecimal(workHourSeconds).divide(BigDecimal.valueOf(3600), 2, RoundingMode.HALF_UP);
|
|
|
|
//减去暂停时间
|
|
|
|
//减去暂停时间
|
|
|
|
QueryWrapper<SfcHoldLog> queryWrapper=new QueryWrapper<>();
|
|
|
|
QueryWrapper<SfcHoldLog> queryWrapper = new QueryWrapper<>();
|
|
|
|
queryWrapper.eq(SfcHoldLog.SFC,sfc);
|
|
|
|
queryWrapper.eq(SfcHoldLog.SFC, sfc);
|
|
|
|
queryWrapper.eq(SfcHoldLog.STEP_ID,stepId);
|
|
|
|
queryWrapper.eq(SfcHoldLog.STEP_ID, stepId);
|
|
|
|
queryWrapper.eq(SfcHoldLog.TYPE,"CANCEL");
|
|
|
|
queryWrapper.eq(SfcHoldLog.TYPE, "CANCEL");
|
|
|
|
List<SfcHoldLog> list = sfcHoldLogService.list(queryWrapper);
|
|
|
|
List<SfcHoldLog> list = sfcHoldLogService.list(queryWrapper);
|
|
|
|
if (!list.isEmpty()){
|
|
|
|
if (!list.isEmpty()) {
|
|
|
|
BigDecimal holdTime = list.stream().map(SfcHoldLog::getHoldDuration).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
BigDecimal holdTime = list.stream().map(SfcHoldLog::getHoldDuration).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
workHour=workHour.subtract(holdTime);
|
|
|
|
workHour = workHour.subtract(holdTime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
sfcCrossService.completeAction(site, currentRevisionRef.getHandle(), resrce, sfcServiceById.getHandle(), qty);
|
|
|
|
sfcCrossService.completeAction(site, currentRevisionRef.getHandle(), resrce, sfcServiceById.getHandle(), qty);
|
|
|
|
//更改派工单状态
|
|
|
|
//更改派工单状态
|
|
|
|
sfcDispatchCommonService.updateSfcDispatchStatus(site, CommonMethods.getUser(), dispatchNo, DispatchStatusEnum.COMPLETE.getCode(),workHour);
|
|
|
|
sfcDispatchCommonService.updateSfcDispatchStatus(site, CommonMethods.getUser(), dispatchNo, DispatchStatusEnum.COMPLETE.getCode(),workHour);
|
|
|
|