新增物料老鼠图接口
This commit is contained in:
parent
981d1f4a96
commit
0bf4494fb6
|
|
@ -0,0 +1,44 @@
|
|||
package com.nflg.wms.common.pojo.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class MaterialPdfDTO {
|
||||
/**
|
||||
* 图片
|
||||
*/
|
||||
private String image;
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@NotBlank
|
||||
private String materialNo;
|
||||
|
||||
/**
|
||||
* 图号
|
||||
*/
|
||||
private String drawingNo;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@NotBlank
|
||||
private String materialDescribe;
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
@NotNull
|
||||
private BigDecimal num;
|
||||
|
||||
/**
|
||||
* 重量
|
||||
*/
|
||||
private BigDecimal weight;
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class MaterialPdfQO {
|
||||
/**
|
||||
* 清单编号
|
||||
*/
|
||||
private String no;
|
||||
/**
|
||||
* 机台编号
|
||||
*/
|
||||
private String deviceNo;
|
||||
/**
|
||||
* 物料编码
|
||||
*/
|
||||
private String materialNo;
|
||||
/**
|
||||
* 销售订单号
|
||||
*/
|
||||
private String soNo;
|
||||
/**
|
||||
* 客户名称
|
||||
*/
|
||||
private String customerName;
|
||||
/**
|
||||
* 下单日期
|
||||
*/
|
||||
private String orderDay;
|
||||
/**
|
||||
* 物料id
|
||||
*/
|
||||
private List<Long> materialIds;
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.nflg.wms.common.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class MaterialPdfVO {
|
||||
/**
|
||||
* 清单编号
|
||||
*/
|
||||
private String no;
|
||||
/**
|
||||
* 机台编号
|
||||
*/
|
||||
private String deviceNo;
|
||||
/**
|
||||
* 物料编码
|
||||
*/
|
||||
private String materialNo;
|
||||
/**
|
||||
* 销售订单号
|
||||
*/
|
||||
private String soNo;
|
||||
/**
|
||||
* 客户名称
|
||||
*/
|
||||
private String customerName;
|
||||
/**
|
||||
* 下单日期
|
||||
*/
|
||||
private String orderDay;
|
||||
/**
|
||||
* 重量
|
||||
*/
|
||||
private BigDecimal weight;
|
||||
/**
|
||||
* 二维码
|
||||
*/
|
||||
private String qrCode;
|
||||
}
|
||||
|
|
@ -132,6 +132,12 @@
|
|||
<artifactId>hypersistence-tsid</artifactId>
|
||||
<version>2.1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nflg</groupId>
|
||||
<artifactId>nflg-wms-admin</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -3,12 +3,17 @@ package com.nflg.wms.shipment.controller;
|
|||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nflg.wms.admin.pojo.dto.PdfPageDTO;
|
||||
import com.nflg.wms.admin.util.PdfGeneratorUtil;
|
||||
import com.nflg.wms.common.pojo.ApiResult;
|
||||
import com.nflg.wms.common.pojo.PageData;
|
||||
import com.nflg.wms.common.pojo.dto.MaterialPdfDTO;
|
||||
import com.nflg.wms.common.pojo.qo.*;
|
||||
import com.nflg.wms.common.pojo.vo.MaterialPdfVO;
|
||||
import com.nflg.wms.common.pojo.vo.ShipmentMaterialCodeQRVO;
|
||||
import com.nflg.wms.common.pojo.vo.ShipmentMaterialCodeItemVO;
|
||||
import com.nflg.wms.common.util.EecExcelUtil;
|
||||
|
|
@ -25,6 +30,7 @@ import com.nflg.wms.shipment.util.KeyUtil;
|
|||
import com.nflg.wms.shipment.util.QRCodeUtil;
|
||||
import com.nflg.wms.shipment.util.ThymeleafUtil;
|
||||
import com.nflg.wms.starter.BaseController;
|
||||
import com.nflg.wms.starter.service.FileUploadService;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
|
|
@ -43,8 +49,11 @@ import org.ttzero.excel.entity.TemplateSheet;
|
|||
import org.ttzero.excel.entity.Workbook;
|
||||
import org.ttzero.excel.reader.ExcelReader;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDateTime;
|
||||
|
|
@ -83,6 +92,9 @@ public class MaterialCodeController extends BaseController {
|
|||
@Resource
|
||||
private IWmsShipmentMaterialService materialService;
|
||||
|
||||
@Resource
|
||||
private FileUploadService fileUploadService;
|
||||
|
||||
/**
|
||||
* 清单-新增
|
||||
*/
|
||||
|
|
@ -153,7 +165,7 @@ public class MaterialCodeController extends BaseController {
|
|||
public ApiResult<PageData<WmsShipmentMaterialCode>> search(@Valid @RequestBody MaterialCodeSearchQO request) {
|
||||
return ApiResult.success(
|
||||
materialCodeService.lambdaQuery()
|
||||
.eq(Objects.nonNull(request.getStatus()),WmsShipmentMaterialCode::getStatus, request.getStatus())
|
||||
.eq(Objects.nonNull(request.getStatus()), WmsShipmentMaterialCode::getStatus, request.getStatus())
|
||||
.ge(Objects.nonNull(request.getOrderStartDate()), WmsShipmentMaterialCode::getOrderDate, request.getOrderStartDate())
|
||||
.le(Objects.nonNull(request.getOrderEndDate()), WmsShipmentMaterialCode::getOrderDate, request.getOrderEndDate())
|
||||
.ge(Objects.nonNull(request.getStartDate()), WmsShipmentMaterialCode::getCreateTime, request.getStartDate())
|
||||
|
|
@ -161,7 +173,7 @@ public class MaterialCodeController extends BaseController {
|
|||
.like(StrUtil.isNotBlank(request.getNo()), WmsShipmentMaterialCode::getNo, request.getNo())
|
||||
.like(StrUtil.isNotBlank(request.getSoNo()), WmsShipmentMaterialCode::getSoNo, request.getSoNo())
|
||||
.like(StrUtil.isNotBlank(request.getMaterialNo()), WmsShipmentMaterialCode::getMaterialNo, request.getMaterialNo())
|
||||
.like(StrUtil.isNotBlank(request.getCustomerName()), WmsShipmentMaterialCode::getCustomerName, request.getCustomerName()) .orderByAsc(WmsShipmentMaterialCode::getStatus)
|
||||
.like(StrUtil.isNotBlank(request.getCustomerName()), WmsShipmentMaterialCode::getCustomerName, request.getCustomerName()).orderByAsc(WmsShipmentMaterialCode::getStatus)
|
||||
.orderByDesc(WmsShipmentMaterialCode::getId)
|
||||
.page(new Page<>(request.getPage(), request.getPageSize()))
|
||||
);
|
||||
|
|
@ -391,6 +403,7 @@ public class MaterialCodeController extends BaseController {
|
|||
|
||||
/**
|
||||
* 清单明细-导入
|
||||
*
|
||||
* @param materialCodeId 清单ID
|
||||
* @param cover 导入模式,true:覆盖,false:新增
|
||||
* @param file 文件
|
||||
|
|
@ -549,6 +562,7 @@ public class MaterialCodeController extends BaseController {
|
|||
|
||||
/**
|
||||
* 清单明细-根据二维码唯一号获取物料信息(PDA使用)
|
||||
*
|
||||
* @param code 二维码唯一号
|
||||
*/
|
||||
@GetMapping("getInfoByQRCode")
|
||||
|
|
@ -578,6 +592,7 @@ public class MaterialCodeController extends BaseController {
|
|||
|
||||
/**
|
||||
* 根据清单导出标签图片ZIP(用于直连打印机打印)
|
||||
*
|
||||
* @param ids 清单id列表
|
||||
*/
|
||||
@PostMapping("exportItemImageZip1")
|
||||
|
|
@ -589,6 +604,7 @@ public class MaterialCodeController extends BaseController {
|
|||
|
||||
/**
|
||||
* 根据清单项导出标签图片ZIP(用于直连打印机打印)
|
||||
*
|
||||
* @param ids 清单明细id列表
|
||||
*/
|
||||
@PostMapping("exportItemImageZip")
|
||||
|
|
@ -631,6 +647,7 @@ public class MaterialCodeController extends BaseController {
|
|||
|
||||
/**
|
||||
* 代发物料-导入
|
||||
*
|
||||
* @param id 清单ID
|
||||
*/
|
||||
@PostMapping("importForward")
|
||||
|
|
@ -742,4 +759,68 @@ public class MaterialCodeController extends BaseController {
|
|||
.update();
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出老鼠图PDF
|
||||
*/
|
||||
@PostMapping("exportPdf")
|
||||
public ApiResult<String> exportPdf(HttpServletResponse response, @RequestBody MaterialPdfQO request) throws Exception {
|
||||
List<WmsShipmentMaterialCodeItem> materialCodeIts =materialCodeItemService.lambdaQuery()
|
||||
.in(WmsShipmentMaterialCodeItem::getId, request.getMaterialIds()).list();
|
||||
//根据前端传入的物料ID查询对应的物料编号再查询物料主数据
|
||||
List<WmsShipmentMaterial> shipmentMaterials = materialService.lambdaQuery()
|
||||
.in(WmsShipmentMaterial::getNo, materialCodeIts
|
||||
.stream()
|
||||
.map(WmsShipmentMaterialCodeItem::getMaterialNo)
|
||||
.toList())
|
||||
.list();
|
||||
//根据前端传入的物料ID查询物料明细
|
||||
List<WmsShipmentMaterialCodeItem> materialCodeItems = materialCodeItemService.lambdaQuery()
|
||||
.in(WmsShipmentMaterialCodeItem::getId, request.getMaterialIds()).list();
|
||||
//将主数据转换成PDF需要的DTO列表
|
||||
List<MaterialPdfDTO> items = Convert.toList(MaterialPdfDTO.class, materialCodeIts);
|
||||
Map<String, WmsShipmentMaterial> materialMap = shipmentMaterials.stream()
|
||||
.collect(Collectors.toMap(WmsShipmentMaterial::getNo, m -> m));
|
||||
for (MaterialPdfDTO dto : items) {
|
||||
WmsShipmentMaterial mat = materialMap.get(dto.getMaterialNo());
|
||||
if (mat != null) {
|
||||
dto.setImage(mat.getImage());
|
||||
dto.setWeight(mat.getWeight());
|
||||
dto.setDrawingNo(mat.getDrawingNo());
|
||||
}
|
||||
}
|
||||
//计算总重量 = 单个重量 * 数量 累加
|
||||
BigDecimal allWeight = new BigDecimal(0);
|
||||
for (WmsShipmentMaterialCodeItem temp : materialCodeItems) {
|
||||
WmsShipmentMaterial material = shipmentMaterials.stream()
|
||||
.filter(s -> s.getNo().equals(temp.getMaterialNo()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (material == null) continue;
|
||||
BigDecimal weight = material.getWeight() == null ? BigDecimal.ZERO : material.getWeight();
|
||||
BigDecimal num = temp.getActualNum() == null ? BigDecimal.ZERO : temp.getActualNum();
|
||||
allWeight = allWeight.add(weight.multiply(num));
|
||||
}
|
||||
MaterialPdfVO material = Convert.convert(MaterialPdfVO.class, request);
|
||||
material.setWeight(allWeight);
|
||||
material.setQrCode(com.nflg.wms.admin.util.QRCodeUtil.generateQRCodeBase64(request.getNo(), 100, 100));
|
||||
//制作pdf
|
||||
Map<String, Object> variables = new HashMap<>();
|
||||
variables.put("info", material);
|
||||
variables.put("pages", PdfPageDTO.create(items, 9, new MaterialPdfDTO()));
|
||||
String html = ThymeleafUtil.generator(
|
||||
"/template/",
|
||||
"物料老鼠图",
|
||||
".html",
|
||||
variables
|
||||
);
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
PdfGeneratorUtil.generatePdf(
|
||||
"文件名",
|
||||
html,
|
||||
outputStream
|
||||
);
|
||||
InputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
|
||||
return ApiResult.success(fileUploadService.upload("tmp/sp/" + RandomUtil.randomString(10) + "/" + material.getNo() + "老鼠图.pdf", inputStream, MediaType.APPLICATION_PDF_VALUE));
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package com.nflg.wms.shipment.controller;
|
|||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
|
@ -25,8 +26,10 @@ import com.nflg.wms.shipment.util.QRCodeUtil;
|
|||
import com.nflg.wms.shipment.util.ThymeleafUtil;
|
||||
import com.nflg.wms.starter.BaseController;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
|
|
@ -161,6 +164,7 @@ public class PackagingCodeController extends BaseController {
|
|||
|
||||
/**
|
||||
* 根据二维码唯一号获取箱子(PDA使用)
|
||||
*
|
||||
* @param code 二维码唯一号
|
||||
*/
|
||||
@GetMapping("getInfoByQRCode")
|
||||
|
|
@ -216,7 +220,7 @@ public class PackagingCodeController extends BaseController {
|
|||
*/
|
||||
@Transactional
|
||||
@PostMapping("pcPack")
|
||||
public ApiResult<Void> pcPack(@Valid @RequestBody ShipmentPCPackingQO shipmentPCPackingQO){
|
||||
public ApiResult<Void> pcPack(@Valid @RequestBody ShipmentPCPackingQO shipmentPCPackingQO) {
|
||||
List<Long> ids = shipmentPCPackingQO.getCodes().stream()
|
||||
.map(code -> materialCodeItemQrService.getInfoByQRCode(code))
|
||||
.filter(Objects::nonNull)
|
||||
|
|
@ -265,6 +269,7 @@ public class PackagingCodeController extends BaseController {
|
|||
|
||||
/**
|
||||
* 获取包装已打包的物料列表(PDA使用)
|
||||
*
|
||||
* @param packagingCodeId 包装箱ID
|
||||
*/
|
||||
@GetMapping("getPackList")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,150 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<title>物料老鼠图</title>
|
||||
<style>
|
||||
@page {
|
||||
size: A4;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: SimSun, serif;
|
||||
font-size: 9pt;
|
||||
padding: 10px;
|
||||
margin: 0 auto;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.logo {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.logo img {
|
||||
height: 40px;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
border: 1px solid #000;
|
||||
}
|
||||
|
||||
td {
|
||||
border: 1px solid #000;
|
||||
padding: 7px;
|
||||
}
|
||||
|
||||
tr:first-child td {
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
tr:last-child td {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
td:first-child {
|
||||
border-left: none;
|
||||
}
|
||||
|
||||
td:last-child {
|
||||
border-right: none;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.data-item {
|
||||
width: 33.16207%;
|
||||
float: left;
|
||||
border-right: 1px solid #000;
|
||||
}
|
||||
|
||||
.data-item-row-first {
|
||||
border-left: 1px solid #000;
|
||||
}
|
||||
|
||||
.cell-img {
|
||||
display: table-cell;
|
||||
vertical-align: middle;
|
||||
text-align: center;
|
||||
padding: 10px;
|
||||
height: auto;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.cell-img img {
|
||||
vertical-align: middle; /* 防止图片底部留空隙 */
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.cell {
|
||||
border-bottom: 1px solid #000;
|
||||
padding: 7px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.cell1 {
|
||||
border-bottom: 1px solid #000;
|
||||
padding: 7px;
|
||||
height: 25px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.container {
|
||||
page-break-after: always;
|
||||
}
|
||||
|
||||
.container:last-child {
|
||||
page-break-after: auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" th:each="page,pageStat : ${pages}">
|
||||
<div class="logo"><img alt="" src="../img/logo1.png"/></div>
|
||||
<table>
|
||||
<tr>
|
||||
<td>清单编号:<span th:text="${info.no}">12255665451615</span></td>
|
||||
<td>机台编号:<span th:text="${info.deviceNo}">1111</span></td>
|
||||
<td>物料编号:<span th:text="${info.materialNo}">12255665451615</span></td>
|
||||
<!-- 二维码:右侧固定 + 跨3行 -->
|
||||
<td style="width: 120px; text-align: right; vertical-align: middle;" rowspan="3">
|
||||
<img alt="二维码" style="width: 100px; height: 100px;" th:src="${info.qrCode}" src="../img/logo1.png"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
<td>销售订单号:<span th:text="${info.soNo}">1</span></td>
|
||||
<td>客户名称:<span th:text="${info.customerName}">12255665451615</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
<td>下单日期:<span th:text="${info.orderDay}">1</span></td>
|
||||
<td>总重:<span th:text="${info.weight}">348.41</span></td>
|
||||
<td>页码:<span th:text="${pageStat.count}">1</span>/<span th:text="${pageStat.size}">2</span></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="data-item" th:each="item,itemStat : ${page.datas}"
|
||||
th:classappend="${itemStat.index % 3 == 0} ? 'data-item-row-first'">
|
||||
<div class="cell" style="height: 150px;">
|
||||
<div class="cell-img">
|
||||
<img style="width: 200px;height: 130px;" alt=""
|
||||
th:src="${!#strings.isEmpty(item.image)} ? ${item.image} : (${#strings.isEmpty(item.materialNo)} ? '' : 'http://192.168.163.83:9090/nflg-wms/template/none.png')"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell">SAP编码:<span th:text="${item.materialNo}">2222222222</span></div>
|
||||
<div class="cell1">图号:<span
|
||||
th:text="${item.drawingNo}">图号图号图号图号图号图号图号图号图号图号图号图号图号图号图号图号</span>
|
||||
</div>
|
||||
<div class="cell1">名称:<span
|
||||
th:text="${item.materialDescribe}">名称名称名称名称名称名称名称名称名称名名称名名称名称名称称名称名称名称称名称名称名称</span>
|
||||
</div>
|
||||
<div class="cell">数量:<span th:text="${item.num}">1</span> 重量:<span
|
||||
th:text="${item.weight}">348.41</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue