| | |
| | | import zy.cloud.wms.manager.entity.CustOrder; |
| | | import zy.cloud.wms.manager.entity.Mat; |
| | | import zy.cloud.wms.manager.entity.Tag; |
| | | import zy.cloud.wms.manager.mapper.CustOrderMapper; |
| | | import zy.cloud.wms.manager.mapper.TagMapper; |
| | | import zy.cloud.wms.manager.service.*; |
| | | import zy.cloud.wms.manager.utils.HttpHandler; |
| | | import zy.cloud.wms.manager.utils.NodeUtils; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | public static final String URI = "http://8.133.182.21:8080/api"; |
| | | public static final String GET_ORDERS = "cM/basis/getOrders"; |
| | | public static final String GET_BASIS = "cM/basis/getBasis"; |
| | | public static final String UPLOAD_BILL = "cM/basis/uploadBill"; |
| | | public static final String UPLOAD_STOCK = "cM/basis/uploadStock"; |
| | | |
| | | @Autowired |
| | |
| | | private TagService tagService; |
| | | @Autowired |
| | | private TagMapper tagMapper; |
| | | @Autowired |
| | | private CustOrderMapper custOrderMapper; |
| | | |
| | | /** |
| | | * 商品下载 |
| | |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 持久化销售订单 |
| | | */ |
| | | @Scheduled(cron = "0/5 * * * * ? ") |
| | | @Scheduled(cron = "0/45 * * * * ? ") |
| | | @Transactional |
| | | // @PostConstruct |
| | | public void getOrdersExecute(){ |
| | |
| | | .eq("number", data.getNumber()) |
| | | // .ne("bType_id", data.getBTypeID()) |
| | | ) > 0) { |
| | | log.error("{}单号已存在", data.getNumber()); |
| | | // log.error("{}单号已存在", data.getNumber()); |
| | | complete = false; |
| | | continue; |
| | | } |
| | | for (GetOrderResultDetl0 detl0 : data.getDetail()) { |
| | |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException(e.getMessage()); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 完成销售订单 |
| | | */ |
| | | // @Scheduled(cron = "0/10 * * * * ? ") |
| | | @Transactional |
| | | // @PostConstruct |
| | | public void finishOrdersExecute(){ |
| | | try { |
| | | List<CustOrder> custOrders = custOrderService.selectList(new EntityWrapper<CustOrder>().eq("status", 4)); |
| | | if (!Cools.isEmpty(custOrders)) { |
| | | List<String> numbers = custOrders.stream().map(CustOrder::getNumber).distinct().collect(Collectors.toList()); |
| | | for (String number : numbers) { |
| | | GetOrderResult0 getOrderResult0 = new GetOrderResult0(); |
| | | List<GetOrderResultDetl0> list = new ArrayList<>(); |
| | | getOrderResult0.setDetail(list); |
| | | // 遍历递减 |
| | | Iterator<CustOrder> iterator = custOrders.iterator(); |
| | | while (iterator.hasNext()) { |
| | | CustOrder custOrder = iterator.next(); |
| | | if (custOrder.getNumber().equals(number)) { |
| | | // 表头 |
| | | if (Cools.isEmpty(getOrderResult0.getNumber())) { |
| | | getOrderResult0.setNumber(number); |
| | | getOrderResult0.setVchType(11); // todo:luxiaotao |
| | | getOrderResult0.setBillDate(custOrder.getBillDate()); |
| | | getOrderResult0.setBTypeID(custOrder.getBTypeId()); |
| | | getOrderResult0.setKTypeID("宏挺仓库"); |
| | | } |
| | | // 表体 |
| | | GetOrderResultDetl0 detl0 = new GetOrderResultDetl0(); |
| | | detl0.setUserCode(custOrder.getUserCode()); |
| | | detl0.setQty(custOrder.getQty()); |
| | | detl0.setPrice(custOrder.getPrice()); |
| | | detl0.setComment(custOrder.getComment()); |
| | | list.add(detl0); |
| | | iterator.remove(); |
| | | } |
| | | } |
| | | |
| | | System.out.println(JSON.toJSONString(getOrderResult0)); |
| | | |
| | | |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(URI) |
| | | .setPath(UPLOAD_BILL) |
| | | .setJson(JSON.toJSONString(getOrderResult0)) |
| | | .build() |
| | | .doPost(); |
| | | if (!Cools.isEmpty(response)) { |
| | | log.warn(response); |
| | | Result result = JSON.parseObject(response, Result.class); |
| | | if (result.getCode() != 1) { |
| | | return; |
| | | } |
| | | // 转历史档 |
| | | int save = custOrderMapper.saveLog(getOrderResult0.getNumber()); |
| | | if (save > 0) { |
| | | if (custOrderMapper.delete(new EntityWrapper<CustOrder>().eq("number", getOrderResult0.getNumber())) == 0) { |
| | | throw new CoolException("删除销售订单失败"); |
| | | } |
| | | log.info("{}销售订单拣货结束", getOrderResult0.getNumber()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException(e.getMessage()); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 更新库存 |
| | |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException(e.getMessage()); |
| | | } |
| | | |
| | | |