Browse Source

[深爱]获取客商数据

zxl 1 year ago
parent
commit
ec785a09d1

+ 6 - 0
pom.xml

@@ -181,6 +181,12 @@
 			<version>RELEASE</version>
 			<scope>compile</scope>
 		</dependency>
+
+		<dependency>
+			<groupId>cn.hutool</groupId>
+			<artifactId>hutool-all</artifactId>
+			<version>5.8.26</version>
+		</dependency>
 		<!--<dependency>
 			<groupId>sf-sdk</groupId>
 			<artifactId>sf-csim-express</artifactId>

+ 36 - 0
src/main/java/com/uas/eis/controller/STKController.java

@@ -1,11 +1,17 @@
 package com.uas.eis.controller;
 
+import com.alibaba.fastjson.JSONObject;
+import com.uas.eis.dto.stksto.QueryTravellingMerchantDto;
 import com.uas.eis.sdk.dto.AssistBalanceDTO;
+import com.uas.eis.sdk.dto.CustvendDTO;
 import com.uas.eis.sdk.dto.Md5TestVo;
 import com.uas.eis.sdk.entity.ApiResult;
+import com.uas.eis.service.RequestSTKService;
 import com.uas.eis.service.STKService;
 import com.uas.eis.utils.MD5Util;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
@@ -16,11 +22,15 @@ import java.util.*;
  * @author zhuxl
  * @date 2024-10-12
  */
+@Slf4j
 @RestController
 public class STKController {
     @Autowired
     private STKService stkService;
 
+    @Autowired
+    private RequestSTKService requestSTKService;
+
     /**
      * 获取科目余额表-总条数
      */
@@ -107,4 +117,30 @@ public class STKController {
         vo.setSignature(MD5Util.encrypt32Up(temp.toString()));
         return vo;
     }
+
+
+    /**
+     * 模拟客商数据信息
+     * */
+    @PostMapping("/queryTestList")
+    public List<CustvendDTO> queryTestList(@RequestBody QueryTravellingMerchantDto dto){
+        log.info("请求参数:{}", JSONObject.toJSONString(dto));
+        return requestSTKService.queryList();
+    }
+
+    /**
+     * 获取客商信息接口编码
+     * */
+    @Value("${STK.get_travelling_merchant}")
+    private String GET_TRAVELLING_MERCHANT;
+
+
+    @GetMapping("/queryListTest")
+    public List<CustvendDTO> queryListTest(){
+        QueryTravellingMerchantDto dto = new QueryTravellingMerchantDto();
+        dto.setCode(GET_TRAVELLING_MERCHANT);
+        return requestSTKService.selectTravellingMerchantList(dto,"http://192.168.1.104:8186/eis_cw/queryTestList");
+    }
+
+
 }

+ 32 - 0
src/main/java/com/uas/eis/dto/stksto/QueryTravellingMerchantDto.java

@@ -0,0 +1,32 @@
+package com.uas.eis.dto.stksto;
+
+
+import lombok.Data;
+
+/**
+ * 查询深投控客商信息Dto
+ * */
+@Data
+public class QueryTravellingMerchantDto extends STKPageDto {
+
+    /**
+     *开始时间
+     * */
+    private String startTime;
+
+    /**
+     * 结束时间
+     * */
+    private String endTime;
+
+    /**
+     * 接口编码
+     * */
+    private String code;
+
+    /**
+     * 组织编码
+     * */
+    private String s_orgcode;
+
+}

+ 22 - 0
src/main/java/com/uas/eis/dto/stksto/STKPageDto.java

@@ -0,0 +1,22 @@
+package com.uas.eis.dto.stksto;
+
+
+import lombok.Data;
+
+/**
+ * 深投控分页参数
+ * */
+@Data
+public class STKPageDto {
+
+    /**
+     * 页码
+     * */
+    private Integer page;
+
+    /**
+     *每页数量
+     * */
+    private Integer size;
+
+}

+ 46 - 0
src/main/java/com/uas/eis/sdk/dto/CustvendDTO.java

