| | |
| | | /** |
| | | * 轮询获取入库订单 |
| | | */ |
| | | @Scheduled(cron = "0/10 * * * * ? ") |
| | | private void execute() { |
| | | @Scheduled(cron = "0/30 * * * * ? ") |
| | | private synchronized void execute() { |
| | | // 获取当前日期时间 |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | |
| | |
| | | // 格式化日期时间 |
| | | String formattedDateTime = oneMonthAgo.format(formatter); |
| | | |
| | | HashMap<String ,Object> hashMap=new HashMap<>(); |
| | | |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("orgNo", 0);//组织编号 |
| | | |
| | | map.put("orgNo", "2");//组织编号 |
| | | // map.put("docNo",0); |
| | | map.put("startTime", formattedDateTime);//开始时间 |
| | | |
| | | String format = now.format(formatter); |
| | | map.put("endTime", format);//结束时间 |
| | | |
| | | hashMap.put("condition",map); |
| | | |
| | | //查询订单 |
| | | String response = ""; |
| | |
| | | response = new HttpHandler.Builder() |
| | | .setUri(URL) |
| | | .setPath(inaddress) |
| | | .setJson(JSON.toJSONString(map)) |
| | | .setJson(JSON.toJSONString(hashMap)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("status") == 200) { |
| | | JSONArray response1 = JSON.parseArray(jsonObject.get("response").toString()); |
| | | for (int j = 0; j < response1.size(); j++) { |
| | | OrderResult orderResult = response1.getObject(0, OrderResult.class); |
| | | OrderResult orderResult = response1.getObject(j, OrderResult.class); |
| | | Order order = orderService.selectByNo(orderResult.getDocNo());//单据编号 |
| | | if (Cools.isEmpty(order)) { |
| | | Date now1 = new Date(); |
| | |
| | | now1, // 修改时间 |
| | | null // 备注 |
| | | ); |
| | | if (!orderService.insert(order)) { |
| | | throw new CoolException("生成单据失败,请联系管理员"); |
| | | } |
| | | } |
| | | //物料编码 |
| | | Mat mat = matService.selectByMatnr(orderResult.getItemNo()); |
| | | if (Cools.isEmpty(mat)) { |
| | | throw new CoolException(orderResult.getItemNo() + "编号商品检索失败,请先添加商品"); |
| | | Mat mat1=new Mat(); |
| | | mat1.setTagId(1L); |
| | | mat1.setMatnr(orderResult.getItemNo()); |
| | | mat1.setMaktx(orderResult.getItemName()); |
| | | mat1.setSpecs(orderResult.getItemSpec()); |
| | | matService.insert(mat1); |
| | | // throw new CoolException(orderResult.getItemNo() + "编号商品检索失败,请先添加商品"); |
| | | } |
| | | OrderDetl orderDetl1 = orderDetlService.selectOne(new EntityWrapper<OrderDetl>() |
| | | .eq("order_no", orderResult.getDocNo()) |
| | | .eq("matnr", orderResult.getItemNo()) |
| | | .eq("batch", orderResult.getDocLotNo()));//批号 |
| | | if(Cools.isEmpty(orderResult.getDocLotNo())){ |
| | | orderDetl1 = orderDetlService.selectOne(new EntityWrapper<OrderDetl>() |
| | | .eq("order_no", orderResult.getDocNo()) |
| | | .eq("matnr", orderResult.getItemNo())); |
| | | } |
| | | |
| | | if (!Cools.isEmpty(orderDetl1)) { |
| | | continue; |
| | | } |
| | | DocType docType = docTypeService.selectById(orderResult.getDocType()); |
| | | OrderDetl orderDetl = new OrderDetl(); |
| | | orderDetl.sync(mat); |
| | | orderDetl.setMatnr(orderResult.getItemNo()); |
| | | orderDetl.setMaktx(orderResult.getItemName()); |
| | | orderDetl.setSpecs(orderResult.getItemSpec()); |
| | | orderDetl.setBatch(orderResult.getDocLotNo()); |
| | | orderDetl.setAnfme(orderResult.getApplyQty()); |
| | | orderDetl.setOrderId(order.getId()); |