Browse Source

新宝对接

DINGYL 2 years ago
parent
commit
3c9bbd82e0

+ 2 - 0
src/main/java/com/uas/eis/config/DonlimConfig.java

@@ -16,4 +16,6 @@ public class DonlimConfig {
     * 供应商code
     * */
    private String supplyCode;
+
+    private String supplyName;
 }

+ 21 - 0
src/main/java/com/uas/eis/dto/InventoryReq.java

@@ -0,0 +1,21 @@
+package com.uas.eis.dto;
+import com.alibaba.fastjson.JSONObject;
+import lombok.Data;
+import lombok.ToString;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Data
+@ToString(callSuper = true)
+public class InventoryReq extends BaseReq {
+    private JSONObject data;
+    public Map<String, Object> build(){
+       Map<String,Object> map = new HashMap<>();
+       map.put("signName", this.getSignName());
+       map.put("supplyCode", this.getSupplyCode());
+       map.put("timeStamp", this.getTimeStamp());
+        map.put("data", this.data);
+       return map;
+    }
+}

+ 16 - 0
src/main/java/com/uas/eis/dto/InventoryResp.java

@@ -0,0 +1,16 @@
+package com.uas.eis.dto;
+
+import java.util.List;
+
+public class InventoryResp extends BaseResp {
+
+    private String data;
+
+    public String getData() {
+        return data;
+    }
+
+    public void setData(String data) {
+        this.data = data;
+    }
+}

+ 71 - 0
src/main/java/com/uas/eis/task/InventoryTask.java

