45034 PCN:排序报工数据边端汇报了,云端显示未汇报

45035   PCN:前一天汇总报工job,日志提示错误后,没有将错误原因放在加工记录表备注列
uat_temp-xw-202502110000-45034
xiangwei.zhang 3 months ago
parent 548ba84f08
commit 8612803152

@ -27,8 +27,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -79,44 +81,55 @@ public class MesReportWorkByPreDayJob extends BaseMesScheduleJob {
if (CollectionUtils.isEmpty(mesProductionRecordList)) { if (CollectionUtils.isEmpty(mesProductionRecordList)) {
continue; 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 { 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) { 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 -> w.getWorkCenterCode().equalsIgnoreCase(mesWorkOrder.getWorkCenterCode())
&& w.getPartNo().equalsIgnoreCase(mesWorkOrder.getPartNo())).collect(Collectors.toList()); && w.getPartNo().equalsIgnoreCase(mesWorkOrder.getPartNo())).collect(Collectors.toList());
workOrderService.doPcnJobProductReport(mesProductionRecords, mesShiftList, wmsJobParamModel.getOrganizeCode(), userName, mesWorkOrder); workOrderService.doPcnJobProductReport(mesProductionRecords, mesShiftList, wmsJobParamModel.getOrganizeCode(), userName, mesWorkOrder);
for (MesProductionRecord mesProductionRecord : mesProductionRecords) { for (MesProductionRecord mesProductionRecord : mesProductionRecords) {
try {
if (StringUtil.isEmpty(mesProductionRecord.getWorkOrderNo())) { if (StringUtil.isEmpty(mesProductionRecord.getWorkOrderNo())) {
List<MesWorkOrder> collect = mesWorkOrders.stream().filter(w -> w.getWorkCenterCode().equalsIgnoreCase(mesProductionRecord.getWorkCenterCode()) List<MesWorkOrder> collect = mesWorkOrders.stream().filter(w -> w.getWorkCenterCode().equalsIgnoreCase(mesProductionRecord.getWorkCenterCode())
&& w.getPartNo().equalsIgnoreCase(mesProductionRecord.getPartNo())).collect(Collectors.toList()); && w.getPartNo().equalsIgnoreCase(mesProductionRecord.getPartNo())).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(collect)) { if (!CollectionUtils.isEmpty(collect)) {
mesProductionRecord.setWorkOrderNo(collect.get(0).getWorkOrderNo()); 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); 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) { } 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);
}
} }
} }
} }

@ -60,6 +60,9 @@ public class MesProductionRecordService implements IMesProductionRecordService {
@Autowired @Autowired
private MesWorkCellRepository mesWorkCellRepository; private MesWorkCellRepository mesWorkCellRepository;
@Autowired
private MesProductionRecordRepository productionRecordRao;
@Override @Override
public List<MesProductionRecord> findProductionRecordList(String organizeCode, String productSn) { public List<MesProductionRecord> findProductionRecordList(String organizeCode, String productSn) {
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(productSn)) return null; if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(productSn)) return null;
@ -250,14 +253,14 @@ public class MesProductionRecordService implements IMesProductionRecordService {
@Override @Override
public void updateProductionRecord(List<MesProductionRecord> recordList, String userName, Integer reportStatus, String msg) { public void updateProductionRecord(List<MesProductionRecord> recordList, String userName, Integer reportStatus, String msg) {
recordList.forEach(record->{ recordList.forEach(record->{
record.setReportStatus(reportStatus); DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(record.getOrganizeCode());
record.setRemark(msg); DdlPreparedPack.getNumEqualPack(record.getId(), "id", ddlPackBean);
record.setSystemSyncStatus(CommonEnumUtil.FALSE); productionRecordRao.updateByPropertiesNoSync(new String[]{"modifyUser", "modifyDatetime", "reportStatus","remark","systemSyncStatus","systemSyncDatetime"},
record.setSystemSyncDatetime(MesPcnExtConstWords.EMPTY); new Object[]{userName, DateUtil.format(new Date(), MesPcnExtConstWords.DATE_FORMAT_SSS), reportStatus,msg,CommonEnumUtil.FALSE,""}, ddlPackBean);
ConvertBean.serviceModelUpdate(record,userName);
}); });
productionRecordRepository.saveAll(recordList);
} }
} }

@ -387,8 +387,8 @@ public class MesWorkOrderService implements IMesWorkOrderService {
List<MesBom> mesBoms = mesBomRDao.findByHqlWhere(ddlPackBean); List<MesBom> mesBoms = mesBomRDao.findByHqlWhere(ddlPackBean);
if (org.springframework.util.CollectionUtils.isEmpty(mesBoms)) { if (org.springframework.util.CollectionUtils.isEmpty(mesBoms)) {
LOGGER.info("物料{}生产版本{}对应bom信息不存在", partNo, bomVersion ); LOGGER.info("物料{}生产版本{}对应bom信息不存在", partNo, bomVersion );
return mesBoms; //return mesBoms;
// MesPcnException.throwMesBusiException("物料【%s】生产版本【%s】对应bom信息不存在", partNo, bomVersion); MesPcnException.throwMesBusiException("物料【%s】生产版本【%s】对应bom信息不存在", partNo, bomVersion);
} }
MesBom next = mesBoms.iterator().next(); MesBom next = mesBoms.iterator().next();
//如果存在多个bomCode取最新的一个 //如果存在多个bomCode取最新的一个

Loading…
Cancel
Save