czt
2024-11-25 0547e2ae5469bfb96a3e6f9501427e2c29b20be0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package com.fzzy.inte.sh2023.controller;
 
import com.alibaba.fastjson.JSONObject;
import com.fzzy.api.entity.Api9109;
import com.fzzy.api.utils.RSAUtils;
import com.fzzy.inte.sh2023.constant.ApiRespCode;
import com.fzzy.inte.sh2023.dto.ApiResp;
import com.fzzy.inte.sh2023.dto.SHDN2023ReqDto;
import com.fzzy.inte.sh2023.service.SHDNService;
import com.fzzy.push.sh2023.SH2023Constant;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import javax.servlet.http.HttpServletRequest;
import java.util.List;
 
/**
 * 上海对农接口
 */
@Slf4j
@Controller
@RequestMapping("/dnjgsj/v1")
public class ControllerSh2023 {
    @Autowired
    private SHDNService shdnService;
 
    private static final String PRIVATE_KEY = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAJGxqYyI/k6nYkm2nf4ggkAMViEvbnplbQqw6Qweu4neFXCC+iKY8cq5RZEj8JLfrm/gHBTPN8FF1sQIwWwsDV7UUc88DS5KwAi5JXBHMdcbh2tftkINr0YVn6rIgUBTbmPZ7Y8L2iW8psYsF9nxwvUUtcbFJXIMJfi39Qxl0NQvAgMBAAECgYBKWLHfoCy9sFbMrN7UxnwQ+PqetpiW5tkNApf58ljbErQ4FO5V51xDieXBGejy2igmuOM7jz6xZtUgdiNV8uji/RtiNRqsBekVBPMeYAnPwA4GQ0HNwyHJ3ebJNQqT9bwrk8QpRUuCnrx/U1l7P1QNR5o52H1HpEKPlS0ga0fuQQJBAMdiSFYKt8/PwsYclvU/GqXrPy4cxMBhtE/ZssH9KourxnJcyfRz7EPgfSZykxlGHn8j/r8C2XxtAIYW6mRckqECQQC7EIZCZ3eV8abSIB33oKmw2jZlPQrHXMt8DWz8FYbNIA/9bvk9e9O42iQwMUtHfOMcNMWbcvKR/J+83bcE08TPAkA1ErdYl+/H1HDvVUrlq0+HnPArcSL6ZsedfcB0nNRHa4kehg6IEJdylf4aTuNTFfQmOcmkxLhpw4YhK1ZnMrEhAkEAuiMLNXA3MmCumk+TAiBAOdYoYjyHSTEw2VOSqpPQ+rN4tbmDEIbyefG2KK4kNhIy+pIYP0H11QYG/KuxvX/rSQJBALs0TqUgcGOp9+IkOq4jCXiVkP5/r7JWinQ4d6bYhJ4wspQYloYFCHljKKXtst1m8I3PC+vJY8R6va/3xtQKT8U=";
    private static final String SIGN = "JD-DNSGSJ";
    private static final String DEPT_ID = "5303_003";
 
    @RequestMapping("/{interfaceId}")
    public @ResponseBody
    ApiResp dnjgsj(HttpServletRequest request, @PathVariable("interfaceId") String interfaceId, @RequestBody String dataStr) {
 
        if(StringUtils.isEmpty(interfaceId)){
            return new ApiResp(ApiRespCode.R_500.getCode(),ApiRespCode.R_500.getMsg());
        }
 
        //解密报文
        dataStr = RSAUtils.decrypt(dataStr, PRIVATE_KEY);
        if(StringUtils.isEmpty(dataStr)){
            return new ApiResp(ApiRespCode.R_500.getCode(),ApiRespCode.R_500.getMsg());
        }
 
        SHDN2023ReqDto shdn2023ReqDto = JSONObject.parseObject(dataStr, SHDN2023ReqDto.class);
        if(null == shdn2023ReqDto){
            return new ApiResp(ApiRespCode.R_500.getCode(),ApiRespCode.R_500.getMsg());
        }
 
        if(!shdn2023ReqDto.getSign().equals(SIGN) || !shdn2023ReqDto.getDeptId().equals(DEPT_ID)) {
            return new ApiResp(ApiRespCode.R_500.getCode(),ApiRespCode.R_500.getMsg());
        }
 
        //异步保存
        shdnService.syncData(interfaceId, shdn2023ReqDto.getData());
 
        return new ApiResp();
    }
}