From f787dfeaeebe14dc96602729b053b6fe604a221c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=AE=E7=AC=91=E7=9D=80=E9=9D=A2=E5=AF=B9=E6=98=8E?= =?UTF-8?q?=E5=A4=A9?= <752558143@qq.com> Date: Fri, 14 Jun 2024 16:39:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B1=95=E7=A4=BA=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mes/pcn/api/base/IMesPojoVersionService.java | 18 ++ .../IMesProductionCustomContextStepService.java | 27 +++ .../IMesProductionDispatchContextStepService.java | 26 --- .../busi/MesProdShiftRecordController.java | 7 +- .../base/MesPojoVersionServiceImpl.java | 209 +++++++++++++++++++++ .../station/MesProductionNoSortModuleService.java | 16 +- .../MesFunctionProductionStatisticsService.java | 9 +- .../step/MesMouldRecordGenerateStepService.java | 15 +- .../MesProductResultErrorHandleStepService.java | 4 +- .../step/MesProductSnGenerateStepService.java | 46 ++++- .../step/MesProductSnSaveStepService.java | 1 + .../MesProductionReocrdGenerateStepService.java | 6 +- .../MesProductionCustomContextStepService.java | 88 ++++++++- .../MesProductionDispatchContextStepService.java | 89 --------- .../pojo/context/MesProductionProcessContext.java | 19 +- 15 files changed, 427 insertions(+), 153 deletions(-) create mode 100644 modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesPojoVersionService.java create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesPojoVersionServiceImpl.java diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesPojoVersionService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesPojoVersionService.java new file mode 100644 index 0000000..8d07fd9 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesPojoVersionService.java @@ -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); +} diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProductionCustomContextStepService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProductionCustomContextStepService.java index 623857c..dc5fc1f 100644 --- a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProductionCustomContextStepService.java +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProductionCustomContextStepService.java @@ -1,6 +1,7 @@ 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.MesProdShiftContext; import cn.estsh.i3plus.pojo.mes.model.StationKvBean; import cn.estsh.i3plus.pojo.mes.model.StationRequestBean; import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; @@ -49,4 +50,30 @@ public interface IMesProductionCustomContextStepService { @ApiOperation(value = "删除手动选择的腔数及工单信息上下文") void deleteFunctionChooseCavityOrderContext(StationRequestBean reqBean); + @ApiOperation(value = "验证上下文班次班组信息是否存在") + Boolean checkProdShiftDataIsExistContext(String orgainzeCode, String workCenterCode); + + @ApiOperation(value = "获取上下文班次班组信息") + List getProdShiftDataContext(String orgainzeCode, String workCenterCode); + + @ApiOperation(value = "保存上下文班次班组信息", notes = "[JSON]List") + Boolean saveProdShiftDataContext(String orgainzeCode, String workCenterCode, List prodShiftDatList); + + @ApiOperation(value = "删除上下文班次班组信息") + void deleteProdShiftDataContext(String orgainzeCode, String workCenterCode); + + @ApiOperation(value = "获取上下文工位加工数统计信息") + List getProductionStatisticsContext(StationRequestBean reqBean); + + @ApiOperation(value = "保存上下文工位加工数统计信息", notes = "[JSON]List") + Boolean saveProductionStatisticsContext(StationRequestBean reqBean, List prodShiftDatList); + + @ApiOperation(value = "新增上下文工位加工数统计信息") + Boolean addProductionStatisticsContext(StationRequestBean reqBean, int count); + + @ApiOperation(value = "删除上下文工位加工数统计信息") + void deleteProductionStatisticsContext(StationRequestBean reqBean); + + @ApiOperation(value = "获取生产线的当前班组班次信息") + MesProdShiftContext getMesProdShiftKvBean(String orgainzeCode, String workCenterCode); } diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProductionDispatchContextStepService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProductionDispatchContextStepService.java index 66b47b1..2a8675b 100644 --- a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProductionDispatchContextStepService.java +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProductionDispatchContextStepService.java @@ -180,32 +180,6 @@ public interface IMesProductionDispatchContextStepService { @ApiOperation(value = "删除上下文产品加工规则信息集合") void deleteProdRuleDataContext(StationRequestBean reqBean); - @ApiOperation(value = "获取生产线的当前班组班次信息") - MesProdShiftContext getMesProdShiftKvBean(String orgainzeCode, String workCenterCode); - - @ApiOperation(value = "获取上下文班次班组信息") - List getProdShiftDataContext(String orgainzeCode, String workCenterCode); - - @ApiOperation(value = "验证上下文班次班组信息是否存在") - Boolean checkProdShiftDataIsExistContext(String orgainzeCode, String workCenterCode); - - @ApiOperation(value = "保存上下文班次班组信息", notes = "[JSON]List") - Boolean saveProdShiftDataContext(String orgainzeCode, String workCenterCode, List prodShiftDatList); - - @ApiOperation(value = "删除上下文班次班组信息") - void deleteProdShiftDataContext(String orgainzeCode, String workCenterCode); - - @ApiOperation(value = "获取上下文工位加工数统计信息") - List getProductionStatisticsContext(StationRequestBean reqBean); - - @ApiOperation(value = "保存上下文工位加工数统计信息", notes = "[JSON]List") - Boolean saveProductionStatisticsContext(StationRequestBean reqBean, List prodShiftDatList); - - @ApiOperation(value = "新增上下文工位加工数统计信息") - Boolean addProductionStatisticsContext(StationRequestBean reqBean, int count); - - @ApiOperation(value = "删除上下文工位加工数统计信息") - void deleteProductionStatisticsContext(StationRequestBean reqBean); @ApiOperation(value = "获取料桶原材料数据集合") List getMesRawPartChargingDataContext(StationRequestBean reqBean); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesProdShiftRecordController.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesProdShiftRecordController.java index 0551d34..3b36986 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesProdShiftRecordController.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesProdShiftRecordController.java @@ -1,6 +1,7 @@ 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.busi.IMesProductionCustomContextStepService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService; import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant; import cn.estsh.i3plus.mes.pcn.util.StationKvBeanUtil; @@ -37,7 +38,7 @@ public class MesProdShiftRecordController { private IMesProdShiftRecordService mesProdShiftRecordService; @Autowired - private IMesProductionDispatchContextStepService mesProductionDispatchContextStepService; + private IMesProductionCustomContextStepService productionCustomContextStepService; @GetMapping("/query-pager") @ApiOperation(value = "查询开关班记录") public ResultBean queryMesProdShiftRecordByPager(MesProdShiftRecord mesProdShiftRecord, Pager pager) { @@ -68,7 +69,7 @@ public class MesProdShiftRecordController { List getProdShiftData = getProdShiftData(item); - mesProductionDispatchContextStepService.saveProdShiftDataContext(item.getOrganizeCode(), item.getWorkCenterCode(), getProdShiftData); + productionCustomContextStepService.saveProdShiftDataContext(item.getOrganizeCode(), item.getWorkCenterCode(), getProdShiftData); return ResultBean.success("保存开关班记录成功"); } catch (ImppBusiException imppException) { @@ -91,7 +92,7 @@ public class MesProdShiftRecordController { mesProdShiftRecordService.saveMesProdShiftRecord(item, AuthUtil.getOrganizeCode()); 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("保存开关班记录成功"); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesPojoVersionServiceImpl.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesPojoVersionServiceImpl.java new file mode 100644 index 0000000..06b2dc4 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesPojoVersionServiceImpl.java @@ -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 beforeMap = new HashMap<>(); + Map 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> mapDiff; // 版本对比 + String userName = StringUtils.isNotBlank(afterMesPojoVersion.getModifyUser()) ? afterMesPojoVersion.getModifyUser() : afterMesPojoVersion.getCreateUser(); + Map 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 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 mapData, Map mapPropDesc) { + if (mapData == null) { + mapData = new HashMap<>(); + } + if (mapPropDesc == null) { + mapData = new HashMap<>(); + } + + StringBuilder stringBuffer = new StringBuilder(); + String key; + for (Map.Entry 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> mapData, Map mapPropDesc) { + if (mapData == null) { + mapData = new HashMap<>(); + } + if (mapPropDesc == null) { + mapData = new HashMap<>(); + } + + StringBuilder stringBuffer = new StringBuilder(); + String key; + MapDifference.ValueDifference valDiff; + for (Map.Entry> 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(); + } +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/station/MesProductionNoSortModuleService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/station/MesProductionNoSortModuleService.java index d9e3764..5b3b599 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/station/MesProductionNoSortModuleService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/station/MesProductionNoSortModuleService.java @@ -1,5 +1,6 @@ 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.IMesProductionProcessContextStepService; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdShiftContext; @@ -50,7 +51,10 @@ public class MesProductionNoSortModuleService extends BaseModuleService { private IMesProductionProcessContextStepService productionProcessContextStepService; @Autowired - private IMesProductionDispatchContextStepService mesProductionDispatchContextStepService; + private IMesProductionDispatchContextStepService productionDispatchContextStepService; + + @Autowired + private IMesProductionCustomContextStepService productionCustomContextStepService; @Autowired private MesFileRepository mesFileRepository; @@ -58,15 +62,15 @@ public class MesProductionNoSortModuleService extends BaseModuleService { @Override public void init(StationRequestBean reqBean) { // 获取工单信息 - List> moduleContentContext = mesProductionDispatchContextStepService.getModuleContentContext(reqBean); + List> moduleContentContext = productionDispatchContextStepService.getModuleContentContext(reqBean); //获取上下文信息 MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getEquipmentVariableList(reqBean, MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PRODUCTION.getValue()); MesWorkCell mesWorkCell = productionProcessContext.getWorkCell(); // 获取班次信息 - List prodShiftDataContext = mesProductionDispatchContextStepService.getProdShiftDataContext(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode()); - MesProdShiftContext mesProdShiftKvBean = mesProductionDispatchContextStepService.getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode()); + List prodShiftDataContext = productionCustomContextStepService.getProdShiftDataContext(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode()); + 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); @@ -77,9 +81,9 @@ public class MesProductionNoSortModuleService extends BaseModuleService { this.sendMessage(reqBean, resultBean); // 整合班次加工数量 - List productionStatisticsContext = mesProductionDispatchContextStepService.getProductionStatisticsContext(reqBean); + List 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"), + 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())); } StationResultBean shiftCountBean = getStationResultBean(reqBean, productionStatisticsContext,mesWorkCell); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/station/function/MesFunctionProductionStatisticsService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/station/function/MesFunctionProductionStatisticsService.java index 6658ba8..85c2bc9 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/station/function/MesFunctionProductionStatisticsService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/station/function/MesFunctionProductionStatisticsService.java @@ -1,5 +1,6 @@ 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.pojo.context.MesProdShiftContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; @@ -31,17 +32,17 @@ public class MesFunctionProductionStatisticsService extends BaseSwsService imple private IShippingDispatchService shippingDispatchService; @Autowired - private IMesProductionDispatchContextStepService mesProductionDispatchContextStepService; + private IMesProductionCustomContextStepService productionCustomContextStepService; @Override public boolean doFunction(StationRequestBean reqBean, StationResultBean resultBean, ButtonDynamicModel buttonDynamicModel) { // 获取班次信息 - List productionStatisticsContext = mesProductionDispatchContextStepService.getProductionStatisticsContext(reqBean); + List productionStatisticsContext = productionCustomContextStepService.getProductionStatisticsContext(reqBean); 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); return true; diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesMouldRecordGenerateStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesMouldRecordGenerateStepService.java index 9a9e5f7..58c21a2 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesMouldRecordGenerateStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesMouldRecordGenerateStepService.java @@ -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.IMesProductionDispatchContextStepService; 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.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.context.*; import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService; import cn.estsh.i3plus.platform.common.convert.ConvertBean; @@ -62,8 +59,10 @@ public class MesMouldRecordGenerateStepService extends BaseStepService { //获取上下文信息 MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getEquipmentVariableList(reqBean, MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PRODUCTION.getValue()); + + //List productionPartContextList = mesProductionDispatchContextStepService.getProductionPartContext(reqBean); // 获取条码信息 - List mesProduceSns = mesProductionDispatchContextStepService.getOutProduceSnDataContext(reqBean); + List mesProduceSnContexts = mesProductionDispatchContextStepService.getProductionPsOutContext(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, "生成开模记录成功"); } - private void saveMouldRecord(StationRequestBean reqBean, StationResultBean resultBean, MesProductionProcessContext productionProcessContext, List mesProduceSns, MesEquipVariableCollectContext mesFirstMouldNoCollectContext, MesEquipVariableCollectContext mesMouldNoCollectContext) { + private void saveMouldRecord(StationRequestBean reqBean, StationResultBean resultBean, MesProductionProcessContext productionProcessContext, List mesProduceSns, MesEquipVariableCollectContext mesFirstMouldNoCollectContext, MesEquipVariableCollectContext mesMouldNoCollectContext) { List mesProdMouldRecords = new ArrayList<>(); for (MesProduceSn mesProduceSn : mesProduceSns) { @@ -96,7 +95,7 @@ public class MesMouldRecordGenerateStepService extends BaseStepService { DdlPreparedPack.getStringEqualPack(equipmentCode, "equipmentCode", packBean); DdlPreparedPack.getStringEqualPack(mouldNo, "mouldNo", packBean); MesMouldMappingCfg mesMouldMappingCfg = mesMouldMappingCfgRepository.getByProperty(packBean); - //配置错误 抛出异常 + //配置错误 抛出异常 todo 没找到不能报错,就不填这个字段 if (mesMouldMappingCfg == null) execExpSendMsgAndThrowEx(reqBean, resultBean, String.format("请检查模具映射关系维护,根据设备[%s],模具号[%s]", equipmentCode, mouldNo)); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductResultErrorHandleStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductResultErrorHandleStepService.java index 9b7123a..94f961f 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductResultErrorHandleStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductResultErrorHandleStepService.java @@ -42,7 +42,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; /** - * @Description : 加工异常处理工步 + * @Description : 加工异常处理工步 注释调整 * @Author : zxw **/ @Slf4j @@ -128,7 +128,7 @@ public class MesProductResultErrorHandleStepService extends BaseStepService { MesPartInspectionDetail mesPartInspectionDetail = new MesPartInspectionDetail(); mesPartInspectionDetail.setPid(id); - mesPartInspectionDetail.setStatus(10); + mesPartInspectionDetail.setStatus(MesExtEnumUtil.PART_INSPECTION_NC_STATUS.CREATE.getValue()); mesPartInspectionDetail.setDefectTypeCode(mesDefectType.getDefectTypeCode()); mesPartInspectionDetail.setDefectTypeName(mesDefectType.getDefectTypeName()); model.setPartInspection(partInspection); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnGenerateStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnGenerateStepService.java index f1b9963..6e3d019 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnGenerateStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnGenerateStepService.java @@ -1,5 +1,6 @@ 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.IMesProductionProcessContextStepService; 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.serviceimpl.fsm.BaseStepService; 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.codemaker.SnowflakeIdMaker; import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; 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.MesWorkCell; import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel; @@ -62,6 +65,9 @@ public class MesProductSnGenerateStepService extends BaseStepService { @Autowired private IMesProductionDispatchContextStepService mesProductionDispatchContextStepService; + @Autowired + private IMesPojoVersionService mesPojoVersionService; + /**todo 有产成无进料场景 * todo 根据装配件条码没有找到加工规则,如果需要跳过装配件绑定,直接生成条码,就需要不看加工规则,直接根据产成零件生成条码,当前设计方式就需要变更。 * @param reqBean @@ -85,14 +91,38 @@ public class MesProductSnGenerateStepService extends BaseStepService { // 获取零件号,可能存在多个 List partNoList = productionPartContextList.stream().map(MesProductionPartContext::getPartNo).collect(Collectors.toList()); // 根据零件号组装产品条码信息 - List mesProduceSns = generateSn(reqBean, productionProcessContext, mesWorkCell, partNoList, result); + List mesProduceSns = generateSn(reqBean, productionProcessContext, mesWorkCell, partNoList, result); + // 保存条码信息 + mesProduceSnRepository.saveAll(mesProduceSns); + + savePojoVersion(mesProduceSns); + List 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, "生成零件条码成功"); } + private void savePojoVersion(List 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 @@ -101,8 +131,8 @@ public class MesProductSnGenerateStepService extends BaseStepService { * @param partNoList * @return */ - private List generateSn(StationRequestBean reqBean, MesProductionProcessContext productionProcessContext, MesWorkCell mesWorkCell, List partNoList, String result) { - List mesProduceSns = new ArrayList<>(); + private List generateSn(StationRequestBean reqBean, MesProductionProcessContext productionProcessContext, MesWorkCell mesWorkCell, List partNoList, String result) { + List mesProduceSns = new ArrayList<>(); for (String partNo : partNoList) { DdlPackBean packBean = DdlPackBean.getDdlPackBean(reqBean.getOrganizeCode()); DdlPreparedPack.getStringEqualPack(partNo, "partNo", packBean); @@ -113,7 +143,7 @@ public class MesProductSnGenerateStepService extends BaseStepService { // 根据条码规则生成条码 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()); mesProduceSns.add(mesProduceSn); } @@ -133,10 +163,10 @@ public class MesProductSnGenerateStepService extends BaseStepService { 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(); - MesProductionPsOutContext mesProduceSn = new MesProductionPsOutContext(); + MesProduceSn mesProduceSn = new MesProduceSn(); mesProduceSn.setSerialNumber(serialNum + ""); mesProduceSn.setProductSn(sn); mesProduceSn.setCustSn(sn); @@ -149,7 +179,7 @@ public class MesProductSnGenerateStepService extends BaseStepService { mesProduceSn.setCustLabelTemplate(mesPart.getCustLabelTemplate()); mesProduceSn.setProcessLabelTemplate(mesPart.getProcessLabelTemplate()); mesProduceSn.setQty(1d); - mesProduceSn.setSnStatus(MesExtEnumUtil.PRODUCE_SN_STATUS.CREATE.getValue()); + mesProduceSn.setSnStatus(10); Integer qcStatus = MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue(); if (Objects.equal(MesExtEnumUtil.EQUIP_VARIABLE_CFG_CATEGORY.PRODUCT_SCRAP.getValue(), result)) { qcStatus = MesExtEnumUtil.PRODUCE_QC_STATUS.SCRAP.getValue(); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnSaveStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnSaveStepService.java index a84b796..b611067 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnSaveStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnSaveStepService.java @@ -52,6 +52,7 @@ public class MesProductSnSaveStepService extends BaseStepService { } mesProduceSnContexts.forEach(mesProduceSnContext -> { MesProduceSn mesProduceSn = new MesProduceSn(); + //todo 要根据不同的加工结果,返回不同的结果 要分排序和非排序, 排序只保存工单对应的装配件、非排序要保存主条码和装配件记录。 mesProduceSn.setSnStatus(MesExtEnumUtil.PRODUCE_SN_STATUS.OFFLINE.getValue()); mesProduceSns.add(mesProduceSn); }); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductionReocrdGenerateStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductionReocrdGenerateStepService.java index 6e6c3d9..b09f0f1 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductionReocrdGenerateStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductionReocrdGenerateStepService.java @@ -1,5 +1,6 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step; +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionCustomContextStepService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.*; @@ -53,6 +54,9 @@ public class MesProductionReocrdGenerateStepService extends BaseStepService { @Autowired private IMesProductionDispatchContextStepService mesProductionDispatchContextStepService; + @Autowired + private IMesProductionCustomContextStepService productionCustomContextStepService; + public static final String ORDER_NO_JIS_SORT = "ORDER_NO_JIS_SORT"; @@ -81,7 +85,7 @@ public class MesProductionReocrdGenerateStepService extends BaseStepService { mesProductionRecordRepository.saveAll(mesProductionRecords); 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, "生成加工记录成功"); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/context/MesProductionCustomContextStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/context/MesProductionCustomContextStepService.java index 88f4c26..3e75df5 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/context/MesProductionCustomContextStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/context/MesProductionCustomContextStepService.java @@ -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.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.mes.pcn.serviceimpl.fsm.BaseStepService; 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.util.MesExtEnumUtil; import com.alibaba.fastjson.JSONObject; +import com.google.common.base.Objects; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -39,6 +41,7 @@ public class MesProductionCustomContextStepService extends BaseStepService imple //工位加工锁KEY private String getProductionLockContextKey(StationRequestBean reqBean) { return getFsmBusikey(reqBean, new StringJoiner(MesPcnExtConstWords.COLON).add(MesPcnExtConstWords.PRODUCTION_PROCESS_CONTEXT).add(MesPcnExtConstWords.PRODUCTION_LOCK_CONTEXT).toString()); } + //验证上下文工位加工锁是否存在 @Override public Boolean checkProductionLockIsExistContext(StationRequestBean reqBean) { @@ -130,14 +133,97 @@ public class MesProductionCustomContextStepService extends BaseStepService imple } //开班信息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 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 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 + @Override + public Boolean saveProdShiftDataContext(String organizeCode, String workCenterCode, List 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 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 + @Override + public Boolean saveProductionStatisticsContext(StationRequestBean reqBean, List 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 stationKvBeans = getProductionStatisticsContext(reqBean); + if (CollectionUtils.isEmpty(stationKvBeans)) { + String name = "加次数"; + String value = count + ""; + List 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); + } } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/context/MesProductionDispatchContextStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/context/MesProductionDispatchContextStepService.java index 32c7e22..6516696 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/context/MesProductionDispatchContextStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/context/MesProductionDispatchContextStepService.java @@ -398,95 +398,6 @@ public class MesProductionDispatchContextStepService extends BaseStepService imp public void deleteProdRuleDataContext(StationRequestBean reqBean) { deleteFsmBusiData(reqBean.getOrganizeCode(), getContextKey(reqBean), MesPcnExtConstWords.PROD_RULE_DATA_CONTEXT); } - - //获取生产线的当前班组班次信息 - @Override - public MesProdShiftContext getMesProdShiftKvBean(String orgainzeCode, String workCenterCode) { - List 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 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 - @Override - public Boolean saveProdShiftDataContext(String organizeCode, String workCenterCode, List 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 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 - @Override - public Boolean saveProductionStatisticsContext(StationRequestBean reqBean, List 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 stationKvBeans = getProductionStatisticsContext(reqBean); - if (CollectionUtils.isEmpty(stationKvBeans)) { - String name = "加工次数"; - String value = count + ""; - List 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 public List getMesRawPartChargingDataContext(StationRequestBean reqBean) { String mesRawPartChargingDataJson = getFsmBusiData(reqBean.getOrganizeCode(), getContextKey(reqBean), "RAW_PART_CHARGING_DATA_CONTEXT"); diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/context/MesProductionProcessContext.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/context/MesProductionProcessContext.java index bff7097..4954c3a 100644 --- a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/context/MesProductionProcessContext.java +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/context/MesProductionProcessContext.java @@ -1,10 +1,7 @@ package cn.estsh.i3plus.ext.mes.pcn.pojo.context; 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.MesEquipmentVariableCfg; -import cn.estsh.i3plus.pojo.mes.bean.MesWorkCell; -import cn.estsh.i3plus.pojo.mes.bean.MesWorkCenter; +import cn.estsh.i3plus.pojo.mes.bean.*; import com.alibaba.fastjson.JSONObject; import io.swagger.annotations.ApiParam; import lombok.Data; @@ -71,7 +68,8 @@ public class MesProductionProcessContext implements Serializable { @ApiParam("设备变量集合信息([Json]List)") private String equipVariableJson; - + @ApiParam("腔组信息([Json]List)") + private String cavityGroupDetailJson; //---------------------- 构造方法 --------------------------------------- public MesProductionProcessContext() {} @@ -269,5 +267,16 @@ public class MesProductionProcessContext implements Serializable { this.equipVariableJson = JSONObject.toJSONString(equipmentVariableList); return this.isNeedCache(); } + //从上下文中取出腔组信息 + public List getCavityGroupDetailList() { + return !StringUtils.isEmpty(this.cavityGroupDetailJson) ? JSONObject.parseArray(this.cavityGroupDetailJson, MesCavityGroupDetailCfg.class) : null; + } + //上下文赋值数据变量对象集合 + public MesProductionProcessContext cavityGroupDetailJson(List mesCavityGroupDetailCfgs) { + if (CollectionUtils.isEmpty(mesCavityGroupDetailCfgs)) return this; + if (!StringUtils.isEmpty(this.cavityGroupDetailJson)) mesCavityGroupDetailCfgs.addAll(getCavityGroupDetailList()); + this.cavityGroupDetailJson = JSONObject.toJSONString(mesCavityGroupDetailCfgs); + return this.isNeedCache(); + } }