| | |
| | | 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;
|
| | |
| | | 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")
|
| | |
| | | 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("缺少参数");
|
| | | }
|
| | |
|
| | | String pakinType = "flat";
|
| | | if (!Objects.isNull(type)) {
|
| | | type = type.toString();
|
| | | if (type.toString().equals("1")) {
|
| | | pakinType = "flat";
|
| | | } else {
|
| | | pakinType = "ctu";
|
| | | }
|
| | | }
|
| | | ZpalletBarcode one = zpalletBarcodeService.getOne(new LambdaQueryWrapper<ZpalletBarcode>().eq(ZpalletBarcode::getBarcode, barcode));
|
| | | if (one != null) {
|
| | | return R.error("条码起始值已存在");
|
| | | }
|
| | | 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);
|
| | | 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);
|
| | | zpalletBarcodeService.save(zpalletBarcode);
|
| | | barcodeInt += 1;
|
| | | }
|
| | | }
|
| | | return R.ok();
|
| | | }
|