From 957176fd68561f258e0fe3af1aee6740be63b2f4 Mon Sep 17 00:00:00 2001 From: liyongde <1419499670@qq.com> Date: Sun, 22 Oct 2023 14:42:40 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9Ajson=E8=BD=AC=E6=8D=A2=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../acs/service/impl/AcsToWmsServiceImpl.java | 8 +++-- .../src/test/java/org/nl/ext/TestDemo.java | 33 +++++++++++++++---- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java index 05efd09..1d087ec 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java @@ -5,6 +5,7 @@ import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpStatus; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -305,7 +306,8 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { if (regionCode.equals("FJ")) { // 判断是否够码满 // 分拣需要在这设置特殊值 // 校验是否够码满一托 - List list = JSONArray.parseArray(param.getString("list"), ApplyDeviceDto.class); + JSONArray array = param.getJSONArray("list"); + List list = JSONArray.parseArray(array.toJSONString(), ApplyDeviceDto.class); PdmBdWorkorder workorder = workorderService.getDeviceDockingProductionTask(param.getString("device_code")); // 1 获取点位相应数量 int sum = 0; @@ -321,9 +323,9 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { int needFullNumber = TaskUtils.convertMultiply(needFullNumberStr); int surplus = total / needFullNumber; if (surplus == 1) { - return 1; + torus = 1; } else if (surplus == 0) { - return 2; + torus = 2; } } return torus; diff --git a/lms/nladmin-system/nlsso-server/src/test/java/org/nl/ext/TestDemo.java b/lms/nladmin-system/nlsso-server/src/test/java/org/nl/ext/TestDemo.java index fd851c8..2416406 100644 --- a/lms/nladmin-system/nlsso-server/src/test/java/org/nl/ext/TestDemo.java +++ b/lms/nladmin-system/nlsso-server/src/test/java/org/nl/ext/TestDemo.java @@ -1,7 +1,10 @@ package org.nl.ext; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import org.junit.jupiter.api.Test; import org.nl.common.utils.CodeUtil; +import org.nl.wms.ext.acs.service.dto.to.wms.ApplyDeviceDto; import org.nl.wms.ext.mes.service.WmsToMesService; import org.nl.wms.ext.mes.service.dao.mapper.MesRequestMapper; import org.springframework.beans.factory.annotation.Autowired; @@ -10,6 +13,7 @@ import org.springframework.boot.test.context.SpringBootTest; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.List; import java.util.concurrent.atomic.AtomicInteger; /** @@ -107,13 +111,28 @@ public class TestDemo { @Test void test03() throws InterruptedException { -// for (int i = 0; i < 50; i++) { -// System.out.println("生成标识code: " + CodeUtil.getNewCode("PDM_SHIFTORDER")); -// Thread.sleep(1000); -// } -// for (int i = 0; i < 5; i++) { -// new Thread(() -> System.out.println("生成标识code: " + CodeUtil.getNewCode("PDM_SHIFTORDER"))).start(); -// } + JSONObject jsonObject = new JSONObject(); + JSONArray res = new JSONArray(); + JSONObject r1 = new JSONObject(); + r1.put("device_code", "FJ2CDDJW01"); + r1.put("qty", "64887"); + r1.put("vehicle_code", "1033"); + JSONObject r2 = new JSONObject(); + r2.put("device_code", "FJ2CDDJW02"); + r2.put("qty", "64881"); + r2.put("vehicle_code", "1031"); + res.add(r1); + res.add(r2); + jsonObject.put("list", res); + //[{device_code=FJ2CDDJW01, qty=64826, vehicle_code=1096}, {device_code=FJ2CDDJW02, qty=64431, vehicle_code=1152}] + //[{"device_code":"FJ2CDDJW01","qty":"64887","vehicle_code":"1033"},{"device_code":"FJ2CDDJW02","qty":"64881","vehicle_code":"1031"}] + List list = JSONArray.parseArray(jsonObject.getString("list"), ApplyDeviceDto.class); + // 1 获取点位相应数量 + int sum = 0; + for (ApplyDeviceDto applyDeviceDto : list) { + sum += Integer.parseInt(applyDeviceDto.getQty()); + } + System.out.println(sum); } }