| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.moon.server.entity.all.StaticData; |
| | | import com.moon.server.entity.ctrl.PubEntity; |
| | | import com.moon.server.entity.data.MetaPubEntity; |
| | | import com.moon.server.entity.data.PublishEntity; |
| | | import com.moon.server.entity.shujian.*; |
| | | import com.moon.server.helper.HttpHelper; |
| | |
| | | */ |
| | | @Service |
| | | public class ShuJianService { |
| | | private final static Log log = LogFactory.getLog(ShuJianService.class); |
| | | |
| | | @Value("${shujian.ak}") |
| | | private String ak; |
| | | |
| | |
| | | |
| | | @Resource |
| | | PublishService publishService; |
| | | |
| | | private final static Log log = LogFactory.getLog(ShuJianService.class); |
| | | |
| | | /** |
| | | * 分页查询数简的颜色表 |
| | |
| | | /** |
| | | * 插入数简服务 |
| | | */ |
| | | public Integer insertSjService(PubEntity pubEntity, HttpServletRequest req, HttpServletResponse res) { |
| | | CreateLayerEntity layerEntity = createLayerEntity(pubEntity); |
| | | public Integer insertSjService(PubEntity pub) { |
| | | CreateLayerEntity layerEntity = createLayerEntity(pub); |
| | | Integer layerId = postLayerEntity(layerEntity); |
| | | if (null == layerId) { |
| | | return 0; |
| | | } |
| | | |
| | | CreateServiceEntity serviceEntity = createServiceEntity(pubEntity); |
| | | CreateServiceEntity serviceEntity = createServiceEntity(pub); |
| | | Integer serviceId = postServiceEntity(serviceEntity); |
| | | if (null == serviceId) { |
| | | return 0; |
| | | } |
| | | |
| | | PublishEntity publishEntity = createPublishEntity(pubEntity, layerId, serviceId); |
| | | PublishEntity publishEntity = createPublishEntity(pub, layerId, serviceId); |
| | | Integer id = publishService.insert(publishEntity); |
| | | if (null == id) { |
| | | return id; |
| | | } |
| | | |
| | | return publishService.insert(publishEntity); |
| | | return insertMetaPub(pub, id); |
| | | } |
| | | |
| | | /** |
| | |
| | | * 创建发布实体类 |
| | | */ |
| | | public PublishEntity createPublishEntity(PubEntity pub, Integer layerId, Integer serviceId) { |
| | | String epsg = (StaticData.I104903 == pub.getEpsgCode() ? "ESRI:" : "EPSG:") + pub.getEpsgCode(); |
| | | |
| | | PublishEntity entity = new PublishEntity(); |
| | | entity.setType(pub.getType()); |
| | | entity.setName(pub.getName()); |
| | | entity.setMin(pub.getMin()); |
| | | entity.setMax(pub.getMax()); |
| | | entity.setBak(epsg); |
| | | entity.setBak(getEpsg(pub)); |
| | | entity.setCreateUser(pub.getUserId()); |
| | | entity.setDirid(pub.getDircode()); |
| | | entity.setDepid(pub.getDepcode()); |
| | | entity.setStatus(3); |
| | | entity.setLayerid(layerId); |
| | | entity.setServiceid(serviceId); |
| | | entity.setJson(getColorTableJson(pub)); |
| | | |
| | | return entity; |
| | | } |
| | | |
| | | /** |
| | | * 获取EPSG编码 |
| | | */ |
| | | public String getEpsg(PubEntity pub) { |
| | | if (StaticData.I104903 == pub.getEpsgCode()) { |
| | | return "ESRI:" + pub.getEpsgCode(); |
| | | } |
| | | |
| | | return "EPSG:" + pub.getEpsgCode(); |
| | | } |
| | | |
| | | /** |
| | | * 获取颜色表的JSON字符串 |
| | | */ |
| | | public String getColorTableJson(PubEntity pub) { |
| | | if (null == pub.getColorTable() && null == pub.getGradientColorTable()) { |
| | | return null; |
| | | } |
| | | |
| | | if (null != pub.getGradientColorTable()) { |
| | | return JSON.toJSONString(pub.getGradientColorTable()); |
| | | } |
| | | |
| | | return JSON.toJSONString(pub.getColorTable()); |
| | | } |
| | | |
| | | /** |
| | | * 插入元数据发布类 |
| | | */ |
| | | private int insertMetaPub(PubEntity pub, Integer pubid) { |
| | | int count = 0; |
| | | for (Integer metaid : pub.getIds()) { |
| | | MetaPubEntity mp = new MetaPubEntity(); |
| | | mp.setMetaid(metaid); |
| | | mp.setPubid(pubid); |
| | | mp.setCreateUser(pub.getUserId()); |
| | | |
| | | count += publishService.insertMetaPub(mp); |
| | | } |
| | | |
| | | return count; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public Integer deletesSjServices(List<Integer> ids) { |
| | | String strs = StringHelper.join(ids, ","); |
| | | |
| | | List<PublishEntity> list = publishService.selectByIds(strs); |
| | | if (null == list || list.isEmpty()) { |
| | | return 0; |