forked from I3-YF/i3plus-mes-pcn-yfai
uat-temp-wj-shenshanorder
parent
512c06b5dc
commit
7b5ffeb7d4
Binary file not shown.
@ -0,0 +1,100 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
|
||||
|
||||
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.IMesQueueOrderPushService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPartContext;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
||||
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
|
||||
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
||||
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
|
||||
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesQueueOrder;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesQueueOrderPush;
|
||||
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
|
||||
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
|
||||
import cn.estsh.i3plus.pojo.mes.model.StepResult;
|
||||
import cn.estsh.i3plus.pojo.mes.repository.MesQueueOrderRepository;
|
||||
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description : 保存工位队列信息工步 推单工位
|
||||
* @Author : wangjie
|
||||
**/
|
||||
@Slf4j
|
||||
@Service("mesWorkOrderQueueSavePushStepService")
|
||||
public class MesWorkOrderQueueSavePushStepService extends BaseStepService {
|
||||
|
||||
@Autowired
|
||||
private IMesProductionProcessContextStepService productionProcessContextStepService;
|
||||
|
||||
@Autowired
|
||||
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
|
||||
|
||||
@Autowired
|
||||
private IMesQueueOrderPushService queueOrderPushService;
|
||||
|
||||
@Autowired
|
||||
private MesQueueOrderRepository queueOrderRepository;
|
||||
|
||||
@Override
|
||||
public StepResult execute(StationRequestBean reqBean) {
|
||||
|
||||
StationResultBean resultBean = new StationResultBean();
|
||||
|
||||
StepResult stepResult = StepResult.getSuccessComplete();
|
||||
|
||||
//获取上下文信息
|
||||
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.dispatchCurCellEquipment(reqBean);
|
||||
|
||||
//配置错误 抛出异常
|
||||
if (!productionProcessContext.getSuccess()) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), productionProcessContext.getMessage());
|
||||
|
||||
//存储生产过程上下文对象
|
||||
productionProcessContextStepService.dispatchProductionProcessContext(reqBean, productionProcessContext);
|
||||
|
||||
//获取上下文产出零件信息
|
||||
List<MesProductionPartContext> productionPartContextList = productionDispatchContextStepService.getProductionPartContext(reqBean);
|
||||
if (CollectionUtils.isEmpty(productionPartContextList)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前不存在产出零件信息,请重置工序解决!");
|
||||
|
||||
//获取上下文推单队列信息
|
||||
List<MesQueueOrderPush> queueOrderPushList = productionDispatchContextStepService.getSortQueuePushContext(reqBean);
|
||||
if (CollectionUtils.isEmpty(productionPartContextList)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前不存在推单队列信息,请重置工序解决!");
|
||||
|
||||
//修改推送队列信息状态为已完成
|
||||
List<Long> idList = queueOrderPushList.stream().filter(o -> null != o).map(MesQueueOrderPush::getId).collect(Collectors.toList());
|
||||
DdlPackBean packBean = DdlPackBean.getDdlPackBean(reqBean.getOrganizeCode());
|
||||
if (idList.size() == 1) DdlPreparedPack.getNumEqualPack(idList.get(0), MesPcnExtConstWords.ID, packBean);
|
||||
else DdlPreparedPack.getInPackList(idList, MesPcnExtConstWords.ID, packBean);
|
||||
queueOrderPushService.saveQueueOrderPushStatusByDdlPackBean(packBean, reqBean.getUserInfo(), MesExtEnumUtil.QUEUE_ORDER_STATUS.FINISH.getValue());
|
||||
//写入队列信息,默认状态为已完成
|
||||
queueOrderPushList.stream().filter(o -> null != o).forEach(o -> insertQueueOrder(reqBean, o, productionPartContextList));
|
||||
|
||||
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, "保存工位队列成功!");
|
||||
|
||||
}
|
||||
|
||||
private void insertQueueOrder(StationRequestBean reqBean, MesQueueOrderPush queueOrderPush, List<MesProductionPartContext> productionPartContextList) {
|
||||
Optional<MesProductionPartContext> optional = productionPartContextList.stream().filter(o -> (null != o && o.getWorkOrderNo().equals(queueOrderPush.getWorkOrderNo()))).findFirst();
|
||||
MesQueueOrder queueOrder = new MesQueueOrder();
|
||||
if (null != optional && optional.isPresent()) BeanUtils.copyProperties(optional.get(), queueOrder, MesPcnExtConstWords.BASE_BEAN_FIELDS);
|
||||
BeanUtils.copyProperties(queueOrderPush, queueOrder, MesPcnExtConstWords.BASE_BEAN_FIELDS);
|
||||
queueOrder.setWorkCellCode(reqBean.getWorkCellCode());
|
||||
queueOrder.setSerialNumber(queueOrderPush.getProductSn());
|
||||
queueOrder.setStatus(MesExtEnumUtil.QUEUE_ORDER_STATUS.FINISH.getValue());
|
||||
ConvertBean.serviceModelInitialize(queueOrder, reqBean.getUserInfo());
|
||||
queueOrderRepository.insert(queueOrder);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
|
||||
|
||||
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.pojo.context.MesProductionProcessContext;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsInContext;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
||||
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
|
||||
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
|
||||
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
|
||||
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
|
||||
import cn.estsh.i3plus.pojo.mes.model.StepResult;
|
||||
import cn.estsh.i3plus.pojo.mes.repository.MesQueueOrderRepository;
|
||||
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description : 保存工位队列信息工步 非推单工位
|
||||
* @Author : wangjie
|
||||
**/
|
||||
@Slf4j
|
||||
@Service("mesWorkOrderQueueSaveStatusStepService")
|
||||
public class MesWorkOrderQueueSaveStatusStepService extends BaseStepService {
|
||||
|
||||
@Autowired
|
||||
private IMesProductionProcessContextStepService productionProcessContextStepService;
|
||||
|
||||
@Autowired
|
||||
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
|
||||
|
||||
@Autowired
|
||||
private MesQueueOrderRepository queueOrderRepository;
|
||||
|
||||
@Override
|
||||
public StepResult execute(StationRequestBean reqBean) {
|
||||
|
||||
StationResultBean resultBean = new StationResultBean();
|
||||
|
||||
StepResult stepResult = StepResult.getSuccessComplete();
|
||||
|
||||
//获取上下文信息
|
||||
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.dispatchCurCellEquipment(reqBean);
|
||||
|
||||
//配置错误 抛出异常
|
||||
if (!productionProcessContext.getSuccess()) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), productionProcessContext.getMessage());
|
||||
|
||||
//存储生产过程上下文对象
|
||||
productionProcessContextStepService.dispatchProductionProcessContext(reqBean, productionProcessContext);
|
||||
|
||||
//获取上下文条码数据信息集合
|
||||
List<MesProductionPsInContext> productionPsInContextList = productionDispatchContextStepService.getProductionPsInContext(reqBean);
|
||||
if (CollectionUtils.isEmpty(productionPsInContextList)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前不存在零件条码信息,请重置工序解决!");
|
||||
|
||||
productionPsInContextList.stream().filter(o -> null != o).forEach(o -> saveWorkOrderQueue(reqBean, o));
|
||||
|
||||
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, "保存工位队列成功!");
|
||||
|
||||
}
|
||||
|
||||
private void saveWorkOrderQueue(StationRequestBean reqBean, MesProductionPsInContext productionPsInContext) {
|
||||
if (StringUtils.isEmpty(productionPsInContext.getRelateId())) return;
|
||||
queueOrderRepository.updateByPropertiesNoSync(
|
||||
new String[]{MesPcnExtConstWords.ID, MesPcnExtConstWords.ORGANIZE_CODE},
|
||||
new Object[]{productionPsInContext.getRelateId(), reqBean.getOrganizeCode()},
|
||||
new String[]{MesPcnExtConstWords.STATUS, MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME, MesPcnExtConstWords.SYSTEM_SYNC_STATUS, MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME},
|
||||
new Object[]{MesExtEnumUtil.QUEUE_ORDER_STATUS.FINISH.getValue(), reqBean.getUserInfo(), TimeTool.getNowTime(true), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), MesPcnExtConstWords.EMPTY});
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue