package com.landtool.lanbase.modules.res.controller;
|
|
import java.io.BufferedReader;
|
import java.io.File;
|
import java.io.IOException;
|
import java.io.InputStream;
|
import java.io.InputStreamReader;
|
import java.io.UnsupportedEncodingException;
|
import java.net.URL;
|
import java.net.URLDecoder;
|
import java.net.URLEncoder;
|
import java.sql.Timestamp;
|
import java.text.SimpleDateFormat;
|
import java.util.ArrayList;
|
import java.util.Collections;
|
import java.util.Comparator;
|
import java.util.Date;
|
import java.util.HashMap;
|
import java.util.Iterator;
|
import java.util.LinkedHashMap;
|
import java.util.LinkedList;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.UUID;
|
import java.util.stream.Collectors;
|
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
|
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.lang.StringEscapeUtils;
|
import org.apache.commons.lang.StringUtils;
|
import org.apache.shiro.SecurityUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.core.env.Environment;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.ui.Model;
|
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 org.springframework.web.multipart.MultipartFile;
|
|
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
import com.github.pagehelper.Page;
|
import com.github.pagehelper.PageHelper;
|
import com.landtool.lanbase.common.annotation.LogAction;
|
import com.landtool.lanbase.common.map.EsbToken;
|
import com.landtool.lanbase.common.utils.CommonUtils;
|
import com.landtool.lanbase.common.utils.DateUtils;
|
import com.landtool.lanbase.common.utils.HttpOperateUtils;
|
import com.landtool.lanbase.common.utils.JpinyinUtils;
|
import com.landtool.lanbase.common.utils.Result;
|
import com.landtool.lanbase.config.SysTemPropertyConfig;
|
import com.landtool.lanbase.modules.api.utils.Excel;
|
import com.landtool.lanbase.modules.api.utils.JDBCUtils;
|
import com.landtool.lanbase.modules.api.utils.PageBean;
|
import com.landtool.lanbase.modules.log.service.LogActionService;
|
import com.landtool.lanbase.modules.org.entity.OrgUnit;
|
import com.landtool.lanbase.modules.org.entity.OrgUser;
|
import com.landtool.lanbase.modules.org.service.OrgUnitService;
|
import com.landtool.lanbase.modules.org.service.OrgUserService;
|
import com.landtool.lanbase.modules.res.entity.Res_ActionRecord;
|
import com.landtool.lanbase.modules.res.entity.Res_ApplyRecommend;
|
import com.landtool.lanbase.modules.res.entity.Res_Catalog;
|
import com.landtool.lanbase.modules.res.entity.Res_DiyLayerInfo;
|
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_ExtMapUrl;
|
import com.landtool.lanbase.modules.res.entity.Res_ExtSpaceServer;
|
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_FileSource_Way;
|
import com.landtool.lanbase.modules.res.entity.Res_Files;
|
import com.landtool.lanbase.modules.res.entity.Res_MainInfo;
|
import com.landtool.lanbase.modules.res.entity.Res_ProblemFeedback;
|
import com.landtool.lanbase.modules.res.entity.Res_Subscriptions;
|
import com.landtool.lanbase.modules.res.entity.SimpleZiYuan;
|
import com.landtool.lanbase.modules.res.entity.DataBaseLeftDataSource.DataBaseLeftDataSource;
|
import com.landtool.lanbase.modules.res.entity.JSONModels.BiaoJieGou;
|
import com.landtool.lanbase.modules.res.entity.JSONModels.ZiDuanPeiZi;
|
import com.landtool.lanbase.modules.res.entity.UserDefined.DingYue;
|
import com.landtool.lanbase.modules.res.entity.UserDefined.MainInfoJoinAudit;
|
import com.landtool.lanbase.modules.res.entity.UserDefined.MainInfoJoinJcdt;
|
import com.landtool.lanbase.modules.res.entity.UserDefined.UserDef_ZYML_ChaXunQu;
|
import com.landtool.lanbase.modules.res.entity.ViewModels.FileSourceList;
|
import com.landtool.lanbase.modules.res.entity.ZiYuanTongJi.GroupByDanWei;
|
import com.landtool.lanbase.modules.res.entity.ZiYuanTongJi.GroupByGongXiangXieYi;
|
import com.landtool.lanbase.modules.res.entity.ZiYuanTongJi.GroupByPubDate;
|
import com.landtool.lanbase.modules.res.entity.ZiYuanTongJi.GroupByXingZhengQuHua;
|
import com.landtool.lanbase.modules.res.entity.ZiYuanTongJi.GroupByZiYuanLeiXing;
|
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.ResCatalogService;
|
import com.landtool.lanbase.modules.res.service.ResDiyLayerInfoService;
|
import com.landtool.lanbase.modules.res.service.ResEvaluationService;
|
import com.landtool.lanbase.modules.res.service.ResExt3DService;
|
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.ResFileSourceWayService;
|
import com.landtool.lanbase.modules.res.service.ResFilesService;
|
import com.landtool.lanbase.modules.res.service.ResMainInfoService;
|
import com.landtool.lanbase.modules.res.service.ResProblemFeedbackService;
|
import com.landtool.lanbase.modules.res.service.ResQueryAroundService;
|
import com.landtool.lanbase.modules.res.service.ResSubscriptionsService;
|
import com.landtool.lanbase.modules.res.service.ZiYuanMuLuService;
|
import com.landtool.lanbase.modules.sys.controller.AbstractController;
|
import com.landtool.lanbase.modules.sys.service.SysFieldvalueService;
|
|
import cn.hutool.json.JSONUtil;
|
|
/**
|
* @Date: 2018-03-02 11:34
|
* @Description:主表逻辑操作
|
*/
|
@Controller
|
@RequestMapping("/resbak")
|
public class ResMainInfoController_bak20190109 extends AbstractController {
|
@Autowired
|
private ResMainInfoService resMainInfoService;
|
|
@Autowired
|
private ResCatalogService resCatalogService;
|
|
@Autowired
|
private ResExtBaseMapService resExtBaseMapService;
|
|
@Autowired
|
private ResExtBusinessLayerService resExtBusinessLayerService;
|
|
@Autowired
|
private ResExtSpaceServerService resExtSpaceServerService;
|
|
@Autowired
|
private ResExtThemeMapService resExtThemeMapService;
|
|
@Autowired
|
private ResExtIntegrateService resExtIntegrateService;
|
|
@Autowired
|
private ResExtFileSourceService resExtFileSourceService;
|
|
@Autowired
|
private ResActionRecordService resActionRecordService;
|
|
@Autowired
|
private ResExtInterFaceService resExtInterFaceService;
|
|
@Autowired
|
private ResExtDataBaseService resExtDataBaseService;
|
|
@Autowired
|
private ResExt3DService resExt3DService;
|
|
@Autowired
|
private ResExtDataSourceService resExtDataSourceService;
|
|
@Autowired
|
private SysTemPropertyConfig sysConfig;
|
|
@Autowired
|
public ResApplyRecommendService resApplyRecommendService;
|
|
@Autowired
|
private SysFieldvalueService FieldUtils;
|
|
@Autowired
|
private OrgUserService orgUserService;
|
|
@Autowired
|
private OrgUnitService orgUnitService;
|
|
@Autowired
|
private ResFileSourceWayService resFileSourceWayService;
|
|
@Autowired
|
private ResSubscriptionsService resSubscriptionsService;
|
|
@Autowired
|
private ResExtMapUrlService resExtMapUrlService;
|
|
@Autowired
|
private ResAuditService resAuditService;
|
|
@Autowired
|
private ResBusinessRefService resBusinessRefService;
|
|
@Autowired
|
private ResQueryAroundService resQueryAroundService;
|
|
@Autowired
|
private ResEvaluationService resEvaluationService;
|
|
@Autowired
|
private ResDiyLayerInfoService resDiyLayerInfoService;
|
|
@Autowired
|
private Environment env;
|
|
@Autowired
|
private ResFilesService resFileService;
|
|
@Autowired
|
public ZiYuanMuLuService ziYuanMuLuService;
|
|
@Autowired
|
private ResProblemFeedbackService resProblemFeedbackService;
|
|
@Autowired
|
private LogActionService logActionService;
|
|
private String wenjianjiaPath() {
|
return sysConfig.getUploadPath() + "FileSource\\wenjianjia\\";
|
}
|
|
private String wenjianPath() {
|
return sysConfig.getUploadPath() + "FileSource\\wenjian\\";
|
}
|
|
public static String strMuLu = "";
|
|
/**
|
* 访问资源编辑页面(ResRegister.Controller)
|
*/
|
@RequestMapping("ZiYuan/AddZiYuanBasic")
|
public String ziYuanEditJump(Model model, Long resMainInfoId) {
|
if (resMainInfoId != null) {
|
Res_MainInfo resMainInfo = resMainInfoService.selectByPrimaryKey(resMainInfoId.intValue());
|
// 获取资源类型列表
|
LinkedHashMap<String, String> ResourceTypeList = FieldUtils.getFieldListByKey("ResourceType");
|
model.addAttribute("resourceclass", ResourceTypeList.get(resMainInfo.getResourceclass()));
|
}
|
model.addAttribute("resMainInfoId", resMainInfoId);
|
return "FuWuZiYuan/ZiYuan_Edit";
|
}
|
|
/**
|
* 访问资源基本信息新增页面
|
*/
|
@RequestMapping("ZiYuan/AddZiYuanChildren")
|
public String addZiYuanChildren(HttpServletRequest request, Model model, Long resMainInfoId) throws IOException {
|
Res_MainInfo res_mainInfo = new Res_MainInfo();
|
Res_Catalog res_catalog = new Res_Catalog();
|
String Imagelujin = null;
|
// 修改
|
if (resMainInfoId != null) {
|
res_mainInfo = resMainInfoService.selectByPrimaryKey(resMainInfoId.intValue());
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
String Pubdate = sdf.format(res_mainInfo.getPubdate());
|
model.addAttribute("Pubdate", Pubdate);
|
if (res_mainInfo.getCatlogid() != null) {
|
res_catalog = resCatalogService.selectByPrimaryKey(res_mainInfo.getCatlogid());
|
}
|
if (res_mainInfo.getImgurl() != null && res_mainInfo.getImgurl() != "") {
|
StringBuffer url = request.getRequestURL();
|
String ip = "/ZiYuanIcon/";
|
Imagelujin = ip + res_mainInfo.getImgurl();
|
}
|
// 数据覆盖范围--行政区划Id
|
String administrativeid = res_mainInfo.getAdministrativeid();
|
if (administrativeid != null && !administrativeid.isEmpty() && administrativeid != " ") {
|
String getRegionInfourl = sysConfig.getApiServer() + "/api/org/region/getById/" + administrativeid;
|
String jsonStr = HttpOperateUtils.httpGet(getRegionInfourl.trim());
|
if (jsonStr != null && !jsonStr.isEmpty()) {
|
JSONObject item = JSONObject.parseObject(jsonStr);
|
String regionname = item.getString("regionname");
|
model.addAttribute("administrativename", regionname);
|
}
|
}
|
}
|
// 获取资源类型列表
|
LinkedHashMap<String, String> ResourceTypeList = FieldUtils.getFieldListByKey("ResourceType");
|
model.addAttribute("mainInfo", res_mainInfo);
|
model.addAttribute("rescatalog", res_catalog);
|
model.addAttribute("resMainInfoId", resMainInfoId);
|
model.addAttribute("ResourceTypeList", ResourceTypeList);
|
model.addAttribute("Imagelujin", Imagelujin);
|
return "FuWuZiYuan/AddZiYuanChildren";
|
}
|
|
/**
|
* 访问查看页面
|
*/
|
@RequestMapping("ZiYuan/ZiYuanSelect")
|
public String ziYuanSelect(Model model, Long resMainInfoId) {
|
model.addAttribute("resMainInfoId", resMainInfoId);
|
model.addAttribute("pubzyWebRoot", sysConfig.getPubzyWebRoot());
|
model.addAttribute("systemName", sysConfig.getAppFullName());
|
return "FuWuZiYuan/ZiYuanSelect";
|
}
|
|
/**
|
* 访问资源元数据新增页面
|
*/
|
@RequestMapping("ZiYuan/AddZiYuanYSJ")
|
public String addZiYuanYSJ() {
|
return "FuWuZiYuan/AddZiYuanYSJ";
|
}
|
|
/**
|
* 插入资源编辑页面内容
|
*/
|
@RequestMapping("ziYuanInsert")
|
@ResponseBody
|
@LogAction("资源管理,资源发布,资源新增,新增|zy")
|
public String ziYuanInsert(Res_MainInfo resMainInfo, String GUANJIANZI) {
|
// 获取拼音首字母
|
String shortPinYin = JpinyinUtils.changeToGetShortPinYin((String) resMainInfo.getTitle());
|
resMainInfo.setPingyinfiirst(shortPinYin);
|
resMainInfo.setAuditstatus(0);// 设置资源状态为未提交
|
resMainInfo.setResourcestatus(0);// 设置资源服务状态为正常
|
resMainInfo.setEspproxy(0);// 设置是否代理为0:false
|
resMainInfo.setDisplayby2d(0);// 设置是否支持二维展示为0:不支持
|
resMainInfo.setDisplayby3d(0);// 设置是否支持三维展示为0“不支持
|
resMainInfo.setPubdate(DateUtils.getFunllDate(resMainInfo.getPubdate()));
|
//换地址
|
if (resMainInfo.getDesurl() != null && resMainInfo.getDesurl().indexOf("diydes") != -1) {
|
String url = resMainInfo.getDesurl().replace(sysConfig.getUploadRootPath(), "");
|
resMainInfo.setDesurl(url);
|
}
|
int result = resMainInfoService.insertSelective(resMainInfo);
|
resMainInfo.setOrderid(resMainInfo.getResourceid());
|
resMainInfoService.updateByPrimaryKeySelective(resMainInfo);
|
|
Object resourceClass = resMainInfo.getResourceclass();
|
return "{'result':'" + result + "','ziyuanId':'" + resMainInfo.getResourceid() + "','ziyuanClass':'" + resourceClass.toString() + "'}";
|
}
|
|
/**
|
* 更新资源编辑页面内容
|
*/
|
@RequestMapping("ziYuanUpdaate")
|
@ResponseBody
|
@LogAction("资源管理,资源发布,资源修改,修改|zy")
|
public String ziYuanUpdaate(Res_MainInfo resMainInfo) {
|
// 获取拼音首字母
|
String shortPinYin = JpinyinUtils.changeToGetShortPinYin((String) resMainInfo.getTitle());
|
resMainInfo.setPingyinfiirst(shortPinYin);
|
// 更新基本信息时间
|
Timestamp audittime = new Timestamp(new Date().getTime());// 获取当前时间
|
// 更新委托批复
|
if (resMainInfo.getInsteadaudit() == null) {
|
// modified by qufangxu
|
resMainInfo.setInsteadaudit(0);
|
}
|
//换地址
|
if (resMainInfo.getDesurl() != null && resMainInfo.getDesurl().indexOf("diydes") != -1) {
|
String url = resMainInfo.getDesurl().replace(sysConfig.getUploadRootPath(), "");
|
resMainInfo.setDesurl(url);
|
}
|
resMainInfo.setPubdate(DateUtils.getFunllDate(resMainInfo.getPubdate()));
|
resMainInfo.setLasteditdate(audittime);
|
int result = resMainInfoService.updateByPrimaryKeySelective(resMainInfo);
|
|
return "{'result':'" + result + "','ziyuanId':'" + resMainInfo.getResourceid() + "'}";
|
}
|
|
/**
|
* 更新资源编辑页面内容
|
*/
|
@RequestMapping("ziYuanSubmit")
|
@ResponseBody
|
@LogAction("资源管理,资源发布,资源修改,修改")
|
public String ziYuanSubmit(Res_MainInfo resMainInfo) {
|
int result;
|
Res_MainInfo model = resMainInfoService.selectByPrimaryKey(resMainInfo.getResourceid());
|
// 更新委托批复
|
if (resMainInfo.getInsteadaudit() == null) {
|
// modified by qufangxu
|
resMainInfo.setInsteadaudit(0);
|
}
|
if (model.getResourcestatus() == 3) { // 资源提交。如果资源状态为注销则改为正常
|
resMainInfo.setResourcestatus(0);
|
}
|
boolean isExistExt = hasExistExtZiYuan(resMainInfo.getResourceid(), model.getResourceclass());// 是否存在扩展信息
|
if (isExistExt) {
|
String shortPinYin = JpinyinUtils.changeToGetShortPinYin((String) resMainInfo.getTitle());// 获取拼音首字母
|
resMainInfo.setPingyinfiirst(shortPinYin);
|
resMainInfo.setAuditstatus(1);
|
|
result = resMainInfoService.updateByPrimaryKeySelective(resMainInfo);
|
} else {// 如果不存在扩展信息提示填写扩展信息
|
return "{'result':'" + 2 + "','ziyuanId':'" + resMainInfo.getResourceid() + "'}";
|
}
|
return "{'result':'" + result + "','ziyuanId':'" + resMainInfo.getResourceid() + "'}";
|
}
|
|
/**
|
* 检测资源拓展信息是否存在
|
* @param resourceId
|
* @param resourceClass
|
* @return
|
*/
|
public boolean hasExistExtZiYuan(Integer resourceId, String resourceClass) {
|
// LinkedHashMap<String, String> ResourceTypeList =
|
// FieldUtils.getFieldListByKey("ResourceType",
|
// sysConfig.getApiServer();//获取资源类型列表
|
// String resourceType = ResourceTypeList.get(resourceClass);
|
if (resourceClass == null) resourceClass = "";
|
switch (resourceClass) {
|
case "KJ_JCDT":// 基础底图
|
Res_ExtBaseMap res_ExtBaseMap = resExtBaseMapService.selectByPrimaryKey(resourceId);
|
return res_ExtBaseMap != null;
|
case "KJ_YWTC":// 业务图层
|
Res_ExtBusinessLayer res_ExtBusinessLayer = resExtBusinessLayerService.selectByPrimaryKey((resourceId));
|
return res_ExtBusinessLayer != null;
|
case "KJ_KJFX":// 空间分析
|
Res_ExtSpaceServer res_ExtSpaceServer = resExtSpaceServerService.selectByPrimaryKey(resourceId);
|
return res_ExtSpaceServer != null;
|
case "KJ_ZTDT":// 专题地图
|
Res_ExtThemeMap res_ExtThemeMap = resExtThemeMapService.selectByPrimaryKey(resourceId);
|
return res_ExtThemeMap != null;
|
// case "专题应用程序":
|
// Res_ExtApp res_ExtApp =
|
// resExtAppService.selectByPrimaryKey(resourceId);
|
// return res_ExtApp != null;
|
case "YWJC":// 业务集成
|
Res_ExtIntegrate res_ExtIntegrate = resExtIntegrateService.selectByPrimaryKey(resourceId);
|
return res_ExtIntegrate != null;
|
case "SJWJ":// 数据文件
|
Res_ExtFileSource res_ExtFileSource = resExtFileSourceService.selectByPrimaryKey(resourceId);
|
return res_ExtFileSource != null;
|
case "SJKB":// 数据库表
|
Res_ExtDataBase res_extDataBase = resExtDataBaseService.selectByMainInfoId(resourceId);
|
return res_extDataBase != null;
|
case "JKFW":// 接口服务
|
Res_ExtInterFaceService res_extInterFaceService = resExtInterFaceService.selectByPrimaryKey(resourceId);
|
return res_extInterFaceService != null;
|
case "KJ_SWMX":// 三维模型
|
Res_Ext3D res_ext3D = resExt3DService.selectByPrimaryKey(resourceId);
|
return res_ext3D != null;
|
default:
|
return false;
|
}
|
}
|
|
/**
|
* 资源查询页面
|
*/
|
@RequestMapping("ZiYuan/Index")
|
public String index(String Message, Model model) {
|
// 获取下拉框目录
|
LinkedHashMap<String, String> ResourceTypeList = FieldUtils.getFieldListByKey("ResourceType");// 获取资源类型列表
|
model.addAttribute("ResourceTypeList", ResourceTypeList);
|
String ResourceTypeListJson = "";
|
for (Map.Entry<String, String> entry : ResourceTypeList.entrySet()) {
|
if (ResourceTypeListJson != "") ResourceTypeListJson += ",";
|
ResourceTypeListJson += "{key:'" + entry.getKey() + "',value:'" + entry.getValue() + "'}";
|
}
|
if (Message != null) {
|
model.addAttribute("Message", Message);
|
}
|
model.addAttribute("ResourceTypeListJson", "[" + ResourceTypeListJson + "]");
|
model.addAttribute("pubzyWebRoot", sysConfig.getPubzyWebRoot());
|
model.addAttribute("systemName", sysConfig.getAppFullName());
|
model.addAttribute("backstageWebRoot", sysConfig.getApiServer() + "/");
|
// 资源类型饼状统计图
|
List<GroupByZiYuanLeiXing> resourceclassList = resMainInfoService.selectResMainInfoGroupByLeiXing();
|
String ZYLXJson = "";
|
String ZYLXLend = "";
|
int ZYLXCount = 0;
|
// 多于4个类型的话数据显示前7个资源数量最多的类型,后面的都以其它统计
|
if (resourceclassList.size() > 4) {
|
int counter = 0;
|
for (int i = 4; i < resourceclassList.size(); i++) {
|
counter += resourceclassList.get(i).getCount();
|
}
|
for (int i = 0; i < 4; i++) {
|
GroupByZiYuanLeiXing item = resourceclassList.get(i);
|
String leixing = ResourceTypeList.get(item.getResourceclass());
|
ZYLXJson += (ZYLXJson == "" ? "" : ",") + "{ value: " + item.getCount() + ", name: '" + leixing + "'}";
|
ZYLXLend += (ZYLXLend == "" ? "" : ",") + "'" + leixing + "'";
|
ZYLXCount += item.getCount();
|
}
|
ZYLXJson += (ZYLXJson == "" ? "" : ",") + "{ value: " + counter + ", name: '" + "其它" + "'}";
|
ZYLXLend += (ZYLXLend == "" ? "" : ",") + " '" + "其它" + "'";
|
ZYLXCount += counter;
|
}
|
// 少于等于4个类型就全部显示
|
else {
|
for (int i = 0; i < resourceclassList.size(); i++) {
|
GroupByZiYuanLeiXing item = resourceclassList.get(i);
|
String leixing = ResourceTypeList.get(item.getResourceclass());
|
ZYLXJson += (ZYLXJson == "" ? "" : ",") + "{ value: " + item.getCount() + ", name: '" + leixing + "'}";
|
ZYLXLend += (ZYLXLend == "" ? "" : ",") + "'" + leixing + "'";
|
ZYLXCount += item.getCount();
|
}
|
}
|
model.addAttribute("ZYLXJson", "[" + ZYLXJson + "]");
|
model.addAttribute("ZYLXLend", "[" + ZYLXLend + "]");
|
model.addAttribute("ZYLXCount", ZYLXCount);
|
|
// 行政区划饼状统计图
|
List<GroupByXingZhengQuHua> administrativeidList = resMainInfoService.selectResMainInfoGroupByXingZhengQuHua();
|
String XZQHJson = "";
|
String XZQHLend = "";
|
int XZQHCount = 0;
|
String jsonStr = "";
|
String getRegionInfourl = sysConfig.getApiServer() + "/api/org/region/queryList";
|
try {
|
jsonStr = HttpOperateUtils.httpGet(getRegionInfourl.trim());
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
JSONArray XZQHItem = JSONObject.parseArray(jsonStr);
|
if (administrativeidList.size() > 5) {
|
int XZcounter = 0;
|
for (int i = 5; i < administrativeidList.size(); i++) {
|
XZcounter += administrativeidList.get(i).getCount();
|
}
|
for (int i = 0; i < 5; i++) {
|
GroupByXingZhengQuHua item = administrativeidList.get(i);
|
String quhua = item.getAdministrativeid().trim();
|
if (quhua.length() > 0) {
|
if (!quhua.substring(2, quhua.length()).equals("0000")) {
|
quhua = quhua.substring(0, 2) + "0000"; // 下级市区归属到省
|
}
|
} else {
|
continue;
|
} // 为空跳过
|
for (int j = 0; j < XZQHItem.size(); j++) {
|
JSONObject temp = (JSONObject) XZQHItem.get(j);
|
String regionid = temp.getString("regionid");
|
if (regionid.equals(quhua)) {
|
quhua = temp.getString("regionname");
|
break;
|
}
|
}
|
XZQHJson += (XZQHJson == "" ? "" : ",") + "{ value: " + item.getCount() + ", name: '" + quhua + "'}";
|
XZQHLend += (XZQHLend == "" ? "" : ",") + "'" + quhua + "'";
|
XZQHCount += item.getCount();
|
}
|
XZQHJson += (XZQHJson == "" ? "" : ",") + "{ value: " + XZcounter + ", name: '" + "其它" + "'}";
|
XZQHLend += (XZQHLend == "" ? "" : ",") + " '" + "其它" + "'";
|
XZQHCount += XZcounter;
|
} else {
|
for (int i = 0; i < administrativeidList.size(); i++) {
|
GroupByXingZhengQuHua item = administrativeidList.get(i);
|
String quhua = item.getAdministrativeid().trim();
|
if (quhua.length() > 0) {
|
if (!quhua.substring(2, quhua.length()).equals("0000")) {
|
quhua = quhua.substring(0, 2) + "0000"; // 下级市区归属到省
|
}
|
} else {
|
continue;
|
} // 为空跳过
|
for (int j = 0; j < XZQHItem.size(); j++) {
|
JSONObject temp = (JSONObject) XZQHItem.get(j);
|
String regionid = temp.getString("regionid");
|
if (regionid.equals(quhua)) {
|
quhua = temp.getString("regionname");
|
break;
|
}
|
}
|
XZQHJson += (XZQHJson == "" ? "" : ",") + "{ value: " + item.getCount() + ", name: '" + quhua + "'}";
|
XZQHLend += (XZQHLend == "" ? "" : ",") + "'" + quhua + "'";
|
XZQHCount += item.getCount();
|
}
|
}
|
model.addAttribute("XZQHJson", "[" + XZQHJson + "]");
|
model.addAttribute("XZQHLend", "[" + XZQHLend + "]");
|
model.addAttribute("XZQHCount", XZQHCount);
|
|
// 共享协议饼状统计图
|
LinkedHashMap<String, String> GongXiangXieYiList = FieldUtils.getFieldListByKey("SharProtocol");// 获取共享协议列表
|
List<GroupByGongXiangXieYi> sharprotocolList = resMainInfoService.selectResMainInfoGroupByGongXiangXieYi();
|
String GXXYJson = "";
|
String GXXYLend = "";
|
int GXXYCount = 0;
|
for (int i = 0; i < sharprotocolList.size(); i++) {
|
GroupByGongXiangXieYi item = sharprotocolList.get(i);
|
String xieyi = item.getSharprotocol();
|
GXXYJson += (GXXYJson == "" ? "" : ",") + "{ value: " + item.getCount() + ", name: '" + xieyi + "'}";
|
GXXYLend += (GXXYLend == "" ? "" : ",") + "'" + xieyi + "'";
|
GXXYCount += item.getCount();
|
}
|
model.addAttribute("GXXYJson", "[" + GXXYJson + "]");
|
model.addAttribute("GXXYLend", "[" + GXXYLend + "]");
|
model.addAttribute("GXXYCount", GXXYCount);
|
|
// 按单位统计柱状图
|
List<GroupByDanWei> pubunitidList = resMainInfoService.selectResMainInfoGroupByDanWei();
|
String DWJson = "";
|
String DWLend = "";
|
String UnitStr = "";
|
for (int i = 0; i < pubunitidList.size(); i++) {
|
GroupByDanWei item = pubunitidList.get(i);
|
String id = item.getPubunitid();
|
String getUnitInfourl = sysConfig.getApiServer() + "/api/org/unit/getInfoById/" + id;
|
try {
|
UnitStr = HttpOperateUtils.httpGet(getUnitInfourl.trim());
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
JSONObject UnitData = JSONObject.parseObject(UnitStr);
|
String temp = UnitData.getString("unitname");
|
DWJson += (DWJson == "" ? "" : ",") + item.getCount();
|
DWLend += (DWLend == "" ? "" : ",") + "'" + temp + "'";
|
}
|
model.addAttribute("DWJson", "[" + DWJson + "]");
|
model.addAttribute("DWLend", "[" + DWLend + "]");
|
return "FuWuZiYuan/Index";
|
}
|
|
/**
|
* 所属目录目录树
|
*/
|
@RequestMapping("ZiYuan/MuLuShu")
|
public String muLuShu() {
|
return "ResManage/ResRegister/MuLuShu";
|
}
|
|
/**
|
* 行政区划目录树
|
*/
|
@RequestMapping("ZiYuan/AreaTree")
|
public String areaTree(Model model) {
|
model.addAttribute("backstageWebRoot", sysConfig.getApiServer() + "/");
|
model.addAttribute("systemName", sysConfig.getAppFullName());
|
return "FuWuZiYuan/AreaTree";
|
}
|
|
/**
|
* 资源图文列表
|
*/
|
@RequestMapping("ZiYuan/ZiYuanDataList")
|
public String ziYuanDataList(Res_MainInfo resMainInfo, Model model, PageBean pageBean) {
|
//update:dsh(2018/12/05)
|
Page<Res_MainInfo> page = PageHelper.startPage(pageBean.getPage(), 15);
|
List<Res_MainInfo> ziYuanMuLuList = resMainInfoService.selectResMainInfo(resMainInfo);
|
int countNums = (int) ((Page) ziYuanMuLuList).getTotal();
|
PageBean<Res_MainInfo> pageData = new PageBean<>(pageBean.getPage(), pageBean.getLimit(), countNums);
|
pageData.setItems(ziYuanMuLuList);
|
List<SimpleZiYuan> simpleZiYuans = new ArrayList<>();
|
LinkedHashMap<String, String> ResourceTypeList = FieldUtils.getFieldListByKey("ResourceType");
|
for (Integer j = 0; j < ziYuanMuLuList.size(); j++) {
|
Res_MainInfo zy = ziYuanMuLuList.get(j);
|
SimpleZiYuan model1 = new SimpleZiYuan();
|
model1.setResourceid(zy.getResourceid());
|
model1.setTitle(zy.getTitle());
|
model1.setCreateuserid(zy.getCreateuserid());
|
String chinesename = orgUserService.getChinesename(zy.getCreateuserid());// 查询发布人id对应的 name
|
String unitname = orgUnitService.getUnitName((long) zy.getPubunitid());
|
model1.setCreateusername(chinesename);
|
model1.setDatasources(zy.getDatasources());
|
model1.setPubunitid(zy.getPubunitid());
|
model1.setPubunitname(unitname);
|
model1.setKeywords(zy.getKeywords());
|
model1.setSecuritylev(zy.getSecuritylev());
|
model1.setResourceclass(ResourceTypeList.get(zy.getResourceclass()));
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
model1.setPubdate(sdf.format(zy.getPubdate()));
|
simpleZiYuans.add(model1);
|
}
|
model.addAttribute("ZyList", simpleZiYuans);
|
model.addAttribute("Count", countNums);
|
model.addAttribute("Page", pageBean.getPage());
|
return "FuWuZiYuan/ZiYuanDataList";
|
}
|
|
@RequestMapping("ZiYuan/JcdtDataList")
|
public String jcdtDataList(MainInfoJoinJcdt resMainInfo, Model model, PageBean pageBean) {
|
//update:dsh(2018/12/05)
|
Page<MainInfoJoinJcdt> page = PageHelper.startPage(pageBean.getPage(), 15);
|
List<MainInfoJoinJcdt> ziYuanMuLuList = resMainInfoService.selectJcdtList(resMainInfo);
|
int countNums = (int) ((Page) ziYuanMuLuList).getTotal();
|
PageBean<MainInfoJoinJcdt> pageData = new PageBean<>(pageBean.getPage(), pageBean.getLimit(), countNums);
|
pageData.setItems(ziYuanMuLuList);
|
List<SimpleZiYuan> simpleZiYuans = new ArrayList<>();
|
for (Integer j = 0; j < ziYuanMuLuList.size(); j++) {
|
MainInfoJoinJcdt zy = ziYuanMuLuList.get(j);
|
SimpleZiYuan model1 = new SimpleZiYuan();
|
model1.setResourceid(zy.getResourceid());
|
model1.setTitle(zy.getTitle());
|
model1.setCreateuserid(zy.getCreateuserid());
|
model1.setDatasources(zy.getDatasources());
|
model1.setPubunitid(zy.getPubunitid());
|
model1.setKeywords(zy.getKeywords());
|
model1.setSecuritylev(zy.getSecuritylev());
|
LinkedHashMap<String, String> ResourceTypeList = FieldUtils.getFieldListByKey("ResourceType");
|
model1.setResourceclass(ResourceTypeList.get(zy.getResourceclass()));
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
model1.setPubdate(sdf.format(zy.getPubdate()));
|
simpleZiYuans.add(model1);
|
}
|
model.addAttribute("ZyList", simpleZiYuans);
|
model.addAttribute("Count", countNums);
|
model.addAttribute("Page", pageBean.getPage());
|
return "FuWuZiYuan/JcdtDataList";
|
}
|
|
@RequestMapping("ZiYuan/ZiYuanList")
|
public String ziYuanList(Model model) {
|
// 获取下拉框目录
|
LinkedHashMap<String, String> ResourceTypeList = FieldUtils.getFieldListByKey("ResourceType");// 获取资源类型列表
|
List<String> DATASOURCES = resMainInfoService.selectDATASOURCES();
|
Timestamp audittime = new Timestamp(new Date().getTime());
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
|
List<Res_Catalog> MuLuList = resCatalogService.selectResCatalogToParentid(0);
|
String year = sdf.format(audittime);
|
model.addAttribute("year", year);
|
model.addAttribute("DATASOURCESList", DATASOURCES);
|
model.addAttribute("ResourceTypeList", ResourceTypeList);
|
model.addAttribute("MuLuList", MuLuList);
|
String ResourceTypeListJson = "";
|
for (Map.Entry<String, String> entry : ResourceTypeList.entrySet()) {
|
if (ResourceTypeListJson != "") ResourceTypeListJson += ",";
|
ResourceTypeListJson += "{key:'" + entry.getKey() + "',value:'" + entry.getValue() + "'}";
|
}
|
model.addAttribute("ResourceTypeListJson", "[" + ResourceTypeListJson + "]");
|
model.addAttribute("pubzyWebRoot", sysConfig.getPubzyWebRoot());
|
model.addAttribute("systemName", sysConfig.getAppFullName());
|
model.addAttribute("backstageWebRoot", sysConfig.getApiServer() + "/");
|
return "FuWuZiYuan/ZiYuanList";
|
}
|
|
@RequestMapping("ZiYuan/JcdtList")
|
public String jcdtList(Model model) {
|
// 获取下拉框目录
|
LinkedHashMap<String, String> BaseMapTypeList = FieldUtils.getFieldListByKey("BaseMapType");// 获取底图类型字典列表
|
List<String> DATASOURCES = resMainInfoService.selectDATASOURCES();
|
Timestamp audittime = new Timestamp(new Date().getTime());
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
|
List<Res_Catalog> MuLuList = resCatalogService.selectResCatalogToParentid(0);
|
|
String year = sdf.format(audittime);
|
model.addAttribute("year", year);
|
model.addAttribute("DATASOURCESList", DATASOURCES);
|
model.addAttribute("BaseMapTypeList", BaseMapTypeList);
|
model.addAttribute("MuLuList", MuLuList);
|
model.addAttribute("pubzyWebRoot", sysConfig.getPubzyWebRoot());
|
model.addAttribute("systemName", sysConfig.getAppFullName());
|
model.addAttribute("backstageWebRoot", sysConfig.getApiServer() + "/");
|
return "FuWuZiYuan/JcdtList";
|
}
|
|
/**
|
* 查询资源目录id
|
*/
|
@ResponseBody
|
@RequestMapping("selectZiYuan")
|
public Res_MainInfo selectZiYuan(int resMainInfoId) {
|
return resMainInfoService.selectByPrimaryKey(resMainInfoId);
|
}
|
|
/**
|
* 查询资源列表功能
|
*/
|
@ResponseBody
|
@RequestMapping("ZiYuan/selectResMainInfojoinCatalog")
|
@LogAction("资源管理,资源发布,资源列表查询,查询")
|
public Result selectResMainInfojoinCatalog(Res_MainInfo resMainInfo, PageBean pageBean) {
|
Page<Res_MainInfo> page = PageHelper.startPage(pageBean.getPage(), pageBean.getLimit());
|
if (!SecurityUtils.getSubject().isPermitted("org_user_admin")) {
|
resMainInfo.setExistPermission(getUserId().toString());
|
}
|
List<Res_MainInfo> mainInfoJoinCatalogList = resMainInfoService.selectAllMainInfo(resMainInfo);
|
int countNums = (int) ((Page) mainInfoJoinCatalogList).getTotal();
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
PageBean<Res_MainInfo> pageData = new PageBean<>(pageBean.getPage(), pageBean.getLimit(), countNums);
|
pageData.setItems(mainInfoJoinCatalogList);
|
LinkedHashMap<String, String> ResourceTypeList = FieldUtils.getFieldListByKey("ResourceType");// 获取资源类型列表
|
StringBuilder rsb = new StringBuilder();
|
String leixin = "";
|
|
//修改因英文单引号 '和双引号" 导致的错误 alert ykm 2019/01/08
|
List<Map<String,Object>> maps = new LinkedList<>();
|
for (Integer i = 0; i < mainInfoJoinCatalogList.size(); i++) {
|
leixin = ResourceTypeList.get(mainInfoJoinCatalogList.get(i).getResourceclass());
|
String chinesename = orgUserService.getChinesename(mainInfoJoinCatalogList.get(i).getCreateuserid());
|
String unitname = orgUnitService.getUnitName((long) mainInfoJoinCatalogList.get(i).getPubunitid());
|
String mulu = GetBianMu(mainInfoJoinCatalogList.get(i).getCatlogid() == null ? 0 : mainInfoJoinCatalogList.get(i).getCatlogid());
|
|
Map<String, Object> map = new HashMap<>();
|
map.put("resourceid", mainInfoJoinCatalogList.get(i).getResourceid());
|
map.put("title", mainInfoJoinCatalogList.get(i).getTitle());
|
map.put("mulu", mulu);
|
map.put("resourceclass", leixin);
|
map.put("pubdate", sdf.format(mainInfoJoinCatalogList.get(i).getPubdate()));
|
map.put("unitname", unitname);
|
map.put("chinesename", chinesename);
|
map.put("auditstatus", mainInfoJoinCatalogList.get(i).getAuditstatus());
|
maps.add(map);
|
}
|
return Result.ok().put("topics",maps).put("totalCount",countNums);
|
}
|
|
/**
|
* 查询资源所属目录
|
* @param Catlogid
|
* @return
|
*/
|
private String GetBianMu(int Catlogid) {
|
String str = "";
|
strMuLu = "";
|
if (Catlogid > 0) {
|
Res_Catalog zymlBianMu = resCatalogService.selectByPrimaryKey(Catlogid);
|
String str2 = CheckBianMu(zymlBianMu);
|
String[] res = str2.split(">");
|
for (int i = res.length - 1; i >= 0; i--) {
|
if (i == 0) {
|
str += res[i];
|
} else {
|
str += res[i] + " > ";
|
}
|
}
|
}
|
return str;
|
}
|
|
/**
|
* 递归获取资源目录名称
|
* @param zymlBianMu
|
* @return
|
*/
|
private String CheckBianMu(Res_Catalog zymlBianMu) {
|
if (zymlBianMu != null) {
|
strMuLu += zymlBianMu.getTitle() + ">";
|
if (zymlBianMu.getParentid() == 0) {
|
return strMuLu;
|
} else {
|
zymlBianMu = resCatalogService.selectByPrimaryKey(zymlBianMu.getParentid());
|
CheckBianMu(zymlBianMu);
|
}
|
}
|
return strMuLu;
|
}
|
|
@ResponseBody
|
@RequestMapping("ZiYuan/GetMuLu")
|
public String getMuLu(int id) {
|
List<Res_Catalog> List = resCatalogService.selectResCatalogToParentid(id);
|
String result = "{";
|
result += "Count:" + List.size() + ",list:[";
|
for (Res_Catalog model : List) {
|
result += "{ ZIYUANMULUID:" + model.getCatlogid() + ",ZIYUANMC:'" + model.getTitle() + "'},";
|
}
|
if (List.size() > 0) {
|
result = result.substring(0, result.length() - 1);
|
}
|
result += "]}";
|
return result;
|
}
|
|
/**
|
* 资源编辑页面
|
* @return
|
*/
|
@RequestMapping("ZiYuan_Edit")
|
public String ZiYuan_Edit() {
|
return "FuWuZiYuan/ZiYuan_Edit";
|
}
|
|
/**
|
* 查询目录结构
|
*/
|
@ResponseBody
|
@RequestMapping("selectMuLu")
|
public String selectDirectoryStructure(int id) {
|
List<Res_Catalog> resCatalogList = resCatalogService.selectResCatalogToParentid(id);
|
String resCatalogJson = "";
|
for (Res_Catalog resCatalog : resCatalogList) {
|
int childCount = resCatalogService.selectResCatalogIsExistsSon(resCatalog.getCatlogid());
|
resCatalogJson += (resCatalogJson.length() > 0 ? "," : "") + "{id:" + resCatalog.getCatlogid() + ", code: '" + resCatalog.getCatlogcode() + "', name:'" + resCatalog.getTitle() + "', pId:" + resCatalog.getParentid() + ", rpId:" + resCatalog.getParentid();
|
if (resCatalog.getIcon() == null || resCatalog.getIcon().length() == 0) {
|
resCatalogJson += (childCount > 0 ? ",isParent:true,iconOpen:'/image/classicons/folderOpen.png',iconClose:'/image/classicons/folder.png'" : ",icon:'/image/classicons/defaulticon.png'") + "}";
|
} else {
|
resCatalogJson += (",isParent:true,icon:'" + "/uploadPath/" + resCatalog.getIcon()) + "'}";
|
}
|
}
|
return "[" + resCatalogJson + "]";
|
}
|
|
/**
|
* 访问查看页面编辑
|
*/
|
@RequestMapping("ZiYuan/ziYuanSelect_Edit")
|
public String ziYuanSelect_Edit(Model model, int resMainInfoId) throws IOException {
|
// 收藏,用来判断登录的用户是否有收藏这个资源
|
Res_ActionRecord resActionRecord = new Res_ActionRecord();
|
|
Long userId = getUserId();
|
|
resActionRecord.setUserid(userId);
|
resActionRecord.setResourceid(resMainInfoId);
|
resActionRecord.setActiontype("收藏");
|
Res_ActionRecord res_actionRecord = resActionRecordService.getUserActionRecord(resActionRecord);
|
if (res_actionRecord != null) {
|
model.addAttribute("actionid", res_actionRecord.getActionid());
|
}
|
|
// 统计该资源的收藏次数
|
Res_ActionRecord resActionRecord1 = new Res_ActionRecord();
|
resActionRecord1.setActiontype("收藏");
|
resActionRecord1.setResourceid(resMainInfoId);
|
int countResult = resActionRecordService.selectResourceCount(resActionRecord1);
|
model.addAttribute("shoucangcount", countResult);
|
|
// 统计该资源的浏览次数
|
Res_ActionRecord resActionRecord2 = new Res_ActionRecord();
|
resActionRecord2.setActiontype("浏览");
|
resActionRecord2.setResourceid(resMainInfoId);
|
int countResult1 = resActionRecordService.selectResourceCount(resActionRecord2);
|
model.addAttribute("liulancount", countResult1);
|
|
// 统计该资源的调用次数
|
Res_ActionRecord resActionRecord3 = new Res_ActionRecord();
|
resActionRecord3.setActiontype("调用");
|
resActionRecord3.setResourceid(resMainInfoId);
|
int countResult2 = resActionRecordService.selectResourceCount(resActionRecord3);
|
model.addAttribute("diaoyongcount", countResult2);
|
|
Res_MainInfo res_mainInfo = new Res_MainInfo();
|
// 修改
|
res_mainInfo = resMainInfoService.selectByPrimaryKey(resMainInfoId);
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
String Pubdate = sdf.format(res_mainInfo.getPubdate());
|
// 判断所属目录
|
strMuLu = "";
|
res_mainInfo.setCatlogcode(GetBianMu(res_mainInfo.getCatlogid()));
|
// 判断发布单位
|
String unitname = orgUnitService.getUnitName((long) res_mainInfo.getPubunitid());
|
model.addAttribute("unitname", unitname);
|
// res_mainInfo.setPubunitid(unitid);
|
// 判断数据覆盖范围
|
String administrativeid = res_mainInfo.getAdministrativeid();
|
if (administrativeid != null && !administrativeid.isEmpty() && administrativeid != " ") {
|
String getRegionInfourl = sysConfig.getApiServer() + "/api/org/region/getById/" + administrativeid;
|
String jsonStr = HttpOperateUtils.httpGet(getRegionInfourl.trim());
|
if (jsonStr != null && !jsonStr.isEmpty()) {
|
JSONObject item = JSONObject.parseObject(jsonStr);
|
String regionname = item.getString("regionname");
|
res_mainInfo.setAdministrativeid(regionname);
|
}
|
}
|
// LinkedHashMap<String, String> ResourceTypeList =
|
// FieldUtils.getFieldListByKey("ResourceType",
|
// sysConfig.getApiServer();//获取资源类型列表
|
// 获取是否有在申请表有申请RES_APPLYRECOMMEND
|
Res_ApplyRecommend res_applyRecommend = new Res_ApplyRecommend();
|
res_applyRecommend.setAppuserid(getUserId().toString());
|
res_applyRecommend.setIsrecommend(0);
|
res_applyRecommend.setResourceid(resMainInfoId);
|
Res_ApplyRecommend applyRecommend = resApplyRecommendService.selectByResApplyRecommend(res_applyRecommend);
|
String isApply = "True";// 先设为True
|
if (applyRecommend != null && applyRecommend.getAuditresult() == 1) {
|
isApply = "False";
|
}
|
|
// 判断资源类型
|
String leixin = res_mainInfo.getResourceclass();
|
if (leixin == null) leixin = "";
|
// 判断该类型对应那张表,然后查询对应的表的字段
|
switch (leixin) {
|
case "KJ_JCDT":// 基础底图
|
Res_ExtBaseMap resExtBaseMap = resExtBaseMapService.selectByPrimaryKey(resMainInfoId);
|
if (resExtBaseMap != null) {
|
model.addAttribute("resExtBaseMap", resExtBaseMap);
|
} else {
|
Res_ExtBaseMap resExtBaseMap1 = new Res_ExtBaseMap();
|
model.addAttribute("resExtBaseMap", resExtBaseMap1);
|
}
|
break;
|
case "KJ_YWTC":// 业务图层
|
Res_ExtBusinessLayer resExtBusinessLayer = resExtBusinessLayerService.selectByPrimaryKey(resMainInfoId);
|
if (resExtBusinessLayer != null) {
|
model.addAttribute("resExtBusinessLayer", resExtBusinessLayer);
|
} else {
|
Res_ExtBusinessLayer resExtBusinessLayer1 = new Res_ExtBusinessLayer();
|
model.addAttribute("resExtBusinessLayer", resExtBusinessLayer1);
|
}
|
break;
|
case "KJ_KJFX":// 空间分析
|
Res_ExtSpaceServerWithBLOBs resExtSpaceServerWithBLOBs = resExtSpaceServerService.selectByPrimaryKey(resMainInfoId);
|
if (resExtSpaceServerWithBLOBs != null) {
|
model.addAttribute("resExtSpaceServerWithBLOBs", resExtSpaceServerWithBLOBs);
|
} else {
|
Res_ExtSpaceServerWithBLOBs resExtSpaceServerWithBLOBs1 = new Res_ExtSpaceServerWithBLOBs();
|
model.addAttribute("resExtSpaceServerWithBLOBs", resExtSpaceServerWithBLOBs1);
|
}
|
break;
|
case "KJ_ZTDT":// 专题地图
|
Res_ExtThemeMap resExtThemeMap = resExtThemeMapService.selectByPrimaryKey(resMainInfoId);
|
if (resExtThemeMap != null) {
|
model.addAttribute("resExtThemeMap", resExtThemeMap);
|
} else {
|
Res_ExtThemeMap resExtThemeMap1 = new Res_ExtThemeMap();
|
model.addAttribute("resExtThemeMap", resExtThemeMap1);
|
}
|
break;
|
// case "专题应用程序":
|
// Res_ExtApp resExtApp =
|
// resExtAppService.selectByPrimaryKey(resMainInfoId);
|
// if (resExtApp != null) {
|
// model.addAttribute("resExtApp", resExtApp);
|
// } else {
|
// Res_ExtApp resExtApp1 = new Res_ExtApp();
|
// model.addAttribute("resExtApp", resExtApp1);
|
// }
|
// break;
|
case "YWJC":// 业务集成
|
Res_ExtIntegrate resExtIntegrate = resExtIntegrateService.selectByPrimaryKey(resMainInfoId);
|
if (resExtIntegrate != null) {
|
model.addAttribute("resExtIntegrate", resExtIntegrate);
|
} else {
|
Res_ExtIntegrate resExtIntegrate1 = new Res_ExtIntegrate();
|
model.addAttribute("resExtIntegrate", resExtIntegrate1);
|
}
|
break;
|
case "SJWJ":// 数据文件
|
Res_ExtFileSource resExtFileSource = resExtFileSourceService.selectByPrimaryKey(resMainInfoId);
|
if (resExtFileSource != null) {
|
LinkedHashMap<String, String> filetypelist = FieldUtils.getFieldListByKey("FileType");
|
resExtFileSource.setFiletype(filetypelist.get(resExtFileSource.getFiletype()));
|
model.addAttribute("resExtFileSource", resExtFileSource);
|
} else {
|
Res_ExtFileSource resExtFileSource1 = new Res_ExtFileSource();
|
model.addAttribute("resExtFileSource", resExtFileSource1);
|
}
|
break;
|
case "SJKB":// 数据库表
|
Res_ExtDataBase res_extDataBase = resExtDataBaseService.selectByMainInfoId(resMainInfoId);
|
if (res_extDataBase != null) {
|
Res_ExtDataSource res_extDataSource = resExtDataSourceService.selectByPrimaryKey(res_extDataBase.getDatasourceid());
|
model.addAttribute("resExtDataBase", res_extDataBase);
|
model.addAttribute("resExtDataSource", res_extDataSource);
|
} else {
|
res_extDataBase = new Res_ExtDataBase();
|
Res_ExtDataSource res_extDataSource = new Res_ExtDataSource();
|
model.addAttribute("resExtDataBase", res_extDataBase);
|
model.addAttribute("resExtDataSource", res_extDataSource);
|
}
|
break;
|
case "JKFW":// 接口服务
|
Res_ExtInterFaceService res_extInterFaceService = resExtInterFaceService.selectByPrimaryKey(resMainInfoId);
|
if (res_extInterFaceService != null) {
|
model.addAttribute("resExtInterFaceService", res_extInterFaceService);
|
} else {
|
res_extInterFaceService = new Res_ExtInterFaceService();
|
model.addAttribute("resExtInterFaceService", res_extInterFaceService);
|
}
|
break;
|
case "KJ_SWMX":// 三维模型
|
Res_Ext3D res_ext3D = resExt3DService.selectByPrimaryKey(resMainInfoId);
|
if (res_ext3D != null) {
|
model.addAttribute("resExt3D", res_ext3D);
|
} else {
|
res_ext3D = new Res_Ext3D();
|
model.addAttribute("resExt3D", res_ext3D);
|
}
|
break;
|
}
|
model.addAttribute("Pubdate", Pubdate);
|
model.addAttribute("mainInfo", res_mainInfo);
|
model.addAttribute("resMainInfoId", resMainInfoId);
|
model.addAttribute("resourceType", leixin);
|
model.addAttribute("WuQZ", isApply);
|
|
return "FuWuZiYuan/ZiYuanSelect_Edit";
|
}
|
|
/**
|
* 删除主表信息
|
*/
|
@ResponseBody
|
@RequestMapping("deleteByPrimaryKey")
|
@LogAction("资源管理,资源发布,资源删除,删除|zy")
|
public int deleteByPrimaryKey(int resourceid,String title) {
|
// 先查询id对应的资源类型是哪一个
|
Res_MainInfo resMainInfo = resMainInfoService.selectByPrimaryKey(resourceid);
|
String leixin = resMainInfo.getResourceclass();
|
if (leixin == null) leixin = "";
|
// 判断该类型对应那张表,然后先删除从表在删除主表
|
switch (leixin) {
|
case "KJ_JCDT":// 基础底图
|
Res_ExtBaseMap resExtBaseMap = resExtBaseMapService.selectByPrimaryKey(resourceid);
|
if (resExtBaseMap != null) {
|
resExtBaseMapService.deleteByPrimaryKey(resourceid);
|
}
|
break;
|
case "KJ_YWTC":// 业务图层
|
Res_ExtBusinessLayer resExtBusinessLayer = resExtBusinessLayerService.selectByPrimaryKey(resourceid);
|
if (resExtBusinessLayer != null) {
|
resExtBusinessLayerService.deleteByPrimaryKey(resourceid);
|
}
|
break;
|
case "KJ_KJFX":// 空间分析
|
Res_ExtSpaceServerWithBLOBs resExtSpaceServerWithBLOBs = resExtSpaceServerService.selectByPrimaryKey(resourceid);
|
if (resExtSpaceServerWithBLOBs != null) {
|
resExtSpaceServerService.deleteByPrimaryKey(resourceid);
|
}
|
break;
|
case "KJ_ZTDT":// 专题地图
|
Res_ExtThemeMap resExtThemeMap = resExtThemeMapService.selectByPrimaryKey(resourceid);
|
if (resExtThemeMap != null) {
|
resExtThemeMapService.deleteByPrimaryKey(resourceid);
|
}
|
break;
|
// case "专题应用程序":
|
// Res_ExtApp resExtApp =
|
// resExtAppService.selectByPrimaryKey(resourceid);
|
// if (resExtApp != null) {
|
// resExtAppService.deleteByPrimaryKey(resourceid);
|
// }
|
// break;
|
case "YWJC":// 业务集成
|
Res_ExtIntegrate resExtIntegrate = resExtIntegrateService.selectByPrimaryKey(resourceid);
|
if (resExtIntegrate != null) {
|
resExtIntegrateService.deleteByPrimaryKey(resourceid);
|
}
|
break;
|
case "SJWJ":// 数据文件
|
Res_ExtFileSource resExtFileSource = resExtFileSourceService.selectByPrimaryKey(resourceid);
|
if (resExtFileSource != null) {
|
resExtFileSourceService.deleteByPrimaryKey(resourceid);
|
}
|
//展现方式
|
List<Res_FileSource_Way> resFileSourceWay = resFileSourceWayService.selectById(resourceid);
|
if (resFileSourceWay != null && resFileSourceWay.size() > 0) {
|
resFileSourceWayService.deleteByPrimaryKey(resourceid);
|
}
|
break;
|
case "SJKB":// 数据库表
|
Res_ExtDataBase res_extDataBase = resExtDataBaseService.selectByMainInfoId(resourceid);
|
if (res_extDataBase != null) {
|
resExtDataBaseService.deleteByPrimaryKey(resourceid);
|
}
|
break;
|
case "JKFW":// 接口服务
|
Res_ExtInterFaceService res_extInterFaceService = resExtInterFaceService.selectByPrimaryKey(resourceid);
|
if (res_extInterFaceService != null) {
|
resExtInterFaceService.deleteByPrimaryKey(resourceid);
|
}
|
break;
|
case "KJ_SWMX":// 三维模型
|
Res_Ext3D res_ext3D = resExt3DService.selectByPrimaryKey(resourceid);
|
if (res_ext3D != null) {
|
resExt3DService.deleteByPrimaryKey(resourceid);
|
}
|
break;
|
}
|
//资源附件
|
List<Res_Files> resFileList = resFileService.selectDataListForResourceid(resourceid);
|
if (resFileList != null && resFileList.size() > 0) {
|
resFileService.deleteByResourceid(resourceid);
|
}
|
//资源协议与地址
|
List<Res_ExtMapUrl> 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);
|
}
|
//自定义图层未实现
|
return resMainInfoService.deleteByPrimaryKey(resourceid);
|
}
|
|
/**
|
* 访问资源审核页面
|
*/
|
/* 插入资源编辑页面内容 */
|
@RequestMapping("ZiYuanShenHe/Index")
|
public String ziYuanShenHeIndex(Model model) {
|
// 获取下拉框目录
|
LinkedHashMap<String, String> ResourceTypeList = FieldUtils.getFieldListByKey("ResourceType");// 获取资源类型列表
|
model.addAttribute("ResourceTypeList", ResourceTypeList);
|
return "ZiYuanShenHe/Index";
|
}
|
|
@RequestMapping("ziYuanLiuLanInsert")
|
@ResponseBody
|
public String ziYuanLiuLanInsert() {
|
Res_ActionRecord resActionRecord = new Res_ActionRecord();
|
resActionRecord.setResourceid(1);
|
resActionRecord.setUserid(getUserId());
|
resActionRecord.setAppid(1);
|
Timestamp audittime = new Timestamp(new Date().getTime());
|
resActionRecord.setActiontime(audittime);
|
resActionRecord.setActiontype("浏览");
|
int result = resActionRecordService.insertSelective(resActionRecord);
|
|
return "" + result;
|
}
|
|
/**
|
* 查询资源审核列表功能(修改请到ResAuditController)
|
*/
|
@ResponseBody
|
@RequestMapping("selectResMainInfojoinAudit")
|
public String selectResMainInfojoinAudit(Res_MainInfo resMainInfo, PageBean pageBean) {
|
PageHelper.startPage(pageBean.getPage(), pageBean.getLimit());
|
List<MainInfoJoinAudit> mainInfoJoinAuditList = resMainInfoService.selectResMainInfojoinAudit(resMainInfo);
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
int countNums = (int) ((Page) mainInfoJoinAuditList).getTotal();
|
PageBean<MainInfoJoinAudit> pageData = new PageBean<>(pageBean.getPage(), pageBean.getLimit(), countNums);
|
pageData.setItems(mainInfoJoinAuditList);
|
LinkedHashMap<String, String> ResourceTypeList = FieldUtils.getFieldListByKey("ResourceType");// 获取资源类型列表
|
StringBuilder rsb = new StringBuilder();
|
rsb.append("{'totalCount':'" + countNums + "','topics':[");
|
for (Integer i = 0; i < mainInfoJoinAuditList.size(); i++) {
|
if (i != 0) {
|
rsb.append(",");
|
}
|
String resourceclass = ResourceTypeList.get(mainInfoJoinAuditList.get(i).getResourceclass());
|
if (resourceclass == null) {
|
resourceclass = "";
|
}
|
rsb.append("{'resourceid':'" + mainInfoJoinAuditList.get(i).getResourceid() + "','title':'" + mainInfoJoinAuditList.get(i).getTitle() + "','resourceclass':'" + resourceclass + "','pubunitid':'" + mainInfoJoinAuditList.get(i).getPubunitid() + "','pubdate':'" + sdf.format(mainInfoJoinAuditList.get(i).getPubdate()) + "','audituserid':'" + mainInfoJoinAuditList.get(i).getAudituserid() + "','auditstatus':'" + mainInfoJoinAuditList.get(i).getAuditstatus() + "'}");
|
}
|
rsb.append("]}");
|
return rsb.toString();
|
}
|
|
/**
|
* 资源注销 审核状态,为提交审核通过,则资源服务状态改为正常;如是注销,则修改审核状态为未提交(可以修改保存、提交、审核);
|
* @param resourceid
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("ZiYuan/SignOutResource")
|
@LogAction("资源管理,资源发布,资源修改(注销),修改")
|
public String signOutResource(int resourceid) {
|
Res_MainInfo resMainInfo = resMainInfoService.selectByPrimaryKey(resourceid);// 获取资源信息
|
int resourcestatus = 3;// 资源服务状态(0正常/1异常/3注销)
|
resMainInfo.setResourcestatus(resourcestatus);// 设置资源状态为注销
|
resMainInfo.setAuditstatus(0); // 设置资源状态为未提交
|
int auditResult = resMainInfoService.updateByPrimaryKeySelective(resMainInfo);// 更新数据
|
|
return "{success:true,msg:\"注销成功!\"}";
|
}
|
|
/**
|
* 处理文件上传
|
* @param request
|
* @param file
|
* @param model
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("testuploadimg")
|
public String download(HttpServletRequest request, @RequestParam("myFile") MultipartFile file, Model model) {
|
if (file.isEmpty()) {
|
return "No File";
|
}
|
String[] imgTypeArr = new String[]{"jpg", "png", "gif", "bmp", "jpeg"};
|
String imgType = file.getContentType();// 获取文件格式
|
boolean IsImg = false;// 文件格式检查状态
|
// 判断上传文件格式
|
for (int i = 0; i < imgTypeArr.length; i++) {
|
if (imgType.toLowerCase().endsWith(imgTypeArr[i])) {
|
IsImg = true;
|
break;
|
}
|
}
|
|
if (IsImg) {
|
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
|
String name = file.getOriginalFilename();
|
System.out.println("FileName:" + name);
|
|
String fileType = name.substring(name.lastIndexOf("."));
|
|
// image的名称
|
String Filename = uuid + fileType;
|
System.out.println("FileType:" + Filename);
|
|
String size = FileUtils.byteCountToDisplaySize(file.getSize());
|
System.out.println("FileSize:" + size);
|
//数据库保存 MainInfo/asdf.jpg
|
//path是本地地址
|
String path = sysConfig.getUploadPath() + "MainInfo\\";
|
File desFile = new File(path + Filename);
|
|
String info = desFile.getAbsolutePath();
|
System.out.println("info:" + info);
|
try {
|
FileUtils.copyInputStreamToFile(file.getInputStream(), desFile);
|
//返回网络地址,然后存储在数据库
|
return "MainInfo/" + Filename;
|
} catch (IOException e) {
|
e.printStackTrace();
|
return "0";
|
}
|
}
|
|
return "-1";
|
}
|
|
/**
|
* 查询所有的资源
|
*/
|
@ResponseBody
|
@RequestMapping("ZiYuan/getAll")
|
public String getAll() {
|
List<Res_MainInfo> list = resMainInfoService.getAll();
|
StringBuilder str = new StringBuilder();
|
str.append("[");
|
for (int i = 0; i < list.size(); i++) {
|
if (i != 0) {
|
str.append(",");
|
}
|
str.append("{");
|
str.append("'title':'" + list.get(i).getTitle() + "',");
|
str.append("'resourceid':'" + list.get(i).getResourceid() + "',");
|
str.append("}");
|
}
|
str.append("]");
|
return str.toString();
|
}
|
|
/**
|
* 查询所有的资源,根据发布时间排序
|
*/
|
@ResponseBody
|
@RequestMapping("ZiYuan/getAllOrderByTime")
|
public String getAllOrderByTime() {
|
List<Res_MainInfo> list = resMainInfoService.selectAllOrderByTime();
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
StringBuilder str = new StringBuilder();
|
str.append("[");
|
for (int i = 0; i < list.size(); i++) {
|
if (i != 0) {
|
str.append(",");
|
}
|
str.append("{");
|
String title = list.get(i).getTitle();
|
if (list.get(i).getTitle().length() > 15) { //按字符截取
|
title = CommonUtils.subStringUtils(title, 30);
|
}
|
str.append("'title':'" + title + "',");
|
str.append("'fulltitle':'" + list.get(i).getTitle() + "',");
|
str.append("'resourceid':'" + list.get(i).getResourceid() + "',");
|
str.append("'pubdate':'" + sdf.format(list.get(i).getPubdate()) + "'");
|
str.append("}");
|
}
|
str.append("]");
|
return str.toString();
|
}
|
|
// 导出excel
|
@ResponseBody
|
@RequestMapping("ZiYuan/excel")
|
public String excel(HttpServletResponse response, Res_MainInfo resMainInfo) {
|
List<Res_MainInfo> mainInfoJoinCatalogList = resMainInfoService.selectResMainInfojoinCatalog(resMainInfo);
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
LinkedHashMap<String, String> ResourceTypeList = FieldUtils.getFieldListByKey("ResourceType");// 获取资源类型列表
|
StringBuilder rsb = new StringBuilder();
|
String leixin = "";
|
// rsb.append("{'totalCount':'" + "");
|
// rsb.append("','topics':[");
|
|
List<Map<String,Object>> maps = new LinkedList<>();
|
for (Integer i = 0; i < mainInfoJoinCatalogList.size(); i++) {
|
leixin = ResourceTypeList.get(mainInfoJoinCatalogList.get(i).getResourceclass());
|
String chinesename = orgUserService.getChinesename(mainInfoJoinCatalogList.get(i).getCreateuserid()); // obj.getString("chinesename");
|
String unitname = orgUnitService.getUnitName((long) mainInfoJoinCatalogList.get(i).getPubunitid()); // obj1.getString("unitname");
|
String mulu = GetBianMu(mainInfoJoinCatalogList.get(i).getCatlogid() == null ? 0 : mainInfoJoinCatalogList.get(i).getCatlogid());
|
|
Map<String,Object> map = new HashMap<>();
|
map.put("resourceid",mainInfoJoinCatalogList.get(i).getResourceid());
|
map.put("title",mainInfoJoinCatalogList.get(i).getTitle());
|
map.put("mulu",mulu);
|
map.put("resourceclass",leixin);
|
map.put("pubdate",sdf.format(mainInfoJoinCatalogList.get(i).getPubdate()));
|
map.put("pubunitid",unitname);
|
map.put("createuserid",chinesename);
|
map.put("resourcestatus", mainInfoJoinCatalogList.get(i).getResourcestatus());
|
maps.add(map);
|
|
// if (i != 0) {
|
// rsb.append(",");
|
// }
|
// strMuLu = "";
|
//
|
// rsb.append("{'resourceid':'" + mainInfoJoinCatalogList.get(i).getResourceid() + "'");// 资源id
|
// rsb.append(",'title':'" + mainInfoJoinCatalogList.get(i).getTitle() + "'");// 资源名称
|
// rsb.append(",'mulu':'" + GetBianMu(mainInfoJoinCatalogList.get(i).getCatlogid() == null ? 0 : mainInfoJoinCatalogList.get(i).getCatlogid()) + "'");// 所属目录编码
|
//
|
// leixin = ResourceTypeList.get(mainInfoJoinCatalogList.get(i).getResourceclass());
|
// rsb.append(",'resourceclass':'" + leixin + "'");// 资源类型
|
// rsb.append(",'pubdate':'" + sdf.format(mainInfoJoinCatalogList.get(i).getPubdate()) + "'");// 发布时间
|
// // 查询发布人id对应的 name
|
// String chinesename = orgUserService.getChinesename(mainInfoJoinCatalogList.get(i).getCreateuserid()); // obj.getString("chinesename");
|
// String unitname = orgUnitService.getUnitName((long) mainInfoJoinCatalogList.get(i).getPubunitid()); // obj1.getString("unitname");
|
// rsb.append(",'pubunitid':'" + unitname + "'");// 发布单位id
|
// rsb.append(",'createuserid':'" + chinesename);// 发布添加人
|
// rsb.append("'}");
|
}
|
// rsb.append("]}");
|
|
String a[] = {"资源id", "资源名称", "所属目录编码", "资源类型", "发布时间", "发布单位", "发布添加人"};
|
try {
|
String Filename = Excel.going(response, a, JSON.toJSONString(maps, SerializerFeature.WriteMapNullValue), sysConfig.getUploadPath() + "excel\\");
|
String path2 = "/uploadPath/excel/";
|
String desFile = path2 + Filename;
|
System.out.println(desFile);
|
return desFile;
|
} catch (IOException e) {
|
e.printStackTrace();
|
return null;
|
}
|
}
|
|
// 获取最新的6条热门搜索
|
@ResponseBody
|
@GetMapping("/getTopHotSearch")
|
public String getTopHotSearch() {
|
StringBuilder str = new StringBuilder();
|
List<String> list = resMainInfoService.selectTopHotSearch();
|
str.append("[");
|
for (int i = 0; i < list.size(); i++) {
|
if (i != 0) {
|
str.append(",");
|
}
|
str.append("{");
|
str.append("'keyword':'" + list.get(i) + "',");
|
str.append("}");
|
}
|
str.append("]");
|
return str.toString();
|
}
|
|
/**
|
* 发布时间 http://127.0.0.1:8082/res/ziyuanmulu/index?Menu=ZYZX&menuId=07在这个页面当中调用了
|
*/
|
@ResponseBody
|
@RequestMapping("/ZiYuan/getZiYuanFaBuQingKuangChartData")
|
public String getZiYuanFaBuQingKuangChartData(String Method) {
|
String ResultJson = "";
|
String preJcdtSeries = "";
|
String preYwtcSeries = "";
|
String preZtdtSeries = "";
|
String preWdcgSeries = "";
|
String preQtSeries = "";
|
String nowJcdtSeries = "";
|
String nowYwtcSeries = "";
|
String nowZtdtSeries = "";
|
String nowWdcgSeries = "";
|
String nowQtSeries = "";
|
String Legend = "[{\"name\":\"基础底图\", \"icon\": \"rect\"},{\"name\":\"业务图层\", \"icon\": \"rect\"},{\"name\":\"专题地图\", \"icon\": \"rect\"},{\"name\":\"数据文件\", \"icon\": \"rect\"},{\"name\":\"其它\", \"icon\": \"rect\"}]";
|
if (Method.equals("Month")) {
|
String monstr = "[";
|
Date nowDate = new Date();
|
int nowmon = nowDate.getMonth(); // 记录当前的月份,并且生成X轴的字符
|
int lastmon = 0;
|
if (nowmon == 12) {
|
lastmon = 13;
|
} else {
|
lastmon = nowmon + 1;
|
}
|
for (int j = nowmon; j >= 1; j--) {
|
monstr = monstr + "\"" + j + "月\"" + ",";
|
}
|
for (int i = 12; i >= lastmon; i--) {
|
monstr = monstr + "\"去年" + i + "月\"" + ",";
|
}
|
|
monstr = monstr.substring(0, monstr.length() - 1);
|
monstr = monstr + "]";
|
int Year = nowDate.getYear();
|
int LastYear = Year - 1;
|
List<GroupByPubDate> preMonthList = resMainInfoService.selectResMainInfoGroupByPubDate(LastYear);
|
List<GroupByPubDate> nowMonthList = resMainInfoService.selectResMainInfoGroupByPubDate(Year);
|
String[] zylxList = new String[]{"KJ_JCDT", "KJ_YWTC", "KJ_ZTDT", "SJWJ", "QT"};
|
// 去年的月份资源拼接
|
if (nowmon != 12) {
|
// 去年资源发布数据统计,如果现在是12月则不统计去年的
|
for (int i = 0; i < zylxList.length; i++) {
|
int j = 0;
|
switch (zylxList[i]) {
|
case "KJ_JCDT":
|
preJcdtSeries = Screen(preJcdtSeries, lastmon, preMonthList, "KJ_JCDT");
|
break;
|
case "KJ_YWTC":
|
preJcdtSeries = Screen(preJcdtSeries, lastmon, preMonthList, "KJ_YWTC");
|
break;
|
case "KJ_ZTDT":
|
preJcdtSeries = Screen(preJcdtSeries, lastmon, preMonthList, "KJ_ZTDT");
|
break;
|
case "SJWJ":
|
preJcdtSeries = Screen(preJcdtSeries, lastmon, preMonthList, "SJWJ");
|
break;
|
default:
|
preQtSeries = ScreenOther(preQtSeries, lastmon, preMonthList);
|
break;
|
}
|
}
|
}
|
// 今年的资源拼接
|
for (int i = 0; i < zylxList.length; i++) {
|
String item = zylxList[i];
|
// 今年的资源发布情况数据统计
|
int j = 0;
|
switch (item) {
|
case "KJ_JCDT":
|
nowJcdtSeries = MontageResource(nowJcdtSeries, nowmon, nowMonthList, "KJ_JCDT");
|
break;
|
case "KJ_YWTC":
|
nowJcdtSeries = MontageResource(nowJcdtSeries, nowmon, nowMonthList, "KJ_YWTC");
|
break;
|
case "KJ_ZTDT":
|
nowJcdtSeries = MontageResource(nowJcdtSeries, nowmon, nowMonthList, "KJ_ZTDT");
|
break;
|
case "SJWJ":
|
nowJcdtSeries = MontageResource(nowJcdtSeries, nowmon, nowMonthList, "SJWJ");
|
break;
|
default:
|
nowQtSeries = MontageResourceOther(nowQtSeries, nowmon, nowMonthList);
|
break;
|
}
|
}
|
ResultJson = "{\"Legend\": " + Legend + ", \"xAxis\": " + monstr + ", \"Series\": {\"JcdtSeries\":[" + preJcdtSeries + nowJcdtSeries + "], \"YwtcSeries\": [" + preYwtcSeries + nowYwtcSeries + "], \"ZtdtSeries\": [" + preZtdtSeries + nowZtdtSeries + "],\"WdcgSeries\": [" + preWdcgSeries + nowWdcgSeries + "], \"prenowQtSeries\": [" + preQtSeries + nowQtSeries + "]}}";
|
}
|
return ResultJson;
|
}
|
|
//拼接资源(其他的)
|
private String MontageResourceOther(String nowQtSeries, int nowmon, List<GroupByPubDate> nowMonthList) {
|
int j;
|
List<GroupByPubDate> qt = nowMonthList.stream().filter((GroupByPubDate b) -> b.getResourceclass() != "KJ_JCDT" && b.getResourceclass() != "KJ_YWTC" && b.getResourceclass() != "KJ_ZTDT" && b.getResourceclass() != "SJWJ").collect(Collectors.toList());
|
// 降序是否正确
|
Collections.sort(qt, new Comparator() {
|
@Override
|
public int compare(Object o1, Object o2) {
|
if (o1 instanceof GroupByPubDate && o2 instanceof GroupByPubDate) {
|
GroupByPubDate e1 = (GroupByPubDate) o1;
|
GroupByPubDate e2 = (GroupByPubDate) o2;
|
return e2.getMonth() - e1.getMonth();
|
}
|
throw new ClassCastException("不能转换为GroupByPubDate类型");
|
}
|
});
|
j = 0;
|
for (int k = nowmon; k >= 1; k--) {
|
List<GroupByPubDate> monList = null;
|
switch (k) {
|
case 1:
|
monList = qt.stream().filter((GroupByPubDate b) -> b.getMonth() == 1).collect(Collectors.toList());
|
break;
|
case 2:
|
monList = qt.stream().filter((GroupByPubDate b) -> b.getMonth() == 2).collect(Collectors.toList());
|
break;
|
case 3:
|
monList = qt.stream().filter((GroupByPubDate b) -> b.getMonth() == 3).collect(Collectors.toList());
|
break;
|
case 4:
|
monList = qt.stream().filter((GroupByPubDate b) -> b.getMonth() == 4).collect(Collectors.toList());
|
break;
|
case 5:
|
monList = qt.stream().filter((GroupByPubDate b) -> b.getMonth() == 5).collect(Collectors.toList());
|
break;
|
case 6:
|
monList = qt.stream().filter((GroupByPubDate b) -> b.getMonth() == 6).collect(Collectors.toList());
|
break;
|
case 7:
|
monList = qt.stream().filter((GroupByPubDate b) -> b.getMonth() == 7).collect(Collectors.toList());
|
break;
|
case 8:
|
monList = qt.stream().filter((GroupByPubDate b) -> b.getMonth() == 8).collect(Collectors.toList());
|
break;
|
case 9:
|
monList = qt.stream().filter((GroupByPubDate b) -> b.getMonth() == 9).collect(Collectors.toList());
|
break;
|
case 10:
|
monList = qt.stream().filter((GroupByPubDate b) -> b.getMonth() == 10).collect(Collectors.toList());
|
break;
|
case 11:
|
monList = qt.stream().filter((GroupByPubDate b) -> b.getMonth() == 11).collect(Collectors.toList());
|
break;
|
case 12:
|
monList = qt.stream().filter((GroupByPubDate b) -> b.getMonth() == 12).collect(Collectors.toList());
|
break;
|
}
|
int total = 0;
|
if (monList.size() > 0) {
|
for (int z = 0; z < monList.size(); z++) {
|
total = total + monList.get(z).getCount();
|
}
|
}
|
|
nowQtSeries += (nowQtSeries == "" ? "" : ",") + total;
|
j++;
|
}
|
if (nowmon != 12) {
|
nowQtSeries = nowQtSeries + ",";
|
}
|
return nowQtSeries;
|
}
|
|
//拼接资源(特定类型的)
|
private String MontageResource(String nowJcdtSeries, int nowmon, List<GroupByPubDate> nowMonthList, String type) {
|
int j;// 筛选类型为基础底图的集合
|
List<GroupByPubDate> jcdt = nowMonthList.stream().filter((GroupByPubDate b) -> b.getResourceclass() == type).collect(Collectors.toList());
|
// 降序是否正确
|
Collections.sort(jcdt, new Comparator() {
|
@Override
|
public int compare(Object o1, Object o2) {
|
if (o1 instanceof GroupByPubDate && o2 instanceof GroupByPubDate) {
|
GroupByPubDate e1 = (GroupByPubDate) o1;
|
GroupByPubDate e2 = (GroupByPubDate) o2;
|
return e2.getMonth() - e1.getMonth();
|
}
|
throw new ClassCastException("不能转换为GroupByPubDate类型");
|
}
|
});
|
j = 0;
|
for (int k = nowmon; k >= 1; k--) {
|
if (k == nowmon) {
|
if (jcdt.size() > 0) {
|
for (int x = k; x < jcdt.get(j).getMonth(); j++) {
|
// 由于分组采用倒序排序,此处保证开始统计的月份是当前月份
|
}
|
}
|
}
|
if (j >= jcdt.size() || jcdt.get(j).getMonth() != k) {
|
nowJcdtSeries += (nowJcdtSeries == "" ? "" : ",") + 0;
|
|
} else {
|
nowJcdtSeries += (nowJcdtSeries == "" ? "" : ",") + jcdt.get(j).getCount();
|
j++;
|
}
|
}
|
if (nowmon != 12) {
|
nowJcdtSeries = nowJcdtSeries + ",";
|
}
|
return nowJcdtSeries;
|
}
|
|
// 筛选不同类型的集合(其他的)
|
private String ScreenOther(String preQtSeries, int lastmon, List<GroupByPubDate> preMonthList) {
|
List<GroupByPubDate> qt = preMonthList.stream().filter((GroupByPubDate b) -> b.getResourceclass() != "KJ_JCDT" && b.getResourceclass() != "KJ_YWTC" && b.getResourceclass() != "KJ_ZTDT" && b.getResourceclass() != "SJWJ").collect(Collectors.toList());
|
// 降序是否正确
|
Collections.sort(qt, new Comparator() {
|
@Override
|
public int compare(Object o1, Object o2) {
|
if (o1 instanceof GroupByPubDate && o2 instanceof GroupByPubDate) {
|
GroupByPubDate e1 = (GroupByPubDate) o1;
|
GroupByPubDate e2 = (GroupByPubDate) o2;
|
return e2.getMonth() - e1.getMonth();
|
}
|
throw new ClassCastException("不能转换为GroupByPubDate类型");
|
}
|
});
|
for (int k = 12; k >= lastmon; k--) {
|
List<GroupByPubDate> monList = null;
|
switch (k) {
|
case 1:
|
monList = qt.stream().filter((GroupByPubDate b) -> b.getMonth() == 1).collect(Collectors.toList());
|
break;
|
case 2:
|
monList = qt.stream().filter((GroupByPubDate b) -> b.getMonth() == 2).collect(Collectors.toList());
|
break;
|
case 3:
|
monList = qt.stream().filter((GroupByPubDate b) -> b.getMonth() == 3).collect(Collectors.toList());
|
break;
|
case 4:
|
monList = qt.stream().filter((GroupByPubDate b) -> b.getMonth() == 4).collect(Collectors.toList());
|
break;
|
case 5:
|
monList = qt.stream().filter((GroupByPubDate b) -> b.getMonth() == 5).collect(Collectors.toList());
|
break;
|
case 6:
|
monList = qt.stream().filter((GroupByPubDate b) -> b.getMonth() == 6).collect(Collectors.toList());
|
break;
|
case 7:
|
monList = qt.stream().filter((GroupByPubDate b) -> b.getMonth() == 7).collect(Collectors.toList());
|
break;
|
case 8:
|
monList = qt.stream().filter((GroupByPubDate b) -> b.getMonth() == 8).collect(Collectors.toList());
|
break;
|
case 9:
|
monList = qt.stream().filter((GroupByPubDate b) -> b.getMonth() == 9).collect(Collectors.toList());
|
break;
|
case 10:
|
monList = qt.stream().filter((GroupByPubDate b) -> b.getMonth() == 10).collect(Collectors.toList());
|
break;
|
case 11:
|
monList = qt.stream().filter((GroupByPubDate b) -> b.getMonth() == 11).collect(Collectors.toList());
|
break;
|
case 12:
|
monList = qt.stream().filter((GroupByPubDate b) -> b.getMonth() == 12).collect(Collectors.toList());
|
break;
|
}
|
|
int total = 0;
|
if (monList.size() > 0) {
|
for (int z = 0; z < monList.size(); z++) {
|
total = total + monList.get(z).getCount();
|
}
|
}
|
|
preQtSeries += (preQtSeries == "" ? "" : ",") + total;
|
}
|
return preQtSeries;
|
}
|
|
// 筛选不同类型的集合(特定类型的)
|
private String Screen(String preJcdtSeries, int lastmon, List<GroupByPubDate> preMonthList, String type) {
|
int j;
|
List<GroupByPubDate> jcdt = preMonthList.stream().filter((GroupByPubDate b) -> b.getResourceclass() == type).collect(Collectors.toList());
|
// 降序是否正确
|
Collections.sort(jcdt, new Comparator() {
|
@Override
|
public int compare(Object o1, Object o2) {
|
if (o1 instanceof GroupByPubDate && o2 instanceof GroupByPubDate) {
|
GroupByPubDate e1 = (GroupByPubDate) o1;
|
GroupByPubDate e2 = (GroupByPubDate) o2;
|
return e2.getMonth() - e1.getMonth();
|
}
|
throw new ClassCastException("不能转换为GroupByPubDate类型");
|
}
|
});
|
j = 0;
|
for (int k = 12; k >= lastmon; k--) {
|
if (j >= jcdt.size() || jcdt.get(j).getMonth() != k) {
|
preJcdtSeries += (preJcdtSeries == "" ? "" : ",") + 0;
|
} else {
|
preJcdtSeries += (preJcdtSeries == "" ? "" : ",") + jcdt.get(j).getCount();
|
j++;
|
}
|
}
|
return preJcdtSeries;
|
}
|
|
/**
|
* 获取最新6笔资源推荐
|
*/
|
@ResponseBody
|
@RequestMapping("ZiYuan/getTopRecommend")
|
public String getTopRecommend(boolean isDiTuFuwu) {
|
Long userid = getUserId();
|
Long unitId = orgUserService.getDefaultUnit(userid).getUnitid();
|
Res_ApplyRecommend resApplyRecommend = new Res_ApplyRecommend();
|
resApplyRecommend.setAppuserid(userid.toString());
|
resApplyRecommend.setAppunitid(unitId.toString());
|
Map<String, Object> paramMap = new HashMap<String, Object>();
|
paramMap.put("appuserid", userid);
|
paramMap.put("appunitid", unitId);
|
if (isDiTuFuwu == true) {
|
paramMap.put("isDiTuFuwu", getMapResourceClass());
|
} else {
|
paramMap.put("isDiTuFuwu", null);
|
}
|
List<Res_MainInfo> resMainInfoList = resApplyRecommendService.getTopRecommend(paramMap);
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
StringBuilder str = new StringBuilder();
|
str.append("[");
|
for (int i = 0; i < resMainInfoList.size(); i++) {
|
if (i != 0) {
|
str.append(",");
|
}
|
str.append("{");
|
if (resMainInfoList.get(i).getTitle().length() > 12) {
|
String title = CommonUtils.subStringUtils(resMainInfoList.get(i).getTitle(), 24);
|
str.append("'title':'" + title + "',");
|
} else {
|
str.append("'title':'" + resMainInfoList.get(i).getTitle() + "',");
|
}
|
str.append("'resourceid':'" + resMainInfoList.get(i).getResourceid() + "',");
|
String description = resMainInfoList.get(i).getDescription();
|
if (description != null && description.length() > 60) {
|
description = description.substring(0, 60) + "...";
|
try {
|
description = URLEncoder.encode(description, "utf-8").replace("+", "%20");
|
} catch (UnsupportedEncodingException e) {
|
e.printStackTrace();
|
}
|
str.append("'description':'" + description + "',");
|
} else {
|
try {
|
if(description != null) {
|
description = URLEncoder.encode(description, "utf-8").replace("+", "%20");
|
}
|
else description = "";
|
} catch (UnsupportedEncodingException e) {
|
e.printStackTrace();
|
}
|
str.append("'description':'" + description + "',");
|
}
|
String fulldescription = resMainInfoList.get(i).getDescription();
|
try {
|
if(fulldescription != null)
|
fulldescription = URLEncoder.encode(fulldescription, "utf-8").replace("+", "%20");
|
else fulldescription = "";
|
} catch (UnsupportedEncodingException e) {
|
e.printStackTrace();
|
}
|
str.append("'fulldescription':'" + fulldescription + "',");
|
str.append("'resourceclass':'" + resMainInfoList.get(i).getResourceclass() + "',");
|
String path = null;
|
if (resMainInfoList.get(i).getImgurl() != null && !resMainInfoList.get(i).getImgurl().isEmpty()) {
|
if(resMainInfoList.get(i).getImgurl().startsWith("Atkas")){//图集
|
path = "/image/" + resMainInfoList.get(i).getImgurl();
|
File file = new File(System.getProperty("user.dir")+ "\\src\\main\\resources\\static" + ("/image/"+resMainInfoList.get(i).getImgurl()).replace("/","\\"));
|
if (!file.exists()) { //判断物理路径是否存在,不存在则默认
|
path = "/image/classimg/" + resMainInfoList.get(i).getResourceclass() + ".gif";
|
}
|
}else {
|
path = "/uploadPath/" + resMainInfoList.get(i).getImgurl();
|
String filepath = sysConfig.getUploadPath() + resMainInfoList.get(i).getImgurl();
|
File file = new File(filepath);
|
if (!file.exists()) { //判断物理路径是否存在,不存在则默认
|
path = "/image/classimg/" + resMainInfoList.get(i).getResourceclass() + ".gif";
|
}
|
}
|
} else {
|
path = "/image/classimg/" + resMainInfoList.get(i).getResourceclass() + ".gif";
|
}
|
str.append("'imgurl':'" + path + "',");
|
str.append("'pubdate':'" + sdf.format(resMainInfoList.get(i).getPubdate()) + "',");
|
//判断是否有权限
|
Map<String, Object> map = new HashMap<>();
|
map.put("resourceid", resMainInfoList.get(i).getResourceid());
|
map.put("userid", getUserId());
|
map.put("unitid", unitId);
|
int count = resMainInfoService.checkZiYuanQuanXian(map);
|
//有权限查看(1有,0没有)
|
Integer isquanxian = 0;
|
if (count > 0) {
|
isquanxian = 1;
|
}
|
str.append("'isquanxian':" + isquanxian + ",");
|
str.append("'firstMapUrl':'" + getZTDTByPortalMapUrl(resMainInfoList.get(i).getResourceid(), resMainInfoList.get(i).getResourceclass()) + "',");
|
str.append("'resourceclass':'" + resMainInfoList.get(i).getResourceclass() + "'");
|
str.append("}");
|
}
|
str.append("]");
|
// String jsonEncoder = new sun.misc.BASE64Encoder().encode(str.toString().getBytes());
|
return str.toString();
|
}
|
|
/**
|
* 获取所有资源推荐
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("ZiYuan/getAllRecommend")
|
public String getAllRecommend(boolean isDiTuFuwu) {
|
Long userid = getUserId();
|
Long unitId = orgUserService.getDefaultUnit(userid).getUnitid();
|
|
Res_ApplyRecommend resApplyRecommend = new Res_ApplyRecommend();
|
resApplyRecommend.setAppuserid(userid.toString());
|
resApplyRecommend.setAppunitid(unitId.toString());
|
Map<String, Object> paramMap = new HashMap<String, Object>();
|
paramMap.put("appuserid", userid);
|
paramMap.put("appunitid", unitId);
|
if (isDiTuFuwu) {
|
paramMap.put("isDiTuFuwu", getMapResourceClass());
|
} else {
|
paramMap.put("isDiTuFuwu", null);
|
}
|
List<Res_MainInfo> resMainInfoList = resApplyRecommendService.getAllRecommend(paramMap);
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
StringBuilder str = new StringBuilder();
|
str.append("[");
|
for (int i = 0; i < resMainInfoList.size(); i++) {
|
if (i != 0) {
|
str.append(",");
|
}
|
str.append("{");
|
if (resMainInfoList.get(i).getTitle().length() > 12) {
|
String title = resMainInfoList.get(i).getTitle().substring(0, 12) + "...";
|
str.append("'title':'" + title + "',");
|
} else {
|
str.append("'title':'" + resMainInfoList.get(i).getTitle() + "',");
|
}
|
str.append("'resourceid':'" + resMainInfoList.get(i).getResourceid() + "',");
|
if (resMainInfoList.get(i).getDescription().length() > 60) {
|
String description = resMainInfoList.get(i).getDescription().substring(0, 60) + "...";
|
str.append("'description':'" + description + "',");
|
} else {
|
str.append("'description':'" + resMainInfoList.get(i).getDescription() + "',");
|
}
|
str.append("'resourceclass':'" + resMainInfoList.get(i).getResourceclass() + "',");
|
String path = null;
|
if (!resMainInfoList.get(i).getImgurl().isEmpty()) {
|
path = "/uploadPath/" + resMainInfoList.get(i).getImgurl();
|
String filepath = sysConfig.getUploadPath() + resMainInfoList.get(i).getImgurl();
|
File file = new File(filepath);
|
if (!file.exists()) { //判断物理路径是否存在,不存在则默认
|
path = "/image/classimg/" + resMainInfoList.get(i).getResourceclass() + ".gif";
|
}
|
} else {
|
path = "/image/classimg/" + resMainInfoList.get(i).getResourceclass() + ".gif";
|
}
|
str.append("'imgurl':'" + path + "',");
|
str.append("'pubdate':'" + sdf.format(resMainInfoList.get(i).getPubdate()) + "',");
|
str.append("}");
|
}
|
str.append("]");
|
return str.toString();
|
}
|
|
// 获取地图服务的类型代码
|
private String getMapResourceClass() {
|
LinkedHashMap<String, String> resourceTypeList = FieldUtils.getFieldListByKey("ResourceType");
|
Iterator<Map.Entry<String, String>> iter = resourceTypeList.entrySet().iterator();
|
String dituTypes = "";
|
while (iter.hasNext()) {
|
Map.Entry entry = (Map.Entry) iter.next();
|
Object key = entry.getKey();
|
if (key.toString().startsWith("KJ_")) {
|
dituTypes += "'" + key.toString() + "',";
|
}
|
}
|
dituTypes = dituTypes.length() > 0 ? dituTypes.substring(0, dituTypes.length() - 1) : dituTypes;
|
return dituTypes;
|
}
|
|
/**
|
* 资源目录左侧面板目录结构
|
* @param id 节点ID
|
* @param treeType 目录树类型(0:资源目录 4:资源类型)
|
* @param XZQHID 区域ID
|
* @param NF 时间
|
* @param IsSC 是否收藏
|
* @return String
|
*/
|
@ResponseBody
|
@RequestMapping("GetMuLuTreeData")
|
public String getMuLuTreeData(Integer id, int treeType, String XZQHID, String NF, int IsSC,String catalogName) {
|
String result = "";
|
if (id == null) id = 0;
|
Map<String, Object> map = new HashMap<>();
|
map.put("parentid", id);
|
map.put("xzqhid", XZQHID);
|
if (NF != null && !NF.isEmpty()) {
|
map.put("nf", NF);
|
}
|
map.put("shoucang", IsSC);
|
|
if (treeType == 0) {// 资源目录
|
if (catalogName != null && !catalogName.isEmpty()) {
|
//dsh 2018/12/12
|
map.put("catalogName", URLDecoder.decode(catalogName));
|
}
|
List<Res_Catalog> resCatalogList = resCatalogService.getMuLuTreeData(map);
|
for (Res_Catalog resCatalog : resCatalogList) {
|
int childCount = resCatalogService.selectResCatalogIsExistsSon(resCatalog.getCatlogid());
|
result += (result.length() > 0 ? "," : "") + "{id:" + resCatalog.getCatlogid() + ", code: '" + resCatalog.getCatlogcode() + "', name:'" + resCatalog.getTitle() + "(" + GetZYCountByClass(0, resCatalog.getCatlogcode(),catalogName) + ")', pId:" + resCatalog.getParentid() + ", rpId:" + resCatalog.getParentid() + (childCount > 0 ? ",isParent:true,iconOpen:'/image/classicons/folderOpen.png',iconClose:'/image/classicons/folder.png'" : ",icon:'/image/classicons/defaulticon.png'") + "}";
|
}
|
} else if (treeType == 4) {// 资源类型
|
LinkedHashMap<String, String> ResourceTypeList = FieldUtils.getFieldListByKey("ResourceType");// 获取资源类型列表
|
String kj = "";
|
if (ResourceTypeList.size() > 0) {
|
int count = 0;
|
for (Map.Entry<String, String> entry : ResourceTypeList.entrySet()) {
|
if (entry.getKey().length() > 3 && entry.getKey().substring(0, 3).equals("KJ_")) {
|
kj += (kj.length() > 0 ? "," : "") + "{id:'" + entry.getKey() + "', code: '" + entry.getKey() + "', name:'" + entry.getValue() + "(" + GetZYCountByClass(4, entry.getKey(),"") + ")'" + ",icon:'/image/classicons/"+entry.getKey()+".png'" + " }";
|
}
|
}
|
for (Map.Entry<String, String> entry : ResourceTypeList.entrySet()) {
|
if (entry.getKey().equals("KJ_")) {
|
result += (result.length() > 0 ? "," : "") + "{id:'" + entry.getKey() + "', code: '" + entry.getKey() + "', name:'" + entry.getValue() + "(" + GetZYCountByClass(4, entry.getKey(),"") + ")',open:true,children:[" + kj + "],iconOpen:'/image/classicons/folderOpen.png',iconClose:'/image/classicons/folder.png'}";
|
} else if (entry.getKey().length() > 3 && entry.getKey().substring(0, 3).equals("KJ_")) {
|
continue;
|
} else {
|
result += (result.length() > 0 ? "," : "") + "{id:'" + entry.getKey() + "', code: '" + entry.getKey() + "', name:'" + entry.getValue() + "(" + GetZYCountByClass(4, entry.getKey(),"") + ")'" + ",icon:'/image/classicons/"+entry.getKey()+".png'" + "}";
|
}
|
}
|
System.out.println(result);
|
}
|
}
|
if (id == 0 && treeType == 4) {
|
result = "{id:0,name:'" + (treeType == 4 ? "资源类型" : "资源目录") + "(" + GetZYCountByClass(0, "","") + ")',pId:-1,isParent:true,open:true,children:[" + result + "],iconOpen:'/image/classicons/folderOpen.png',iconClose:'/image/classicons/folder.png' }";
|
}
|
return "[" + result + "]";
|
}
|
|
/**
|
* 根据名称拼音 显示名字
|
*/
|
@ResponseBody
|
@RequestMapping("/user/findUserByWord")
|
public String findUserByWord(String keyWord, HttpServletRequest request) {
|
String callbackFunName = request.getParameter("callback");
|
if(callbackFunName == null || callbackFunName.isEmpty()){
|
callbackFunName = "callback";
|
}
|
String url = sysConfig.getApiServer() + "/api/org/user/findUserByWord/" + keyWord;
|
String username = null;
|
try {
|
username = HttpOperateUtils.httpGet(url);
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
StringBuilder Json = new StringBuilder();
|
Json.append(username);
|
//System.out.print("test:==============" + Json.toString());
|
//return Json.toString();
|
return callbackFunName + "(" + Json.toString() + ")";
|
}
|
|
/**
|
* 资源查看页面新版
|
*/
|
@RequestMapping("ZiYuan/ZiYuanBaseInfo")
|
public String ziYuanBaseInfo(Integer resourceid, Model model, HttpServletRequest request) {
|
Long userId = getUserId(); //获取用户ID
|
OrgUnit orgUnit = getUnit();//获取用户单位信息
|
model.addAttribute("backstageWebRoot", sysConfig.getApiServer() + "/"); // 后台服务路径
|
model.addAttribute("pubzyWebRoot", sysConfig.getPubzyWebRoot()); // 公共资源库路径
|
model.addAttribute("systemName", sysConfig.getAppFullName());
|
model.addAttribute("gisPortal", sysConfig.getGisPortal());
|
model.addAttribute("userId", String.valueOf(userId));
|
Res_MainInfo res_mainInfo = new Res_MainInfo();
|
String integratetype = "";
|
String integrateurl = "";
|
// 修改
|
res_mainInfo = resMainInfoService.selectByPrimaryKey(resourceid);
|
if (res_mainInfo != null) {
|
//判断显示是否未提交、未审核、审核未通过
|
if (res_mainInfo.getAuditstatus() == 0) {
|
String html = "";
|
html += "<span style='font-size: 14px;'>【<font style='color:white;' '>未提交</font>】</span>";
|
model.addAttribute("shenhe", html);
|
} else if (res_mainInfo.getAuditstatus() == 1) {
|
String html = "";
|
html += "<span style='font-size: 14px;'>【<font style='color:white;' '>未审核</font>】</span>";
|
model.addAttribute("shenhe", html);
|
} else if (res_mainInfo.getAuditstatus() == 3) {
|
String html = "";
|
html += "<span style='font-size: 14px;'>【<font style='color:white;' '>审核未通过</font>】</span>";
|
model.addAttribute("shenhe", html);
|
}
|
|
// 收藏,用来判断登录的用户是否有收藏这个资源
|
Res_ActionRecord resActionRecord = new Res_ActionRecord();
|
resActionRecord.setUserid(userId);
|
resActionRecord.setResourceid(resourceid);
|
resActionRecord.setActiontype("收藏");
|
Res_ActionRecord res_actionRecord = resActionRecordService.getUserActionRecord(resActionRecord);
|
if (res_actionRecord != null) {
|
model.addAttribute("actionid", res_actionRecord.getActionid());//已收藏
|
} else {
|
model.addAttribute("actionid", 0);//未收藏
|
}
|
|
// 统计该资源的收藏次数
|
Res_ActionRecord resActionRecord1 = new Res_ActionRecord();
|
resActionRecord1.setActiontype("收藏");
|
resActionRecord1.setResourceid(resourceid);
|
int countResult = resActionRecordService.selectResourceCount(resActionRecord1);
|
model.addAttribute("shoucangcount", countResult);
|
|
// 统计该资源的浏览次数
|
Res_ActionRecord resActionRecord2 = new Res_ActionRecord();
|
resActionRecord2.setActiontype("浏览");
|
resActionRecord2.setResourceid(resourceid);
|
int countResult1 = resActionRecordService.selectResourceCount(resActionRecord2);
|
model.addAttribute("liulancount", countResult1);
|
|
// 统计该资源的调用次数
|
Res_ActionRecord resActionRecord3 = new Res_ActionRecord();
|
resActionRecord3.setActiontype("调用");
|
resActionRecord3.setResourceid(resourceid);
|
int countResult2 = resActionRecordService.selectResourceCount(resActionRecord3);
|
model.addAttribute("diaoyongcount", countResult2);
|
|
// 统计该资源的申请次数
|
Res_ApplyRecommend resApplyRecommend = new Res_ApplyRecommend();
|
resApplyRecommend.setResourceid(resourceid);
|
//alter: Xxx 资源申请数量统计完善 20181227
|
int shenqingcount = resApplyRecommendService.getApplyCount(resourceid);
|
model.addAttribute("shenqingcount", shenqingcount);
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat sdfmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
String Pubdate = sdf.format(res_mainInfo.getPubdate());
|
// 判断所属目录
|
strMuLu = "";
|
res_mainInfo.setCatlogcode(GetBianMu(res_mainInfo.getCatlogid()));
|
// 判断发布单位
|
String unitname = orgUnitService.getUnitById((long) res_mainInfo.getPubunitid()).getUnitname();
|
model.addAttribute("unitname", unitname);
|
// res_mainInfo.setPubunitid(unitid);
|
// 判断数据覆盖范围
|
String administrativeid = res_mainInfo.getAdministrativeid();
|
if (administrativeid != null && !administrativeid.isEmpty() && administrativeid != " ") {
|
String getRegionInfourl = sysConfig.getApiServer() + "/api/org/region/getById/" + administrativeid;
|
String jsonStr = "";
|
try {
|
jsonStr = HttpOperateUtils.httpGet(getRegionInfourl.trim());
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
if (jsonStr != null && !jsonStr.isEmpty()) {
|
JSONObject item = JSONObject.parseObject(jsonStr);
|
String regionname = item.getString("regionname");
|
res_mainInfo.setAdministrativeid(regionname);
|
}
|
}
|
|
//申请按钮控制
|
Integer isApply = -1;//-1 发布人、完全公开、已有记录且审核过且未超过有效截止时间,不显示申请按钮 1 已申请未批复
|
//如果当前用户是管理员则不显示申请按钮
|
if(!SecurityUtils.getSubject().isPermitted("org_user_admin")) {
|
if (!res_mainInfo.getCreateuserid().equals(userId) && !res_mainInfo.getSharprotocol().equals("完全公开") && !(res_mainInfo.getSharprotocol().equals("单位内公开") && res_mainInfo.getPubunitid() == orgUnit.getUnitid().intValue())) {
|
// 获取是否有在申请表有申请RES_APPLYRECOMMEND
|
Map<String, Object> map = new HashMap<>();
|
map.put("resourceid", resourceid);
|
map.put("userid", userId);
|
map.put("unitid", orgUnit.getUnitid());
|
Res_ApplyRecommend recommend = resApplyRecommendService.checkZiYuanShenQing(map);
|
if (recommend != null) {
|
if (recommend.getAuditresult().equals(0)) {//已申请未批复
|
isApply = 1;
|
} else {//申请批复后时间没有过
|
Long timenum = new Date().getTime();
|
if (recommend.getEffendtime() != null && timenum < recommend.getEffendtime().getTime()) {
|
isApply = -1;
|
} else {
|
isApply = 0;
|
}
|
}
|
} else {
|
isApply = 0;
|
}
|
}
|
}
|
|
//订阅按钮控制
|
Integer isDingYue = -1;
|
if (res_mainInfo.getResourceclass().equals("SJKB")) {
|
isDingYue = 0; //2018.08.01 自己也可以订阅自己发布的资源,亦可多次订阅同一个资源
|
// Res_Subscriptions sub = new Res_Subscriptions();
|
// sub.setAppuserid(getUserId().toString());
|
// sub.setResourceid(resourceid);
|
// Res_Subscriptions subscriptions = resSubscriptionsService.selectSubscriptionsByUser(sub);
|
// if(subscriptions != null){
|
// isDingYue = 1;
|
// }
|
}
|
model.addAttribute("dingyue", isDingYue);
|
|
// 判断资源类型
|
String leixin = res_mainInfo.getResourceclass();
|
if (leixin == null) leixin = "";
|
// 判断该类型对应那张表,然后查询对应的表的字段
|
switch (leixin) {
|
case "SJWJ":// 数据文件(有用误删)
|
Res_ExtFileSource resExtFileSource = resExtFileSourceService.selectByPrimaryKey(resourceid);
|
if (resExtFileSource != null) {
|
LinkedHashMap<String, String> filetypelist = FieldUtils.getFieldListByKey("FileType");
|
resExtFileSource.setFiletype(filetypelist.get(resExtFileSource.getFiletype()));
|
//判断是否有权限
|
Map<String, Object> map = new HashMap<>();
|
map.put("resourceid", resourceid);
|
map.put("userid", userId);
|
OrgUser user = getUser();
|
map.put("unitid", orgUserService.getDefaultUnit(user.getUserid()).getUnitid());
|
int count = resMainInfoService.checkZiYuanQuanXian(map);
|
//有权限查看
|
if (count > 0) {
|
SelectFileUrl(resourceid, model, request, resExtFileSource);
|
model.addAttribute("XianShiWenJian", 1);//1代表可以显示
|
} else {
|
model.addAttribute("XianShiWenJian", 0);//0代表不可以显示
|
}
|
|
model.addAttribute("resExtFileSource", resExtFileSource);
|
} else {
|
Res_ExtFileSource resExtFileSource1 = new Res_ExtFileSource();
|
model.addAttribute("resExtFileSource", resExtFileSource1);
|
}
|
break;
|
case "SJKB":// 数据库表(有用误删)
|
|
//查询该笔资源的订阅次数,订阅的相关信息
|
Map<String, Object> smap = new HashMap<String, Object>();
|
smap.put("resourceid", resourceid);
|
if (!SecurityUtils.getSubject().isPermitted("org_user_admin") && userId != res_mainInfo.getCreateuserid()) {
|
smap.put("appuserid", getUserId());
|
}
|
List<Res_Subscriptions> subscriptionsList = resSubscriptionsService.selectByResourceIdList(smap);
|
model.addAttribute("dingyuecount", subscriptionsList.size());
|
boolean isDingYueList = false;
|
if (subscriptionsList.size() > 0) {
|
List<DingYue> dingYues = new ArrayList<DingYue>();
|
for (int i = 0; i < subscriptionsList.size(); i++) {
|
DingYue dingYue = new DingYue();
|
OrgUser user = orgUserService.queryObject(Long.parseLong(subscriptionsList.get(i).getAppuserid()));
|
OrgUnit unit = orgUserService.getDefaultUnit(Long.parseLong(subscriptionsList.get(i).getAppuserid()));
|
dingYue.setUsername(user.getChinesename());
|
dingYue.setUnit(unit.getUnitname());
|
Res_ExtDataSource dataSource = resExtDataSourceService.selectByPrimaryKey(subscriptionsList.get(i).getDatasourceid());
|
if (dataSource != null) {
|
dingYue.setDatabasetype(dataSource.getDatabasetype());
|
}
|
dingYue.setSyncmessage(subscriptionsList.get(i).getSyncmessage());
|
dingYue.setHangup(subscriptionsList.get(i).getHangup());
|
dingYue.setTablename(subscriptionsList.get(i).getTablename());
|
dingYue.setLastupdate(sdfmt.format(subscriptionsList.get(i).getLastupdate()));
|
dingYue.setAppdate(sdfmt.format(subscriptionsList.get(i).getAppdate()));
|
dingYue.setId(subscriptionsList.get(i).getAppid());
|
dingYue.setSyncresult(subscriptionsList.get(i).getSyncresult());
|
dingYue.setAuditresult(subscriptionsList.get(i).getAuditresult());
|
if (userId == res_mainInfo.getCreateuserid() && !SecurityUtils.getSubject().isPermitted("org_user_admin")) {
|
dingYue.setFlag("1");
|
} else {
|
dingYue.setFlag("0");
|
}
|
dingYues.add(dingYue);
|
}
|
isDingYueList = true;
|
model.addAttribute("dingYues", dingYues);
|
}
|
model.addAttribute("isDingYueList", isDingYueList);
|
|
Res_ExtDataBase res_extDataBase = resExtDataBaseService.selectByMainInfoId(resourceid);
|
if (res_extDataBase != null) {
|
Res_ExtDataSource resExtDataSource = resExtDataSourceService.selectByPrimaryKey(res_extDataBase.getDatasourceid());
|
//开始拼接sql,然后判断是哪个数据库
|
String leirong = null;
|
JSONArray leirongjson = null;
|
JSONArray leirongjsonTwo = null;
|
if(resExtDataSource != null) { //缺少null值处理 alert 2018/12/27
|
if (resExtDataSource.getDatabasetype().equalsIgnoreCase("SQLServer")) {
|
String sql = "SELECT convert(varchar(100),col.name) AS name , " + "convert(varchar(100),ISNULL(ep.[value], '') ) AS ColumnDescription ," + "t.name AS DataType,col.length AS ColLength, " + "convert(varchar(100),ISNULL(COLUMNPROPERTY(col.id, col.name, 'Scale'), 0) ) AS XiaoShuNum," + "CASE WHEN col.isnullable = 1 THEN '否' ELSE '是' END AS Required " + "FROM dbo.syscolumns col LEFT JOIN dbo.systypes t " + "ON col.xtype = t.xusertype inner JOIN dbo.sysobjects obj " + "ON col.id = obj.id AND obj.xtype = 'U' AND obj.status >= 0 LEFT JOIN dbo.syscomments comm " + "ON col.cdefault = comm.id LEFT JOIN sys.extended_properties ep " + "ON col.id = ep.major_id " + "AND col.colid = ep.minor_id " + "AND ep.name = 'MS_Description' LEFT JOIN sys.extended_properties epTwo " + "ON obj.id = epTwo.major_id AND epTwo.minor_id = 0 AND epTwo.name = 'MS_Description' " + "WHERE obj.name = '" + res_extDataBase.getTablename() + "' ORDER BY col.name";
|
leirong = JDBCUtils.SqlServerConnUtils(resExtDataSource.getServeraddress(), resExtDataSource.getDatabasename(), resExtDataSource.getUsername(), resExtDataSource.getPassword(), sql);
|
leirongjson = JSONArray.parseArray(leirong);
|
//获取我设置的别名
|
DataBaseLeftDataSource database = resExtDataBaseService.selectBaseLeftSource(resourceid);
|
JSONObject sqlObj = JSON.parseObject(database.getFieldconfig());
|
//sqlObj 为 null 报错,缺少空值处理。ccr add
|
if (sqlObj != null) {
|
if (leirongjson.getJSONObject(0).get("success").toString().equals("true")) {
|
JSONArray jsarr = JSONArray.parseArray(sqlObj.getString("sql"));
|
leirongjsonTwo = new JSONArray();
|
JSONArray obj = JSONArray.parseArray(leirongjson.getJSONObject(0).get("data").toString());
|
int k = 0;
|
// for (int j = 0; j < obj.size(); j++) {
|
// BiaoJieGou biaoJieGou = JSONUtil.toBean(obj.get(j).toString(), BiaoJieGou.class);
|
// biaoJieGou.setColumnDescription("");
|
// for (int i = 0; i < jsarr.size(); i++) {
|
// ZiDuanPeiZi ziDuanPeiZi = JSONUtil.toBean(jsarr.get(i).toString(), ZiDuanPeiZi.class);
|
// if (ziDuanPeiZi.getZiDuanName().equals(biaoJieGou.getName())) {
|
// biaoJieGou.setColumnDescription(ziDuanPeiZi.getZiDuanBieMing());
|
// }
|
// }
|
// JSONObject Json = (JSONObject) JSONObject.toJSON(biaoJieGou);
|
// if (!biaoJieGou.getColumnDescription().equals("")) {
|
// leirongjsonTwo.set(k, Json);
|
// k++;
|
// }
|
// }
|
//update dsh 2018/12/28
|
for (int i = 0; i < jsarr.size(); i++) {
|
for (int j = 0; j < obj.size(); j++) {
|
BiaoJieGou biaoJieGou = JSONUtil.toBean(obj.get(j).toString(), BiaoJieGou.class);
|
ZiDuanPeiZi ziDuanPeiZi = JSONUtil.toBean(jsarr.get(i).toString(), ZiDuanPeiZi.class);
|
if (ziDuanPeiZi.getZiDuanName().equals(biaoJieGou.getName())) {
|
biaoJieGou.setColumnDescription(ziDuanPeiZi.getZiDuanBieMing());
|
JSONObject Json = (JSONObject) JSONObject.toJSON(biaoJieGou);
|
leirongjsonTwo.set(k, Json);
|
k++;
|
}
|
}
|
}
|
}
|
}
|
}
|
if (resExtDataSource.getDatabasetype().equalsIgnoreCase("Oracle")) {
|
String sql = "select" + " A.column_name as \"name\"," + " B.comments \"ColumnDescription\"," + " A.data_type \"DataType\"," + " A.data_length \"ColLength\"," + " nvl(A.Data_Scale,0) \"XiaoShuNum\"," + " CASE WHEN A.nullable = 'Y' THEN '否' ELSE '是' END AS \"Required\" " + " from" + " user_tab_columns A,user_col_comments B" + " where" + " A.Table_Name = B.Table_Name" + " and A.Column_Name = B.Column_Name" + " and A.Table_Name = '" + res_extDataBase.getTablename() + "'";
|
leirong = JDBCUtils.OracleConnUtils(resExtDataSource.getServeraddress(), resExtDataSource.getDatabasename(), resExtDataSource.getUsername(), resExtDataSource.getPassword(), resExtDataSource.getPort(), sql);
|
leirongjson = JSONArray.parseArray(leirong);
|
//获取我设置的别名
|
DataBaseLeftDataSource database = resExtDataBaseService.selectBaseLeftSource(resourceid);
|
JSONObject sqlObj = JSON.parseObject(database.getFieldconfig());
|
//sqlObj 为 null 报错,缺少空值处理。ccr add
|
if (sqlObj != null) {
|
if (leirongjson.getJSONObject(0).get("success").toString().equals("true")) {
|
JSONArray jsarr = JSONArray.parseArray(sqlObj.getString("sql"));
|
leirongjsonTwo = new JSONArray();
|
JSONArray obj = JSONArray.parseArray(leirongjson.getJSONObject(0).get("data").toString());
|
int k = 0;
|
// for (int j = 0; j < obj.size(); j++) {
|
// BiaoJieGou biaoJieGou = JSONUtil.toBean(obj.get(j).toString(), BiaoJieGou.class);
|
// biaoJieGou.setColumnDescription("");
|
// for (int i = 0; i < jsarr.size(); i++) {
|
// ZiDuanPeiZi ziDuanPeiZi = JSONUtil.toBean(jsarr.get(i).toString(), ZiDuanPeiZi.class);
|
// if (ziDuanPeiZi.getZiDuanName().equals(biaoJieGou.getName())) {
|
// biaoJieGou.setColumnDescription(ziDuanPeiZi.getZiDuanBieMing());
|
// }
|
// }
|
// JSONObject Json = (JSONObject) JSONObject.toJSON(biaoJieGou);
|
// if (!biaoJieGou.getColumnDescription().equals("")) {
|
// leirongjsonTwo.set(k, Json);
|
// k++;
|
// }
|
// }
|
//update dsh 2018/12/28
|
for (int i = 0; i < jsarr.size(); i++) {
|
for (int j = 0; j < obj.size(); j++) {
|
BiaoJieGou biaoJieGou = JSONUtil.toBean(obj.get(j).toString(), BiaoJieGou.class);
|
ZiDuanPeiZi ziDuanPeiZi = JSONUtil.toBean(jsarr.get(i).toString(), ZiDuanPeiZi.class);
|
if (ziDuanPeiZi.getZiDuanName().equals(biaoJieGou.getName())) {
|
biaoJieGou.setColumnDescription(ziDuanPeiZi.getZiDuanBieMing());
|
JSONObject Json = (JSONObject) JSONObject.toJSON(biaoJieGou);
|
leirongjsonTwo.set(k, Json);
|
k++;
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
model.addAttribute("leirongjson", leirongjsonTwo);
|
model.addAttribute("resExtDataBase", res_extDataBase);
|
model.addAttribute("resExtDataSource", resExtDataSource);
|
} else {
|
res_extDataBase = new Res_ExtDataBase();
|
JSONArray leirongjsonTwo = null;
|
Res_ExtDataSource res_extDataSource = new Res_ExtDataSource();
|
model.addAttribute("leirongjson", leirongjsonTwo);
|
model.addAttribute("resExtDataBase", res_extDataBase);
|
model.addAttribute("resExtDataSource", res_extDataSource);
|
}
|
break;
|
case "JKFW":// 接口服务(有用误删)
|
Res_ExtInterFaceService res_extInterFaceService = resExtInterFaceService.selectByPrimaryKey(resourceid);
|
model.addAttribute("show", 0);
|
//接口说明是否显示 1为显示
|
model.addAttribute("ShuoMing", 0);
|
if (res_extInterFaceService != null) {
|
if (res_extInterFaceService.getServertype().equals("WebService")) {
|
//判断是否有权限
|
Map<String, Object> map = new HashMap<>();
|
map.put("resourceid", resourceid);
|
map.put("userid", userId);
|
OrgUser user = getUser();
|
map.put("unitid", orgUserService.getDefaultUnit(user.getUserid()).getUnitid());
|
int count = resMainInfoService.checkZiYuanQuanXian(map);
|
//>0就是有权限
|
if (count > 0) {
|
res_extInterFaceService.setHelpurl(StringEscapeUtils.unescapeHtml(res_extInterFaceService.getHelpurl()));
|
model.addAttribute("helpurl", res_extInterFaceService.getHelpurl());
|
model.addAttribute("resExtInterFaceService", res_extInterFaceService);
|
model.addAttribute("show", 1);
|
model.addAttribute("ShuoMing", 0);
|
|
//查询相关的附件
|
List<Res_Files> res_filesList = resFileService.selectDataListForResourceid(resourceid);
|
model.addAttribute("resFileList", res_filesList);
|
} else {
|
res_extInterFaceService.setHelpurl(StringEscapeUtils.unescapeHtml(res_extInterFaceService.getHelpurl()));
|
model.addAttribute("helpurl", res_extInterFaceService.getHelpurl());
|
model.addAttribute("resExtInterFaceService", res_extInterFaceService);
|
model.addAttribute("show", 0);
|
model.addAttribute("ShuoMing", 0);
|
}
|
} else {
|
res_extInterFaceService.setHelpurl(StringEscapeUtils.unescapeHtml(res_extInterFaceService.getHelpurl()));
|
model.addAttribute("helpurl", res_extInterFaceService.getHelpurl());
|
model.addAttribute("show", 0);
|
model.addAttribute("ShuoMing", 1);
|
model.addAttribute("resExtInterFaceService", res_extInterFaceService);
|
}
|
} else {
|
res_extInterFaceService = new Res_ExtInterFaceService();
|
model.addAttribute("show", 0);
|
model.addAttribute("resExtInterFaceService", res_extInterFaceService);
|
}
|
break;
|
case "YWJC":
|
Res_ExtIntegrate resExtIntegrate = resExtIntegrateService.selectByPrimaryKey(resourceid);
|
integratetype = resExtIntegrate.getIntegratetype() != null ? resExtIntegrate.getIntegratetype() : "";
|
//判断是否有权限
|
Map<String, Object> map = new HashMap<>();
|
map.put("resourceid", resourceid);
|
map.put("userid", getUserId());
|
map.put("unitid", orgUnit.getUnitid());
|
if (resMainInfoService.checkZiYuanQuanXian(map) > 0) {
|
integrateurl = resExtIntegrate.getServerurl() != null ? resExtIntegrate.getServerurl() : "";
|
}
|
break;
|
case "KJ_KJFX": //空间分析
|
Res_ExtSpaceServer res_extSpaceServer = resExtSpaceServerService.selectByPrimaryKey(resourceid);
|
//判断是否有权限
|
if (res_extSpaceServer != null) {
|
if (checkZiYuanQuanXian(resourceid) > 0) {
|
model.addAttribute("helpurl", res_extSpaceServer.getHelpurl());
|
model.addAttribute("show", 1);
|
|
//查询相关的附件
|
List<Res_Files> res_filesList = resFileService.selectDataListForResourceid(resourceid);
|
model.addAttribute("resFileList", res_filesList);
|
} else {
|
model.addAttribute("helpurl", res_extSpaceServer.getHelpurl());
|
model.addAttribute("show", 1);
|
}
|
}
|
break;
|
}
|
model.addAttribute("Pubdate", Pubdate);
|
model.addAttribute("resourceType", leixin);
|
model.addAttribute("apply", isApply);
|
}
|
//换地址
|
if (res_mainInfo != null && res_mainInfo.getDesurl() != null && res_mainInfo.getDesurl().indexOf("diydes") != -1 && res_mainInfo.getDesurl().indexOf(res_mainInfo.getResourceid().toString()) != -1) {
|
String url = sysConfig.getUploadRootPath() + res_mainInfo.getDesurl();
|
res_mainInfo.setDesurl(url);
|
}
|
model.addAttribute("mainInfo", res_mainInfo);
|
model.addAttribute("resMainInfoId", resourceid);
|
model.addAttribute("isMyZy", res_mainInfo.getCreateuserid() != getUserId() ? false : true);//判断是否是自己申请的资源(申请按钮)
|
//编辑按钮
|
boolean isEdit = false;
|
if (res_mainInfo.getCreateuserid() == getUserId() || SecurityUtils.getSubject().isPermitted("org_user_admin")) {
|
isEdit = true;
|
}
|
model.addAttribute("isEdit", isEdit);
|
model.addAttribute("integratetype", integratetype);
|
model.addAttribute("integrateurl", integrateurl);
|
model.addAttribute("firstMapUrl", getZTDTByPortalMapUrl(res_mainInfo.getResourceid(), res_mainInfo.getResourceclass()));
|
String imgurl = "";
|
String defClassImg = "/image/classimg/" + res_mainInfo.getResourceclass() + ".gif";
|
if (res_mainInfo.getImgurl() != null && !res_mainInfo.getImgurl().isEmpty()) {
|
if(res_mainInfo.getImgurl().startsWith("Atkas")){//图集
|
imgurl = "/image/" + res_mainInfo.getImgurl();
|
File file = new File(System.getProperty("user.dir")+ "\\src\\main\\resources\\static" + ("/image/"+res_mainInfo.getImgurl()).replace("/","\\"));
|
if (!file.exists()) { //判断物理路径是否存在,不存在则默认
|
imgurl = defClassImg;
|
}
|
}else{
|
imgurl = "/uploadPath/" + res_mainInfo.getImgurl();
|
File file = new File(sysConfig.getUploadPath() + res_mainInfo.getImgurl());
|
if (!file.exists()) { //判断物理路径是否存在,不存在则默认
|
imgurl = defClassImg;
|
}
|
}
|
} else {
|
imgurl = defClassImg;
|
}
|
model.addAttribute("imgurl", imgurl);
|
|
if (checkZiYuanQuanXian(resourceid) > 0 || SecurityUtils.getSubject().isPermitted("org_user_admin")) {
|
model.addAttribute("resourceChaKan", 1);
|
} else {
|
model.addAttribute("resourceChaKan", 0);
|
}
|
|
boolean del = false;
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
//自定义风格列表
|
List<Res_DiyLayerInfo> res_diyLayerInfos = resDiyLayerInfoService.selectByResourceid(resourceid);
|
for (int i = 0; i < res_diyLayerInfos.size(); i++) {
|
res_diyLayerInfos.get(i).setDiydate(sdf.format(res_diyLayerInfos.get(i).getDiytime()));
|
if (res_diyLayerInfos.get(i).getDiyuserid() == 0) { //定义风格用户ID为0时,管理员和发布该资源的用户可以删除该风格
|
if (SecurityUtils.getSubject().isPermitted("org_user_admin") || getUserId() == res_mainInfo.getCreateuserid()) {
|
del = true;
|
}
|
}
|
if (getUserId() == res_diyLayerInfos.get(i).getDiyuserid().longValue()) { //当前登录用户是定义人则可以删除自己定义的风格
|
del = true;
|
}
|
res_diyLayerInfos.get(i).setDel(del);
|
}
|
model.addAttribute("diyLayerInfos", res_diyLayerInfos);
|
return "ResManage/ResRegister/ZiYuanBaseInfo";
|
}
|
|
/**
|
* 删除自定义风格
|
*/
|
@RequestMapping("diylayer/deleteDiyLayerInfo")
|
@ResponseBody
|
public String deleteDiyLayerInfo(Integer diyid) {
|
resDiyLayerInfoService.deleteDiyLayerInfo(diyid);
|
return "1";
|
}
|
|
private void SelectFileUrl(Integer resourceid, Model model, HttpServletRequest request, Res_ExtFileSource resExtFileSource) {
|
if (resExtFileSource.getSourcetype() != null && resExtFileSource.getSourcetype().equals("文件夹")) {
|
if (resExtFileSource.getServerurl() != null && resExtFileSource.getStoragemode().equals("本地")) {
|
File file = new File(sysConfig.getUploadPath() + resExtFileSource.getServerurl());
|
String ip = "/uploadPath/";
|
String webUrl = ip + resExtFileSource.getServerurl();
|
String httpurl = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + webUrl;
|
List<Res_FileSource_Way> res_fileSource_way = null;
|
if (file.isDirectory()) {
|
System.out.println(resExtFileSource.getServerurl());
|
String[] fileLists = file.list();
|
File[] files = file.listFiles();
|
List<FileSourceList> fileSourceLists = new ArrayList<>();
|
List list = new ArrayList();
|
for (int i = 0; i < fileLists.length; i++) {
|
File file1 = new File(fileLists[i]);
|
File file2 = new File(files[i].getAbsolutePath());
|
String size = FileUtils.byteCountToDisplaySize(file2.length());
|
String path2 = wenjianjiaPath() + file1.getName(); // 文件映射路径
|
FileSourceList sourceList = new FileSourceList();
|
sourceList.setName(file1.getName());
|
sourceList.setPath(webUrl + "/" + file1.getName());
|
sourceList.setSize(size);
|
//查看 展现方式
|
res_fileSource_way = resFileSourceWayService.selectById(resourceid);
|
List<Res_FileSource_Way> ways = new ArrayList<Res_FileSource_Way>();
|
for (int j = 0; j < res_fileSource_way.size(); j++) {
|
Res_FileSource_Way way = res_fileSource_way.get(j);
|
if (!(StringUtils.isEmpty(way.getUrl()) || StringUtils.equals(way.getUrl(), "--"))) {
|
ways.add(0, way);
|
}
|
}
|
sourceList.setList(ways);
|
fileSourceLists.add(sourceList);
|
}
|
if (res_fileSource_way != null) {
|
for (int j = 0; j < res_fileSource_way.size(); j++) {
|
if (!res_fileSource_way.get(j).getUrl().equals("") && !res_fileSource_way.get(j).getRemark().equals("")) {
|
Res_FileSource_Way way = res_fileSource_way.get(j);
|
String PathUrl = way.getRemark();
|
if (!StringUtils.isEmpty(PathUrl)) {
|
PathUrl += URLEncoder.encode(httpurl);
|
way.setRemark(PathUrl);
|
}
|
|
list.add(way);
|
}
|
}
|
}
|
model.addAttribute("res_fileSource_way", list);
|
System.out.println(fileSourceLists);
|
System.out.println(request.getServerName());
|
//model.addAttribute("webUrl",request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+webUrl);
|
model.addAttribute("webUrl", httpurl);
|
model.addAttribute("filelist", fileSourceLists);
|
//model.addAttribute("zhanxian",zhanxian);
|
}
|
}
|
}
|
if (resExtFileSource.getSourcetype() != null && resExtFileSource.getSourcetype().equals("文件")) {
|
if (resExtFileSource.getServerurl() != null && resExtFileSource.getStoragemode().equals("本地")) {
|
File file = new File(sysConfig.getUploadPath() + resExtFileSource.getServerurl());
|
String ip = "/uploadPath/";
|
String webUrl = ip + resExtFileSource.getServerurl();
|
FileSourceList sourceList = new FileSourceList();
|
List<FileSourceList> fileSourceLists = new ArrayList<>();
|
sourceList.setName(file.getName());
|
sourceList.setPath(webUrl);
|
sourceList.setSize(FileUtils.byteCountToDisplaySize(file.length()));
|
List<Res_FileSource_Way> res_fileSource_way = resFileSourceWayService.selectById(resourceid);
|
sourceList.setList(res_fileSource_way);
|
fileSourceLists.add(sourceList);
|
model.addAttribute("webUrlWenJian", request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + webUrl);
|
model.addAttribute("filelist", fileSourceLists);
|
}
|
}
|
}
|
|
private LinkedHashMap<String, String> queryUserOrUnitList(String gettype) {
|
String url = sysConfig.getApiServer() + (gettype == "unit" ? "/api/org/unit/queryAllList" : "/api/org/user/queryAllList");
|
LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
|
try {
|
String jsonStr = HttpOperateUtils.httpGet(url.trim());
|
if (jsonStr.length() != 0) {
|
JSONArray list = JSON.parseArray(jsonStr);
|
for (int i = 0; i < list.size(); i++) {
|
Map maps = (Map) JSON.parse(list.get(i).toString());
|
map.put(maps.get("id").toString(), maps.get("name").toString());
|
}
|
}
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
return map;
|
}
|
|
@RequestMapping("ZiYuan/BaseInfoExtBaseMap")//基础底图
|
public String BaseInfoExtBaseMap(Integer resourceid, Model model, HttpServletRequest request) {
|
GetMainInfo(resourceid, model, request);
|
return "ResManage/ResRegister/BaseInfoExtBaseMap";
|
}
|
|
@RequestMapping("ZiYuan/BaseInfoExtBusinessLayer")
|
public String BaseInfoExtBusinessLayer(Integer resourceid, Model model, HttpServletRequest request) {
|
GetMainInfo(resourceid, model, request);
|
return "ResManage/ResRegister/BaseInfoExtBusinessLayer";
|
}
|
|
@RequestMapping("ZiYuan/BaseInfoExtSpaceServer")
|
public String BaseInfoExtSpaceServer(Integer resourceid, Model model, HttpServletRequest request) {
|
if (checkZiYuanQuanXian(resourceid) > 0) {
|
model.addAttribute("isReadUrl", 1);
|
} else {
|
model.addAttribute("isReadUrl", 0);
|
}
|
Res_ExtSpaceServer res_extSpaceServer = resExtSpaceServerService.selectByPrimaryKey(resourceid);
|
if (res_extSpaceServer != null) {
|
model.addAttribute("ResExtSpaceServer", res_extSpaceServer);
|
String UrlAndToken = getUrlAndToken(resourceid, res_extSpaceServer.getServerurl(), request);
|
model.addAttribute("urlAndToken", UrlAndToken);
|
} else {
|
res_extSpaceServer = new Res_ExtSpaceServer();
|
model.addAttribute("ResExtSpaceServer", res_extSpaceServer);
|
}
|
GetMainInfo(resourceid, model, request);
|
return "ResManage/ResRegister/BaseInfoExtSpaceServer";
|
}
|
|
@RequestMapping("ZiYuan/BaseInfoExtThemeMap")
|
public String BaseInfoExtThemeMap(Integer resourceid, Model model, HttpServletRequest request) {
|
GetMainInfo(resourceid, model, request);
|
return "ResManage/ResRegister/BaseInfoExtThemeMap";
|
}
|
|
@RequestMapping("ZiYuan/BaseInfoExtIntegrate")
|
public String BaseInfoExtIntegrate(Integer resourceid, Model model, HttpServletRequest request) {
|
if (checkZiYuanQuanXian(resourceid) > 0) {
|
model.addAttribute("isReadUrl", 1);
|
} else {
|
model.addAttribute("isReadUrl", 0);
|
}
|
Res_ExtIntegrate res_extIntegrate = resExtIntegrateService.selectByPrimaryKey(resourceid);
|
if (res_extIntegrate != null) {
|
model.addAttribute("res_extIntegrate", res_extIntegrate);
|
String UrlAndToken = getUrlAndToken(resourceid, res_extIntegrate.getServerurl(), request);
|
model.addAttribute("urlAndToken", UrlAndToken);
|
} else {
|
res_extIntegrate = new Res_ExtIntegrate();
|
model.addAttribute("res_extIntegrate", res_extIntegrate);
|
}
|
GetMainInfo(resourceid, model, request);
|
|
return "ResManage/ResRegister/BaseInfoExtIntegrate";
|
}
|
|
@RequestMapping("ZiYuan/BaseInfoExtFileSource")
|
public String BaseInfoExtFileSource(Integer resourceid, Model model, HttpServletRequest request) {
|
Res_ExtFileSource res_extFileSource = resExtFileSourceService.selectByPrimaryKey(resourceid);
|
if (res_extFileSource != null) {
|
|
model.addAttribute("resExtFileSource", res_extFileSource);
|
} else {
|
res_extFileSource = new Res_ExtFileSource();
|
model.addAttribute("resExtFileSource", res_extFileSource);
|
}
|
GetMainInfo(resourceid, model, request);
|
return "ResManage/ResRegister/BaseInfoExtFileSource";
|
}
|
|
@RequestMapping("ZiYuan/BaseInfoExtDataBase")
|
public String BaseInfoExtDataBase(Integer resourceid, Model model, HttpServletRequest request) {
|
GetMainInfo(resourceid, model, request);
|
DataBaseLeftDataSource database = resExtDataBaseService.selectBaseLeftSource(resourceid);
|
String databasetype = "";
|
if (database != null) {
|
databasetype = database.getDatabasetype();
|
}
|
model.addAttribute("databasetype", databasetype);
|
return "ResManage/ResRegister/BaseInfoExtDataBase";
|
}
|
|
@RequestMapping("ZiYuan/BaseInfoEextInterFace")
|
public String BaseInfoEextInterFace(Integer resourceid, Model model, HttpServletRequest request) {
|
GetMainInfo(resourceid, model, request);
|
if (checkZiYuanQuanXian(resourceid) > 0) {
|
model.addAttribute("isReadUrl", 1);
|
} else {
|
model.addAttribute("isReadUrl", 0);
|
}
|
Res_ExtInterFaceService res_extInterFaceService = resExtInterFaceService.selectByPrimaryKey(resourceid);
|
if (res_extInterFaceService != null) {
|
|
model.addAttribute("resExtInterFaceService", res_extInterFaceService);
|
String UrlAndToken = getUrlAndToken(resourceid, res_extInterFaceService.getServerurl(), request);
|
model.addAttribute("urlAndToken", UrlAndToken);
|
} else {
|
res_extInterFaceService = new Res_ExtInterFaceService();
|
model.addAttribute("resExtInterFaceService", res_extInterFaceService);
|
}
|
return "ResManage/ResRegister/BaseInfoEextInterFace";
|
}
|
|
@RequestMapping("ZiYuan/BaseInfoExt3D")
|
public String BaseInfoExt3D(Integer resourceid, Model model, HttpServletRequest request) {
|
if (checkZiYuanQuanXian(resourceid) > 0) {
|
model.addAttribute("isReadUrl", 1);
|
} else {
|
model.addAttribute("isReadUrl", 0);
|
}
|
Res_Ext3D res_ext3D = resExt3DService.selectByPrimaryKey(resourceid);
|
if (res_ext3D != null) {
|
model.addAttribute("resExt3D", res_ext3D);
|
String UrlAndToken = getUrlAndToken(resourceid, res_ext3D.getServerurl(), request);
|
model.addAttribute("urlAndToken", UrlAndToken);
|
} else {
|
res_ext3D = new Res_Ext3D();
|
model.addAttribute("resExt3D", res_ext3D);
|
}
|
GetMainInfo(resourceid, model, request);
|
return "ResManage/ResRegister/BaseInfoExt3D";
|
}
|
|
private Model GetMainInfo(Integer resourceid, Model model, HttpServletRequest request) {
|
String UrlAndToken = "";//复制地址
|
Res_MainInfo res_mainInfo = new Res_MainInfo();
|
OrgUnit orgUnit = getUnit();//获取用户单位信息
|
// 修改
|
res_mainInfo = resMainInfoService.selectByPrimaryKey(resourceid);
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
String Pubdate = sdf.format(res_mainInfo.getPubdate());
|
String Productiontime = res_mainInfo.getProductiontime() != null ? sdf.format(res_mainInfo.getProductiontime()) : "";
|
// 判断所属目录
|
strMuLu = "";
|
res_mainInfo.setCatlogcode(GetBianMu(res_mainInfo.getCatlogid()));
|
// 判断发布单位
|
String unitname = orgUnitService.getUnitById((long) res_mainInfo.getPubunitid()).getUnitname();
|
model.addAttribute("unitname", unitname);
|
// 判断数据覆盖范围
|
String administrativeid = res_mainInfo.getAdministrativeid();
|
if (administrativeid != null && !administrativeid.isEmpty() && administrativeid != " ") {
|
String getRegionInfourl = sysConfig.getApiServer() + "/api/org/region/getById/" + administrativeid;
|
String jsonStr = "";
|
try {
|
jsonStr = HttpOperateUtils.httpGet(getRegionInfourl.trim());
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
if (jsonStr != null && !jsonStr.isEmpty()) {
|
JSONObject item = JSONObject.parseObject(jsonStr);
|
String regionname = item.getString("regionname");
|
res_mainInfo.setAdministrativeid(regionname);
|
}
|
}
|
List list = new ArrayList();
|
if (res_mainInfo.getKeywords() != "") {
|
String keywords = res_mainInfo.getKeywords();
|
if (keywords != null && !keywords.equals("")) {
|
String key[] = keywords.split(",");
|
for (int i = 0; i < key.length; i++) {
|
String s = key[i];
|
list.add(s);
|
}
|
}
|
}
|
model.addAttribute("Pubdate", Pubdate);
|
model.addAttribute("Productiontime", Productiontime);
|
//换地址
|
if (res_mainInfo != null && res_mainInfo.getDesurl() != null && res_mainInfo.getDesurl().indexOf("diydes") != -1 && res_mainInfo.getDesurl().indexOf(res_mainInfo.getResourceid().toString()) != -1) {
|
String url = sysConfig.getUploadRootPath() + res_mainInfo.getDesurl();
|
res_mainInfo.setDesurl(url);
|
}
|
|
model.addAttribute("list", list);
|
model.addAttribute("createusername", res_mainInfo.getCreateuserid() != null ? orgUserService.getChinesename(res_mainInfo.getCreateuserid()) : "");//发布人
|
//资源类型
|
switch (res_mainInfo.getResourceclass()) {
|
case "KJ_JCDT"://基础底图
|
Res_ExtBaseMap resExtBaseMap = resExtBaseMapService.selectByPrimaryKey(resourceid);
|
if (resExtBaseMap == null) {
|
resExtBaseMap = new Res_ExtBaseMap();
|
}
|
model.addAttribute("resExtBaseMap", resExtBaseMap);
|
break;
|
case "KJ_ZTDT":// 专题地图
|
Res_ExtThemeMap resExtThemeMap = resExtThemeMapService.selectByPrimaryKey(resourceid);
|
if (resExtThemeMap == null) {
|
resExtThemeMap = new Res_ExtThemeMap();
|
}
|
model.addAttribute("resExtThemeMap", resExtThemeMap);
|
break;
|
case "KJ_YWTC":// 业务图层
|
Res_ExtBusinessLayer resExtBusinessLayer = resExtBusinessLayerService.selectByPrimaryKey(resourceid);
|
if (resExtBusinessLayer == null) {
|
resExtBusinessLayer = new Res_ExtBusinessLayer();
|
}
|
model.addAttribute("resExtBusinessLayer", resExtBusinessLayer);
|
break;
|
}
|
//服务地址链接
|
List<Res_ExtMapUrl> resExtMapUrls = resExtMapUrlService.selectByCondition(resourceid);
|
String serviceUrl = "";//服务地址
|
Integer isReadUrl = 0;//是否有权限查看服务地址
|
if (resExtMapUrls.size() > 0) {
|
//判断是否有权限
|
Map<String, Object> map = new HashMap<>();
|
Long userId = getUserId(); //获取用户ID
|
map.put("resourceid", resourceid);
|
map.put("userid", userId);
|
OrgUser user = getUser();
|
map.put("unitid", orgUserService.getDefaultUnit(user.getUserid()).getUnitid());
|
int count = resMainInfoService.checkZiYuanQuanXian(map);
|
if (count > 0) {
|
isReadUrl = 1;
|
serviceUrl = (resExtMapUrls != null && resExtMapUrls.size() > 0) ? resExtMapUrls.get(0).getServerurl() : "";//暂时先取第一个地址
|
}
|
UrlAndToken = getUrlAndToken(resourceid, serviceUrl, request);
|
model.addAttribute("urlAndToken", UrlAndToken);
|
model.addAttribute("isReadUrl", isReadUrl);
|
}
|
model.addAttribute("serviceUrl", serviceUrl);
|
model.addAttribute("mainInfo", res_mainInfo);
|
GetProblemStatus(res_mainInfo, model);
|
|
ProblemFeedback(resourceid, model);
|
|
return model;
|
}
|
|
private int checkZiYuanQuanXian(Integer resourceid) {
|
Map<String, Object> map = new HashMap<>();
|
Long userId = getUserId(); //获取用户ID
|
map.put("resourceid", resourceid);
|
map.put("userid", userId);
|
OrgUser user = getUser();
|
map.put("unitid", orgUserService.getDefaultUnit(user.getUserid()).getUnitid());
|
return resMainInfoService.checkZiYuanQuanXian(map);
|
}
|
|
/**
|
* 复制
|
*/
|
@ResponseBody
|
@RequestMapping("/ZiYuan/copyMainInfoAndKZ")
|
public int copyMainInfoAndKZ(int resourceid, String copyname, String copyurl, String type) {
|
int resultId = 0;
|
Timestamp nowtime = new Timestamp(new Date().getTime());// 获取当前时间
|
Res_MainInfo mainInfo = resMainInfoService.selectByPrimaryKey(resourceid);
|
if (mainInfo != null) {
|
mainInfo.setResourceid(null);
|
mainInfo.setAuditstatus(0);
|
mainInfo.setCreatedate(nowtime);
|
mainInfo.setLasteditdate(nowtime);
|
mainInfo.setTitle(copyname);
|
resultId = resMainInfoService.insertSelective(mainInfo);
|
if (resultId == 1) {
|
resultId = resMainInfoService.queryResMainInfoIdentCurrent();
|
int isExitsUrl = 0;
|
switch (type) {
|
case "ExtBaseMap"://基础底图
|
Res_ExtBaseMap baseMapInfo = resExtBaseMapService.selectByPrimaryKey(resourceid);
|
if (baseMapInfo != null) {
|
baseMapInfo.setResourceid(resultId);
|
resExtBaseMapService.insertSelective(baseMapInfo);
|
isExitsUrl = 1;
|
}
|
break;
|
case "ExtSpaceServer"://空间分析不用复制扩展信息
|
break;
|
case "ExtBusinessLayer"://业务图层
|
Res_ExtBusinessLayer businessInfo = resExtBusinessLayerService.selectByPrimaryKey(resourceid);
|
if (businessInfo != null) {
|
businessInfo.setResourceid(resultId);
|
resExtBusinessLayerService.insertSelective(businessInfo);
|
isExitsUrl = 1;
|
}
|
break;
|
case "ExtThemeMap"://专题地图
|
Res_ExtThemeMap themeInfo = resExtThemeMapService.selectByPrimaryKey(resourceid);
|
if (themeInfo != null) {
|
themeInfo.setResourceid(resultId);
|
resExtThemeMapService.insertSelective(themeInfo);
|
isExitsUrl = 1;
|
}
|
break;
|
case "ExtFileSource"://数据文件不用复制扩展信息
|
break;
|
case "ExtIntegrate"://业务集成
|
Res_ExtIntegrate integerInfo = resExtIntegrateService.selectByPrimaryKey(resourceid);
|
if (integerInfo != null) {
|
integerInfo.setResourceid(resultId);
|
integerInfo.setServerurl(copyurl);
|
resExtIntegrateService.insertSelective(integerInfo);
|
}
|
break;
|
case "ExtInterFaceService"://接口服务
|
Res_ExtInterFaceService faceInfo = resExtInterFaceService.selectByPrimaryKey(resourceid);
|
if (faceInfo != null) {
|
faceInfo.setResourceid(resultId);
|
faceInfo.setServerurl(copyurl);
|
resExtInterFaceService.insertSelective(faceInfo);
|
}
|
break;
|
case "Ext3D"://3D模型
|
Res_Ext3D threeDInfo = resExt3DService.selectByPrimaryKey(resourceid);
|
if (threeDInfo != null) {
|
threeDInfo.setResourceid(resultId);
|
threeDInfo.setServerurl(copyurl);
|
resExt3DService.insertSelective(threeDInfo);
|
}
|
break;
|
case "ExtDataBase"://数据库表不用复制扩展信息
|
break;
|
}
|
//复制服务地址
|
if (isExitsUrl == 1) {
|
List<Res_ExtMapUrl> extMapUrlList = resExtMapUrlService.selectByCondition(resourceid);
|
if (extMapUrlList != null && extMapUrlList.size() > 0) {
|
for (int i = 0; i < extMapUrlList.size(); i++) {
|
Res_ExtMapUrl urlmodel = extMapUrlList.get(i);
|
urlmodel.setUrlid(null);
|
urlmodel.setResourceid(resultId);
|
if (i == 0) {//填写的服务地址替换第一个
|
urlmodel.setServerurl(copyurl);
|
}
|
resExtMapUrlService.insertSelective(urlmodel);
|
}
|
}
|
}
|
}
|
}
|
return resultId;
|
}
|
|
//类型为专题地图portal专题类型获取首笔协议服务路径
|
private String getZTDTByPortalMapUrl(Integer resourceid, String resourceclass) {
|
String firstMapUrl = "";
|
if (resourceid != null && resourceclass != null) {
|
if (resourceclass.equals("KJ_ZTDT")) {
|
Res_ExtThemeMap resExtThemeMap = resExtThemeMapService.selectByPrimaryKey(resourceid);
|
if (resExtThemeMap != null && resExtThemeMap.getType() != null && resExtThemeMap.getType().equals("Portal专题")) {
|
List<Res_ExtMapUrl> urlList = resExtMapUrlService.selectByCondition(resourceid);
|
if (urlList != null && urlList.size() > 0 && urlList.get(0).getServerurl() != null)
|
firstMapUrl = urlList.get(0).getServerurl();
|
}
|
}
|
}
|
return firstMapUrl;
|
}
|
|
/**
|
* 自动补全输入首字母查询
|
* @param keyWord
|
* @return
|
*/
|
@ResponseBody
|
@GetMapping("/findPinyinByKeyWord")
|
public String[] findpinyinByKeyWord(@RequestParam(name = "keyWord") String keyWord) {
|
List<String> titles = resMainInfoService.pingyin(URLDecoder.decode(keyWord.toLowerCase()));
|
|
if (org.springframework.util.StringUtils.isEmpty(titles)) {
|
return null;
|
}
|
|
int size = titles.size();
|
|
String[] arr = titles.toArray(new String[size]);
|
|
return arr;
|
}
|
|
/** 文件上传 */
|
/**
|
* @Description:
|
* @author dsh
|
* 文件资源类型
|
* @date 2018/6/28
|
*/
|
@ResponseBody
|
@RequestMapping("/ZiYuan/uploadfile")
|
public String uploadfile(@RequestParam("myFile") MultipartFile[] file, String resourceid) {
|
String res = "";
|
for (int i = 0; i < file.length; i++) {
|
if (file[i].isEmpty()) {
|
return "No File";
|
}
|
// 判断文件夹是否存在(resource/diydes/resourceid/文件)
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
String timePath = sdf.format(new Date().getTime());
|
timePath = timePath.replace("-", "");
|
String thisPath = sysConfig.getUploadPath() + "diydes\\" + timePath + "\\" + resourceid;
|
String paths[] = {""};
|
try {
|
String tempPath = new File(thisPath).getCanonicalPath();
|
paths = tempPath.split("\\\\");
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
//创建文件夹
|
String dir = paths[0];
|
for (int j = 0; j < paths.length - 1; j++) {
|
try {
|
dir = dir + "/" + paths[j + 1];
|
File dirFile = new File(dir);
|
if (!dirFile.exists()) {
|
dirFile.mkdirs();
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
//判断文件是否存在
|
File thisfile = new File(thisPath + "\\" + file[i].getOriginalFilename());
|
File thisdir = new File(thisPath);
|
String webpath = "";
|
if (!thisfile.exists()) {
|
try {
|
//删除已有的文件
|
File[] childrens = thisdir.listFiles();
|
for (int j = 0; j < childrens.length; j++) {
|
File temp = childrens[i];
|
temp.delete();
|
}
|
//文件网络地址
|
webpath = "diydes/" + timePath + "/" + resourceid + "/" + file[i].getOriginalFilename(); // 类型为文件指向文件
|
FileUtils.copyInputStreamToFile(file[i].getInputStream(), thisfile);
|
res = "{'result':'1','name':'" + file[i].getOriginalFilename() + "','Path':'" + sysConfig.getUploadRootPath() + webpath + "'}";
|
} catch (Exception e) {
|
e.printStackTrace();
|
res = "{'result':'0'}";
|
}
|
} else {
|
res = "{'result':'3'}";
|
}
|
}
|
return res;
|
}
|
|
/**
|
* 获取复制地址
|
* @param resourceid
|
* @param url
|
* @param request
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("mainInfo/getUrlAndToken")
|
public String getUrlAndToken(Integer resourceid, String url, HttpServletRequest request) {
|
Res_MainInfo resMainInfo = resMainInfoService.selectByPrimaryKey(resourceid);
|
if (resMainInfo.getEspproxy() == 1) {
|
Res_ExtThemeMap resExtThemeMap = resExtThemeMapService.selectByPrimaryKey(resourceid);
|
String subzyids = "";
|
if (resExtThemeMap != null) {
|
subzyids = resExtThemeMap.getSublayerset();
|
}
|
boolean isPubzy = false;
|
if (resMainInfo != null && resMainInfo.getSharprotocol().equals("完全公开")) {
|
isPubzy = true;
|
}
|
String serviceUrl = url;
|
String path = EsbToken.getEsbUrl(serviceUrl, getUserId().intValue(), request.getRemoteAddr(), resourceid, resMainInfo.getEspproxy(), sysConfig, subzyids, isPubzy, resMainInfo.getToken(), false);
|
return path;
|
} else {
|
if (resMainInfo.getToken() != null && !resMainInfo.getToken().isEmpty()) {
|
if (url.indexOf("?") > -1) {
|
return url + "&token=" + resMainInfo.getToken();
|
} else {
|
return url + "?token=" + resMainInfo.getToken();
|
}
|
} else {
|
return url;
|
}
|
}
|
}
|
|
//检查服务地址是否异常,异常则插入记录
|
@ResponseBody
|
@RequestMapping("ZiYuan/CheckServerurl")
|
public String CheckServerurl(Integer resourceid, String urlStr) {
|
Integer status = -1;//不成功
|
if (urlStr == null || urlStr.trim().equals("")) {
|
return "";
|
}
|
Res_MainInfo res_mainInfo = resMainInfoService.selectByPrimaryKey(resourceid);
|
//检查:pingIP或域名是否成功
|
//1.先查最新一笔记录是否为异常,异常则不检查
|
//2.最新一笔记录为网络异常,再次检查,如果正常则插入正常消息
|
//3.没有异常消息,检查
|
List<Res_ProblemFeedback> problemFeedbacks = resProblemFeedbackService.selectByResourceid(resourceid);
|
Integer lastServerStatus = (problemFeedbacks != null && problemFeedbacks.size() > 0 && problemFeedbacks.get(0).getServerstatus() != null) ? problemFeedbacks.get(0).getServerstatus() : -1;
|
String lastStatus = (problemFeedbacks != null && problemFeedbacks.size() > 0 && problemFeedbacks.get(0).getFeedbackstatus() != null) ? problemFeedbacks.get(0).getFeedbackstatus() : "";
|
String lastType = (problemFeedbacks != null && problemFeedbacks.size() > 0 && problemFeedbacks.get(0).getFeedbacktype() != null) ? problemFeedbacks.get(0).getFeedbacktype() : "";
|
boolean res = false;
|
if (problemFeedbacks == null || problemFeedbacks.size() == 0 || lastServerStatus.equals(1) || (lastStatus.equals("网络问题") && lastServerStatus.equals(0) && lastType.equals("系统"))) {
|
try {
|
Runtime runtime = Runtime.getRuntime();
|
Process process = null;
|
String line = null;
|
InputStream is = null;
|
InputStreamReader isr = null;
|
BufferedReader br = null;
|
URL url = new URL(urlStr);
|
String ip = url.getHost();
|
res = false;
|
process = runtime.exec("ping " + ip);
|
is = process.getInputStream();
|
isr = new InputStreamReader(is);
|
br = new BufferedReader(isr);
|
while ((line = br.readLine()) != null) {
|
if (line.contains("TTL")) {
|
res = true;
|
break;
|
}
|
}
|
is.close();
|
isr.close();
|
br.close();
|
br.close();
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
if (res && (lastStatus.equals("网络问题") && lastServerStatus.equals(0) && lastType.equals("系统"))) {
|
InsertProblem(resourceid, 1, 0);
|
if (res_mainInfo != null) res_mainInfo.setResourcestatus(0);
|
status = 0;
|
}
|
if (!res && (lastServerStatus.equals(1) || lastServerStatus.equals(-1))) {
|
InsertProblem(resourceid, 0, 1);
|
if (res_mainInfo != null) res_mainInfo.setResourcestatus(1);
|
status = 1;
|
}
|
}
|
return "{result:" + status + "}";
|
}
|
|
//插入问题消息
|
private void InsertProblem(Integer resourceid, Integer status, Integer resourcestatus) {
|
Res_ProblemFeedback model = new Res_ProblemFeedback();
|
Timestamp time = new Timestamp(new Date().getTime());
|
model.setResourceid(resourceid);
|
model.setCreateuserid(getUserId().intValue());
|
model.setAddtime(time);
|
model.setFeedbacktype("系统");
|
model.setServerstatus(status);
|
model.setFeedbackstatus("网络问题");
|
model.setRemark("无法连接服务器");
|
resProblemFeedbackService.insertSelective(model);
|
Res_MainInfo mainInfo = new Res_MainInfo();
|
mainInfo.setResourceid(resourceid);
|
mainInfo.setResourcestatus(resourcestatus);
|
resMainInfoService.updateByPrimaryKeySelective(mainInfo);
|
}
|
|
//获取问题类型
|
private Model GetProblemStatus(Res_MainInfo mainInfo, Model model) {
|
String status = "";
|
if (mainInfo != null) {
|
List<Res_ProblemFeedback> problemFeedbacks = resProblemFeedbackService.selectByResourceid(mainInfo.getResourceid());
|
if (problemFeedbacks != null && problemFeedbacks.size() > 0 && problemFeedbacks.get(0).getServerstatus().equals(0)) {
|
status = problemFeedbacks.get(0).getFeedbackstatus();
|
}
|
}
|
model.addAttribute("problemStatus", status.equals("") ? "" : status.substring(0, 2));
|
return model;
|
}
|
|
//根据类型获取资源条数
|
private int GetZYCountByClass(Integer treeType, String search,String catalogname) {
|
UserDef_ZYML_ChaXunQu userDefZymlChaXunQu = new UserDef_ZYML_ChaXunQu();
|
if (!search.equals("") && treeType == 4) userDefZymlChaXunQu.setResourceclass(search);
|
if (!search.equals("") && treeType == 0) {
|
userDefZymlChaXunQu.setCatlogcode(search);
|
userDefZymlChaXunQu.setCatalogName(catalogname);
|
};
|
int count = ziYuanMuLuService.selectZiYuanMuLuList(userDefZymlChaXunQu).size();
|
return count;
|
}
|
|
private Model ProblemFeedback(Integer resourceid, Model model) {
|
//获取资源最后一笔问题反馈的状态
|
Res_ProblemFeedback problemFeedback = resProblemFeedbackService.selectTopByResourceid(resourceid);
|
String result = "";
|
if(problemFeedback != null) {
|
if(problemFeedback.getServerstatus() == 1) {
|
result = "正常";
|
}
|
else {
|
result = "异常";
|
}
|
}
|
model.addAttribute("ProblemFeedback",result);
|
return model;
|
}
|
}
|