| | |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.http.*; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | |
| | | private final static String API_LAYER = "%s/sj_raster/v6/api/layer?%s&sort=name%%20asc"; |
| | | |
| | | private final static String MISSION_STATUS = "%s/sj_raster/v6/api/mission/%d?op=get_status&%s"; |
| | | |
| | | private final static String COLOR_TABLE = "%s/sj_raster/v6/api/color_table?%s&page_count=%d&page_num=%d&key="; |
| | | |
| | | private final static String IMAGE_INFO = "%s/sj_raster/v6/api/image?%s&key=&page_num=1&page_count=1000&layer_id=%d"; |
| | | |
| | | /** |
| | | * 分页查询数简的颜色表 |
| | |
| | | public void selectSjLayers(Integer port, HttpServletRequest req, HttpServletResponse res) { |
| | | try { |
| | | String url = String.format(API_LAYER, null == port || 50001 == port ? sjUrl1 : sjUrl5, ak); |
| | | |
| | | HttpHelper httpHelper = new HttpHelper(); |
| | | httpHelper.service(req, res, null, url); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询数简任务状态 |
| | | */ |
| | | public void selectSjMissionStatus(Integer id, HttpServletRequest req, HttpServletResponse res) { |
| | | try { |
| | | String url = String.format(MISSION_STATUS, sjUrl5, id, ak); |
| | | |
| | | HttpHelper httpHelper = new HttpHelper(); |
| | | httpHelper.service(req, res, null, url); |
| | |
| | | CreateLayerEntity.Layer layer = entity.getLayer(); |
| | | layer.setName(pub.getName() + "_" + pub.getTime()); |
| | | layer.setProjection(getEpsg(pub)); |
| | | layer.setType(TYPES.indexOf(pub.getType())); |
| | | layer.setType(getPublishType(pub)); |
| | | layer.setEnhance_type(pub.getEnhanceType()); |
| | | layer.setEnhance_factor(pub.getEnhanceFactor()); |
| | | layer.setNodata(getNoData(pub, metas)); |
| | |
| | | } |
| | | |
| | | return entity; |
| | | } |
| | | |
| | | /** |
| | | * 获取发布类型 |
| | | */ |
| | | private int getPublishType(PubEntity pub) { |
| | | if (null != pub.getColorTable() || null != pub.getGradientColorTable()) { |
| | | return StaticData.I2; |
| | | } |
| | | |
| | | return TYPES.indexOf(pub.getType()); |
| | | } |
| | | |
| | | /** |
| | |
| | | Integer type = null != pub.getColorTable() ? 0 : 1; |
| | | List<?> levels = null != pub.getColorTable() ? pub.getColorTable() : pub.getGradientColorTable(); |
| | | |
| | | return entity.new Config(type, levels); |
| | | return entity.new Config(pub.getColorTableId(), type, levels); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * 插入数简服务 |
| | | * 更新数简服务 |
| | | */ |
| | | public Integer updateSjService(PubEntity pub) { |
| | | PublishEntity entity = publishService.selectById(pub.getPubid()); |
| | |
| | | */ |
| | | public List<TaskResultEntity.Result> getTaskStatus(List<Integer> list) { |
| | | String url = String.format("%s/sj_raster/v6/api/mission?op=bulk_get_mission_status&%s", sjUrl5, ak); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | Map<String, Object> map = new HashMap<>(1); |
| | | map.put("cmd_list", list); |
| | | |
| | | TaskResultEntity rs = postForRest(url, map, TaskResultEntity.class); |
| | |
| | | |
| | | return flag ? null : rs.getResult(); |
| | | } |
| | | |
| | | /** |
| | | * 更新数简图层的拉伸方式 |
| | | */ |
| | | public Integer updateSjLayerStretch(PubEntity entity) { |
| | | PublishEntity pub = publishService.selectByLayerId(entity.getLayerId()); |
| | | if (null == pub || null == pub.getLayerid()) { |
| | | return 0; |
| | | } |
| | | |
| | | ImageResultEntity ir = selectImageInfo(pub.getLayerid()); |
| | | if (null == ir || null == ir.getResult() || null == ir.getResult().getItem_list()) { |
| | | return 0; |
| | | } |
| | | |
| | | List<ImageResultEntity.Image> itemList = ir.getResult().getItem_list(); |
| | | for (ImageResultEntity.Image image : itemList) { |
| | | Integer imgId = updateImageLayerStretch(image.getData_id(), entity); |
| | | } |
| | | |
| | | pub.setUpdateUser(entity.getUserId()); |
| | | if (null == pub.getGeom()) { |
| | | pub.setGeom("null"); |
| | | } |
| | | |
| | | return publishService.update(pub); |
| | | } |
| | | |
| | | /** |
| | | * 根据图层ID查询影像信息 |
| | | */ |
| | | public ImageResultEntity selectImageInfo(Integer layerId) { |
| | | try { |
| | | String url = String.format(IMAGE_INFO, sjUrl5, ak, layerId); |
| | | |
| | | RestTemplate rest = RestHelper.getRestTemplate(); |
| | | ResponseEntity<ImageResultEntity> resp = rest.getForEntity(url, ImageResultEntity.class); |
| | | |
| | | return resp.getBody(); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更新影像图层的拉伸方式 |
| | | */ |
| | | private Integer updateImageLayerStretch(Integer imageLayerId, PubEntity entity) { |
| | | String url = String.format("%s/sj_raster/v6/api/image/%d?op=update&%s", sjUrl5, imageLayerId, ak); |
| | | |
| | | Map<String, Object> map = new HashMap<>(3); |
| | | map.put("tile_rgb", entity.getTile_rgb()); |
| | | map.put("enhance_type", entity.getEnhanceType()); |
| | | map.put("enhance_factor", entity.getEnhanceFactor()); |
| | | |
| | | ServiceResultEntity rs = postForRest(url, map, ServiceResultEntity.class); |
| | | boolean flag = null == rs || !StaticData.SUCCESS.equals(rs.getStatus()); |
| | | |
| | | return flag ? null : rs.getResult(); |
| | | } |
| | | } |