ResponsePage增加导出功能
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.nis.domain.callback;
|
||||
|
||||
import com.nis.domain.configuration.BaseCfg;
|
||||
import com.nis.util.excel.ExcelField;
|
||||
/**
|
||||
* http代理文件策略
|
||||
* @author nanfang
|
||||
@@ -11,8 +12,11 @@ public class ProxyFileResponsePageCfg extends BaseCfg<ProxyFileResponsePageCfg>
|
||||
private static final long serialVersionUID = -1989406217948847813L;
|
||||
public final static String TABLE_NAME = "pxy_profile_response_pages";//对应表名
|
||||
private String indexTable = "pxy_profile_response_pages";
|
||||
@ExcelField(title="file_desc",sort=1)
|
||||
private String fileDesc;//文件描述
|
||||
@ExcelField(title="response_file",sort=2)
|
||||
private String url;//文件保存的url
|
||||
@ExcelField(title="format",sort=3)
|
||||
private String contentType;//内容类型,如text/html,取字典表contentType
|
||||
private String md5;//文件md5值
|
||||
private Long contentLength;//文件长度
|
||||
|
||||
@@ -9,7 +9,10 @@
|
||||
package com.nis.web.controller.configuration.proxy;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -26,11 +29,14 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.callback.ProxyFileHijackCfg;
|
||||
import com.nis.domain.callback.ProxyFileResponsePageCfg;
|
||||
import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.domain.maat.ToMaatResult;
|
||||
import com.nis.domain.maat.ToMaatResult.ResponseData;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.ConfigServiceUtil;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.FileUtils;
|
||||
import com.nis.util.JsonMapper;
|
||||
import com.nis.util.LogUtils;
|
||||
@@ -219,4 +225,62 @@ public class FileResponsePageController extends CommonController {
|
||||
}
|
||||
return "redirect:" + adminPath +"/proxy/fileResponsePage/list?functionId="+functionId;
|
||||
}
|
||||
@RequestMapping(value = "exportFileResponsePage")
|
||||
public void exportPxy(Model model, HttpServletRequest request, HttpServletResponse response,
|
||||
@ModelAttribute("cfg") ProxyFileResponsePageCfg entity, String ids, RedirectAttributes redirectAttributes) {
|
||||
try {
|
||||
// export data info
|
||||
List<String> titleList = new ArrayList<String>();
|
||||
Map<String, Class<?>> classMap = new HashMap<String, Class<?>>();
|
||||
Map<String, List> dataMap = new HashMap<String, List>();
|
||||
Map<String, String> noExportMap = new HashMap<String, String>();
|
||||
|
||||
List<ProxyFileResponsePageCfg> ipLists = new ArrayList<ProxyFileResponsePageCfg>();
|
||||
// 导出选中记录
|
||||
if (!StringUtil.isEmpty(ids)) {
|
||||
ipLists = proxyFileResponsePageService.findByList(ids);
|
||||
} else {
|
||||
entity.setTableName(IpPortCfg.getTablename());
|
||||
Page<ProxyFileResponsePageCfg> pageInfo = new Page<ProxyFileResponsePageCfg>(request, response, "a");
|
||||
pageInfo.setPageNo(1);
|
||||
pageInfo.setPageSize(Constants.MAX_EXPORT_SIZE);
|
||||
Page<ProxyFileResponsePageCfg> page = proxyFileResponsePageService.findPage(pageInfo, entity);
|
||||
ipLists = page.getList();
|
||||
}
|
||||
titleList.add(entity.getMenuNameCode());
|
||||
classMap.put(entity.getMenuNameCode(), ProxyFileResponsePageCfg.class);
|
||||
String cfgIndexInfoNoExport = ",config_describe,whether_area_block,block_type,do_log,client_port,ir_type,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,";
|
||||
|
||||
// 时间过滤
|
||||
if (entity.getSearch_create_time_start() == null && entity.getSearch_create_time_end() == null) {
|
||||
cfgIndexInfoNoExport = ",config_time" + cfgIndexInfoNoExport;
|
||||
}
|
||||
if (entity.getSearch_edit_time_start() == null && entity.getSearch_edit_time_end() == null) {
|
||||
cfgIndexInfoNoExport = ",edit_time" + cfgIndexInfoNoExport;
|
||||
}
|
||||
if (entity.getSearch_audit_time_start() == null && entity.getSearch_audit_time_end() == null) {
|
||||
cfgIndexInfoNoExport = ",audit_time" + cfgIndexInfoNoExport;
|
||||
}
|
||||
if (!StringUtil.isEmpty(entity.gethColumns())) {
|
||||
cfgIndexInfoNoExport = "," + entity.gethColumns() + "," + cfgIndexInfoNoExport;
|
||||
}
|
||||
|
||||
noExportMap.put(entity.getMenuNameCode(), cfgIndexInfoNoExport);
|
||||
dataMap.put(entity.getMenuNameCode(), ipLists);
|
||||
|
||||
String timeRange = initTimeMap(entity);
|
||||
noExportMap.put("timeRange", timeRange);
|
||||
if ("csv".equals(entity.getExType())) {
|
||||
this._exportCsv(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
|
||||
classMap, dataMap, noExportMap);
|
||||
} else {
|
||||
this._export(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
|
||||
classMap, dataMap, noExportMap);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("proxyFileHijack export failed", e);
|
||||
addMessage(redirectAttributes, "error", "export_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,6 @@ public interface ProxyFileResponsePageDao {
|
||||
public ProxyFileResponsePageCfg getCfgById(@Param("cfgId")Long cfgId);
|
||||
public void insert(ProxyFileResponsePageCfg entity);
|
||||
public void update(ProxyFileResponsePageCfg entity);
|
||||
|
||||
List<ProxyFileResponsePageCfg> findByList(@Param("ids")String ids);
|
||||
|
||||
}
|
||||
|
||||
@@ -326,7 +326,21 @@
|
||||
</set>
|
||||
where cfg_id = #{cfgId,jdbcType=BIGINT}
|
||||
</update>
|
||||
|
||||
<!-- 查出所有 有效数据-->
|
||||
<select id="findByList" resultMap="ProxyFileResponsePageCfg">
|
||||
SELECT
|
||||
<include refid="ProxyFileResponsePageCfgColumn"/>
|
||||
<trim prefix="," prefixOverrides=",">
|
||||
,s.name as creator_name,e.name as editor_name,u.name as auditor_name
|
||||
,ri.request_title as requestName
|
||||
</trim>
|
||||
FROM pxy_profile_response_pages a
|
||||
left join sys_user s on a.creator_id=s.id
|
||||
left join sys_user e on a.editor_id=e.id
|
||||
left join sys_user u on a.auditor_id=u.id
|
||||
left join request_info ri on a.request_id=ri.id
|
||||
where a.CFG_ID in (${ids})
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -132,5 +132,9 @@ public class ProxyFileResponsePageService extends BaseService{
|
||||
List<ProxyFileResponsePageCfg> list=proxyFileDao.findPage(entity);
|
||||
return list;
|
||||
}
|
||||
public List<ProxyFileResponsePageCfg> findByList(String ids) {
|
||||
List<ProxyFileResponsePageCfg> list=proxyFileDao.findByList(ids);
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user