liupeng 4 years ago
parent
commit
95f081c479

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

@@ -33,6 +33,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 
+import com.alibaba.fastjson.JSON;
 import com.google.common.collect.Maps;
 
 import me.chanjar.weixin.cp.bean.WxCpOauth2UserInfo;
@@ -267,6 +268,35 @@ public class ApiController extends BaseController {
 			String hzFilePath = "/public/excel/userReport" + DateUtil.getTimeStamp() + ".xlsx";
 			List<Map<String, Object>> hzList = sapCheckService.selectReportDayList(dto.getStartDate(), dto.getEndDate(),
 					dto.getDepartId(), dto.getName());
+			LoggerUtil.info("hz:" + hzList.size());
+			LoggerUtil.info("hz:" + JSON.toJSONString(hzList.get(0)));
+			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.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());
+			LoggerUtil.info("hz:" + hzList.size());
+			LoggerUtil.info("hz:" + JSON.toJSONString(hzList.get(0)));
 			ExcelExportUtil.exportExcelFile(getRootPath() + ysFilePath, hzList, getRootPath() + hzFilePath, 1, 0);
 			ysFilePath = hzFilePath;
 			// 明细

+ 13 - 6
code/sapparent/sapservice/src/main/java/org/fouram/mapper/SapCheckMapper.xml

@@ -75,12 +75,6 @@
 		where EXISTS (SELECT 1 from sap_checkin_option o where a.userId = o.userId)
 		order by a.userId ASC, b.checkinDay asc;
 	</insert>
-	<select id="selectReportDayList" resultType="Map">
-		SELECT a.userId, a.name, ${reportDaySql}
-		from sap_check_report a, sap_checkdate b 
-		where a.checkinDay=b.checkinDay and a.checkinDay >= #{startDay} and a.checkinDay &lt;= #{endDay}
-		group by a.userId, a.name;
-	</select>
 	
 	<update id="updateHrsdWorkTime">
 		update sap_check_report set workTime = '10:00' where groupName like '%华人时代%' 
@@ -143,6 +137,19 @@
 		delete from sap_checkout_end where id = #{id}
 	</update>
 	
+	<select id="selectReportDayList" resultType="Map">
+		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,