客户端下线 不再清除数据 变更成 上线时清除

tags/yfai-pcn-ext-v1.0
王杰 10 months ago
parent 10f0c723a0
commit f5904f4430

@ -5,6 +5,7 @@ import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionCustomContextStepServi
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.MesProductionPartContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
@ -74,16 +75,15 @@ public class MesProductionNoSortModuleService extends BaseModuleService {
//获取上下文信息
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);
throw ImppExceptionBuilder.newInstance().setSystemID(CommonEnumUtil.SOFT_TYPE.MES_PCN.getCode()).setErrorCode("NO_SHOW_MSG").build();
MesPcnException.throwBusiException("请先开班");
}
// 发送班次班组和工单
StationResultBean resultBean = getStationResultBean(reqBean, moduleContentContext, prodShiftDataContext);
@ -92,8 +92,8 @@ public class MesProductionNoSortModuleService extends BaseModuleService {
// 整合班次加工数量
List<StationKvBean> productionStatisticsContext = productionCustomContextStepService.getProductionStatisticsContext(reqBean);
if (CollectionUtils.isEmpty(productionStatisticsContext)) {
productionStatisticsContext = StationKvBeanUtil.addStationKvBeanList(new ArrayList<>(), new StationKvBean(new StringJoiner(MesPcnExtConstWords.AND).add(mesProdShiftKvBean.getShiftGroup()).add(mesProdShiftKvBean.getShiftCode()).toString(), "加工数", "0"),
new StationKvBean("color", "颜色", MesExtEnumUtil.COLOR.BLACK.getValue()));
productionStatisticsContext = StationKvBeanUtil.addStationKvBeanList(new ArrayList<>(), new StationKvBean(new StringJoiner(MesPcnExtConstWords.AND).add(mesProdShiftKvBean.getShiftGroup()).add(mesProdShiftKvBean.getShiftCode()).toString(), "加工数", MesPcnExtConstWords.ZERO_STR),
new StationKvBean(MesPcnExtConstWords.COLOR, "颜色", MesExtEnumUtil.COLOR.BLACK.getValue()));
}
StationResultBean shiftCountBean = getStationResultBean(reqBean, productionStatisticsContext,mesWorkCell, mesProdShiftKvBean);
this.sendMessage(reqBean, shiftCountBean);
@ -137,14 +137,6 @@ public class MesProductionNoSortModuleService extends BaseModuleService {
return resultBean;
}
private List<AttrBean> packDataAttrList() {
List<AttrBean> attrBeanList = new ArrayList<>();
PojoAttrUtil.loadPojoAttrs(attrBeanList, "index", "序号",true);
PojoAttrUtil.loadPojoAttrs(attrBeanList, "custPartNo", "客户零件号", true);
PojoAttrUtil.loadPojoAttrs(attrBeanList, "orderNo", "工单号", true);
return attrBeanList;
}
private StationResultBean getStationResultBean(StationRequestBean reqBean, List<StationKvBean> productionStatisticsContext, MesWorkCell mesWorkCell, MesProdShiftContext mesProdShiftKvBean) {
StationResultBean resultBean = new StationResultBean();
resultBean.setBusiType(MesPcnEnumUtil.STATION_BUSI_TYPE.MODULE_CUSTOM_CONTENT.getValue());
@ -158,7 +150,7 @@ public class MesProductionNoSortModuleService extends BaseModuleService {
if (!StringUtils.isEmpty(mesWorkCell.getFileId())) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean();
DdlPreparedPack.getNumEqualPack(Long.parseLong(mesWorkCell.getFileId()), "id", packBean);
DdlPreparedPack.getNumEqualPack(Long.parseLong(mesWorkCell.getFileId()), MesPcnExtConstWords.ID, packBean);
MesFile mesFile = mesFileRepository.getByProperty(packBean);
if (mesFile != null) {
url = mesFile.getFileUrl();
@ -169,15 +161,15 @@ public class MesProductionNoSortModuleService extends BaseModuleService {
List<MesWorkOrder> workOrderList = workOrderExtService.getWorkOrderListByShiftCode(reqBean.getOrganizeCode(), mesWorkCell.getWorkCenterCode(), mesProdShiftKvBean.getShiftCode());
if (CollectionUtils.isEmpty(workOrderList)) {
StationKvBeanUtil.addStationKvBeanList(orderQtyKvBeans, new ArrayList<>(),
new StationKvBean(MesPcnExtConstWords.QTY, "工单计划数", 0 + ""),
new StationKvBean(MesPcnExtConstWords.COMPLATED_QTY, "工单完成数", 0 + ""));
new StationKvBean(MesPcnExtConstWords.QTY, "工单计划数", MesPcnExtConstWords.ZERO_STR),
new StationKvBean(MesPcnExtConstWords.COMPLATED_QTY, "工单完成数", MesPcnExtConstWords.ZERO_STR));
} else {
double qty = workOrderList.stream().map(MesWorkOrder::getQty).reduce((a, b) -> a + b).get();
double complateQty = workOrderList.stream().map(MesWorkOrder::getCompleteQty).reduce((a, b) -> a + b).get();
Double qty = workOrderList.stream().map(MesWorkOrder::getQty).reduce((a, b) -> a + b).get();
Double complateQty = workOrderList.stream().map(MesWorkOrder::getCompleteQty).reduce((a, b) -> a + b).get();
StationKvBeanUtil.addStationKvBeanList(orderQtyKvBeans, new ArrayList<>(),
new StationKvBean(MesPcnExtConstWords.QTY, "工单计划数", qty + ""),
new StationKvBean(MesPcnExtConstWords.COMPLATED_QTY, "工单完成数", complateQty + ""));
new StationKvBean(MesPcnExtConstWords.QTY, "工单计划数", qty.toString()),
new StationKvBean(MesPcnExtConstWords.COMPLATED_QTY, "工单完成数", complateQty.toString()));
}
if (!CollectionUtils.isEmpty(productionPartContextList)) {
@ -186,11 +178,11 @@ public class MesProductionNoSortModuleService extends BaseModuleService {
resultBean.setResultList(orderQtyKvBeans);
} else if (Objects.equal(MesExtEnumUtil.WORK_FILE_TYPE.PROD_VIDEO.getValue(), mesWorkCell.getIsShowMsg())) {
dataType = MesPcnEnumUtil.STATION_DATA_TYPE.VIDEO.getValue();
reqJson.put("url", url);
reqJson.put(MesPcnExtConstWords.URL, url);
resultBean.setResultObj(reqJson);
} else if (Objects.equal(MesExtEnumUtil.WORK_FILE_TYPE.WORK_CELL_PICTURE.getValue(), mesWorkCell.getIsShowMsg())) {
dataType = MesPcnEnumUtil.STATION_DATA_TYPE.IMAGE.getValue();
reqJson.put("url", url);
reqJson.put(MesPcnExtConstWords.URL, url);
resultBean.setResultObj(reqJson);
}
@ -205,19 +197,20 @@ public class MesProductionNoSortModuleService extends BaseModuleService {
return resultBean;
}
@Override
public boolean execStateModule(StationRequestBean reqBean, List<MesStateMachineStatus> states, Map<String, String> wcpcMap) {
init(reqBean);
return true;
}
//封装展示组件班组班次内容
private List<StationKvBean> getProdShiftData(MesProdShiftRecord record) {
return StationKvBeanUtil.addStationKvBeanList(new ArrayList<>(),
new StationKvBean("shiftGroup", "班组", record.getShiftGroup()),
new StationKvBean("shiftGroupName", "班组名称", record.getShiftGroupName()),
new StationKvBean("shiftCode", "班次", record.getShiftCode()),
new StationKvBean("shiftName", "班次名称", record.getShiftName()))
;
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()));
}
}

@ -49,8 +49,9 @@ public class MesFunctionChooseCavityOrderService extends BaseSwsService implemen
MesWorkCell workCell = productionProcessContext.getWorkCell();
//暂定不需要卡控
// if (StringUtils.isEmpty(workCell.getIsAllowOrder()) || CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue() == workCell.getIsAllowOrder()) {
// this.sendMessage(reqBean, resultBean.writeDbLog(MesExtEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PICK.getValue()).scanInfo(buttonDynamicModel.getFunctionValue()),
// this.sendMessage(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PICK.getValue()).scanInfo(buttonDynamicModel.getFunctionValue()),
// String.format("生产线[%s]工位[%s]%s失败,工位未设置允许界面选工单!", reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), buttonDynamicModel.getButtonName()), MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT);
// return false;
// }

@ -1,14 +1,12 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.station.function;
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.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
import cn.estsh.i3plus.pojo.mes.model.ButtonDynamicModel;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
@ -18,18 +16,15 @@ import org.springframework.util.StringUtils;
@Service
public class MesFunctionSwitchCellService extends BaseSwsService implements IFsmModuleFunctionService {
@Autowired
private IShippingDispatchService shippingDispatchService;
@Override
public Object doCustomApiDispatch(StationRequestBean reqBean, StationResultBean resultBean, ButtonDynamicModel buttonDynamicModel) {
resultBean.isWs(false).writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PICK.getValue()).scanInfo(buttonDynamicModel.getFunctionValue());
if (StringUtils.isEmpty(buttonDynamicModel.getFunctionValue()) || buttonDynamicModel.getFunctionValue().equals(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValueStr()))
this.sendMessage(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PICK.getValue()).scanInfo(buttonDynamicModel.getFunctionValue()),
String.format("生产线[%s]工位[%s]%s,客户端已下线!", reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), buttonDynamicModel.getButtonName()), MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);
this.sendMessage(reqBean, resultBean, String.format("生产线[%s]工位[%s]执行工位按钮[%s]客户端下线!", reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), buttonDynamicModel.getButtonName()), MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);
else
this.sendMessage(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PICK.getValue()).scanInfo(buttonDynamicModel.getFunctionValue()),
String.format("生产线[%s]工位[%s]%s,客户端已在线!", reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), buttonDynamicModel.getButtonName()), MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);
this.sendMessage(reqBean, resultBean, String.format("生产线[%s]工位[%s]执行工位按钮[%s]客户端上线!", reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), buttonDynamicModel.getButtonName()), MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);
return true;

