master
philip 3 years ago
parent bf1ba1d3b6
commit 772fa58b45

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

Loading…
Cancel
Save