From 9f0c7c6e43817529ee750bf5a83ecc27b46351e6 Mon Sep 17 00:00:00 2001 From: liyongde <1419499670@qq.com> Date: Wed, 11 Oct 2023 15:40:46 +0800 Subject: [PATCH] =?UTF-8?q?add:=20=E5=90=8C=E6=AD=A5=E8=B4=A7=E6=9E=B6?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=88=B0mes=EF=BC=8C=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E5=8E=8B=E6=9C=BA=E6=A3=80=E6=B5=8B=E6=95=B0=E6=8D=AE=E5=88=B0?= =?UTF-8?q?mes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/MdBaseBrickInfoServiceImpl.java | 5 ++ .../acs/service/impl/AcsToWmsServiceImpl.java | 10 ++- .../autotask/AutoSaveShelfInformation.java | 59 ++++++++++++++ .../wms/ext/mes/service/WmsToMesService.java | 25 +++++- .../service/dao/mapper/MesRequestMapper.java | 6 ++ .../service/dao/mapper/MesRequestMapper.xml | 52 ++++++++++++ .../service/dto/MesQSPressMonitorData.java | 53 +++++++++++++ .../wms/ext/mes/service/dto/MesShelfInfo.java | 77 ++++++++++++++++++ .../mes/service/impl/WmsToMesServiceImpl.java | 79 +++++++++++++++++-- .../src/main/java/org/nl/wms/util/Tes.java | 29 ------- 10 files changed, 354 insertions(+), 41 deletions(-) create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/autotask/AutoSaveShelfInformation.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/dto/MesQSPressMonitorData.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/dto/MesShelfInfo.java delete mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/util/Tes.java diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/brick/service/impl/MdBaseBrickInfoServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/brick/service/impl/MdBaseBrickInfoServiceImpl.java index 5136335..50aa495 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/brick/service/impl/MdBaseBrickInfoServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/brick/service/impl/MdBaseBrickInfoServiceImpl.java @@ -13,6 +13,7 @@ import org.nl.wms.database.brick.service.IMdBaseBrickInfoService; import org.nl.wms.database.brick.service.dao.MdBaseBrickInfo; import org.nl.wms.database.brick.service.dao.mapper.MdBaseBrickInfoMapper; import org.nl.wms.ext.acs.service.dto.BrickInfoDto; +import org.nl.wms.ext.mes.service.WmsToMesService; import org.nl.wms.pdm.workorder.service.IPdmBdWorkorderService; import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder; import org.springframework.beans.factory.annotation.Autowired; @@ -34,6 +35,8 @@ public class MdBaseBrickInfoServiceImpl extends ServiceImpl queryAll(Map whereJson, PageQuery page) { @@ -66,6 +69,8 @@ public class MdBaseBrickInfoServiceImpl extends ServiceImpl mesShelfInfos = wmsToMesService.getAllShelfInfos(); + AtomicInteger successNum = new AtomicInteger(); + long startTime = System.currentTimeMillis(); + String now = DateUtil.now(); + mesShelfInfos.forEach(shelfInfo -> { + shelfInfo.setMSGID(IdUtil.getSnowflake(1,1).nextIdStr()); + shelfInfo.setCREATE_TM(now); + shelfInfo.setSEND_TM(now); + shelfInfo.setOP_FLAG(GeneralDefinition.NO); + // 插入数据 + try { + wmsToMesService.saveShelfInfoBatchToMes(shelfInfo); + successNum.getAndIncrement(); + } catch (Exception e) { + log.error("插入货架数据失败的数据: {}", shelfInfo); + log.error("插入货架数据失败的信息:{}", e.getMessage()); + // notice通知 + noticeService.createNotice(e.getMessage(), "货架数据同步失败" + shelfInfo.getGROUP_ID(), + NoticeTypeEnum.NOTIFICATION.getCode()); + } + }); + long endTime = System.currentTimeMillis(); + log.info("滚筒线数据有" + mesShelfInfos.size() + "条,成功" + successNum.get() + "条, 消耗时长:" + (endTime - startTime) + "ms"); + } +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/WmsToMesService.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/WmsToMesService.java index 265d7a0..cbea84c 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/WmsToMesService.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/WmsToMesService.java @@ -1,10 +1,9 @@ package org.nl.wms.ext.mes.service; +import org.nl.wms.database.brick.service.dao.MdBaseBrickInfo; +import org.nl.wms.ext.acs.service.dto.BrickInfoDto; import org.nl.wms.ext.mes.autotask.AutoSaveWaitGdyInfo; -import org.nl.wms.ext.mes.service.dto.MesGdyInfoDto; -import org.nl.wms.ext.mes.service.dto.MesGdyInfoWaitDto; -import org.nl.wms.ext.mes.service.dto.MesMudConsumptionDto; -import org.nl.wms.ext.mes.service.dto.MesSemiProductionInfo; +import org.nl.wms.ext.mes.service.dto.*; import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder; import java.util.List; @@ -75,4 +74,22 @@ public interface WmsToMesService { * @return */ List getAllWaitIntoGdyInfos(); + + /** + * 上报mes砖块检测信息 + * @param brickInfo + */ + void reportBrickInfo(MdBaseBrickInfo brickInfo); + + /** + * 获取货架所有数据 + * @return + */ + List getAllShelfInfos(); + + /** + * 插入货架信息 + * @param shelfInfo + */ + void saveShelfInfoBatchToMes(MesShelfInfo shelfInfo); } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/dao/mapper/MesRequestMapper.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/dao/mapper/MesRequestMapper.java index 7b70e43..6eb022a 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/dao/mapper/MesRequestMapper.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/dao/mapper/MesRequestMapper.java @@ -53,4 +53,10 @@ public interface MesRequestMapper { List getAllWaitIntoGdyInfos(); @DS("oracle") void insertGdyMaterialWait(MesGdyInfoWaitDto mesGdyInfoWaitDto); + @DS("oracle") + void insertQSPressMonitorData(MesQSPressMonitorData mesQSPressMonitorData); + @DS("mysql") + List getAllShelfInfos(); + @DS("oracle") + void saveShelfInfoBatchToMes(MesShelfInfo shelfInfo); } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/dao/mapper/MesRequestMapper.xml b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/dao/mapper/MesRequestMapper.xml index b975ffa..74366f7 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/dao/mapper/MesRequestMapper.xml +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/dao/mapper/MesRequestMapper.xml @@ -70,6 +70,24 @@ VALUES (#{MSGID}, #{SEND_TM}, #{TRAY_NO}, #{FPRODUCT_MATERIAL_ID}, #{FPRODUCT_MATERIAL_NAME}, #{FMATSPEC} , #{FMATMODEL}, #{BATCHNO}, #{PRESSUNIT}, #{PRO_SUBNUM}, #{PRO_SUBUNIT}, #{CREATE_TM}, #{OP_FLAG}) + + INSERT INTO "LMSTELCOM"."RECEIVE_QS_PRESS_MONITORDATA"(BRICK_ID, GET_STATION, PUT_STATION, IS_QUALIFIED, LASER_MARKING_CODE + , WEIGHT, HEIGHT1, HEIGHT2, HEIGHT3, HEIGHT4, WIDTH1, WIDTH2, LEN, VOLUME, FLATNESS, UNQUALIFIED_QTY, WORKORDER_CODE + , CREATE_TM, OP_FLAG) VALUES (#{BRICK_ID}, #{GET_STATION}, #{PUT_STATION}, #{IS_QUALIFIED}, #{LASER_MARKING_CODE} + , #{WEIGHT}, #{HEIGHT1}, #{HEIGHT2}, #{HEIGHT3}, #{HEIGHT4}, #{WIDTH1}, #{WIDTH2}, #{LEN}, #{VOLUME}, #{FLATNESS} + , #{UNQUALIFIED_QTY}, #{WORKORDER_CODE}, #{CREATE_TM}, #{OP_FLAG}) + + + INSERT INTO "LMSTELCOM"."RECEIVE_LMS_BINSTA"(MSGID, SEND_TM, GROUP_ID, VEHICLE_TYPE, VEHICLE_CODE, MATERIAL_ID + , MATERIAL_NAME, MATSPEC, MATMODEL, SOURCE_VEHICLE_CODE, POINT_CODE, POINT_NAME, IS_FIRING, IS_FULL, PCSN + , INSTORAGE_TIME, STANDING_TIME, MATERIAL_QTY, MATERIAL_WEIGHT, WORKORDER_CODE, GROUP_NUMBER + , GROUP_BIND_MATERIAL_STATUS, MOVE_WAY, REMARK, UPDATE_TIME, OUT_KILN_TIME, INTO_KILN_TIME, CREATE_TM, OP_FLAG) + VALUES (#{MSGID}, #{SEND_TM}, #{GROUP_ID}, #{VEHICLE_TYPE}, #{VEHICLE_CODE}, #{MATERIAL_ID}, #{MATERIAL_NAME} + , #{MATSPEC}, #{MATMODEL}, #{SOURCE_VEHICLE_CODE}, #{POINT_CODE}, #{POINT_NAME}, #{IS_FIRING}, #{IS_FULL}, #{PCSN} + , #{INSTORAGE_TIME}, #{STANDING_TIME}, #{MATERIAL_QTY}, #{MATERIAL_WEIGHT}, #{WORKORDER_CODE}, #{GROUP_NUMBER} + , #{GROUP_BIND_MATERIAL_STATUS}, #{MOVE_WAY}, #{REMARK}, #{UPDATE_TIME}, #{OUT_KILN_TIME}, #{INTO_KILN_TIME} + , #{CREATE_TM}, #{OP_FLAG}) + UPDATE "LMSTELCOM"."SEND_POP_SCHEDULE_PRESS" SET OP_FLAG = '1' @@ -227,4 +245,38 @@ vg.point_code IN ( 'HCSSX01', 'HCSSX63' ) AND pw.workorder_code IS NOT NULL + diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/dto/MesQSPressMonitorData.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/dto/MesQSPressMonitorData.java new file mode 100644 index 0000000..bdba2c2 --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/dto/MesQSPressMonitorData.java @@ -0,0 +1,53 @@ +package org.nl.wms.ext.mes.service.dto; + +import lombok.Data; + +/** + * @Author: lyd + * @Description: 压机检测数据 + * @Date: 2023/10/11 + * 唯一标识 + * 当前抓取工位 + * 当前放置工位 + * 是否合格 + * 激光标刻码 + * 重量 + * 高度1 + * 高度2 + * 高度3 + * 高度4 + * 宽度1 + * 宽度2 + * 长度 + * 体积 + * 平面度 + * 缺陷个数 + * 工单标识 + * 写入时间 + * 读取标志,0未读取,1已读取 + * 读取时间 + */ +@Data +public class MesQSPressMonitorData { + private String BRICK_ID; + private String GET_STATION; + private String PUT_STATION; + private Boolean IS_QUALIFIED; + private String LASER_MARKING_CODE; + private String WEIGHT; + private String HEIGHT1; + private String HEIGHT2; + private String HEIGHT3; + private String HEIGHT4; + private String WIDTH1; + private String WIDTH2; + private String LEN; + private String VOLUME; + private String FLATNESS; + private String UNQUALIFIED_QTY; + private String WORKORDER_CODE; + private String CREATE_TM; + private String OP_FLAG; + private String OP_TM; + +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/dto/MesShelfInfo.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/dto/MesShelfInfo.java new file mode 100644 index 0000000..e9ccdcb --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/dto/MesShelfInfo.java @@ -0,0 +1,77 @@ +package org.nl.wms.ext.mes.service.dto; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @Author: lyd + * @Description: 三层货架信息 + * @Date: 2023/10/11 + * 唯一ID - 新生成 + * 发送时间 - 新生成 + * 仓库号 - 不录入 + * 组盘标识 + * 载具类型 + * 载具编码 + * 物料标识 + * 物料名称 + * 规格 + * 型号 + * 来源载具编码/载具的来源点位(压机) + * 货位号 + * 点位名称 + * 是否已烧制 + * 是否满托 + * 批次 + * 入库时间 + * 静置时间(分钟) + * 物料数量 + * 物料重量 + * 搬运工单编码 + * 组盘次数 + * 组盘绑定物料状态 + * 位置跟踪 + * 备注 + * 修改时间 + * 出窑时间 + * 入窑时间 + * 写入时间 + * 读取标识 + * 读取时间 + */ +@Data +public class MesShelfInfo { + private String MSGID; + private String SEND_TM; + private String LOGT; + private String GROUP_ID; + private String VEHICLE_TYPE; + private String VEHICLE_CODE; + private String MATERIAL_ID; + private String MATERIAL_NAME; + private String MATSPEC; + private String MATMODEL; + private String SOURCE_VEHICLE_CODE; + private String POINT_CODE; + private String POINT_NAME; + private Boolean IS_FIRING; + private Boolean IS_FULL; + private String PCSN; + private String INSTORAGE_TIME; + private String STANDING_TIME; + private int MATERIAL_QTY; + private BigDecimal MATERIAL_WEIGHT; + private String WORKORDER_CODE; + private String GROUP_NUMBER; + private String GROUP_BIND_MATERIAL_STATUS; + private String MOVE_WAY; + private String REMARK; + private String UPDATE_TIME; + private String OUT_KILN_TIME; + private String INTO_KILN_TIME; + private String CREATE_TM; + private String OP_FLAG; + private String OP_TM; + +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/WmsToMesServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/WmsToMesServiceImpl.java index 0de4948..8e7ab1f 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/WmsToMesServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/WmsToMesServiceImpl.java @@ -9,8 +9,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import lombok.extern.slf4j.Slf4j; import org.nl.system.service.notice.ISysNoticeService; +import org.nl.wms.database.brick.service.dao.MdBaseBrickInfo; import org.nl.wms.database.material.service.IMdBaseMaterialService; import org.nl.wms.database.material.service.dao.MdBaseMaterial; +import org.nl.wms.ext.acs.service.dto.BrickInfoDto; import org.nl.wms.ext.mes.autotask.AutoSaveWaitGdyInfo; import org.nl.wms.ext.mes.service.WmsToMesService; import org.nl.wms.ext.mes.service.dao.mapper.MesRequestMapper; @@ -36,7 +38,7 @@ import java.util.stream.Collectors; /** * @Author: lyd - * @Description: + * @Description: wms请求mes的实现类 * @Date: 2023/8/3 */ @Slf4j @@ -140,7 +142,8 @@ public class WmsToMesServiceImpl implements WmsToMesService { mesProductDataDto.setPRO_SUBNUM(BigDecimal.valueOf(vehiclematerialgroup.getMaterial_qty()));// 数量 mesProductDataDto.setPRO_SUBUNIT("块"); mesProductDataDto.setCHECKERIN_TIM(DateUtil.now()); - mesProductDataDto.setPRODATE(ObjectUtil.isNotEmpty(workorder.getProduce_date()) ? workorder.getProduce_date() : DateUtil.now()); + mesProductDataDto.setPRODATE(ObjectUtil.isNotEmpty(workorder.getProduce_date()) + ? workorder.getProduce_date() : DateUtil.now()); mesProductDataDto.setCREATE_TM(DateUtil.now()); mesProductDataDto.setOP_FLAG(GeneralDefinition.NO); log.info("压机产出返给MES的数据:{}", mesProductDataDto); @@ -150,8 +153,8 @@ public class WmsToMesServiceImpl implements WmsToMesService { } catch (Exception e) { log.error("反馈压机产出插入mes数据库失败:{}", e.getMessage()); // 发送通知 - noticeService.createNotice("反馈压机产出插入mes数据库失败", "压机产出" + mesProductDataDto.getPRESSUNIT(), - NoticeTypeEnum.EXCEPTION.getCode()); + noticeService.createNotice("反馈压机产出插入mes数据库失败", "压机产出" + + mesProductDataDto.getPRESSUNIT(), NoticeTypeEnum.EXCEPTION.getCode()); } } @@ -192,8 +195,8 @@ public class WmsToMesServiceImpl implements WmsToMesService { } catch (Exception e) { log.error("半成品入库插入mes数据库失败:{}", e.getMessage()); // todo:发送通知 - noticeService.createNotice("半成品入库插入mes数据库失败", "半成品入库" + semiProductionInfoInDto.getMSGID(), - NoticeTypeEnum.EXCEPTION.getCode()); + noticeService.createNotice("半成品入库插入mes数据库失败", "半成品入库" + + semiProductionInfoInDto.getMSGID(), NoticeTypeEnum.EXCEPTION.getCode()); } } @@ -364,6 +367,9 @@ public class WmsToMesServiceImpl implements WmsToMesService { mesRequestMapper.insertMesUnusedInfo(mesUnusedDto); } catch (Exception e) { log.error("插入机口判废失败:{}", e.getMessage()); + // todo:发送通知 + noticeService.createNotice("机口判废插入mes数据库失败", "机口判废" + mesUnusedDto.getMSGID(), + NoticeTypeEnum.EXCEPTION.getCode()); } } @@ -372,6 +378,67 @@ public class WmsToMesServiceImpl implements WmsToMesService { return mesRequestMapper.getAllWaitIntoGdyInfos(); } + @Override + public void reportBrickInfo(MdBaseBrickInfo brickInfo) { + // 转换成mes字段 + MesQSPressMonitorData mesQSPressMonitorData = toPressMonitorMapper(brickInfo); + // 插入mes数据库 + try { + mesRequestMapper.insertQSPressMonitorData(mesQSPressMonitorData); + } catch (Exception e) { + log.error("插入压机检测失败:{}", e.getMessage()); + // todo:发送通知 + noticeService.createNotice("压机检测插入mes数据库失败", "压机检测" + + mesQSPressMonitorData.getBRICK_ID(), NoticeTypeEnum.EXCEPTION.getCode()); + } + } + + @Override + public List getAllShelfInfos() { + return mesRequestMapper.getAllShelfInfos(); + } + + @Override + public void saveShelfInfoBatchToMes(MesShelfInfo shelfInfo) { + mesRequestMapper.saveShelfInfoBatchToMes(shelfInfo); + } + + /** + * 转换 + * @param brickInfo:lms的砖块检测信息 + * @return 上报mes的砖块检测信息 + */ + private MesQSPressMonitorData toPressMonitorMapper(MdBaseBrickInfo brickInfo) { + // 获取mes的设备 + SchBasePoint device = pointService.getById(brickInfo.getGet_station()); + MesQSPressMonitorData monitorData = new MesQSPressMonitorData(); + monitorData.setBRICK_ID(brickInfo.getBrick_id()); + monitorData.setGET_STATION(device.getExt_point_code()); + monitorData.setPUT_STATION(brickInfo.getPut_station()); + monitorData.setIS_QUALIFIED(brickInfo.getIs_qualified()); + monitorData.setLASER_MARKING_CODE(brickInfo.getLaser_marking_code()); + monitorData.setWEIGHT(brickInfo.getWeight()); + monitorData.setHEIGHT1(brickInfo.getHeight1()); + monitorData.setHEIGHT2(brickInfo.getHeight2()); + monitorData.setHEIGHT3(brickInfo.getHeight3()); + monitorData.setHEIGHT4(brickInfo.getHeight4()); + monitorData.setWIDTH1(brickInfo.getWidth1()); + monitorData.setWIDTH2(brickInfo.getWidth2()); + monitorData.setLEN(brickInfo.getLen()); + monitorData.setVOLUME(brickInfo.getVolume()); + monitorData.setFLATNESS(brickInfo.getFlatness()); + monitorData.setUNQUALIFIED_QTY(brickInfo.getUnqualified_qty()); + monitorData.setWORKORDER_CODE(brickInfo.getWorkorder_code()); + monitorData.setCREATE_TM(DateUtil.now()); + monitorData.setOP_FLAG(GeneralDefinition.NO); + return monitorData; + } + + /** + * 转换 + * @param mesWorkOrderInfos: mes的工单 + * @return lms工单 + */ public List toWorkOrderList(List mesWorkOrderInfos) { List list = new CopyOnWriteArrayList<>(); mesWorkOrderInfos.forEach(mesWorkOrderDto -> { diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/util/Tes.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/util/Tes.java deleted file mode 100644 index 78ac359..0000000 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/util/Tes.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.nl.wms.util; - -import java.io.IOException; - -/** - * @Author: lyd - * @Description: - * @Date: 2023/10/8 - */ -public class Tes { - public static void main(String[] args) { - String videoFilePath = "video.mp4"; - String audioFilePath = "audio.wav"; - - String ffmpegCommand = "ffmpeg -i " + videoFilePath + " -vn -acodec pcm_s16le -ar 44100 -ac 2 " + audioFilePath; - - try { - Process process = Runtime.getRuntime().exec(ffmpegCommand); - int exitCode = process.waitFor(); - if (exitCode == 0) { - System.out.println("音频提取完成"); - } else { - System.err.println("音频提取失败"); - } - } catch (IOException | InterruptedException e) { - e.printStackTrace(); - } - } -}