add:采购单据打印

opt:采购单转发中鼎优化
This commit is contained in:
zhaoyf
2026-06-17 09:23:03 +08:00
parent 34a6c03720
commit 7b962b0bfa
11 changed files with 136 additions and 3 deletions

View File

@@ -0,0 +1,15 @@
package org.nl.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Data
@Configuration
@ConfigurationProperties("printer")
public class PrinterProperties {
private String ip = "192.168.1.100";
private int port = 9100;
}

View File

@@ -64,16 +64,17 @@ public class InboundEasSyncServiceImpl implements InboundEasSyncService {
easMst.setBill_status(PurchaseBillStatus.CREATED.getCode());
easMst.setModify_date(DateUtil.now());
purchasemstMapper.insert(easMst);
for (Purchasedtl dtl : easDtlList) {
purchasedtlMapper.insert(dtl);
if (dtl.getHouse_code().contains("ZDLK")){
//中鼎立库
easMst.setForwardZD(1);
//TODO 转发中鼎参数待确定
wmsToZDWmdService.syncPurchaseReceiving(new JSONObject());
}
}
purchasemstMapper.insert(easMst);
log.info("EAS采购入库单同步完成, billId: {}, 明细数: {}", billId, easDtlList.size());
JSONObject result = new JSONObject();

View File

@@ -63,4 +63,11 @@ public class PurchaseController {
purchaseService.issueReturnBill(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
@PostMapping("/print")
@Log("打印采购入库单")
public ResponseEntity<Object> print(@RequestBody Set<String> ids) {
purchaseService.print(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@@ -32,5 +32,7 @@ public interface PurchaseService extends IService<Purchasemst> {
List<Purchasedtl> selectListByBillId(String billId);
void print(Set<String> ids);
List<PurchaseMatInfoVo> selectPdaInMat(HashMap of);
}

View File

@@ -23,6 +23,8 @@ public class Purchasemst implements Serializable {
private String order_type;
private Integer forwardZD;
private String supplier_code;
private String supplier_name;

View File

@@ -8,6 +8,7 @@
m.bill_id,
m.order_no,
m.order_type,
m.forwardZD,
m.supplier_code,
m.supplier_name,
m.creator,

View File

@@ -28,10 +28,15 @@ import org.nl.wms.warehouse_manage.enums.IOSEnum;
import org.nl.wms.warehouse_manage.stockReturn.service.IPmStockReturnService;
import org.nl.wms.warehouse_manage.stockReturn.service.dao.PmStockReturn;
import org.nl.wms.warehouse_manage.stockReturn.service.enums.StockReturnStatusEnum;
import org.nl.config.PrinterProperties;
import org.nl.wms.pm_manage.purchase.util.ZplUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.OutputStream;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.util.*;
@Slf4j
@@ -50,6 +55,9 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchasemstMapper, Purchase
@Autowired
private WmsToErpService wmsToErpService;
@Autowired
private PrinterProperties printerProperties;
@Override
public IPage<PurchasemstListVo> queryAll(Map whereJson, PageQuery page) {
return purchasemstMapper.queryAllByPage(
@@ -192,6 +200,38 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchasemstMapper, Purchase
}
}
@Override
public void print(Set<String> ids) {
List<Purchasemst> mstList = purchasemstMapper.selectBatchIds(ids);
if (ObjectUtil.isEmpty(mstList)) {
throw new BadRequestException("未找到选中的单据");
}
StringBuilder allZpl = new StringBuilder();
int labelCount = 0;
for (Purchasemst mst : mstList) {
List<Purchasedtl> dtlList = purchasedtlMapper.selectList(
new LambdaQueryWrapper<Purchasedtl>()
.eq(Purchasedtl::getBill_id, mst.getBill_id()));
for (Purchasedtl dtl : dtlList) {
String zpl = ZplUtil.generateLabel(
dtl.getSku_name(), dtl.getSku_code(),
dtl.getQty() != null ? dtl.getQty().stripTrailingZeros().toPlainString() : "0",
dtl.getUnit(), mst.getBill_id(), dtl.getItem_no());
allZpl.append(zpl);
labelCount++;
}
}
try (Socket socket = new Socket(printerProperties.getIp(), printerProperties.getPort());
OutputStream out = socket.getOutputStream()) {
out.write(allZpl.toString().getBytes(StandardCharsets.UTF_8));
out.flush();
} catch (Exception e) {
log.error("打印失败, 打印机: {}:{}, 标签数: {}", printerProperties.getIp(), printerProperties.getPort(), labelCount, e);
throw new BadRequestException("打印机连接失败: " + e.getMessage());
}
log.info("打印成功, 打印机: {}:{}, 标签数: {}", printerProperties.getIp(), printerProperties.getPort(), labelCount);
}
@Override
public List<PurchaseMatInfoVo> pdaInboundSelectMatInfo(Map whereJson) {
return purchasemstMapper.selectPdaInMat(whereJson);

View File

@@ -13,6 +13,8 @@ public class PurchasemstListVo {
private String order_type;
private Integer forwardZD;
private String supplier_code;
private String supplier_name;