|
@@ -1,6 +1,8 @@
|
|
package com.hb.proj.car.controller;
|
|
package com.hb.proj.car.controller;
|
|
|
|
|
|
|
|
+import java.io.File;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.HashSet;
|
|
import java.util.HashSet;
|
|
import java.util.Iterator;
|
|
import java.util.Iterator;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -10,11 +12,13 @@ import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
import com.hb.proj.car.service.CarService;
|
|
import com.hb.proj.car.service.CarService;
|
|
|
|
+import com.hb.proj.excel.ExcelUtils;
|
|
import com.hb.proj.excel.imp.ExcelDataExtractor;
|
|
import com.hb.proj.excel.imp.ExcelDataExtractor;
|
|
import com.hb.proj.excel.imp.ExcelResult;
|
|
import com.hb.proj.excel.imp.ExcelResult;
|
|
import com.hb.proj.sysdata.service.OrgService;
|
|
import com.hb.proj.sysdata.service.OrgService;
|
|
@@ -28,6 +32,7 @@ import com.hb.proj.utils.RptMonthUtil;
|
|
import com.hb.xframework.dao.util.PageModel;
|
|
import com.hb.xframework.dao.util.PageModel;
|
|
import com.hb.xframework.dao.util.UUIDHexGenerator;
|
|
import com.hb.xframework.dao.util.UUIDHexGenerator;
|
|
import com.hb.xframework.util.DateUtil;
|
|
import com.hb.xframework.util.DateUtil;
|
|
|
|
+import com.hb.xframework.util.JsonParamHandler;
|
|
import com.hb.xframework.util.MapUtils;
|
|
import com.hb.xframework.util.MapUtils;
|
|
import com.hb.xframework.util.SessionThreadLocal;
|
|
import com.hb.xframework.util.SessionThreadLocal;
|
|
import com.hb.xframework.util.SessionUser;
|
|
import com.hb.xframework.util.SessionUser;
|
|
@@ -328,4 +333,38 @@ public class CarController {
|
|
|
|
|
|
return new String[]{StringUtils.join(carNums,","),(ignorMsg.length()>0?ignorMsg.toString():null)};
|
|
return new String[]{StringUtils.join(carNums,","),(ignorMsg.length()>0?ignorMsg.toString():null)};
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 车辆基本信息导出
|
|
|
|
+ * @param request
|
|
|
|
+ * @param response
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping("/export")
|
|
|
|
+ public void export(HttpServletRequest request,HttpServletResponse response){
|
|
|
|
+ try{
|
|
|
|
+ MySessionUser su=(MySessionUser)SessionThreadLocal.getSessionUser();
|
|
|
|
+ Map<String,Object> args=JsonParamHandler.getMapParam(request.getParameter("where"));
|
|
|
|
+ args.put("showAll", su!=null&&su.isSysAdmin()?"1":null); //系统管理员显示全部
|
|
|
|
+
|
|
|
|
+ PageModel<Map<String,Object>> pagedData=service.queryCar(args,DataAuthUtils.getAuthOrgAssistCode(su),1, 10000);
|
|
|
|
+ if(pagedData==null||pagedData.getData()==null||pagedData.getData().size()==0){
|
|
|
|
+ JsonOutUtils.writeToResponse(response, "<script>alert('暂时无数据可导出');window.close();</script>","text/html;charset=UTF-8");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ String crtMonth=DateUtil.format(new Date(), "yyyy-MM-dd");
|
|
|
|
+ for(Map<String,Object> car : pagedData.getData()){
|
|
|
|
+ car.put("realAge", RptMonthUtil.getWorkAge((String)car.get("wkStart"),crtMonth));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String templateName=File.separator+"excel"+File.separator+"carExport.xls";
|
|
|
|
+ Map<String,Object> context=new HashMap<String,Object>();
|
|
|
|
+ context.put("ds", pagedData.getData());
|
|
|
|
+ Workbook wb=CarExportBound.bound(context,ExcelUtils.reader(templateName,request.getSession().getServletContext()));
|
|
|
|
+ ExcelUtils.exportExcel(response, "车辆基本信息", wb);
|
|
|
|
+ }
|
|
|
|
+ catch(Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ JsonOutUtils.writeToResponse(response, "<script>alert('导出数据出现错误');window.close();</script>","text/html;charset=UTF-8");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|