¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.otherview.whhpjl.pr; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.bstek.dorado.annotation.DataProvider; |
| | | import com.bstek.dorado.annotation.DataResolver; |
| | | import com.bstek.dorado.annotation.Expose; |
| | | import com.fzzy.api.Constant; |
| | | import com.fzzy.api.data.ApiParam; |
| | | import com.fzzy.api.dto.ResponseDto; |
| | | import com.fzzy.api.entity.ApiConfs; |
| | | import com.fzzy.api.entity.ApiInfoData; |
| | | import com.fzzy.api.service.ApiCommonService; |
| | | import com.fzzy.api.service.ApiPushManager; |
| | | import com.fzzy.api.service.ApiRemoteService; |
| | | import com.fzzy.api.view.repository.ApiInfoDataRep; |
| | | import com.fzzy.otherview.whhpjl.WhjlConstant; |
| | | import com.fzzy.otherview.whhpjl.dto.WhjlApi1106; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author: YYC |
| | | * @Description:æ²¹ç½ä¿¡æ¯ |
| | | * @DateTime: 2023-10-25 14:13 |
| | | **/ |
| | | @Component |
| | | public class WhjlApi1106PR { |
| | | |
| | | @Autowired |
| | | private ApiCommonService apiCommonService; |
| | | @Autowired |
| | | private ApiPushManager apiPushManager; |
| | | @Autowired |
| | | private ApiInfoDataRep apiInfoDataRep; |
| | | |
| | | /** |
| | | * è·ååè¡¨ä¿¡æ¯ |
| | | * WhjlApi1106PR#listData |
| | | * |
| | | * @return |
| | | */ |
| | | @DataProvider |
| | | public List<WhjlApi1106> listData() { |
| | | List<ApiInfoData> result = apiInfoDataRep.getDataByInteId(WhjlConstant.API_CODE_1106); |
| | | if (null == result || result.isEmpty()) { |
| | | return null; |
| | | } |
| | | List<WhjlApi1106> list = new ArrayList<>(); |
| | | WhjlApi1106 whjlApi1106; |
| | | for (ApiInfoData infoData : result) { |
| | | whjlApi1106 = JSONObject.parseObject(infoData.getData(), WhjlApi1106.class); |
| | | whjlApi1106.setKqdm(infoData.getKqdm()); |
| | | whjlApi1106.setCzbz(infoData.getCzbz()); |
| | | whjlApi1106.setUpdateTime(infoData.getUpdateTime()); |
| | | whjlApi1106.setBizId(infoData.getDataId()); |
| | | list.add(whjlApi1106); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * æ´æ°æä¿®æ¹ |
| | | * WhjlApi1106PR#saveData |
| | | * |
| | | * @param data |
| | | * @return |
| | | */ |
| | | @DataResolver |
| | | public void saveData(WhjlApi1106 data) { |
| | | ApiInfoData infoData = new ApiInfoData(); |
| | | infoData.setId(data.getBizId()); |
| | | infoData.setKqdm(data.getKqdm()); |
| | | infoData.setInteType(WhjlConstant.API_CATEGORY_11); |
| | | infoData.setInteId(WhjlConstant.API_CODE_1106); |
| | | infoData.setUpdateTime(new Date()); |
| | | infoData.setDataId(data.getBizId()); |
| | | infoData.setData(JSON.toJSONString(data)); |
| | | infoData.setCzbz(data.getCzbz()); |
| | | infoData.setRemarks("夿³¨ä¿¡æ¯"); |
| | | |
| | | apiInfoDataRep.save(infoData); |
| | | } |
| | | |
| | | /** |
| | | * å é¤ |
| | | * WhjlApi1106PR#delData |
| | | * |
| | | * @param data |
| | | * @return |
| | | */ |
| | | @Expose |
| | | public String delData(WhjlApi1106 data) { |
| | | apiInfoDataRep.deleteById(data.getBizId()); |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * ä¸ä¼ |
| | | * WhjlApi1106PR#pushData |
| | | * |
| | | * @param items |
| | | * @return |
| | | */ |
| | | @Expose |
| | | public String pushData(List<WhjlApi1106> items) { |
| | | |
| | | String result = ""; |
| | | |
| | | String kqdm = items.get(0).getKqdm(); |
| | | ApiConfs apiConf = apiCommonService.getConf(kqdm); |
| | | |
| | | if (null == apiConf) { |
| | | return "ç³»ç»æ²¡æè·åå°å½ååºåºé
置信æ¯ï¼æ§è¡å¤±è´¥"; |
| | | } |
| | | |
| | | //å°è£
åæ° |
| | | ApiParam param = new ApiParam(apiConf, WhjlConstant.API_CATEGORY_11, WhjlConstant.API_CODE_1106); |
| | | |
| | | //è·åå®ç°æ¥å£ |
| | | ApiRemoteService apiService = apiPushManager.getApiRemoteService(param.getPushProtocol()); |
| | | if (null == apiService) { |
| | | return "ç³»ç»æ²¡æå½åæ¨éåè®®é
ç½®ï¼æ§è¡å¤±è´¥"; |
| | | } |
| | | |
| | | ResponseDto responseDto; |
| | | ApiInfoData infoData; |
| | | for (WhjlApi1106 data : items) { |
| | | responseDto = apiService.pushData(param, apiConf, data); |
| | | if (responseDto.getSuccess() == 0) { |
| | | if (Constant.CZBZ_I.equals(data.getCzbz())) { |
| | | infoData = new ApiInfoData(); |
| | | infoData.setId(data.getBizId()); |
| | | infoData.setKqdm(data.getKqdm()); |
| | | infoData.setInteType(WhjlConstant.API_CATEGORY_11); |
| | | infoData.setInteId(WhjlConstant.API_CODE_1106); |
| | | infoData.setUpdateTime(new Date()); |
| | | infoData.setDataId(data.getBizId()); |
| | | |
| | | data.setCzbz(Constant.CZBZ_U); |
| | | infoData.setCzbz(Constant.CZBZ_U); |
| | | infoData.setData(JSON.toJSONString(data)); |
| | | apiInfoDataRep.save(infoData); |
| | | } |
| | | } |
| | | result += responseDto.toString(); |
| | | } |
| | | return result; |
| | | } |
| | | } |