|
|
|
@ -11,6 +11,7 @@ import cn.estsh.i3plus.pojo.mes.bean.MesShift;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesProductionRecordRepository;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesShiftRepository;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
|
|
|
|
import cn.estsh.impp.framework.boot.init.ApplicationProperties;
|
|
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
@ -46,16 +47,18 @@ public class MesReportWorkByPreDayJob extends BaseMesScheduleJob {
|
|
|
|
|
private MesShiftRepository mesShiftRepository;
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMesConfigService configService;
|
|
|
|
|
|
|
|
|
|
public MesReportWorkByPreDayJob() {
|
|
|
|
|
super(MesReportWorkByPreDayJob.class, "根据前一天待报工记录数插入工单并报工JOB");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void executeMesJob(JobExecutionContext context, ApplicationProperties applicationProperties) {
|
|
|
|
|
String jobParam = this.getJobParam();
|
|
|
|
|
JSONObject jsonObject= JSONUtil.parseObj(jobParam);
|
|
|
|
|
JSONObject jsonObject = JSONUtil.parseObj(jobParam);
|
|
|
|
|
String organizeCode = jsonObject.getStr("organizeCode");
|
|
|
|
|
String userName = "REPORT_PRE_DAY_JOB";
|
|
|
|
|
if (null == organizeCode){
|
|
|
|
|
if (null == organizeCode) {
|
|
|
|
|
log.error("请添加需要报工的工厂代码!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -68,29 +71,43 @@ public class MesReportWorkByPreDayJob extends BaseMesScheduleJob {
|
|
|
|
|
for (String workCenterCode : workCenterCodeList) {
|
|
|
|
|
List<MesShift> mesShiftList = mesShiftListAll.stream().filter(s -> s.getWorkCenterCode().equalsIgnoreCase(workCenterCode)).collect(Collectors.toList());
|
|
|
|
|
//1.获取生产加工记录production_record表中,report_status为待汇报状态的工单
|
|
|
|
|
List<MesProductionRecord> mesProductionRecordList = workOrderService.getPreDayReportMesProductionRecord(organizeCode,mesShiftList,workCenterCode);
|
|
|
|
|
if(CollectionUtils.isEmpty(mesProductionRecordList)){
|
|
|
|
|
List<MesProductionRecord> mesProductionRecordList = workOrderService.getPreDayReportMesProductionRecord(organizeCode, mesShiftList, workCenterCode);
|
|
|
|
|
if (CollectionUtils.isEmpty(mesProductionRecordList)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//2. 查询 mesProduceSn
|
|
|
|
|
List<MesProduceSn> unReportMesProduceSn = workOrderService.getPreDayReportMesProduceSn(organizeCode,mesProductionRecordList);
|
|
|
|
|
if(CollectionUtils.isEmpty(unReportMesProduceSn)){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
List<MesWorkOrder> mesWorkOrders = workOrderService.insertMesWorkOrder(unReportMesProduceSn, mesShiftList,organizeCode, userName);
|
|
|
|
|
if(CollectionUtils.isEmpty(mesWorkOrders)){
|
|
|
|
|
List<MesProduceSn> unReportMesProduceSn = workOrderService.getPreDayReportMesProduceSn(organizeCode, mesProductionRecordList);
|
|
|
|
|
if (CollectionUtils.isEmpty(unReportMesProduceSn)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//根据产线+物料产生的工单报工
|
|
|
|
|
for (MesWorkOrder mesWorkOrder : mesWorkOrders) {
|
|
|
|
|
List<MesProduceSn> mesProduceSnList = unReportMesProduceSn.stream().filter(w -> w.getPartNo().equalsIgnoreCase(mesWorkOrder.getPartNo())).collect(Collectors.toList());
|
|
|
|
|
workOrderService.doPcnJobProductReport(mesProduceSnList,mesShiftList,organizeCode,userName, mesWorkOrder);
|
|
|
|
|
LOGGER.info("产线:{}报工mesWorkOrders:{}", workCenterCode, unReportMesProduceSn);
|
|
|
|
|
//3.插入生产工单表
|
|
|
|
|
List<MesWorkOrder> mesWorkOrders = workOrderService.insertMesWorkOrder(unReportMesProduceSn, mesShiftList, organizeCode, userName);
|
|
|
|
|
if (CollectionUtils.isEmpty(mesWorkOrders)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
for (MesProductionRecord mesProductionRecord : mesProductionRecordList) {
|
|
|
|
|
mesProductionRecord.setReportStatus(20);
|
|
|
|
|
ConvertBean.serviceModelUpdate(mesProductionRecord, userName);
|
|
|
|
|
LOGGER.info("产线:{}报工mesWorkOrders:{}", workCenterCode, mesWorkOrders);
|
|
|
|
|
//4.根据产线+物料产生的工单报工
|
|
|
|
|
try {
|
|
|
|
|
for (MesWorkOrder mesWorkOrder : mesWorkOrders) {
|
|
|
|
|
List<MesProduceSn> mesProduceSnList = unReportMesProduceSn.stream().filter(w -> w.getPartNo().equalsIgnoreCase(mesWorkOrder.getPartNo())).collect(Collectors.toList());
|
|
|
|
|
workOrderService.doPcnJobProductReport(mesProduceSnList, mesShiftList, organizeCode, userName, mesWorkOrder);
|
|
|
|
|
for (MesProductionRecord mesProductionRecord : mesProductionRecordList) {
|
|
|
|
|
mesProductionRecord.setReportStatus(20);
|
|
|
|
|
ConvertBean.serviceModelUpdate(mesProductionRecord, userName);
|
|
|
|
|
}
|
|
|
|
|
productionRecordRao.saveAll(mesProductionRecordList);
|
|
|
|
|
}
|
|
|
|
|
} catch (ImppBusiException e) {
|
|
|
|
|
LOGGER.error("产线:{}报工失败:{}", workCenterCode, e.getErrorDetail());
|
|
|
|
|
// for (MesProductionRecord mesProductionRecord : mesProductionRecordList) {
|
|
|
|
|
// mesProductionRecord.setReportStatus(40);
|
|
|
|
|
// ConvertBean.serviceModelUpdate(mesProductionRecord, userName);
|
|
|
|
|
// }
|
|
|
|
|
// productionRecordRao.saveAll(mesProductionRecordList);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
productionRecordRao.saveAll(mesProductionRecordList);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|