车间生产:成品条码完善:
1、根据生产计划编号获取成品条码
2、根据生产计划编号生成成品条码,生成数量只能等于生产计划的数量
3、对于已经打印的成品条码可以重新生成
4、根据甲方提供的模板调整模板和完善打印方法
master
xs 5 months ago
parent 87d2aa5cdc
commit 737f6762c0

@ -144,8 +144,6 @@ public class MesBaseBarcodeInfo extends BaseEntity
//需要打印的条码数量 //需要打印的条码数量
private BigDecimal barcodeAmount; private BigDecimal barcodeAmount;
private String materialCode; private String materialCode;
/** 物料名称 */ /** 物料名称 */
@ -158,6 +156,7 @@ public class MesBaseBarcodeInfo extends BaseEntity
private String checkStatus;//质检状态 private String checkStatus;//质检状态
private BigDecimal dispatchAmount;//派工数量
public String getPrintFlag() { public String getPrintFlag() {
return printFlag; return printFlag;
@ -484,6 +483,14 @@ public class MesBaseBarcodeInfo extends BaseEntity
this.checkStatus = checkStatus; this.checkStatus = checkStatus;
} }
public BigDecimal getDispatchAmount() {
return dispatchAmount;
}
public void setDispatchAmount(BigDecimal dispatchAmount) {
this.dispatchAmount = dispatchAmount;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -5,6 +5,7 @@ import com.hw.common.core.constant.ServiceNameConstants;
import com.hw.common.core.domain.R; import com.hw.common.core.domain.R;
import com.hw.mes.api.domain.MesBaseBarcodeInfo; import com.hw.mes.api.domain.MesBaseBarcodeInfo;
import com.hw.printer.api.domain.vo.PrintContentVo; import com.hw.printer.api.domain.vo.PrintContentVo;
import com.hw.printer.api.domain.vo.PrinterVo;
import com.hw.printer.api.factory.RemotePrinterFallbackFactory; import com.hw.printer.api.factory.RemotePrinterFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -17,14 +18,14 @@ import java.util.List;
public interface RemotePrinterService { public interface RemotePrinterService {
/** /**
* *
* *
* @param printContents * @param printerVo
* @param source * @param source
* @return * @return
*/ */
@PostMapping("/printService/printBarcodes") @PostMapping("/printService/printBarcodes")
public R<?> printBarcodes(@RequestBody List<List<PrintContentVo>> printContents, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); public R<?> printBarcodes(@RequestBody PrinterVo printerVo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
/** /**

@ -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_QC_RESULT_NO = "qcResultNo";
public static final String RAW_MATERIAL_LABEL_KEY_QRCODE = "qrcode"; public static final String RAW_MATERIAL_LABEL_KEY_QRCODE = "qrcode";
public static final String PRODUCT_PLAN_CODE = "productPlanCode";
private String key; private String key;
private String value; private String value;

@ -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<List<PrintContentVo>> printContents;
}

@ -6,6 +6,7 @@ import com.hw.common.core.exception.ServiceException;
import com.hw.mes.api.domain.MesBaseBarcodeInfo; import com.hw.mes.api.domain.MesBaseBarcodeInfo;
import com.hw.printer.api.RemotePrinterService; import com.hw.printer.api.RemotePrinterService;
import com.hw.printer.api.domain.vo.PrintContentVo; import com.hw.printer.api.domain.vo.PrintContentVo;
import com.hw.printer.api.domain.vo.PrinterVo;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory; import org.springframework.cloud.openfeign.FallbackFactory;
@ -28,8 +29,8 @@ public class RemotePrinterFallbackFactory implements FallbackFactory<RemotePrint
log.error("打印条码服务调用失败:{}", throwable.getMessage()); log.error("打印条码服务调用失败:{}", throwable.getMessage());
return new RemotePrinterService() { return new RemotePrinterService() {
@Override @Override
public R<?> printBarcodes(List<List<PrintContentVo>> printContents, String source) { public R<?> printBarcodes(PrinterVo printerVo, String source) {
throw new ServiceException("打印条码服务调用异常:" + throwable.getMessage()); throw new ServiceException("打印物料条码服务调用异常:" + throwable.getMessage());
} }
@Override @Override

@ -3,6 +3,7 @@ package com.hw.mes.controller;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.hw.common.core.constant.MesConstants;
import com.hw.common.security.annotation.InnerAuth; import com.hw.common.security.annotation.InnerAuth;
import com.hw.common.security.utils.SecurityUtils; import com.hw.common.security.utils.SecurityUtils;
import com.hw.mes.api.domain.MesBaseBarcodeInfo; import com.hw.mes.api.domain.MesBaseBarcodeInfo;
@ -112,14 +113,15 @@ public class MesBaseBarcodeInfoController extends BaseController
/** /**
* *
* @param barcodeIds * @param barcodeIds
* @return * @return
*/ */
@GetMapping(value = "/printBarcodes/{barcodeIds}") @GetMapping(value = "/printBarcodes/{barcodeIds}")
@RequiresPermissions("mes:barcode:printBarcodes")
public AjaxResult printBarcodes(@PathVariable Long[] barcodeIds) 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<MesBaseBarcodeInfo> 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));
}
} }

