|
|
@ -2,25 +2,39 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
|
|
|
|
|
|
|
|
|
|
|
|
import akka.actor.ActorRef;
|
|
|
|
import akka.actor.ActorRef;
|
|
|
|
import akka.actor.ActorSystem;
|
|
|
|
import akka.actor.ActorSystem;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesNcProcessingService;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesCellEquipContext;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesCellEquipContext;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.ActorMessage;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.ActorMessage;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingInputModel;
|
|
|
|
import cn.estsh.i3plus.mes.pcn.config.SpringExtProvider;
|
|
|
|
import cn.estsh.i3plus.mes.pcn.config.SpringExtProvider;
|
|
|
|
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
|
|
|
|
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
|
|
|
|
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.MesEnumUtil;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesDefectType;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspection;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspectionDetail;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StepResult;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StepResult;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DatePattern;
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
|
|
import com.google.common.base.Objects;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
@ -36,12 +50,10 @@ public class MesProductResultErrorHandleStepService extends BaseStepService {
|
|
|
|
private SnowflakeIdMaker snowflakeIdMaker;
|
|
|
|
private SnowflakeIdMaker snowflakeIdMaker;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private ActorSystem actorSystem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private IMesProductionProcessContextStepService productionProcessContextStepService;
|
|
|
|
private IMesProductionProcessContextStepService productionProcessContextStepService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private IMesNcProcessingService ncProcessingService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private IMesProductionDispatchContextStepService mesProductionDispatchContextStepService;
|
|
|
|
private IMesProductionDispatchContextStepService mesProductionDispatchContextStepService;
|
|
|
@ -53,38 +65,61 @@ public class MesProductResultErrorHandleStepService extends BaseStepService {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public StepResult execute(StationRequestBean reqBean) {
|
|
|
|
public StepResult execute(StationRequestBean reqBean) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StepResult stepResult = StepResult.getSuccessComplete();
|
|
|
|
StationResultBean resultBean = new StationResultBean();
|
|
|
|
StationResultBean resultBean = new StationResultBean();
|
|
|
|
|
|
|
|
|
|
|
|
StepResult stepResult = StepResult.getSuccessComplete();
|
|
|
|
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getEquipmentVariableList(reqBean, MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PRODUCTION.getValue());
|
|
|
|
|
|
|
|
|
|
|
|
// 获取上下文信息
|
|
|
|
String result = mesProductionDispatchContextStepService.getProductResultContext(reqBean);
|
|
|
|
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getCurCellEquipment(reqBean);
|
|
|
|
// 如果是报废或者可疑,需要编辑条码状态为不合格、并且nc判定需要新增一条记录
|
|
|
|
|
|
|
|
if (!Objects.equal(MesExtEnumUtil.EQUIP_VARIABLE_CFG_CATEGORY.PRODUCT_SCRAP.getValue(), result)) {
|
|
|
|
|
|
|
|
return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "加工结果合格,无需记录异常");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String defectTypeCode = MesEnumUtil.DEFECT_TYPE_CODE.BACK_SPRAY.getValue();
|
|
|
|
|
|
|
|
|
|
|
|
// 获取条码信息
|
|
|
|
|
|
|
|
List<MesProduceSn> mesProduceSns = mesProductionDispatchContextStepService.getOutProduceSnDataContext(reqBean);
|
|
|
|
List<MesProduceSn> mesProduceSns = mesProductionDispatchContextStepService.getOutProduceSnDataContext(reqBean);
|
|
|
|
// 通过上下文获取工位设备信息
|
|
|
|
|
|
|
|
MesCellEquipContext curCellEquip = productionProcessContext.getCurCellEquip();
|
|
|
|
mesProduceSns.forEach(mesProduceSn -> {
|
|
|
|
|
|
|
|
MesNcProcessingInputModel model = new MesNcProcessingInputModel();
|
|
|
|
String mesProduceSnsStr = !CollectionUtils.isEmpty(mesProduceSns) ? JSONObject.toJSONString(mesProduceSns) : null;
|
|
|
|
MesDefectType mesDefectType = new MesDefectType();
|
|
|
|
ActorMessage actorMessage = ActorMessage.builder()
|
|
|
|
mesDefectType.setBackDefect(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
|
|
|
.equipmentCode(curCellEquip.getEquipmentCode())
|
|
|
|
mesDefectType.setDefectTypeCode(defectTypeCode);
|
|
|
|
.equipId(curCellEquip.getEquipId())
|
|
|
|
mesDefectType.setDefectTypeName(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getDescription());
|
|
|
|
.organizeCode(reqBean.getOrganizeCode())
|
|
|
|
//mesDefectType.setDefectType(MesExtEnumUtil.MES_DEFECT_TYPE);
|
|
|
|
.organizeName(reqBean.getOrganizeName())
|
|
|
|
model.setSn(mesProduceSn.getProductSn());
|
|
|
|
.workCellCode(reqBean.getWorkCellCode())
|
|
|
|
model.setPerson(mesDefectType);
|
|
|
|
.workCenterCode(reqBean.getWorkCenterCode())
|
|
|
|
|
|
|
|
.areaCode(reqBean.getAreaCode())
|
|
|
|
MesPartInspection partInspection = new MesPartInspection();
|
|
|
|
.craftCode(productionProcessContext.getCraftCode())
|
|
|
|
|
|
|
|
.processCode(reqBean.getProcessCode())
|
|
|
|
Long id = snowflakeIdMaker.nextId();
|
|
|
|
.produceSnJson(mesProduceSnsStr)
|
|
|
|
partInspection.setWorkCenterCode(reqBean.getWorkCenterCode());
|
|
|
|
.userName(reqBean.getUserInfo())
|
|
|
|
partInspection.setSourceType(MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue());
|
|
|
|
.build();
|
|
|
|
partInspection.setPartNo(mesProduceSn.getPartNo());
|
|
|
|
// 数据采集信息需要存放到 redis中
|
|
|
|
partInspection.setPartName(mesProduceSn.getPartNameRdd());
|
|
|
|
String key = this.getFsmBusikey(reqBean, MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PROCESS_FINISH.name());
|
|
|
|
partInspection.setDefectTypeCode(mesDefectType.getDefectTypeCode());
|
|
|
|
ActorRef ref = refMap.computeIfAbsent(key,
|
|
|
|
partInspection.setInspectionDate(DateUtil.format(new Date(), DatePattern.NORM_DATETIME_FORMATTER));
|
|
|
|
k -> actorSystem.actorOf(SpringExtProvider.getInstance().get(actorSystem).create("mesHandlerEquipLogActor"), key));
|
|
|
|
partInspection.setLotNo(mesProduceSn.getLotNo());
|
|
|
|
ref.tell(actorMessage, ActorRef.noSender());
|
|
|
|
partInspection.setNcStatus(MesExtEnumUtil.PART_INSPECTION_NC_STATUS.SCRAP.getValue());
|
|
|
|
|
|
|
|
partInspection.setRejectQty(mesProduceSn.getQty().intValue());
|
|
|
|
return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "保存工艺参数成功");
|
|
|
|
partInspection.setShiftCode(mesProduceSn.getShiftCode());
|
|
|
|
}
|
|
|
|
partInspection.setSn(mesProduceSn.getProductSn());
|
|
|
|
|
|
|
|
partInspection.setQty(mesProduceSn.getQty().intValue());
|
|
|
|
|
|
|
|
partInspection.setInspectionStatus(MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue());
|
|
|
|
|
|
|
|
partInspection.setId(id);
|
|
|
|
|
|
|
|
ConvertBean.serviceModelInitialize(partInspection, reqBean.getUserInfo());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MesPartInspectionDetail mesPartInspectionDetail = new MesPartInspectionDetail();
|
|
|
|
|
|
|
|
mesPartInspectionDetail.setPid(id);
|
|
|
|
|
|
|
|
mesPartInspectionDetail.setStatus(10);
|
|
|
|
|
|
|
|
mesPartInspectionDetail.setDefectTypeCode(mesDefectType.getDefectTypeCode());
|
|
|
|
|
|
|
|
mesPartInspectionDetail.setDefectTypeName(mesDefectType.getDefectTypeName());
|
|
|
|
|
|
|
|
model.setPartInspection(partInspection);
|
|
|
|
|
|
|
|
model.setPartInspectionDetailList(Arrays.asList(mesPartInspectionDetail));
|
|
|
|
|
|
|
|
ncProcessingService.saveNc(model, reqBean.getOrganizeCode());
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "加工异常处理成功");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|