Browse Source

新增当天请假人数接口

zh 4 years ago
parent
commit
0ee32f5f96

+ 5 - 0
boman-web-core/src/main/java/com/boman/web/core/controller/LeaveController.java

@@ -31,4 +31,9 @@ public class LeaveController {
         Map<String, Integer> result = service.statisticByType(yyyy);
         return AjaxResult.success(result);
     }
+
+    @GetMapping("/statistic/count/staticLeave")
+    public AjaxResult staticLeave() {
+        return AjaxResult.success(service.statisticLeave());
+    }
 }

+ 28 - 0
boman-web-core/src/main/java/com/boman/web/core/mapper/LeaveMapper.java

@@ -0,0 +1,28 @@
+package com.boman.web.core.mapper;
+
+import org.apache.ibatis.annotations.SelectProvider;
+
+import javax.xml.crypto.Data;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public interface LeaveMapper {
+
+    @SelectProvider(type = LeaveMapper.SqlProvider.class, method = "statisticLeave")
+    Integer statisticLeave();
+
+    class SqlProvider {
+
+        public String statisticLeave() {
+            Date date = new Date();
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            return "SELECT (SELECT count(*) FROM leavefrom f WHERE f.status = 2 and '" + sdf.format(date) + "' "
+                    + " BETWEEN date_format(f.leavefrom_start_time, \"%Y-%m-%d\" ) "
+                    + " and date_format( f.leavefrom_end_time, \"%Y-%m-%d\" )) "
+                    + " + (SELECT count(*) FROM boman_temp_leaveform t WHERE  t.status = 2 and  '" + sdf.format(date) + "' "
+                    + " BETWEEN date_format(t.leavefrom_start_time, \"%Y-%m-%d\" ) "
+                    + " and date_format(t.leavefrom_end_time, \"%Y-%m-%d\" )) as count "
+                    + " FROM DUAL";
+        }
+    }
+}

+ 6 - 0
boman-web-core/src/main/java/com/boman/web/core/service/leave/LeaveService.java

@@ -16,4 +16,10 @@ public interface LeaveService {
      * @return int
      */
     Map<String, Integer> statisticByType(String yyyy);
+
+    /**
+     * 当天请假人数
+     * @return
+     */
+    Integer statisticLeave();
 }

+ 16 - 0
boman-web-core/src/main/java/com/boman/web/core/service/leave/LeaveServiceImpl.java

@@ -2,9 +2,11 @@ package com.boman.web.core.service.leave;
 
 import com.alibaba.fastjson.JSONObject;
 import com.boman.common.core.utils.DateUtils;
+import com.boman.web.core.mapper.LeaveMapper;
 import com.boman.web.core.service.common.ICommonService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -31,6 +33,9 @@ public class LeaveServiceImpl implements LeaveService {
     @Resource
     private ICommonService commonService;
 
+    @Autowired
+    private LeaveMapper leaveMapper;
+
     /**
      * 功能描述: 直接查询一年的
      *
@@ -68,6 +73,17 @@ public class LeaveServiceImpl implements LeaveService {
         return map;
     }
 
+    /**
+     * 功能描述: 直接查询一年的
+     *
+     * @return int
+     */
+    @Override
+    public Integer statisticLeave() {
+        Integer count = leaveMapper.statisticLeave();
+        return count == null ? 0 : count;
+    }
+
     private List<JSONObject> listByTime(String startTime, String endTime) {
         JSONObject condition = new JSONObject();
         condition.put(LEAVEFROM_START_TIME, startTime);