@@ -0,0 +1,46 @@
+package com.uas.eis.sdk.dto;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+
+/**
+ * dto说明
+ * */
+
+@Data
+@NoArgsConstructor
+public class CustvendDTO {
+
+    /**
+     *主键ID
+     * */
+    private int id;
+    private int s_id;
+    private String s_code;
+    private String name;
+    private String uid_type;
+    private String uid;
+    private String customer_type;
+    private String is_valid;
+    private String created_org;
+    private String created_system;
+    private String istemporary;
+    private String mdm_code;
+    private String reg_country;
+    private String reg_place;
+    private String reg_rep;
+    private String reg_captial;
+    private String reg_period;
+    private String reg_bizscope;
+    private Date reg_foundeddate;
+    private String reg_url;
+    private String reg_address;
+    private Date creat_time;
+    private Date update_time;
+    private String serial;
+
+}

+ 138 - 0
src/main/java/com/uas/eis/service/Impl/RequestSTKServiceImpl.java

@@ -0,0 +1,138 @@
+package com.uas.eis.service.Impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.uas.eis.dao.BaseDao;
+import com.uas.eis.dao.SqlRowList;
+import com.uas.eis.dto.stksto.QueryTravellingMerchantDto;
+import com.uas.eis.sdk.dto.CustvendDTO;
+import com.uas.eis.service.RequestSTKService;
+import com.uas.eis.utils.HttpUtil;
+import com.uas.eis.utils.HuToolUtils;
+import com.uas.eis.utils.STKSignUtil;
+import com.uas.eis.vo.stkVo.HttpResultResponse;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.stereotype.Service;
+
+import javax.xml.ws.ServiceMode;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+@Slf4j
+public class RequestSTKServiceImpl implements RequestSTKService {
+
+
+    @Value("${STK.app_id}")
+    private String STK_APP_ID;
+
+    @Value("${STK.app_key}")
+    private String STK_APP_KEY;
+
+    /**
+     * 公司组织编码
+     * */
+    @Value("${STK.s_org_code}")
+    private String S_ORG_CODE;
+
+    @Autowired
+    private BaseDao baseDao;
+
+    /**
+     * 获取客商相关数据
+     * */
+    @Override
+    public List<CustvendDTO> selectTravellingMerchantList(QueryTravellingMerchantDto dto,String url){
+        if(null == dto.getPage() || null == dto.getSize()){
+            dto.setPage(1);
+            dto.setSize(10);
+        }
+
+        dto.setS_orgcode(S_ORG_CODE);
+
+        log.info("请求参数dto,content:"+JSONObject.toJSONString(dto));
+
+        //头部请求参数
+        Map<String,String> headerMap = null;
+        try {
+            headerMap = getHeaderMap(dto);
+        } catch (Exception e) {
+            log.error("STK加密异常:{}",e.getMessage());
+        }
+
+        //请求数据 (接口地址根据测试环境与正式环境变更)
+        HttpResultResponse resultResponse = HuToolUtils.post(url,dto,headerMap);
+        if(!resultResponse.getSuccess()){
+            log.error(resultResponse.getMessage());
+            return null;
+        }
+
+        System.out.println("STK,获取客商信息返回结果:"+resultResponse.getBody());
+
+        if(StringUtils.isBlank(resultResponse.getBody())){
+            return new ArrayList<>();
+        }
+
+        //System.out.println("返回结果:"+listArray.size());
+        return JSONObject.parseArray(resultResponse.getBody(),CustvendDTO.class);  //返回结果
+    }
+
+    @Override
+    public List<CustvendDTO> queryList() {
+        List<CustvendDTO> custvendDTO = new ArrayList<CustvendDTO>();
+        SqlRowList rs = baseDao.queryForRowSet("select * from STK_CUSTVEND_CS");
+        while (rs.next()) {
+            CustvendDTO custvend = baseDao.getJdbcTemplate().queryForObject("select *  from STK_CUSTVEND_CS where id = " + rs.getInt("id"), new BeanPropertyRowMapper<CustvendDTO>(CustvendDTO.class));
+            custvendDTO.add(custvend);
+        }
+        return custvendDTO;
+    }
+
+    /**
+     * POST请求头部参数封装
+     * */
+    public Map<String,String> getHeaderMap(QueryTravellingMerchantDto dto) throws Exception {
+
+        //获取签名
+        String sign = getSign(dto);
+        log.info("STK,加密后的签名:"+sign);
+
+        //时间戳
+        String timestamp = Long.toString(System.currentTimeMillis());
+
+        Map<String,String> headerMap = new HashMap<>();
+        headerMap.put("appid",STK_APP_ID);
+        headerMap.put("timestamp",timestamp);
+        headerMap.put("sign",sign);
+        headerMap.put("Content-Type","application/json");
+        return headerMap;
+    }
+
+    /**
+     * 获取深投控加密参数
+     * */
+    public String getSign(QueryTravellingMerchantDto dto) throws Exception {
+
+        //时间戳
+        String timestamp = Long.toString(System.currentTimeMillis());
+
+        String content = JSONObject.toJSONString(dto);
+
+        //加签方法第一个参数
+        StringBuilder signBuilder = new StringBuilder("appid").append("=").append(STK_APP_ID).append("&")
+                .append(content).append("&")
+                .append("timestamp").append("=").append(timestamp).append("&")
+                .append("key").append("=").append(STK_APP_KEY);
+        log.info("STK,加密前参数:"+signBuilder.toString());
+        //加签
+        return STKSignUtil.HMACSHA256(signBuilder.toString(),STK_APP_KEY);
+    }
+
+
+}

+ 45 - 4
src/main/java/com/uas/eis/service/Impl/STKServiceImpl.java

@@ -1,15 +1,13 @@
 package com.uas.eis.service.Impl;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.uas.eis.core.config.SpObserver;
 import com.uas.eis.dao.BaseDao;
 import com.uas.eis.dao.SqlRowList;
-import com.uas.eis.sdk.dto.AssistBalanceDTO;
-import com.uas.eis.sdk.dto.BalanceCountDTO;
-import com.uas.eis.sdk.dto.BalanceDTO;
-import com.uas.eis.sdk.dto.CashFlowDTO;
+import com.uas.eis.sdk.dto.*;
 import com.uas.eis.sdk.entity.ApiResult;
 import com.uas.eis.sdk.resp.ApiResponse;
 import com.uas.eis.service.STKService;
@@ -20,6 +18,7 @@ import com.uas.eis.utils.StringUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
@@ -153,6 +152,47 @@ public class STKServiceImpl implements STKService {
         return null;
     }
 
+
+
+
+    @Override
+    public void getCustvend(List<CustvendDTO> custvendDTOS) {
+        List<String> sqls = new ArrayList<>();
+        for (int i = 0; i < custvendDTOS.size(); i++) {
+            sqls.add("delete from STK_CUSTVEND2;");
+            sqls.add("insert into STK_CUSTVEND2(ID,S_ID,S_CODE,NAME,UID_TYPE,UID2,CUSTOMER_TYPE,IS_VALID,CREATED_ORG,CREATED_SYSTEM,ISTEMPORARY,MDM_CODE,REG_COUNTRY, " +
+                    "REG_PLACE,REG_REP,REG_CAPTIAL,REG_PERIOD,REG_BIZSCOPE,REG_FOUNDEDDATE,REG_URL,REG_ADDRESS,CREAT_TIME,UPDATE_TIME,SERIAL) " +
+                    "values ("+custvendDTOS.get(i).getId()+","+custvendDTOS.get(i).getS_id()+",'"+custvendDTOS.get(i).getS_code()+"','"+custvendDTOS.get(i).getName()+"'" +
+                    ",'"+custvendDTOS.get(i).getUid_type()+"','"+custvendDTOS.get(i).getUid()+"','"+custvendDTOS.get(i).getCustomer_type()+"','"+custvendDTOS.get(i).getIs_valid()+"'" +
+                    ",'"+custvendDTOS.get(i).getCreated_org()+"','"+custvendDTOS.get(i).getCreated_system()+"','"+custvendDTOS.get(i).getIstemporary()+"','"+custvendDTOS.get(i).getMdm_code()+"','"+custvendDTOS.get(i).getReg_country()+"'" +
+                    ",'"+custvendDTOS.get(i).getReg_place()+"','"+custvendDTOS.get(i).getReg_rep()+"','"+custvendDTOS.get(i).getReg_captial()+"','"+custvendDTOS.get(i).getReg_period()+"','"+custvendDTOS.get(i).getReg_bizscope()+"','"+custvendDTOS.get(i).getReg_foundeddate()+"'" +
+                    ",'"+custvendDTOS.get(i).getReg_url()+"','"+custvendDTOS.get(i).getReg_address()+"','"+custvendDTOS.get(i).getCreat_time()+"','"+custvendDTOS.get(i).getUpdate_time()+"','"+custvendDTOS.get(i).getSerial()+"')");
+        }
+        baseDao.execute(sqls);
+    }
+
+
+    private Map<String, JSONArray> getData(HttpServletRequest request){
+        Map<String, JSONArray> map = new HashMap<>();
+        try {
+            String data = PSHttpUtils.readRaw(request.getInputStream());
+            JSONObject jsonObject = JSON.parseObject(data);
+            Object data1 = jsonObject.get("Data");
+            JSONObject jsonObject1 = JSON.parseObject(StringUtil.nvl(data1,""));
+            Object page1 = jsonObject1.get("Page1");
+            Object page2 = jsonObject1.get("Page2");
+            JSONArray jsonArray = JSON.parseArray(StringUtil.nvl(page1, ""));
+            map.put("main",jsonArray);
+            JSONArray jsonArray1 = JSON.parseArray(StringUtil.nvl(page2, ""));
+            map.put("detail",jsonArray1);
+        } catch (IOException e) {
+            logger.info("参数解析异常信息:"+e.getMessage());
+            e.printStackTrace();
+        }
+        return map;
+    }
+
+
     /**
      * 获取header参数
      * */
@@ -188,4 +228,5 @@ public class STKServiceImpl implements STKService {
         }
         return jsonObject;
     }
+
 }

+ 24 - 0
src/main/java/com/uas/eis/service/RequestSTKService.java

@@ -0,0 +1,24 @@
+package com.uas.eis.service;
+
+import com.uas.eis.dto.stksto.QueryTravellingMerchantDto;
+import com.uas.eis.sdk.dto.CustvendDTO;
+
+import java.util.List;
+
+/**
+ * 请求深投控service
+ * */
+
+public interface RequestSTKService {
+
+    /**
+     * 获取客商相关信息
+     * */
+    List<CustvendDTO> selectTravellingMerchantList(QueryTravellingMerchantDto dto, String url);
+
+    /**
+     * 获取深投控测试获取,测试
+     * */
+    List<CustvendDTO> queryList();
+
+}

+ 7 - 0
src/main/java/com/uas/eis/service/STKService.java

@@ -4,9 +4,11 @@ package com.uas.eis.service;
 
 import com.alibaba.fastjson.JSONObject;
 import com.uas.eis.sdk.dto.AssistBalanceDTO;
+import com.uas.eis.sdk.dto.CustvendDTO;
 import com.uas.eis.sdk.entity.ApiResult;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -41,4 +43,9 @@ public interface STKService {
      * 接口测试
      * */
     ApiResult<String> getAssistBalanceCountTest(HttpServletRequest request, AssistBalanceDTO dto);
+
+    /**
+     * 获取客商信息
+     * */
+    void getCustvend(List<CustvendDTO> custvendDTOS);
 }

+ 59 - 0
src/main/java/com/uas/eis/task/STKTask.java

