| | |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.helper.WebHelper; |
| | | import com.lf.server.service.data.LayerService; |
| | | import com.lf.server.service.data.PublishService; |
| | | import com.lf.server.service.sys.TokenService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @RestController |
| | | @RequestMapping("/publish") |
| | | public class PublishController extends BaseController { |
| | | @Autowired |
| | | @Resource |
| | | PublishService publishService; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | TokenService tokenService; |
| | | |
| | | @Resource |
| | | LayerService layerService; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "分页查询元数据") |
| | |
| | | return fail("数据类别为空", null); |
| | | } |
| | | |
| | | String types = getType(type); |
| | | String types = getType(dircode, type); |
| | | int count = publishService.selectMetasByCount(depcode, dircode, verid, types, name); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | |
| | | /** |
| | | * 获取类型 |
| | | */ |
| | | private String getType(String type) throws Exception { |
| | | private String getType(String dircode, String type) throws Exception { |
| | | switch (type) { |
| | | case "DOM": |
| | | return "type in ('tif', 'tiff', 'img')"; |
| | | return "type in ('tif', 'tiff', 'img')" + getFilter(dircode, type); |
| | | case "DEM": |
| | | return "type in ('tif', 'tiff')"; |
| | | return "type in ('tif', 'tiff')" + getFilter(dircode, type); |
| | | case "MPT": |
| | | return "type = 'mpt'"; |
| | | case "3DML": |
| | |
| | | return "type = 'cpt'"; |
| | | case "BIM": |
| | | return "type in ('ifc', 'fbx', 'rvt')"; |
| | | case "LAS": |
| | | return "type in ('las', 'laz')"; |
| | | case "OSGB": |
| | | return "type = 'osgb'"; |
| | | default: |
| | | throw new Exception("数据类型不匹配"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取过滤条件 |
| | | */ |
| | | private String getFilter(String dircode, String type) { |
| | | dircode = StringHelper.isEmpty(dircode) ? "" : StringHelper.getRightLike(dircode); |
| | | |
| | | List<String> list = null; |
| | | switch (type) { |
| | | case "DOM": |
| | | list = publishService.selectCodesForDir(dircode, 0); |
| | | break; |
| | | case "DEM": |
| | | list = publishService.selectCodesForDir(dircode, 1); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | if (null == list || list.isEmpty()) { |
| | | return ""; |
| | | } |
| | | |
| | | for (int i = 0, c = list.size(); i < c; i++) { |
| | | list.set(i, "'" + list.get(i) + "'"); |
| | | } |
| | | |
| | | return " and dircode not in (" + StringHelper.join(list, ",") + ")"; |
| | | } |
| | | |
| | | @SysLog() |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询Las文件坐标系ID") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "ids", value = "元数据ID集合", dataType = "Integer[]", paramType = "query", example = "10285, 10481, 10456, 10483") |
| | | }) |
| | | @GetMapping(value = "/selectLasCs") |
| | | public ResponseMsg<Object> selectLasCs(@RequestParam(value = "ids[]") Integer[] ids, HttpServletRequest req) { |
| | | try { |
| | | if (null == ids || ids.length == 0) { |
| | | return fail("元数据ID集合不能为空"); |
| | | } |
| | | |
| | | PubEntity entity = new PubEntity(); |
| | | entity.setIds(Arrays.asList(ids)); |
| | | entity.setDircode("00"); |
| | | entity.setToken(WebHelper.getToken(req)); |
| | | |
| | | List<Integer> list = publishService.selectLasCs(entity, "/Convert/ReadLasCs", req); |
| | | |
| | | return success(list); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "插入发布数据") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "entity", value = "实体类", dataType = "PubEntity", paramType = "body") |
| | |
| | | |
| | | String method = getConvertMethod(entity.getType()); |
| | | long count = publishService.postForPub(entity, method, req); |
| | | if (count > 0) { |
| | | layerService.clearCache(); |
| | | } |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | return "/Convert/ToSG"; |
| | | case "BIM": |
| | | return "/Convert/ToTileset"; |
| | | case "LAS": |
| | | return "/Convert/ToLas"; |
| | | case "OSGB": |
| | | return "/Convert/ToOsgb"; |
| | | default: |
| | | throw new Exception("数据类型不匹配"); |
| | | } |
| | |
| | | return fail("id数组不能为空", -1); |
| | | } |
| | | |
| | | String strs = StringHelper.join(ids, ","); |
| | | List<PublishEntity> list = publishService.selectByIds(strs); |
| | | if (null == list || list.isEmpty()) { |
| | | return fail("没有找到要删除的数据", -1); |
| | | } |
| | | |
| | | publishService.deleteFiles(list); |
| | | int count = publishService.deletes(ids, req); |
| | | if (count > 0) { |
| | | layerService.clearCache(); |
| | | } |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | } |
| | | |
| | | int count = publishService.update(entity); |
| | | if (count > 0) { |
| | | layerService.clearCache(); |
| | | } |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |