展示组件

tags/yfai-pcn-ext-v1.0
微笑着面对明天 11 months ago
parent 9207a635de
commit f787dfeaee

@ -0,0 +1,18 @@
package cn.estsh.i3plus.ext.mes.pcn.api.base;
import cn.estsh.i3plus.pojo.mes.bean.MesPojoVersion;
public interface IMesPojoVersionService {
/**
*
* @param bean
* @return
*/
MesPojoVersion getPojoVersion(MesPojoVersion bean);
/**
*
* @param mesPojoVersion
*/
void recordPojoVersion(MesPojoVersion mesPojoVersion);
}

@ -1,6 +1,7 @@
package cn.estsh.i3plus.ext.mes.pcn.api.busi; package cn.estsh.i3plus.ext.mes.pcn.api.busi;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesCellEquipContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesCellEquipContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdShiftContext;
import cn.estsh.i3plus.pojo.mes.model.StationKvBean; import cn.estsh.i3plus.pojo.mes.model.StationKvBean;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean; import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
@ -49,4 +50,30 @@ public interface IMesProductionCustomContextStepService {
@ApiOperation(value = "删除手动选择的腔数及工单信息上下文") @ApiOperation(value = "删除手动选择的腔数及工单信息上下文")
void deleteFunctionChooseCavityOrderContext(StationRequestBean reqBean); void deleteFunctionChooseCavityOrderContext(StationRequestBean reqBean);
@ApiOperation(value = "验证上下文班次班组信息是否存在")
Boolean checkProdShiftDataIsExistContext(String orgainzeCode, String workCenterCode);
@ApiOperation(value = "获取上下文班次班组信息")
List<StationKvBean> getProdShiftDataContext(String orgainzeCode, String workCenterCode);
@ApiOperation(value = "保存上下文班次班组信息", notes = "[JSON]List<StationKvBean>")
Boolean saveProdShiftDataContext(String orgainzeCode, String workCenterCode, List<StationKvBean> prodShiftDatList);
@ApiOperation(value = "删除上下文班次班组信息")
void deleteProdShiftDataContext(String orgainzeCode, String workCenterCode);
@ApiOperation(value = "获取上下文工位加工数统计信息")
List<StationKvBean> getProductionStatisticsContext(StationRequestBean reqBean);
@ApiOperation(value = "保存上下文工位加工数统计信息", notes = "[JSON]List<StationKvBean>")
Boolean saveProductionStatisticsContext(StationRequestBean reqBean, List<StationKvBean> prodShiftDatList);
@ApiOperation(value = "新增上下文工位加工数统计信息")
Boolean addProductionStatisticsContext(StationRequestBean reqBean, int count);
@ApiOperation(value = "删除上下文工位加工数统计信息")
void deleteProductionStatisticsContext(StationRequestBean reqBean);
@ApiOperation(value = "获取生产线的当前班组班次信息")
MesProdShiftContext getMesProdShiftKvBean(String orgainzeCode, String workCenterCode);
} }

