forked from I3-YF/i3plus-mes-pcn-yfai
shipping rfid
parent
03f5ebc952
commit
4241dcd230
@ -0,0 +1,18 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.api.busi;
|
||||
|
||||
import cn.estsh.i3plus.pojo.mes.bean.seres.MesCimSeresJisRfid;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingQueue;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
public interface IMesShippingQueueService {
|
||||
|
||||
@ApiOperation("根据零件发运组代码查询创建时间正序创建状态的一条发运队列")
|
||||
MesShippingQueue getShippingQueue(String organizeCode, String shippingGroupCode);
|
||||
|
||||
@ApiOperation("根据ID修改发运队列")
|
||||
void saveShippingQueue(String organizeCode, Long id, String[] propertyName, Object[] propertyValue);
|
||||
|
||||
@ApiOperation("根据VIN查询赛力斯RFID信息")
|
||||
MesCimSeresJisRfid getCimSeresJisRfid(String organizeCode, String vin);
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi;
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesShippingQueueService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
||||
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
||||
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.seres.MesCimSeresJisRfid;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingQueue;
|
||||
import cn.estsh.i3plus.pojo.mes.repository.MesShippingQueueRepository;
|
||||
import cn.estsh.i3plus.pojo.mes.repository.seres.IMesCimSeresJisRfidRepository;
|
||||
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
||||
import groovy.util.logging.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class MesShippingQueueService implements IMesShippingQueueService {
|
||||
|
||||
@Autowired
|
||||
private MesShippingQueueRepository shippingQueueRepository;
|
||||
|
||||
@Autowired
|
||||
private IMesCimSeresJisRfidRepository cimSeresJisRfidRepository;
|
||||
|
||||
@Override
|
||||
public MesShippingQueue getShippingQueue(String organizeCode, String shippingGroupCode) {
|
||||
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(shippingGroupCode)) return null;
|
||||
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
|
||||
DdlPreparedPack.getStringEqualPack(shippingGroupCode, MesPcnExtConstWords.SHIPPING_GROUP_CODE, packBean);
|
||||
DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.QUEUE_ORDER_STATUS.CREATE.getValue(), MesPcnExtConstWords.QUEUE_STATUS, packBean);
|
||||
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.ASC.getValue()}, new String[]{MesPcnExtConstWords.CREATE_DATE_TIME}, packBean);
|
||||
return shippingQueueRepository.getByProperty(packBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveShippingQueue(String organizeCode, Long id, String[] propertyName, Object[] propertyValue) {
|
||||
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(id)) return;
|
||||
shippingQueueRepository.updateByPropertiesNoSync(new String[]{MesPcnExtConstWords.ID, MesPcnExtConstWords.ORGANIZE_CODE}, new Object[]{id, organizeCode}, propertyName, propertyValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MesCimSeresJisRfid getCimSeresJisRfid(String organizeCode, String vin) {
|
||||
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(vin)) return null;
|
||||
return cimSeresJisRfidRepository.getByProperty(
|
||||
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, MesPcnExtConstWords.VIN_CODE, MesPcnExtConstWords.STATUS},
|
||||
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), vin, CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()});
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.station.function;
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesPartShippingGroupService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
||||
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseSwsService;
|
||||
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.IShippingDispatchService;
|
||||
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.function.IFsmModuleFunctionService;
|
||||
import cn.estsh.i3plus.mes.pcn.util.StationKvBeanUtil;
|
||||
import cn.estsh.i3plus.platform.common.util.MesPcnConstWords;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
|
||||
import cn.estsh.i3plus.pojo.mes.model.ButtonDynamicModel;
|
||||
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.util.MesExtEnumUtil;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @Description : 工位参数按钮事件接口实现【选择发运组】
|
||||
**/
|
||||
@Service
|
||||
public class MesFunctionChooseShippingGroupService extends BaseSwsService implements IFsmModuleFunctionService {
|
||||
|
||||
@Autowired
|
||||
private IMesProductionProcessContextStepService productionProcessContextStepService;
|
||||
|
||||
@Autowired
|
||||
private IShippingDispatchService shippingDispatchService;
|
||||
|
||||
@Autowired
|
||||
private IMesPartShippingGroupService partShippingGroupService;
|
||||
|
||||
@Override
|
||||
public Boolean doFunction(StationRequestBean reqBean, StationResultBean resultBean, ButtonDynamicModel buttonDynamicModel) {
|
||||
|
||||
//验证发运组信息是否有效
|
||||
List<StationKvBean> resultList = checkShippingGroupIsValid(reqBean.getOrganizeCode(), buttonDynamicModel.getFunctionValue());
|
||||
if (CollectionUtils.isEmpty(resultList)) {
|
||||
this.sendMessage(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PICK.getValue()).scanInfo(buttonDynamicModel.getFunctionValue()),
|
||||
String.format("生产线[%s]工位[%s]%s失败,请检查选择的发运组信息[%s]的有效性!", reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), buttonDynamicModel.getButtonName(), buttonDynamicModel.getFunctionValue()),
|
||||
MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT);
|
||||
return false;
|
||||
}
|
||||
|
||||
//保存选择的零件发运组信息上下文
|
||||
productionProcessContextStepService.dispatchFunctionChooseShippingGroupContext(reqBean, resultList);
|
||||
|
||||
this.sendMessage(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PICK.getValue()).scanInfo(buttonDynamicModel.getFunctionValue()),
|
||||
String.format("生产线[%s]工位[%s]%s成功,请等待验证!提交信息[%s]", reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), buttonDynamicModel.getButtonName(), buttonDynamicModel.getFunctionValue()),
|
||||
MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);
|
||||
|
||||
reqBean.setClientInfo(shippingDispatchService.getActorClientInfo(reqBean));
|
||||
reqBean.setInterfaceType(MesPcnConstWords.SHIPPING);
|
||||
reqBean.setBusiType(MesPcnEnumUtil.ACTOR_RECEIVE_STRATEGY.WS_CMD_DO_SCAN.getCode());
|
||||
reqBean.setTriggerAutoFsm(true);
|
||||
shippingDispatchService.sendScanQueueIfNoQueue(reqBean, false, this.getClass().getSimpleName());
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
//验证发运组信息是否有效
|
||||
public List<StationKvBean> checkShippingGroupIsValid(String organizeCode, String functionValue) {
|
||||
//查询发运组数据
|
||||
if (null == partShippingGroupService.getMesPartShippingGroup(organizeCode, functionValue)) return null;
|
||||
return StationKvBeanUtil.addStationKvBeanList(new ArrayList<>(),
|
||||
new StationKvBean(MesPcnExtConstWords.SHIPPING_GROUP_CODE, "零件发运组代码", functionValue),
|
||||
new StationKvBean(MesPcnExtConstWords.CELL_MESSAGE_SOURCE, "工位信息来源", MesExtEnumUtil.CELL_MESSAGE_SOURCE.READ.getValueStr()));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,140 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
|
||||
|
||||
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.IMesShippingQueueService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.station.function.MesFunctionChooseShippingGroupService;
|
||||
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.actor.shipping.dispatch.IFsmCommonService;
|
||||
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingQueue;
|
||||
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.model.StepResult;
|
||||
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;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description : 发运队列获取工步
|
||||
* @Author : wangjie
|
||||
**/
|
||||
@Slf4j
|
||||
@Service("mesShippingQueueFindStepService")
|
||||
public class MesShippingQueueFindStepService extends BaseStepService {
|
||||
|
||||
@Autowired
|
||||
private IMesProductionProcessContextStepService productionProcessContextStepService;
|
||||
|
||||
@Autowired
|
||||
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
|
||||
|
||||
@Autowired
|
||||
private IMesProductionCustomContextStepService productionCustomContextStepService;
|
||||
|
||||
@Autowired
|
||||
private MesFunctionChooseShippingGroupService functionChooseShippingGroupService;
|
||||
|
||||
@Autowired
|
||||
private IMesShippingQueueService shippingQueueService;
|
||||
|
||||
@Autowired
|
||||
private IFsmCommonService fsmCommonService;
|
||||
|
||||
@Override
|
||||
public StepResult init(StationRequestBean reqBean) {
|
||||
|
||||
StepResult stepResult = StepResult.getSuccessComplete();
|
||||
|
||||
String endlessLoopReadTimes = fsmCommonService.handleFsmWcpcMapDataForDoScan(reqBean).get(MesPcnExtConstWords.ENDLESS_LOOP_READ_TIMES);
|
||||
if (StringUtils.isEmpty(endlessLoopReadTimes)) endlessLoopReadTimes = MesPcnExtConstWords.ENDLESS_LOOP_READ_TIMES_DEFAULT;
|
||||
if (productionDispatchContextStepService.dispatchOverEndlessLoopReadTimes(reqBean, endlessLoopReadTimes)) {
|
||||
stepThreadSleepAndSendTaskCompleteAndThrowEx(reqBean, new StationResultBean().isWs(false),
|
||||
stepResult.isCompleted(false).msg(String.format("当前未获取到发运队列超过[%s]次!", endlessLoopReadTimes)),
|
||||
MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, getStepParams(reqBean), MesPcnExtConstWords.READ_FAILURE_SLEEP, MesPcnExtConstWords.READ_FAILURE_SLEEP_DEFAULT_TIME);
|
||||
}
|
||||
|
||||
//发送工步内容
|
||||
productionCustomContextStepService.sendStepContextMessage(reqBean);
|
||||
|
||||
return stepResult;
|
||||
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
//扫描信息置空
|
||||
String scanInfo = reqBean.resetScanInfo(reqBean.getScanInfo());
|
||||
|
||||
//验证发运组信息是否有效
|
||||
List<StationKvBean> resultList = null;
|
||||
|
||||
if (!StringUtils.isEmpty(scanInfo)) {
|
||||
//发送工步内容
|
||||
productionCustomContextStepService.sendStepContextMessage(reqBean, scanInfo, MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN);
|
||||
//验证扫描的发运组信息是否有效
|
||||
resultList = functionChooseShippingGroupService.checkShippingGroupIsValid(reqBean.getOrganizeCode(), scanInfo);
|
||||
}
|
||||
|
||||
//扫描的发运组信息无效,获取缓存中的发运组信息
|
||||
if (CollectionUtils.isEmpty(resultList)) resultList = productionProcessContextStepService.getFunctionChooseShippingGroupContext(reqBean);
|
||||
//扫描的发运组信息有效,保存到上下文
|
||||
else productionProcessContextStepService.dispatchFunctionChooseShippingGroupContext(reqBean, resultList);
|
||||
|
||||
//验证是否存在发运组代码
|
||||
if (CollectionUtils.isEmpty(resultList)) {
|
||||
if (!StringUtils.isEmpty(scanInfo)) this.sendMessage(reqBean, new StationResultBean().writeDbLog().scanInfo(scanInfo), String.format("扫描信息零件发运组代码[%s]信息无效", scanInfo), MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT);
|
||||
stepSendGuideAndThrowEx(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), "请扫描或选择零件发运组代码!");
|
||||
}
|
||||
|
||||
//发送工步内容
|
||||
scanInfo = resultList.stream().filter(o -> (null != o && !o.getKey().equals(MesPcnExtConstWords.CELL_MESSAGE_SOURCE))).map(o -> o.getName() + MesPcnExtConstWords.SQUARE_BRACKETS_L + o.getValue() + MesPcnExtConstWords.SQUARE_BRACKETS_R).collect(Collectors.joining(MesPcnExtConstWords.SEMICOLON));
|
||||
productionCustomContextStepService.sendStepContextMessage(reqBean, scanInfo, MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN);
|
||||
|
||||
scanInfo = resultList.stream().filter(o -> (null != o && o.getKey().equals(MesPcnExtConstWords.SHIPPING_GROUP_CODE))).findFirst().get().getValue();
|
||||
MesShippingQueue shippingQueue = shippingQueueService.getShippingQueue(reqBean.getOrganizeCode(), scanInfo);
|
||||
|
||||
if (null == shippingQueue) {
|
||||
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().checkRepeat(), stepResult,
|
||||
false, MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT, String.format("当前零件发运组[%s]未匹配到有效的发运队列,持续监听中...", scanInfo),
|
||||
getStepParams(reqBean), MesPcnExtConstWords.READ_FAILURE_SLEEP, MesPcnExtConstWords.READ_FAILURE_SLEEP_DEFAULT_TIME);
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(shippingQueue.getVin())) {
|
||||
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().checkRepeat(), stepResult,
|
||||
false, MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT, String.format("当前零件发运组[%s]匹配的发运队列单号[%s]VIN为空,请人工处理! 持续监听中...", scanInfo, shippingQueue.getShippingCode()),
|
||||
getStepParams(reqBean), MesPcnExtConstWords.READ_FAILURE_SLEEP, MesPcnExtConstWords.READ_FAILURE_SLEEP_DEFAULT_TIME);
|
||||
}
|
||||
|
||||
//保存上下文发运队列信息
|
||||
productionDispatchContextStepService.dispatchShippingQueueContext(reqBean, shippingQueue);
|
||||
|
||||
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format("零件发运组[%s]已匹配发运队列单号[%s]VIN[%s]!", scanInfo, shippingQueue.getShippingCode(), shippingQueue.getVin()));
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
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.IMesShippingQueueService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdRuleContext;
|
||||
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.bean.shipping.MesShippingQueue;
|
||||
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.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("mesShippingQueueRemoveStepService")
|
||||
public class MesShippingQueueRemoveStepService extends BaseStepService {
|
||||
|
||||
@Autowired
|
||||
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
|
||||
|
||||
@Autowired
|
||||
private IMesShippingQueueService shippingQueueService;
|
||||
|
||||
@Override
|
||||
public StepResult execute(StationRequestBean reqBean) {
|
||||
|
||||
StationResultBean resultBean = new StationResultBean();
|
||||
|
||||
StepResult stepResult = StepResult.getSuccessComplete();
|
||||
|
||||
//保存上下文发运队列信息
|
||||
MesShippingQueue shippingQueue = productionDispatchContextStepService.getShippingQueueContext(reqBean);
|
||||
if (null == shippingQueue) {
|
||||
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult,
|
||||
true, MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT, "当前未获取到缓存中有效的发运队列,消除队列失败!");
|
||||
}
|
||||
|
||||
//获取上下文加工规则数据信息集合
|
||||
List<MesProdRuleContext> prodRuleContextList = productionDispatchContextStepService.getProdRuleDataContext(reqBean);
|
||||
|
||||
//修改字段数组
|
||||
String[] propertyName = new String[]{MesPcnExtConstWords.QUEUE_STATUS, MesPcnExtConstWords.PID, MesPcnExtConstWords.PRODUCTION_RECORD_ID,
|
||||
MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME, MesPcnExtConstWords.SYSTEM_SYNC_STATUS, MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME};
|
||||
|
||||
//修改值数组
|
||||
Object[] propertyValue = new Object[]{MesExtEnumUtil.QUEUE_ORDER_STATUS.FINISH.getValue(), (!StringUtils.isEmpty(shippingQueue.getPidStr()) ? Long.valueOf(shippingQueue.getPidStr()) : 0L),
|
||||
((!CollectionUtils.isEmpty(prodRuleContextList) && !StringUtils.isEmpty(prodRuleContextList.get(0).getProductionRecordId())) ? prodRuleContextList.get(0).getProductionRecordId() : 0L),
|
||||
reqBean.getUserInfo(), TimeTool.getNowTime(true), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), MesPcnExtConstWords.EMPTY};
|
||||
|
||||
//根据ID修改发运队列
|
||||
shippingQueueService.saveShippingQueue(reqBean.getOrganizeCode(), shippingQueue.getId(), propertyName, propertyValue);
|
||||
|
||||
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format("发运单号[%s]已从发运队列中消除成功!", shippingQueue.getShippingCode()));
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
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.IMesShippingQueueService;
|
||||
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.pojo.base.enumutil.CommonEnumUtil;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingQueue;
|
||||
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 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;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description : 发运队列RFID匹配工步
|
||||
* @Author : wangjie
|
||||
**/
|
||||
@Slf4j
|
||||
@Service("mesShippingRfidMatchStepService")
|
||||
public class MesShippingRfidMatchStepService extends BaseStepService {
|
||||
|
||||
@Autowired
|
||||
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
|
||||
|
||||
@Autowired
|
||||
private IMesShippingQueueService shippingQueueService;
|
||||
|
||||
@Override
|
||||
public StepResult execute(StationRequestBean reqBean) {
|
||||
|
||||
StationResultBean resultBean = new StationResultBean();
|
||||
|
||||
StepResult stepResult = StepResult.getSuccessComplete();
|
||||
|
||||
//获取上下文发运队列信息
|
||||
MesShippingQueue shippingQueue = productionDispatchContextStepService.getShippingQueueContext(reqBean);
|
||||
if ((null == shippingQueue || StringUtils.isEmpty(shippingQueue.getRfidSn()))) {
|
||||
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().checkRepeat(), stepResult,
|
||||
false, MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT, "当前未获取到缓存中有效的发运队列,即将重新获取!",
|
||||
getStepParams(reqBean), MesPcnExtConstWords.READ_FAILURE_SLEEP, MesPcnExtConstWords.READ_FAILURE_SLEEP_DEFAULT_TIME);
|
||||
}
|
||||
|
||||
//获取上下文进料零件条码信息集合
|
||||
List<MesProductionPsInContext> productionPsInContextList = productionDispatchContextStepService.getProductionPsInContext(reqBean);
|
||||
//过滤有效的进料零件条码
|
||||
String productSn = filterProductionPsInContextList(productionPsInContextList);
|
||||
if (StringUtils.isEmpty(productSn)) {
|
||||
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().checkRepeat(), stepResult.nextTriggerEvent(MesPcnExtConstWords.NEXT_TRIGGER_EVENT_PRODUCT_SN),
|
||||
false, MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT, "当前未获取到缓存中有效的进料条码,即将重新获取!",
|
||||
getStepParams(reqBean), MesPcnExtConstWords.READ_FAILURE_SLEEP, MesPcnExtConstWords.READ_FAILURE_SLEEP_DEFAULT_TIME);
|
||||
}
|
||||
|
||||
if (!shippingQueue.getRfidSn().equals(productSn)) {
|
||||
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().checkRepeat(), stepResult,
|
||||
false, MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT, String.format("RFID匹配失败!读条码[%s]与RFID条码[%s]不一致!", productSn, shippingQueue.getRfidSn()),
|
||||
getStepParams(reqBean), MesPcnExtConstWords.READ_FAILURE_SLEEP, MesPcnExtConstWords.READ_FAILURE_SLEEP_DEFAULT_TIME);
|
||||
}
|
||||
|
||||
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "RFID匹配成功!");
|
||||
|
||||
}
|
||||
|
||||
//过滤有效的进料零件条码
|
||||
private String filterProductionPsInContextList(List<MesProductionPsInContext> productionPsInContextList) {
|
||||
productionPsInContextList = CollectionUtils.isEmpty(productionPsInContextList) ? null :
|
||||
productionPsInContextList.stream().filter(o -> (null != o && o.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0)).collect(Collectors.toList());
|
||||
return CollectionUtils.isEmpty(productionPsInContextList) ? null : productionPsInContextList.get(0).getProductSn();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
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.IMesShippingQueueService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
||||
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesProdRouteOptParam;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.seres.MesCimSeresJisRfid;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingQueue;
|
||||
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 lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @Description : 发运队列获取赛力斯RFID工步
|
||||
* @Author : wangjie
|
||||
**/
|
||||
@Slf4j
|
||||
@Service("mesShippingRfidSeresFindStepService")
|
||||
public class MesShippingRfidSeresFindStepService extends BaseStepService {
|
||||
|
||||
@Autowired
|
||||
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
|
||||
|
||||
@Autowired
|
||||
private IMesShippingQueueService shippingQueueService;
|
||||
|
||||
@Override
|
||||
public StepResult execute(StationRequestBean reqBean) {
|
||||
|
||||
StationResultBean resultBean = new StationResultBean();
|
||||
|
||||
StepResult stepResult = StepResult.getSuccessComplete();
|
||||
|
||||
//获取工步参数
|
||||
Optional<Map<String, MesProdRouteOptParam>> stepParamMap = getStepParams(reqBean);
|
||||
|
||||
//获取上下文发运队列信息
|
||||
MesShippingQueue shippingQueue = productionDispatchContextStepService.getShippingQueueContext(reqBean);
|
||||
if ((null == shippingQueue || StringUtils.isEmpty(shippingQueue.getVin()))) {
|
||||
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().checkRepeat(), stepResult,
|
||||
false, MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT, "当前未获取到缓存中有效的发运队列,即将重新获取!",
|
||||
stepParamMap, MesPcnExtConstWords.READ_FAILURE_SLEEP, MesPcnExtConstWords.READ_FAILURE_SLEEP_DEFAULT_TIME);
|
||||
}
|
||||
|
||||
//根据VIN查询赛力斯RFID信息
|
||||
MesCimSeresJisRfid cimSeresJisRfid = shippingQueueService.getCimSeresJisRfid(reqBean.getOrganizeCode(), shippingQueue.getVin());
|
||||
if (null == cimSeresJisRfid || StringUtils.isEmpty(cimSeresJisRfid.getRfid())) {
|
||||
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().checkRepeat(), stepResult,
|
||||
false, MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT,
|
||||
String.format("当前零件发运组[%s]匹配的发运队列单号[%s]VIN[%s]未查询到有效的赛力斯RFID信息,请人工处理! 持续监听中...", shippingQueue.getShippingGroupCode(), shippingQueue.getShippingCode(), shippingQueue.getVin()),
|
||||
stepParamMap, MesPcnExtConstWords.READ_FAILURE_SLEEP, MesPcnExtConstWords.READ_FAILURE_SLEEP_DEFAULT_TIME);
|
||||
}
|
||||
|
||||
//解析rfidSn
|
||||
String rfidSn = getRfidSn(stepParamMap, cimSeresJisRfid.getRfid());
|
||||
if (StringUtils.isEmpty(rfidSn)) {
|
||||
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().checkRepeat(), stepResult,
|
||||
false, MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT,
|
||||
String.format("当前零件发运组[%s]匹配的发运队列单号[%s]VIN[%s]查询到的赛力斯RFID[%s]解析错误,请人工处理! 持续监听中...", shippingQueue.getShippingGroupCode(), shippingQueue.getShippingCode(), shippingQueue.getVin(), cimSeresJisRfid.getRfid()),
|
||||
stepParamMap, MesPcnExtConstWords.READ_FAILURE_SLEEP, MesPcnExtConstWords.READ_FAILURE_SLEEP_DEFAULT_TIME);
|
||||
}
|
||||
|
||||
//保存上下文发运队列信息
|
||||
shippingQueue.setPidStr(cimSeresJisRfid.getId().toString());
|
||||
shippingQueue.setRfidSn(rfidSn);
|
||||
productionDispatchContextStepService.dispatchShippingQueueContext(reqBean, shippingQueue);
|
||||
|
||||
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult,
|
||||
String.format("零件发运组[%s]发运队列单号[%s]VIN[%s]已匹配到赛力斯RFID信息[%s]!", shippingQueue.getShippingGroupCode(), shippingQueue.getShippingCode(), shippingQueue.getVin(), cimSeresJisRfid.getRfid()));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* ################## 【拉动单号18位】
|
||||
* 3263 【供应商代码 4位】
|
||||
* 1 【-个VIN对应几个托盘 1位】
|
||||
* 2 【左右区分,0代表做,1代表右;不区分左右为2 1位】
|
||||
* JSG1DJ05 【LMS零件类 8位】
|
||||
* 默认替换说明: 截取96位后面的32位替换为上面拼接的字符串
|
||||
*/
|
||||
//解析rfidSn
|
||||
private String getRfidSn(Optional<Map<String, MesProdRouteOptParam>> stepParamMap, String rfid) {
|
||||
//replaceIndex=替换起始位置; replaceLength=替换长度; replaceInfo=替换信息
|
||||
String replaceIndex = (null != stepParamMap && stepParamMap.isPresent() && stepParamMap.get().containsKey(MesPcnExtConstWords.REPLACE_INDEX)) ? stepParamMap.get().get(MesPcnExtConstWords.REPLACE_INDEX).getParamValue() : null;
|
||||
String replaceLength = (null != stepParamMap && stepParamMap.isPresent() && stepParamMap.get().containsKey(MesPcnExtConstWords.REPLACE_LENGTH)) ? stepParamMap.get().get(MesPcnExtConstWords.REPLACE_LENGTH).getParamValue() : null;
|
||||
String replaceInfo = (null != stepParamMap && stepParamMap.isPresent() && stepParamMap.get().containsKey(MesPcnExtConstWords.REPLACE_INFO)) ? stepParamMap.get().get(MesPcnExtConstWords.REPLACE_INFO).getParamValue() : null;
|
||||
if (StringUtils.isEmpty(replaceIndex)) replaceIndex = "96";
|
||||
if (StringUtils.isEmpty(replaceLength)) replaceLength = "32";
|
||||
if (StringUtils.isEmpty(replaceInfo)) replaceInfo = "##################326312JSG1DJ05";
|
||||
try {
|
||||
return new StringBuilder().append(rfid, MesPcnExtConstWords.ZERO, Integer.parseInt(replaceIndex)).append(replaceInfo).append(rfid, Integer.parseInt(replaceIndex) + Integer.parseInt(replaceLength), rfid.length()).toString();
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// String rfid = "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567";
|
||||
// System.out.println(rfid.length());
|
||||
// System.out.println(rfid);
|
||||
// System.out.println(rfid.substring(0, 96) + "##################326312JSG1DJ05" + rfid.substring(128));
|
||||
// System.out.println(new StringBuilder().append(rfid, 0, 96).append("##################326312JSG1DJ05").append(rfid, 96+32, rfid.length()).toString());
|
||||
// }
|
||||
|
||||
}
|
Loading…
Reference in New Issue