@ -72,11 +72,13 @@ public interface IMesBaseBarcodeInfoService
public int deleteMesBaseBarcodeInfoByBarcodeId(Long barcodeId); public int deleteMesBaseBarcodeInfoByBarcodeId(Long barcodeId);
/** /**
* *
*
* @param barcodeIds * @param barcodeIds
* @param printType 1 3
* @return * @return
*/ */
public int printBarcodes(Long[] barcodeIds); public int printBarcodes(Long[] barcodeIds,String printType);
/** /**
* () * ()

@ -23,9 +23,12 @@ import com.hw.mes.domain.MesOrderBind;
import com.hw.mes.domain.MesProductOrder; import com.hw.mes.domain.MesProductOrder;
import com.hw.mes.domain.vo.MesBindBarcodeVo; import com.hw.mes.domain.vo.MesBindBarcodeVo;
import com.hw.mes.mapper.*; import com.hw.mes.mapper.*;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import com.hw.printer.api.RemotePrinterService; import com.hw.printer.api.RemotePrinterService;
import com.hw.printer.api.domain.vo.PrintContentVo; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.hw.mes.service.IMesBaseBarcodeInfoService; 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)) { else if (mesBaseBarcodeInfo.getBarcodeType().equals(MesConstants.MES_BARCODE_TYPE_PRODUCT)) {
Date currentDate = new Date(); generateProductBarcode(mesBaseBarcodeInfo);
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);
}
} }
return 1; 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<MesBaseBarcodeInfo> 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) { public MesBaseBarcodeInfo getInsertedBarcodeInfo(MesBaseBarcodeInfo mesBaseBarcodeInfo, String batchCode, String userName, Date currentDate) {
MesBaseBarcodeInfo toInsertedBarcodeInfo = new MesBaseBarcodeInfo(); MesBaseBarcodeInfo toInsertedBarcodeInfo = new MesBaseBarcodeInfo();
//同一批次的批次代码相同 //同一批次的批次代码相同
@ -259,14 +279,15 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
} }
/** /**
* *
* *
* @param barcodeIds * @param barcodeIds
* @param printType 1 3
* @return * @return
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public int printBarcodes(Long[] barcodeIds) { public int printBarcodes(Long[] barcodeIds, String printType) {
//获取条码List //获取条码List
List<List<PrintContentVo>> printContents = new ArrayList<>(); List<List<PrintContentVo>> printContents = new ArrayList<>();
List<MesBaseBarcodeInfo> toUpdatedBaseBarcodeInfos = new ArrayList<>(); List<MesBaseBarcodeInfo> toUpdatedBaseBarcodeInfos = new ArrayList<>();
@ -278,67 +299,94 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
throw new ServiceException("此物料条码[" + mesBaseBarcodeInfo.getBarcodeInfo() + "]已经打印过,不能重复打印"); throw new ServiceException("此物料条码[" + mesBaseBarcodeInfo.getBarcodeInfo() + "]已经打印过,不能重复打印");
} }
String materialName = mesBaseBarcodeInfo.getMaterialName();
List<PrintContentVo> printContentVos = new ArrayList<>(); List<PrintContentVo> 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(); PrintContentVo printMaterialCode = new PrintContentVo();
printMaterialCode.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_MATERIAL_CODE); printMaterialCode.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_MATERIAL_CODE);
printMaterialCode.setValue(mesBaseBarcodeInfo.getMaterialCode()); printMaterialCode.setValue(mesBaseBarcodeInfo.getMaterialCode());
printMaterialCode.setType(PrintContentVo.TYPE_TEXT); 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(); PrintContentVo printPreMaterial = new PrintContentVo();
// if (mesBaseBarcodeInfo.getBindFlag() == null) { // 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(); PrintContentVo printSaleOrderCode = new PrintContentVo();
printSaleOrderCode.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_SALE_ORDER_CODE); printSaleOrderCode.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_SALE_ORDER_CODE);
printSaleOrderCode.setValue(mesBaseBarcodeInfo.getSaleorderCode()); printSaleOrderCode.setValue(mesBaseBarcodeInfo.getSaleorderCode());
printSaleOrderCode.setType(PrintContentVo.TYPE_TEXT); 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(); PrintContentVo printBarCode = new PrintContentVo();
printBarCode.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_QRCODE); printBarCode.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_QRCODE);
printBarCode.setValue(mesBaseBarcodeInfo.getBarcodeInfo()); printBarCode.setValue(mesBaseBarcodeInfo.getBarcodeInfo());
printBarCode.setType(PrintContentVo.TYPE_QRCODE); 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(printMaterialCode);
printContentVos.add(printPoNo);
printContentVos.add(printPreMaterial); printContentVos.add(printPreMaterial);
printContentVos.add(printMaterialSpec);
printContentVos.add(printSaleOrderCode); printContentVos.add(printSaleOrderCode);
printContentVos.add(printQty);
printContentVos.add(printBatchCode);
printContentVos.add(printBarCode); printContentVos.add(printBarCode);
String checkStatus = mesBaseBarcodeInfo.getCheckStatus() == null ? "" : mesBaseBarcodeInfo.getCheckStatus(); String checkStatus = mesBaseBarcodeInfo.getCheckStatus() == null ? "" : mesBaseBarcodeInfo.getCheckStatus();
@ -367,8 +415,12 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
this.updateMesBaseBarcodeInfo(toUpdateMesBaseBarcodeInfo); 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) {//抛出异常,回滚事务 if (printResultR.getCode() != Constants.SUCCESS) {//抛出异常,回滚事务
throw new RuntimeException(printResultR.getMsg()); throw new RuntimeException(printResultR.getMsg());
} }
@ -532,14 +584,21 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
/** /**
* *
*
* @param mesBaseBarcodeInfo * @param mesBaseBarcodeInfo
* @return * @return
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public int regenerateBarcode(MesBaseBarcodeInfo mesBaseBarcodeInfo) { public int regenerateBarcode(MesBaseBarcodeInfo mesBaseBarcodeInfo) {
String barcodeType = mesBaseBarcodeInfo.getBarcodeType();
String oldBarcode = mesBaseBarcodeInfo.getBarcodeInfo(); 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(); String userName = SecurityUtils.getUsername();
Date currentDate = new Date(); Date currentDate = new Date();
@ -557,7 +616,6 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
mesBaseBarcodeInfo.setUpdateTime(currentDate); mesBaseBarcodeInfo.setUpdateTime(currentDate);
return mesBaseBarcodeInfoMapper.updateMesBaseBarcodeInfo(mesBaseBarcodeInfo); return mesBaseBarcodeInfoMapper.updateMesBaseBarcodeInfo(mesBaseBarcodeInfo);
} }
} }

@ -209,6 +209,7 @@
<el-row> <el-row>
<el-button type="primary">首页</el-button> <el-button type="primary">首页</el-button>
<el-button type="success" @click="handleProductInstock"></el-button> <el-button type="success" @click="handleProductInstock"></el-button>
<el-button type="warning" @click="connectSerial"></el-button>
<!--el-button type="info">最小化</el-button--> <!--el-button type="info">最小化</el-button-->
<el-button type="danger" @click="logout">退</el-button> <el-button type="danger" @click="logout">退</el-button>
</el-row> </el-row>
@ -420,6 +421,14 @@ export default {
}, },
data() { data() {
return { return {
serialPort: null,
reader: null,
lastScannedBarcode: '',
decoder: new TextDecoder(),
returnModelVisible: false, returnModelVisible: false,
returnModelForm:{}, returnModelForm:{},
WarehousesList:[], WarehousesList:[],
@ -473,14 +482,14 @@ export default {
} }
}, },
mounted() { mounted() {
setInterval(() => { // setInterval(() => {
this.$notify.info({ // this.$notify.info({
title: '通知', // title: '',
message: '通知公告', // message: '',
position: 'bottom-right', // position: 'bottom-right',
duration: 0 // duration: 0
}); // });
}, 60 * 1000) // }, 60 * 1000)
getProductPlans({pageNum: 1, pageSize: 5}).then(e => { getProductPlans({pageNum: 1, pageSize: 5}).then(e => {
this.tableData = e.rows this.tableData = e.rows
this.totalNum1 = Math.ceil(e.total / 5) 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: { 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() { async logout() {
this.$confirm('确定注销并退出系统吗?', '提示', { this.$confirm('确定注销并退出系统吗?', '提示', {
@ -850,7 +924,6 @@ export default {
this.getStockTotal(); this.getStockTotal();
}, },
print(val) { print(val) {
console.log(val)
this.PrintData = val this.PrintData = val
this.printModel = true this.printModel = true
}, },

@ -109,7 +109,7 @@ export default {
floorData: [ floorData: [
{ {
floor: 1, floor: 1,
processId: 1, processId: 11,
route: '/board/firstFloor' route: '/board/firstFloor'
}, },
{ {

@ -46,45 +46,25 @@
size="mini" size="mini"
type="primary" type="primary"
@click="handleAdd" @click="handleAdd"
>新增 v-if = "addBarcodeBtnVisible"
>新增条码
</el-button> </el-button>
</el-col> </el-col>
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="success"-->
<!-- plain-->
<!-- icon="el-icon-edit"-->
<!-- size="mini"-->
<!-- :disabled="single"-->
<!-- @click="handleUpdate"-->
<!-- v-hasPermi="['mes:barcode:edit']"-->
<!-- >修改-->
<!-- </el-button>-->
<!-- </el-col>-->
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
v-hasPermi="['mes:barcode:remove']" type="warning"
:disabled="multiple"
icon="el-icon-delete"
plain plain
icon="el-icon-printer"
size="mini" size="mini"
type="danger" @click="handlePrintBarcodes"
@click="handleDelete" :disabled="batchPrintBtnDisabled"
>删除 v-hasPermi="['mes:barcode:printProductBarcodes']"
>打印
</el-button> </el-button>
</el-col> </el-col>
<el-col :span="1.5">
<el-button <!--right-toolbar :columns="columns" :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar-->
v-hasPermi="['mes:barcode:export']"
icon="el-icon-download"
plain
size="mini"
type="warning"
@click="handleExport"
>导出
</el-button>
</el-col>
<right-toolbar :columns="columns" :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
<el-table v-loading="loading" :data="barcodeList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="barcodeList" @selection-change="handleSelectionChange">
@ -98,87 +78,48 @@
<el-table-column v-if="columns[17].visible" align="center" label="生产计划编号" prop="planCode" width="110"/> <el-table-column v-if="columns[17].visible" align="center" label="生产计划编号" prop="planCode" width="110"/>
<el-table-column v-if="columns[20].visible" align="center" label="销售订单编号" prop="saleorderCode" width="110"/> <el-table-column v-if="columns[20].visible" align="center" label="销售订单编号" prop="saleorderCode" width="110"/>
<el-table-column v-if="columns[13].visible" align="center" label="采购订单号" prop="poNo" width="100"/> <el-table-column v-if="columns[13].visible" align="center" label="采购订单号" prop="poNo" width="100"/>
<el-table-column v-if="columns[6].visible" align="center" label="批次代码" prop="batchCode" width="100"/>
<el-table-column v-if="columns[5].visible" align="center" label="条码内容" prop="barcodeInfo" width="100"/> <el-table-column v-if="columns[5].visible" align="center" label="条码内容" prop="barcodeInfo" width="100"/>
<el-table-column v-if="columns[3].visible" align="center" label="批次标识" prop="batchFlag"> <el-table-column v-if="columns[8].visible" align="center" label="物料名称" prop="materialName" width="100"/>
<el-table-column label="打印标识" align="center" prop="printFlag">
<template slot-scope="scope"> <template slot-scope="scope">
<dict-tag :options="dict.type.active_flag" :value="scope.row.batchFlag"/> <dict-tag :options="dict.type.mes_print_flag" :value="scope.row.printFlag"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column v-if="columns[8].visible" align="center" label="物料名称" prop="materialName" width="100"/>
<el-table-column v-if="columns[9].visible" align="center" label="供应商ID" prop="manufacturerId"/>
<el-table-column v-if="columns[10].visible" align="center" label="数量" prop="amount"/>
<el-table-column v-if="columns[14].visible" align="center" label="生产日期" prop="productionDate" width="180"> <el-table-column v-if="columns[14].visible" align="center" label="生产日期" prop="productionDate" width="180">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ parseTime(scope.row.productionDate, '{y}-{m}-{d} {h}:{i}:{s}') }}</span> <span>{{ parseTime(scope.row.productionDate, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column v-if="columns[15].visible" align="center" label="接受日期" prop="acceptedDate" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.acceptedDate, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template>
</el-table-column>
<el-table-column v-if="columns[16].visible" align="center" label="最晚出库日期" prop="lastOutstockDate" width="180"> <el-table-column v-if="columns[16].visible" align="center" label="最晚出库日期" prop="lastOutstockDate" width="180">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ parseTime(scope.row.lastOutstockDate, '{y}-{m}-{d} {h}:{i}:{s}') }}</span> <span>{{ parseTime(scope.row.lastOutstockDate, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column v-if="columns[7].visible" align="center" label="托盘RFID代码" prop="palletInfoCode" width="110"/>
<el-table-column v-if="columns[11].visible" align="center" label="打印机台名称" prop="machineName" width="110"/>
<el-table-column v-if="columns[12].visible" align="center" label="打印次数" prop="printNumber"/>
<el-table-column v-if="columns[2].visible" align="center" label="打印人" prop="printPerson"/>
<el-table-column v-if="columns[1].visible" align="center" label="打印时间" prop="printTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.printTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template>
</el-table-column>
<el-table-column v-if="columns[18].visible" align="center" label="生产计划明细编号" prop="planDetailCode"/> <el-table-column v-if="columns[18].visible" align="center" label="生产计划明细编号" prop="planDetailCode"/>
<el-table-column v-if="columns[19].visible" align="center" label="销售订单ID" prop="saleOrderId"/> <el-table-column v-if="columns[19].visible" align="center" label="销售订单ID" prop="saleOrderId"/>
<el-table-column v-if="columns[21].visible" align="center" label="项目号" prop="projectNo"/> <el-table-column v-if="columns[21].visible" align="center" label="项目号" prop="projectNo"/>
<el-table-column v-if="columns[22].visible" align="center" label="流水号" prop="serialNumber"/>
<el-table-column v-if="columns[23].visible" align="center" label="备注" prop="remark"/> <el-table-column v-if="columns[23].visible" align="center" label="备注" prop="remark"/>
<el-table-column v-if="columns[24].visible" align="center" label="绑定状态" prop="bindStatus">
<template slot-scope="scope">
<dict-tag :options="dict.type.bind_status" :value="scope.row.bindStatus"/>
</template>
</el-table-column>
<el-table-column v-if="columns[25].visible" align="center" label="绑定托盘的人" prop="bindBy" width="110"/>
<el-table-column v-if="columns[26].visible" align="center" label="绑定托盘时间" prop="bindTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.bindTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template>
</el-table-column>
<el-table-column v-if="columns[27].visible" align="center" label="更新人" prop="updateBy"/>
<el-table-column v-if="columns[28].visible" align="center" label="更新时间" prop="updateTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template>
</el-table-column>
<el-table-column align="center" class-name="small-padding fixed-width" fixed="right" label="操作"> <el-table-column align="center" class-name="small-padding fixed-width" fixed="right" label="操作">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
icon="el-icon-printer"
size="mini" size="mini"
type="text" type="text"
@click="handlePrintBarCode(scope.row)" icon="el-icon-refresh"
@click="regenerateProductBarcode(scope.row)"
v-if="scope.row.printFlag ==='1'"
v-hasPermi="['mes:barcode:regenerateProductBarcode']"
>重新生成
</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-printer"
@click="handlePrintBarcodes(scope.row)"
v-if="scope.row.printFlag ==='0'"
v-hasPermi="['mes:barcode:printBarcode']"
>打印 >打印
</el-button> </el-button>
<!-- <el-button-->
<!-- size="mini"-->
<!-- type="text"-->
<!-- icon="el-icon-edit"-->
<!-- @click="handleUpdate(scope.row)"-->
<!-- v-hasPermi="['mes:barcode:edit']"-->
<!-- >修改-->
<!-- </el-button>-->
<!-- <el-button-->
<!-- size="mini"-->
<!-- type="text"-->
<!-- icon="el-icon-delete"-->
<!-- @click="handleDelete(scope.row)"-->
<!-- v-hasPermi="['mes:barcode:remove']"-->
<!-- >删除-->
<!-- </el-button>-->
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -195,8 +136,7 @@
<el-dialog :title="title" :visible.sync="open" append-to-body width="500px"> <el-dialog :title="title" :visible.sync="open" append-to-body width="500px">
<el-form ref="form" :model="form" :rules="rules" label-width="120px"> <el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-form-item label="生产计划编号" prop="planCode"> <el-form-item label="生产计划编号" prop="planCode">
<el-input v-model="form.planCode" placeholder="请点击右侧检索生产计划编号" readonly> <el-input v-model="form.planCode" :disabled = "true">
<el-button slot="append" icon="el-icon-search" @click="handleProductPlanAdd"></el-button>
</el-input> </el-input>
</el-form-item> </el-form-item>
<!-- <el-form-item label="销售订单编号" prop="saleorderCode">--> <!-- <el-form-item label="销售订单编号" prop="saleorderCode">-->
@ -230,7 +170,7 @@
<!-- <el-input v-model="form.manufacturerId" placeholder="请输入供应商ID" />--> <!-- <el-input v-model="form.manufacturerId" placeholder="请输入供应商ID" />-->
<!-- </el-form-item>--> <!-- </el-form-item>-->
<el-form-item label="数量" prop="amount"> <el-form-item label="数量" prop="amount">
<el-input-number v-model="form.amount" :min="0" placeholder="请输入数量"/> <el-input-number v-model="form.amount" :min="0" placeholder="请输入数量" :disabled="true"/>
</el-form-item> </el-form-item>
<el-form-item label="生产日期" prop="productionDate"> <el-form-item label="生产日期" prop="productionDate">
@ -299,12 +239,12 @@
</template> </template>
<script> <script>
import {listBarcode, getBarcode, delBarcode, addBarcode, updateBarcode, printBarCode} from "@/api/mes/barcode"; import {listProductBarcode, getBarcode, delBarcode, addProductBarcode, printProductBarcodes,regenerateProductBarcode} from "@/api/mes/barcode";
import addProductPlan from '@//views/mes/productplan/addProductPlan.vue'; import addProductPlan from '@//views/mes/productplan/addProductPlan.vue';
export default { export default {
name: "Barcode", name: "Barcode",
dicts: ['bind_status', 'active_flag', 'barcode_type'], dicts: ['bind_status', 'active_flag', 'barcode_type','mes_print_flag'],
components: { components: {
'add-ProductPlan': addProductPlan, 'add-ProductPlan': addProductPlan,
}, },
@ -411,9 +351,14 @@ export default {
{key: 27, label: `更新人`, visible: false}, {key: 27, label: `更新人`, visible: false},
{key: 28, label: `更新时间`, visible: false}, {key: 28, label: `更新时间`, visible: false},
], ],
addBarcodeBtnVisible: false,
batchPrintBtnDisabled: false,
}; };
}, },
created() { created() {
this.addBarcodeBtnVisible = false;
this.getData();
this.getList(); this.getList();
}, },
props: { props: {
@ -442,15 +387,24 @@ export default {
batchFlag:'0', batchFlag:'0',
barcodeType:'3', barcodeType:'3',
saleOrderId:null, saleOrderId:null,
amount :this.defineData.dispatchAmount,
dispatchAmount : this.defineData.dispatchAmount,
} }
this.queryParams.planCode = this.defineData.planCode;
}, },
/** 查询条码信息列表 */ /** 查询条码信息列表 */
getList() { getList() {
this.loading = true; this.loading = true;
listBarcode(this.queryParams).then(response => { listProductBarcode(this.queryParams).then(response => {
this.barcodeList = response.rows; this.barcodeList = response.rows;
this.total = response.total; this.total = response.total;
if(this.total && this.total >0){
this.addBarcodeBtnVisible = true;
}else{
this.addBarcodeBtnVisible = true;
}
this.loading = false; this.loading = false;
}); });
}, },
@ -539,12 +493,26 @@ export default {
}, },
/** 打印条码按钮操作 */ /** 打印条码按钮操作 */
handlePrintBarCode(row) { handlePrintBarcodes(row) {
const barcodeIds = row.barcodeId || this.ids; const barcodeIds = row.barcodeId || this.ids;
printBarCode(barcodeIds).then(response => {
if (barcodeIds == null || barcodeIds == '') {
this.$modal.msgWarning("请选择要打印的物料条码");
return;
}
if (row.printFlag) {
row.printFlag = '1';
} else {
this.batchPrintBtnDisabled = true;
}
printProductBarcodes(barcodeIds).then(response => {
this.$modal.msgSuccess("打印条码成功"); this.$modal.msgSuccess("打印条码成功");
this.getList();
this.batchPrintBtnDisabled = false;
}).catch(() => { }).catch(() => {
this.batchPrintBtnDisabled = false;
}); });
}, },
/** 新增销售订单按钮操作 */ /** 新增销售订单按钮操作 */
@ -565,19 +533,11 @@ export default {
submitForm() { submitForm() {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
if (this.form.barcodeId != null) { addProductBarcode(this.form).then(response => {
updateBarcode(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addBarcode(this.form).then(response => {
this.$modal.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
}
} }
}); });
}, },
@ -598,7 +558,23 @@ export default {
this.download('mes/barcode/export', { this.download('mes/barcode/export', {
...this.queryParams ...this.queryParams
}, `barcode_${new Date().getTime()}.xlsx`) }, `barcode_${new Date().getTime()}.xlsx`)
} },
//
regenerateProductBarcode(row) {
const barcodeId = row.barcodeId;
const barcodeInfo = row.barcodeInfo;
const barcodeType = row.barcodeType;
this.$modal.confirm('重新生成后之前的条码将会作废,是否确认重新生成条码内容为"' + barcodeInfo + '"的数据项?').then(function () {
return regenerateProductBarcode({"barcodeId": barcodeId, "barcodeInfo": barcodeInfo, "barcodeType": barcodeType});
}).then(() => {
this.getList();
this.$modal.msgSuccess("重新生成成功");
}).catch(() => {
});
},
} }
}; };
</script> </script>

