WMS:打印库位条码和打印料箱条码功能
master
xs 1 year ago
parent fc7f75b007
commit 9450afa74c

@ -4,6 +4,7 @@ import com.hw.common.core.constant.SecurityConstants;
import com.hw.common.core.constant.ServiceNameConstants; 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.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.*;
@ -23,7 +24,15 @@ public interface RemotePrinterService {
public MesBaseBarcodeInfo printBarCode(@RequestBody MesBaseBarcodeInfo barcodeInfo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); public MesBaseBarcodeInfo printBarCode(@RequestBody MesBaseBarcodeInfo barcodeInfo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
/**
*
*
* @param printContentVo
* @param source
* @return
*/
@PostMapping("/printService/printLocationLabel")
public R<?> printLocationLabel(@RequestBody PrintContentVo printContentVo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
} }

@ -0,0 +1,13 @@
package com.hw.printer.api.domain.vo;
import lombok.Data;
import java.util.HashMap;
@Data
public class PrintContentVo {
private String templatePath;
private HashMap<String,String> params;
}

@ -5,6 +5,7 @@ import com.hw.common.core.domain.R;
import com.hw.common.core.exception.ServiceException; import com.hw.common.core.exception.ServiceException;
import com.hw.printer.api.RemotePrinterService; import com.hw.printer.api.RemotePrinterService;
import com.hw.mes.api.domain.MesBaseBarcodeInfo; import com.hw.mes.api.domain.MesBaseBarcodeInfo;
import com.hw.printer.api.domain.vo.PrintContentVo;
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;
@ -27,6 +28,11 @@ public class RemotePrinterFallbackFactory implements FallbackFactory<RemotePrint
public MesBaseBarcodeInfo printBarCode(MesBaseBarcodeInfo barcodeInfo, String source) { public MesBaseBarcodeInfo printBarCode(MesBaseBarcodeInfo barcodeInfo, String source) {
throw new ServiceException("打印条码服务调用异常:" + throwable.getMessage()); throw new ServiceException("打印条码服务调用异常:" + throwable.getMessage());
} }
@Override
public R<?> printLocationLabel(PrintContentVo printContentVo, String source) {
throw new ServiceException("打印库位条码服务调用异常:" + throwable.getMessage());
}
}; };
} }
} }

@ -129,4 +129,8 @@ public enum BusinessType
*/ */
CHECK, CHECK,
/**
*
*/
PRINT,
} }

@ -2,14 +2,14 @@ package com.hw.printer.controller;
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.service.IPrinterService; import com.hw.printer.service.IPrinterService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import java.util.HashMap;
import org.springframework.web.bind.annotation.RestController;
/** /**
* *
@ -25,7 +25,7 @@ public class PrinterController {
private IPrinterService printerService; private IPrinterService printerService;
/** /**
* *
* @param barcodeInfo * @param barcodeInfo
* @return * @return
*/ */
@ -39,4 +39,21 @@ public class PrinterController {
} }
} }
/**
*
* @param printContentVo
* @return
*/
@PostMapping("/printLocationLabel")
public R<?> printLocationLabel(@RequestBody PrintContentVo printContentVo) {
try {
printerService.printLocationLabel(printContentVo.getParams());
return R.ok();
} catch (Exception e) {
log.error("打印条码失败", e);
return R.fail(e.getMessage());
}
}
} }

@ -1,6 +1,9 @@
package com.hw.printer.service; package com.hw.printer.service;
import com.hw.mes.api.domain.MesBaseBarcodeInfo; import com.hw.mes.api.domain.MesBaseBarcodeInfo;
import com.hw.printer.utils.HwPrintUtil;
import java.util.HashMap;
/** /**
* *
@ -16,4 +19,12 @@ public interface IPrinterService {
* @throws Exception * @throws Exception
*/ */
MesBaseBarcodeInfo printBarCode(MesBaseBarcodeInfo barcodeInfo) throws Exception; MesBaseBarcodeInfo printBarCode(MesBaseBarcodeInfo barcodeInfo) throws Exception;
/**
*
* @param params
* @return
*/
public void printLocationLabel(HashMap<String, String> params);
} }

@ -24,17 +24,44 @@ public class PrinterServiceImpl implements IPrinterService {
public String localPrintPath; public String localPrintPath;
/** /**
* PDF * PDF
*/ */
@Value("${print.pdfTemplatePath}") @Value("${print.pdfTemplatePath}")
public String pdfTemplatePath; public String pdfTemplatePath;
/** /**
* PDF * PDF
*/ */
@Value("${print.generatePath}") @Value("${print.generatePath}")
public String generatePath; public String generatePath;
/**
* PDF
*/
@Value("${print.productLabelTemplatePath}")
public String productLabelTemplatePath;
/**
* PDF
*/
@Value("${print.generateProductLabelPath}")
public String generateProductLabelPath;
/**
* PDF
*/
@Value("${print.locationLabelTemplatePath}")
public String locationLabelTemplatePath;
/**
* PDF
*/
@Value("${print.generateLocationLabelPath}")
public String generateLocationLabelPath;
/** /**
* *
* *
@ -58,4 +85,16 @@ public class PrinterServiceImpl implements IPrinterService {
} }
/**
*
* @param params
* @return
*/
@Override
public void printLocationLabel(HashMap<String, String> params) {
HwPrintUtil.printLocationQRCode(localPrintPath, locationLabelTemplatePath,
generateLocationLabelPath, params);
}
} }