@@ -0,0 +1,59 @@
+package com.uas.eis.task;
+
+import com.alibaba.fastjson.JSONObject;
+import com.uas.eis.dto.stksto.QueryTravellingMerchantDto;
+import com.uas.eis.sdk.dto.CustvendDTO;
+import com.uas.eis.service.RequestSTKService;
+import com.uas.eis.service.STKService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Scheduled;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+
+@Slf4j
+public class STKTask {
+
+    /**
+     * 复杂查询接口请求地址
+     * */
+    @Value("${STK.complexity_query_url}")
+    private String COMPLEXITY_QUERY_URL;
+
+    /**
+     * 获取客商信息接口编码
+     * */
+    @Value("${STK.get_travelling_merchant}")
+    private String GET_TRAVELLING_MERCHANT;
+
+    /**
+     * 获取客商状态反馈信息
+     * */
+    @Value("${STK.get_travelling_merchant_status}")
+    private String GET_TRAVELLING_MERCHANT_STATUS;
+
+    @Autowired
+    RequestSTKService requestSTKService;
+
+    @Autowired
+    private STKService stkService;
+
+    @Scheduled(cron = "0 0/5 * * * ?")
+    public void getSellerOrders(){
+        log.info("开始获取深投控客商状态信息=========start=============");
+        Date date = new Date();
+
+        QueryTravellingMerchantDto dto = new QueryTravellingMerchantDto();
+        dto.setCode(GET_TRAVELLING_MERCHANT);
+
+        List<CustvendDTO> custvendDTOS =  requestSTKService.selectTravellingMerchantList(dto,GET_TRAVELLING_MERCHANT_STATUS);
+        stkService.getCustvend(custvendDTOS);
+        log.info("定时任务获取深投控客商信息数据结果:{}", JSONObject.toJSONString(custvendDTOS));
+
+        log.info("开始获取深投控客商状态信息,结束:"+((System.currentTimeMillis()-date.getTime())/1000));
+    }
+
+}

+ 200 - 0
src/main/java/com/uas/eis/utils/HuToolUtils.java

