Pārlūkot izejas kodu

导出考勤数据。。。

zhaoxian 4 gadi atpakaļ
vecāks
revīzija
ef7cbdfe5b

+ 22 - 4
module-oa/src/main/java/cn/com/ctop/oa/modules/controller/WechatNoListController.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.oa.modules.controller;
 
 import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.ExportExcelUtils;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.oa.modules.entity.WechatAttendance;
@@ -270,11 +271,14 @@ public class WechatNoListController {
     public void getExcelReport(HttpServletResponse response) {
         Map<String, Object> paramsMap = new HashMap<>();
         List<WechatAttendance> excelData = wechatNoListService.queryAttendanceData(paramsMap);
-        if (excelData.isEmpty()) {
+        List<WechatAttendance> overtimeData = wechatNoListService.queryOverTimeData(paramsMap);
+        if (excelData.isEmpty()||overtimeData.isEmpty()) {
             return;
         }
-        String[] titles = {"姓名", "部门", "考勤日期", "考勤类型", "考勤状态", "考勤时间", "审核状态", "状态时长"};
+        String[] titles = {"姓名", "部门", "考勤日期", "考勤类型", "考勤状态", "考勤时间", "审核状态", "状态时长","审批状态"};
+        String[] overtimeTitles = {"姓名", "部门", "加班日期", "加班时长"};
         List<List<Object>> excelList = new ArrayList<>();
+        List<List<Object>> overtimeExcelList = new ArrayList<>();
         excelData.forEach(data -> {
             List<Object> temp = new ArrayList<>();
             temp.add(data.getUserName());
@@ -285,14 +289,28 @@ public class WechatNoListController {
             temp.add(data.getCheckinTime());
             temp.add(data.getType());
             temp.add(data.getStateDuration());
+            if(!Check.isNull(data.getStatus())){
+                temp.add("1".equals(data.getStatus())?"审批中":"已通过");
+            }else{
+                temp.add("");
+            }
             excelList.add(temp);
         });
+        overtimeData.forEach(data -> {
+            List<Object> temp = new ArrayList<>();
+            temp.add(data.getUserName());
+            temp.add(data.getDepartName());
+            temp.add(data.getCheckinDate());
+            temp.add(data.getOvertime());
+            overtimeExcelList.add(temp);
+        });
         try {
             OutputStream os = response.getOutputStream();
             ExportExcelUtils eeu = new ExportExcelUtils();
             XSSFWorkbook workbook = new XSSFWorkbook();
-            eeu.exportExcelForAttendance(workbook, 0, "考勤", titles, excelList);
-            HttpUtils.setResponseHeader(response, "考勤异常记录.xlsx");
+            eeu.exportExcelForAttendance(workbook, 0, "异常考勤", titles, excelList);
+            eeu.exportExcel(workbook, 1, "加班考勤", overtimeTitles, overtimeExcelList);
+            HttpUtils.setResponseHeader(response, "考勤记录.xlsx");
             workbook.write(os);
             os.flush();
             os.close();

+ 8 - 0
module-oa/src/main/java/cn/com/ctop/oa/modules/entity/WechatAttendance.java

@@ -26,6 +26,10 @@ public class WechatAttendance {
      */
     private String departName;
     /**
+     * 审批状态 1-审批中;2-已通过;
+     */
+    private String status;
+    /**
      * 部门编号
      */
     private String departId;
@@ -53,5 +57,9 @@ public class WechatAttendance {
      * 状态时长
      */
     private String stateDuration;
+    /**
+     * 加班时长
+     */
+    private String overtime;
 
 }

+ 2 - 0
module-oa/src/main/java/cn/com/ctop/oa/modules/mapper/WechatNoListMapper.java

@@ -18,4 +18,6 @@ import java.util.Map;
 public interface WechatNoListMapper extends BaseMapper<WechatNoList> {
 
     List<WechatAttendance> queryAttendanceData(Map<String, Object> paramsMap);
+
+    List<WechatAttendance> queryOverTimeData(Map<String, Object> paramsMap);
 }

+ 28 - 0
module-oa/src/main/java/cn/com/ctop/oa/modules/mapper/xml/WechatNoListMapper.xml

@@ -11,6 +11,7 @@
            DATE_FORMAT(ck.checkin_time,'%Y-%m-%d') AS checkinDate,
            ck.checkin_type AS checkinType,
            ck.exception_type AS exceptionType,
+           nl.status as status,
            DATE_FORMAT(ck.checkin_time, '%Y-%m-%d %H:%i:%s') AS checkinTime,
         case  when nl.type !='' THEN  nl.type
         when ck.checkin_type ='上班打卡' AND exception_type ='时间异常' then '迟到'
@@ -44,4 +45,31 @@
     </select>
 
 
+    <select id="queryOverTimeData" resultType="cn.com.ctop.oa.modules.entity.WechatAttendance">
+        SELECT
+        us.user_id AS userId,
+        us.user_name AS userName,
+        dpt.depart_id AS departId,
+        dpt.depart_name AS departName,
+        DATE_FORMAT(ck.checkin_time,'%Y-%m-%d') AS checkinDate,
+        CONCAT(ck.overtime,' h') AS overtime
+        FROM ctop_wechat_checkin_data as ck
+        LEFT JOIN ctop_wechat_user_list as us ON ck.user_id = us.user_id
+        LEFT JOIN ctop_wechat_department as dpt ON dpt.depart_id = us.depart_id
+        WHERE ck.overtime_or_not = 1
+        <if test="userId != null and userId != '' " >
+            and us.user_id = #{userId}
+        </if>
+        <if test="departId != null and departId != '' " >
+            and dpt.depart_id = #{departId}
+        </if>
+        <if test="startTime != null">
+            and ck.checkin_time &gt;= #{startTime}
+        </if>
+        <if test="stopTime != null ">
+            and ck.checkin_time &lt;= #{stopTime}
+        </if>
+        order by us.depart_id,us.user_name ,ck.checkin_time
+    </select>
+
 </mapper>

+ 2 - 0
module-oa/src/main/java/cn/com/ctop/oa/modules/service/IWechatNoListService.java

@@ -40,4 +40,6 @@ public interface IWechatNoListService extends IService<WechatNoList> {
     void getNoDateByNo(String starttime, String endtime);
 
     List<WechatAttendance> queryAttendanceData(Map<String, Object> paramsMap);
+
+    List<WechatAttendance> queryOverTimeData(Map<String, Object> paramsMap);
 }

+ 5 - 0
module-oa/src/main/java/cn/com/ctop/oa/modules/service/impl/WechatNoListServiceImpl.java

@@ -276,4 +276,9 @@ public class WechatNoListServiceImpl extends ServiceImpl<WechatNoListMapper, Wec
     public List<WechatAttendance> queryAttendanceData(Map<String, Object> paramsMap) {
         return wechatNoListMapper.queryAttendanceData(paramsMap);
     }
+
+    @Override
+    public List<WechatAttendance> queryOverTimeData(Map<String, Object> paramsMap) {
+        return wechatNoListMapper.queryOverTimeData(paramsMap);
+    }
 }