liupeng il y a 4 ans
Parent
commit
64e462236d

+ 31 - 9
code/sapparent/sapcms/src/main/java/org/fouram/controller/ApiController.java

@@ -16,6 +16,8 @@ import org.fouram.core.plugin.weixin.cp.core.WXCpMailList;
 import org.fouram.core.util.AppUtil;
 import org.fouram.core.util.AppUtil.ResultConstant;
 import org.fouram.core.util.ConfConfig;
+import org.fouram.core.util.DateUtil;
+import org.fouram.core.util.ExcelExportUtil;
 import org.fouram.core.util.LoggerUtil;
 import org.fouram.entity.SapOrg;
 import org.fouram.entity.SapUser;
@@ -98,8 +100,8 @@ public class ApiController extends BaseController {
 			SapOrg sapOrg = null;
 			if (StringUtils.isBlank(departId) || WebConstants.TOP_DEPART.toString().equals(departId)) {
 				departId = WebConstants.TOP_DEPART.toString();
-				sapOrg = SapOrg.builder().id(WebConstants.TOP_DEPART.toString()).sapName(WebConstants.TOP_DEPART_NAME).level("1")
-						.build();
+				sapOrg = SapOrg.builder().id(WebConstants.TOP_DEPART.toString()).sapName(WebConstants.TOP_DEPART_NAME)
+						.level("1").build();
 			} else {
 				sapOrg = sapOrgService.selectById(departId);
 			}
@@ -156,7 +158,7 @@ public class ApiController extends BaseController {
 			return AppUtil.error(ResultConstant.WEB_ERR_MSG);
 		}
 	}
-	
+
 	/**
 	 * 查询离职员工列表
 	 *
@@ -175,7 +177,7 @@ public class ApiController extends BaseController {
 			return AppUtil.error(ResultConstant.WEB_ERR_MSG);
 		}
 	}
-	
+
 	/**
 	 * 删除离职员工
 	 *
@@ -189,11 +191,11 @@ public class ApiController extends BaseController {
 		}
 		try {
 			String userId = getPageData().getString("userId");
-			if(StringUtils.isBlank(userId)) {
+			if (StringUtils.isBlank(userId)) {
 				return AppUtil.error("参数用户ID不可以为空");
 			}
 			SapUser sapUser = sapUserService.selectByUserId(userId);
-			if(sapUser.getDelFlag().intValue() != DelFlagEnum.UNABLE.intValue()) {
+			if (sapUser.getDelFlag().intValue() != DelFlagEnum.UNABLE.intValue()) {
 				return AppUtil.error("该用户ID不是离职数据");
 			}
 			// 操作用户ID
@@ -219,7 +221,7 @@ public class ApiController extends BaseController {
 		}
 		return true;
 	}
-	
+
 	@RequestMapping(value = "/findDepartJSON", produces = "application/json;charset=utf-8")
 	@ResponseBody
 	public Object findDepartJSON(HttpServletRequest request) {
@@ -230,8 +232,7 @@ public class ApiController extends BaseController {
 			return AppUtil.error(ResultConstant.WEB_ERR_MSG);
 		}
 	}
-	
-	
+
 	@RequestMapping(value = "/findUserReports", produces = "application/json;charset=utf-8")
 	@ResponseBody
 	public Object findUsers(HttpServletRequest request) {
@@ -248,4 +249,25 @@ public class ApiController extends BaseController {
 		}
 	}
 
+	@SuppressWarnings("unchecked")
+	@RequestMapping(value = "/exportUserReportExcel")
+	public Object exportUserReportExcel() {
+		try {
+			// 开始时间、结束时间、 部门、姓名
+			String startDate = getPageData().getString("startDate");
+			String endDate = getPageData().getString("endDate");
+			String departId = getPageData().getString("departId");
+			String name = getPageData().getString("name");
+			Object object = sapCheckService.findUserReports(startDate, endDate, departId, name);
+			List<Map<String, Object>> dataList = (List<Map<String, Object>>) object;
+			String filePath = "/public/excel/userReport" + DateUtil.getTimeStamp() + ".xlsx";
+			String haveFilePath = "/public/excel/userReport.xlsx";
+			ExcelExportUtil.exportExcelFile(getRootPath() + haveFilePath, dataList, getRootPath() + filePath, 3);
+			return AppUtil.success(filePath, null);
+		} catch (Exception e) {
+			LoggerUtil.error(e);
+			return AppUtil.error(AppUtil.ResultConstant.WEB_ERR_MSG);
+		}
+	}
+
 }

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


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


+ 4 - 2
code/sapparent/sapservice/src/main/java/org/fouram/mapper/SapCheckMapper.xml

@@ -158,8 +158,10 @@
 		delete from sap_checkout_end where id = #{id}
 	</update>
 	
-	<select id="findUserReports" resultType="Map">
-		SELECT a.*,c.firstDepartName,c.secondDepartName 
+	<select id="findUserReports" resultType="java.util.LinkedHashMap">
+		SELECT a.id,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 b.weekday = 1 and a.checkinDay=b.checkinDay and a.userId = c.userId
 		<if test="departId != null and departId != ''">