|
|
|
@ -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;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -82,47 +79,54 @@ public class MesReportWorkByPreDayJob extends BaseMesScheduleJob {
|
|
|
|
|
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) {
|
|
|
|
|
List<MesProductionRecord> mesProductionRecords = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
mesProductionRecords = mesProductionRecordList.stream().filter(
|
|
|
|
|
w -> w.getWorkCenterCode().equalsIgnoreCase(mesWorkOrder.getWorkCenterCode())
|
|
|
|
|
&& w.getPartNo().equalsIgnoreCase(mesWorkOrder.getPartNo())).collect(Collectors.toList());
|
|
|
|
|
workOrderService.doPcnJobProductReport(mesProductionRecords, mesShiftList, wmsJobParamModel.getOrganizeCode(), userName, mesWorkOrder);
|
|
|
|
|
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();
|
|
|
|
|
LOGGER.info("产线=-零件号:{},:{},报工mesProductionRecordList:{}",k, v.size());
|
|
|
|
|
//3.插入生产工单表
|
|
|
|
|
List<MesWorkOrder> mesWorkOrders = workOrderService.insertMesWorkOrder(v, mesShiftList, wmsJobParamModel.getOrganizeCode(), userName);
|
|
|
|
|
if (CollectionUtils.isEmpty(mesWorkOrders)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
LOGGER.info("产线:{}报工mesWorkOrders:{}", workCenterCode, mesWorkOrders.size());
|
|
|
|
|
//4.根据产线+物料产生的工单报工
|
|
|
|
|
for (MesWorkOrder mesWorkOrder : mesWorkOrders) {
|
|
|
|
|
List<MesProductionRecord> mesProductionRecords = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
mesProductionRecords = mesProductionRecordList.stream().filter(
|
|
|
|
|
w -> w.getWorkCenterCode().equalsIgnoreCase(mesWorkOrder.getWorkCenterCode())
|
|
|
|
|
&& w.getPartNo().equalsIgnoreCase(mesWorkOrder.getPartNo())).collect(Collectors.toList());
|
|
|
|
|
workOrderService.doPcnJobProductReport(mesProductionRecords, mesShiftList, wmsJobParamModel.getOrganizeCode(), userName, mesWorkOrder);
|
|
|
|
|
|
|
|
|
|
for (MesProductionRecord mesProductionRecord : mesProductionRecords) {
|
|
|
|
|
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());
|
|
|
|
|
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.setReportStatus(MesExtEnumUtil.REPORT_STATUS.REPORT_STATUS_20.getValue());
|
|
|
|
|
mesProductionRecord.setSystemSyncStatus(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
|
|
|
|
|
ConvertBean.serviceModelUpdate(mesProductionRecord, userName);
|
|
|
|
|
mesProductionRecord.setModifyDatetime((new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS")).format(new Date()));
|
|
|
|
|
mesProductionRecord.setReportStatus(MesExtEnumUtil.REPORT_STATUS.REPORT_STATUS_20.getValue());
|
|
|
|
|
mesProductionRecord.setSystemSyncStatus(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
|
|
|
|
|
ConvertBean.serviceModelUpdate(mesProductionRecord, userName);
|
|
|
|
|
mesProductionRecord.setModifyDatetime((new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS")).format(new Date()));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
productionRecordRao.saveAll(mesProductionRecords);
|
|
|
|
|
} catch (ImppBusiException e) {
|
|
|
|
|
List<String> snList = mesProductionRecords.stream().map(MesProductionRecord::getProductSn).collect(Collectors.toList());
|
|
|
|
|
String errorMsg = StringUtil.isEmpty(e.getErrorDetail()) ? e.getErrorMsg() : e.getErrorDetail();
|
|
|
|
|
LOGGER.info("条码:{}报工失败,{}", snList, errorMsg);
|
|
|
|
|
for (MesProductionRecord mesProductionRecord : mesProductionRecords) {
|
|
|
|
|
productionRecordService.updateProductionRecord(mesProductionRecord.getOrganizeCode(), userName, mesProductionRecord.getId(), errorMsg);
|
|
|
|
|
}
|
|
|
|
|
productionRecordRao.saveAll(mesProductionRecords);
|
|
|
|
|
} catch (ImppBusiException e) {
|
|
|
|
|
List<String> snList = mesProductionRecords.stream().map(MesProductionRecord::getProductSn).collect(Collectors.toList());
|
|
|
|
|
String errorMsg = StringUtil.isEmpty(e.getErrorDetail()) ? e.getErrorMsg() : e.getErrorDetail();
|
|
|
|
|
LOGGER.info("条码:{}报工失败,{}", snList, errorMsg);
|
|
|
|
|
for (MesProductionRecord mesProductionRecord : mesProductionRecords) {
|
|
|
|
|
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();
|
|
|
|
|