From 737f6762c0bd5a076032de8d469798002c73266a Mon Sep 17 00:00:00 2001 From: xs Date: Sat, 22 Jun 2024 17:39:38 +0800 Subject: [PATCH] =?UTF-8?q?2.4.7=20=E8=BD=A6=E9=97=B4=E7=94=9F=E4=BA=A7:?= =?UTF-8?q?=E6=88=90=E5=93=81=E6=9D=A1=E7=A0=81=E5=AE=8C=E5=96=84=EF=BC=9A?= =?UTF-8?q?=201=E3=80=81=E6=A0=B9=E6=8D=AE=E7=94=9F=E4=BA=A7=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E7=BC=96=E5=8F=B7=E8=8E=B7=E5=8F=96=E6=88=90=E5=93=81?= =?UTF-8?q?=E6=9D=A1=E7=A0=81=202=E3=80=81=E6=A0=B9=E6=8D=AE=E7=94=9F?= =?UTF-8?q?=E4=BA=A7=E8=AE=A1=E5=88=92=E7=BC=96=E5=8F=B7=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=88=90=E5=93=81=E6=9D=A1=E7=A0=81=EF=BC=8C=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=95=B0=E9=87=8F=E5=8F=AA=E8=83=BD=E7=AD=89=E4=BA=8E=E7=94=9F?= =?UTF-8?q?=E4=BA=A7=E8=AE=A1=E5=88=92=E7=9A=84=E6=95=B0=E9=87=8F=203?= =?UTF-8?q?=E3=80=81=E5=AF=B9=E4=BA=8E=E5=B7=B2=E7=BB=8F=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E7=9A=84=E6=88=90=E5=93=81=E6=9D=A1=E7=A0=81=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E9=87=8D=E6=96=B0=E7=94=9F=E6=88=90=204=E3=80=81=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E7=94=B2=E6=96=B9=E6=8F=90=E4=BE=9B=E7=9A=84=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E8=B0=83=E6=95=B4=E6=A8=A1=E6=9D=BF=E5=92=8C=E5=AE=8C?= =?UTF-8?q?=E5=96=84=E6=89=93=E5=8D=B0=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hw/mes/api/domain/MesBaseBarcodeInfo.java | 11 +- .../hw/printer/api/RemotePrinterService.java | 7 +- .../printer/api/domain/vo/PrintContentVo.java | 2 + .../hw/printer/api/domain/vo/PrinterVo.java | 16 ++ .../factory/RemotePrinterFallbackFactory.java | 5 +- .../MesBaseBarcodeInfoController.java | 57 +++++- .../service/IMesBaseBarcodeInfoService.java | 6 +- .../impl/MesBaseBarcodeInfoServiceImpl.java | 164 ++++++++++----- .../src/views/board/fourthFloor/assemble.vue | 91 ++++++++- hw-ui/src/views/login.vue | 2 +- .../src/views/mes/barcode/endProductIndex.vue | 188 ++++++++---------- hw-ui/src/views/mes/barcode/index.vue | 11 +- 12 files changed, 375 insertions(+), 185 deletions(-) create mode 100644 hw-api/hw-api-printer/src/main/java/com/hw/printer/api/domain/vo/PrinterVo.java diff --git a/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/domain/MesBaseBarcodeInfo.java b/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/domain/MesBaseBarcodeInfo.java index bedcb2d..0ebca48 100644 --- a/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/domain/MesBaseBarcodeInfo.java +++ b/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/domain/MesBaseBarcodeInfo.java @@ -144,8 +144,6 @@ public class MesBaseBarcodeInfo extends BaseEntity //需要打印的条码数量 private BigDecimal barcodeAmount; - - private String materialCode; /** 物料名称 */ @@ -158,6 +156,7 @@ public class MesBaseBarcodeInfo extends BaseEntity private String checkStatus;//质检状态 + private BigDecimal dispatchAmount;//派工数量 public String getPrintFlag() { return printFlag; @@ -484,6 +483,14 @@ public class MesBaseBarcodeInfo extends BaseEntity this.checkStatus = checkStatus; } + public BigDecimal getDispatchAmount() { + return dispatchAmount; + } + + public void setDispatchAmount(BigDecimal dispatchAmount) { + this.dispatchAmount = dispatchAmount; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/hw-api/hw-api-printer/src/main/java/com/hw/printer/api/RemotePrinterService.java b/hw-api/hw-api-printer/src/main/java/com/hw/printer/api/RemotePrinterService.java index 7ae1bab..cdb925a 100644 --- a/hw-api/hw-api-printer/src/main/java/com/hw/printer/api/RemotePrinterService.java +++ b/hw-api/hw-api-printer/src/main/java/com/hw/printer/api/RemotePrinterService.java @@ -5,6 +5,7 @@ import com.hw.common.core.constant.ServiceNameConstants; import com.hw.common.core.domain.R; import com.hw.mes.api.domain.MesBaseBarcodeInfo; import com.hw.printer.api.domain.vo.PrintContentVo; +import com.hw.printer.api.domain.vo.PrinterVo; import com.hw.printer.api.factory.RemotePrinterFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.*; @@ -17,14 +18,14 @@ import java.util.List; public interface RemotePrinterService { /** - * 通过条码查询条码信息 + * 批量打印物料条码信息 * - * @param printContents 条码信息 + * @param printerVo 条码信息 * @param source 请求来源 * @return 结果 */ @PostMapping("/printService/printBarcodes") - public R printBarcodes(@RequestBody List> printContents, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + public R printBarcodes(@RequestBody PrinterVo printerVo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); /** diff --git a/hw-api/hw-api-printer/src/main/java/com/hw/printer/api/domain/vo/PrintContentVo.java b/hw-api/hw-api-printer/src/main/java/com/hw/printer/api/domain/vo/PrintContentVo.java index e7f40ae..73fef06 100644 --- a/hw-api/hw-api-printer/src/main/java/com/hw/printer/api/domain/vo/PrintContentVo.java +++ b/hw-api/hw-api-printer/src/main/java/com/hw/printer/api/domain/vo/PrintContentVo.java @@ -22,6 +22,8 @@ public class PrintContentVo { public static final String RAW_MATERIAL_LABEL_KEY_QC_RESULT_NO = "qcResultNo"; public static final String RAW_MATERIAL_LABEL_KEY_QRCODE = "qrcode"; + public static final String PRODUCT_PLAN_CODE = "productPlanCode"; + private String key; private String value; diff --git a/hw-api/hw-api-printer/src/main/java/com/hw/printer/api/domain/vo/PrinterVo.java b/hw-api/hw-api-printer/src/main/java/com/hw/printer/api/domain/vo/PrinterVo.java new file mode 100644 index 0000000..98f25ca --- /dev/null +++ b/hw-api/hw-api-printer/src/main/java/com/hw/printer/api/domain/vo/PrinterVo.java @@ -0,0 +1,16 @@ +package com.hw.printer.api.domain.vo; + +import lombok.Data; + +import java.util.List; + +@Data +public class PrinterVo { + + public static final String PRINT_TYPE_RAW_LABEL = "1"; + public static final String PRINT_TYPE_PRODUCT_LABEL = "3"; + + public String printType; + + public List> printContents; +} diff --git a/hw-api/hw-api-printer/src/main/java/com/hw/printer/api/factory/RemotePrinterFallbackFactory.java b/hw-api/hw-api-printer/src/main/java/com/hw/printer/api/factory/RemotePrinterFallbackFactory.java index 410d225..fcd24be 100644 --- a/hw-api/hw-api-printer/src/main/java/com/hw/printer/api/factory/RemotePrinterFallbackFactory.java +++ b/hw-api/hw-api-printer/src/main/java/com/hw/printer/api/factory/RemotePrinterFallbackFactory.java @@ -6,6 +6,7 @@ import com.hw.common.core.exception.ServiceException; import com.hw.mes.api.domain.MesBaseBarcodeInfo; import com.hw.printer.api.RemotePrinterService; import com.hw.printer.api.domain.vo.PrintContentVo; +import com.hw.printer.api.domain.vo.PrinterVo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cloud.openfeign.FallbackFactory; @@ -28,8 +29,8 @@ public class RemotePrinterFallbackFactory implements FallbackFactory printBarcodes(List> printContents, String source) { - throw new ServiceException("打印条码服务调用异常:" + throwable.getMessage()); + public R printBarcodes(PrinterVo printerVo, String source) { + throw new ServiceException("打印物料条码服务调用异常:" + throwable.getMessage()); } @Override 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 fcf3dbe..b464501 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 @@ -3,6 +3,7 @@ package com.hw.mes.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; +import com.hw.common.core.constant.MesConstants; import com.hw.common.security.annotation.InnerAuth; import com.hw.common.security.utils.SecurityUtils; import com.hw.mes.api.domain.MesBaseBarcodeInfo; @@ -112,14 +113,15 @@ public class MesBaseBarcodeInfoController extends BaseController /** - * 打印条码 + * 打印原材料条码 * @param barcodeIds * @return */ @GetMapping(value = "/printBarcodes/{barcodeIds}") + @RequiresPermissions("mes:barcode:printBarcodes") public AjaxResult printBarcodes(@PathVariable Long[] barcodeIds) { - return success(mesBaseBarcodeInfoService.printBarcodes(barcodeIds)); + return success(mesBaseBarcodeInfoService.printBarcodes(barcodeIds,MesConstants.MES_BARCODE_TYPE_RAW)); } /** @@ -189,4 +191,55 @@ public class MesBaseBarcodeInfoController extends BaseController } + + /** + * 打印成品条码 + * @param barcodeIds + * @return + */ + @GetMapping(value = "/printProductBarcodes/{barcodeIds}") + @RequiresPermissions("mes:barcode:printProductBarcodes") + public AjaxResult printProductBarcodes(@PathVariable Long[] barcodeIds) + { + return success(mesBaseBarcodeInfoService.printBarcodes(barcodeIds, MesConstants.MES_BARCODE_TYPE_PRODUCT)); + } + + + /** + * 重新生成d成品条码信息(之前的作废) + */ + @RequiresPermissions("mes:barcode:regenerateProductBarcode") + @Log(title = "条码信息", businessType = BusinessType.REGENERATE) + @PostMapping(value="/regenerateProductBarcode") + public AjaxResult regenerateProductBarcode(@RequestBody MesBaseBarcodeInfo mesBaseBarcodeInfo) + { + return toAjax(mesBaseBarcodeInfoService.regenerateBarcode(mesBaseBarcodeInfo)); + } + + + + /** + * 查询条码信息列表 + */ + @RequiresPermissions("mes:barcode:listProductBarcode") + @GetMapping("/listProductBarcode") + public TableDataInfo listProductBarcode(MesBaseBarcodeInfo mesBaseBarcodeInfo) + { + startPage(); + List list = mesBaseBarcodeInfoService.selectMesBaseBarcodeInfoList(mesBaseBarcodeInfo); + return getDataTable(list); + } + + + /** + * 新增成品条码信息 + */ + @RequiresPermissions("mes:barcode:addProductBarcode") + @Log(title = "条码信息", businessType = BusinessType.INSERT) + @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/IMesBaseBarcodeInfoService.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesBaseBarcodeInfoService.java index 2e4fb01..68ca72b 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesBaseBarcodeInfoService.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesBaseBarcodeInfoService.java @@ -72,11 +72,13 @@ public interface IMesBaseBarcodeInfoService public int deleteMesBaseBarcodeInfoByBarcodeId(Long barcodeId); /** - * 打印条码 + * 打印物料条码 + * * @param barcodeIds + * @param printType 打印类型(1原材料 3成品) * @return */ - public int printBarcodes(Long[] barcodeIds); + public int printBarcodes(Long[] barcodeIds,String printType); /** * 绑定条码信息(适用于五楼柜体拆分区) 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 49a89ac..233e322 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 @@ -23,9 +23,12 @@ import com.hw.mes.domain.MesOrderBind; import com.hw.mes.domain.MesProductOrder; import com.hw.mes.domain.vo.MesBindBarcodeVo; import com.hw.mes.mapper.*; + import java.text.DecimalFormat; + import com.hw.printer.api.RemotePrinterService; import com.hw.printer.api.domain.vo.PrintContentVo; +import com.hw.printer.api.domain.vo.PrinterVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.hw.mes.service.IMesBaseBarcodeInfoService; @@ -113,19 +116,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService // 生成成品条码 else if (mesBaseBarcodeInfo.getBarcodeType().equals(MesConstants.MES_BARCODE_TYPE_PRODUCT)) { - Date currentDate = new Date(); - String userName = SecurityUtils.getUsername(); - // 批次代码 == 条码内容 - int frequency = mesBaseBarcodeInfo.getAmount().intValue(); - for (int i = 0; i < frequency; i++) { - String code = Seq.getId(Seq.mesCompBarcodeSeqType, Seq.mesCompBarcodeCode); - mesBaseBarcodeInfo.setBatchCode(code); - mesBaseBarcodeInfo.setBarcodeInfo(code); - mesBaseBarcodeInfo.setAmount(new BigDecimal(1)); - mesBaseBarcodeInfo.setCreateTime(currentDate); - mesBaseBarcodeInfo.setCreateBy(userName); - mesBaseBarcodeInfoMapper.insertMesBaseBarcodeInfo(mesBaseBarcodeInfo); - } + generateProductBarcode(mesBaseBarcodeInfo); } return 1; @@ -195,6 +186,35 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService } } + + public void generateProductBarcode(MesBaseBarcodeInfo mesBaseBarcodeInfo) { + int dispatchAmount = mesBaseBarcodeInfo.getDispatchAmount().intValue(); + int generateAmount = mesBaseBarcodeInfo.getAmount().intValue();//获取要生成的条码数量,目前也是派工的数量 + + String planCode = mesBaseBarcodeInfo.getPlanCode(); + MesBaseBarcodeInfo queryBarcodeInfo = new MesBaseBarcodeInfo(); + queryBarcodeInfo.setPlanCode(planCode); + List mesBaseBarcodeInfos = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoList(queryBarcodeInfo); + int hadGeneratedLabelCount = mesBaseBarcodeInfos == null ? 0 : mesBaseBarcodeInfos.size();//获取已经生成条码的数量 + + if (generateAmount + hadGeneratedLabelCount > dispatchAmount) { + throw new ServiceException("新增条码数量总数不能大于" + dispatchAmount); + } + + 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); + } + } + + public MesBaseBarcodeInfo getInsertedBarcodeInfo(MesBaseBarcodeInfo mesBaseBarcodeInfo, String batchCode, String userName, Date currentDate) { MesBaseBarcodeInfo toInsertedBarcodeInfo = new MesBaseBarcodeInfo(); //同一批次的批次代码相同 @@ -259,14 +279,15 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService } /** - * 打印条码 + * 打印物料条码 * * @param barcodeIds + * @param printType 打印类型(1原材料 3成品) * @return */ @Override @Transactional(rollbackFor = Exception.class) - public int printBarcodes(Long[] barcodeIds) { + public int printBarcodes(Long[] barcodeIds, String printType) { //获取条码List List> printContents = new ArrayList<>(); List toUpdatedBaseBarcodeInfos = new ArrayList<>(); @@ -278,67 +299,94 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService throw new ServiceException("此物料条码[" + mesBaseBarcodeInfo.getBarcodeInfo() + "]已经打印过,不能重复打印"); } + String materialName = mesBaseBarcodeInfo.getMaterialName(); List printContentVos = new ArrayList<>(); - PrintContentVo printMaterialName = new PrintContentVo(); - printMaterialName.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_MATERIAL_NAME); - printMaterialName.setValue(mesBaseBarcodeInfo.getMaterialName()); - printMaterialName.setType(PrintContentVo.TYPE_TEXT); PrintContentVo printMaterialCode = new PrintContentVo(); printMaterialCode.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_MATERIAL_CODE); printMaterialCode.setValue(mesBaseBarcodeInfo.getMaterialCode()); printMaterialCode.setType(PrintContentVo.TYPE_TEXT); - PrintContentVo printPoNo = new PrintContentVo(); - printPoNo.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_PO_NO); - printPoNo.setValue(mesBaseBarcodeInfo.getPoNo()); - printPoNo.setType(PrintContentVo.TYPE_TEXT); - PrintContentVo printPreMaterial = new PrintContentVo(); // if (mesBaseBarcodeInfo.getBindFlag() == null) { // // } - String printPreMaterialKey = mesBaseBarcodeInfo.getBindFlag() != null && mesBaseBarcodeInfo.getBindFlag().equals(MesConstants.MES_MATERIAL_BIND_FLAG_YES) - ? PrintContentVo.RAW_MATERIAL_LABEL_KEY_PRE_MATERIAL_YES : PrintContentVo.RAW_MATERIAL_LABEL_KEY_PRE_MATERIAL_NO; - printPreMaterial.setKey(printPreMaterialKey); - printPreMaterial.setType(PrintContentVo.TYPE_CHECKBOX); - - PrintContentVo printMaterialSpec = new PrintContentVo(); - printMaterialSpec.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_MATERIAL_SPEC); - printMaterialSpec.setValue(mesBaseBarcodeInfo.getMaterialSpec()); - printMaterialSpec.setType(PrintContentVo.TYPE_TEXT); - PrintContentVo printSaleOrderCode = new PrintContentVo(); printSaleOrderCode.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_SALE_ORDER_CODE); printSaleOrderCode.setValue(mesBaseBarcodeInfo.getSaleorderCode()); printSaleOrderCode.setType(PrintContentVo.TYPE_TEXT); - PrintContentVo printQty = new PrintContentVo(); - printQty.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_QTY); - DecimalFormat df = new DecimalFormat("#.##"); - String formattedNumber = df.format(mesBaseBarcodeInfo.getAmount()); - printQty.setValue(formattedNumber); - printQty.setType(PrintContentVo.TYPE_TEXT); - - PrintContentVo printBatchCode = new PrintContentVo(); - printBatchCode.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_BATCH_CODE); - printBatchCode.setValue(mesBaseBarcodeInfo.getBatchCode()); - printBatchCode.setType(PrintContentVo.TYPE_TEXT); PrintContentVo printBarCode = new PrintContentVo(); printBarCode.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_QRCODE); printBarCode.setValue(mesBaseBarcodeInfo.getBarcodeInfo()); printBarCode.setType(PrintContentVo.TYPE_QRCODE); - printContentVos.add(printMaterialName); + if (printType.equals(PrinterVo.PRINT_TYPE_RAW_LABEL)) { + PrintContentVo printMaterialName = new PrintContentVo(); + printMaterialName.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_MATERIAL_NAME); + materialName = materialName.length() <= 10 ? "\n" + materialName : materialName; + printMaterialName.setValue(materialName); + printMaterialName.setType(PrintContentVo.TYPE_TEXT); + + PrintContentVo printBatchCode = new PrintContentVo(); + printBatchCode.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_BATCH_CODE); + printBatchCode.setValue(mesBaseBarcodeInfo.getBatchCode()); + printBatchCode.setType(PrintContentVo.TYPE_TEXT); + + PrintContentVo printPoNo = new PrintContentVo(); + printPoNo.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_PO_NO); + printPoNo.setValue(mesBaseBarcodeInfo.getPoNo()); + printPoNo.setType(PrintContentVo.TYPE_TEXT); + + String printPreMaterialKey = mesBaseBarcodeInfo.getBindFlag() != null && mesBaseBarcodeInfo.getBindFlag().equals(MesConstants.MES_MATERIAL_BIND_FLAG_YES) + ? PrintContentVo.RAW_MATERIAL_LABEL_KEY_PRE_MATERIAL_YES : PrintContentVo.RAW_MATERIAL_LABEL_KEY_PRE_MATERIAL_NO; + printPreMaterial.setKey(printPreMaterialKey); + printPreMaterial.setType(PrintContentVo.TYPE_CHECKBOX); + + PrintContentVo printMaterialSpec = new PrintContentVo(); + printMaterialSpec.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_MATERIAL_SPEC); + printMaterialSpec.setValue(mesBaseBarcodeInfo.getMaterialSpec()); + printMaterialSpec.setType(PrintContentVo.TYPE_TEXT); + + PrintContentVo printQty = new PrintContentVo(); + printQty.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_QTY); + DecimalFormat df = new DecimalFormat("#.##"); + String formattedNumber = df.format(mesBaseBarcodeInfo.getAmount()); + printQty.setValue(formattedNumber); + printQty.setType(PrintContentVo.TYPE_TEXT); + + printContentVos.add(printMaterialName); + printContentVos.add(printBatchCode); + printContentVos.add(printPoNo); + printContentVos.add(printMaterialSpec); + printContentVos.add(printQty); + + } else if (printType.equals(PrinterVo.PRINT_TYPE_PRODUCT_LABEL)) { + PrintContentVo printMaterialName = new PrintContentVo(); + materialName = materialName.length() <= 8 ? "\n" + materialName : materialName; + printMaterialName.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_MATERIAL_NAME); + printMaterialName.setValue(materialName); + printMaterialName.setType(PrintContentVo.TYPE_TEXT); + + PrintContentVo printQty = new PrintContentVo(); + printQty.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_QTY); + printQty.setValue("1"); + printQty.setType(PrintContentVo.TYPE_TEXT); + + PrintContentVo printPlanCode = new PrintContentVo(); + printPlanCode.setKey(PrintContentVo.PRODUCT_PLAN_CODE); + printPlanCode.setValue(mesBaseBarcodeInfo.getPlanCode()); + printPlanCode.setType(PrintContentVo.TYPE_TEXT); + printContentVos.add(printMaterialName); + printContentVos.add(printQty); + printContentVos.add(printPlanCode); + } + printContentVos.add(printMaterialCode); - printContentVos.add(printPoNo); printContentVos.add(printPreMaterial); - printContentVos.add(printMaterialSpec); printContentVos.add(printSaleOrderCode); - printContentVos.add(printQty); - printContentVos.add(printBatchCode); printContentVos.add(printBarCode); String checkStatus = mesBaseBarcodeInfo.getCheckStatus() == null ? "" : mesBaseBarcodeInfo.getCheckStatus(); @@ -367,8 +415,12 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService this.updateMesBaseBarcodeInfo(toUpdateMesBaseBarcodeInfo); } + PrinterVo printerVo = new PrinterVo(); + printerVo.setPrintType(printType); + printerVo.setPrintContents(printContents); + //调用的打印接口 - R printResultR = remotePrinterService.printBarcodes(printContents, SecurityConstants.INNER); + R printResultR = remotePrinterService.printBarcodes(printerVo, SecurityConstants.INNER); if (printResultR.getCode() != Constants.SUCCESS) {//抛出异常,回滚事务 throw new RuntimeException(printResultR.getMsg()); } @@ -532,14 +584,21 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService /** * 重新生成条码信息,之前的作废 + * * @param mesBaseBarcodeInfo * @return */ @Transactional(rollbackFor = Exception.class) @Override public int regenerateBarcode(MesBaseBarcodeInfo mesBaseBarcodeInfo) { + String barcodeType = mesBaseBarcodeInfo.getBarcodeType(); String oldBarcode = mesBaseBarcodeInfo.getBarcodeInfo(); - String newBarcode = Seq.getId(Seq.mesBarcodeSeqType, Seq.mesBarcodeCode); + String newBarcode = ""; + if (barcodeType.equals(MesConstants.MES_BARCODE_TYPE_RAW)) { + newBarcode = Seq.getId(Seq.mesBarcodeSeqType, Seq.mesBarcodeCode); + } else { + newBarcode = Seq.getId(Seq.mesCompBarcodeSeqType, Seq.mesCompBarcodeCode); + } String userName = SecurityUtils.getUsername(); Date currentDate = new Date(); @@ -557,7 +616,6 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService mesBaseBarcodeInfo.setUpdateTime(currentDate); return mesBaseBarcodeInfoMapper.updateMesBaseBarcodeInfo(mesBaseBarcodeInfo); - } } diff --git a/hw-ui/src/views/board/fourthFloor/assemble.vue b/hw-ui/src/views/board/fourthFloor/assemble.vue index d9196dc..dd4d918 100644 --- a/hw-ui/src/views/board/fourthFloor/assemble.vue +++ b/hw-ui/src/views/board/fourthFloor/assemble.vue @@ -209,6 +209,7 @@ 首页 成品入库 + 连接条码枪 退出 @@ -420,6 +421,14 @@ export default { }, data() { return { + serialPort: null, + reader: null, + lastScannedBarcode: '', + decoder: new TextDecoder(), + + + + returnModelVisible: false, returnModelForm:{}, WarehousesList:[], @@ -473,14 +482,14 @@ export default { } }, mounted() { - setInterval(() => { - this.$notify.info({ - title: '通知', - message: '通知公告', - position: 'bottom-right', - duration: 0 - }); - }, 60 * 1000) + // setInterval(() => { + // this.$notify.info({ + // title: '通知', + // message: '通知公告', + // position: 'bottom-right', + // duration: 0 + // }); + // }, 60 * 1000) getProductPlans({pageNum: 1, pageSize: 5}).then(e => { this.tableData = e.rows this.totalNum1 = Math.ceil(e.total / 5) @@ -654,7 +663,72 @@ export default { ] }) }, + + beforeUnmount() { + // 组件卸载时关闭串口和释放资源 + if (this.reader) { + this.reader.cancel().then(() => this.reader.releaseLock()); + } + if (this.serialPort) { + this.serialPort.close(); + } + }, + + methods: { + checkPortConnection(){ + checkPortConnection(portName).then((isConnected) => { + if (isConnected) { + console.log('串口已连接并可用.'); + } else { + console.log('串口未连接或不可用.'); + } + }).catch((error) => { + console.error('检查串口连接时发生错误:', error); + }); + }, + + + + async connectSerial() { + 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); + } + } catch (error) { + console.error('连接或读取串口时发生错误:', error); + } + }, + processReceivedData(data) { + // 假设条码数据以回车符或换行符结束 + const barcodeEnd = /\r|\n/; + if (barcodeEnd.test(data)) { + const barcode = data.split(barcodeEnd)[0].trim(); // 获取并清理条码数据 + this.lastScannedBarcode = barcode; // 更新最后一次扫描的条码 + console.log('扫描到的条码:', barcode); + } + }, + + + async logout() { this.$confirm('确定注销并退出系统吗?', '提示', { @@ -850,7 +924,6 @@ export default { this.getStockTotal(); }, print(val) { - console.log(val) this.PrintData = val this.printModel = true }, diff --git a/hw-ui/src/views/login.vue b/hw-ui/src/views/login.vue index f7dbe6d..3beeceb 100644 --- a/hw-ui/src/views/login.vue +++ b/hw-ui/src/views/login.vue @@ -109,7 +109,7 @@ export default { floorData: [ { floor: 1, - processId: 1, + processId: 11, route: '/board/firstFloor' }, { diff --git a/hw-ui/src/views/mes/barcode/endProductIndex.vue b/hw-ui/src/views/mes/barcode/endProductIndex.vue index fc5fc79..39b4660 100644 --- a/hw-ui/src/views/mes/barcode/endProductIndex.vue +++ b/hw-ui/src/views/mes/barcode/endProductIndex.vue @@ -46,45 +46,25 @@ size="mini" type="primary" @click="handleAdd" - >新增 + v-if = "addBarcodeBtnVisible" + >新增条码 - - - - - - - - - - - - + 删除 + @click="handlePrintBarcodes" + :disabled="batchPrintBtnDisabled" + v-hasPermi="['mes:barcode:printProductBarcodes']" + >打印 - - 导出 - - - + + @@ -98,87 +78,48 @@ - - + + - - - + - - - - - - - - - - - - - - - - - - - - - - @@ -195,8 +136,7 @@ - - + @@ -230,7 +170,7 @@ - + @@ -299,12 +239,12 @@ diff --git a/hw-ui/src/views/mes/barcode/index.vue b/hw-ui/src/views/mes/barcode/index.vue index 246be6f..2c11c86 100644 --- a/hw-ui/src/views/mes/barcode/index.vue +++ b/hw-ui/src/views/mes/barcode/index.vue @@ -83,7 +83,7 @@ size="mini" @click="handlePrintBarcodes" :disabled="batchPrintBtnDisabled" - v-hasPermi="['mes:barcode:print']" + v-hasPermi="['mes:barcode:printBarcode']" >打印 @@ -180,7 +180,7 @@ icon="el-icon-refresh" @click="regenerateBarcode(scope.row)" v-if="scope.row.printFlag ==='1'" - v-hasPermi="['mes:barcode:print']" + v-hasPermi="['mes:barcode:regenerate']" >重新生成 打印 @@ -705,7 +705,7 @@ export default { this.getList(); this.batchPrintBtnDisabled = false; }).catch(() => { - + this.batchPrintBtnDisabled = false; }); }, @@ -713,9 +713,10 @@ export default { regenerateBarcode(row) { const barcodeId = row.barcodeId; const barcodeInfo = row.barcodeInfo; + const barcodeType = row.barcodeType; this.$modal.confirm('重新生成后之前的条码将会作废,是否确认重新生成条码内容为"' + barcodeInfo + '"的数据项?').then(function () { - return regenerateBarcode({"barcodeId": barcodeId, "barcodeInfo": barcodeInfo}); + return regenerateBarcode({"barcodeId": barcodeId, "barcodeInfo": barcodeInfo, "barcodeType": barcodeType}); }).then(() => { this.getList(); this.$modal.msgSuccess("重新生成成功");