| | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.fzzy.api.entity.*; |
| | | import com.fzzy.api.service.ApiCommonService; |
| | | import com.fzzy.api.utils.RedisUtil; |
| | | import com.fzzy.api.view.repository.*; |
| | | import com.fzzy.inte.sh2023.constant.ApiRespCode; |
| | | import com.fzzy.inte.sh2023.dto.ApiResp; |
| | | import com.fzzy.inte.sh2023.dto.ResultDto; |
| | | import com.fzzy.push.sh2023.SH2023Constant; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private Api9115Rep api9115Rep; |
| | | @Autowired |
| | | private Api9116Rep api9116Rep; |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | |
| | | @Async |
| | | public void syncData(String interfaceId, String dataStr, String deptId){ |
| | | public void syncData(String interfaceId, String dataStr, String deptId, String outId){ |
| | | |
| | | ApiConfs apiConfs = apiConfsRep.getDataByDeptId(deptId); |
| | | if(null == apiConfs){ |
| | | log.error("-----æªè·åå°åºåºä¿¡æ¯é
ç½®ï¼ä¸è§£æ---------"); |
| | | resultRedis(outId, ApiRespCode.R_500.getCode(), "æªè·åå°åºåºä¿¡æ¯é
ç½®ï¼ä¸è§£æ"); |
| | | return; |
| | | } |
| | | try { |
| | | //åä½ä¿¡æ¯ |
| | | if(SH2023Constant.SH_2023_API_CODE_3101.equals(interfaceId)){ |
| | | List<Api9109> list = JSONObject.parseArray(dataStr, Api9109.class); |
| | | if(null == list || list.isEmpty()){ |
| | | log.error("-----æªè·åå°ä¿¡æ¯ï¼ä¸è§£æ---------"); |
| | | resultRedis(outId, ApiRespCode.R_500.getCode(), "æªè·åå°ä¿¡æ¯ï¼ä¸è§£æ"); |
| | | return; |
| | | } |
| | | for (Api9109 apiData : list) { |
| | |
| | | api9109Rep.save(apiData); |
| | | } |
| | | log.info("-----åä½ä¿¡æ¯è§£æå®æ={}-----", list); |
| | | //è§£æç»ææ¾å
¥ç¼å |
| | | resultRedis(outId, ApiRespCode.R_200.getCode(), "åä½ä¿¡æ¯è§£æå®æ"); |
| | | } |
| | | |
| | | //æ¶çº³åºä¿¡æ¯ |
| | |
| | | List<Api9110> list = JSONObject.parseArray(dataStr, Api9110.class); |
| | | if(null == list || list.isEmpty()){ |
| | | log.error("-----æªè·åå°åºåºä¿¡æ¯ï¼ä¸è§£æ---------"); |
| | | resultRedis(outId, ApiRespCode.R_500.getCode(), "æªè·åå°åºåºä¿¡æ¯ï¼ä¸è§£æ"); |
| | | return; |
| | | } |
| | | for (Api9110 apiData : list) { |
| | | apiData.setZhgxsj(new Date()); |
| | | api9110Rep.save(apiData); |
| | | } |
| | | log.info("-----åºåºä¿¡æ¯è§£æå®æ={}-----", list); |
| | | //è§£æç»ææ¾å
¥ç¼å |
| | | resultRedis(outId, ApiRespCode.R_200.getCode(), "åºåºä¿¡æ¯è§£æå®æ"); |
| | | } |
| | | |
| | | //仿¿ä¿¡æ¯ |
| | | if(SH2023Constant.SH_2023_API_CODE_3103.equals(interfaceId)){ |
| | | List<Api9111> list = JSONObject.parseArray(dataStr, Api9111.class); |
| | | if(null == list || list.isEmpty()){ |
| | | log.error("-----æªè·åå°ä»æ¿ä¿¡æ¯ï¼ä¸è§£æ---------"); |
| | | resultRedis(outId, ApiRespCode.R_500.getCode(), "æªè·åå°ä»æ¿ä¿¡æ¯ï¼ä¸è§£æ"); |
| | | return; |
| | | } |
| | | for (Api9111 apiData : list) { |
| | |
| | | api9111Rep.save(apiData); |
| | | } |
| | | log.info("-----仿¿ä¿¡æ¯è§£æå®æ={}-----", list); |
| | | //è§£æç»ææ¾å
¥ç¼å |
| | | resultRedis(outId, ApiRespCode.R_200.getCode(), "仿¿ä¿¡æ¯è§£æå®æ"); |
| | | } |
| | | |
| | | //å»é´ä¿¡æ¯ |
| | | if(SH2023Constant.SH_2023_API_CODE_3104.equals(interfaceId)){ |
| | | List<Api9112> list = JSONObject.parseArray(dataStr, Api9112.class); |
| | | if(null == list || list.isEmpty()){ |
| | | log.error("-----æªè·åå°ä»æ¿ä¿¡æ¯ï¼ä¸è§£æ---------"); |
| | | resultRedis(outId, ApiRespCode.R_500.getCode(), "æªè·åå°ä»æ¿ä¿¡æ¯ï¼ä¸è§£æ"); |
| | | return; |
| | | } |
| | | for (Api9112 apiData : list) { |
| | |
| | | api9112Rep.save(apiData); |
| | | } |
| | | log.info("-----å»é´ä¿¡æ¯è§£æå®æ={}-----", list); |
| | | //è§£æç»ææ¾å
¥ç¼å |
| | | resultRedis(outId, ApiRespCode.R_200.getCode(), "å»é´ä¿¡æ¯è§£æå®æ"); |
| | | } |
| | | |
| | | //è´§ä½ä¿¡æ¯ |
| | | if(SH2023Constant.SH_2023_API_CODE_3105.equals(interfaceId)){ |
| | | List<Api9113> list = JSONObject.parseArray(dataStr, Api9113.class); |
| | | if(null == list || list.isEmpty()){ |
| | | log.error("-----æªè·åå°è´§ä½ä¿¡æ¯ï¼ä¸è§£æ---------"); |
| | | resultRedis(outId, ApiRespCode.R_500.getCode(), "æªè·åå°ä»æ¿ä¿¡æ¯ï¼ä¸è§£æ"); |
| | | return; |
| | | } |
| | | for (Api9113 apiData : list) { |
| | |
| | | api9113Rep.save(apiData); |
| | | } |
| | | log.info("-----è´§ä½ä¿¡æ¯è§£æå®æ={}-----", list); |
| | | //è§£æç»ææ¾å
¥ç¼å |
| | | resultRedis(outId, ApiRespCode.R_200.getCode(), "è´§ä½ä¿¡æ¯è§£æå®æ"); |
| | | } |
| | | |
| | | //ç²®é£å
¥åºä¿¡æ¯ |
| | | if(SH2023Constant.SH_2023_API_CODE_3201.equals(interfaceId)){ |
| | | List<Api9114> list = JSONObject.parseArray(dataStr, Api9114.class); |
| | | if(null == list || list.isEmpty()){ |
| | | log.error("-----æªè·åå°ç²®é£å
¥åºä¿¡æ¯ï¼ä¸è§£æ---------"); |
| | | resultRedis(outId, ApiRespCode.R_500.getCode(), "æªè·åå°ä»æ¿ä¿¡æ¯ï¼ä¸è§£æ"); |
| | | return; |
| | | } |
| | | for (Api9114 apiData : list) { |
| | |
| | | api9114Rep.save(apiData); |
| | | } |
| | | log.info("-----ç²®é£å
¥åºä¿¡æ¯è§£æå®æ={}-----", list); |
| | | //è§£æç»ææ¾å
¥ç¼å |
| | | resultRedis(outId, ApiRespCode.R_200.getCode(), "ç²®é£å
¥åºä¿¡æ¯è§£æå®æ"); |
| | | } |
| | | |
| | | //æ¥ç²®æ£éªä¿¡æ¯ |
| | | if(SH2023Constant.SH_2023_API_CODE_3202.equals(interfaceId)){ |
| | | List<Api9115> list = JSONObject.parseArray(dataStr, Api9115.class); |
| | | if(null == list || list.isEmpty()){ |
| | | log.error("-----æªè·åå°æ¥ç²®æ£éªä¿¡æ¯ï¼ä¸è§£æ---------"); |
| | | resultRedis(outId, ApiRespCode.R_500.getCode(), "æªè·åå°ä»æ¿ä¿¡æ¯ï¼ä¸è§£æ"); |
| | | return; |
| | | } |
| | | for (Api9115 apiData : list) { |
| | |
| | | api9115Rep.save(apiData); |
| | | } |
| | | log.info("-----æ¥ç²®æ£éªä¿¡æ¯è§£æå®æ={}-----", list); |
| | | //è§£æç»ææ¾å
¥ç¼å |
| | | resultRedis(outId, ApiRespCode.R_200.getCode(), "æ¥ç²®æ£éªä¿¡æ¯è§£æå®æ"); |
| | | } |
| | | |
| | | //ç²®é£æ¶è´åºç¡ä¿¡æ¯ |
| | | if(SH2023Constant.SH_2023_API_CODE_3203.equals(interfaceId)){ |
| | | List<Api9116> list = JSONObject.parseArray(dataStr, Api9116.class); |
| | | if(null == list || list.isEmpty()){ |
| | | log.error("-----æªè·åå°ç²®é£æ¶è´åºç¡ä¿¡æ¯ï¼ä¸è§£æ---------"); |
| | | resultRedis(outId, ApiRespCode.R_500.getCode(), "æªè·åå°ä»æ¿ä¿¡æ¯ï¼ä¸è§£æ"); |
| | | return; |
| | | } |
| | | for (Api9116 apiData : list) { |
| | |
| | | api9116Rep.save(apiData); |
| | | } |
| | | log.info("-----ç²®é£æ¶è´åºç¡ä¿¡æ¯è§£æå®æ={}-----", list); |
| | | //è§£æç»ææ¾å
¥ç¼å |
| | | resultRedis(outId, ApiRespCode.R_200.getCode(), "ç²®é£æ¶è´åºç¡ä¿¡æ¯è§£æå®æ"); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("-----æ¥å£{}è§£ææ¥éï¼é误åå ={}-----", interfaceId, e.toString()); |
| | | resultRedis(outId, ApiRespCode.R_500.getCode(), "-----æ¥å£"+interfaceId+"è§£ææ¥éï¼é误åå ="+e.toString()+"-----"); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * ä»ç¼åä¸è·åè§£æç»æ |
| | | * @param dataStr |
| | | * @return |
| | | */ |
| | | public ApiResp getResult(String dataStr){ |
| | | List<ResultDto> list = JSONObject.parseArray(dataStr, ResultDto.class); |
| | | if(null == list || list.isEmpty()){ |
| | | log.error("-----outId为空---------"); |
| | | return new ApiResp(ApiRespCode.R_500.getCode(), "outIdä¸ºç©ºï¼æ æ³è·åè§£æç»æï¼"); |
| | | } |
| | | ApiResp result = (ApiResp)redisUtil.get(list.get(0).getOutId()); |
| | | if(null == result){ |
| | | log.error("-----æªè·åå°outId对åºçè§£æç»æ---------"); |
| | | return new ApiResp(ApiRespCode.R_500.getCode(), "æªè·åå°outId对åºçè§£æç»æï¼"); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * ç»æåå
¥ç¼å |
| | | * @param outId |
| | | * @param code |
| | | * @param msg |
| | | */ |
| | | public void resultRedis(String outId, String code, String msg){ |
| | | ApiResp result = new ApiResp(code, msg); |
| | | //ç»æåå
¥ç¼å2å°æ¶ |
| | | redisUtil.set(outId, result, 60*60*2); |
| | | } |
| | | } |