From b50a2e2df1c0fab844dc194ae58f01cf906e32b8 Mon Sep 17 00:00:00 2001 From: LSH Date: 星期一, 27 三月 2023 12:12:12 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/task/handler/OrderSyncHandler.java | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 46 insertions(+), 1 deletions(-) diff --git a/src/main/java/com/zy/asrs/task/handler/OrderSyncHandler.java b/src/main/java/com/zy/asrs/task/handler/OrderSyncHandler.java index 6571c51..ff7cf34 100644 --- a/src/main/java/com/zy/asrs/task/handler/OrderSyncHandler.java +++ b/src/main/java/com/zy/asrs/task/handler/OrderSyncHandler.java @@ -1,5 +1,8 @@ package com.zy.asrs.task.handler; +import com.alibaba.fastjson.JSON; +import com.core.common.Cools; +import com.core.common.DateUtils; import com.core.exception.CoolException; import com.zy.asrs.entity.DocType; import com.zy.asrs.entity.Order; @@ -11,12 +14,15 @@ import com.zy.asrs.task.AbstractHandler; import com.zy.asrs.task.core.ReturnT; import com.zy.common.service.erp.ErpService; +import com.zy.common.service.erp.entity.VoucherDetail; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; +import java.util.Date; import java.util.List; /** @@ -45,6 +51,15 @@ if (null == docType) { return SUCCESS; } + if (!Cools.isEmpty(docType.getMemo())) { + if (docType.getMemo().equals("hand")) { + // 淇敼璁㈠崟鐘舵�� 4.瀹屾垚 ===>> 6.宸蹭笂鎶� + if (!orderService.updateSettle(order.getId(), 6L, null)) { + throw new CoolException("鏈嶅姟鍣ㄥ唴閮ㄩ敊璇紝璇疯仈绯荤鐞嗗憳"); + } + return SUCCESS; + } + } List<OrderDetl> orderDetls = orderDetlService.selectByOrderId(order.getId()); // 鍏ュ簱瀹屾垚涓婃姤 if (docType.getPakin() == 1) { @@ -57,6 +72,11 @@ erpService.updateTimeForVoucherDetail(order.getOrderNo()); } + // 淇敼璁㈠崟鐘舵�� 4.瀹屾垚 ===>> 6.宸蹭笂鎶� + if (!orderService.updateSettle(order.getId(), 6L, null)) { + throw new CoolException("鏈嶅姟鍣ㄥ唴閮ㄩ敊璇紝璇疯仈绯荤鐞嗗憳"); + } + } catch (Exception e) { log.error("fail", e); return FAIL.setMsg(e.getMessage()); @@ -65,16 +85,41 @@ // 鍑哄簱瀹屾垚涓婃姤 if (docType.getPakout() == 1) { try { + double TotalNum = 0.0; + Integer TotalCount = orderDetls.size(); // erp 鍚屾 int state = 2; if (!erpService.updateStateForVoucher(order.getOrderNo(), state)) { throw new CoolException(order.getOrderNo() + "璁㈠崟淇敼State涓�"+state+"澶辫触"); } else { - erpService.updateTimeForVoucherDetail(order.getOrderNo()); + Date now = new Date(); + for (OrderDetl orderDetl : orderDetls) { + TotalNum = TotalNum + orderDetl.getAnfme(); + if (null == erpService.selectVoucherDetail(order.getOrderNo(), orderDetl.getBatch())) { + VoucherDetail voucherDetail = new VoucherDetail(); + voucherDetail.setVoucherID(order.getOrderNo()); + voucherDetail.setPickID("fepvnn0496"); + voucherDetail.setBarcode(orderDetl.getBatch()); + voucherDetail.setLastUpdatedDate(DateUtils.convert(now)); + if (!erpService.insertVoucherDetail(voucherDetail)) { + throw new CoolException(order.getOrderNo() + "璁㈠崟娣诲姞VoucherDetail"+ JSON.toJSONString(voucherDetail)+"澶辫触"); + } + } + } + } + // 鏇存柊閲嶉噺鍜屾暟閲� + if (!erpService.updateStateForVoucher(order.getOrderNo(), TotalNum, TotalCount)) { + throw new CoolException(order.getOrderNo() + "璁㈠崟淇敼閲嶉噺鍜屾暟閲忓け璐�"); + } + + // 淇敼璁㈠崟鐘舵�� 4.瀹屾垚 ===>> 6.宸蹭笂鎶� + if (!orderService.updateSettle(order.getId(), 6L, null)) { + throw new CoolException("鏈嶅姟鍣ㄥ唴閮ㄩ敊璇紝璇疯仈绯荤鐞嗗憳"); } } catch (Exception e) { log.error("fail", e); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); return FAIL.setMsg(e.getMessage()); } } -- Gitblit v1.9.1