@@ -0,0 +1,200 @@
+package com.uas.eis.utils;
+
+import cn.hutool.http.HttpException;
+import cn.hutool.http.HttpRequest;
+import cn.hutool.http.HttpResponse;
+import com.alibaba.fastjson.JSON;
+import com.uas.eis.vo.stkVo.HttpResultResponse;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.Map;
+
+@Slf4j
+public class HuToolUtils {
+
+    /**
+     * 超时毫秒数。http的连接与读取
+     */
+    private static final int TIME_OUT_MILLISECONDS = 60000;
+
+    /**
+     * Content-Type
+     */
+    private static final String CONTENT_TYPE_JSON = "application/json; charset=utf-8";
+
+    private static final String CONTENT_TYPE_FORM = "multipart/form-data";
+
+    /**
+     * GET请求
+     */
+    public static HttpResultResponse get(String url) {
+        return get(url, null);
+    }
+
+    public static HttpResultResponse get(String url, Map<String, String> headerMap) {
+        HttpResultResponse httpResultResponse = new HttpResultResponse();
+        try {
+            HttpResponse response = HttpRequest
+                .get(url)
+                .timeout(TIME_OUT_MILLISECONDS)
+                .addHeaders(headerMap)
+                .execute();
+
+            if (!response.isOk()) {
+                log.error("HttpUtils get 响应失败. url={},headerMap={}, response={}", url, headerMap, response.toString());
+                return httpResultResponse.buildError();
+            }
+
+            return httpResultResponse.buildSuccess(response.body());
+        } catch (HttpException e) {
+            log.error("HttpUtils get HttpException异常. url={},headerMap={}", url, headerMap, e);
+            return httpResultResponse.buildError(e.getMessage());
+        } catch (Exception e) {
+            log.error("HttpUtils get Exception异常. url={},headerMap={}", url, headerMap, e);
+            return httpResultResponse.buildError(e.getMessage());
+        }
+    }
+
+    public static HttpResultResponse post(String url, Object postBody) {
+        return post(url, postBody, null);
+    }
+
+    /**
+     * post 请求
+     *
+     * @param url       请求链接
+     * @param postBody  请求对象 or 请求json字符串
+     * @param headerMap 请求头map
+     *
+     * @return HttpResultResponse
+     */
+    public static HttpResultResponse post(String url, Object postBody, Map<String, String> headerMap) {
+        HttpResultResponse httpResultResponse = new HttpResultResponse();
+		HttpResponse response = null;
+        try {
+            HttpRequest httpRequest = HttpRequest
+                .post(url)
+                .timeout(TIME_OUT_MILLISECONDS)
+                .addHeaders(headerMap);
+
+            if (postBody instanceof byte[]) {
+                httpRequest.body((byte[]) postBody);
+            } else if (postBody instanceof String) {
+                httpRequest.body((String) postBody);
+            } else {
+                httpRequest.body(JSON.toJSONString(postBody), CONTENT_TYPE_JSON);
+            }
+
+            response = httpRequest.execute();
+
+            if (!response.isOk()) {
+                log.error("HttpUtils post 响应失败. url={},postBody={}, headerMap={}, response={}", url, postBody,
+                    headerMap, response.toString());
+                return httpResultResponse.buildError(response.body());
+            }
+
+            return httpResultResponse.buildSuccess(response.body());
+        } catch (HttpException e) {
+            log.error("HttpUtils post HttpException异常. url={},postBody={}, headerMap={}", url, postBody, headerMap, e);
+            return httpResultResponse.buildError(e.getMessage());
+        } catch (Exception e) {
+            log.error("HttpUtils post Exception异常. url={},postBody={},headerMap={}", url, postBody, headerMap, e);
+            return httpResultResponse.buildError(e.getMessage());
+        } finally {
+			if (response != null) {
+				response.close(); // 确保关闭响应
+			}
+		}
+    }
+
+    public static HttpResultResponse postByForm(String url, Object postBody, Map<String, String> headerMap) {
+        HttpResultResponse httpResultResponse = new HttpResultResponse();
+
+        String body;
+        if (postBody instanceof String) {
+            body = (String) postBody;
+        } else {
+            body = JSON.toJSONString(postBody);
+        }
+
+        try {
+            HttpResponse response = HttpRequest
+                .post(url)
+                .body(body, CONTENT_TYPE_FORM)
+                .timeout(TIME_OUT_MILLISECONDS)
+                .addHeaders(headerMap)
+                .execute();
+
+            if (!response.isOk()) {
+                log.error("HttpUtils post 响应失败. url={},postBody={}, headerMap={}, response={}", url, postBody,
+                    headerMap, response.toString());
+                return httpResultResponse.buildError();
+            }
+
+            return httpResultResponse.buildSuccess(response.body());
+        } catch (HttpException e) {
+            log.error("HttpUtils post HttpException异常. url={},postBody={}, headerMap={}", url, postBody, headerMap, e);
+            return httpResultResponse.buildError(e.getMessage());
+        } catch (Exception e) {
+            log.error("HttpUtils post Exception异常. url={},postBody={},headerMap={}", url, postBody, headerMap, e);
+            return httpResultResponse.buildError(e.getMessage());
+        }
+    }
+
+    /**
+     * put 请求, 无header
+     *
+     * @param url     链接
+     * @param putBody 请求对象 or 请求json字符串
+     *
+     * @return HttpResultResponse
+     */
+    public static HttpResultResponse put(String url, Object putBody) {
+        return put(url, putBody, null);
+    }
+
+    /**
+     * put 请求
+     *
+     * @param url       请求链接
+     * @param putBody   请求对象 or 请求json字符串
+     * @param headerMap 请求头map
+     *
+     * @return HttpResultResponse
+     */
+    public static HttpResultResponse put(String url, Object putBody, Map<String, String> headerMap) {
+        HttpResultResponse httpResultResponse = new HttpResultResponse();
+
+        try {
+            HttpRequest httpRequest = HttpRequest
+                .put(url)
+                .timeout(TIME_OUT_MILLISECONDS)
+                .addHeaders(headerMap);
+
+            if (putBody instanceof byte[]) {
+                httpRequest.body((byte[]) putBody);
+            } else if (putBody instanceof String) {
+                httpRequest.body((String) putBody);
+            } else {
+                httpRequest.body(JSON.toJSONString(putBody), CONTENT_TYPE_JSON);
+            }
+
+            HttpResponse response = httpRequest.execute();
+
+            if (!response.isOk()) {
+                log.error("HttpUtil put 响应失败. url={},putBody={}, headerMap={}, response={}", url, putBody,
+                    headerMap, response.toString());
+                return httpResultResponse.buildError();
+            }
+
+            return httpResultResponse.buildSuccess(response.body());
+        } catch (HttpException e) {
+            log.error("HttpUtil put HttpException异常. url={},putBody={}, headerMap={}", url, putBody, headerMap, e);
+            return httpResultResponse.buildError(e.getMessage());
+        } catch (Exception e) {
+            log.error("HttpUtil put Exception异常. url={},putBody={},headerMap={}", url, putBody, headerMap, e);
+            return httpResultResponse.buildError(e.getMessage());
+        }
+    }
+
+}

