package com.landtool.lanbase.modules.api.controller; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.net.URLDecoder; import java.util.HashMap; import java.util.List; import java.util.Map; import com.alibaba.fastjson.JSON; import com.landtool.lanbase.common.utils.HttpUtils; import com.landtool.lanbase.modules.res.service.impl.ResApplyRecommendServiceImpl; import com.landtool.lanbase.modules.sys.controller.AbstractController; 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.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.alibaba.fastjson.JSONObject; import com.landtool.lanbase.common.utils.HttpOperateUtils; import com.landtool.lanbase.common.utils.Result; import com.landtool.lanbase.config.SysTemPropertyConfig; import com.landtool.lanbase.modules.org.service.OrgUserService; import com.landtool.lanbase.modules.res.entity.Res_Ext3D; import com.landtool.lanbase.modules.res.entity.Res_ExtBaseMap; import com.landtool.lanbase.modules.res.entity.Res_ExtBusinessLayer; import com.landtool.lanbase.modules.res.entity.Res_ExtDataBase; import com.landtool.lanbase.modules.res.entity.Res_ExtDataSource; import com.landtool.lanbase.modules.res.entity.Res_ExtFileSource; import com.landtool.lanbase.modules.res.entity.Res_ExtIntegrate; import com.landtool.lanbase.modules.res.entity.Res_ExtInterFaceService; import com.landtool.lanbase.modules.res.entity.Res_ExtSpaceServerWithBLOBs; 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.ResBusinessRefService; import com.landtool.lanbase.modules.res.service.ResCatalogService; import com.landtool.lanbase.modules.res.service.ResDiyLayerInfoService; import com.landtool.lanbase.modules.res.service.ResExt3DService; import com.landtool.lanbase.modules.res.service.ResExtAppService; import com.landtool.lanbase.modules.res.service.ResExtBaseMapService; import com.landtool.lanbase.modules.res.service.ResExtBusinessLayerService; import com.landtool.lanbase.modules.res.service.ResExtDataBaseService; import com.landtool.lanbase.modules.res.service.ResExtDataSourceService; import com.landtool.lanbase.modules.res.service.ResExtFileSourceService; import com.landtool.lanbase.modules.res.service.ResExtIntegrateService; import com.landtool.lanbase.modules.res.service.ResExtInterFaceService; import com.landtool.lanbase.modules.res.service.ResExtMapUrlService; import com.landtool.lanbase.modules.res.service.ResExtSpaceServerService; 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 cn.hutool.core.date.DateTime; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import javax.security.auth.Subject; @Controller @RequestMapping("/api/") @Api(value = "", tags = { "资源相关接口" }) public class ResApiController extends AbstractController { @Autowired private ResCatalogService resCatalogService; @Autowired private ResMainInfoService resMainInfoService; @Autowired private ResActionRecordService resActionRecordService; @Autowired private ResExtBaseMapService resExtBaseMapService; @Autowired private ResExtBusinessLayerService resExtBusinessLayerService; @Autowired private ResExtSpaceServerService resExtSpaceServerService; @Autowired private ResExtThemeMapService resExtThemeMapService; @Autowired private ResExtAppService resExtAppService; @Autowired private ResExtIntegrateService resExtIntegrateService; @Autowired private ResExtFileSourceService resExtFileSourceService; @Autowired private ResExtDataBaseService resExtDataBaseService; @Autowired private ResExtInterFaceService resExtInterFaceService; @Autowired private ResExt3DService resExt3DService; @Autowired private ResDiyLayerInfoService resDiyLayerInfoService; @Autowired private ResExtMapUrlService resExtMapUrlService; @Autowired private ResBusinessRefService resBusinessRefService; @Autowired private ResQueryAroundService resQueryAroundService; @Autowired private OrgUserService orgUserService; @Autowired private SysTemPropertyConfig sysConfig; @Autowired private ResExtDataSourceService resExtDataSourceService; @Autowired private ResApplyRecommendServiceImpl resApplyRecommendService; // /** // * @param parentCatalogId // * @Description: 获取目录树信息 {@link ResCatalogService} // * @Author: xiaoxuan.xie // * @Date: 17:30 2018/3/15 // * @return: String // * @see Res_Catalog // */ // @ResponseBody // @GetMapping(path = "catalog/getTreeByParentID/{parentCatalogId}") // @ApiOperation(value = "获取目录树信息", notes = "") // public String getTreeByParentID( // @ApiParam(name = "parentCatalogId", value = "目录父节点Id", required = true) @PathVariable(name = "parentCatalogId") int parentCatalogId) { // String resCatalogTreeJson = getTreeChildrenNodeList(parentCatalogId);// 递归获取目录子节点列表 // return "[" + resCatalogTreeJson + "]"; // } // // /** // * @param parentCatalogId // * @Description: 递归获取目录子节点列表 {@link ResCatalogService} // * @Author: xiaoxuan.xie // * @Date: 17:30 2018/3/15 // * @return: String // */ // private String getTreeChildrenNodeList(int parentCatalogId) { // String resCatalogTreeJson = "";// 定义目录树Json字符串存储对象 // List res_catalogList = resCatalogService.selectResCatalogToParentid(parentCatalogId);// 根据目录父Id获取子目录列表 // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 实例化时间格式转换器 // // 循环构造目录树结构Json // for (Res_Catalog resCatalog : res_catalogList) { // if (resCatalogTreeJson != "") // resCatalogTreeJson += ","; // resCatalogTreeJson += "{'catlogid':" + resCatalog.getCatlogid(); // resCatalogTreeJson += ",'catlogcode':'" + resCatalog.getCatlogcode() + "'"; // resCatalogTreeJson += ",'parentid':" + resCatalog.getParentid(); // resCatalogTreeJson += ",'title':'" + resCatalog.getTitle() + "'"; // resCatalogTreeJson += ",'pingyinfiirst':'" + resCatalog.getPingyinfiirst() + "'"; // resCatalogTreeJson += ",'description':'" + resCatalog.getDescription() + "'"; // resCatalogTreeJson += ",'imgurl':'" + resCatalog.getImgurl() + "'"; // resCatalogTreeJson += ",'orderid':" + resCatalog.getOrderid(); // resCatalogTreeJson += ",'createuser':'" + resCatalog.getCreateuser() + "'"; // resCatalogTreeJson += ",'createdate':'" + sdf.format(resCatalog.getCreatedate()) + "'"; // resCatalogTreeJson += ",'remark':'" + resCatalog.getRemark() + "'"; // resCatalogTreeJson += ",'childnodes':["; // String resCatalogChildNode = getTreeChildrenNodeList(resCatalog.getCatlogid());// 递归获取目录子节点列表 // if (resCatalogChildNode != "") { // resCatalogTreeJson += resCatalogChildNode; // } // resCatalogTreeJson += "]}"; // } // // return resCatalogTreeJson; // } // // /** // * @param parentCatalogId // * @Description: 获取子目录信息列表{@link ResCatalogService} // * @Author: xiaoxuan.xie // * @Date: 17:30 2018/3/15 // * @return: List // * @see Res_Catalog // */ // @ResponseBody // @GetMapping(path = "catalog/getListByParentID/{parentCatalogId}") // @ApiOperation(value = "获取子目录信息列表", notes = "") // public List getListByParentID( // @ApiParam(name = "parentCatalogId", value = "目录父节点Id", required = true) @PathVariable(name = "parentCatalogId") int parentCatalogId) { // return resCatalogService.selectResCatalogToParentid(parentCatalogId); // } // // /** // * @param catalogId // * @Description: 查询目录信息{@link ResCatalogService} // * @Author: xiaoxuan.xie // * @Date: 09:30 2018/3/16 // * @return: Res_Catalog // * @see Res_Catalog // */ // @ResponseBody // @GetMapping(path = "catalog/getById/{catalogId}") // @ApiOperation(value = "查询目录信息", notes = "") // public Res_Catalog getById( // @ApiParam(name = "catalogId", value = "目录Id", required = true) @PathVariable(name = "catalogId") int catalogId) { // return resCatalogService.getResCatalogInfoById(catalogId); // } // // /** // * @param serverId // * @Description: 查询服务基本信息{@link ResMainInfoService} // * @Author: xiaoxuan.xie // * @Date: 09:30 2018/3/16 // * @return: String // * @see Res_MainInfo // */ // @ResponseBody // @GetMapping(path = "Server/getBaseInfoById/{serverId}") // @ApiOperation(value = "查询服务基本信息", notes = "") // public String getBaseInfoById( // @ApiParam(name = "serverId", value = "服务Id", required = true) @PathVariable(name = "serverId") int serverId) { // String BaseInfoJson = "";// 定义返回Json存储对象 // Res_MainInfo resMainInfo = resMainInfoService.selectByPrimaryKey(serverId);// 获取资源基本信息 // BaseInfoJson = JSONObject.toJSONStringWithDateFormat(resMainInfo, "YYYY-MM-dd HH:mm:ss"); // BaseInfoJson = BaseInfoJson.substring(0, BaseInfoJson.length() - 1); // BaseInfoJson += ",resExtInfo:" + getResExtInfo(serverId, resMainInfo.getResourceclass()) + "}"; // // return BaseInfoJson; // } // // /** // * @param resourceid // * @param userid // * @param actiontype // * @param appid // * @Description: 日志数据写入 {@link ResActionRecordService} // * @Author: xiaoxuan.xie // * @Date: 13:30 2018/3/28 // * @return: Model // * @see Res_ActionRecord // */ // @ResponseBody // @GetMapping(path = "/setActionRecordInfo") // @ApiOperation(value = "日志信息写入", notes = "") // public String setActionRecordInfo(Integer resourceid, Long userid, String actiontype, Integer appid) { // Timestamp audittime = new Timestamp(new Date().getTime());// 获取当前时间 // int row = 0;// 操作数据库记录数 // // boolean success = false;// 操作状态 // String msg = "";// 操作返回消息 // Res_ActionRecord resRecord = new Res_ActionRecord(); // resRecord.setResourceid(resourceid); // resRecord.setUserid(userid); // resRecord.setActiontype(actiontype); // Res_ActionRecord res_actionRecord = resActionRecordService.getUserActionRecord(resRecord); // if (res_actionRecord == null) { // resRecord.setActiontype(actiontype); // resRecord.setActiontime(audittime); // resRecord.setAppid(appid); // row = resActionRecordService.insertSelective(resRecord); // success = true; // msg = "写入成功!"; // } else { // res_actionRecord.setAppid(appid); // res_actionRecord.setActiontime(audittime); // row = resActionRecordService.updateByPrimaryKeySelective(res_actionRecord); // success = true; // msg = "更新收藏!"; // } // return "{success:" + success + ", msg:'" + msg + "'}"; // } /** * @Description: 查询服务列表{@link ResMainInfoService} //change ykm * @Author: xiaoxuan.xie * @Date: 09:30 2018/3/16 * @return: String * @see Res_MainInfo */ @ResponseBody @GetMapping(path = "Server/getServerList") @ApiOperation(value = "查询服务列表", notes = "") public String getServerList(@ApiParam(name = "catalogid", value = "目录ID") @RequestParam(name = "catalogid", required = false) Integer catalogid, @ApiParam(name = "resourceclass", value = "资源类型") @RequestParam(name = "resourceclass", required = false) String resourceclass, @ApiParam(name = "resourceid", value = "资源ID") @RequestParam(name = "resourceid", required = false) Integer resourceid ) { String BaseInfoListJson = "";// 定义返回Json存储对象 Map map = new HashMap(); map.put("catalogid",catalogid); map.put("resourceclass",resourceclass); map.put("resourceid",resourceid); // List resMainInfoList = resMainInfoService.getAll();// 获取所有资源信息 List resMainInfoList = resMainInfoService.getListByMap(map);// 获取所有资源信息 for (Res_MainInfo resMainInfo : resMainInfoList) { String BaseInfoJson = ""; BaseInfoJson = JSONObject.toJSONStringWithDateFormat(resMainInfo, "YYYY-MM-dd HH:mm:ss"); JSONObject obj = JSONObject.parseObject(BaseInfoJson); Map m = obj; m.remove("remark"); BaseInfoJson = m.toString(); BaseInfoJson = BaseInfoJson.substring(0, BaseInfoJson.length() - 1); BaseInfoJson += ",resExtInfo:" + getResExtInfo(resMainInfo.getResourceid(), resMainInfo.getResourceclass()) + "}"; if (!BaseInfoListJson.isEmpty()) BaseInfoListJson += ","; BaseInfoListJson += BaseInfoJson; } BaseInfoListJson = htmlDecodeByRegExp(BaseInfoListJson); BaseInfoListJson = URLDecoder.decode(BaseInfoListJson.replaceAll("%","%25")); // } return "[" + BaseInfoListJson + "]"; } /** * @param Resourceid * @param leixing * @return String * @Description: 获取资源拓展信息 */ private String getResExtInfo(int Resourceid, String leixing) { String ResExtInfo = ""; String ResourceType = leixing; if (ResourceType == null) ResourceType = ""; // 根据资源类型获取资源拓展信息 //alert ykm 2019/02/26 if(ResourceType.equals("KJ_SWMX") || ResourceType.equals("KJ_SWDX") || ResourceType.equals("KJ_SWYX")) ResourceType = "KJ_SW"; switch (ResourceType) { case "KJ_JCDT":// 基础底图 Res_ExtBaseMap resExtBaseMap = resExtBaseMapService.selectByPrimaryKey(Resourceid);// 获取基础底图信息 ResExtInfo = JSONObject.toJSONString(resExtBaseMap); break; case "KJ_YWTC":// 业务图层 Res_ExtBusinessLayer resExtBusinessLayer = resExtBusinessLayerService.selectByPrimaryKey(Resourceid);// 获取业务图层信息 if(resExtBusinessLayer != null && resExtBusinessLayer.getServiceHTML() != null) { resExtBusinessLayer.setServiceHTML(htmlDecodeByRegExp(resExtBusinessLayer.getServiceHTML())); } ResExtInfo = JSONObject.toJSONString(resExtBusinessLayer); break; case "KJ_KJFX":// 空间分析 Res_ExtSpaceServerWithBLOBs resExtSpaceServerWithBLOBs = resExtSpaceServerService .selectByPrimaryKey(Resourceid);// 获取空间服务信息 if(resExtSpaceServerWithBLOBs != null && resExtSpaceServerWithBLOBs.getHelpurl() != null){ resExtSpaceServerWithBLOBs.setHelpurl(htmlDecodeByRegExp(resExtSpaceServerWithBLOBs.getHelpurl())); } ResExtInfo += JSONObject.toJSONString(resExtSpaceServerWithBLOBs); break; case "KJ_ZTDT":// 专题地图 Res_ExtThemeMap resExtThemeMap = resExtThemeMapService.selectByPrimaryKey(Resourceid);// 获取专题地图信息 ResExtInfo += JSONObject.toJSONString(resExtThemeMap); break; case "YWJC":// 业务集成 Res_ExtIntegrate resExtIntegrate = resExtIntegrateService.selectByPrimaryKey(Resourceid);// 获取业务集成信息 ResExtInfo += JSONObject.toJSONString(resExtIntegrate); break; case "SJWJ":// 文档数据 Res_ExtFileSource resExtFileSource = resExtFileSourceService.selectByPrimaryKey(Resourceid);// 获取文档数据信息 ResExtInfo += JSONObject.toJSONString(resExtFileSource); break; case "SJKB":// 数据库表 Res_ExtDataBase res_extDataBase = resExtDataBaseService.selectByMainInfoId(Resourceid); if(res_extDataBase!=null && res_extDataBase.getDatasourceid() != null) { Res_ExtDataSource resExtDataSource = resExtDataSourceService.selectByPrimaryKey(res_extDataBase.getDatasourceid()); //add ykm JSONObject obj = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(res_extDataBase,"YYYY-MM-dd HH:mm:ss")); obj.put("DataSourceInfo", JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(resExtDataSource,"YYYY-MM-dd HH:mm:ss"))); ResExtInfo += obj.toJSONString(); } else { ResExtInfo += JSONObject.toJSONString(res_extDataBase); } break; case "JKFW":// 接口服务 Res_ExtInterFaceService res_extInterFaceService = resExtInterFaceService.selectByPrimaryKey(Resourceid); if(res_extInterFaceService != null && res_extInterFaceService.getHelpurl() != null) { res_extInterFaceService.setHelpurl(htmlDecodeByRegExp(res_extInterFaceService.getHelpurl())); } ResExtInfo += JSONObject.toJSONString(res_extInterFaceService); break; // case "KJ_SWMX":// 三维模型 case "KJ_SW":// 三维类型,三维模型,三维地形,三维影像 Res_Ext3D res_ext3D = resExt3DService.selectByPrimaryKey(Resourceid); ResExtInfo += JSONObject.toJSONString(res_ext3D); break; default: ResExtInfo += "{}"; break; } return ResExtInfo; } public String htmlDecodeByRegExp(String str){ String s = ""; if(str.equals("")) return ""; s = str.replace("&","&"); s = s.replace("<","<"); s = s.replace(">",">"); s = s.replace(" "," "); s = s.replace("'","\'"); s = s.replace(""","\""); s = s.replace("\\",""); return s; } // /** // * @Description: 获取资源服务地址信息 // * @Author: xiaoxuan.xie // * @Date: 09:30 2018/3/31 // * @return: String // * @see Res_MainInfo // */ // @ResponseBody // @GetMapping(path = "Server/getLayerObject/{resourceid}/{userid}") // @ApiOperation(value = "获取资源服务地址信息", notes = "") // public String GetLayerObject( // @ApiParam(name = "resourceid", value = "资源Id", required = true) @PathVariable(name = "resourceid") int resourceid, // @ApiParam(name = "userid", value = "用户Id", required = true) @PathVariable(name = "userid") Integer userid, // HttpServletRequest request) { // String Json = ""; // if (resourceid > 0) { // Res_MainInfo resMainInfo = resMainInfoService.selectByPrimaryKey(resourceid);// 获取资源主表信息 // if (resMainInfo != null) { // String resourceType = resMainInfo.getResourceclass();// 获取资源类型 // if (resourceType == null) // resourceType = ""; // LayerObject layer = null; // switch (resourceType) { // case "KJ_YWTC": // case "KJ_JCDT": // String username = request.getRemoteUser(); // Boolean GuanLian = false;//业务关联 // Boolean ZhouBian = false;//周边查询 // if(resourceType.equals("KJ_YWTC")) { // Res_BusinessRef res_businessRef = new Res_BusinessRef(); // res_businessRef.setResourceid(resourceid); // List resBusinessRefList = resBusinessRefService.selectResBusinesssRef(res_businessRef);//获取业务图层关联分析信息 // if(resBusinessRefList.size() > 0) GuanLian = true; // List resQueryAroundList = resQueryAroundService.getZhouBianList(resourceid);//获取资源周边查询列表 // if(resQueryAroundList.size() > 0) ZhouBian = true; // } // // 获取用户定义JSON // Res_DiyLayerInfo resDiyLayerInfo = resDiyLayerInfoService.queryUserObject(userid, resourceid); // if (resDiyLayerInfo != null) { // Json = "{ diyId: " + resDiyLayerInfo.getDiyid() + ", resourceId: " + resourceid + ", title: '" // + resDiyLayerInfo.getTitle() + "', content: " + resDiyLayerInfo.getContent() + ", GuanLian: " + GuanLian + ", ZhouBian: " + ZhouBian + "}"; // } else { // // 获取管理员定义JSON // resDiyLayerInfo = resDiyLayerInfoService.queryUserObject(0, resourceid); // if (resDiyLayerInfo != null) { // Json = "{ diyId: " + resDiyLayerInfo.getDiyid() + ", resourceId: " + resourceid // + ", title: '" + resDiyLayerInfo.getTitle() + "', content: " // + resDiyLayerInfo.getContent() + ", GuanLian: " + GuanLian + ", ZhouBian: " + ZhouBian + " }"; // } else { // // 获取资源支持协议与地址 // Res_ExtMapUrl resExtMapUrl = resExtMapUrlService.queryFirstOrderByResId(resourceid); // if (resExtMapUrl != null) { // // 获取token // //String token = "";// token // //String urlEncode = ""; // //if (resMainInfo.getEspproxy() == 1) { // // try { // // urlEncode = java.net.URLEncoder.encode(resExtMapUrl.getServerurl(), "UTF-8"); // // String getTokenUrl = sysConfig.getTokenWebRoot() + "?loginName=" + username // // + "&resourceId=" + resourceid + "&resourceUrl=" + urlEncode // // + "&expireSeconds=360000&clientIp=" + request.getRemoteAddr();// token获取地址 // // String TokenResponse = HttpOperateUtils.httpGet(getTokenUrl);// 请求token // // if (!TokenResponse.isEmpty()) { // // JSONObject object = JSONObject.parseObject(TokenResponse);// 转换返回JSON字符串 // // token = object.getString("token");// 获取返回token // // } // // Json = "{ resourceId: " + resourceid + ", title: '" + resMainInfo.getTitle() // // + "', typeandurl: '" + resExtMapUrl.getTypeandurl() + "', serverUrl: '" // // + resExtMapUrl.getServerurl() + "?token=" + token + "' }"; // // } catch (java.io.IOException e) { // // Json = "{ resourceId: " + resourceid + ", title: '" + resMainInfo.getTitle() // // + "', typeandurl: '" + resExtMapUrl.getTypeandurl() + "', serverUrl: '" // // + resExtMapUrl.getServerurl() + "?token=" + token + "' }"; // // } // //} else { // // Json = "{ resourceId: " + resourceid + ", title: '" + resMainInfo.getTitle() // // + "', typeandurl: '" + resExtMapUrl.getTypeandurl() + "', serverUrl: '" // // + resExtMapUrl.getServerurl() + "' }"; // //} // OrgUser orgUser = orgUserService.queryObject(Long.parseLong(userid.toString())); // Json = "{ resourceId: " + resourceid + ", title: '" + resMainInfo.getTitle() // + "', typeandurl: '" + resExtMapUrl.getTypeandurl() + "', serverUrl: '" // + EsbToken.getEsbUrl(resExtMapUrl.getServerurl(), orgUser.getLoginname(), request.getRemoteAddr(), resourceid, resMainInfo.getEspproxy(), sysConfig) // + "', GuanLian: " + GuanLian + ", ZhouBian: " + ZhouBian + " }"; // } else { // Json = "{ resourceId: " + resourceid + ", title: '" + resMainInfo.getTitle() // + "', typeandurl: '', serverUrl: '' , GuanLian: " + GuanLian + ", ZhouBian: " + ZhouBian + "}"; // } // } // } // break; // case "KJ_ZTDT": // Res_ExtThemeMap resExtThemeMap = resExtThemeMapService.selectByPrimaryKey(resourceid);// 获取专题地图拓展信息 // if (resExtThemeMap != null && resExtThemeMap.getMapjson() != null // && !resExtThemeMap.getMapjson().isEmpty()) { // Json = "{resourceId: " + resourceid + ", title: '" + resMainInfo.getTitle() + "', mapjson: " // + resExtThemeMap.getMapjson() + "}"; // } else { // Json = "{resourceId: " + resourceid + ", title: '" + resMainInfo.getTitle() // + "', mapjson: null}"; // } // break; // } // } // } // // return Json; // } // // /** // * @Description: 获取资源服务协议与地址信息 // * @Author: xiaoxuan.xie // * @Date: 09:30 2018/4/2 // * @return: String // * @see Res_MainInfo // */ // @ResponseBody // @GetMapping(path = "Server/getMapUrlObject/{userid}/{resourceid}/{type}/{id}") // @ApiOperation(value = "获取资源服务协议与地址信息", notes = "") // public String GetMapUrlObject( // @ApiParam(name = "userid", value = "用户ID", required = true) @PathVariable(name = "userid") Long userid, // @ApiParam(name = "resourceid", value = "资源Id", required = true) @PathVariable(name = "resourceid") Integer resourceid, // @ApiParam(name = "type", value = "type", required = true) @PathVariable(name = "type") String type, // @ApiParam(name = "id", value = "id", required = true) @PathVariable(name = "id") Integer id, // HttpServletRequest request) { // String Json = ""; // if (type.equals("Url")) { // Res_ExtMapUrl resExtMapUrl = resExtMapUrlService.selectByPrimaryKey(id);// 获取资源支持协议与地址 // Res_MainInfo resMainInfo = resMainInfoService.selectByPrimaryKey(resourceid);// 获取资源主表信息 // if (resExtMapUrl != null) { // // 获取token // //String token = "";// token // //String urlEncode = ""; // //if (resMainInfo.getEspproxy() == 1) { // // try { // // urlEncode = java.net.URLEncoder.encode(resExtMapUrl.getServerurl(), "UTF-8"); // // String getTokenUrl = sysConfig.getTokenWebRoot() + "?resourceId=" + resourceid // // + "&resourceUrl=" + urlEncode + "&expireSeconds=360000&clientIp=" // // + request.getRemoteAddr();// token获取地址 // // String TokenResponse = HttpOperateUtils.httpGet(getTokenUrl);// 请求token // // JSONObject object = JSONObject.parseObject(TokenResponse);// 转换返回JSON字符串 // // token = object.getString("token");// 获取返回token // // Json = "{ resourceId: " + resourceid + ", title: '" + resMainInfo.getTitle() // // + "', typeandurl: '" + resExtMapUrl.getTypeandurl() + "', serverUrl: '" // // + resExtMapUrl.getServerurl() + "?token=" + token + "' }"; // // } catch (UnsupportedEncodingException e) { // // Json = "{ resourceId: " + resourceid + ", title: '" + resMainInfo.getTitle() // // + "', typeandurl: '" + resExtMapUrl.getTypeandurl() + "', serverUrl: '" // // + resExtMapUrl.getServerurl() + "?token=" + token + "' }"; // // } catch (Exception e) { // // Json = "{ resourceId: " + resourceid + ", title: '" + resMainInfo.getTitle() // // + "', typeandurl: '" + resExtMapUrl.getTypeandurl() + "', serverUrl: '" // // + resExtMapUrl.getServerurl() + "?token=" + token + "' }"; // // } // //} else { // // Json = "{ resourceId: " + resourceid + ", title: '" + resMainInfo.getTitle() + "', typeandurl: '" // // + resExtMapUrl.getTypeandurl() + "', serverUrl: '" + resExtMapUrl.getServerurl() + "' }"; // //} // OrgUser orgUser = orgUserService.queryObject(userid); // Json = "{ resourceId: " + resourceid + ", title: '" + resMainInfo.getTitle() // + "', typeandurl: '" + resExtMapUrl.getTypeandurl() + "', serverUrl: '" // + EsbToken.getEsbUrl(resExtMapUrl.getServerurl(), orgUser.getLoginname(), request.getRemoteAddr(), resourceid, resMainInfo.getEspproxy(), sysConfig) + "' }"; // } else { // Json = "{ resourceId: " + resourceid + ", title: '" + resMainInfo.getTitle() // + "', typeandurl: '', serverUrl: '' }"; // } // } else { // Res_DiyLayerInfo resDiyLayerInfo = resDiyLayerInfoService.getById(id);// 获取自定义风格信息 // if (resDiyLayerInfo != null) { // Json = "{ diyId: " + resDiyLayerInfo.getDiyid() + ", resourceId: " + resourceid + ", title: '" // + resDiyLayerInfo.getTitle() + "', content: " + resDiyLayerInfo.getContent() + " }"; // } else { // Json = "{ diyId: " + id + ", resourceId: " + resourceid + ", title: '', content: null }"; // } // } // // return Json; // } // // /** // * @Description: 获取业务集成-页面集成-Iframe区块目录树 // */ // @ResponseBody // @GetMapping(path = "Server/getYWJCTreeData/{id}") // @ApiOperation(value = "获取业务集成-页面集成-Iframe区块目录树", notes = "") // public String getYWJCTreeData( // @ApiParam(name = "id", value = "id", required = true) @PathVariable(name = "id") String id, // HttpServletRequest request) { // StringBuilder resCatalogJson = new StringBuilder(); // String leixiId = "YWJC"; // Res_MainInfo resMainInfoTWO = new Res_MainInfo(); // resMainInfoTWO.setResourceclass(leixiId); // resMainInfoTWO.setCParentid(Integer.parseInt(id)); // resMainInfoTWO.setCatlogid(Integer.parseInt(id)); // List resCatalogList = resCatalogService.getYWJCMuLuTree(Integer.parseInt(id));// 获取子目录列表 // // 循环构造子目录节点 // for (Res_Catalog resCatalog : resCatalogList) { // if (!"".equals(resCatalogJson.toString())) { // resCatalogJson.append(','); // } // resCatalogJson.append( // "{id: " + resCatalog.getCatlogid() + ",name:'" + resCatalog.getTitle() + "', isParent: true}"); // } // // 获取资源类型列表 // List resMainInfo = resMainInfoService.getYWJCTreeData(resMainInfoTWO); // 获取目录下业务集成--页面集成--Iframe区块资源列表 // // 循环构造资源节点 // for (Res_MainInfo resMainInfo1 : resMainInfo) { // Res_ExtIntegrate res_extIntegrate = resExtIntegrateService.selectByPrimaryKey(resMainInfo1.getResourceid());// 获取业务集成拓展信息 // if (!"".equals(resCatalogJson.toString())) { // resCatalogJson.append(','); // } // // String title = resMainInfo1.getTitle(); // if (resMainInfo1.getTitle().length() > 16) { // title = resMainInfo1.getTitle().substring(0, 16) + ".."; // } // // String serverUrl = res_extIntegrate.getServerurl(); // if (serverUrl == null) // serverUrl = ""; // // resCatalogJson.append("{id: 'ZiYuan_" + resMainInfo1.getResourceid() + "',name:'" + title + "', title: '" // + resMainInfo1.getTitle() + "',isParent:false, ServerUrl: '" + serverUrl + "'}"); // } // return "[" + resCatalogJson.toString() + "]"; // } /** * @Description: 查询资源是否存在 * @Author: dengshuhua * @return: Boolean */ @ResponseBody @GetMapping(path = "/cheackZYIsExist") @ApiOperation(value = "查询服务列表", notes = "") public Boolean getServerList(@ApiParam(name = "resourceid", value = "资源ID") @RequestParam(name = "resourceid", required = true) Integer resourceid) { Boolean result = false; Res_MainInfo mainInfo = resMainInfoService.selectByPrimaryKey(resourceid); if(mainInfo != null) result = true; return result; } @ResponseBody @GetMapping(path = "/GetStationDataSearch") @ApiOperation(value = "海洋站监测数据数据信息检索", notes = "") public Result GetStationDataSearch(Integer stationCode,String startDate,String endDate,String factorCode) { String data = ""; String path = sysConfig.getUploadPath() + "cache\\"+"Search.txt"; try { String url = "http://192.168.4.124:8100/stations/data/search?stationCode=" + stationCode + "&startDate=" + startDate + "&endDate=" + endDate + "&factorCode=" + factorCode; data = HttpOperateUtils.httpGet(url); File file = new File(path); file.createNewFile(); FileWriter writer = new FileWriter(file); BufferedWriter out = new BufferedWriter(writer); out.write(data); out.flush(); } catch (Exception ex) { } return Result.ok().put("path",sysConfig.getUploadRootPath()+"cache/"+"Search.txt"); } @ResponseBody @GetMapping(path = "/GetCXDataByTaiZhanNameAndTime") @ApiOperation(value = "获取台站预报数据", notes = "") public Result GetCXDataByTaiZhanNameAndTime(String name,String timeStr) { String ycdata = ""; String parpath = sysConfig.getUploadPath() + "cache\\yc"; String date = DateTime.now().toString().substring(0,10); String todayData = parpath +"\\"+date+".txt"; try { File parentDir = new File(parpath); if(parentDir.isDirectory()){ File[] files = parentDir.listFiles(); //是否存在当天的预测数据 boolean isExits = false; for(File f : files){ String n = f.getName(); if(f.getName().equals(date+".txt")){ isExits = true; break; } } //不存在则从接口获取数据写入当天缓存 if(!isExits){ //删除文件夹下的文件 for(File f : files){ f.delete(); } String url = "http://192.168.20.106/Ocean/WebServices/ElecTable/X_CWYG_Server.asmx/GetCXDataByTaiZhanNameAndTime"; SearchZscg searchZscg = new SearchZscg(); searchZscg.setName(URLDecoder.decode(name)); searchZscg.setTimeStr(timeStr); ycdata = HttpOperateUtils.httpPost(url,searchZscg); File newfile = new File(todayData); newfile.createNewFile(); FileWriter writer = new FileWriter(newfile); BufferedWriter out = new BufferedWriter(writer); out.write(ycdata); out.flush(); } } } catch (Exception ex) { } return Result.ok().put("path",sysConfig.getUploadRootPath()+"cache/yc/"+date+".txt"); } public class SearchZscg{ private String name; private String timeStr; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getTimeStr() { return timeStr; } public void setTimeStr(String timeStr) { this.timeStr = timeStr; } } }