| | |
| | | |
| | | import cn.gistack.common.utils.SpringContextUtil; |
| | | import cn.gistack.sm.sjztmd.entity.*; |
| | | import cn.gistack.sm.sjztmd.vo.AttResWithRainfall; |
| | | import cn.gistack.sm.sjztmd.vo.StationExport; |
| | | import cn.gistack.sm.sjztmd.vo.ZtResultInfo; |
| | | import cn.gistack.sm.sjztmd.vo.StationParams; |
| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.parser.Feature; |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.tool.utils.ObjectUtil; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | @Service |
| | | @AllArgsConstructor |
| | | @DS("zt") |
| | | @Slf4j |
| | | public class SjztmdServiceImpl implements ISjztmdService { |
| | | |
| | | //总计 |
| | | private final String RIBAO_SHEET1_TOTAL_URL = "/services/1234567890ABCDEFGHIJKLMN/ribao_sheet1/api?small_start_stag=0&small_end_stag=2&mid_start_stag=0&mid_end_stag=2&big_start_stag=0&big_end_stag=2"; |
| | | private final String RIBAO_SHEET1_TOTAL_URL = "/services/1234567890ABCDEFGHIJKLMN/ribao_sheet1/api?small_start_stag=0&mid_start_stag=0&big_start_stag=0"; |
| | | private final String RIBAO_SHEET1_OVER_NORM_POOL_STAG = "/services/1234567890ABCDEFGHIJKLMN/ribao/sheet1_over_norm_pool_stag/api?"; |
| | | //中大型水库 |
| | | private final String RIBAO_SHEET2_ZDX_URL = "/services/1234567890ABCDEFGHIJKLMN/ribao/sheet2_zdx/api?mid_start_stag=0&mid_end_stag=2&big_start_stag=0&big_end_stag=2"; |
| | | private final String RIBAO_SHEET2_ZDX_URL = "/services/1234567890ABCDEFGHIJKLMN/ribao/sheet2_zdx/api?mid_start_stag=0&big_start_stag=0"; |
| | | //超汛明细 |
| | | private final String RIBAO_SHEET3_OVER_STAG_LIST_URL = "/services/1234567890ABCDEFGHIJKLMN/ribao/sheet3_over_stag_list/api?small_start_stag=0&small_end_stag=2&mid_start_stag=0&mid_end_stag=2&big_start_stag=0&big_end_stag=2"; |
| | | private final String RIBAO_SHEET3_OVER_STAG_LIST_URL = "/services/1234567890ABCDEFGHIJKLMN/ribao/sheet3_over_stag_list/api?small_start_stag=0&mid_start_stag=0&big_start_stag=0"; |
| | | //省直管 |
| | | private final String SZ_INFO = "/services/1234567890ABCDEFGHIJKLMN/ribao/shengzh_new_rz/api"; |
| | | |
| | |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | | private final SjztMdMapper mapper; |
| | | |
| | | private final IAttResBaseService attResBase; |
| | | private final ITbAttResBaseService attResBaseService; |
| | | private final ITbAttResStagCharService attResStagCharService; |
| | | private final ITbAttResWaterDeliveryService attResWaterDeliveryService; |
| | |
| | | private final ITbAttResWaterBlockService attResWaterBlockService; |
| | | private final ITbAttResRsbNorspiService attResRsbNorspiService; |
| | | private final ITbAttResPowerStationService attResPowerStationService; |
| | | |
| | | private final IStResRainfallService stResRainfallService; |
| | | private final ITbAttResProjectUtilizeService attResProjectUtilizeService; |
| | | private final ITbAttResInformationProjectService attResInformationProjectService; |
| | | |
| | |
| | | |
| | | |
| | | @Override |
| | | public List<TotalInfo> getTotalInfo() { |
| | | JSONObject ztData = this.getZtData(null, RIBAO_SHEET1_TOTAL_URL); |
| | | public List<TotalInfo> getTotalInfo(String isShow) { |
| | | JSONObject ztData = this.getZtData("&is_show="+isShow, RIBAO_SHEET1_TOTAL_URL); |
| | | JSONArray data = ztData.getJSONArray("data"); |
| | | List<TotalInfo> list = data.toJavaList(TotalInfo.class); |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public List<DzkInfo> getDzkInfo() { |
| | | JSONObject ztData = this.getZtData(null, RIBAO_SHEET2_ZDX_URL); |
| | | public List<TotalInfo> getTotalOverInfo(String isShow, HashMap<String, String> map) { |
| | | |
| | | String params = "&is_show=" + isShow; |
| | | if (map != null){ |
| | | for (Map.Entry<String, String> entry : map.entrySet()){ |
| | | String key=entry.getKey(); |
| | | String vlaue = entry.getValue(); |
| | | |
| | | String p = StringUtil.format("&{}={}",key,vlaue); |
| | | params +=p; |
| | | } |
| | | } |
| | | |
| | | JSONObject ztData = this.getZtData(params, RIBAO_SHEET1_OVER_NORM_POOL_STAG); |
| | | JSONArray data = ztData.getJSONArray("data"); |
| | | List<TotalInfo> list = data.toJavaList(TotalInfo.class); |
| | | return list; |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void getReservoirRainfallForecast(List<String> dayIndexList) { |
| | | List<StResRainfall> stResRainfalls = new ArrayList<>(); |
| | | for (String dayIndex : dayIndexList) { |
| | | List<AttResWithRainfall> attResByRainfall = attResBase.getAttResByRainfall(null, null, dayIndex); |
| | | for (AttResWithRainfall attResWithRainfall : attResByRainfall) { |
| | | StResRainfall stResRainfall = new StResRainfall(); |
| | | stResRainfall.setId(UUID.randomUUID().toString().replaceAll("-", "")); |
| | | stResRainfall.setResCd(attResWithRainfall.getCode()); |
| | | stResRainfall.setDrp(attResWithRainfall.getRainfall()); |
| | | stResRainfall.setFileName(attResWithRainfall.getFileName()); |
| | | stResRainfall.setDayIndex(dayIndex); |
| | | stResRainfall.setCreateTime(new Date()); |
| | | stResRainfalls.add(stResRainfall); |
| | | } |
| | | } |
| | | if (!stResRainfalls.isEmpty()) { |
| | | stResRainfallService.remove(Wrappers.<StResRainfall>query().lambda()); |
| | | stResRainfallService.saveBatch(stResRainfalls); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<DzkInfo> getDzkInfo(String isShow) { |
| | | JSONObject ztData = this.getZtData("&is_show="+isShow, RIBAO_SHEET2_ZDX_URL); |
| | | JSONArray data = ztData.getJSONArray("data"); |
| | | List<DzkInfo> list = data.toJavaList(DzkInfo.class); |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public List<OverDetail> getOverDetailInfo() { |
| | | JSONObject ztData = this.getZtData(null, RIBAO_SHEET3_OVER_STAG_LIST_URL); |
| | | public List<OverDetail> getOverDetailInfo(String isShow) { |
| | | JSONObject ztData = this.getZtData("&is_show="+isShow, RIBAO_SHEET3_OVER_STAG_LIST_URL); |
| | | JSONArray data = ztData.getJSONArray("data"); |
| | | List<OverDetail> list = data.toJavaList(OverDetail.class); |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public List<SzInfo> getSzInfo() { |
| | | JSONObject ztData = this.getZtData(null, SZ_INFO); |
| | | public List<SzInfo> getSzInfo(String isShow) { |
| | | JSONObject ztData = this.getZtData("?is_show="+isShow, SZ_INFO); |
| | | JSONArray data = ztData.getJSONArray("data"); |
| | | List<SzInfo> list = data.toJavaList(SzInfo.class); |
| | | return list; |
| | |
| | | // 获取环境 |
| | | String activeProfile = SpringContextUtil.getActiveProfile(); |
| | | if (activeProfile.equals("dev")) { |
| | | url = ZtApiUrlConstant.url_prefix_dev + url; |
| | | url = ZtApiUrlConstant.url_prefix_dev + url + params; |
| | | } |
| | | if (activeProfile.equals("prod")) { |
| | | url = ZtApiUrlConstant.url_prefix_prod + url; |
| | | url = ZtApiUrlConstant.url_prefix_prod + url + params; |
| | | } |
| | | if (activeProfile.equals("test")) { |
| | | url = ZtApiUrlConstant.url_prefix_test + url; |
| | | url = ZtApiUrlConstant.url_prefix_test + url + params; |
| | | } |
| | | |
| | | log.info("请求url地址:{}", url); |
| | | //设置请求头 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.add(ZtConfigConstant.header_key, ZtConfigConstant.header_value); |