@ -118,8 +118,8 @@ public class MesProductionCustomContextStepService extends BaseStepService imple
if (CollectionUtils.isEmpty(stationKvBeans)) {
return null;
}
StationKvBean shiftGroupKvBean = stationKvBeans.stream().filter(stationKvBean -> Objects.equal(stationKvBean.getKey(), "shiftGroup")).findFirst().orElse(null);
StationKvBean shiftCodeKvBean = stationKvBeans.stream().filter(stationKvBean -> Objects.equal(stationKvBean.getKey(), "shiftCode")).findFirst().orElse(null);
StationKvBean shiftGroupKvBean = stationKvBeans.stream().filter(stationKvBean -> Objects.equal(stationKvBean.getKey(), MesPcnExtConstWords.SHIFT_GROUP)).findFirst().orElse(null);
StationKvBean shiftCodeKvBean = stationKvBeans.stream().filter(stationKvBean -> Objects.equal(stationKvBean.getKey(), MesPcnExtConstWords.SHIFT_CODE)).findFirst().orElse(null);
mesProdShiftContext.setShiftCode(shiftGroupKvBean == null ? null : shiftCodeKvBean.getValue());
mesProdShiftContext.setShiftGroup(shiftCodeKvBean == null ? null : shiftGroupKvBean.getValue());
@ -186,18 +186,18 @@ public class MesProductionCustomContextStepService extends BaseStepService imple
List<StationKvBean> stationKvBeans = getProductionStatisticsContext(reqBean);
String countStr = String.valueOf(count);
AtomicReference<Integer> amount = new AtomicReference<>();
amount.set(count);
if (CollectionUtils.isEmpty(stationKvBeans)) {
String name = "加工数";
String value = count + "";
stationKvBeans = StationKvBeanUtil.addStationKvBeanList(new ArrayList<>(),
new StationKvBean(mesProdShiftKvBean.getShiftGroup(), name, value), new StationKvBean("color", "颜色", MesExtEnumUtil.COLOR.BLACK.getValue()));
new StationKvBean(mesProdShiftKvBean.getShiftGroup(), name, countStr), new StationKvBean(MesPcnExtConstWords.COLOR, "颜色", MesExtEnumUtil.COLOR.BLACK.getValue()));
} else {
stationKvBeans.stream().forEach(stationKvBean -> {
if (stationKvBean.getKey().contains(mesProdShiftKvBean.getShiftGroup())) {
stationKvBean.setValue(stationKvBean == null ? count + "" : (Integer.valueOf(stationKvBean.getValue()) + count) + "");
stationKvBean.setValue(stationKvBean == null ? countStr : String.valueOf(Integer.valueOf(stationKvBean.getValue()) + count));
amount.set(Integer.valueOf(stationKvBean.getValue()));
}
});

@ -441,6 +441,7 @@ public class MesProductionProcessContextStepService extends BaseStepService impl
if (null == scanMonitorContext) return false;
//开模记录ID, 工序开始时间
if (isSetMouldRecordId) scanMonitorContext.mouldRecordId(snowflakeIdMaker.nextId()).startDateTime(TimeTool.getNowTime(true));
log.info("工厂{}生产线{}工位{}:工序缓存工位扫描监控信息:{}", reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), JSONObject.toJSONString(scanMonitorContext));
return saveFsmBusiData(reqBean.getOrganizeCode(), getContextKey(reqBean), MesPcnExtConstWords.SCAN_MONITOR_CONTEXT, JSONObject.toJSONString(scanMonitorContext));
}
@ -457,7 +458,7 @@ public class MesProductionProcessContextStepService extends BaseStepService impl
}
private String getContextKey(String organizeCode, String workCenterCode, String workCellCode) {
return new StringJoiner(":").add(organizeCode).add(workCenterCode).add(workCellCode).add(MesPcnExtConstWords.PRODUCTION_PROCESS_CONTEXT).add(MesPcnExtConstWords.BASE_DATA_CONTEXT).toString();
return new StringJoiner(MesPcnExtConstWords.COLON).add(organizeCode).add(workCenterCode).add(workCellCode).add(MesPcnExtConstWords.PRODUCTION_PROCESS_CONTEXT).add(MesPcnExtConstWords.BASE_DATA_CONTEXT).toString();
}
//获取上下文工位扫描监控信息

