From e046dba174365eb8934ee1e4206f09821145e876 Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期四, 21 八月 2025 13:23:22 +0800 Subject: [PATCH] no message --- zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/controller/ZpalletBarcodeController.java | 60 +++++++++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 47 insertions(+), 13 deletions(-) diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/controller/ZpalletBarcodeController.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/controller/ZpalletBarcodeController.java index eb39db2..845fadb 100644 --- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/controller/ZpalletBarcodeController.java +++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/controller/ZpalletBarcodeController.java @@ -1,5 +1,6 @@ package com.zy.asrs.wms.asrs.controller; +import com.alibaba.excel.util.StringUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zy.asrs.framework.common.Cools; @@ -18,10 +19,7 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; +import java.util.*; @RestController @RequestMapping("/api") @@ -57,6 +55,13 @@ @OperationLog("娣诲姞瀹瑰櫒绠$悊") @PostMapping("/zpalletBarcode/save") public R save(@RequestBody ZpalletBarcode zpalletBarcode) { + if (Objects.isNull(zpalletBarcode.getBarcode())) { + return R.error("鎵樼洏鐮佷笉鑳戒负绌猴紒锛�"); + } + ZpalletBarcode one = zpalletBarcodeService.getOne(new LambdaQueryWrapper<ZpalletBarcode>().eq(ZpalletBarcode::getBarcode, zpalletBarcode.getBarcode())); + if (!Objects.isNull(one)) { + return R.error("瀹瑰櫒宸插瓨鍦紝涓嶅彲閲嶅娣诲姞锛侊紒"); + } if (!zpalletBarcodeService.save(zpalletBarcode)) { return R.error("娣诲姞澶辫触"); } @@ -108,20 +113,49 @@ public R generate(@RequestBody Map<String, Object> map) { Object barcode = map.get("barcode"); Object num = map.get("num"); + Object type = map.get("type"); if (barcode == null || num == null) { return R.error("缂哄皯鍙傛暟"); } - ZpalletBarcode one = zpalletBarcodeService.getOne(new LambdaQueryWrapper<ZpalletBarcode>().eq(ZpalletBarcode::getBarcode, barcode)); - if (one != null) { - return R.error("鏉$爜璧峰鍊煎凡瀛樺湪"); + String pakinType = "flat"; + if (!Objects.isNull(type)) { + type = type.toString(); + if (type.toString().equals("1")) { + pakinType = "flat"; + } else { + pakinType = "ctu"; + } } - int barcodeInt = Integer.parseInt(String.valueOf(barcode)); - for (int i = 0; i < Integer.parseInt(String.valueOf(num)); i++) { - ZpalletBarcode zpalletBarcode = new ZpalletBarcode(); - zpalletBarcode.setBarcode(String.valueOf(barcodeInt)); - zpalletBarcodeService.save(zpalletBarcode); - barcodeInt += 1; + + if (pakinType.equals("flat")) { + int barcodeInt = Integer.parseInt(String.valueOf(barcode)); + for (int i = 0; i < Integer.parseInt(String.valueOf(num)); i++) { + ZpalletBarcode zpalletBarcode = new ZpalletBarcode(); + String strBarcode = String.format("%08d", barcodeInt); + zpalletBarcode.setBarcode("PK" + strBarcode); + ZpalletBarcode one = zpalletBarcodeService.getOne(new LambdaQueryWrapper<ZpalletBarcode>() + .eq(ZpalletBarcode::getBarcode, strBarcode)); + if (one != null) { + continue; + } + zpalletBarcodeService.save(zpalletBarcode); + barcodeInt += 1; + } + } else { + int barcodeInt = Integer.parseInt(String.valueOf(barcode)); + for (int i = 0; i < Integer.parseInt(String.valueOf(num)); i++) { + ZpalletBarcode zpalletBarcode = new ZpalletBarcode(); + String strBarcode = String.format("%08d", barcodeInt); + zpalletBarcode.setBarcode(strBarcode); + ZpalletBarcode one = zpalletBarcodeService.getOne(new LambdaQueryWrapper<ZpalletBarcode>() + .eq(ZpalletBarcode::getBarcode, strBarcode)); + if (one != null) { + continue; + } + zpalletBarcodeService.save(zpalletBarcode); + barcodeInt += 1; + } } return R.ok(); } -- Gitblit v1.9.1