| | |
| | | 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.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; |
| | | |
| | | /** |
| | | * 上海对农接口 |
| | |
| | | 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 PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCRsamMiP5Op2JJtp3+IIJADFYhL256ZW0KsOkMHruJ3hVwgvoimPHKuUWRI/CS365v4BwUzzfBRdbECMFsLA1e1FHPPA0uSsAIuSVwRzHXG4drX7ZCDa9GFZ+qyIFAU25j2e2PC9olvKbGLBfZ8cL1FLXGxSVyDCX4t/UMZdDULwIDAQAB"; |
| | | private static final String SIGN = "JD-DNSGSJ"; |
| | | private static final String DEPT_ID = "5303_003"; |
| | | |
| | |
| | | public @ResponseBody |
| | | ApiResp dnjgsj(HttpServletRequest request, @PathVariable("interfaceId") String interfaceId, @RequestBody String dataStr) { |
| | | |
| | | log.info("-----接收对农系统数据={}-----", 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()); |
| | | } |
| | | |
| | |
| | | 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()); |
| | | } |
| | | |
| | | //解密报文 |
| | | String data = RSAUtils.decrypt(shdn2023ReqDto.getData(), PRIVATE_KEY); |
| | | if(StringUtils.isEmpty(data)){ |
| | | return new ApiResp(ApiRespCode.R_500.getCode(),ApiRespCode.R_500.getMsg()); |
| | | } |
| | | log.info("-----对农系统,接口编码={},数据解密={}-----",interfaceId, data); |
| | | //异步保存 |
| | | shdnService.syncData(interfaceId, shdn2023ReqDto.getData()); |
| | | shdnService.syncData(interfaceId, data, shdn2023ReqDto.getDeptId()); |
| | | |
| | | return new ApiResp(); |
| | | } |