来函专项增加csv导出及首行显示标题和时间范围
This commit is contained in:
@@ -13,14 +13,17 @@ import javax.servlet.http.HttpServletResponse;
|
||||
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;
|
||||
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.util.Constants;
|
||||
import com.nis.util.DateUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.excel.ExcelField;
|
||||
import com.nis.web.controller.BaseController;
|
||||
@@ -160,7 +163,7 @@ public class TaskInfoController extends BaseController{
|
||||
}
|
||||
//配置导出
|
||||
@RequestMapping(value = "exportTaskInfo")
|
||||
public void exportTaskInfo(Model model,HttpServletRequest request,HttpServletResponse response,
|
||||
public void exportTaskInfo(Model model,HttpServletRequest request,HttpServletResponse response,String hcolumn,String exType,
|
||||
@ModelAttribute("cfg")TaskInfo entity,String ids,RedirectAttributes redirectAttributes){
|
||||
try {
|
||||
//export data info
|
||||
@@ -189,6 +192,18 @@ public class TaskInfoController extends BaseController{
|
||||
if(column.toString().length()>0) {
|
||||
column.append(",");
|
||||
}
|
||||
|
||||
if(entity.getBeginDate()==null ){
|
||||
hcolumn+=",task_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(",")){
|
||||
@@ -203,15 +218,43 @@ public class TaskInfoController extends BaseController{
|
||||
Page<TaskInfo> page = taskInfoService.findTaskInfo(pageInfo, entity);
|
||||
list=page.getList();
|
||||
}
|
||||
|
||||
dataMap.put(entity.getMenuNameCode(),list);
|
||||
// 获取国际化配置
|
||||
this._export(model, request, response, redirectAttributes,entity.getMenuNameCode(),titleList,classMap,dataMap,noExportMap);
|
||||
//获取国际化配置
|
||||
String timeRange = initTaskMap(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 initTaskMap(TaskInfo info){
|
||||
Properties msgProp = getMsgProp();
|
||||
String logTime=msgProp.getProperty(info.getMenuNameCode(),info.getMenuNameCode());
|
||||
if(info.getBeginDate()!=null){
|
||||
logTime+=" "+msgProp.getProperty("task_time","task_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