|
|
|
@ -0,0 +1,136 @@
|
|
|
|
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.station;
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesProdShiftRecordService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionCustomContextStepService;
|
|
|
|
|
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.IMesWorkOrderExtService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdShiftContext;
|
|
|
|
|
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.BaseModuleService;
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.IStepService;
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.util.StationKvBeanUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesProdShiftRecord;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesStateMachineStatus;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCell;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StationKvBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesFileRepository;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description : 展示组件:非排序生产
|
|
|
|
|
* @Author :wangjie
|
|
|
|
|
**/
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service("mesProductionSortModuleService")
|
|
|
|
|
public class MesProductionSortModuleService extends BaseModuleService {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMesProductionProcessContextStepService productionProcessContextStepService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMesProductionCustomContextStepService productionCustomContextStepService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMesProdShiftRecordService mesProdShiftRecordService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMesWorkOrderExtService workOrderExtService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesFileRepository mesFileRepository;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void init(StationRequestBean reqBean) {
|
|
|
|
|
// 获取工单信息
|
|
|
|
|
List<List<StationKvBean>> moduleContentContext = productionDispatchContextStepService.getModuleContentContext(reqBean);
|
|
|
|
|
|
|
|
|
|
//获取上下文信息
|
|
|
|
|
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getEquipmentVariableList(reqBean, MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PRODUCTION.getValue());
|
|
|
|
|
MesWorkCell mesWorkCell = productionProcessContext.getWorkCell();
|
|
|
|
|
|
|
|
|
|
//获取班次信息,先查询缓存,缓存没有在查询数据库
|
|
|
|
|
List<StationKvBean> prodShiftDataContext = getShiftRecordStationKvBeans(reqBean);
|
|
|
|
|
|
|
|
|
|
MesProdShiftContext mesProdShiftKvBean = productionCustomContextStepService.getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(prodShiftDataContext)) {
|
|
|
|
|
this.sendMessage(reqBean, new StationResultBean().writeDbLog(), "请先开班", MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);
|
|
|
|
|
MesPcnException.throwBusiException("请先开班");
|
|
|
|
|
}
|
|
|
|
|
// 发送班次班组和工单
|
|
|
|
|
StationResultBean resultBean = getStationResultBean(reqBean, moduleContentContext, prodShiftDataContext);
|
|
|
|
|
this.sendMessage(reqBean, resultBean);
|
|
|
|
|
|
|
|
|
|
//TODO 右侧排序表格数据
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//验证工位是否锁定
|
|
|
|
|
reqBean.getDataMap().put(MesPcnEnumUtil.ACTOR_RECEIVE_STRATEGY.WS_CMD_INIT_MODULE.getCode(), CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValueStr());
|
|
|
|
|
((IStepService) SpringContextsUtil.getBean("mesCountDownShowStepService")).executeInState(reqBean);
|
|
|
|
|
|
|
|
|
|
//设备BYPASS监控
|
|
|
|
|
//((IStepService) SpringContextsUtil.getBean("mesEquipByPassReadStepService")).executeInState(reqBean);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<StationKvBean> getShiftRecordStationKvBeans(StationRequestBean reqBean) {
|
|
|
|
|
// 获取班次信息 redis
|
|
|
|
|
List<StationKvBean> prodShiftDataContext = productionCustomContextStepService.getProdShiftDataContext(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
|
|
|
|
|
if (CollectionUtils.isEmpty(prodShiftDataContext)) {
|
|
|
|
|
MesProdShiftRecord shiftRecord = new MesProdShiftRecord();
|
|
|
|
|
shiftRecord.setWorkCenterCode(reqBean.getWorkCenterCode());
|
|
|
|
|
shiftRecord.setWorkStatus(MesExtEnumUtil.WORK_STATUS.START.getValue());
|
|
|
|
|
// 查询数据库
|
|
|
|
|
MesProdShiftRecord prodShiftRecord = mesProdShiftRecordService.queryMesProdShiftRecord(shiftRecord);
|
|
|
|
|
if (prodShiftRecord != null) {
|
|
|
|
|
prodShiftDataContext = getProdShiftData(prodShiftRecord);
|
|
|
|
|
productionCustomContextStepService.dispatchProdShiftDataContext(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(),prodShiftDataContext);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return prodShiftDataContext;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private StationResultBean getStationResultBean(StationRequestBean reqBean, List<List<StationKvBean>> moduleContentContext, List<StationKvBean> prodShiftDataContext) {
|
|
|
|
|
StationResultBean resultBean = new StationResultBean();
|
|
|
|
|
resultBean.setBusiType(MesPcnEnumUtil.STATION_BUSI_TYPE.MODULE_CONTENT.getValue());
|
|
|
|
|
resultBean.setDataType(MesPcnEnumUtil.STATION_DATA_TYPE.CUSTOM.getValue());
|
|
|
|
|
resultBean.setCustomPageName(MesPcnExtConstWords.CUSTOM_PAGE_NAME_DEFAULT);
|
|
|
|
|
resultBean.setSpecialDisplayData(getStepColIndent(reqBean));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resultBean.setResultObj(prodShiftDataContext);
|
|
|
|
|
resultBean.setResultList(moduleContentContext);
|
|
|
|
|
return resultBean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//封装展示组件班组班次内容
|
|
|
|
|
private List<StationKvBean> getProdShiftData(MesProdShiftRecord record) {
|
|
|
|
|
|
|
|
|
|
return StationKvBeanUtil.addStationKvBeanList(new ArrayList<>(),
|
|
|
|
|
new StationKvBean(MesPcnExtConstWords.SHIFT_GROUP, "班组", record.getShiftGroup()),
|
|
|
|
|
new StationKvBean(MesPcnExtConstWords.SHIFT_GROUP_NAME, "班组名称", record.getShiftGroupName()),
|
|
|
|
|
new StationKvBean(MesPcnExtConstWords.SHIFT_CODE, "班次", record.getShiftCode()),
|
|
|
|
|
new StationKvBean(MesPcnExtConstWords.SHIFT_NAME, "班次名称", record.getShiftName()));
|
|
|
|
|
}
|
|
|
|
|
}
|