liupeng 4 years ago
parent
commit
23e5d4aea1

+ 5 - 30
code/sapparent/sapcms/src/main/java/org/fouram/controller/ApiController.java

@@ -23,7 +23,7 @@ import org.fouram.core.util.ResultUtil;
 import org.fouram.entity.SapOrg;
 import org.fouram.entity.SapUser;
 import org.fouram.input.FindUsersDTO;
-import org.fouram.service.SapCheckService;
+import org.fouram.service.SapCheckReportService;
 import org.fouram.service.SapOrgService;
 import org.fouram.service.SapUserService;
 import org.fouram.service.WxDepartService;
@@ -48,7 +48,7 @@ public class ApiController extends BaseController {
 	@Autowired
 	private WxDepartService wxDepartService;
 	@Autowired
-	private SapCheckService sapCheckService;
+	private SapCheckReportService sapCheckReportService;
 	@Autowired
 	private static final String TOKEN = "UserId";
 
@@ -243,7 +243,7 @@ public class ApiController extends BaseController {
 			if (dto.getPageNumber() == null) {
 				return ResultUtil.error("参数pageNumber为空");
 			}
-			Object result = sapCheckService.findUserReportPage(dto.getStartDate(), dto.getEndDate(), dto.getDepartId(),
+			Object result = sapCheckReportService.findUserReportPage(dto.getStartDate(), dto.getEndDate(), dto.getDepartId(),
 					dto.getName(), dto.getStatus(), dto.getPageSize(), dto.getPageNumber());
 			return ResultUtil.success(result, "操作成功");
 		} catch (Exception e) {
@@ -265,38 +265,13 @@ public class ApiController extends BaseController {
 			String ysFilePath = "/public/excel/userReport.xlsx";
 			// 汇总
 			String hzFilePath = "/public/excel/userReport" + DateUtil.getTimeStamp() + ".xlsx";
-			List<Map<String, Object>> hzList = sapCheckService.selectReportDayList(dto.getStartDate(), dto.getEndDate(),
+			List<Map<String, Object>> hzList = sapCheckReportService.selectReportDayList(dto.getStartDate(), dto.getEndDate(),
 					dto.getDepartId(), dto.getName());
 			ExcelExportUtil.exportExcelFile(getRootPath() + ysFilePath, hzList, getRootPath() + hzFilePath, 0, 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.getStatus(), 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);
-		}
-	}
-
-	@RequestMapping(value = "/exportUserReportExcelTest")
-	@ResponseBody
-	public Object exportUserReportExcelTest(HttpServletResponse response) {
-		try {
-			FindUsersDTO dto = FindUsersDTO.builder().startDate(getPageData().getString("startDate"))
-					.endDate(getPageData().getString("endDate")).build();
-			String ysFilePath = "/public/excel/userReport.xlsx";
-			// 汇总
-			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(),
+			List<Map<String, Object>> mxList = sapCheckReportService.findUserReports(dto.getStartDate(), dto.getEndDate(),
 					dto.getDepartId(), dto.getName(), dto.getStatus(), null, null);
 			ExcelExportUtil.exportExcelFile(getRootPath() + ysFilePath, mxList, getRootPath() + resultFilePath, 1, 1);
 			return ResultUtil.success(resultFilePath, "操作成功");

+ 0 - 61
code/sapparent/sapservice/src/main/java/org/fouram/mapper/SapCheckMapper.xml

@@ -137,67 +137,6 @@
 		delete from sap_checkout_end where id = #{id}
 	</update>
 	
-	<select id="selectReportDayList" resultType="java.util.LinkedHashMap">
-		SELECT c.firstDepartName,c.secondDepartName, a.userId, a.name, ${reportDaySql}
-		from sap_check_report a, wx_user c
-		where a.userId = c.userId and a.checkinDay >= #{startDate} and a.checkinDay &lt;= #{endDate}
-		<if test="name != null and name != ''">
-			and a.name like CONCAT(CONCAT('%', #{name}),'%')
-		</if>
-		<if test="departId != null and departId != ''">
-			and (c.firstDepartId=#{departId} or c.secondDepartId=#{departId})
-		</if>
-		group by c.firstDepartName,c.secondDepartName, a.userId, a.name
-	</select>
-	
-	<select id="findUserReports" resultType="java.util.LinkedHashMap">
-		SELECT c.firstDepartName,c.secondDepartName,a.userId,groupName,workTime,offWorkTime,a.name,a.checkinDay,
-			checkinDate,checkinException,checkoffDate,checkoffException,checkoutDate1,checkoutDate2,leaveCreatedTime,
-			leaveStartDate,leaveEndDate,leaveDay,leaveComment,bukaDay,result
-		from sap_check_report a, sap_checkdate b, wx_user c 
-		where a.checkinDay=b.checkinDay and a.userId = c.userId
-		<if test="departId != null and departId != ''">
-			and (c.firstDepartId=#{departId} or c.secondDepartId=#{departId})
-		</if>
-		<if test="startDate != null and startDate != ''">
-			and a.checkinDay >= #{startDate} 
-		</if>
-		<if test="endDate != null and endDate != ''">
-			and a.checkinDay &lt;= #{endDate} 
-		</if>
-		<if test="name != null and name != ''">
-			and a.name like CONCAT(CONCAT('%', #{name}),'%')
-		</if>
-		<if test="state != null and state != ''">
-			and a.result = #{state} 
-		</if>
-		order by a.userId, a.checkinDay 
-		<if test="pageCurrent != null and pageCurrent != ''">
-			limit ${pageCurrent},${pageSize}
-		</if>
-	</select>
-	
-	<select id="findUserReportTotal" resultType="Long">
-		SELECT count(1) 
-		from sap_check_report a, sap_checkdate b, wx_user c 
-		where a.checkinDay=b.checkinDay and a.userId = c.userId
-		<if test="departId != null and departId != ''">
-			and (c.firstDepartId=#{departId} or c.secondDepartId=#{departId})
-		</if>
-		<if test="startDate != null and startDate != ''">
-			and a.checkinDay >= #{startDate} 
-		</if>
-		<if test="endDate != null and endDate != ''">
-			and a.checkinDay &lt;= #{endDate} 
-		</if>
-		<if test="name != null and name != ''">
-			and a.name like CONCAT(CONCAT('%', #{name}),'%')
-		</if>
-		<if test="state != null and state != ''">
-			and a.result = #{state} 
-		</if>
-	</select>
-	
 	<select id="queryCheckInTotal" resultType="Long">
 		SELECT count(1) from sap_checkin
 	</select>

+ 64 - 0
code/sapparent/sapservice/src/main/java/org/fouram/mapper/SapCheckReportMapper.xml

@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="SapCheckReportMapper">
+	<select id="selectReportDayList" resultType="java.util.LinkedHashMap">
+		SELECT c.firstDepartName,c.secondDepartName, a.userId, a.name, ${reportDaySql}
+		from sap_check_report a, wx_user c
+		where a.userId = c.userId and a.checkinDay >= #{startDate} and a.checkinDay &lt;= #{endDate}
+		<if test="name != null and name != ''">
+			and a.name like CONCAT(CONCAT('%', #{name}),'%')
+		</if>
+		<if test="departId != null and departId != ''">
+			and (c.firstDepartId=#{departId} or c.secondDepartId=#{departId})
+		</if>
+		group by c.firstDepartName,c.secondDepartName, a.userId, a.name
+	</select>
+	
+	<select id="findUserReports" resultType="java.util.LinkedHashMap">
+		SELECT c.firstDepartName,c.secondDepartName,a.userId,groupName,workTime,offWorkTime,a.name,a.checkinDay,
+			checkinDate,checkinException,checkoffDate,checkoffException,checkoutDate1,checkoutDate2,leaveCreatedTime,
+			leaveStartDate,leaveEndDate,leaveDay,leaveComment,bukaDay,result
+		from sap_check_report a, sap_checkdate b, wx_user c 
+		where a.checkinDay=b.checkinDay and a.userId = c.userId
+		<if test="departId != null and departId != ''">
+			and (c.firstDepartId=#{departId} or c.secondDepartId=#{departId})
+		</if>
+		<if test="startDate != null and startDate != ''">
+			and a.checkinDay >= #{startDate} 
+		</if>
+		<if test="endDate != null and endDate != ''">
+			and a.checkinDay &lt;= #{endDate} 
+		</if>
+		<if test="name != null and name != ''">
+			and a.name like CONCAT(CONCAT('%', #{name}),'%')
+		</if>
+		<if test="state != null and state != ''">
+			and a.result = #{state} 
+		</if>
+		order by a.userId, a.checkinDay 
+		<if test="pageCurrent != null and pageCurrent != ''">
+			limit ${pageCurrent},${pageSize}
+		</if>
+	</select>
+	
+	<select id="findUserReportTotal" resultType="Long">
+		SELECT count(1) 
+		from sap_check_report a, sap_checkdate b, wx_user c 
+		where a.checkinDay=b.checkinDay and a.userId = c.userId
+		<if test="departId != null and departId != ''">
+			and (c.firstDepartId=#{departId} or c.secondDepartId=#{departId})
+		</if>
+		<if test="startDate != null and startDate != ''">
+			and a.checkinDay >= #{startDate} 
+		</if>
+		<if test="endDate != null and endDate != ''">
+			and a.checkinDay &lt;= #{endDate} 
+		</if>
+		<if test="name != null and name != ''">
+			and a.name like CONCAT(CONCAT('%', #{name}),'%')
+		</if>
+		<if test="state != null and state != ''">
+			and a.result = #{state} 
+		</if>
+	</select>
+</mapper>

+ 119 - 0
code/sapparent/sapservice/src/main/java/org/fouram/service/SapCheckReportService.java

@@ -0,0 +1,119 @@
+package org.fouram.service;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+import org.fouram.core.base.service.BaseService;
+import org.fouram.core.util.DateUtil;
+import org.springframework.stereotype.Service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+@Service
+public class SapCheckReportService extends BaseService {
+
+	public JSONObject findUserReportPage(String startDate, String endDate, String departId, String name, String state,
+			Integer pageSize, Integer pageNumber) throws Exception {
+		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);
+	}
+	
+	public static JSONObject getPageResult(List<? extends Object> list, Object total) {
+		JSONObject object = new JSONObject();
+		object.put("total", total);
+		object.put("data", list);
+		return object;
+	}
+
+	@SuppressWarnings("unchecked")
+	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);
+		}
+		if (StringUtils.isNotBlank(state)) {
+			if ("1".equals(state)) {
+				state = "正常";
+			} else {
+				state = "异常";
+			}
+		}
+		Map<String, String> pd = Maps.newHashMap();
+		pd.put("startDate", startDate);
+		pd.put("endDate", endDate);
+		pd.put("departId", departId);
+		pd.put("name", name);
+		pd.put("state", state);
+		if (pageSize != null) {
+			pd.put("pageCurrent", String.valueOf(pageSize * (pageNumber - 1)));
+			pd.put("pageSize", String.valueOf(pageSize));
+		}
+		return (List<Map<String, Object>>) findList("SapCheckReportMapper.findUserReports", pd);
+	}
+
+	@SuppressWarnings("unchecked")
+	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);
+		}
+		Map<String, String> pd = Maps.newHashMap();
+		pd.put("startDate", startDate);
+		pd.put("endDate", endDate);
+		pd.put("departId", departId);
+		pd.put("name", name);
+		pd.put("reportDaySql", getReportDaySql(startDate, endDate));
+
+//		公司 部门 工号	姓名5月25日	5月26日	5月27日	5月28日	5月29日
+		List<String> days = DateUtil.getSubDateList(startDate, endDate);
+		Map<String, Object> headerMap = Maps.newLinkedHashMap();
+		headerMap.put("firstDepartName", "公司");
+		headerMap.put("secondDepartName", "部门");
+		headerMap.put("userId", "工号");
+		headerMap.put("name", "姓名");
+		for (String day : days) {
+			headerMap.put(day, day);
+		}
+		List<Map<String, Object>> result = Lists.newArrayList(headerMap);
+		List<Map<String, Object>> list = (List<Map<String, Object>>) findList("SapCheckReportMapper.selectReportDayList", pd);
+		list.stream().forEach(check -> result.add(check));
+		return result;
+	}
+
+	private String getReportDaySql(String startDate, String endDate) throws Exception {
+		String baseSql = "replace(group_concat(case when a.checkinDay = '%s' then a.result else '' end ),',','') as '%s',";
+		List<String> days = DateUtil.getSubDateList(startDate, endDate);
+		String reportDaySql = "";
+		for (String day : days) {
+			reportDaySql += String.format(baseSql, day, day);
+		}
+		reportDaySql = reportDaySql.substring(0, reportDaySql.length() - 1);
+		return reportDaySql;
+	}
+
+	public Long findUserReportTotal(String startDate, String endDate, String departId, String name, String state)
+			throws Exception {
+		if (StringUtils.isNotBlank(departId) && departId.endsWith(",")) {
+			departId = departId.substring(0, departId.length() - 1);
+		}
+		if (StringUtils.isNotBlank(state)) {
+			if ("1".equals(state)) {
+				state = "正常";
+			} else {
+				state = "异常";
+			}
+		}
+		Map<String, String> pd = Maps.newHashMap();
+		pd.put("startDate", startDate);
+		pd.put("endDate", endDate);
+		pd.put("departId", departId);
+		pd.put("name", name);
+		pd.put("state", state);
+		return (Long) findObject("SapCheckReportMapper.findUserReportTotal", pd);
+	}
+}

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

@@ -16,8 +16,6 @@ import org.fouram.entity.SapCheckReport;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import com.alibaba.fastjson.JSONObject;
-import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 
@@ -207,106 +205,4 @@ public class SapCheckService extends BaseService {
 		}
 		return false;
 	}
-
-	public JSONObject findUserReportPage(String startDate, String endDate, String departId, String name, String state,
-			Integer pageSize, Integer pageNumber) throws Exception {
-		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, 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);
-		}
-		if (StringUtils.isNotBlank(state)) {
-			if ("1".equals(state)) {
-				state = "正常";
-			} else {
-				state = "异常";
-			}
-		}
-		Map<String, String> pd = Maps.newHashMap();
-		pd.put("startDate", startDate);
-		pd.put("endDate", endDate);
-		pd.put("departId", departId);
-		pd.put("name", name);
-		pd.put("state", state);
-		if (pageSize != null) {
-			pd.put("pageCurrent", String.valueOf(pageSize * (pageNumber - 1)));
-			pd.put("pageSize", String.valueOf(pageSize));
-		}
-		return (List<Map<String, Object>>) findList("SapCheckMapper.findUserReports", pd);
-	}
-
-	@SuppressWarnings("unchecked")
-	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);
-		}
-		Map<String, String> pd = Maps.newHashMap();
-		pd.put("startDate", startDate);
-		pd.put("endDate", endDate);
-		pd.put("departId", departId);
-		pd.put("name", name);
-		pd.put("reportDaySql", getReportDaySql(startDate, endDate));
-
-//		公司 部门 工号	姓名5月25日	5月26日	5月27日	5月28日	5月29日
-		List<String> days = DateUtil.getSubDateList(startDate, endDate);
-		Map<String, Object> headerMap = Maps.newLinkedHashMap();
-		headerMap.put("A", "公司");
-		headerMap.put("B", "部门");
-		headerMap.put("C", "工号");
-		headerMap.put("D", "姓名");
-		for (String day : days) {
-			headerMap.put(day, day);
-		}
-		List<Map<String, Object>> result = Lists.newArrayList(headerMap);
-		List<Map<String, Object>> list = (List<Map<String, Object>>) findList("SapCheckMapper.selectReportDayList", pd);
-		list.stream().forEach(check -> result.add(check));
-		return result;
-	}
-
-	private String getReportDaySql(String startDate, String endDate) throws Exception {
-		String baseSql = "replace(group_concat(case when a.checkinDay = '%s' then a.result else '' end ),',','') as '%s',";
-		List<String> days = DateUtil.getSubDateList(startDate, endDate);
-		String reportDaySql = "";
-		for (String day : days) {
-			reportDaySql += String.format(baseSql, day, day);
-		}
-		reportDaySql = reportDaySql.substring(0, reportDaySql.length() - 1);
-		return reportDaySql;
-	}
-
-	public Long findUserReportTotal(String startDate, String endDate, String departId, String name, String state)
-			throws Exception {
-		if (StringUtils.isNotBlank(departId) && departId.endsWith(",")) {
-			departId = departId.substring(0, departId.length() - 1);
-		}
-		if (StringUtils.isNotBlank(state)) {
-			if ("1".equals(state)) {
-				state = "正常";
-			} else {
-				state = "异常";
-			}
-		}
-		Map<String, String> pd = Maps.newHashMap();
-		pd.put("startDate", startDate);
-		pd.put("endDate", endDate);
-		pd.put("departId", departId);
-		pd.put("name", name);
-		pd.put("state", state);
-		return (Long) findObject("SapCheckMapper.findUserReportTotal", pd);
-	}
-
-	public static JSONObject getPageResult(List<? extends Object> list, Object total) {
-		JSONObject object = new JSONObject();
-		object.put("total", total);
-		object.put("data", list);
-		return object;
-	}
 }