no message
							parent
							
								
									3c8d036aa9
								
							
						
					
					
						commit
						2a38649044
					
				| 
						 | 
					@ -95,29 +95,26 @@ public class MlsServiceImpl implements MlsService {
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void getOrderInfo(String resultJson) {
 | 
					    public void getOrderInfo(String resultJson) {
 | 
				
			||||||
        if (StringUtils.isEmpty(resultJson)) {
 | 
					        if (StringUtils.isEmpty(resultJson)) {
 | 
				
			||||||
            throw new RuntimeException("获取送货单接口失败!");
 | 
					            throw new IllegalArgumentException("获取送货单接口失败!");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        JSONObject resulObject = JSON.parseObject(resultJson);
 | 
					        JSONObject resulObject = JSON.parseObject(resultJson);
 | 
				
			||||||
        if (resulObject == null) {
 | 
					 | 
				
			||||||
            throw new RuntimeException("获取送货单接口返回数据为空!");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        String code = resulObject.getString("code") == null ? "" : resulObject.getString("code");
 | 
					        String code = resulObject.getString("code") == null ? "" : resulObject.getString("code");
 | 
				
			||||||
        String msg = resulObject.getString("msg") == null ? "" : resulObject.getString("msg");
 | 
					        String msg = resulObject.getString("msg") == null ? "" : resulObject.getString("msg");
 | 
				
			||||||
        //判断接口是否成功
 | 
					        //判断接口是否成功
 | 
				
			||||||
        if (!"0".equals(code)) {
 | 
					        if (!"0".equals(code)) {
 | 
				
			||||||
            throw new RuntimeException("获取送货单接口异常信息:" + msg);
 | 
					            throw new IllegalArgumentException("获取送货单接口异常信息:" + msg);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        String data = resulObject.getString("data") == null ? "" : resulObject.getString("data");
 | 
					        String data = resulObject.getString("data") == null ? "" : resulObject.getString("data");
 | 
				
			||||||
        JSONObject dataObject = JSON.parseObject(data);
 | 
					        if (StringUtils.isEmpty(data)) {
 | 
				
			||||||
        if (dataObject == null) {
 | 
					            throw new IllegalArgumentException("获取送货单接口返回数据为空!");
 | 
				
			||||||
            throw new RuntimeException("获取送货单接口返回数据为空!");
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        JSONObject dataObject = JSON.parseObject(data);
 | 
				
			||||||
        JSONArray details = dataObject.getJSONArray("list");
 | 
					        JSONArray details = dataObject.getJSONArray("list");
 | 
				
			||||||
        //判断是否有送货单数据
 | 
					        //判断是否有送货单数据
 | 
				
			||||||
        if (details == null || details.size() == 0) {
 | 
					        if (details == null || details.isEmpty()) {
 | 
				
			||||||
            throw new RuntimeException("没有获取到送货单数据!");
 | 
					            throw new IllegalArgumentException("没有获取到送货单数据!");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        List<Order> ordersToCreate = new ArrayList<>();//新增订单集合
 | 
					        List<Order> ordersToCreate = new ArrayList<>();//新增订单集合
 | 
				
			||||||
| 
						 | 
					@ -233,31 +230,29 @@ public class MlsServiceImpl implements MlsService {
 | 
				
			||||||
     * @return
 | 
					     * @return
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    @Transactional(rollbackFor = Exception.class)
 | 
					 | 
				
			||||||
    public void getMoInfo(String resultJson) {
 | 
					    public void getMoInfo(String resultJson) {
 | 
				
			||||||
        if (StringUtils.isEmpty(resultJson)) {
 | 
					        if (StringUtils.isEmpty(resultJson)) {
 | 
				
			||||||
            throw new RuntimeException("获取MO票接口失败!");
 | 
					            throw new IllegalArgumentException("MO票接口失败!");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        JSONObject resulObject = JSON.parseObject(resultJson);
 | 
					        JSONObject resulObject = JSON.parseObject(resultJson);
 | 
				
			||||||
        if (resulObject == null) {
 | 
					 | 
				
			||||||
            throw new RuntimeException("获取MO票接口返回数据为空!");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        String code = resulObject.getString("code") == null ? "" : resulObject.getString("code");
 | 
					        String code = resulObject.getString("code") == null ? "" : resulObject.getString("code");
 | 
				
			||||||
        String msg = resulObject.getString("msg") == null ? "" : resulObject.getString("msg");
 | 
					        String msg = resulObject.getString("msg") == null ? "" : resulObject.getString("msg");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!"0".equals(code)) {
 | 
					        if (!"0".equals(code)) {
 | 
				
			||||||
            throw new RuntimeException("获取MO票接口异常信息:" + msg);
 | 
					            throw new IllegalArgumentException("MO票接口异常: " + msg);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        String data = resulObject.getString("data") == null ? "" : resulObject.getString("data");
 | 
					        String data = resulObject.getString("data") == null ? "" : resulObject.getString("data");
 | 
				
			||||||
        JSONObject dataObject = JSON.parseObject(data);
 | 
					        if (StringUtils.isEmpty(data)) {
 | 
				
			||||||
        if (dataObject == null) {
 | 
					            throw new IllegalArgumentException("获取MO票接口返回数据为空!");
 | 
				
			||||||
            throw new RuntimeException("获取MO票接口返回数据为空!");
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        JSONObject dataObject = JSON.parseObject(data);
 | 
				
			||||||
        JSONArray details = dataObject.getJSONArray("list");
 | 
					        JSONArray details = dataObject.getJSONArray("list");
 | 
				
			||||||
        //判断是否有MO票数据
 | 
					        //判断是否有MO票数据
 | 
				
			||||||
        if (details == null || details.size() == 0) {
 | 
					        if (details == null || details.isEmpty()) {
 | 
				
			||||||
            throw new RuntimeException("没有获取到MO票数据!");
 | 
					            throw new IllegalArgumentException("未获取到MO票数据!");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        List<Mo> mosToCreate = new ArrayList<>();//新增Mo集合
 | 
					        List<Mo> mosToCreate = new ArrayList<>();//新增Mo集合
 | 
				
			||||||
| 
						 | 
					@ -278,21 +273,11 @@ public class MlsServiceImpl implements MlsService {
 | 
				
			||||||
        Map<String, Mo> existingMos = moService.findBylabelNos(labelNos);
 | 
					        Map<String, Mo> existingMos = moService.findBylabelNos(labelNos);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //获取仓库
 | 
					        //获取仓库
 | 
				
			||||||
        Dept dept = null;
 | 
					        Dept dept = getDeptFromCache();
 | 
				
			||||||
        boolean flag = redisUtils.hasKey("dept");
 | 
					 | 
				
			||||||
        if (flag) {
 | 
					 | 
				
			||||||
            dept = (Dept) redisUtils.get("dept");
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            DeptDto deptDto = deptService.findById(7L);
 | 
					 | 
				
			||||||
            dept = deptService.toEntity(deptDto);
 | 
					 | 
				
			||||||
            redisUtils.set("dept", dept);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //循环处理每个MO票
 | 
					        //循环处理每个MO票
 | 
				
			||||||
        for (int i = 0; i < details.size(); i++) {
 | 
					        for (int i = 0; i < details.size(); i++) {
 | 
				
			||||||
            JSONObject detail = details.getJSONObject(i);
 | 
					            JSONObject detail = details.getJSONObject(i);
 | 
				
			||||||
            String labelState = detail.getString("labelState");//标签状态
 | 
					 | 
				
			||||||
            //物料编码
 | 
					            //物料编码
 | 
				
			||||||
            String itemCode = detail.getString("itemCode").trim();
 | 
					            String itemCode = detail.getString("itemCode").trim();
 | 
				
			||||||
            Item item = null;
 | 
					            Item item = null;
 | 
				
			||||||
| 
						 | 
					@ -328,6 +313,22 @@ public class MlsServiceImpl implements MlsService {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private Dept getDeptFromCache() {
 | 
				
			||||||
 | 
					        // 从缓存中获取部门信息
 | 
				
			||||||
 | 
					        Dept dept = (Dept) redisUtils.get("dept");
 | 
				
			||||||
 | 
					        if (dept == null) {
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                // 缓存中不存在,从数据库中获取
 | 
				
			||||||
 | 
					                DeptDto deptDto = deptService.findById(7L);
 | 
				
			||||||
 | 
					                dept = deptService.toEntity(deptDto);
 | 
				
			||||||
 | 
					                redisUtils.set("dept", dept); // 存储到缓存,可考虑设置适当的过期时间或不设
 | 
				
			||||||
 | 
					            } catch (Exception e) {
 | 
				
			||||||
 | 
					                e.printStackTrace();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return dept;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 创建订单
 | 
					     * 创建订单
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue