来函专项增加csv导出及首行显示标题和时间范围
This commit is contained in:
@@ -14,6 +14,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
@@ -22,7 +23,9 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.configuration.RequestInfo;
|
||||
import com.nis.domain.configuration.TaskInfo;
|
||||
import com.nis.domain.log.BaseLogEntity;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DateUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.excel.ExcelField;
|
||||
import com.nis.web.controller.BaseController;
|
||||
@@ -188,7 +191,7 @@ public class RequestInfoController extends BaseController{
|
||||
}
|
||||
//配置导出
|
||||
@RequestMapping(value = "exportRequestInfo")
|
||||
public void exportTaskInfo(Model model,HttpServletRequest request,HttpServletResponse response,
|
||||
public void exportTaskInfo(Model model,HttpServletRequest request,HttpServletResponse response, String exType,String hcolumn,
|
||||
@ModelAttribute("requestInfo")RequestInfo entity,String ids,RedirectAttributes redirectAttributes){
|
||||
try {
|
||||
//export data info
|
||||
@@ -196,8 +199,6 @@ public class RequestInfoController extends BaseController{
|
||||
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<RequestInfo> list=Lists.newArrayList();
|
||||
titleList.add(entity.getMenuNameCode());
|
||||
@@ -217,6 +218,17 @@ public class RequestInfoController extends BaseController{
|
||||
if(column.toString().length()>0) {
|
||||
column.append(",");
|
||||
}
|
||||
|
||||
if(entity.getBeginDate()==null){
|
||||
hcolumn+=",request_time,";
|
||||
}
|
||||
if(entity.getDobeginDate()==null){
|
||||
hcolumn+=",edit_time,";
|
||||
}
|
||||
|
||||
if(!StringUtils.isEmpty(hcolumn)){
|
||||
column.append(","+hcolumn+",");
|
||||
}
|
||||
noExportMap.put(entity.getMenuNameCode(),column.toString());
|
||||
if(!StringUtil.isEmpty(ids)){
|
||||
for(String id:ids.split(",")){
|
||||
@@ -231,14 +243,43 @@ public class RequestInfoController extends BaseController{
|
||||
Page<RequestInfo> page = requestInfoService.findRequestInfo(pageInfo, entity);
|
||||
list=page.getList();
|
||||
}
|
||||
|
||||
dataMap.put(entity.getMenuNameCode(),list);
|
||||
// 获取国际化配置
|
||||
this._export(model, request, response, redirectAttributes,entity.getMenuNameCode(),titleList,classMap,dataMap,noExportMap);
|
||||
String timeRange = initRequestMap(entity);
|
||||
noExportMap.put("timeRange", timeRange);
|
||||
if ("csv".equals(exType)) {
|
||||
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("ip addr export failed",e);
|
||||
addMessage(redirectAttributes,"error", "export_failed");
|
||||
}
|
||||
//return "redirect:" + adminPath +"/ntc/iplist/list?functionId="+entity.getFunctionId();
|
||||
}
|
||||
|
||||
public String initRequestMap(RequestInfo info){
|
||||
Properties msgProp = getMsgProp();
|
||||
String logTime=msgProp.getProperty(info.getMenuNameCode(),info.getMenuNameCode());
|
||||
if(info.getBeginDate()!=null){
|
||||
logTime+=" "+msgProp.getProperty("request_time","request_time")+":"+DateUtils.formatDateTime(info.getBeginDate());
|
||||
if(info.getEndDate()!=null){
|
||||
logTime+="—"+DateUtils.formatDateTime(info.getEndDate());
|
||||
}else{
|
||||
logTime+="—"+DateUtils.getDateTime();
|
||||
}
|
||||
}
|
||||
if(info.getDobeginDate()!=null){
|
||||
logTime+=" "+msgProp.getProperty("edit_time","edit_time")+":"+DateUtils.formatDateTime(info.getDobeginDate());
|
||||
if(info.getDoendDate()!=null){
|
||||
logTime+="—"+DateUtils.formatDateTime(info.getDoendDate());
|
||||
}else{
|
||||
logTime+="—"+DateUtils.getDateTime();
|
||||
}
|
||||
}
|
||||
return logTime;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user