@@ -0,0 +1,71 @@
+package com.uas.eis.task;
+
+import com.alibaba.fastjson.JSONObject;
+import com.uas.eis.config.DonlimConfig;
+import com.uas.eis.dao.BaseDao;
+import com.uas.eis.dao.SqlRowList;
+import com.uas.eis.dto.InventoryReq;
+import com.uas.eis.dto.InventoryResp;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class InventoryTask extends BaseTask{
+    @Autowired
+    private DonlimConfig donlimConfig;
+    @Autowired
+    private BaseDao baseDao;
+
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+    public void execute() {
+        Object ob=baseDao.getFieldDataByCondition("DOCKING_XB_WH_CHANGE","max(ID_)","NVL(DEALSTATE,0)=0");
+        if(ob!=null){
+            try{
+                String Sql = "select * from DOCKING_Inventory where YM_VIEW_PARAM.SET_ID_("+ob+")<="+ob+" order by WAREHOUSENO, MATERIALNO";
+                SqlRowList rs = baseDao.queryForRowSet(Sql);
+                while (rs.next()) {
+                    JSONObject jsonobj=new JSONObject();
+                    jsonobj.put("supplyCode", donlimConfig.getSupplyCode());
+                    jsonobj.put("supplyName", donlimConfig.getSupplyName());
+                    jsonobj.put("warehouseNo", rs.getGeneralString("warehouseNo"));
+                    jsonobj.put("warehouseName", rs.getGeneralString("warehouseName"));
+                    jsonobj.put("materialNo", rs.getGeneralString("materialNo"));
+                    jsonobj.put("materialName", rs.getGeneralString("materialName"));
+                    jsonobj.put("materialSpecification", rs.getGeneralString("materialSpecification"));
+                    jsonobj.put("stockNum", rs.getGeneralInt("stockNum"));
+                    jsonobj.put("updateTime", rs.getGeneralString("updateTime"));
+                    jsonobj.put("bakOne", rs.getGeneralString("bakOne"));
+                    jsonobj.put("bakTwo", rs.getGeneralString("bakTwo"));
+                    jsonobj.put("bakThree", rs.getGeneralString("bakThree"));
+                    jsonobj.put("bakFour", rs.getGeneralString("bakFour"));
+
+                    InventoryReq req= new InventoryReq();
+                    req.setSupplyCode(donlimConfig.getSupplyCode());
+                    req.configSign();
+                    req.setData(jsonobj);
+                    HttpHeaders headers = new HttpHeaders();
+                    headers.setContentType(MediaType.APPLICATION_JSON);
+                    ResponseEntity<InventoryResp> resp = restTemplate.postForEntity(donlimConfig.getRoute()+"/wms/inventory", configHttpEntity(req), InventoryResp.class);
+                    assertOK(resp);
+                    logger.info("Inventory code {} ,msg {} ",resp.getBody().getCode(),resp.getBody().getMsg());
+                }
+                baseDao.execute("update DOCKING_XB_WH_CHANGE set dealdate_=sysdate ,DEALSTATE=1 where  ID_<="+ob+" and NVL(DEALSTATE,0)=0");
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        /*else{
+            logger.info("InventoryTask 无数据变更,无须对接 ");
+        }*/
+    }
+}

+ 7 - 1
src/main/java/com/uas/eis/task/SaleDownLoadTask.java

@@ -1,5 +1,6 @@
 package com.uas.eis.task;
 import com.uas.eis.config.DonlimConfig;
+import com.uas.eis.dao.BaseDao;
 import com.uas.eis.dto.SaleDownLoadDTO;
 import com.uas.eis.dto.SaleDownLoadReq;
 import com.uas.eis.dto.SaleDownLoadResp;
@@ -14,13 +15,15 @@ import java.util.List;
 public class SaleDownLoadTask extends BaseTask {
     @Autowired
     private DonlimConfig donlimConfig;
+    @Autowired
+    private BaseDao baseDao;
 
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
     public void execute() {
         SaleDownLoadReq req = new SaleDownLoadReq();
         req.setSupplyCode(donlimConfig.getSupplyCode());
         req.configSign();
-        req.setQueryTime("2023-06-10 12:30:00");
+        req.setQueryTime("2023-06-01 00:00:00");
         try {
             HttpHeaders headers = new HttpHeaders();
             headers.setContentType(MediaType.APPLICATION_JSON);
@@ -28,6 +31,9 @@ public class SaleDownLoadTask extends BaseTask {
             assertOK(resp);
             logger.info("SaleDownLoad code {} ,msg {} ",resp.getBody().getCode(),resp.getBody().getMsg());
             List<SaleDownLoadDTO> downLoadDTOS = resp.getBody().getData();
+            //记录对接日志
+            //对接数据写入中间表
+            //对接数据转入正式表
             logger.info("SaleDownLoad dataSize {}", downLoadDTOS.size());
         } catch (Exception e) {
             e.printStackTrace();

+ 36 - 0
src/main/resources/application-dev.yml

@@ -0,0 +1,36 @@
+spring:
+    datasource:
+        type: com.alibaba.druid.pool.DruidDataSource
+        driverClassName: oracle.jdbc.OracleDriver
+        username: AJC
+        password: select!#%*(
+        url: jdbc:oracle:thin:@10.1.81.208:11526:orcl
+        initialSize: 1
+        maxActive: 3
+        maxWait: 30000
+        testOnBorrow: false
+        testOnReturn: false
+        testWhileIdle: true
+        validationQuery: SELECT 1 FROM DUAL
+        timeBetweenEvictionRunsMillis: 60000
+        removeAbandoned: true
+        removeAbandonedTimeout: 1800
+        minEvictableIdleTimeMillis: 300000
+        poolPreparedStatements: true
+        maxPoolPreparedStatementPerConnectionSize: 3
+server:
+    tomcat:
+        uri_encoding: UTF-8
+    context-path:
+        /EIS
+    port: 8183
+
+action:
+    api_action: /EIS/api,/EIS/mes,/EIS/erp
+    public_actions: /EIS/logout,/EIS/hello1
+
+extral:
+    donlim:
+        route: http://scp.donlim.com/supply-api/open
+        supplyCode: VAJ008
+        supplyName: 深圳市安捷诚电子有限公司

+ 3 - 2
src/main/resources/application-prod.yml

@@ -2,7 +2,7 @@ spring:
     datasource:
         type: com.alibaba.druid.pool.DruidDataSource
         driverClassName: oracle.jdbc.OracleDriver
-        username: DATACENTER
+        username: N_AJC
         password: select!#%*(
         url: jdbc:oracle:thin:@10.1.81.208:11526:orcl
         initialSize: 1
@@ -32,4 +32,5 @@ action:
 extral:
     donlim:
         route: http://scp.donlim.com/supply-api/open
-        supplyCode: VAJ008
+        supplyCode: VAJ008
+        supplyName: 深圳市安捷诚电子有限公司