|
|
@@ -1,23 +1,36 @@
|
|
|
package com.style24.batch.biz.service;
|
|
|
|
|
|
+import java.net.URI;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Collection;
|
|
|
-
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-
|
|
|
+import org.springframework.core.env.Environment;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
import com.gagaframework.web.parameter.GagaMap;
|
|
|
+import com.google.gson.Gson;
|
|
|
+import com.google.gson.GsonBuilder;
|
|
|
+import com.google.gson.reflect.TypeToken;
|
|
|
import com.style24.batch.biz.dao.TsbDeliveryDao;
|
|
|
import com.style24.batch.support.env.TsbConstants;
|
|
|
import com.style24.persistence.domain.Delivery;
|
|
|
-
|
|
|
+import com.style24.persistence.domain.ErpStock;
|
|
|
import com.style24.core.support.env.TscConstants.OrderDetailStat;
|
|
|
+import com.style24.core.support.env.TscConstants.OrderChangeStat;
|
|
|
import com.style24.core.biz.dao.TscOrderDao;
|
|
|
+import com.style24.core.biz.service.TscErpService;
|
|
|
+import com.style24.core.biz.service.TscWmsService;
|
|
|
import com.style24.persistence.domain.Order;
|
|
|
-
|
|
|
+import com.style24.persistence.domain.WmsDelivery;
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 배치 Service
|
|
|
*
|
|
|
@@ -28,12 +41,25 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
@Slf4j
|
|
|
public class TsbDeliveryService {
|
|
|
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private Environment env;
|
|
|
+
|
|
|
@Autowired
|
|
|
private TsbDeliveryDao deliveryDao;
|
|
|
|
|
|
@Autowired
|
|
|
private TscOrderDao orderDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RestTemplate restTemplate;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TscWmsService wmsService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TscErpService erpService;
|
|
|
+
|
|
|
/**
|
|
|
* 총알배송 권역정보 갱신
|
|
|
* @param Collection<Delivery>
|
|
|
@@ -140,7 +166,7 @@ public class TsbDeliveryService {
|
|
|
|
|
|
// 출고예외 등록 -H
|
|
|
for(Delivery data : list) {
|
|
|
- data.setOrdDtlStat(OrderDetailStat.SHIP_COMPLETE.value());
|
|
|
+ data.setOrdDtlStat(OrderDetailStat.SHIPPING.value());
|
|
|
data.setUpdNo(TsbConstants.REG_NO);
|
|
|
deliveryDao.updateTbOrderDtlStat(data);
|
|
|
|
|
|
@@ -154,4 +180,222 @@ public class TsbDeliveryService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 회수결과 처리
|
|
|
+ * @param Delivery
|
|
|
+ * @return
|
|
|
+ * @author moon
|
|
|
+ * @since 2021. 03. 19
|
|
|
+ */
|
|
|
+ @Transactional("shopTxnManager")
|
|
|
+ public void createWithdraw(Delivery delivery) {
|
|
|
+
|
|
|
+ delivery.setRegNo(TsbConstants.REG_NO);
|
|
|
+
|
|
|
+ // TB_WITHDRAW 입력
|
|
|
+ deliveryDao.insertTbWithdraw(delivery);
|
|
|
+ // TB_WITHDRAW_DETAIL 입력
|
|
|
+ deliveryDao.insertTbWithdrawDetail(delivery);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 주문정보 조회
|
|
|
+ * @param Delivery
|
|
|
+ * @return Delivery
|
|
|
+ * @author moon
|
|
|
+ * @since 2021. 03. 23
|
|
|
+ */
|
|
|
+ public Delivery getOrderInfoList(Delivery delivery) {
|
|
|
+
|
|
|
+ Delivery orderInfo = deliveryDao.getOrderInfoList(delivery);
|
|
|
+ return orderInfo ;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 회수결과 주문변경 처리
|
|
|
+ * @param Delivery
|
|
|
+ * @return
|
|
|
+ * @author moon
|
|
|
+ * @since 2021. 03. 25
|
|
|
+ */
|
|
|
+ @Transactional("shopTxnManager")
|
|
|
+ public void updateOrderChange(Delivery delivery) {
|
|
|
+
|
|
|
+ delivery.setRegNo(TsbConstants.REG_NO);
|
|
|
+ delivery.setChgStat(OrderChangeStat.EXCHANGE_COMPLETE.value()); // 교환완료
|
|
|
+ // TB_ORDER_CHANGE
|
|
|
+ deliveryDao.updateTbOrderChange(delivery);
|
|
|
+ // TB_ORDER_CHANGE_DETAIL
|
|
|
+ deliveryDao.updateTbOrderChangeDetail(delivery);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 회수결과 - 주문상세 상태값 변경
|
|
|
+ * @param Delivery
|
|
|
+ * @return
|
|
|
+ * @author moon
|
|
|
+ * @since 2021. 03. 25
|
|
|
+ */
|
|
|
+ @Transactional("shopTxnManager")
|
|
|
+ public void updateWdOrderDtlStat(Delivery data ) {
|
|
|
+
|
|
|
+ data.setOrdDtlStat(OrderDetailStat.PAYMENT_AFTER_CANCEL.value()); //
|
|
|
+ data.setUpdNo(TsbConstants.REG_NO);
|
|
|
+ deliveryDao.updateWdOrderDtlStat(data);
|
|
|
+
|
|
|
+ // 주문상세이력
|
|
|
+ Order order = new Order();
|
|
|
+ order.setOrdDtlNo(data.getOrderdtlno());
|
|
|
+ order.setUpdNo(TsbConstants.REG_NO);
|
|
|
+ order.setRegNo(TsbConstants.REG_NO);
|
|
|
+ orderDao.createOrderDetailHst(order);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 교환대기 상태값변경
|
|
|
+ * @param Delivery
|
|
|
+ * @return
|
|
|
+ * @author moon
|
|
|
+ * @since 2021. 03. 25
|
|
|
+ */
|
|
|
+ @Transactional("shopTxnManager")
|
|
|
+ public void updateOrderExch(Delivery data) {
|
|
|
+
|
|
|
+ data.setOrdDtlStat(OrderDetailStat.PAYMENT_COMPLETE.value());
|
|
|
+ data.setUpdNo(TsbConstants.REG_NO);
|
|
|
+ deliveryDao.updateOrderExch(data);
|
|
|
+
|
|
|
+ // 주문상세이력
|
|
|
+ Order order = new Order();
|
|
|
+ order.setOrdDtlNo(data.getChgOrdDtlNo());
|
|
|
+ order.setUpdNo(TsbConstants.REG_NO);
|
|
|
+ order.setRegNo(TsbConstants.REG_NO);
|
|
|
+ orderDao.createOrderDetailHst(order);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 출고 송장번호 등록
|
|
|
+ * @param Delivery
|
|
|
+ * @return
|
|
|
+ * @author moon
|
|
|
+ * @since 2021. 03. 25
|
|
|
+ */
|
|
|
+ @Transactional("shopTxnManager")
|
|
|
+ public void saveInvoice(Delivery data) {
|
|
|
+
|
|
|
+ data.setOrdDtlStat(OrderDetailStat.PAYMENT_COMPLETE.value());
|
|
|
+ data.setUpdNo(TsbConstants.REG_NO);
|
|
|
+ deliveryDao.insertTbOrdDtlInvoice(data);
|
|
|
+
|
|
|
+ if("N".equals(data.getAddinvoiceyn())){
|
|
|
+ data.setOrdDtlStat(OrderDetailStat.DELIVERY_PREPARE.value()); // DELIVERY_PREPARE("G013_40"), // 배송준비중
|
|
|
+ // INVOICE_SEND_YN Y N 대상 확인후 case에 반영
|
|
|
+
|
|
|
+ deliveryDao.updateOrdDtlStat(data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 실시간 재고조회(WMS&ERP)
|
|
|
+ * @param Delivery
|
|
|
+ * @return Collection<WmsDelivery> stockLoc:WH-wms 외 매장코드 locQty: 수량
|
|
|
+ * @author moon
|
|
|
+ * @since 2021. 03. 28
|
|
|
+ */
|
|
|
+ public Collection<WmsDelivery> getRealStock(Integer productNo, String skuCode, String styleCd, String colorCd, String sizeCd) {
|
|
|
+
|
|
|
+ //// 임시
|
|
|
+// productNo = 14475554;
|
|
|
+// skuCode = "13096364-5"; // "13096364-5"
|
|
|
+// styleCd = "COF0GABL02";
|
|
|
+// colorCd = "CE"; //"CE"
|
|
|
+// sizeCd = "150";
|
|
|
+ //////
|
|
|
+
|
|
|
+ Collection<WmsDelivery> list = new ArrayList();
|
|
|
+ String chk1 = "N";
|
|
|
+ String chk2 = "N";
|
|
|
+
|
|
|
+
|
|
|
+ WmsDelivery wmsRtn = wmsService.getWmsRealStock(productNo, skuCode);
|
|
|
+
|
|
|
+ Collection<ErpStock> erpRtnList = erpService.getErpRealStock(styleCd, colorCd, sizeCd);
|
|
|
+
|
|
|
+ if(wmsRtn != null ) {
|
|
|
+ list.add(wmsRtn);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ chk1 = "Y";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!"".equals(erpRtnList) && erpRtnList != null) {
|
|
|
+ for(ErpStock data : erpRtnList) {
|
|
|
+ WmsDelivery tmp = new WmsDelivery();
|
|
|
+ tmp.setStockLoc(data.getStockLoc());
|
|
|
+ tmp.setLocQty(data.getLocQty());
|
|
|
+ list.add(tmp);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ chk2 = "Y";
|
|
|
+ }
|
|
|
+
|
|
|
+ if("Y".equals(chk1) && "Y".equals(chk2)) {
|
|
|
+ list = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * ERP 매장상품재고 조회 및 등록
|
|
|
+ * @param Delivery
|
|
|
+ * @return
|
|
|
+ * @author moon
|
|
|
+ * @since 2021. 03. 28
|
|
|
+ */
|
|
|
+ public void saveErpGoodsStock() {
|
|
|
+
|
|
|
+ String erpurl = env.getProperty("erp.api.stock.url");
|
|
|
+ GagaMap resultMap = new GagaMap();
|
|
|
+
|
|
|
+ URI url = URI.create(erpurl);
|
|
|
+
|
|
|
+ ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class);
|
|
|
+ HttpStatus status = responseEntity.getStatusCode();
|
|
|
+
|
|
|
+ log.info("erpurl 호출결과: "+status.name());
|
|
|
+
|
|
|
+ if("OK".equals(status.name())) {
|
|
|
+
|
|
|
+ String jsonResult = responseEntity.getBody();
|
|
|
+
|
|
|
+
|
|
|
+ Gson gson = new GsonBuilder().create();
|
|
|
+ resultMap = gson.fromJson(jsonResult, GagaMap.class);
|
|
|
+
|
|
|
+ String GoodsInfo = resultMap.get("GoodsInfo").toString();
|
|
|
+
|
|
|
+ List<Map<String, Object>> List = null;
|
|
|
+ List = gson.fromJson(GoodsInfo, new TypeToken<List<Map<String, Object>>>() {}.getType());
|
|
|
+
|
|
|
+ deliveryDao.deleteShopStock();
|
|
|
+
|
|
|
+ for(int i=0; i<List.size(); i++) {
|
|
|
+ Map data = List.get(i);
|
|
|
+ Delivery goods = new Delivery();
|
|
|
+ goods.setRegNo(TsbConstants.REG_NO);
|
|
|
+ goods.setSupplyCompCd(TsbConstants.COMPANY_CD_DR); // 1003 한세드립
|
|
|
+ goods.setCdShop(data.get("CD_SHOP").toString());
|
|
|
+ goods.setCdStyle(data.get("CD_STYLE").toString());
|
|
|
+ goods.setCdColor(data.get("CD_COLOR").toString());
|
|
|
+ goods.setCdSize(data.get("CD_SIZE").toString());
|
|
|
+ goods.setQtStock((int)Double.parseDouble(data.get("QT_STOCK").toString()));
|
|
|
+ deliveryDao.insertShopStock(goods);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|