From 9f6dacf7b39e5aeba37d8faf575c9e56d8cbe51a Mon Sep 17 00:00:00 2001 From: czt <czt18638530771@163.com> Date: 星期六, 11 十月 2025 13:35:42 +0800 Subject: [PATCH] 武汉黄陂军粮-质检报告共享接口同步及推送 --- src/main/java/com/fzzy/inte/sh2023/controller/ControllerSh2023.java | 49 ++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 38 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/fzzy/inte/sh2023/controller/ControllerSh2023.java b/src/main/java/com/fzzy/inte/sh2023/controller/ControllerSh2023.java index 01fdb0b..882e588 100644 --- a/src/main/java/com/fzzy/inte/sh2023/controller/ControllerSh2023.java +++ b/src/main/java/com/fzzy/inte/sh2023/controller/ControllerSh2023.java @@ -1,8 +1,10 @@ package com.fzzy.inte.sh2023.controller; import com.alibaba.fastjson.JSONObject; -import com.fzzy.api.entity.Api9109; +import com.fzzy.api.entity.Api9116; +import com.fzzy.api.utils.ContextUtil; import com.fzzy.api.utils.RSAUtils; +import com.fzzy.api.utils.RedisUtil; import com.fzzy.inte.sh2023.constant.ApiRespCode; import com.fzzy.inte.sh2023.dto.ApiResp; import com.fzzy.inte.sh2023.dto.SHDN2023ReqDto; @@ -10,14 +12,15 @@ import com.fzzy.push.sh2023.SH2023Constant; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.time.DateFormatUtils; 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.Date; import java.util.List; /** @@ -29,8 +32,10 @@ public class ControllerSh2023 { @Autowired private SHDNService shdnService; - + @Autowired + private RedisUtil redisUtil; 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"; @@ -38,22 +43,44 @@ public @ResponseBody ApiResp dnjgsj(HttpServletRequest request, @PathVariable("interfaceId") String interfaceId, @RequestBody String dataStr) { - //瑙e瘑鎶ユ枃 - dataStr = RSAUtils.decrypt(dataStr, PRIVATE_KEY); - - if(StringUtils.isBlank(interfaceId) || StringUtils.isBlank(dataStr)){ + log.info("-----鎺ユ敹瀵瑰啘绯荤粺鏁版嵁={}-----", dataStr); + if(StringUtils.isEmpty(interfaceId)){ 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()); + //瑙e瘑鎶ユ枃 + 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("-----瀵瑰啘绯荤粺锛屾帴鍙g紪鐮�={}锛屾暟鎹В瀵�={}-----",interfaceId, data); - return new ApiResp(); + //鍒ゆ柇鏄惁涓虹粨鏋滃洖璋冩帴鍙� + if(SH2023Constant.SH_2023_API_CODE_3301.equals(interfaceId)){ + return shdnService.getResult(data); + } + + //鐢熸垚outID + String outId = "OUT_ID_" + interfaceId + "_" + DateFormatUtils.format(new Date(), "yyyyMMddHHmmss"); + //寮傛瑙f瀽 + shdnService.syncData(interfaceId, data, shdn2023ReqDto.getDeptId(), outId); + + //杩斿洖outId,鐢ㄤ簬瀵瑰啘绯荤粺鍥炶皟 + return new ApiResp(outId); + } + + public static void main(String[] args) { + String outid = RSAUtils.encrypt("[{\n" + + "\t\"outId\":\"OUT_ID_3101_20250324161241\"\n" + + "\t}]",PUBLIC_KEY); + System.out.println("=====" + outid); } } -- Gitblit v1.9.3