@ -83,7 +83,7 @@
size="mini" size="mini"
@click="handlePrintBarcodes" @click="handlePrintBarcodes"
:disabled="batchPrintBtnDisabled" :disabled="batchPrintBtnDisabled"
v-hasPermi="['mes:barcode:print']" v-hasPermi="['mes:barcode:printBarcode']"
>打印 >打印
</el-button> </el-button>
</el-col> </el-col>
@ -180,7 +180,7 @@
icon="el-icon-refresh" icon="el-icon-refresh"
@click="regenerateBarcode(scope.row)" @click="regenerateBarcode(scope.row)"
v-if="scope.row.printFlag ==='1'" v-if="scope.row.printFlag ==='1'"
v-hasPermi="['mes:barcode:print']" v-hasPermi="['mes:barcode:regenerate']"
>重新生成 >重新生成
</el-button> </el-button>
<el-button <el-button
@ -189,7 +189,7 @@
icon="el-icon-printer" icon="el-icon-printer"
@click="handlePrintBarcodes(scope.row)" @click="handlePrintBarcodes(scope.row)"
v-if="scope.row.printFlag ==='0'" v-if="scope.row.printFlag ==='0'"
v-hasPermi="['mes:barcode:print']" v-hasPermi="['mes:barcode:printBarcode']"
>打印 >打印
</el-button> </el-button>
<!-- <el-button--> <!-- <el-button-->
@ -705,7 +705,7 @@ export default {
this.getList(); this.getList();
this.batchPrintBtnDisabled = false; this.batchPrintBtnDisabled = false;
}).catch(() => { }).catch(() => {
this.batchPrintBtnDisabled = false;
}); });
}, },
@ -713,9 +713,10 @@ export default {
regenerateBarcode(row) { regenerateBarcode(row) {
const barcodeId = row.barcodeId; const barcodeId = row.barcodeId;
const barcodeInfo = row.barcodeInfo; const barcodeInfo = row.barcodeInfo;
const barcodeType = row.barcodeType;
this.$modal.confirm('重新生成后之前的条码将会作废,是否确认重新生成条码内容为"' + barcodeInfo + '"的数据项?').then(function () { this.$modal.confirm('重新生成后之前的条码将会作废,是否确认重新生成条码内容为"' + barcodeInfo + '"的数据项?').then(function () {
return regenerateBarcode({"barcodeId": barcodeId, "barcodeInfo": barcodeInfo}); return regenerateBarcode({"barcodeId": barcodeId, "barcodeInfo": barcodeInfo, "barcodeType": barcodeType});
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.$modal.msgSuccess("重新生成成功"); this.$modal.msgSuccess("重新生成成功");

Loading…
Cancel
Save