| | |
| | | package cn.gistack.sm.sjztods.service.impl; |
| | | |
| | | import cn.gistack.common.utils.SpringContextUtil; |
| | | import cn.gistack.sm.sjztmd.entity.AttAdBase; |
| | | import cn.gistack.sm.sjztmd.service.IAttAdBaseService; |
| | | import cn.gistack.sm.sjztmd.vo.AttAdBaseVO; |
| | | import cn.gistack.sm.sjztods.constant.ZtApiUrlConstant; |
| | | import cn.gistack.sm.sjztods.constant.ZtConfigConstant; |
| | | import cn.gistack.sm.sjztods.entity.SkxsQkTj; |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | |
| | | |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | | |
| | | @Autowired |
| | | private IAttAdBaseService attAdBaseService; |
| | | |
| | | /** |
| | | * 上报 |
| | |
| | | // 设置创建人员,时间信息 |
| | | xsfsQktj.setCreateUser(AuthUtil.getUserId()); |
| | | xsfsQktj.setCreateTime(new Date()); |
| | | |
| | | //根据行政区名获取行政区code |
| | | AttAdBaseVO attAdBaseVO = new AttAdBaseVO(); |
| | | attAdBaseVO.setAdName(xsfsQktj.getAdName()); |
| | | AttAdBaseVO detail = attAdBaseService.getDetail(attAdBaseVO); |
| | | |
| | | xsfsQktj.setAdCode(detail.getAdCode()); |
| | | xsfsQktj.setAdGrad(detail.getAdGrad()); |
| | | // 保存并返回 |
| | | save(xsfsQktj); |
| | | return; |
| | |
| | | // 遍历,写入数据 |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | String ad_nm = ""; |
| | | if (xsfsQktj.getType().equals("city_cd")){ |
| | | ad_nm = jsonArray.getJSONObject(i).getString("county_nm"); |
| | | }else if (xsfsQktj.getType().equals("county_cd")){ |
| | | ad_nm = jsonArray.getJSONObject(i).getString("town_nm"); |
| | | }else { |
| | | String adGrad = ""; |
| | | String adCode = ""; |
| | | |
| | | if (StringUtil.isBlank(xsfsQktj.getType())){ |
| | | ad_nm = jsonArray.getJSONObject(i).getString("city_nm"); |
| | | adCode = jsonArray.getJSONObject(i).getString("city_cd"); |
| | | adGrad =jsonArray.getJSONObject(i).getString("ad_grad"); |
| | | }else { |
| | | if (xsfsQktj.getType().equals("city_cd")) { |
| | | ad_nm = jsonArray.getJSONObject(i).getString("county_nm"); |
| | | adCode = jsonArray.getJSONObject(i).getString("county_cd"); |
| | | adGrad =jsonArray.getJSONObject(i).getString("ad_grad"); |
| | | |
| | | //不存 |
| | | if (StringUtil.isBlank(adCode)||StringUtil.isBlank(ad_nm)){ |
| | | continue; |
| | | } |
| | | |
| | | } else if (xsfsQktj.getType().equals("county_cd")) { |
| | | ad_nm = jsonArray.getJSONObject(i).getString("town_nm"); |
| | | adCode = jsonArray.getJSONObject(i).getString("town_cd"); |
| | | adGrad =jsonArray.getJSONObject(i).getString("ad_grad"); |
| | | } |
| | | } |
| | | |
| | | // 查询库里是否已存在数据 |
| | | XsfsQktj xsfsQktjBy = baseMapper.selectXsfsQktjBy(ad_nm,xsfsQktj.getQueryTime()); |
| | | XsfsQktj xsfsQktjBy = baseMapper.selectXsfsQktjBy(adCode,xsfsQktj.getQueryTime()); |
| | | if (null!=xsfsQktjBy){ |
| | | // 跳出本次循环 |
| | | continue; |
| | | } |
| | | XsfsQktj qkTj = new XsfsQktj(); |
| | | qkTj.setAdName(ad_nm); |
| | | qkTj.setAdCode(adCode); |
| | | qkTj.setAdGrad(adGrad); |
| | | // 设置各项值 |
| | | setXsfsQktjInfo(qkTj,jsonArray,i,xsfsQktj.getQueryTime()); |
| | | // 加入集合 |
| | |
| | | } |
| | | // 批量插入 |
| | | saveBatch(list); |
| | | } |
| | | |
| | | @Override |
| | | public R saveRegionData(XsfsQktjVO xsfsQktj) { |
| | | |
| | | AttAdBase params = new AttAdBase(); |
| | | |
| | | //先获取市级数据 |
| | | saveOrUpdateData(xsfsQktj); |
| | | |
| | | //获取市级集合 |
| | | List<AttAdBase> attAdBaseVOS = attAdBaseService.list(Condition.getQueryWrapper(params) |
| | | .eq("\"ad_grad\"","2")); |
| | | |
| | | //获取县级数据 |
| | | attAdBaseVOS.forEach(attAdBase ->{ |
| | | xsfsQktj.setType("city_cd"); |
| | | xsfsQktj.setTypeValue(attAdBase.getAdCode()); |
| | | |
| | | saveOrUpdateData(xsfsQktj); |
| | | } ); |
| | | |
| | | return R.success("获取成功"); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | skxs.setSysResource("zt"); |
| | | // 总 |
| | | skxs.setZxsTotal(jsonArray.getJSONObject(i).getDouble("tot_cap")); |
| | | skxs.setZxsSc(jsonArray.getJSONObject(i).getString("diff_last_day")); |
| | | skxs.setZxsLastYearTq(jsonArray.getJSONObject(i).getString("rate_last_year_cap")); |
| | | skxs.setZxsLastYearTqzj(jsonArray.getJSONObject(i).getString("diff_last_year")); |
| | | skxs.setZxsHisTq(jsonArray.getJSONObject(i).getString("diff_his_cap")); |
| | | skxs.setZxsHisTqzj(jsonArray.getJSONObject(i).getString("rate_avg_cap")); |
| | | skxs.setZxsSc(jsonArray.getJSONObject(i).getDouble("diff_last_day")); |
| | | skxs.setZxsLastYearTq(jsonArray.getJSONObject(i).getDouble("rate_last_year_cap")); |
| | | skxs.setZxsLastYearTqzj(jsonArray.getJSONObject(i).getDouble("diff_last_year")); |
| | | skxs.setZxsHisTq(jsonArray.getJSONObject(i).getDouble("diff_his_cap")); |
| | | skxs.setZxsHisTqzj(jsonArray.getJSONObject(i).getDouble("rate_avg_cap")); |
| | | // 大型 |
| | | skxs.setDxskXsTotal(jsonArray.getJSONObject(i).getDouble("big_tot_cap")); |
| | | skxs.setDxskXsHis(jsonArray.getJSONObject(i).getString("big_diff_his")); |
| | | skxs.setDxskXsLastYear(jsonArray.getJSONObject(i).getString("big_diff_last_year")); |
| | | skxs.setDxskXsHis(jsonArray.getJSONObject(i).getDouble("big_diff_his")); |
| | | skxs.setDxskXsLastYear(jsonArray.getJSONObject(i).getDouble("big_diff_last_year")); |
| | | // 中型 |
| | | skxs.setZxskXsTotal(jsonArray.getJSONObject(i).getDouble("mid_tot_cap")); |
| | | skxs.setZxskXsHis(jsonArray.getJSONObject(i).getString("mid_diff_his")); |
| | | skxs.setZxskXsLastYear(jsonArray.getJSONObject(i).getString("mid_diff_last_year")); |
| | | skxs.setZxskXsHis(jsonArray.getJSONObject(i).getDouble("mid_diff_his")); |
| | | skxs.setZxskXsLastYear(jsonArray.getJSONObject(i).getDouble("mid_diff_last_year")); |
| | | // 小型 |
| | | skxs.setXxskXsTotal(jsonArray.getJSONObject(i).getDouble("small_tot_cap")); |
| | | } |