package com.landtool.lanbase.modules.api.controller.MapPortal; import java.io.File; import java.sql.Timestamp; import java.util.Date; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.landtool.lanbase.common.utils.JpinyinUtils; import com.landtool.lanbase.config.SysTemPropertyConfig; import com.landtool.lanbase.modules.org.entity.OrgUnit; import com.landtool.lanbase.modules.org.service.OrgUserService; import com.landtool.lanbase.modules.res.entity.Res_ExtBusinessLayer; import com.landtool.lanbase.modules.res.entity.Res_ExtMapUrl; import com.landtool.lanbase.modules.res.entity.Res_ExtThemeMap; import com.landtool.lanbase.modules.res.entity.Res_MainInfo; import com.landtool.lanbase.modules.res.service.ResActionRecordService; import com.landtool.lanbase.modules.res.service.ResApplyRecommendService; import com.landtool.lanbase.modules.res.service.ResAuditService; import com.landtool.lanbase.modules.res.service.ResBusinessRefService; import com.landtool.lanbase.modules.res.service.ResEvaluationService; import com.landtool.lanbase.modules.res.service.ResExtBusinessLayerService; import com.landtool.lanbase.modules.res.service.ResExtMapUrlService; import com.landtool.lanbase.modules.res.service.ResExtThemeMapService; import com.landtool.lanbase.modules.res.service.ResMainInfoService; import com.landtool.lanbase.modules.res.service.ResQueryAroundService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; /** * @author 刘小波 * @Description: 专题制图相关接口 * @date 2018-05-26 */ @Controller @RequestMapping("/api/thememaping/") @Api(value = "", tags = { "专题制图相关接口" }) public class ThemeMappingController { @Autowired private ResExtThemeMapService resExtThemeMapService; @Autowired private ResMainInfoService resMainInfoService; @Autowired private OrgUserService orgUserService; @Autowired private ResExtBusinessLayerService resExtBusinessLayerService; @Autowired private ResExtMapUrlService resExtMapUrlService; @Autowired private ResActionRecordService resActionRecordService; @Autowired private ResApplyRecommendService resApplyRecommendService; @Autowired private ResAuditService resAuditService; @Autowired private ResBusinessRefService resBusinessRefService; @Autowired private ResQueryAroundService resQueryAroundService; @Autowired private ResEvaluationService resEvaluationService; @Autowired private SysTemPropertyConfig sysConfig; /** * 新增系统资源扩展(专题地图) */ @PostMapping(path = "/addMap") @ApiOperation(value = "新增系统资源扩展(专题地图)", notes = "") @ResponseBody public int addMap( // @ApiParam(name="catlogid",value="资源目录Id",required=true) // @RequestParam(name="catlogid")int catlogid, @ApiParam(name = "resourceid", value = "资源Id") Integer resourceid, @ApiParam(name = "title", value = "资源名称", required = true) @RequestParam(name = "title") String title, @ApiParam(name = "resourceclass", value = "资源类型代码") String resourceclass, @ApiParam(name = "catlogcode", value = "所属目录编码") String catlogcode, @ApiParam(name = "publishsoft", value = "发布平台") String publishsoft, @ApiParam(name = "layername", value = "原图层名称") String layername, @ApiParam(name = "portalguid", value = "Portal资源GUID") String portalguid, @ApiParam(name = "legeendurl", value = "自定义图例") String legeendurl, @ApiParam(name = "sublayerset", value = "子图层设置") String sublayerset, @ApiParam(name = "defaultlayerset", value = "默认底图设置") Integer defaultlayerset, @ApiParam(name = "initxmin", value = "初始化地图范围最小的X坐标值") Double initxmin, @ApiParam(name = "initxmax", value = "初始化地图范围最大的X坐标值") Double initxmax, @ApiParam(name = "initymin", value = "初始化地图范围最小的Y坐标值") Double initymin, @ApiParam(name = "initymax", value = "初始化地图范围最大的Y坐标值") Double initymax, @ApiParam(name = "fullxmin", value = "地图覆盖范围最小的X坐标值") Double fullxmin, @ApiParam(name = "fullxmax", value = "地图覆盖范围最大的X坐标值") Double fullxmax, @ApiParam(name = "fullymin", value = "地图覆盖范围最小的Y坐标值") Double fullymin, @ApiParam(name = "fullymax", value = "地图覆盖范围最大的Y坐标值") Double fullymax, @ApiParam(name = "type", value = "专题类型") String type, @ApiParam(name = "mapjson", value = "地图JSON", required = true) String mapjson, @ApiParam(name = "userid", value = "创建用户ID", required = true) Long userid) { if (resourceid == null) resourceid = -1; Res_MainInfo main = resMainInfoService.selectByPrimaryKey(resourceid); if (main != null) { main.setTitle(title); main.setAbbreviation(title); main.setResourceclass("KJ_ZTDT");// 暂时先赋值0 main.setCatlogcode("0");// 暂时先赋值0 main.setPingyinfiirst(JpinyinUtils.changeToGetShortPinYin(title).toUpperCase()); Timestamp time = new Timestamp(new Date().getTime()); main.setLasteditdate(time); resMainInfoService.updateByPrimaryKeySelective(main); Res_ExtThemeMap info = resExtThemeMapService.selectByPrimaryKey(resourceid); if (info != null) { info.setPublishsoft(publishsoft); info.setLayername(layername); info.setSublayerset(sublayerset); info.setDefaultlayerset(defaultlayerset); info.setInitxmin(initxmin == null ? 0 : initxmin); info.setInitxmax(initxmax == null ? 0 : initxmax); info.setInitymin(initymin == null ? 0 : initymin); info.setInitymax(initymax == null ? 0 : initymax); info.setType(type == null ? "系统制作" : type); info.setMapjson(mapjson); resExtThemeMapService.updateByPrimaryKeySelective(info); } } else { main = new Res_MainInfo(); main.setTitle(title); main.setAbbreviation(title); main.setCatlogid(0);// 默认设置0 main.setResourceclass("KJ_ZTDT");// 暂时先赋值0 main.setCatlogcode("0");// 暂时先赋值0 main.setPingyinfiirst(JpinyinUtils.changeToGetShortPinYin(title).toUpperCase()); Timestamp time = new Timestamp(new Date().getTime()); main.setPubdate(time); // 查询发布人对应的单位ID OrgUnit orgUnit = orgUserService.getDefaultUnit(userid); if(orgUnit != null) { main.setPubunitid(orgUnit.getUnitid().intValue()); } else { main.setPubunitid(0); } main.setCreateuserid(userid); main.setCreatedate(time); main.setLasteditdate(time); main.setSharprotocol("完全公开"); main.setEspproxy(0); main.setResourcestatus(0); main.setAuditstatus(0); main.setDisplayby2d(0); main.setDisplayby3d(0); resMainInfoService.insertSelective(main); resourceid = resMainInfoService.queryResMainInfoIdentCurrent(); Res_ExtThemeMap info = new Res_ExtThemeMap(); info.setResourceid(resourceid); info.setPublishsoft(publishsoft); info.setLayername(layername); info.setPortalguid(portalguid); info.setSublayerset(sublayerset); info.setDefaultlayerset(defaultlayerset); info.setInitxmin(initxmin == null ? 0 : initxmin); info.setInitxmax(initxmax == null ? 0 : initxmax); info.setInitymin(initymin == null ? 0 : initymin); info.setInitymax(initymax == null ? 0 : initymax); info.setType(type == null ? "系统制作" : type); info.setMapjson(mapjson); resExtThemeMapService.insert(info); } return resourceid; } /** * 编辑系统资源扩展(专题地图)地图JSON */ @PostMapping(path = "/updateMap") @ApiOperation(value = "编辑系统资源扩展(专题地图)地图JSON", notes = "") @ResponseBody public int updateExtThemeMap( @ApiParam(name = "resourceid", value = "信息资源Id", required = true) @RequestParam(name = "resourceid") int resourceid, @ApiParam(name = "title", value = "资源名称") @RequestParam(name = "title") String title, @ApiParam(name = "mapjson", value = "地图JSON") @RequestParam(name = "mapjson") String mapjson) { Res_MainInfo resMainInfo = new Res_MainInfo(); resMainInfo.setResourceid(resourceid); resMainInfo.setTitle(title); resMainInfoService.updateByPrimaryKeySelective(resMainInfo); Res_ExtThemeMap info = new Res_ExtThemeMap(); info.setResourceid(resourceid); info.setMapjson(mapjson); resExtThemeMapService.updateByPrimaryKeySelective(info); return resourceid; } @ResponseBody @GetMapping("/info/{resourceid}") @ApiOperation(value = "获取系统资源扩展(专题地图)", notes = "") public Res_ExtThemeMap queryExtThemeMap( @ApiParam(name = "resourceid", value = "信息资源Id") @PathVariable("resourceid") int resourceid) { return resExtThemeMapService.selectByPrimaryKey(resourceid); } @ResponseBody @PostMapping("/del") @ApiOperation(value = "删除我的制图相关信息", notes = "") public String delExtThemeMap( @ApiParam(name = "resourceid", value = "信息资源Id") @RequestParam(name ="resourceid") int resourceid) { Res_ExtThemeMap resExtThemeMap = resExtThemeMapService.selectByPrimaryKey(resourceid); if (resExtThemeMap != null) { if(resExtThemeMap.getLegendurl() != null) { String path = sysConfig.getUploadPath() + "ResExtThemMapServer/" + resExtThemeMap.getLegendurl(); File file = new File(path); if(file.exists()) { file.delete(); } } resExtThemeMapService.deleteByPrimaryKey(resourceid); } //资源协议与地址 List resExtMapUrlList = resExtMapUrlService.selectByCondition(resourceid); if(resExtMapUrlList != null && resExtMapUrlList.size() > 0){ resExtMapUrlService.deleteByResourceId(resourceid); } //资源操作记录 int resActionRecordCount = resActionRecordService.selectCountByResourceid(resourceid); if(resActionRecordCount > 0){ resActionRecordService.deleteByResourceid(resourceid); } //资源申请/推荐 int resApplyRecommendCount = resApplyRecommendService.selectCountByResourceid(resourceid); if(resApplyRecommendCount > 0){ resApplyRecommendService.deleteByResourceid(resourceid); } //资源发布注销变更审核 int resAuditCount = resAuditService.selectCountByResourceid(resourceid); if(resAuditCount > 0){ resAuditService.deleteByResourceid(resourceid); } //业务关联分析 int resBusinessrefCount = resBusinessRefService.selectCountByResourceid(resourceid); if(resBusinessrefCount > 0){ resBusinessRefService.deleteByResourceid(resourceid); } //业务关联周边查询 int resQueryAroundCount = resQueryAroundService.selectCountByResourceid(resourceid); if(resQueryAroundCount > 0 ){ resQueryAroundService.deleteByResourceid(resourceid); } //资源评价 int resEvaluationCount = resEvaluationService.selectCountByResourceid(resourceid); if(resEvaluationCount > 0){ resEvaluationService.deleteByResourceid(resourceid); } resMainInfoService.deleteByPrimaryKey(resourceid); return "删除成功"; } /** * 新增系统资源扩展(业务图层) */ @PostMapping(path = "/addBusinessLayer") @ApiOperation(value = "新增系统资源扩展(业务图层)", notes = "") @ResponseBody public int addBusinessLayer( // @ApiParam(name="catlogid",value="资源目录Id",required=true) // @RequestParam(name="catlogid")int catlogid, @ApiParam(name = "resourceid", value = "资源Id") Integer resourceid, @ApiParam(name = "title", value = "资源名称", required = true) @RequestParam(name = "title") String title, @ApiParam(name = "resourceclass", value = "资源类型代码") String resourceclass, @ApiParam(name = "catlogcode", value = "所属目录编码") String catlogcode, @ApiParam(name = "publishsoft", value = "发布平台", required = true) @RequestParam(name = "publishsoft") String publishsoft, @ApiParam(name = "layername", value = "原图层名称") String layername, @ApiParam(name = "dataloadtype", value = "加载方式(按需(MODE_ONDEMAND)、快照(MODE_SNAPSHOT))") String dataloadtype, @ApiParam(name = "advancequeryurl", value = "自定义高级查询地址") String advancequeryurl, @ApiParam(name = "diyqueryurl", value = "自定义查询列表") String diyqueryurl, @ApiParam(name = "diybubbleurl", value = "自定义气泡路径") String diybubbleurl, @ApiParam(name = "typeandurl", value = "地理参考信息", required = true) @RequestParam(name = "typeandurl") String typeandurl, @ApiParam(name = "serverurl", value = "服务地址", required = true) @RequestParam(name = "serverurl") String serverurl, @ApiParam(name = "userid", value = "创建用户ID", required = true) @RequestParam(name = "userid") Long userid) { if (resourceid == null) resourceid = -1; Res_MainInfo main = resMainInfoService.selectByPrimaryKey(resourceid); if (main != null) { main.setTitle(title); main.setAbbreviation(title); main.setResourceclass("KJ_YWTC");// 暂时先赋值0 main.setCatlogcode("0");// 暂时先赋值0 main.setPingyinfiirst(JpinyinUtils.changeToGetShortPinYin(title).toUpperCase()); Timestamp time = new Timestamp(new Date().getTime()); main.setLasteditdate(time); resMainInfoService.updateByPrimaryKeySelective(main); Res_ExtBusinessLayer info = resExtBusinessLayerService.selectByPrimaryKey(resourceid); if (info != null) { info.setPublishsoft(publishsoft); info.setLayername(layername); info.setAdvancequeryurl(advancequeryurl); info.setDataloadtype(dataloadtype); info.setDiybubbleurl(diybubbleurl); info.setDiyqueryurl(diyqueryurl); resExtBusinessLayerService.updateByPrimaryKeySelective(info); } Res_ExtMapUrl res_extMapUrl = new Res_ExtMapUrl(); res_extMapUrl.setResourceid(resourceid); res_extMapUrl.setServerurl(serverurl); res_extMapUrl.setTypeandurl(typeandurl); resExtMapUrlService.insertSelective(res_extMapUrl); } else { main = new Res_MainInfo(); main.setTitle(title); main.setAbbreviation(title); main.setCatlogid(0);// 默认设置0 main.setResourceclass("KJ_YWTC");// 暂时先赋值0 main.setCatlogcode("0");// 暂时先赋值0 main.setPingyinfiirst(JpinyinUtils.changeToGetShortPinYin(title).toUpperCase()); Timestamp time = new Timestamp(new Date().getTime()); main.setPubdate(time); // 查询发布人对应的单位ID OrgUnit orgUnit = orgUserService.getDefaultUnit(userid); if(orgUnit != null) { main.setPubunitid(orgUnit.getUnitid().intValue()); } else { main.setPubunitid(0); } main.setCreateuserid(userid); main.setCreatedate(time); main.setLasteditdate(time); main.setSharprotocol("完全公开"); main.setEspproxy(0); main.setResourcestatus(0); main.setAuditstatus(0); main.setDisplayby2d(0); main.setDisplayby3d(0); resMainInfoService.insertSelective(main); resourceid = resMainInfoService.queryResMainInfoIdentCurrent(); Res_ExtBusinessLayer info = new Res_ExtBusinessLayer(); info.setResourceid(resourceid); info.setPublishsoft(publishsoft); info.setLayername(layername); info.setAdvancequeryurl(advancequeryurl); info.setDataloadtype(dataloadtype); info.setDiyqueryurl(diyqueryurl); info.setDiybubbleurl(diybubbleurl); resExtBusinessLayerService.insert(info); Res_ExtMapUrl res_extMapUrl = new Res_ExtMapUrl(); res_extMapUrl.setResourceid(resourceid); res_extMapUrl.setServerurl(serverurl); res_extMapUrl.setTypeandurl(typeandurl); resExtMapUrlService.insertSelective(res_extMapUrl); } return resourceid; } }