|
|
|
@ -27,8 +27,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
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.stream.Collectors;
|
|
|
|
|
|
|
|
|
@ -79,44 +81,55 @@ public class MesReportWorkByPreDayJob extends BaseMesScheduleJob {
|
|
|
|
|
if (CollectionUtils.isEmpty(mesProductionRecordList)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
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.根据产线+物料产生的工单报工
|
|
|
|
|
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 = mesProductionRecordList.stream().filter(
|
|
|
|
|
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) {
|
|
|
|
|
try {
|
|
|
|
|
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);
|
|
|
|
|
} catch (ImppBusiException e) {
|
|
|
|
|
String errorMsg = StringUtil.isEmpty(e.getErrorDetail()) ? e.getErrorMsg(): e.getErrorDetail();
|
|
|
|
|
LOGGER.error("条码:{}报工失败,{}", mesProductionRecord.getProductSn(), errorMsg);
|
|
|
|
|
productionRecordService.updateProductionRecord(mesProductionRecord.getOrganizeCode(), userName, mesProductionRecord.getId(), errorMsg);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (ImppBusiException e) {
|
|
|
|
|
LOGGER.error("产线:{}报工失败:{}", workCenterCode, e.getErrorDetail());
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|