+ 21 - 0
src/main/java/com/uas/eis/utils/STKSignUtil.java

@@ -0,0 +1,21 @@
+package com.uas.eis.utils;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+
+public class STKSignUtil {
+
+    //加签方法
+    public static String HMACSHA256(String data, String key) throws Exception {
+        Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
+        SecretKeySpec secret_key = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA256");
+        sha256_HMAC.init(secret_key);
+        byte[] array = sha256_HMAC.doFinal(data.getBytes("UTF-8"));
+        StringBuilder sb = new StringBuilder();
+        for (byte item : array) {
+            sb.append(Integer.toHexString(item & 0xFF | 0x100).substring(1, 3));
+        }
+        return sb.toString().toUpperCase();
+    }
+
+}

+ 45 - 0
src/main/java/com/uas/eis/vo/stkVo/HttpResultResponse.java

@@ -0,0 +1,45 @@
+package com.uas.eis.vo.stkVo;
+
+import lombok.Data;
+
+@Data
+public class HttpResultResponse {
+
+    /**
+     * 响应成功 or 失败
+     */
+    private Boolean success;
+
+    /**
+     * 信息提示
+     */
+    private String message;
+
+    /**
+     * http响应的body
+     */
+    private String body;
+
+    public HttpResultResponse buildSuccess(String body) {
+        return buildSuccess(body, "响应成功");
+    }
+
+    public HttpResultResponse buildSuccess(String body, String message) {
+        this.success = true;
+        this.message = message;
+        this.body = body;
+        return this;
+    }
+
+    public HttpResultResponse buildError() {
+        return buildError("响应失败");
+    }
+
+    public HttpResultResponse buildError(String message) {
+        this.success = false;
+        this.message = message;
+        this.body = null;
+        return this;
+    }
+
+}

+ 17 - 1
src/main/resources/application-dev.yml

@@ -27,4 +27,20 @@ server:
 
 action:
     api_action: /EIS/api,/EIS/mes,/EIS/erp
-    public_actions: /EIS/logout,/EIS/hello1
+    public_actions: /EIS/logout,/EIS/hello1
+
+STK:
+    s_org_code: 5418
+    app_id: bc81efc8_b2c6_4670_818e_e2710a45
+    app_key: 9a1ae28bc9104deb86f74575acc1c2d6
+    #获取客商信息接口编码
+    get_travelling_merchant: AZTrgG8P
+    #获取客商状态反馈信息接口编码
+    get_travelling_merchant_status: nMy1haj6
+    #自动化查询接口
+    query_url: https://10.67.2.187/api/oapigw/api/oapisvc/automicApi/
+    #自动化新增或变更类接口地址
+    save_or_update_url: http://10.67.2.187/api/oapigw/api/oapisvc/automicUpsertApi/
+    #复杂查询接口地址
+    complexity_query_url: https://10.67.2.187/api/oapigw/api/oapisvc/api/v2/search
+

+ 15 - 0
src/main/resources/application-prod.yml

@@ -28,3 +28,18 @@ server:
 action:
     api_action: /EIS/api,/EIS/mes,/EIS/erp
     public_actions: /EIS/logout,/EIS/hello1
+
+STK:
+    s_org_code: 5418
+    app_id: bf00be8b_0387_44f4_b073_50c3c2d6
+    app_key: eb1b6053bdda437c98a93d93013d9fae
+    #获取客商信息接口编码
+    get_travelling_merchant: vhtITAFq
+    #获取客商状态反馈信息接口编码
+    get_travelling_merchant_status: WT3uRr4V
+    #自动化查询接口
+    query_url: https://10.67.2.187/api/oapigw/api/oapisvc/automicApi/
+    #自动化新增或变更类接口地址
+    save_or_update_url: http://10.67.2.187/api/oapigw/api/oapisvc/automicUpsertApi/
+    #复杂查询接口地址
+    complexity_query_url: https://10.67.2.187/api/oapigw/api/oapisvc/api/v2/search