@ -180,32 +180,6 @@ public interface IMesProductionDispatchContextStepService {
@ApiOperation(value = "删除上下文产品加工规则信息集合") @ApiOperation(value = "删除上下文产品加工规则信息集合")
void deleteProdRuleDataContext(StationRequestBean reqBean); void deleteProdRuleDataContext(StationRequestBean reqBean);
@ApiOperation(value = "获取生产线的当前班组班次信息")
MesProdShiftContext getMesProdShiftKvBean(String orgainzeCode, String workCenterCode);
@ApiOperation(value = "获取上下文班次班组信息")
List<StationKvBean> getProdShiftDataContext(String orgainzeCode, String workCenterCode);
@ApiOperation(value = "验证上下文班次班组信息是否存在")
Boolean checkProdShiftDataIsExistContext(String orgainzeCode, String workCenterCode);
@ApiOperation(value = "保存上下文班次班组信息", notes = "[JSON]List<StationKvBean>")
Boolean saveProdShiftDataContext(String orgainzeCode, String workCenterCode, List<StationKvBean> prodShiftDatList);
@ApiOperation(value = "删除上下文班次班组信息")
void deleteProdShiftDataContext(String orgainzeCode, String workCenterCode);
@ApiOperation(value = "获取上下文工位加工数统计信息")
List<StationKvBean> getProductionStatisticsContext(StationRequestBean reqBean);
@ApiOperation(value = "保存上下文工位加工数统计信息", notes = "[JSON]List<StationKvBean>")
Boolean saveProductionStatisticsContext(StationRequestBean reqBean, List<StationKvBean> prodShiftDatList);
@ApiOperation(value = "新增上下文工位加工数统计信息")
Boolean addProductionStatisticsContext(StationRequestBean reqBean, int count);
@ApiOperation(value = "删除上下文工位加工数统计信息")
void deleteProductionStatisticsContext(StationRequestBean reqBean);
@ApiOperation(value = "获取料桶原材料数据集合") @ApiOperation(value = "获取料桶原材料数据集合")
List<MesRawPartCharging> getMesRawPartChargingDataContext(StationRequestBean reqBean); List<MesRawPartCharging> getMesRawPartChargingDataContext(StationRequestBean reqBean);

@ -1,6 +1,7 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.controller.busi; package cn.estsh.i3plus.ext.mes.pcn.apiservice.controller.busi;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesProdShiftRecordService; 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.IMesProductionDispatchContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant; import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
import cn.estsh.i3plus.mes.pcn.util.StationKvBeanUtil; import cn.estsh.i3plus.mes.pcn.util.StationKvBeanUtil;
@ -37,7 +38,7 @@ public class MesProdShiftRecordController {
private IMesProdShiftRecordService mesProdShiftRecordService; private IMesProdShiftRecordService mesProdShiftRecordService;
@Autowired @Autowired
private IMesProductionDispatchContextStepService mesProductionDispatchContextStepService; private IMesProductionCustomContextStepService productionCustomContextStepService;
@GetMapping("/query-pager") @GetMapping("/query-pager")
@ApiOperation(value = "查询开关班记录") @ApiOperation(value = "查询开关班记录")
public ResultBean queryMesProdShiftRecordByPager(MesProdShiftRecord mesProdShiftRecord, Pager pager) { public ResultBean queryMesProdShiftRecordByPager(MesProdShiftRecord mesProdShiftRecord, Pager pager) {
@ -68,7 +69,7 @@ public class MesProdShiftRecordController {
List<StationKvBean> getProdShiftData = getProdShiftData(item); List<StationKvBean> getProdShiftData = getProdShiftData(item);
mesProductionDispatchContextStepService.saveProdShiftDataContext(item.getOrganizeCode(), item.getWorkCenterCode(), getProdShiftData); productionCustomContextStepService.saveProdShiftDataContext(item.getOrganizeCode(), item.getWorkCenterCode(), getProdShiftData);
return ResultBean.success("保存开关班记录成功"); return ResultBean.success("保存开关班记录成功");
} catch (ImppBusiException imppException) { } catch (ImppBusiException imppException) {
@ -91,7 +92,7 @@ public class MesProdShiftRecordController {
mesProdShiftRecordService.saveMesProdShiftRecord(item, AuthUtil.getOrganizeCode()); mesProdShiftRecordService.saveMesProdShiftRecord(item, AuthUtil.getOrganizeCode());
if (Objects.equal(MesExtEnumUtil.WORK_STATUS.END.getValue(), item.getWorkStatus())) { if (Objects.equal(MesExtEnumUtil.WORK_STATUS.END.getValue(), item.getWorkStatus())) {
mesProductionDispatchContextStepService.deleteProdShiftDataContext(item.getOrganizeCode(), item.getWorkCenterCode()); productionCustomContextStepService.deleteProdShiftDataContext(item.getOrganizeCode(), item.getWorkCenterCode());
} }
return ResultBean.success("保存开关班记录成功"); return ResultBean.success("保存开关班记录成功");

@ -0,0 +1,209 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.base;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesPojoVersionService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.MesConfigService;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.platform.common.tool.JsonUtilTool;
import cn.estsh.i3plus.platform.common.util.CommonConstWords;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesPojoVersion;
import cn.estsh.i3plus.pojo.mes.bean.MesPojoVersionDetail;
import cn.estsh.i3plus.pojo.mes.repository.MesPojoVersionDetailRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesPojoVersionRepository;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.MapDifference;
import com.google.common.collect.Maps;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class MesPojoVersionServiceImpl implements IMesPojoVersionService {
private static final Logger LOGGER = LoggerFactory.getLogger(MesPojoVersionServiceImpl.class);
@Autowired
private MesPojoVersionRepository mesPojoVersionRepository;
@Autowired
private MesPojoVersionDetailRepository mesPojoVersionDetailRepository;
@Resource
private SnowflakeIdMaker snowflakeIdMaker;
@Autowired
private MesConfigService mesConfigService;
@Override
public MesPojoVersion getPojoVersion(MesPojoVersion bean) {
return mesPojoVersionRepository.getByProperty(DdlPackBean.getDdlPackBean(bean));
}
@Override
public void recordPojoVersion(MesPojoVersion afterMesPojoVersion) {
MesPojoVersion beforePojoVersion = new MesPojoVersion();
MesPojoVersionDetail beforePojoVersionDetail = new MesPojoVersionDetail();
Map<String, Object> beforeMap = new HashMap<>();
Map<String, Object> afterMap = JsonUtilTool.decode(afterMesPojoVersion.getBean(), Map.class);
MesPojoVersionDetail afterPojoVersionDetail = null;
String config = mesConfigService.getCfgValue(afterMesPojoVersion.getOrganizeCode(), "MARK_FILED");
JSONObject reqJson = new JSONObject();
if (!StringUtils.isEmpty(config)) {
reqJson = JSONObject.parseObject(config);
}
Integer versionNo; // 对象版本
CommonEnumUtil.DAO_OPERATE_TYPE operateType = CommonEnumUtil.DAO_OPERATE_TYPE.INSERT; // 操作类型
Map<String, MapDifference.ValueDifference<Object>> mapDiff; // 版本对比
String userName = StringUtils.isNotBlank(afterMesPojoVersion.getModifyUser()) ? afterMesPojoVersion.getModifyUser() : afterMesPojoVersion.getCreateUser();
Map<String, String> mapPropDesc = afterMesPojoVersion.getPojoPropDesc();
if (!"insert".equals(afterMesPojoVersion.getVersionMethodName())) { // 不是新增数据的时候则需要查询历史记录
// 已存在数据封装
afterMesPojoVersion.setOrderByParam("createDatetime");
afterMesPojoVersion.setAscOrDesc(CommonEnumUtil.ASC_OR_DESC.DESC.getValue());
beforePojoVersion = this.getPojoVersion(afterMesPojoVersion);
if (Objects.nonNull(beforePojoVersion)) {
beforePojoVersionDetail = mesPojoVersionDetailRepository.getById(beforePojoVersion.getPojoDetailId());
if (Objects.nonNull(beforePojoVersionDetail)) {
beforeMap.putAll(JsonUtilTool.decode(beforePojoVersionDetail.getPojoAfter(), Map.class));
}
}
operateType = CommonEnumUtil.DAO_OPERATE_TYPE.UPDATE;
}
// 不保存字段 数据剔除
for (String key : CommonConstWords.POJO_VERSION_SAVE_ATTR_REMOVE) {
afterMap.remove(key);
}
mapDiff = Maps.difference(beforeMap, afterMap).entriesDiffering();
/* mapDiff = Maps.difference(beforeMap, afterMap).entriesOnlyOnLeft();
if (beforeMap.size() == 0 && afterMap.size() > 0) {
mapDiff.putAll(afterMap);
}*/
// 是否需要落库
if (reqJson.getString(afterMesPojoVersion.getRefClass()) != null) {
List<String> fileds = Arrays.asList(reqJson.getString(afterMesPojoVersion.getRefClass()).split(","));
mapDiff = mapDiff.entrySet().stream().filter(e -> fileds.contains(e.getKey())).collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue()));
} else {
mapDiff = null;
LOGGER.info("没有变化的字段,不需要进行持久化");
return;
}
String pojoCompare = mapDiff == null ? null : mapDiff.toString();
versionNo = Objects.nonNull(beforePojoVersion) ? beforePojoVersion.getVersionNo() : 0;
afterMesPojoVersion.setVersionNo(++versionNo);
afterMesPojoVersion.setId(snowflakeIdMaker.nextId());
afterPojoVersionDetail = new MesPojoVersionDetail();
afterPojoVersionDetail.setId(snowflakeIdMaker.nextId());
afterPojoVersionDetail.setPojoVersionId(afterMesPojoVersion.getId());
afterPojoVersionDetail.setPojoBefore(JSON.toJSONString(beforeMap));
afterPojoVersionDetail.setPojoAfter(JSON.toJSONString(afterMap));
afterPojoVersionDetail.setPojoCompare(pojoCompare);
afterPojoVersionDetail.setPojoBeforeTxt(getMapToStr(beforeMap, mapPropDesc));
afterPojoVersionDetail.setPojoAfterTxt(getMapToStr(afterMap, mapPropDesc));
afterPojoVersionDetail.setPojoCompareTxt(getMapDiffToStr(mapDiff, mapPropDesc));
String name = afterMesPojoVersion.getCreateUser();
String organizeCode = afterMesPojoVersion.getOrganizeCode();
afterPojoVersionDetail.setOrganizeCode(organizeCode);
ConvertBean.serviceModelInitialize(afterPojoVersionDetail, name);
mesPojoVersionDetailRepository.insert(afterPojoVersionDetail);
afterMesPojoVersion.setOperateType(operateType.getValue());
afterMesPojoVersion.setVersionNo(versionNo);
afterMesPojoVersion.setPojoCompare(pojoCompare);
afterMesPojoVersion.setPojoCompareTxt(getMapDiffToStr(mapDiff, mapPropDesc));
afterMesPojoVersion.setPojoDetailId(afterPojoVersionDetail.getId());
ConvertBean.serviceModelInitialize(afterMesPojoVersion, name);
mesPojoVersionRepository.insert(afterMesPojoVersion);
LOGGER.info("PojoVersionQueueReceiver:保存的pojoVersion:{}",afterMesPojoVersion);
}
/**
* Map
*
* @param mapData
* @param mapPropDesc
* @return
*/
private String getMapToStr(Map<String, Object> mapData, Map<String, String> mapPropDesc) {
if (mapData == null) {
mapData = new HashMap<>();
}
if (mapPropDesc == null) {
mapData = new HashMap<>();
}
StringBuilder stringBuffer = new StringBuilder();
String key;
for (Map.Entry<String, Object> entry : mapData.entrySet()) {
key = mapPropDesc.get(entry.getKey());
if (key == null) {
key = entry.getKey();
}
stringBuffer.append(key).append(":").append(entry.getValue()).append(",");
}
return stringBuffer.toString();
}
/**
* MapDifference
*
* @param mapData
* @param mapPropDesc
* @return
*/
private String getMapDiffToStr(Map<String, MapDifference.ValueDifference<Object>> mapData, Map<String, String> mapPropDesc) {
if (mapData == null) {
mapData = new HashMap<>();
}
if (mapPropDesc == null) {
mapData = new HashMap<>();
}
StringBuilder stringBuffer = new StringBuilder();
String key;
MapDifference.ValueDifference<Object> valDiff;
for (Map.Entry<String, MapDifference.ValueDifference<Object>> entry : mapData.entrySet()) {
valDiff = entry.getValue();
if (valDiff == null) {
continue;
}
key = mapPropDesc.get(entry.getKey());
if (key == null) {
key = entry.getKey();
}
stringBuffer.append("修改值 ").append(key)
.append(",旧值为 ").append(valDiff.leftValue())
.append(",新值为 ").append(valDiff.rightValue())
.append("。");
}
return stringBuffer.toString();
}
}

@ -1,5 +1,6 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.station; package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.station;
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.IMesProductionDispatchContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdShiftContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdShiftContext;
@ -50,7 +51,10 @@ public class MesProductionNoSortModuleService extends BaseModuleService {
private IMesProductionProcessContextStepService productionProcessContextStepService; private IMesProductionProcessContextStepService productionProcessContextStepService;
@Autowired @Autowired
private IMesProductionDispatchContextStepService mesProductionDispatchContextStepService; private IMesProductionDispatchContextStepService productionDispatchContextStepService;
@Autowired
private IMesProductionCustomContextStepService productionCustomContextStepService;
@Autowired @Autowired
private MesFileRepository mesFileRepository; private MesFileRepository mesFileRepository;
@ -58,15 +62,15 @@ public class MesProductionNoSortModuleService extends BaseModuleService {
@Override @Override
public void init(StationRequestBean reqBean) { public void init(StationRequestBean reqBean) {
// 获取工单信息 // 获取工单信息
List<List<StationKvBean>> moduleContentContext = mesProductionDispatchContextStepService.getModuleContentContext(reqBean); List<List<StationKvBean>> moduleContentContext = productionDispatchContextStepService.getModuleContentContext(reqBean);
//获取上下文信息 //获取上下文信息
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getEquipmentVariableList(reqBean, MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PRODUCTION.getValue()); MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getEquipmentVariableList(reqBean, MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PRODUCTION.getValue());
MesWorkCell mesWorkCell = productionProcessContext.getWorkCell(); MesWorkCell mesWorkCell = productionProcessContext.getWorkCell();
// 获取班次信息 // 获取班次信息
List<StationKvBean> prodShiftDataContext = mesProductionDispatchContextStepService.getProdShiftDataContext(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode()); List<StationKvBean> prodShiftDataContext = productionCustomContextStepService.getProdShiftDataContext(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
MesProdShiftContext mesProdShiftKvBean = mesProductionDispatchContextStepService.getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode()); MesProdShiftContext mesProdShiftKvBean = productionCustomContextStepService.getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
if (CollectionUtils.isEmpty(prodShiftDataContext)) { if (CollectionUtils.isEmpty(prodShiftDataContext)) {
this.sendMessage(reqBean, new StationResultBean().writeDbLog(), "请先开班", MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT); this.sendMessage(reqBean, new StationResultBean().writeDbLog(), "请先开班", MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);
@ -77,9 +81,9 @@ public class MesProductionNoSortModuleService extends BaseModuleService {
this.sendMessage(reqBean, resultBean); this.sendMessage(reqBean, resultBean);
// 整合班次加工数量 // 整合班次加工数量
List<StationKvBean> productionStatisticsContext = mesProductionDispatchContextStepService.getProductionStatisticsContext(reqBean); List<StationKvBean> productionStatisticsContext = productionCustomContextStepService.getProductionStatisticsContext(reqBean);
if (CollectionUtils.isEmpty(productionStatisticsContext)) { if (CollectionUtils.isEmpty(productionStatisticsContext)) {
productionStatisticsContext = StationKvBeanUtil.addStationKvBeanList(new ArrayList<>(), new StationKvBean(new StringJoiner(MesPcnExtConstWords.AND).add(mesProdShiftKvBean.getShiftGroup()).add(mesProdShiftKvBean.getShiftCode()).toString(), "加次数", "0"), 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())); new StationKvBean("color", "颜色", MesExtEnumUtil.COLOR.BLACK.getValue()));
} }
StationResultBean shiftCountBean = getStationResultBean(reqBean, productionStatisticsContext,mesWorkCell); StationResultBean shiftCountBean = getStationResultBean(reqBean, productionStatisticsContext,mesWorkCell);

@ -1,5 +1,6 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.station.function; package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.station.function;
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.IMesProductionDispatchContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdShiftContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdShiftContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
@ -31,17 +32,17 @@ public class MesFunctionProductionStatisticsService extends BaseSwsService imple
private IShippingDispatchService shippingDispatchService; private IShippingDispatchService shippingDispatchService;
@Autowired @Autowired
private IMesProductionDispatchContextStepService mesProductionDispatchContextStepService; private IMesProductionCustomContextStepService productionCustomContextStepService;
@Override @Override
public boolean doFunction(StationRequestBean reqBean, StationResultBean resultBean, ButtonDynamicModel buttonDynamicModel) { public boolean doFunction(StationRequestBean reqBean, StationResultBean resultBean, ButtonDynamicModel buttonDynamicModel) {
// 获取班次信息 // 获取班次信息
List<StationKvBean> productionStatisticsContext = mesProductionDispatchContextStepService.getProductionStatisticsContext(reqBean); List<StationKvBean> productionStatisticsContext = productionCustomContextStepService.getProductionStatisticsContext(reqBean);
if (!CollectionUtils.isEmpty(productionStatisticsContext)) { if (!CollectionUtils.isEmpty(productionStatisticsContext)) {
mesProductionDispatchContextStepService.deleteProductionStatisticsContext(reqBean); productionCustomContextStepService.deleteProductionStatisticsContext(reqBean);
} }
this.sendMessage(reqBean, resultBean.writeDbLog(), String.format("生产线[%s]工位[%s]%s,加次数已清零!", this.sendMessage(reqBean, resultBean.writeDbLog(), String.format("生产线[%s]工位[%s]%s,加次数已清零!",
reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), buttonDynamicModel.getButtonName()), MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT); reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), buttonDynamicModel.getButtonName()), MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);
return true; return true;

@ -5,10 +5,7 @@ import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesEquipVariableCfgRuleMatchDispatc
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesEquipmentLogExtService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesEquipmentLogExtService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService; 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.IMesProductionProcessContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesCellEquipContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.*;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesEquipVariableCfgCollectContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesEquipVariableCollectContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService; import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.platform.common.convert.ConvertBean; import cn.estsh.i3plus.platform.common.convert.ConvertBean;
@ -62,8 +59,10 @@ public class MesMouldRecordGenerateStepService extends BaseStepService {
//获取上下文信息 //获取上下文信息
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getEquipmentVariableList(reqBean, MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PRODUCTION.getValue()); MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getEquipmentVariableList(reqBean, MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PRODUCTION.getValue());
//List<MesProductionPartContext> productionPartContextList = mesProductionDispatchContextStepService.getProductionPartContext(reqBean);
// 获取条码信息 // 获取条码信息
List<MesProduceSn> mesProduceSns = mesProductionDispatchContextStepService.getOutProduceSnDataContext(reqBean); List<MesProductionPsOutContext> mesProduceSnContexts = mesProductionDispatchContextStepService.getProductionPsOutContext(reqBean);
// 获取头道模具号 // 获取头道模具号
MesEquipVariableCollectContext mesFirstMouldNoCollectContext = mesProductionDispatchContextStepService.getFirstMouldNoContext(reqBean); MesEquipVariableCollectContext mesFirstMouldNoCollectContext = mesProductionDispatchContextStepService.getFirstMouldNoContext(reqBean);
// 获取模具号 // 获取模具号
@ -71,12 +70,12 @@ public class MesMouldRecordGenerateStepService extends BaseStepService {
/** /**
* *
*/ */
saveMouldRecord(reqBean, resultBean, productionProcessContext, mesProduceSns, mesFirstMouldNoCollectContext, mesMouldNoCollectContext); saveMouldRecord(reqBean, resultBean, productionProcessContext, mesProduceSnContexts, mesFirstMouldNoCollectContext, mesMouldNoCollectContext);
return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "生成开模记录成功"); return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "生成开模记录成功");
} }
private void saveMouldRecord(StationRequestBean reqBean, StationResultBean resultBean, MesProductionProcessContext productionProcessContext, List<MesProduceSn> mesProduceSns, MesEquipVariableCollectContext mesFirstMouldNoCollectContext, MesEquipVariableCollectContext mesMouldNoCollectContext) { private void saveMouldRecord(StationRequestBean reqBean, StationResultBean resultBean, MesProductionProcessContext productionProcessContext, List<MesProductionPsOutContext> mesProduceSns, MesEquipVariableCollectContext mesFirstMouldNoCollectContext, MesEquipVariableCollectContext mesMouldNoCollectContext) {
List<MesProdMouldRecord> mesProdMouldRecords = new ArrayList<>(); List<MesProdMouldRecord> mesProdMouldRecords = new ArrayList<>();
for (MesProduceSn mesProduceSn : mesProduceSns) { for (MesProduceSn mesProduceSn : mesProduceSns) {
@ -96,7 +95,7 @@ public class MesMouldRecordGenerateStepService extends BaseStepService {
DdlPreparedPack.getStringEqualPack(equipmentCode, "equipmentCode", packBean); DdlPreparedPack.getStringEqualPack(equipmentCode, "equipmentCode", packBean);
DdlPreparedPack.getStringEqualPack(mouldNo, "mouldNo", packBean); DdlPreparedPack.getStringEqualPack(mouldNo, "mouldNo", packBean);
MesMouldMappingCfg mesMouldMappingCfg = mesMouldMappingCfgRepository.getByProperty(packBean); MesMouldMappingCfg mesMouldMappingCfg = mesMouldMappingCfgRepository.getByProperty(packBean);
//配置错误 抛出异常 //配置错误 抛出异常 todo 没找到不能报错,就不填这个字段
if (mesMouldMappingCfg == null) execExpSendMsgAndThrowEx(reqBean, resultBean, if (mesMouldMappingCfg == null) execExpSendMsgAndThrowEx(reqBean, resultBean,
String.format("请检查模具映射关系维护,根据设备[%s],模具号[%s]", equipmentCode, mouldNo)); String.format("请检查模具映射关系维护,根据设备[%s],模具号[%s]", equipmentCode, mouldNo));

@ -42,7 +42,7 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
/** /**
* @Description : * @Description :
* @Author : zxw * @Author : zxw
**/ **/
@Slf4j @Slf4j
@ -128,7 +128,7 @@ public class MesProductResultErrorHandleStepService extends BaseStepService {
MesPartInspectionDetail mesPartInspectionDetail = new MesPartInspectionDetail(); MesPartInspectionDetail mesPartInspectionDetail = new MesPartInspectionDetail();
mesPartInspectionDetail.setPid(id); mesPartInspectionDetail.setPid(id);
mesPartInspectionDetail.setStatus(10); mesPartInspectionDetail.setStatus(MesExtEnumUtil.PART_INSPECTION_NC_STATUS.CREATE.getValue());
mesPartInspectionDetail.setDefectTypeCode(mesDefectType.getDefectTypeCode()); mesPartInspectionDetail.setDefectTypeCode(mesDefectType.getDefectTypeCode());
mesPartInspectionDetail.setDefectTypeName(mesDefectType.getDefectTypeName()); mesPartInspectionDetail.setDefectTypeName(mesDefectType.getDefectTypeName());
model.setPartInspection(partInspection); model.setPartInspection(partInspection);

@ -1,5 +1,6 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step; package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesPojoVersionService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService; 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.IMesProductionProcessContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException; import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
@ -9,10 +10,12 @@ import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsOutContext;
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService; import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService; import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.platform.common.convert.ConvertBean; import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.platform.common.tool.JsonUtilTool;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker; import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.MesPart; import cn.estsh.i3plus.pojo.mes.bean.MesPart;
import cn.estsh.i3plus.pojo.mes.bean.MesPojoVersion;
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn; import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCell; import cn.estsh.i3plus.pojo.mes.bean.MesWorkCell;
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel; import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
@ -62,6 +65,9 @@ public class MesProductSnGenerateStepService extends BaseStepService {
@Autowired @Autowired
private IMesProductionDispatchContextStepService mesProductionDispatchContextStepService; private IMesProductionDispatchContextStepService mesProductionDispatchContextStepService;
@Autowired
private IMesPojoVersionService mesPojoVersionService;
/**todo /**todo
* todo * todo
* @param reqBean * @param reqBean
@ -85,14 +91,38 @@ public class MesProductSnGenerateStepService extends BaseStepService {
// 获取零件号,可能存在多个 // 获取零件号,可能存在多个
List<String> partNoList = productionPartContextList.stream().map(MesProductionPartContext::getPartNo).collect(Collectors.toList()); List<String> partNoList = productionPartContextList.stream().map(MesProductionPartContext::getPartNo).collect(Collectors.toList());
// 根据零件号组装产品条码信息 // 根据零件号组装产品条码信息
List<MesProductionPsOutContext> mesProduceSns = generateSn(reqBean, productionProcessContext, mesWorkCell, partNoList, result); List<MesProduceSn> mesProduceSns = generateSn(reqBean, productionProcessContext, mesWorkCell, partNoList, result);
// 保存条码信息
mesProduceSnRepository.saveAll(mesProduceSns);
savePojoVersion(mesProduceSns);
List<MesProductionPsOutContext> mesProductionPsOutContexts = new ArrayList<>();
for (MesProduceSn mesProduceSn : mesProduceSns) {
MesProductionPsOutContext mesProductionPsOutContext = new MesProductionPsOutContext();
BeanUtils.copyProperties(mesProduceSn, mesProductionPsOutContext);
mesProductionPsOutContexts.add(mesProductionPsOutContext);
}
// 放到上下文 // 放到上下文
mesProductionDispatchContextStepService.saveProductionPsOutContext(reqBean, mesProduceSns); mesProductionDispatchContextStepService.saveProductionPsOutContext(reqBean, mesProductionPsOutContexts);
return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "生成零件条码成功"); return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "生成零件条码成功");
} }
private void savePojoVersion(List<MesProduceSn> mesProduceSns) {
mesProduceSns.forEach(mesProduceSn -> {
MesPojoVersion version = new MesPojoVersion();
version.setRefId(mesProduceSn.getId());
version.setRefClass(mesProduceSn.getClass().getName());
version.setBean(JsonUtilTool.encode(mesProduceSn));
version.setCreateUser(version.getCreateUser());
version.setModifyUser(version.getModifyUser());
version.setVersionMethodName("insert");
version.setOrganizeCode(mesProduceSn.getOrganizeCode());
mesPojoVersionService.recordPojoVersion(version);
});
}
/** /**
* *
* @param reqBean * @param reqBean
@ -101,8 +131,8 @@ public class MesProductSnGenerateStepService extends BaseStepService {
* @param partNoList * @param partNoList
* @return * @return
*/ */
private List<MesProductionPsOutContext> generateSn(StationRequestBean reqBean, MesProductionProcessContext productionProcessContext, MesWorkCell mesWorkCell, List<String> partNoList, String result) { private List<MesProduceSn> generateSn(StationRequestBean reqBean, MesProductionProcessContext productionProcessContext, MesWorkCell mesWorkCell, List<String> partNoList, String result) {
List<MesProductionPsOutContext> mesProduceSns = new ArrayList<>(); List<MesProduceSn> mesProduceSns = new ArrayList<>();
for (String partNo : partNoList) { for (String partNo : partNoList) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(reqBean.getOrganizeCode()); DdlPackBean packBean = DdlPackBean.getDdlPackBean(reqBean.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(partNo, "partNo", packBean); DdlPreparedPack.getStringEqualPack(partNo, "partNo", packBean);
@ -113,7 +143,7 @@ public class MesProductSnGenerateStepService extends BaseStepService {
// 根据条码规则生成条码 // 根据条码规则生成条码
String sn = generateByRule(mesPart); String sn = generateByRule(mesPart);
// 组装条码信息 // 组装条码信息
MesProductionPsOutContext mesProduceSn = generateMesProduceSn(mesPart, sn, mesWorkCell, productionProcessContext, reqBean, result); MesProduceSn mesProduceSn = generateMesProduceSn(mesPart, sn, mesWorkCell, productionProcessContext, reqBean, result);
ConvertBean.serviceModelInitialize(mesProduceSn, reqBean.getUserInfo()); ConvertBean.serviceModelInitialize(mesProduceSn, reqBean.getUserInfo());
mesProduceSns.add(mesProduceSn); mesProduceSns.add(mesProduceSn);
} }
@ -133,10 +163,10 @@ public class MesProductSnGenerateStepService extends BaseStepService {
return resultList.get(0); return resultList.get(0);
} }
private MesProductionPsOutContext generateMesProduceSn(MesPart mesPart, String sn, MesWorkCell mesWorkCell,MesProductionProcessContext productionProcessContext, StationRequestBean reqBean, String result) { private MesProduceSn generateMesProduceSn(MesPart mesPart, String sn, MesWorkCell mesWorkCell,MesProductionProcessContext productionProcessContext, StationRequestBean reqBean, String result) {
long serialNum = snowflakeIdMaker.nextId(); long serialNum = snowflakeIdMaker.nextId();
MesProductionPsOutContext mesProduceSn = new MesProductionPsOutContext(); MesProduceSn mesProduceSn = new MesProduceSn();
mesProduceSn.setSerialNumber(serialNum + ""); mesProduceSn.setSerialNumber(serialNum + "");
mesProduceSn.setProductSn(sn); mesProduceSn.setProductSn(sn);
mesProduceSn.setCustSn(sn); mesProduceSn.setCustSn(sn);
@ -149,7 +179,7 @@ public class MesProductSnGenerateStepService extends BaseStepService {
mesProduceSn.setCustLabelTemplate(mesPart.getCustLabelTemplate()); mesProduceSn.setCustLabelTemplate(mesPart.getCustLabelTemplate());
mesProduceSn.setProcessLabelTemplate(mesPart.getProcessLabelTemplate()); mesProduceSn.setProcessLabelTemplate(mesPart.getProcessLabelTemplate());
mesProduceSn.setQty(1d); mesProduceSn.setQty(1d);
mesProduceSn.setSnStatus(MesExtEnumUtil.PRODUCE_SN_STATUS.CREATE.getValue()); mesProduceSn.setSnStatus(10);
Integer qcStatus = MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue(); Integer qcStatus = MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue();
if (Objects.equal(MesExtEnumUtil.EQUIP_VARIABLE_CFG_CATEGORY.PRODUCT_SCRAP.getValue(), result)) { if (Objects.equal(MesExtEnumUtil.EQUIP_VARIABLE_CFG_CATEGORY.PRODUCT_SCRAP.getValue(), result)) {
qcStatus = MesExtEnumUtil.PRODUCE_QC_STATUS.SCRAP.getValue(); qcStatus = MesExtEnumUtil.PRODUCE_QC_STATUS.SCRAP.getValue();

@ -52,6 +52,7 @@ public class MesProductSnSaveStepService extends BaseStepService {
} }
mesProduceSnContexts.forEach(mesProduceSnContext -> { mesProduceSnContexts.forEach(mesProduceSnContext -> {
MesProduceSn mesProduceSn = new MesProduceSn(); MesProduceSn mesProduceSn = new MesProduceSn();
//todo 要根据不同的加工结果,返回不同的结果 要分排序和非排序, 排序只保存工单对应的装配件、非排序要保存主条码和装配件记录。
mesProduceSn.setSnStatus(MesExtEnumUtil.PRODUCE_SN_STATUS.OFFLINE.getValue()); mesProduceSn.setSnStatus(MesExtEnumUtil.PRODUCE_SN_STATUS.OFFLINE.getValue());
mesProduceSns.add(mesProduceSn); mesProduceSns.add(mesProduceSn);
}); });

@ -1,5 +1,6 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step; 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.IMesProductionDispatchContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService; 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.context.*;
@ -53,6 +54,9 @@ public class MesProductionReocrdGenerateStepService extends BaseStepService {
@Autowired @Autowired
private IMesProductionDispatchContextStepService mesProductionDispatchContextStepService; private IMesProductionDispatchContextStepService mesProductionDispatchContextStepService;
@Autowired
private IMesProductionCustomContextStepService productionCustomContextStepService;
public static final String ORDER_NO_JIS_SORT = "ORDER_NO_JIS_SORT"; public static final String ORDER_NO_JIS_SORT = "ORDER_NO_JIS_SORT";
@ -81,7 +85,7 @@ public class MesProductionReocrdGenerateStepService extends BaseStepService {
mesProductionRecordRepository.saveAll(mesProductionRecords); mesProductionRecordRepository.saveAll(mesProductionRecords);
if (Objects.equal(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue(),mesWorkCell.getIsCountFinish())) { if (Objects.equal(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue(),mesWorkCell.getIsCountFinish())) {
// 保存班次加工数量上下文 // 保存班次加工数量上下文
mesProductionDispatchContextStepService.addProductionStatisticsContext(reqBean,mesProduceSnContexts.size()); productionCustomContextStepService.addProductionStatisticsContext(reqBean,mesProduceSnContexts.size());
} }
return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "生成加工记录成功"); return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "生成加工记录成功");

@ -2,6 +2,7 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step.context;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionCustomContextStepService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionCustomContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesCellEquipContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesCellEquipContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdShiftContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService; import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.mes.pcn.util.StationKvBeanUtil; import cn.estsh.i3plus.mes.pcn.util.StationKvBeanUtil;
@ -11,6 +12,7 @@ import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.model.StationResultBean; import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Objects;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@ -39,6 +41,7 @@ public class MesProductionCustomContextStepService extends BaseStepService imple
//工位加工锁KEY //工位加工锁KEY
private String getProductionLockContextKey(StationRequestBean reqBean) { return getFsmBusikey(reqBean, new StringJoiner(MesPcnExtConstWords.COLON).add(MesPcnExtConstWords.PRODUCTION_PROCESS_CONTEXT).add(MesPcnExtConstWords.PRODUCTION_LOCK_CONTEXT).toString()); } private String getProductionLockContextKey(StationRequestBean reqBean) { return getFsmBusikey(reqBean, new StringJoiner(MesPcnExtConstWords.COLON).add(MesPcnExtConstWords.PRODUCTION_PROCESS_CONTEXT).add(MesPcnExtConstWords.PRODUCTION_LOCK_CONTEXT).toString()); }
//验证上下文工位加工锁是否存在 //验证上下文工位加工锁是否存在
@Override @Override
public Boolean checkProductionLockIsExistContext(StationRequestBean reqBean) { public Boolean checkProductionLockIsExistContext(StationRequestBean reqBean) {
@ -130,14 +133,97 @@ public class MesProductionCustomContextStepService extends BaseStepService imple
} }
//开班信息KEY 【PS:生产线级别】 //开班信息KEY 【PS:生产线级别】
private String getProdShiftContextKey(StationRequestBean reqBean) { return new StringJoiner(MesPcnExtConstWords.COLON).add(reqBean.getOrganizeCode()).add(MesPcnExtConstWords.PRODUCTION_PROCESS_CONTEXT).add(MesPcnExtConstWords.PROD_SHIFT_DATA_CONTEXT).add(reqBean.getWorkCenterCode()).toString(); } private String getProdShiftContextKey(String orgainzeCode, String workCenterCode) { return new StringJoiner(MesPcnExtConstWords.COLON).add(orgainzeCode).add(MesPcnExtConstWords.PRODUCTION_PROCESS_CONTEXT).add(MesPcnExtConstWords.PROD_SHIFT_DATA_CONTEXT).add(workCenterCode).toString(); }
//获取生产线的当前班组班次信息
@Override
public MesProdShiftContext getMesProdShiftKvBean(String orgainzeCode, String workCenterCode) {
List<StationKvBean> stationKvBeans = getProdShiftDataContext(orgainzeCode, workCenterCode);
MesProdShiftContext mesProdShiftContext = new MesProdShiftContext();
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);
mesProdShiftContext.setShiftCode(shiftGroupKvBean == null ? null : shiftGroupKvBean.getValue());
mesProdShiftContext.setShiftGroup(shiftCodeKvBean == null ? null : shiftCodeKvBean.getValue());
return mesProdShiftContext;
}
//获取上下文班次班组信息
@Override
public List<StationKvBean> getProdShiftDataContext(String orgainzeCode, String workCenterCode) {
String prodShiftJson = getFsmBusiData(orgainzeCode, getProdShiftContextKey(orgainzeCode, workCenterCode), workCenterCode);
return !StringUtils.isEmpty(prodShiftJson) ? JSONObject.parseArray(prodShiftJson, StationKvBean.class) : null;
}
//验证上下文班次班组信息是否存在
@Override
public Boolean checkProdShiftDataIsExistContext(String orgainzeCode, String workCenterCode) {
String prodShiftJson = getFsmBusiData(orgainzeCode, getProdShiftContextKey(orgainzeCode, MesPcnExtConstWords.PROD_SHIFT_DATA_CONTEXT), workCenterCode);
return !StringUtils.isEmpty(prodShiftJson) ? true : false;
}
//保存上下文班次班组信息 [JSON]List<StationKvBean>
@Override
public Boolean saveProdShiftDataContext(String organizeCode, String workCenterCode, List<StationKvBean> prodShiftDataList) {
if (CollectionUtils.isEmpty(prodShiftDataList)) return false;
return saveFsmBusiData(organizeCode, getProdShiftContextKey(organizeCode, MesPcnExtConstWords.PROD_SHIFT_DATA_CONTEXT), workCenterCode, JSONObject.toJSONString(prodShiftDataList));
}
//删除上下文班次班组信息
@Override
public void deleteProdShiftDataContext(String orgainzeCode, String workCenterCode) {
deleteFsmBusiData(orgainzeCode, getProdShiftContextKey(orgainzeCode, MesPcnExtConstWords.PROD_SHIFT_DATA_CONTEXT), workCenterCode);
}
//获取上下文工位加工数统计信息
@Override
public List<StationKvBean> getProductionStatisticsContext(StationRequestBean reqBean) {
String productionStatisticsJson = getFsmBusiData(reqBean.getOrganizeCode(), getProductionLockContextKey(reqBean), MesPcnExtConstWords.PRODUCTION_STATISTICS_CONTEXT);
return !StringUtils.isEmpty(productionStatisticsJson) ? JSONObject.parseArray(productionStatisticsJson, StationKvBean.class) : null;
}
//保存上下文工位加工数统计信息 [JSON]List<StationKvBean>
@Override
public Boolean saveProductionStatisticsContext(StationRequestBean reqBean, List<StationKvBean> productionStatisticsList) {
if (CollectionUtils.isEmpty(productionStatisticsList)) return false;
return saveFsmBusiData(reqBean.getOrganizeCode(), getProductionLockContextKey(reqBean), MesPcnExtConstWords.PRODUCTION_STATISTICS_CONTEXT, JSONObject.toJSONString(productionStatisticsList));
}
@Override
public Boolean addProductionStatisticsContext(StationRequestBean reqBean, int count) {
MesProdShiftContext mesProdShiftKvBean = getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
String key = new StringJoiner(MesPcnExtConstWords.AND).add(mesProdShiftKvBean.getShiftGroup()).add(mesProdShiftKvBean.getShiftCode()).toString();
List<StationKvBean> stationKvBeans = getProductionStatisticsContext(reqBean);
if (CollectionUtils.isEmpty(stationKvBeans)) {
String name = "加次数";
String value = count + "";
List<StationKvBean> generateStationKvBeans = StationKvBeanUtil.addStationKvBeanList(new ArrayList<>(), new StationKvBean(key, name, value),
new StationKvBean("color", "颜色", MesExtEnumUtil.COLOR.BLACK.getValue()));
saveProductionStatisticsContext(reqBean, generateStationKvBeans);
} else {
stationKvBeans.stream().forEach(stationKvBean -> {
if (Objects.equal(stationKvBean.getKey(), key)) {
stationKvBean.setValue(stationKvBean == null ? count + "" : (Integer.valueOf(stationKvBean.getValue()) + count) + "");
}
});
saveProductionStatisticsContext(reqBean, stationKvBeans);
}
return true;
}
//删除上下文工位加工数统计信息
@Override
public void deleteProductionStatisticsContext(StationRequestBean reqBean) {
deleteFsmBusiData(reqBean.getOrganizeCode(), getProductionLockContextKey(reqBean), MesPcnExtConstWords.PRODUCTION_STATISTICS_CONTEXT);
}
} }

@ -398,95 +398,6 @@ public class MesProductionDispatchContextStepService extends BaseStepService imp
public void deleteProdRuleDataContext(StationRequestBean reqBean) { public void deleteProdRuleDataContext(StationRequestBean reqBean) {
deleteFsmBusiData(reqBean.getOrganizeCode(), getContextKey(reqBean), MesPcnExtConstWords.PROD_RULE_DATA_CONTEXT); deleteFsmBusiData(reqBean.getOrganizeCode(), getContextKey(reqBean), MesPcnExtConstWords.PROD_RULE_DATA_CONTEXT);
} }
//获取生产线的当前班组班次信息
@Override
public MesProdShiftContext getMesProdShiftKvBean(String orgainzeCode, String workCenterCode) {
List<StationKvBean> stationKvBeans = getProdShiftDataContext(orgainzeCode, workCenterCode);
MesProdShiftContext mesProdShiftContext = new MesProdShiftContext();
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);
mesProdShiftContext.setShiftCode(shiftGroupKvBean == null ? null : shiftGroupKvBean.getValue());
mesProdShiftContext.setShiftGroup(shiftCodeKvBean == null ? null : shiftCodeKvBean.getValue());
return mesProdShiftContext;
}
//获取上下文班次班组信息
@Override
public List<StationKvBean> getProdShiftDataContext(String orgainzeCode, String workCenterCode) {
String prodShiftJson = getFsmBusiData(orgainzeCode, getContextKey(orgainzeCode, MesPcnExtConstWords.PROD_SHIFT_DATA_CONTEXT), workCenterCode);
return !StringUtils.isEmpty(prodShiftJson) ? JSONObject.parseArray(prodShiftJson, StationKvBean.class) : null;
}
//验证上下文班次班组信息是否存在
@Override
public Boolean checkProdShiftDataIsExistContext(String orgainzeCode, String workCenterCode) {
String prodShiftJson = getFsmBusiData(orgainzeCode, getContextKey(orgainzeCode, MesPcnExtConstWords.PROD_SHIFT_DATA_CONTEXT), workCenterCode);
return !StringUtils.isEmpty(prodShiftJson) ? true : false;
}
//保存上下文班次班组信息 [JSON]List<StationKvBean>
@Override
public Boolean saveProdShiftDataContext(String organizeCode, String workCenterCode, List<StationKvBean> prodShiftDataList) {
if (CollectionUtils.isEmpty(prodShiftDataList)) return false;
return saveFsmBusiData(organizeCode, getContextKey(organizeCode, MesPcnExtConstWords.PROD_SHIFT_DATA_CONTEXT), workCenterCode, JSONObject.toJSONString(prodShiftDataList));
}
//删除上下文班次班组信息
@Override
public void deleteProdShiftDataContext(String orgainzeCode, String workCenterCode) {
deleteFsmBusiData(orgainzeCode, getContextKey(orgainzeCode, MesPcnExtConstWords.PROD_SHIFT_DATA_CONTEXT), workCenterCode);
}
//获取上下文工位加工数统计信息
@Override
public List<StationKvBean> getProductionStatisticsContext(StationRequestBean reqBean) {
String productionStatisticsJson = getFsmBusiData(reqBean.getOrganizeCode(), getContextKey(reqBean), MesPcnExtConstWords.PRODUCTION_STATISTICS_CONTEXT);
return !StringUtils.isEmpty(productionStatisticsJson) ? JSONObject.parseArray(productionStatisticsJson, StationKvBean.class) : null;
}
//保存上下文工位加工数统计信息 [JSON]List<StationKvBean>
@Override
public Boolean saveProductionStatisticsContext(StationRequestBean reqBean, List<StationKvBean> productionStatisticsList) {
if (CollectionUtils.isEmpty(productionStatisticsList)) return false;
return saveFsmBusiData(reqBean.getOrganizeCode(), getContextKey(reqBean), MesPcnExtConstWords.PRODUCTION_STATISTICS_CONTEXT, JSONObject.toJSONString(productionStatisticsList));
}
@Override
public Boolean addProductionStatisticsContext(StationRequestBean reqBean, int count) {
MesProdShiftContext mesProdShiftKvBean = getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
String key = new StringJoiner(MesPcnExtConstWords.AND).add(mesProdShiftKvBean.getShiftGroup()).add(mesProdShiftKvBean.getShiftCode()).toString();
List<StationKvBean> stationKvBeans = getProductionStatisticsContext(reqBean);
if (CollectionUtils.isEmpty(stationKvBeans)) {
String name = "加工次数";
String value = count + "";
List<StationKvBean> generateStationKvBeans = StationKvBeanUtil.addStationKvBeanList(new ArrayList<>(), new StationKvBean(key, name, value),
new StationKvBean("color", "颜色", MesExtEnumUtil.COLOR.BLACK.getValue()));
saveProductionStatisticsContext(reqBean, generateStationKvBeans);
} else {
stationKvBeans.stream().forEach(stationKvBean -> {
if (Objects.equal(stationKvBean.getKey(), key)) {
stationKvBean.setValue(stationKvBean == null ? count + "" : (Integer.valueOf(stationKvBean.getValue()) + count) + "");
}
});
saveProductionStatisticsContext(reqBean, stationKvBeans);
}
return true;
}
//删除上下文工位加工数统计信息
@Override
public void deleteProductionStatisticsContext(StationRequestBean reqBean) {
deleteFsmBusiData(reqBean.getOrganizeCode(), getContextKey(reqBean), MesPcnExtConstWords.PRODUCTION_STATISTICS_CONTEXT);
}
@Override @Override
public List<MesRawPartCharging> getMesRawPartChargingDataContext(StationRequestBean reqBean) { public List<MesRawPartCharging> getMesRawPartChargingDataContext(StationRequestBean reqBean) {
String mesRawPartChargingDataJson = getFsmBusiData(reqBean.getOrganizeCode(), getContextKey(reqBean), "RAW_PART_CHARGING_DATA_CONTEXT"); String mesRawPartChargingDataJson = getFsmBusiData(reqBean.getOrganizeCode(), getContextKey(reqBean), "RAW_PART_CHARGING_DATA_CONTEXT");

@ -1,10 +1,7 @@
package cn.estsh.i3plus.ext.mes.pcn.pojo.context; package cn.estsh.i3plus.ext.mes.pcn.pojo.context;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentVariable; import cn.estsh.i3plus.pojo.mes.bean.*;
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentVariableCfg;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCell;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCenter;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import lombok.Data; import lombok.Data;
@ -71,7 +68,8 @@ public class MesProductionProcessContext implements Serializable {
@ApiParam("设备变量集合信息([Json]List<MesEquipmentVariable>)") @ApiParam("设备变量集合信息([Json]List<MesEquipmentVariable>)")
private String equipVariableJson; private String equipVariableJson;
@ApiParam("腔组信息([Json]List<MesCavityGroupDetailCfg>)")
private String cavityGroupDetailJson;
//---------------------- 构造方法 --------------------------------------- //---------------------- 构造方法 ---------------------------------------
public MesProductionProcessContext() {} public MesProductionProcessContext() {}
@ -269,5 +267,16 @@ public class MesProductionProcessContext implements Serializable {
this.equipVariableJson = JSONObject.toJSONString(equipmentVariableList); this.equipVariableJson = JSONObject.toJSONString(equipmentVariableList);
return this.isNeedCache(); return this.isNeedCache();
} }
//从上下文中取出腔组信息
public List<MesCavityGroupDetailCfg> getCavityGroupDetailList() {
return !StringUtils.isEmpty(this.cavityGroupDetailJson) ? JSONObject.parseArray(this.cavityGroupDetailJson, MesCavityGroupDetailCfg.class) : null;
}
//上下文赋值数据变量对象集合
public MesProductionProcessContext cavityGroupDetailJson(List<MesCavityGroupDetailCfg> mesCavityGroupDetailCfgs) {
if (CollectionUtils.isEmpty(mesCavityGroupDetailCfgs)) return this;
if (!StringUtils.isEmpty(this.cavityGroupDetailJson)) mesCavityGroupDetailCfgs.addAll(getCavityGroupDetailList());
this.cavityGroupDetailJson = JSONObject.toJSONString(mesCavityGroupDetailCfgs);
return this.isNeedCache();
}
} }

Loading…
Cancel
Save