forked from I3-YF/i3plus-mes-pcn-yfai
step
parent
2795d3109d
commit
3f9d4f0e98
@ -1,119 +0,0 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesMouldMultiCavityService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesEquipVariableCfgRuleMatchDispatchService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesEquipmentLogExtService;
|
||||
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.MesEquipLogDispatchContext;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
|
||||
import cn.estsh.i3plus.mes.pcn.api.iservice.base.IPartService;
|
||||
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.*;
|
||||
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 com.alibaba.fastjson.JSONObject;
|
||||
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.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @Description : 发送初始化指令工步
|
||||
* @Author : wangjie
|
||||
**/
|
||||
@Slf4j
|
||||
@Service("MesSendInitializationCmdStepSeryice")
|
||||
public class MesSendInitializationCmdStepSeryice extends BaseStepService {
|
||||
|
||||
@Autowired
|
||||
private IMesProductionProcessContextStepService productionProcessContextStepService;
|
||||
|
||||
@Autowired
|
||||
private IMesEquipmentLogExtService equipmentLogExtService;
|
||||
|
||||
@Autowired
|
||||
private IMesEquipVariableCfgRuleMatchDispatchService equipVariableCfgRuleMatchService;
|
||||
|
||||
@Autowired
|
||||
private IMesMouldMultiCavityService mouldMultiCavityService;
|
||||
|
||||
@Autowired
|
||||
private IPartService partService;
|
||||
|
||||
@Override
|
||||
public StepResult init(StationRequestBean reqBean) {
|
||||
|
||||
productionProcessContextStepService.doSendStepContextMessage(reqBean);
|
||||
|
||||
return super.init(reqBean);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public StepResult execute(StationRequestBean reqBean) {
|
||||
|
||||
StationResultBean resultBean = new StationResultBean();
|
||||
|
||||
StepResult stepResult = StepResult.getSuccessComplete();
|
||||
|
||||
Optional<Map<String, MesProdRouteOptParam>> stepParamMap = getStepParams(reqBean);
|
||||
|
||||
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getCurCellEquipment(reqBean, stepParamMap);
|
||||
|
||||
//当前工序已存在头道模具号跟一模多腔信息
|
||||
if (!StringUtils.isEmpty(productionProcessContext.getFirstMouldNo()) && !StringUtils.isEmpty(productionProcessContext.getMouldCavityJson())) return stepResult;
|
||||
|
||||
//获取生产过程上下文对象有异常信息 抛出异常
|
||||
if (!productionProcessContextStepService.getEquipmentVariableCfgList(productionProcessContext).getSuccess()) execExpSendMsgAndThrowEx(reqBean, resultBean, productionProcessContext.getMessage());
|
||||
|
||||
List<MesEquipmentVariableCfg> equipmentVariableCfgList = productionProcessContext.getEquipVariableCfgListByVct();
|
||||
|
||||
equipmentVariableCfgList = productionProcessContextStepService.collectEquipmentVariableCfgList(equipmentVariableCfgList, MesExtEnumUtil.EQUIP_VARIABLE_CFG_CATEGORY.SEND_INIT.getValue());
|
||||
|
||||
MesCellEquipContext cellEquipContext = productionProcessContext.getCurCellEquip();
|
||||
|
||||
//配置错误 抛出异常
|
||||
if (CollectionUtils.isEmpty(equipmentVariableCfgList)) execExpSendMsgAndThrowEx(reqBean, resultBean,
|
||||
String.format("请检查设备数据变量接口逻辑信息,设备[%s]未配置变量配置类型[%s]头道模具号相关变量类别的数据变量接口逻辑信息!", cellEquipContext.getEquipmentCode(), cellEquipContext.getVariableCfgType()));
|
||||
|
||||
List<String> categoryLevelTwoList = productionProcessContextStepService.collectCategoryLevelTwoList(equipmentVariableCfgList);
|
||||
|
||||
List<MesEquipmentVariable> equipmentVariableList = productionProcessContextStepService.findEquipmentVariableList(productionProcessContext, MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PRODUCTION.getValue(), categoryLevelTwoList);
|
||||
|
||||
//配置错误 抛出异常
|
||||
if (CollectionUtils.isEmpty(equipmentVariableList)) execExpSendMsgAndThrowEx(reqBean, resultBean,
|
||||
String.format("请检查设备数据变量信息,根据设备[%s]对应的数据变量接口逻辑信息,未配置变量类型[%s]二级变量%s相关的数据变量信息!", cellEquipContext.getEquipmentCode(), MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PRODUCTION.getDescription(), categoryLevelTwoList.toString()));
|
||||
|
||||
MesEquipLogDispatchContext equipLogDispatchContext = equipmentLogExtService.doHandleEquipmentLogList(cellEquipContext, equipmentVariableList, equipmentVariableCfgList);
|
||||
this.sendMessage(reqBean, resultBean, JSONObject.toJSONString(equipLogDispatchContext), MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);
|
||||
|
||||
//发送 todo
|
||||
MesEquipmentVariableCfg mesEquipmentVariableCfg = equipmentVariableCfgList.get(0);
|
||||
StringBuilder jsonSb = new StringBuilder();
|
||||
for (MesEquipmentVariable mesEquipmentVariable : equipmentVariableList) {
|
||||
jsonSb.append("{\n");
|
||||
jsonSb.append("\"tem:ReadVariable\":{\n");
|
||||
jsonSb.append("\"tem:equipmentId\":\""+mesEquipmentVariable.getEquipId()+"\",\n");
|
||||
jsonSb.append("\"tem:channel\":\""+mesEquipmentVariable.getChannel()+"\",\n");
|
||||
jsonSb.append("\"tem:clientHandle\":\""+mesEquipmentVariable.getClientHandle()+"\",\n");
|
||||
jsonSb.append("\"tem:v\":\""+mesEquipmentVariableCfg.getValue()+"\"\n");
|
||||
jsonSb.append("}\n");
|
||||
String json = jsonSb.append("}\n").toString();
|
||||
//发送
|
||||
}
|
||||
|
||||
return stepResult;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,126 +0,0 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesMouldMultiCavityService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesEquipVariableCfgRuleMatchDispatchService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesEquipmentLogExtService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.*;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
||||
import cn.estsh.i3plus.mes.pcn.api.iservice.base.IPartService;
|
||||
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
|
||||
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.bean.*;
|
||||
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 com.alibaba.fastjson.JSONObject;
|
||||
import javassist.tools.web.Webserver;
|
||||
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 javax.jws.WebService;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description : 发送允许加工指令工步
|
||||
* @Author : wangjie
|
||||
**/
|
||||
@Slf4j
|
||||
@Service("MesSendProcessCmdStepService")
|
||||
public class MesSendProcessCmdStepService extends BaseStepService {
|
||||
|
||||
@Autowired
|
||||
private IMesProductionProcessContextStepService productionProcessContextStepService;
|
||||
|
||||
@Autowired
|
||||
private IMesEquipmentLogExtService equipmentLogExtService;
|
||||
|
||||
@Autowired
|
||||
private IMesEquipVariableCfgRuleMatchDispatchService equipVariableCfgRuleMatchService;
|
||||
|
||||
@Autowired
|
||||
private IMesMouldMultiCavityService mouldMultiCavityService;
|
||||
|
||||
@Autowired
|
||||
private IPartService partService;
|
||||
|
||||
@Override
|
||||
public StepResult init(StationRequestBean reqBean) {
|
||||
|
||||
productionProcessContextStepService.doSendStepContextMessage(reqBean);
|
||||
|
||||
return super.init(reqBean);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public StepResult execute(StationRequestBean reqBean) {
|
||||
|
||||
StationResultBean resultBean = new StationResultBean();
|
||||
|
||||
StepResult stepResult = StepResult.getSuccessComplete();
|
||||
|
||||
Optional<Map<String, MesProdRouteOptParam>> stepParamMap = getStepParams(reqBean);
|
||||
|
||||
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getCurCellEquipment(reqBean, stepParamMap);
|
||||
|
||||
//当前工序已存在头道模具号跟一模多腔信息
|
||||
if (!StringUtils.isEmpty(productionProcessContext.getFirstMouldNo()) && !StringUtils.isEmpty(productionProcessContext.getMouldCavityJson())) return stepResult;
|
||||
|
||||
//获取生产过程上下文对象有异常信息 抛出异常
|
||||
if (!productionProcessContextStepService.getEquipmentVariableCfgList(productionProcessContext).getSuccess()) execExpSendMsgAndThrowEx(reqBean, resultBean, productionProcessContext.getMessage());
|
||||
|
||||
List<MesEquipmentVariableCfg> equipmentVariableCfgList = productionProcessContext.getEquipVariableCfgListByVct();
|
||||
|
||||
equipmentVariableCfgList = productionProcessContextStepService.collectEquipmentVariableCfgList(equipmentVariableCfgList, MesExtEnumUtil.EQUIP_VARIABLE_CFG_CATEGORY.SEND_PROCESS.getValue());
|
||||
|
||||
MesCellEquipContext cellEquipContext = productionProcessContext.getCurCellEquip();
|
||||
|
||||
//配置错误 抛出异常
|
||||
if (CollectionUtils.isEmpty(equipmentVariableCfgList)) execExpSendMsgAndThrowEx(reqBean, resultBean,
|
||||
String.format("请检查设备数据变量接口逻辑信息,设备[%s]未配置变量配置类型[%s]允许加工指令工步 相关变量类别的数据变量接口逻辑信息!", cellEquipContext.getEquipmentCode(), cellEquipContext.getVariableCfgType()));
|
||||
|
||||
List<String> categoryLevelTwoList = productionProcessContextStepService.collectCategoryLevelTwoList(equipmentVariableCfgList);
|
||||
|
||||
List<MesEquipmentVariable> equipmentVariableList = productionProcessContextStepService.findEquipmentVariableList(productionProcessContext, MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PRODUCTION.getValue(), categoryLevelTwoList);
|
||||
|
||||
//配置错误 抛出异常
|
||||
if (CollectionUtils.isEmpty(equipmentVariableList)) execExpSendMsgAndThrowEx(reqBean, resultBean,
|
||||
String.format("请检查设备数据变量信息,根据设备[%s]对应的数据变量接口逻辑信息,未配置变量类型[%s]二级变量%s相关的数据变量信息!", cellEquipContext.getEquipmentCode(), MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PRODUCTION.getDescription(), categoryLevelTwoList.toString()));
|
||||
|
||||
MesEquipLogDispatchContext equipLogDispatchContext = equipmentLogExtService.doHandleEquipmentLogList(cellEquipContext, equipmentVariableList, equipmentVariableCfgList);
|
||||
this.sendMessage(reqBean, resultBean, JSONObject.toJSONString(equipLogDispatchContext), MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);
|
||||
//发送 todo
|
||||
MesEquipmentVariableCfg mesEquipmentVariableCfg = equipmentVariableCfgList.get(0);
|
||||
StringBuilder jsonSb = new StringBuilder();
|
||||
for (MesEquipmentVariable mesEquipmentVariable : equipmentVariableList) {
|
||||
jsonSb.append("{\n");
|
||||
jsonSb.append("\"tem:ReadVariable\":{\n");
|
||||
jsonSb.append("\"tem:equipmentId\":\""+mesEquipmentVariable.getEquipId()+"\",\n");
|
||||
jsonSb.append("\"tem:channel\":\""+mesEquipmentVariable.getChannel()+"\",\n");
|
||||
jsonSb.append("\"tem:clientHandle\":\""+mesEquipmentVariable.getClientHandle()+"\",\n");
|
||||
jsonSb.append("\"tem:v\":\""+mesEquipmentVariableCfg.getValue()+"\"\n");
|
||||
jsonSb.append("}\n");
|
||||
String json = jsonSb.append("}\n").toString();
|
||||
//发送
|
||||
}
|
||||
|
||||
if (!stepResult.isCompleted()) threadSleep(stepParamMap, MesPcnExtConstWords.READ_FAILURE_SLEEP, MesPcnExtConstWords.READ_FAILURE_SLEEP_DEFAULT_TIME);
|
||||
|
||||
return stepResult;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue