|
|
@@ -0,0 +1,115 @@
|
|
|
+package com.style24.batch.biz.job.statistics;
|
|
|
+
|
|
|
+import java.util.Collection;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import com.style24.batch.biz.job.TsbAbstractJob;
|
|
|
+import com.style24.batch.biz.service.TsbStatisticsService;
|
|
|
+import com.style24.core.biz.thirdparty.HansaeErp;
|
|
|
+import com.style24.persistence.domain.Erp;
|
|
|
+
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+
|
|
|
+import com.gagaframework.web.parameter.GagaMap;
|
|
|
+import com.gagaframework.web.util.GagaStringUtil;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 한세드림 ERP 매출반영
|
|
|
+ *
|
|
|
+ * @author gagamel
|
|
|
+ * @since 2021. 10. 7
|
|
|
+ */
|
|
|
+@Component
|
|
|
+@Slf4j
|
|
|
+public class TsbSalesUploadHsdrJob extends TsbAbstractJob<String, String, String> {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TsbStatisticsService statisticsService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private HansaeErp hansaeErp;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String read() throws Exception {
|
|
|
+ return "OK";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String process(String result) throws Exception {
|
|
|
+ for (int i = 1; i <= 30; i++) {
|
|
|
+ String dtSale = "202109" + GagaStringUtil.getLPadding(String.valueOf(i), 2, "0");
|
|
|
+
|
|
|
+ // 한세드림 매출반영
|
|
|
+ this.uploadSales(HansaeErp.ErpGb.HANSAE_DR.value(), dtSale);
|
|
|
+ }
|
|
|
+
|
|
|
+ return "OK";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String write(String result) throws Exception {
|
|
|
+ return "OK";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void notify(String result) throws Exception {
|
|
|
+ // Do nothing
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 매출반영
|
|
|
+ * @param erpGb - ERP구분(hsmk:한세MK, hsdr:한세드림)
|
|
|
+ * @param dtSale - 판매일자
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ private void uploadSales(String erpGb, String dtSale) throws Exception {
|
|
|
+ // 매출반영 브랜드 목록
|
|
|
+ Collection<String> brandList = statisticsService.getSalesUploadBrandList2(erpGb, dtSale);
|
|
|
+
|
|
|
+ if (brandList == null || brandList.isEmpty()) {
|
|
|
+ log.info("매출반영할 브랜드 목록이 없습니다.");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (String brandCd : brandList) {
|
|
|
+ Erp erp = new Erp();
|
|
|
+ erp.setErpGb(erpGb);
|
|
|
+ erp.setBrandCd(brandCd);
|
|
|
+ erp.setDtSale(dtSale);
|
|
|
+
|
|
|
+ // 매출업로드 목록
|
|
|
+ Collection<GagaMap> uploadList = statisticsService.getSalesUploadList2(erp);
|
|
|
+
|
|
|
+ if (uploadList == null || uploadList.isEmpty()) {
|
|
|
+ log.error("{}-{} 브랜드의 매출반영할 데이터가 없습니다.", erpGb, brandCd);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 매출반영I/F번호 조회
|
|
|
+ String noIf = statisticsService.getSalesUploadInterfaceNo(erpGb);
|
|
|
+ log.info("매출반영I/F번호: {}", noIf);
|
|
|
+
|
|
|
+ for (GagaMap dataMap : uploadList) {
|
|
|
+ // 매출반영목록 I/F번호 Update
|
|
|
+ dataMap.setString("NO_IF", noIf);
|
|
|
+ statisticsService.updateSalesUploadListInterfaceNo(erpGb, dataMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 매출업로드
|
|
|
+ GagaMap salesMap = hansaeErp.uploadErpSales(erpGb, uploadList);
|
|
|
+
|
|
|
+ if (salesMap == null || salesMap.isEmpty()) {
|
|
|
+ log.error("{}-{} 브랜드의 매출반영결과 데이터가 없습니다. 한세 ERP 시스템담당자에게 문의해 주세요.", erpGb, brandCd);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 매출반영결과 처리
|
|
|
+ statisticsService.updateSalesUploadResult(erpGb, salesMap);
|
|
|
+
|
|
|
+ log.info("{}-{} 브랜드의 매출반영 업로드 성공", erpGb, brandCd);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|