|
|
|
@ -28,10 +28,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -81,19 +78,22 @@ public class MesReportWorkByPreDayJob extends BaseMesScheduleJob {
|
|
|
|
|
if (CollectionUtils.isEmpty(mesProductionRecordList)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
LOGGER.info("产线:{}报工mesProductionRecordList:{}", workCenterCode, mesProductionRecordList.size());
|
|
|
|
|
//3.插入生产工单表
|
|
|
|
|
List<MesWorkOrder> mesWorkOrders = workOrderService.insertMesWorkOrder(mesProductionRecordList, mesShiftList, wmsJobParamModel.getOrganizeCode(), userName);
|
|
|
|
|
if (CollectionUtils.isEmpty(mesWorkOrders)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
LOGGER.info("产线:{}报工mesWorkOrders:{}", workCenterCode, mesWorkOrders.size());
|
|
|
|
|
//4.根据产线+物料产生的工单报工
|
|
|
|
|
for (MesWorkOrder mesWorkOrder : mesWorkOrders) {
|
|
|
|
|
Map<String,List<MesProductionRecord>> recordMap = mesProductionRecordList.stream().collect(Collectors.groupingBy(sn -> sn.getWorkCenterCode() + "=" + sn.getPartNo()));
|
|
|
|
|
for (Map.Entry<String, List<MesProductionRecord>> entry : recordMap.entrySet()) {
|
|
|
|
|
String k = entry.getKey();
|
|
|
|
|
List<MesProductionRecord> v = entry.getValue();
|
|
|
|
|
try {
|
|
|
|
|
LOGGER.info("产线=-零件号:{},:{},报工mesProductionRecordList:{}",k, v.size());
|
|
|
|
|
//3.插入生产工单表,根据产线和零件号会创建又给工单
|
|
|
|
|
MesWorkOrder mesWorkOrder = workOrderService.insertMesWorkOrder(v, mesShiftList, wmsJobParamModel.getOrganizeCode(), userName);
|
|
|
|
|
if (mesWorkOrder == null) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
LOGGER.info("产线:{}报工mesWorkOrder:{}", workCenterCode, mesWorkOrder.getWorkOrderNo());
|
|
|
|
|
//4.根据产线+物料产生的工单报工
|
|
|
|
|
List<MesProductionRecord> mesProductionRecords = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
mesProductionRecords = mesProductionRecordList.stream().filter(
|
|
|
|
|
mesProductionRecords = v.stream().filter(
|
|
|
|
|
w -> w.getWorkCenterCode().equalsIgnoreCase(mesWorkOrder.getWorkCenterCode())
|
|
|
|
|
&& w.getPartNo().equalsIgnoreCase(mesWorkOrder.getPartNo())).collect(Collectors.toList());
|
|
|
|
|
workOrderService.doPcnJobProductReport(mesProductionRecords, mesShiftList, wmsJobParamModel.getOrganizeCode(), userName, mesWorkOrder);
|
|
|
|
@ -101,11 +101,7 @@ public class MesReportWorkByPreDayJob extends BaseMesScheduleJob {
|
|
|
|
|
for (MesProductionRecord mesProductionRecord : mesProductionRecords) {
|
|
|
|
|
|
|
|
|
|
if (StringUtil.isEmpty(mesProductionRecord.getWorkOrderNo())) {
|
|
|
|
|
List<MesWorkOrder> collect = mesWorkOrders.stream().filter(w -> w.getWorkCenterCode().equalsIgnoreCase(mesProductionRecord.getWorkCenterCode())
|
|
|
|
|
&& w.getPartNo().equalsIgnoreCase(mesProductionRecord.getPartNo())).collect(Collectors.toList());
|
|
|
|
|
if (!CollectionUtils.isEmpty(collect)) {
|
|
|
|
|
mesProductionRecord.setWorkOrderNo(collect.get(0).getWorkOrderNo());
|
|
|
|
|
}
|
|
|
|
|
mesProductionRecord.setWorkOrderNo(mesWorkOrder.getWorkOrderNo());
|
|
|
|
|
}
|
|
|
|
|
mesProductionRecord.setReportStatus(MesExtEnumUtil.REPORT_STATUS.REPORT_STATUS_20.getValue());
|
|
|
|
|
mesProductionRecord.setSystemSyncStatus(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
|
|
|
|
@ -122,13 +118,13 @@ public class MesReportWorkByPreDayJob extends BaseMesScheduleJob {
|
|
|
|
|
productionRecordService.updateProductionRecord(mesProductionRecord.getOrganizeCode(), userName, mesProductionRecord.getId(), errorMsg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (ImppBusiException e) {
|
|
|
|
|
List<String> snList = mesProductionRecordList.stream().map(MesProductionRecord::getProductSn).collect(Collectors.toList());
|
|
|
|
|
String errorMsg = StringUtil.isEmpty(e.getErrorDetail()) ? e.getErrorMsg() : e.getErrorDetail();
|
|
|
|
|
LOGGER.info("条码:{}报工失败,{}", snList, errorMsg);
|
|
|
|
|
for (MesProductionRecord mesProductionRecord : mesProductionRecordList) {
|
|
|
|
|
productionRecordService.updateProductionRecord(mesProductionRecord.getOrganizeCode(), userName, mesProductionRecord.getId(), errorMsg);
|
|
|
|
|
} catch (ImppBusiException e) {
|
|
|
|
|
List<String> snList = v.stream().map(MesProductionRecord::getProductSn).collect(Collectors.toList());
|
|
|
|
|
String errorMsg = StringUtil.isEmpty(e.getErrorDetail()) ? e.getErrorMsg() : e.getErrorDetail();
|
|
|
|
|
LOGGER.info("条码:{}报工失败,{}", snList, errorMsg);
|
|
|
|
|
for (MesProductionRecord mesProductionRecord : v) {
|
|
|
|
|
productionRecordService.updateProductionRecord(mesProductionRecord.getOrganizeCode(), userName, mesProductionRecord.getId(), errorMsg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|