From 3cc7e0aae9ce9dbf2d8940eb2e873bf0b0de2480 Mon Sep 17 00:00:00 2001 From: xs Date: Tue, 25 Jun 2024 10:06:51 +0800 Subject: [PATCH] =?UTF-8?q?2.4.8=20=E8=BD=A6=E9=97=B4=E7=94=9F=E4=BA=A7:?= =?UTF-8?q?=201=E3=80=81=E6=88=90=E5=93=81=E6=9D=A1=E7=A0=81=E5=AE=8C?= =?UTF-8?q?=E5=96=84=EF=BC=9A=E6=A0=B9=E6=8D=AE=E7=94=9F=E4=BA=A7=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E6=98=8E=E7=BB=86=E7=94=9F=E6=88=90=E6=9D=A1=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E4=B8=94=E5=9C=A8=E5=AE=8C=E6=88=90=E6=98=8E?= =?UTF-8?q?=E7=BB=86=E5=90=8E=E6=89=8D=E8=83=BD=E7=94=9F=E6=88=90=202?= =?UTF-8?q?=E3=80=81=E5=9B=9B=E6=A5=BC=E8=A3=85=E9=85=8D=E5=8C=BA=E5=9F=9F?= =?UTF-8?q?=E6=9D=A1=E7=A0=81=E6=9E=AA=E5=AF=B9=E6=8E=A5=E5=AE=8C=E6=88=90?= =?UTF-8?q?=EF=BC=8C=E5=8C=85=E6=8B=AC=E6=89=AB=E6=8F=8F=E7=89=A9=E6=96=99?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E5=92=8C=E6=88=90=E5=93=81=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hw/common/core/constant/MesConstants.java | 2 +- .../MesBaseBarcodeInfoController.java | 2 +- .../impl/MesBaseBarcodeInfoServiceImpl.java | 52 +- .../mapper/mes/MesProductPlanMapper.xml | 4 +- hw-ui/src/api/mes/barcode.js | 41 +- hw-ui/src/utils/serial.js | 73 +++ .../src/views/board/fourthFloor/assemble.vue | 601 ++++++++++-------- .../src/views/mes/barcode/endProductIndex.vue | 52 +- 8 files changed, 516 insertions(+), 311 deletions(-) create mode 100644 hw-ui/src/utils/serial.js diff --git a/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/MesConstants.java b/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/MesConstants.java index f50b777..3cf9575 100644 --- a/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/MesConstants.java +++ b/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/MesConstants.java @@ -106,7 +106,7 @@ public class MesConstants { /**物料信息绑定标识,是否需要采购订单明细绑定销售订单*/ public static final String MES_MATERIAL_BIND_FLAG_YES = "1";//是 - + public static final String MES_MATERIAL_BIND_FLAG_NO = "0";//否 /**物料条码打印标识*/ public static final String MES_BARCODE_PRINT_FLAG_YES = "1";//是 diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesBaseBarcodeInfoController.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesBaseBarcodeInfoController.java index b464501..a1936df 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesBaseBarcodeInfoController.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesBaseBarcodeInfoController.java @@ -239,7 +239,7 @@ public class MesBaseBarcodeInfoController extends BaseController @PostMapping(value="/addProductBarcode") public AjaxResult addProductBarcode(@RequestBody MesBaseBarcodeInfo mesBaseBarcodeInfo) { - mesBaseBarcodeInfo.setCreateBy(SecurityUtils.getUsername()); + return toAjax(mesBaseBarcodeInfoService.insertMesBaseBarcodeInfo(mesBaseBarcodeInfo)); } } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBaseBarcodeInfoServiceImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBaseBarcodeInfoServiceImpl.java index 233e322..48a06aa 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBaseBarcodeInfoServiceImpl.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBaseBarcodeInfoServiceImpl.java @@ -17,10 +17,7 @@ import com.hw.common.core.utils.uuid.Seq; import com.hw.common.security.utils.SecurityUtils; import com.hw.mes.api.domain.MesBaseBarcodeInfo; import com.hw.mes.api.domain.MesBaseMaterialInfo; -import com.hw.mes.domain.MesBaseAbandonBarcode; -import com.hw.mes.domain.MesBasePalletInfo; -import com.hw.mes.domain.MesOrderBind; -import com.hw.mes.domain.MesProductOrder; +import com.hw.mes.domain.*; import com.hw.mes.domain.vo.MesBindBarcodeVo; import com.hw.mes.mapper.*; @@ -65,6 +62,9 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService @Autowired private MesBaseAbandonBarcodeMapper mesBaseAbandonBarcodeMapper; + @Autowired + private MesProductPlanMapper mesProductPlanMapper; + /** * 查询条码信息 * @@ -188,30 +188,40 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService public void generateProductBarcode(MesBaseBarcodeInfo mesBaseBarcodeInfo) { - int dispatchAmount = mesBaseBarcodeInfo.getDispatchAmount().intValue(); - int generateAmount = mesBaseBarcodeInfo.getAmount().intValue();//获取要生成的条码数量,目前也是派工的数量 - String planCode = mesBaseBarcodeInfo.getPlanCode(); + String planDetailCode = mesBaseBarcodeInfo.getPlanDetailCode(); + MesBaseBarcodeInfo queryBarcodeInfo = new MesBaseBarcodeInfo(); - queryBarcodeInfo.setPlanCode(planCode); + queryBarcodeInfo.setPlanDetailCode(planDetailCode); List mesBaseBarcodeInfos = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoList(queryBarcodeInfo); - int hadGeneratedLabelCount = mesBaseBarcodeInfos == null ? 0 : mesBaseBarcodeInfos.size();//获取已经生成条码的数量 - if (generateAmount + hadGeneratedLabelCount > dispatchAmount) { - throw new ServiceException("新增条码数量总数不能大于" + dispatchAmount); + if (mesBaseBarcodeInfos != null && !mesBaseBarcodeInfos.isEmpty()) { + throw new ServiceException("此计划明细已经生成条码,不能重复生成"); } - Date currentDate = new Date(); - for (int i = 0; i < generateAmount; i++) { - String barcode = Seq.getId(Seq.mesCompBarcodeSeqType, Seq.mesCompBarcodeCode); - mesBaseBarcodeInfo.setBatchCode(barcode);// 成品的批次代码 == 条码内容 - mesBaseBarcodeInfo.setBarcodeInfo(barcode); - mesBaseBarcodeInfo.setAmount(new BigDecimal(1)); - mesBaseBarcodeInfo.setCreateTime(currentDate); - mesBaseBarcodeInfo.setBatchFlag(MesConstants.NOT_IS_BATCH); - mesBaseBarcodeInfo.setSafeFlag(MesConstants.MES_ORDER_BIND_SAFE_FLAG_YES); - mesBaseBarcodeInfoMapper.insertMesBaseBarcodeInfo(mesBaseBarcodeInfo); + MesProductPlan productPlan = mesProductPlanMapper.selectOnlyMesProductPlanByPlanCode(planCode); + if(productPlan == null){ + throw new ServiceException("此生产任务不存在"); } + + Date currentDate = new Date(); + String barcode = Seq.getId(Seq.mesCompBarcodeSeqType, Seq.mesCompBarcodeCode); + mesBaseBarcodeInfo.setBatchCode(barcode);// 成品的批次代码 == 条码内容 + mesBaseBarcodeInfo.setBarcodeInfo(barcode); + mesBaseBarcodeInfo.setAmount(new BigDecimal(1)); + + mesBaseBarcodeInfo.setBatchFlag(MesConstants.NOT_IS_BATCH); + mesBaseBarcodeInfo.setSafeFlag(MesConstants.MES_ORDER_BIND_SAFE_FLAG_YES); + + mesBaseBarcodeInfo.setMaterialId(productPlan.getMaterialId()); + mesBaseBarcodeInfo.setPrintFlag(MesConstants.MES_BARCODE_PRINT_FLAG_NO); + mesBaseBarcodeInfo.setSaleOrderId(productPlan.getSaleOrderId()); + mesBaseBarcodeInfo.setSaleorderCode(productPlan.getSaleorderCode()); + + mesBaseBarcodeInfo.setCreateTime(currentDate); + mesBaseBarcodeInfo.setCreateBy(SecurityUtils.getUsername()); + mesBaseBarcodeInfoMapper.insertMesBaseBarcodeInfo(mesBaseBarcodeInfo); + } diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductPlanMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductPlanMapper.xml index ef2f09e..1308bde 100644 --- a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductPlanMapper.xml +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductPlanMapper.xml @@ -345,7 +345,7 @@ - select a.plan_id, a.product_order_id, a.plan_code, @@ -357,6 +357,8 @@ a.last_process_id, a.station_id, a.user_id, + a.sale_order_id, + a.saleorder_code, a.production_time, a.dispatch_amount, a.plan_amount, diff --git a/hw-ui/src/api/mes/barcode.js b/hw-ui/src/api/mes/barcode.js index fc1492c..31f616e 100644 --- a/hw-ui/src/api/mes/barcode.js +++ b/hw-ui/src/api/mes/barcode.js @@ -43,7 +43,7 @@ export function delBarcode(barcodeId) { }) } -// 打印条码 +// 打印原材料条码 export function printBarcodes(barcodeIds) { return request({ url: '/mes/barcode/printBarcodes/' + barcodeIds, @@ -88,3 +88,42 @@ export function regenerateBarcode(data) { data: data }) } + + +// 打印成品条码 +export function printProductBarcodes(barcodeIds) { + return request({ + url: '/mes/barcode/printProductBarcodes/' + barcodeIds, + method: 'get' + }) +} + + +// 重新生成成品条码信息,之前的条码作废 +export function regenerateProductBarcode(data) { + return request({ + url: '/mes/barcode/regenerateProductBarcode', + method: 'post', + data: data + }) +} + + +// 查询成品条码信息列表 +export function listProductBarcode(query) { + return request({ + url: '/mes/barcode/listProductBarcode', + method: 'get', + params: query + }) +} + + +// 新增成品条码信息 +export function addProductBarcode(data) { + return request({ + url: '/mes/barcode/addProductBarcode', + method: 'post', + data: data + }) +} diff --git a/hw-ui/src/utils/serial.js b/hw-ui/src/utils/serial.js new file mode 100644 index 0000000..07b5770 --- /dev/null +++ b/hw-ui/src/utils/serial.js @@ -0,0 +1,73 @@ +export const monitorSerialData = { + data() { + return { + serialPort: null, + reader: null, + decoder: new TextDecoder(), + barcode: '',//临时拼装数据使用 + serialData: ''//获得的最终的条码数据 + + }; + }, + methods: { + checkSerialConnected() { + if (this.serialPort && this.serialPort.readable) { + console.log("串口当前已连接"); + return true; + } else { + console.log("串口未连接或已断开"); + return false; + } + }, + + + async connectSerial(callback) { + try { + // 请求串口访问权限 + this.serialPort = await navigator.serial.requestPort(); + await this.serialPort.open({baudRate: 9600}); // 假设条码枪的波特率为9600 + + // 设置数据流解码 + this.decoder = new TextDecoderStream(); + const readableStreamClosed = this.serialPort.readable.pipeTo(this.decoder.writable); + this.reader = this.decoder.readable.getReader(); + + // 监听串口数据 + while (true) { + const {value, done} = await this.reader.read(); + if (done) { + this.reader.releaseLock(); + break; + } + + // console.log("---"+value); + // const data = this.decoder.decode(value); + this.processReceivedData(value,callback); + } + } catch (error) { + console.error('连接或读取串口时发生错误:', error); + } + }, + + processReceivedData(data,callback) { + // 假设条码数据以回车符或换行符结束 + const barcodeEnd = /\r|\n/; + // console.log("---:" + data) + if (barcodeEnd.test(data)) { + const barcode = data.split(barcodeEnd)[0].trim(); // 获取并清理条码数据 + console.log('扫描到的条码:', this.barcode + barcode); + this.serialData = this.barcode + barcode; + // 调用传入的函数 + if (typeof callback === 'function') { + callback(); + } + this.barcode = ''; + } else { + this.barcode += data; + } + }, + } +}; + + + diff --git a/hw-ui/src/views/board/fourthFloor/assemble.vue b/hw-ui/src/views/board/fourthFloor/assemble.vue index dd4d918..83b90d2 100644 --- a/hw-ui/src/views/board/fourthFloor/assemble.vue +++ b/hw-ui/src/views/board/fourthFloor/assemble.vue @@ -7,72 +7,65 @@
- + @@ -139,6 +120,10 @@ + + + + @@ -160,12 +145,12 @@ - + @@ -223,7 +208,7 @@ @@ -380,18 +365,14 @@ export default { methods: { getData() { this.form = { + planId: this.defineData.planId, planCode: this.defineData.planCode, - saleorderCode: this.defineData.saleorderCode, - materialId: this.defineData.materialId, - materialName: this.defineData.materialName, + planDetailCode: this.defineData.planDetailCode, batchFlag:'0', barcodeType:'3', - saleOrderId:null, - amount :this.defineData.dispatchAmount, - dispatchAmount : this.defineData.dispatchAmount, - + amount :1, } - this.queryParams.planCode = this.defineData.planCode; + this.queryParams.planDetailCode = this.defineData.planDetailCode; }, /** 查询条码信息列表 */ @@ -401,9 +382,10 @@ export default { this.barcodeList = response.rows; this.total = response.total; if(this.total && this.total >0){ - this.addBarcodeBtnVisible = true; + this.addBarcodeBtnVisible = false; }else{ this.addBarcodeBtnVisible = true; + this.handleAdd(); } this.loading = false; });