liupeng 4 years ago
parent
commit
979a83af4a

+ 12 - 11
code/sapparent/sapcms/src/main/java/org/fouram/controller/ApiController.java

@@ -252,7 +252,6 @@ public class ApiController extends BaseController {
 		}
 	}
 
-	@SuppressWarnings("unchecked")
 	@RequestMapping(value = "/exportUserReportExcel")
 	@ResponseBody
 	public Object exportUserReportExcel(HttpServletResponse response, @RequestBody FindUsersDTO dto) {
@@ -263,17 +262,19 @@ public class ApiController extends BaseController {
 			if (StringUtils.isBlank(dto.getEndDate())) {
 				return ResultUtil.error("结束日期不可以为空");
 			}
-			String haveFilePath = "/public/excel/userReport.xlsx";
-			// 明细
-			String mxFilePath = "/public/excel/userReport" + DateUtil.getTimeStamp() + ".xlsx";
-			Object object = sapCheckService.findUserReports(dto.getStartDate(), dto.getEndDate(), dto.getDepartId(),
-					dto.getName(), dto.getState(), null, null);
-			List<Map<String, Object>> dataList = (List<Map<String, Object>>) object;
-			ExcelExportUtil.exportExcelFile(getRootPath() + haveFilePath, dataList, getRootPath() + mxFilePath, 1, 0);
+			String ysFilePath = "/public/excel/userReport.xlsx";
 			// 汇总
-			String allFilePath = "/public/excel/userReport" + DateUtil.getTimeStamp() + ".xlsx";
-			ExcelExportUtil.exportExcelFile(getRootPath() + mxFilePath, dataList, getRootPath() + allFilePath, 1, 1);
-			return ResultUtil.success(allFilePath, "操作成功");
+			String hzFilePath = "/public/excel/userReport" + DateUtil.getTimeStamp() + ".xlsx";
+			List<Map<String, Object>> hzList = sapCheckService.selectReportDayList(dto.getStartDate(), dto.getEndDate(),
+					dto.getDepartId(), dto.getName());
+			ExcelExportUtil.exportExcelFile(getRootPath() + ysFilePath, hzList, getRootPath() + hzFilePath, 1, 0);
+			ysFilePath = hzFilePath;
+			// 明细
+			String resultFilePath = "/public/excel/userReport" + DateUtil.getTimeStamp() + ".xlsx";
+			List<Map<String, Object>> mxList = sapCheckService.findUserReports(dto.getStartDate(), dto.getEndDate(),
+					dto.getDepartId(), dto.getName(), dto.getState(), null, null);
+			ExcelExportUtil.exportExcelFile(getRootPath() + ysFilePath, mxList, getRootPath() + resultFilePath, 1, 1);
+			return ResultUtil.success(resultFilePath, "操作成功");
 		} catch (Exception e) {
 			LoggerUtil.error(e);
 			return ResultUtil.error(ResultConstant.WEB_ERR_MSG);

BIN
code/sapparent/sapcms/src/main/webapp/public/excel/userReport.xlsx


+ 5 - 5
code/sapparent/sapservice/src/main/java/org/fouram/service/SapCheckService.java

@@ -209,14 +209,14 @@ public class SapCheckService extends BaseService {
 
 	public JSONObject findUserReportPage(String startDate, String endDate, String departId, String name, String state,
 			Integer pageSize, Integer pageNumber) throws Exception {
-		List<Map<String, String>> list = findUserReports(startDate, endDate, departId, name, state, pageSize,
+		List<Map<String, Object>> list = findUserReports(startDate, endDate, departId, name, state, pageSize,
 				pageNumber);
 		Long total = findUserReportTotal(startDate, endDate, departId, name, state);
 		return getPageResult(list, total);
 	}
 
 	@SuppressWarnings("unchecked")
-	public List<Map<String, String>> findUserReports(String startDate, String endDate, String departId, String name,
+	public List<Map<String, Object>> findUserReports(String startDate, String endDate, String departId, String name,
 			String state, Integer pageSize, Integer pageNumber) throws Exception {
 		if (StringUtils.isNotBlank(departId) && departId.endsWith(",")) {
 			departId = departId.substring(0, departId.length() - 1);
@@ -238,11 +238,11 @@ public class SapCheckService extends BaseService {
 			pd.put("pageCurrent", String.valueOf(pageSize * (pageNumber - 1)));
 			pd.put("pageSize", String.valueOf(pageSize));
 		}
-		return (List<Map<String, String>>) findList("SapCheckMapper.findUserReports", pd);
+		return (List<Map<String, Object>>) findList("SapCheckMapper.findUserReports", pd);
 	}
 
 	@SuppressWarnings("unchecked")
-	public List<Map<String, String>> selectReportDayList(String startDate, String endDate, String departId, String name)
+	public List<Map<String, Object>> selectReportDayList(String startDate, String endDate, String departId, String name)
 			throws Exception {
 		if (StringUtils.isNotBlank(departId) && departId.endsWith(",")) {
 			departId = departId.substring(0, departId.length() - 1);
@@ -253,7 +253,7 @@ public class SapCheckService extends BaseService {
 		pd.put("departId", departId);
 		pd.put("name", name);
 		pd.put("reportDaySql", getReportDaySql(startDate, endDate));
-		return (List<Map<String, String>>) findList("SapCheckMapper.selectReportDayList", pd);
+		return (List<Map<String, Object>>) findList("SapCheckMapper.selectReportDayList", pd);
 	}
 
 	private String getReportDaySql(String startDate, String endDate) throws Exception {