@ -67,7 +67,7 @@ public class MesProductionProcessMonitorService extends BaseProcessMonitorServic
//客户端下线
@Override
public Boolean doOffLine(StationRequestBean requestBean) {
public Boolean doOnLine(StationRequestBean requestBean) {
//删除当前工步集
fsmCommonService.doFlushCache(requestBean);
//清除上下文中的所有业务数据
@ -77,6 +77,10 @@ public class MesProductionProcessMonitorService extends BaseProcessMonitorServic
return true;
}
//客户端下线
@Override
public Boolean doOffLine(StationRequestBean requestBean) { return true; }
//工位流程重置 【父类已经调用: 删除当前工步集; 清除工位工序流程; TASK_COMPLETE】
@Override
public Boolean fsmReset(StationRequestBean requestBean) {

@ -75,7 +75,7 @@ public class MesPcnException {
*/
public static void throwBusiException(String errorDetail, Object...args){
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES.getCode())
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES_PCN.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail(errorDetail, args)
.build();

@ -85,10 +85,14 @@ public class MesPcnExtConstWords {
public static final String MOULD_NO = "mouldNo";
// 工单完成数
public static final String COMPLATED_QTY = "complateQty";
// 班次
// 班次代码
public static final String SHIFT_CODE = "shiftCode";
// 班次名称
public static final String SHIFT_NAME = "shiftName";
// 班组
public static final String SHIFT_GROUP = "shiftGroup";
// 班组名称
public static final String SHIFT_GROUP_NAME = "shiftGroupName";
// 工序代码
public static final String PROCESS_CODE = "processCode";
// 工艺代码
@ -163,6 +167,8 @@ public class MesPcnExtConstWords {
public static final String RULE_CODE = "ruleCode";
// 打印状态
public static final String PRINT_STATUS = "printStatus";
// 颜色
public static final String COLOR = "color";
// 时间格式
public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";

Loading…
Cancel
Save