来函专项增加csv导出及首行显示标题和时间范围
This commit is contained in:
@@ -332,7 +332,7 @@ public class ExcelCsv {
|
||||
log.error("Get entity value failed",ex);
|
||||
val = "";
|
||||
}
|
||||
sb.append(val + ", ");
|
||||
sb.append(val + "┆~");
|
||||
}
|
||||
listT.add(String.valueOf(sb));
|
||||
}
|
||||
@@ -425,7 +425,7 @@ public class ExcelCsv {
|
||||
// 写入文件内容
|
||||
//Html 解码
|
||||
data = Encodes.unescapeHtml(data.toString());
|
||||
String [] datas=data.split(",");
|
||||
String [] datas=data.split("┆~");
|
||||
for (String tag : datas) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
if("null".equals(tag.trim())){
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -394,7 +394,7 @@ public class UserManageController extends BaseController{
|
||||
}
|
||||
for (UserManage userManage : ipLists) {
|
||||
if(!StringUtils.isEmpty( userManage.getServerIp())){
|
||||
userManage.setServerIp(userManage.getServerIp().substring(0,userManage.getServerIp().length()-1).replaceAll(",", ","));
|
||||
userManage.setServerIp(userManage.getServerIp().substring(0,userManage.getServerIp().length()-1));
|
||||
}
|
||||
}
|
||||
noExportMap.put("user_manage", cfgIndexInfoNoExport);
|
||||
|
||||
@@ -68,10 +68,22 @@
|
||||
<button type="button" class="btn btn-default" onclick="edit(${taskInfo.functionId})">
|
||||
<i class="fa fa-edit"></i> <spring:message code="edit"></spring:message></button>
|
||||
<sys:delRow url="${ctx}/basics/taskInfo/delete?functionId=${taskInfo.functionId}" id="contentTable" label="delete"></sys:delRow>
|
||||
<sys:delRow url="${ctx}/basics/taskInfo/exportTaskInfo?functionId=${taskInfo.functionId}" searchUrl="${ctx}/basics/taskInfo/list?functionId=${taskInfo.functionId}" id="contentTable" maxRow="10000" label="export"></sys:delRow>
|
||||
<%-- <sys:delRow url="${ctx}/basics/taskInfo/exportTaskInfo?functionId=${taskInfo.functionId}" searchUrl="${ctx}/basics/taskInfo/list?functionId=${taskInfo.functionId}" id="contentTable" maxRow="10000" label="export"></sys:delRow> --%>
|
||||
<!-- <button type="button" class="btn btn-default">
|
||||
<i class="fa fa-download"></i> 导出</button> -->
|
||||
</shiro:hasPermission>
|
||||
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-wrench"></i> <spring:message code="export"></spring:message>
|
||||
<i class="fa fa-angle-down"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu pull-right" style="min-width: 110px;" >
|
||||
<li><sys:delRow url="${ctx}/basics/taskInfo/exportTaskInfo?functionId=${taskInfo.functionId}&exType=excel" searchUrl="${ctx}/basics/taskInfo/list?functionId=${taskInfo.functionId}" id="contentTable" maxRow="10000" label="cfg_excel"></sys:delRow></li>
|
||||
<li><sys:delRow url="${ctx}/basics/taskInfo/exportTaskInfo?functionId=${taskInfo.functionId}&exType=csv" searchUrl="${ctx}/basics/taskInfo/list?functionId=${taskInfo.functionId}" id="contentTable" maxRow="10000" label="cfg_csv"></sys:delRow></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<shiro:hasPermission name="basics:taskInfo:confirm">
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
|
||||
@@ -162,17 +174,17 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th><input type="checkbox" class="i-checks" id="checkAll"></th>
|
||||
<th><spring:message code="task_name"></spring:message></th>
|
||||
<th><spring:message code="task_org"></spring:message></th>
|
||||
<th><spring:message code="task_time"></spring:message></th>
|
||||
<th><spring:message code="state"></spring:message></th>
|
||||
<th><spring:message code="desc"></spring:message></th>
|
||||
<th><spring:message code="creator"></spring:message></th>
|
||||
<th class="sort-column createTime"><spring:message code="create_time"/></th>
|
||||
<th><spring:message code="editor"/></th>
|
||||
<th class="sort-column editTime"><spring:message code="edit_time"/></th>
|
||||
<th><spring:message code="auditor"></spring:message></th>
|
||||
<th class="sort-column auditTime"><spring:message code="audit_time"></spring:message></th>
|
||||
<th column="task_name" ><spring:message code="task_name"></spring:message></th>
|
||||
<th column="task_org" ><spring:message code="task_org"></spring:message></th>
|
||||
<th column="task_time" ><spring:message code="task_time"></spring:message></th>
|
||||
<th column="state" ><spring:message code="state"></spring:message></th>
|
||||
<th column="desc" ><spring:message code="desc"></spring:message></th>
|
||||
<th column="creator" ><spring:message code="creator"></spring:message></th>
|
||||
<th column="create_time" class="sort-column createTime"><spring:message code="create_time"/></th>
|
||||
<th column="editor" ><spring:message code="editor"/></th>
|
||||
<th column="edit_time" class="sort-column editTime"><spring:message code="edit_time"/></th>
|
||||
<th column="auditor" ><spring:message code="auditor"></spring:message></th>
|
||||
<th column="audit_time" class="sort-column auditTime"><spring:message code="audit_time"></spring:message></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
Reference in New Issue
Block a user