@ -15,6 +15,7 @@ import javax.print.*;
import java.awt.print.*; import java.awt.print.*;
import java.io.*; import java.io.*;
import java.util.HashMap; import java.util.HashMap;
import java.util.Set;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -30,20 +31,6 @@ public class HwPrintUtil {
private static final Logger log = LoggerFactory.getLogger(HwPrintUtil.class); private static final Logger log = LoggerFactory.getLogger(HwPrintUtil.class);
/**
*
*/
public static String localPrintPath;
/**
* PDF
*/
public static String pdfTemplatePath;
/**
* PDF
*/
public static String generatePath;
/** /**
* List * List
@ -55,6 +42,33 @@ public class HwPrintUtil {
*/ */
private static PrintService printService = null; private static PrintService printService = null;
/**
* PDF
* WPS PDF
* OneNote 2013
* Microsoft XPS Document Writer
* Microsoft Print to PDF
* Fax
* \\10.11.43.159\HP LaserJet MFP M129-M134
* \\10.11.43.159\HP Laser NS 1020
*/
public static void initPrintService(String localPrintPath) {
// localPrintPath = "导出";
// localPrintPath = "ZD";
for (PrintService service : printServices) {
System.out.println(service.getName());
if (service.getName().contains(localPrintPath)) {
printService = service;
break;
}
}
if (printService == null) {
throw new ServiceException("打印机配置错误!");
}
}
/** /**
* *
*/ */
@ -72,15 +86,15 @@ public class HwPrintUtil {
*/ */
public static String printBarCode(HashMap<String, String> params) { public static String printBarCode(HashMap<String, String> params) {
//解析参数生成打印图片 //解析参数生成打印图片
localPrintPath = params.get("localPrintPath"); String localPrintPath = params.get("localPrintPath");
pdfTemplatePath = params.get("pdfTemplatePath"); String pdfTemplatePath = params.get("pdfTemplatePath");
generatePath = params.get("generatePath"); String generatePath = params.get("generatePath");
String barcodeInfo = params.get("barcodeInfo"); String barcodeInfo = params.get("barcodeInfo");
String batchCode = params.get("batchCode"); String batchCode = params.get("batchCode");
String materialName = params.get("materialName"); String materialName = params.get("materialName");
String date = params.get("date"); String date = params.get("date");
initPrintService(); initPrintService(localPrintPath);
File outputFile = printQRCode(barcodeInfo, batchCode, materialName, date); File outputFile = printQRCode(barcodeInfo, batchCode, materialName, date,pdfTemplatePath,generatePath);
try { try {
printPdf(outputFile); printPdf(outputFile);
log.info("打印条码printBarCode方法,条码内容:" + barcodeInfo); log.info("打印条码printBarCode方法,条码内容:" + barcodeInfo);
@ -100,7 +114,7 @@ public class HwPrintUtil {
* @param date * @param date
* @return PDF * @return PDF
*/ */
public static File printQRCode(String barcodeInfo, String batchCode, String materialName, String date) { public static File printQRCode(String barcodeInfo, String batchCode, String materialName, String date,String pdfTemplatePath,String generatePath) {
try { try {
// 生成PDF文件 // 生成PDF文件
File generateFile = new File(generatePath); File generateFile = new File(generatePath);
@ -160,7 +174,7 @@ public class HwPrintUtil {
* @param date * @param date
* @return PDF * @return PDF
*/ */
public static File printBarCode(String barcodeInfo, String batchCode, String materialName, String date) { public static File printBarCode(String barcodeInfo, String batchCode, String materialName, String date,String pdfTemplatePath,String generatePath) {
try { try {
// 生成PDF文件 // 生成PDF文件
File generateFile = new File(generatePath); File generateFile = new File(generatePath);
@ -256,26 +270,166 @@ public class HwPrintUtil {
} }
} }
/** /**
* PDF *
* WPS PDF *
* OneNote 2013 * @param params
* Microsoft XPS Document Writer * @return
* Microsoft Print to PDF
* Fax
* \\10.11.43.159\HP LaserJet MFP M129-M134
* \\10.11.43.159\HP Laser NS 1020
*/ */
public static void initPrintService() { public static String printLocationQRCode(String localPrintPath, String locationLabelTemplatePath,
for (PrintService service : printServices) { String generateLocationLabelPath,
System.out.println(service.getName()); HashMap<String, String> params) {
if (service.getName().contains(localPrintPath)) { //解析参数生成打印图片
printService = service; String qrCode = params.get("qrCode");
break; initPrintService(localPrintPath);
File outputFile = printLocationLabelContent(params,locationLabelTemplatePath,generateLocationLabelPath);
try {
printQRPdf(outputFile);
log.info("打印条码,条码内容:" + qrCode);
return localPrintPath;
} catch (Exception e) {
log.error("打印条码[" + qrCode + "]异常:" + e);
throw new ServiceException("打印条码[" + qrCode + "]异常:" + e);
} }
} }
if (printService == null) {
throw new ServiceException("打印机配置错误!");
/**
*
*
* @param params
* @return
*/
public static File printLocationLabelContent(HashMap<String, String> params,String locationLabelTemplatePath,String generateLocationLabelPath) {
try {
// 生成PDF文件
File generateFile = new File(generateLocationLabelPath);
FileOutputStream out = new FileOutputStream(generateFile);
// 打印模板PDF
PdfReader reader = new PdfReader(locationLabelTemplatePath);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
// 修改PDF文档的PdfStamper实例将修改后的内容输出到内存中的字节数组
PdfStamper stamper = new PdfStamper(reader, bos);
// 动态地将变量的值填充到PDF表单相应字段
AcroFields form = stamper.getAcroFields();
form.setField("text", params.get("text"));
String qrCode = params.get("qrCode");
//获取位置(左上右下)
AcroFields.FieldPosition fieldPosition = form.getFieldPositions("qrcode").get(0);
// 绘制二维码
float width = fieldPosition.position.getRight() - fieldPosition.position.getLeft();
float height = fieldPosition.position.getTop() - fieldPosition.position.getBottom();
BarcodeQRCode pdf417 = new BarcodeQRCode(qrCode, (int) width, (int) width, null);
// 生成二维码图像
Image image128 = pdf417.getImage();
//而PDF的标准单位是点pt。1点等于1/72英寸,1英寸等于2.54厘米大约1点等于0.03527厘米
// System.out.println("left:" + fieldPosition.position.getLeft()
// + "right:" + fieldPosition.position.getRight()
// + "top:" + fieldPosition.position.getTop()
// + "bottom:" + fieldPosition.position.getBottom()
// + "width:" + width
// + "height:" + height
//
// );
// 条码位置
image128.setAbsolutePosition(fieldPosition.position.getLeft(),
fieldPosition.position.getBottom()-15);
// 获取PDF的第一页
PdfContentByte cb = stamper.getOverContent(1);
cb.addImage(image128);
// 设置表单不可编辑即将表单字段内容固定到PDF中
stamper.setFormFlattening(true);
// 关闭PdfStamper
stamper.close();
// 创建一个新的文档对象
Document doc = new Document();
// 创建 PdfCopy 对象,关联到输出流
PdfCopy copy = new PdfCopy(doc, out);
// 打开文档
doc.open();
// 从内存中的字节数组创建一个 PdfImportedPage 对象
PdfImportedPage importPage = copy.getImportedPage(new PdfReader(bos.toByteArray()), 1);
// 将导入的页面添加到新文档中
copy.addPage(importPage);
// 关闭文档
doc.close();
return generateFile;
} catch (Exception e) {
log.error("打印条码生成PDF异常" + e);
}
return null;
}
/**
* PDF
*
* @param pdfFile PDF
* @throws IOException PDF
*/
private static void printQRPdf(File pdfFile) throws IOException {
PDDocument document = null;
try {
// 定义毫米到英寸的转换系数
double mmToInch = 1 / 25.4;
// 定义英寸到点的转换系数
double inchToPoint = 72;
// 定义纸张尺寸(单位:毫米)
double paperWidthMm = 40;
double paperHeightMm = 30;
// 将纸张尺寸转换为点
double paperWidthPoints = paperWidthMm * mmToInch * inchToPoint;
double paperHeightPoints = paperHeightMm * mmToInch * inchToPoint;
document = PDDocument.load(pdfFile);
//打印的页面的大小和方向
PageFormat pageFormat = new PageFormat();
//设置打印方向 PORTRAIT 竖向 REVERSE_LANDSCAPE 横向
pageFormat.setOrientation(PageFormat.PORTRAIT);
Paper paper = new Paper();
// 纸的大小
paper.setSize(paperWidthPoints, paperHeightPoints);
// Print 区域
paper.setImageableArea(0, 0, paper.getWidth(), paper.getHeight());
pageFormat.setPaper(paper);
Book book = new Book();
PDFPrintable printable = new PDFPrintable(document, Scaling.SCALE_TO_FIT);
book.append(printable, pageFormat, document.getNumberOfPages());
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintService(printService);
job.setPageable(book);
job.defaultPage();
try {
job.print();
} catch (PrinterException e) {
throw new IOException("PDF打印失败:", e);
}
} catch (PrinterException e) {
throw new ServiceException("打印机服务错误:" + e);
} finally {
if (document != null) {
try {
document.close();
} catch (IOException e) {
// 处理关闭文档时可能出现的异常
e.printStackTrace();
} }
} }
}
}
} }

@ -34,8 +34,7 @@ import com.hw.common.core.web.page.TableDataInfo;
*/ */
@RestController @RestController
@RequestMapping("/wmslocation") @RequestMapping("/wmslocation")
public class WmsBaseLocationController extends BaseController public class WmsBaseLocationController extends BaseController {
{
@Autowired @Autowired
private IWmsBaseLocationService wmsBaseLocationService; private IWmsBaseLocationService wmsBaseLocationService;
@ -47,8 +46,7 @@ public class WmsBaseLocationController extends BaseController
*/ */
@RequiresPermissions("wms:wmslocation:list") @RequiresPermissions("wms:wmslocation:list")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(WmsBaseLocation wmsBaseLocation) public TableDataInfo list(WmsBaseLocation wmsBaseLocation) {
{
startPage(); startPage();
List<WmsBaseLocation> list = wmsBaseLocationService.selectWmsBaseLocationJoinList(wmsBaseLocation); List<WmsBaseLocation> list = wmsBaseLocationService.selectWmsBaseLocationJoinList(wmsBaseLocation);
return getDataTable(list); return getDataTable(list);
@ -60,8 +58,7 @@ public class WmsBaseLocationController extends BaseController
@RequiresPermissions("wms:wmslocation:export") @RequiresPermissions("wms:wmslocation:export")
@Log(title = "库位", businessType = BusinessType.EXPORT) @Log(title = "库位", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, WmsBaseLocation wmsBaseLocation) public void export(HttpServletResponse response, WmsBaseLocation wmsBaseLocation) {
{
List<WmsBaseLocation> list = wmsBaseLocationService.selectWmsBaseLocationJoinList(wmsBaseLocation); List<WmsBaseLocation> list = wmsBaseLocationService.selectWmsBaseLocationJoinList(wmsBaseLocation);
ExcelUtil<WmsBaseLocation> util = new ExcelUtil<WmsBaseLocation>(WmsBaseLocation.class); ExcelUtil<WmsBaseLocation> util = new ExcelUtil<WmsBaseLocation>(WmsBaseLocation.class);
util.exportExcel(response, list, "库位数据"); util.exportExcel(response, list, "库位数据");
@ -72,8 +69,7 @@ public class WmsBaseLocationController extends BaseController
*/ */
@RequiresPermissions("wms:wmslocation:query") @RequiresPermissions("wms:wmslocation:query")
@GetMapping(value = "/{locationId}") @GetMapping(value = "/{locationId}")
public AjaxResult getInfo(@PathVariable("locationId") Long locationId) public AjaxResult getInfo(@PathVariable("locationId") Long locationId) {
{
return success(wmsBaseLocationService.selectWmsBaseLocationByLocationId(locationId)); return success(wmsBaseLocationService.selectWmsBaseLocationByLocationId(locationId));
} }
@ -83,8 +79,7 @@ public class WmsBaseLocationController extends BaseController
@RequiresPermissions("wms:wmslocation:add") @RequiresPermissions("wms:wmslocation:add")
@Log(title = "库位", businessType = BusinessType.INSERT) @Log(title = "库位", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody WmsBaseLocation wmsBaseLocation) public AjaxResult add(@RequestBody WmsBaseLocation wmsBaseLocation) {
{
return toAjax(wmsBaseLocationService.insertWmsBaseLocation(wmsBaseLocation)); return toAjax(wmsBaseLocationService.insertWmsBaseLocation(wmsBaseLocation));
} }
@ -94,8 +89,7 @@ public class WmsBaseLocationController extends BaseController
@RequiresPermissions("wms:wmslocation:edit") @RequiresPermissions("wms:wmslocation:edit")
@Log(title = "库位", businessType = BusinessType.UPDATE) @Log(title = "库位", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody WmsBaseLocation wmsBaseLocation) public AjaxResult edit(@RequestBody WmsBaseLocation wmsBaseLocation) {
{
return toAjax(wmsBaseLocationService.updateWmsBaseLocation(wmsBaseLocation)); return toAjax(wmsBaseLocationService.updateWmsBaseLocation(wmsBaseLocation));
} }
@ -105,16 +99,14 @@ public class WmsBaseLocationController extends BaseController
@RequiresPermissions("wms:wmslocation:remove") @RequiresPermissions("wms:wmslocation:remove")
@Log(title = "库位", businessType = BusinessType.DELETE) @Log(title = "库位", businessType = BusinessType.DELETE)
@DeleteMapping("/{locationIds}") @DeleteMapping("/{locationIds}")
public AjaxResult remove(@PathVariable Long[] locationIds) public AjaxResult remove(@PathVariable Long[] locationIds) {
{
return toAjax(wmsBaseLocationService.deleteWmsBaseLocationByLocationIds(locationIds)); return toAjax(wmsBaseLocationService.deleteWmsBaseLocationByLocationIds(locationIds));
} }
@RequiresPermissions("wms:wmslocation:list") @RequiresPermissions("wms:wmslocation:list")
@GetMapping("/getWarehouses") @GetMapping("/getWarehouses")
public AjaxResult list(WmsBaseWarehouse wmsBaseWarehouse) public AjaxResult list(WmsBaseWarehouse wmsBaseWarehouse) {
{
wmsBaseWarehouse.setActiveFlag(WmsConstants.WMS_WAREHOUSE_ACTIVE_FLAG_YES); wmsBaseWarehouse.setActiveFlag(WmsConstants.WMS_WAREHOUSE_ACTIVE_FLAG_YES);
List<WmsBaseWarehouse> list = wmsBaseWarehouseService.selectWmsBaseWarehouseList(wmsBaseWarehouse); List<WmsBaseWarehouse> list = wmsBaseWarehouseService.selectWmsBaseWarehouseList(wmsBaseWarehouse);
return success(list); return success(list);
@ -127,8 +119,7 @@ public class WmsBaseLocationController extends BaseController
@RequiresPermissions("wms:wmslocation:lock") @RequiresPermissions("wms:wmslocation:lock")
@Log(title = "库位", businessType = BusinessType.LOCK) @Log(title = "库位", businessType = BusinessType.LOCK)
@GetMapping("/lockWmsLocation/{locationId}") @GetMapping("/lockWmsLocation/{locationId}")
public AjaxResult lockWmsLocation(@PathVariable Long locationId) public AjaxResult lockWmsLocation(@PathVariable Long locationId) {
{
return toAjax(wmsBaseLocationService.lockWmsBaseLocation(locationId)); return toAjax(wmsBaseLocationService.lockWmsBaseLocation(locationId));
} }
@ -138,9 +129,35 @@ public class WmsBaseLocationController extends BaseController
@RequiresPermissions("wms:wmslocation:lock") @RequiresPermissions("wms:wmslocation:lock")
@Log(title = "库位", businessType = BusinessType.UNLOCK) @Log(title = "库位", businessType = BusinessType.UNLOCK)
@GetMapping("/unlockWmsLocation/{locationId}") @GetMapping("/unlockWmsLocation/{locationId}")
public AjaxResult unlockWmsLocation(@PathVariable Long locationId) public AjaxResult unlockWmsLocation(@PathVariable Long locationId) {
{
return toAjax(wmsBaseLocationService.unlockWmsBaseLocation(locationId)); return toAjax(wmsBaseLocationService.unlockWmsBaseLocation(locationId));
} }
/**
*
*
* @param locationIds
* @return
*/
@RequiresPermissions("wms:wmslocation:printLocationLabel")
@Log(title = "库位", businessType = BusinessType.PRINT)
@GetMapping(value = "/printLocationLabels/{locationIds}")
public AjaxResult printLocationLabels(@PathVariable Long[] locationIds) {
return success(wmsBaseLocationService.printLabels(locationIds, 1));
}
/**
*
*
* @param locationIds
* @return
*/
@RequiresPermissions("wms:wmslocation:printContainerLabel")
@Log(title = "库位", businessType = BusinessType.PRINT)
@GetMapping(value = "/printContainerLabels/{locationIds}")
public AjaxResult printContainerLabels(@PathVariable Long[] locationIds) {
return success(wmsBaseLocationService.printLabels(locationIds, 2));
}
} }

@ -32,6 +32,10 @@ public class WmsBaseLocation extends BaseEntity
@Excel(name = "库位编码") @Excel(name = "库位编码")
private String locationCode; private String locationCode;
/**料箱编码*/
private String containerCode;
/** 排 */ /** 排 */
@Excel(name = "排") @Excel(name = "排")
private Long locRow; private Long locRow;
@ -191,6 +195,15 @@ public class WmsBaseLocation extends BaseEntity
{ {
return locationCode; return locationCode;
} }
public String getContainerCode() {
return containerCode;
}
public void setContainerCode(String containerCode) {
this.containerCode = containerCode;
}
public void setLocRow(Long locRow) public void setLocRow(Long locRow)
{ {
this.locRow = locRow; this.locRow = locRow;

@ -84,4 +84,13 @@ public interface IWmsBaseLocationService
* @return * @return
*/ */
public int unlockWmsBaseLocation(Long locationId); public int unlockWmsBaseLocation(Long locationId);
/**
*
*
* @param locationIds
* @param type(1:2)
* @return
*/
public int printLabels(Long[] locationIds, int type);
} }

@ -1,12 +1,18 @@
package com.hw.wms.service.impl; package com.hw.wms.service.impl;
import java.util.HashMap;
import java.util.List; import java.util.List;
import com.hw.common.core.constant.SecurityConstants;
import com.hw.common.core.constant.WmsConstants; import com.hw.common.core.constant.WmsConstants;
import com.hw.common.core.enums.WmsLocationStatus; import com.hw.common.core.enums.WmsLocationStatus;
import com.hw.common.core.exception.ServiceException; import com.hw.common.core.exception.ServiceException;
import com.hw.common.core.utils.DateUtils; import com.hw.common.core.utils.DateUtils;
import com.hw.common.core.utils.StringUtils;
import com.hw.common.security.utils.SecurityUtils; import com.hw.common.security.utils.SecurityUtils;
import com.hw.mes.api.domain.MesBaseBarcodeInfo;
import com.hw.printer.api.RemotePrinterService;
import com.hw.printer.api.domain.vo.PrintContentVo;
import com.hw.wms.domain.WmsBaseWarehouse; import com.hw.wms.domain.WmsBaseWarehouse;
import com.hw.wms.mapper.WmsBaseWarehouseMapper; import com.hw.wms.mapper.WmsBaseWarehouseMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -15,6 +21,8 @@ import com.hw.wms.mapper.WmsBaseLocationMapper;
import com.hw.wms.domain.WmsBaseLocation; import com.hw.wms.domain.WmsBaseLocation;
import com.hw.wms.service.IWmsBaseLocationService; import com.hw.wms.service.IWmsBaseLocationService;
import javax.annotation.Resource;
/** /**
* Service * Service
* *
@ -29,6 +37,9 @@ public class WmsBaseLocationServiceImpl implements IWmsBaseLocationService {
@Autowired @Autowired
private WmsBaseWarehouseMapper wmsBaseWarehouseMapper; private WmsBaseWarehouseMapper wmsBaseWarehouseMapper;
@Resource
private RemotePrinterService remotePrinterService;
/** /**
* *
* *
@ -125,11 +136,11 @@ public class WmsBaseLocationServiceImpl implements IWmsBaseLocationService {
// return wmsBaseLocationMapper.insertWmsBaseLocation(wmsBaseLocation); // return wmsBaseLocationMapper.insertWmsBaseLocation(wmsBaseLocation);
WmsBaseLocation baseLocation = wmsBaseLocationMapper.selectWmsBaseLocationByLocationId(locationId); WmsBaseLocation baseLocation = wmsBaseLocationMapper.selectWmsBaseLocationByLocationId(locationId);
String locationStatus = baseLocation.getLocationStatus(); String locationStatus = baseLocation.getLocationStatus();
if(locationStatus.equals(WmsLocationStatus.MANUALLOCK.getCode())){ if (locationStatus.equals(WmsLocationStatus.MANUALLOCK.getCode())) {
return 1; return 1;
} }
if(!locationStatus.equals(WmsLocationStatus.NORMAL.getCode())){ if (!locationStatus.equals(WmsLocationStatus.NORMAL.getCode())) {
throw new ServiceException("库位状态为"+WmsLocationStatus.locationStatusMap.get(locationStatus)+",不能锁定"); throw new ServiceException("库位状态为" + WmsLocationStatus.locationStatusMap.get(locationStatus) + ",不能锁定");
} }
baseLocation.setLocationStatus(WmsLocationStatus.MANUALLOCK.getCode()); baseLocation.setLocationStatus(WmsLocationStatus.MANUALLOCK.getCode());
@ -146,11 +157,11 @@ public class WmsBaseLocationServiceImpl implements IWmsBaseLocationService {
public int unlockWmsBaseLocation(Long locationId) { public int unlockWmsBaseLocation(Long locationId) {
WmsBaseLocation baseLocation = wmsBaseLocationMapper.selectWmsBaseLocationByLocationId(locationId); WmsBaseLocation baseLocation = wmsBaseLocationMapper.selectWmsBaseLocationByLocationId(locationId);
String locationStatus = baseLocation.getLocationStatus(); String locationStatus = baseLocation.getLocationStatus();
if(locationStatus.equals(WmsLocationStatus.NORMAL.getCode())){ if (locationStatus.equals(WmsLocationStatus.NORMAL.getCode())) {
return 1; return 1;
} }
if(!locationStatus.equals(WmsLocationStatus.MANUALLOCK.getCode())){ if (!locationStatus.equals(WmsLocationStatus.MANUALLOCK.getCode())) {
throw new ServiceException("库位状态为"+WmsLocationStatus.locationStatusMap.get(locationStatus)+",不能解锁"); throw new ServiceException("库位状态为" + WmsLocationStatus.locationStatusMap.get(locationStatus) + ",不能解锁");
} }
baseLocation.setLocationStatus(WmsLocationStatus.NORMAL.getCode()); baseLocation.setLocationStatus(WmsLocationStatus.NORMAL.getCode());
@ -158,4 +169,45 @@ public class WmsBaseLocationServiceImpl implements IWmsBaseLocationService {
} }
/**
*
*
* @param locationIds
* @param type(1:2)
* @return
*/
@Override
public int printLabels(Long[] locationIds, int type) {
StringBuilder buffer = new StringBuilder();
for (Long locationId : locationIds) {
WmsBaseLocation baseLocation = wmsBaseLocationMapper.selectWmsBaseLocationByLocationId(locationId);
String qrCode = "";
if (type == 1) {
qrCode = baseLocation.getLocationCode();
} else if (type == 2) {
qrCode = baseLocation.getContainerCode();
}
if (StringUtils.isNotEmpty(qrCode)) {
try {
HashMap<String, String> params = new HashMap<>();
params.put("text", qrCode);
params.put("qrCode", qrCode);
PrintContentVo printContentVo = new PrintContentVo();
printContentVo.setParams(params);
//调用的打印接口
remotePrinterService.printLocationLabel(printContentVo, SecurityConstants.INNER);
} catch (Exception e) {
buffer.append("打印料箱条码报错——[条码内容:").append(qrCode).append("]").append(e.getMessage());
}
} else {
buffer.append("打印料箱条码为空——[库位条码:").append(baseLocation.getLocationCode()).append("]");
}
}
if (buffer.length() == 0) {
return 1;
} else {
throw new ServiceException(buffer.toString());
}
}
} }

@ -11,6 +11,7 @@
<result property="agvPositionCode" column="agv_position_code" /> <result property="agvPositionCode" column="agv_position_code" />
<result property="warehouseFloor" column="warehouse_floor" /> <result property="warehouseFloor" column="warehouse_floor" />
<result property="locationCode" column="location_code" /> <result property="locationCode" column="location_code" />
<result property="containerCode" column="container_code" />
<result property="locRow" column="loc_row" /> <result property="locRow" column="loc_row" />
<result property="layerNum" column="layer_num" /> <result property="layerNum" column="layer_num" />
<result property="locColumn" column="loc_column" /> <result property="locColumn" column="loc_column" />
@ -41,7 +42,7 @@
</resultMap> </resultMap>
<sql id="selectWmsBaseLocationVo"> <sql id="selectWmsBaseLocationVo">
select location_id, warehouse_id, location_code,agv_position_code, warehouse_floor,loc_row, layer_num, loc_column, active_flag, manual_flag, qty_limit, instock_flag, outstock_flag, location_status, batch_mix, create_by, create_time, update_by, update_time, remark, del_flag, shelf_order, check_order, pick_order, pick_flag, is_open_kn_flag, location_scrap_type, volume_limit, weight_limit, length, width, height from wms_base_location select location_id, warehouse_id, location_code,container_code,agv_position_code, warehouse_floor,loc_row, layer_num, loc_column, active_flag, manual_flag, qty_limit, instock_flag, outstock_flag, location_status, batch_mix, create_by, create_time, update_by, update_time, remark, del_flag, shelf_order, check_order, pick_order, pick_flag, is_open_kn_flag, location_scrap_type, volume_limit, weight_limit, length, width, height from wms_base_location
</sql> </sql>
<select id="selectWmsBaseLocationList" parameterType="WmsBaseLocation" resultMap="WmsBaseLocationResult"> <select id="selectWmsBaseLocationList" parameterType="WmsBaseLocation" resultMap="WmsBaseLocationResult">
@ -240,7 +241,7 @@
<select id="selectWmsBaseLocationJoinList" parameterType="WmsBaseLocation" resultMap="WmsBaseLocationResult"> <select id="selectWmsBaseLocationJoinList" parameterType="WmsBaseLocation" resultMap="WmsBaseLocationResult">
select wbl.location_id, wbl.warehouse_id,wbl.agv_position_code, wbl.location_code, wbl.loc_row, wbl.layer_num, wbl.loc_column, wbl.active_flag, wbl.manual_flag, select wbl.location_id, wbl.warehouse_id,wbl.agv_position_code, wbl.location_code,wbl.container_code, wbl.loc_row, wbl.layer_num, wbl.loc_column, wbl.active_flag, wbl.manual_flag,
wbl.qty_limit, wbl.instock_flag, wbl.outstock_flag, wbl.location_status, wbl.remark,wbw.warehouse_name wbl.qty_limit, wbl.instock_flag, wbl.outstock_flag, wbl.location_status, wbl.remark,wbw.warehouse_name
from wms_base_location wbl left join wms_base_warehouse wbw on wbl.warehouse_id = wbw.warehouse_id from wms_base_location wbl left join wms_base_warehouse wbw on wbl.warehouse_id = wbw.warehouse_id

@ -68,3 +68,22 @@ export function unlockWmslocation(locationId) {
method: 'get' method: 'get'
}) })
} }
// 打印库位条码
export function printLocationLabels(locationId) {
return request({
url: '/wms/wmslocation/printLocationLabels/' + locationId,
method: 'get'
})
}
// 打印料箱条码
export function printContainerLabels(locationId) {
return request({
url: '/wms/wmslocation/printContainerLabels/' + locationId,
method: 'get'
})
}

@ -532,8 +532,8 @@ export default {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
this.form.mesBaseProcessProdlineList = this.mesBaseProcessProdlineList; this.form.mesBaseProcessProdlineList = this.mesBaseProcessProdlineList;
if (this.form.productionTime <= 0) { if (this.form.productionTime < 0) {
this.$modal.msgError("标准工时天、小时、分钟需为大于等于0的整数!"); this.$modal.msgError("标准工时天、小时、分钟需为大于等于0的整数!");
return; return;
} }
this.convertToSeconds(); this.convertToSeconds();

@ -194,6 +194,31 @@
>删除 >删除
</el-button> </el-button>
</el-col> </el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-print"
size="mini"
:disabled="multiple"
@click="handlePrintLocationLabels"
v-hasPermi="['wms:wmslocation:printLocationLabels']"
>打印库位标签
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-print"
size="mini"
:disabled="multiple"
@click="handlePrintContainerLabels"
v-hasPermi="['wms:wmslocation:printContainerLabels']"
>打印料箱标签
</el-button>
</el-col>
<!--el-col :span="1.5"> <!--el-col :span="1.5">
<el-button <el-button
type="warning" type="warning"
@ -211,6 +236,7 @@
<el-table v-loading="loading" :data="wmslocationList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="wmslocationList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center"/> <el-table-column type="selection" width="55" align="center"/>
<el-table-column label="库位编号" align="center" prop="locationCode"/> <el-table-column label="库位编号" align="center" prop="locationCode"/>
<el-table-column label="料箱编号" align="center" prop="containerCode"/>
<el-table-column label="仓库" align="center" prop="warehouseName"/> <el-table-column label="仓库" align="center" prop="warehouseName"/>
<el-table-column label="层" align="center" prop="layerNum"/> <el-table-column label="层" align="center" prop="layerNum"/>
<el-table-column label="排" align="center" prop="locRow"/> <el-table-column label="排" align="center" prop="locRow"/>
@ -422,7 +448,9 @@ import {
updateWmslocation, updateWmslocation,
getWarehouses, getWarehouses,
lockWmslocation, lockWmslocation,
unlockWmslocation unlockWmslocation,
printLocationLabels,
printContainerLabels
} from "@/api/wms/wmslocation"; } from "@/api/wms/wmslocation";
import Treeselect from "@riophae/vue-treeselect"; import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css"; import "@riophae/vue-treeselect/dist/vue-treeselect.css";
@ -442,6 +470,8 @@ export default {
ids: [], ids: [],
// code // code
codes: [], codes: [],
// code
containerCodes: [],
// //
single: true, single: true,
// //
@ -634,6 +664,7 @@ export default {
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map(item => item.locationId) this.ids = selection.map(item => item.locationId)
this.codes = selection.map(item => item.locationCode) this.codes = selection.map(item => item.locationCode)
this.containerCodes = selection.map(item => item.containerCode)
this.single = selection.length !== 1 this.single = selection.length !== 1
this.multiple = !selection.length this.multiple = !selection.length
}, },
@ -747,6 +778,33 @@ export default {
}); });
}, },
/** 打印库位条码按钮操作 */
handlePrintLocationLabels(row) {
const locationIds = row.locationId || this.ids;
const locationCodes = row.locationCode || this.codes;
this.$modal.confirm('是否确认打印库位码为"' + locationCodes + '"的库位标签?').then(function () {
return printLocationLabels(locationIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("打印成功");
}).catch(() => {
});
},
/** 打印料箱条码按钮操作 */
handlePrintContainerLabels(row) {
const locationIds = row.locationId || this.ids;
const containerCodes = row.containerCode || this.containerCodes;
this.$modal.confirm('是否确认打印料箱码为"' + containerCodes + '"的料箱标签?').then(function () {
return printContainerLabels(locationIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("打印成功");
}).catch(() => {
});
},
} }
}; };
</script> </script>

@ -355,7 +355,7 @@
</el-row> </el-row>
<!--el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="混放批次" prop="batchMix"> <el-form-item label="混放批次" prop="batchMix">
<el-radio-group v-model="form.batchMix" :disabled="disableFlag"> <el-radio-group v-model="form.batchMix" :disabled="disableFlag">
@ -378,7 +378,7 @@
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row--> </el-row>
<el-row> <el-row>
@ -408,7 +408,7 @@
<!--el-row> <el-row>
<el-form-item label="入库要求" prop="inRequirement"> <el-form-item label="入库要求" prop="inRequirement">
<el-radio-group v-model="form.inRequirement" :disabled="disableFlag"> <el-radio-group v-model="form.inRequirement" :disabled="disableFlag">
<el-radio <el-radio
@ -442,7 +442,7 @@
>{{dict.label}}</el-radio> >{{dict.label}}</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-row--> </el-row>
<el-row> <el-row>
<el-form-item label="自动标识" prop="autoFlag"> <el-form-item label="自动标识" prop="autoFlag">

Loading…
Cancel
Save