fix:json转换错误
This commit is contained in:
@@ -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<ApplyDeviceDto> list = JSONArray.parseArray(param.getString("list"), ApplyDeviceDto.class);
|
||||
JSONArray array = param.getJSONArray("list");
|
||||
List<ApplyDeviceDto> 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;
|
||||
|
||||
@@ -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<ApplyDeviceDto> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user