|
|
|
@ -1,129 +1,129 @@
|
|
|
|
|
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.mes.pcn.serviceimpl.fsm.BaseStepService;
|
|
|
|
|
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.MesProdRouteOptParam;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesRawPackageDetail;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesRawPartCharging;
|
|
|
|
|
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.MesRawPackageDetailRepository;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesRawPartChargingRepository;
|
|
|
|
|
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;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description : 从料桶中获取原材料
|
|
|
|
|
* @Author : zxw
|
|
|
|
|
**/
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service("mesMaterialReadStepService")
|
|
|
|
|
public class MesMaterialReadStepService extends BaseStepService {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMesProductionProcessContextStepService productionProcessContextStepService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesRawPackageDetailRepository mesRawPackageDeatilRepository;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesRawPartChargingRepository mesRawPartChargingRepository;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public StepResult execute(StationRequestBean reqBean) {
|
|
|
|
|
|
|
|
|
|
StationResultBean resultBean = new StationResultBean();
|
|
|
|
|
|
|
|
|
|
StepResult stepResult = StepResult.getSuccessComplete();
|
|
|
|
|
|
|
|
|
|
//获取工步参数
|
|
|
|
|
Optional<Map<String, MesProdRouteOptParam>> stepParamMap = getStepParams(reqBean);
|
|
|
|
|
//获取上下文信息
|
|
|
|
|
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.doHandleCurCellEquipment(reqBean, stepParamMap);
|
|
|
|
|
|
|
|
|
|
String equipmentCode = productionProcessContext.getCurCellEquip().getEquipmentCode();
|
|
|
|
|
|
|
|
|
|
// 根据设备id获取加料日志
|
|
|
|
|
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean();
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(equipmentCode, "equipCode", packBean);
|
|
|
|
|
MesRawPackageDetail mesRawPackageDetail = mesRawPackageDeatilRepository.getByProperty(packBean);
|
|
|
|
|
if (mesRawPackageDetail == null) {
|
|
|
|
|
foundExThrow(reqBean, "原材料容器信息未配置");
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 查询原材料信息
|
|
|
|
|
*/
|
|
|
|
|
List<MesRawPartCharging> list = getListByParentDetailId(mesRawPackageDetail.getId());
|
|
|
|
|
/**
|
|
|
|
|
* 查询料桶信息 todo
|
|
|
|
|
*/
|
|
|
|
|
/*MesRawPartCharging mesRawPartCharging = getRawPackByDetailId(mesRawPackageDetail.getId());
|
|
|
|
|
if (mesRawPackageDetail == null) {
|
|
|
|
|
foundExThrow(reqBean, "料桶信息不存在");
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
list.add(mesRawPartCharging);*/
|
|
|
|
|
productionDispatchContextStepService.saveMesRawPartChargingDataContext(reqBean, list);
|
|
|
|
|
|
|
|
|
|
return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, "读取料桶原材料成功");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 递归查询子料桶,直到查到最终的物料
|
|
|
|
|
* @param id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private List<MesRawPartCharging> getListByParentDetailId(Long id){
|
|
|
|
|
if (id == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
List<MesRawPartCharging> list = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean();
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(id, "parentPackageDetailId", packBean);
|
|
|
|
|
|
|
|
|
|
List<MesRawPartCharging> parentList = mesRawPartChargingRepository.findByHqlWhere(packBean);
|
|
|
|
|
if (CollectionUtils.isEmpty(parentList)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
for (MesRawPartCharging mesRawPartCharging : parentList) {
|
|
|
|
|
List<MesRawPartCharging> chilrenList = getListByParentDetailId(mesRawPartCharging.getPackageDetailId());
|
|
|
|
|
if (CollectionUtils.isEmpty(chilrenList)) {
|
|
|
|
|
list.add(mesRawPartCharging);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 递归查询子料桶,直到查到最终的物料
|
|
|
|
|
* @param id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private MesRawPartCharging getRawPackByDetailId(Long id){
|
|
|
|
|
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean();
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(id, "packageDetailId", packBean);
|
|
|
|
|
|
|
|
|
|
return mesRawPartChargingRepository.getByProperty(packBean);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//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.mes.pcn.serviceimpl.fsm.BaseStepService;
|
|
|
|
|
//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.MesProdRouteOptParam;
|
|
|
|
|
//import cn.estsh.i3plus.pojo.mes.bean.MesRawPackageDetail;
|
|
|
|
|
//import cn.estsh.i3plus.pojo.mes.bean.MesRawPartCharging;
|
|
|
|
|
//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.MesRawPackageDetailRepository;
|
|
|
|
|
//import cn.estsh.i3plus.pojo.mes.repository.MesRawPartChargingRepository;
|
|
|
|
|
//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;
|
|
|
|
|
//import java.util.Optional;
|
|
|
|
|
//
|
|
|
|
|
///**
|
|
|
|
|
// * @Description : 从料桶中获取原材料
|
|
|
|
|
// * @Author : zxw
|
|
|
|
|
// **/
|
|
|
|
|
//@Slf4j
|
|
|
|
|
//@Service("mesMaterialReadStepService")
|
|
|
|
|
//public class MesMaterialReadStepService extends BaseStepService {
|
|
|
|
|
//
|
|
|
|
|
// @Autowired
|
|
|
|
|
// private IMesProductionProcessContextStepService productionProcessContextStepService;
|
|
|
|
|
//
|
|
|
|
|
// @Autowired
|
|
|
|
|
// private IMesProductionDispatchContextStepService productionDispatchContextStepService;
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// @Autowired
|
|
|
|
|
// private MesRawPackageDetailRepository mesRawPackageDeatilRepository;
|
|
|
|
|
//
|
|
|
|
|
// @Autowired
|
|
|
|
|
// private MesRawPartChargingRepository mesRawPartChargingRepository;
|
|
|
|
|
//
|
|
|
|
|
// @Override
|
|
|
|
|
// public StepResult execute(StationRequestBean reqBean) {
|
|
|
|
|
//
|
|
|
|
|
// StationResultBean resultBean = new StationResultBean();
|
|
|
|
|
//
|
|
|
|
|
// StepResult stepResult = StepResult.getSuccessComplete();
|
|
|
|
|
//
|
|
|
|
|
// //获取工步参数
|
|
|
|
|
// Optional<Map<String, MesProdRouteOptParam>> stepParamMap = getStepParams(reqBean);
|
|
|
|
|
// //获取上下文信息
|
|
|
|
|
// MesProductionProcessContext productionProcessContext = productionProcessContextStepService.doHandleCurCellEquipment(reqBean, stepParamMap);
|
|
|
|
|
//
|
|
|
|
|
// String equipmentCode = productionProcessContext.getCurCellEquip().getEquipmentCode();
|
|
|
|
|
//
|
|
|
|
|
// // 根据设备id获取加料日志
|
|
|
|
|
//
|
|
|
|
|
// DdlPackBean packBean = DdlPackBean.getDdlPackBean();
|
|
|
|
|
// DdlPreparedPack.getStringEqualPack(equipmentCode, "equipCode", packBean);
|
|
|
|
|
// MesRawPackageDetail mesRawPackageDetail = mesRawPackageDeatilRepository.getByProperty(packBean);
|
|
|
|
|
// if (mesRawPackageDetail == null) {
|
|
|
|
|
// foundExThrow(reqBean, "原材料容器信息未配置");
|
|
|
|
|
// }
|
|
|
|
|
// /**
|
|
|
|
|
// * 查询原材料信息
|
|
|
|
|
// */
|
|
|
|
|
// List<MesRawPartCharging> list = getListByParentDetailId(mesRawPackageDetail.getId());
|
|
|
|
|
// /**
|
|
|
|
|
// * 查询料桶信息 todo
|
|
|
|
|
// */
|
|
|
|
|
// /*MesRawPartCharging mesRawPartCharging = getRawPackByDetailId(mesRawPackageDetail.getId());
|
|
|
|
|
// if (mesRawPackageDetail == null) {
|
|
|
|
|
// foundExThrow(reqBean, "料桶信息不存在");
|
|
|
|
|
// }
|
|
|
|
|
// //
|
|
|
|
|
// list.add(mesRawPartCharging);*/
|
|
|
|
|
// productionDispatchContextStepService.saveMesRawPartChargingDataContext(reqBean, list);
|
|
|
|
|
//
|
|
|
|
|
// return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, "读取料桶原材料成功");
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * 递归查询子料桶,直到查到最终的物料
|
|
|
|
|
// * @param id
|
|
|
|
|
// * @return
|
|
|
|
|
// */
|
|
|
|
|
// private List<MesRawPartCharging> getListByParentDetailId(Long id){
|
|
|
|
|
// if (id == null) {
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
// List<MesRawPartCharging> list = new ArrayList<>();
|
|
|
|
|
//
|
|
|
|
|
// DdlPackBean packBean = DdlPackBean.getDdlPackBean();
|
|
|
|
|
// DdlPreparedPack.getNumEqualPack(id, "parentPackageDetailId", packBean);
|
|
|
|
|
//
|
|
|
|
|
// List<MesRawPartCharging> parentList = mesRawPartChargingRepository.findByHqlWhere(packBean);
|
|
|
|
|
// if (CollectionUtils.isEmpty(parentList)) {
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
// for (MesRawPartCharging mesRawPartCharging : parentList) {
|
|
|
|
|
// List<MesRawPartCharging> chilrenList = getListByParentDetailId(mesRawPartCharging.getPackageDetailId());
|
|
|
|
|
// if (CollectionUtils.isEmpty(chilrenList)) {
|
|
|
|
|
// list.add(mesRawPartCharging);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// return list;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * 递归查询子料桶,直到查到最终的物料
|
|
|
|
|
// * @param id
|
|
|
|
|
// * @return
|
|
|
|
|
// */
|
|
|
|
|
// private MesRawPartCharging getRawPackByDetailId(Long id){
|
|
|
|
|
//
|
|
|
|
|
// DdlPackBean packBean = DdlPackBean.getDdlPackBean();
|
|
|
|
|
// DdlPreparedPack.getNumEqualPack(id, "packageDetailId", packBean);
|
|
|
|
|
//
|
|
|
|
|
// return mesRawPartChargingRepository.getByProperty(packBean);
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|