Bläddra i källkod

Merge remote-tracking branch 'origin/qianshan_data_bureau' into qianshan_data_bureau

shiqian 4 år sedan
förälder
incheckning
5bc512397c

+ 11 - 6
boman-modules/boman-gen/src/main/java/com/boman/gen/service/TableSqlServiceImpl.java

@@ -51,8 +51,10 @@ public class TableSqlServiceImpl implements ITableSqlService {
             return AjaxResult.error("缺少表id");
         }
         GenTable genTable = genTableMapper.selectGenTableById(tableSql.getTableId());
+        //表描述
+        String tableComment = genTable.getTableComment();
         String tableName = genTable.getTableName();
-        tableSql.setCreateSql(createSql(tableSql, tableName));
+        tableSql.setCreateSql(createSql(tableSql, tableComment,tableName));
         tableSql.setCreateBy(SecurityUtils.getUsername());
         tableSql.setCreateLog(DateUtils.getTime() + " " + SecurityUtils.getUsername() + " 创建表 " + tableName);
         tableSqlMapper.insertTableSql(tableSql);
@@ -68,8 +70,10 @@ public class TableSqlServiceImpl implements ITableSqlService {
     @Override
     public AjaxResult reloadTableSql(TableSql tableSql) {
         GenTable genTable = genTableMapper.selectGenTableById(tableSql.getTableId());
+        //表描述
+        String tableComment = genTable.getTableComment();
         String tableName = genTable.getTableName();
-        tableSql.setCreateSql(createSql(tableSql, tableName));
+        tableSql.setCreateSql(createSql(tableSql, tableComment,tableName));
         String createLog = tableSql.getCreateLog();
         StringBuffer sb = new StringBuffer(createLog);
         sb.append("\r\n").append(DateUtils.getTime()).append(" ").append(SecurityUtils.getUsername()).append("刷新创建语句");
@@ -137,18 +141,19 @@ public class TableSqlServiceImpl implements ITableSqlService {
      * 生成建表语句
      *
      * @param tableSql
-     * @param tableName
+     * @param tableComment
      * @return
      */
-    private String createSql(TableSql tableSql, String tableName) {
+    private String createSql(TableSql tableSql,String tableComment,String tableName) {
         //根据表id查询所有字段
         List<GenTableColumn> genTableColumns = genTableColumnMapper.selectGenTableColumnListByTableId(tableSql.getTableId());
         //定义主键id
         String primaryKey = null;
         //拼接建表语句
         StringBuffer sb = new StringBuffer("create table if not exists ");
-        String trimName = StringUtils.trim(tableName);
-        sb.append(trimName).append(" (\r\n");
+        String trimName = StringUtils.trim(tableComment);
+        String tableNameTrim = StringUtils.trim(tableName);
+        sb.append(tableNameTrim).append(" (\r\n");
         for (GenTableColumn genTableColumn : genTableColumns) {
             if (!"HR".equals(genTableColumn.getHtmlType())){
                 sb.append("`").append(StringUtils.trim(genTableColumn.getColumnName())).append("` ").append(StringUtils.trim(genTableColumn.getColumnType()));

+ 1 - 1
boman-modules/boman-gen/src/main/resources/bootstrap.yml

@@ -9,7 +9,7 @@ spring:
     name: boman-gen
   profiles:
     # 环境配置
-    active: dev
+    active: test
   cloud:
     nacos:
       discovery:

+ 25 - 0
boman-web-core/src/main/java/com/boman/web/core/controller/AttendanceController.java

@@ -70,10 +70,35 @@ public class AttendanceController {
 
     /**
      * 功能描述: 根据tableName和userId查找当月考勤详细记录
+     *
      * @return com.boman.domain.dto.AjaxResult
      */
     @PostMapping("/detailedRecord")
     public AjaxResult detailedRecord(@RequestBody FormDataDto dto) {
         return service.detailedRecord(dto);
     }
+
+    /**
+     * 按月统计人员考勤信息
+     *
+     * @param date 传入时间 年-月
+     * @return
+     */
+    @GetMapping("/statistics/{date}")
+    public AjaxResult statisticsByMonth(@PathVariable("date") String date) {
+        return service.statisticsByMonth(date);
+    }
+
+
+    /**
+     * 查询用户某月的上班打卡时间
+     *
+     * @param date   查询的年-月
+     * @param userId 用户id
+     * @return
+     */
+    @GetMapping("/findDate/{date}/{userId}")
+    public AjaxResult findDate(@PathVariable("date") String date, @PathVariable("userId") Long userId) {
+        return service.findDate(date, userId);
+    }
 }

+ 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";
+        }
+    }
+}

+ 46 - 0
boman-web-core/src/main/java/com/boman/web/core/mapper/StandardlyMapper.java

@@ -188,6 +188,52 @@ public interface StandardlyMapper {
     @Select("select * from ${tableName} order by create_time desc limit 1")
     JSONObject getNewest(@Param("tableName") String tableName);
 
+    /**
+     * 按月统计人员考勤信息
+     * @param date
+     * @return
+     */
+    @Select("<script>" +
+            "SELECT\n" +
+            "t.attendance_table_username as userName,\n" +
+            "d.dept_name as deptName,\n" +
+            "sum(if(attendance_table_leave_or = 'Y','1','0')) as attendanceTableLeaveOrSum,\n" +
+            "sum(if(attendance_table_late = 'Y','1','0')) as attendanceTableLateSum,\n" +
+            "sum(if(attendance_table_leave = 'Y','1','0')) as attendanceTableLeaveSum,\n" +
+            "DATE_FORMAT(t.create_time,'%Y-%m') as date\n" +
+            "FROM  \n" +
+            "attendance_table t\n" +
+            "LEFT JOIN sys_dept d ON d.id = t.dept_id \n" +
+            "<where>" +
+            "1=1 " +
+            "<if test='date!=null'>"+
+            "DATE_FORMAT(t.create_time,'%Y-%m') = DATE_FORMAT(#{date},'%Y-%m') \n" +
+            "</if>"+
+            "</where>" +
+            "GROUP BY\n" +
+            "t.user_id" +
+            "</script>")
+    List<JSONObject> statisticsByMonth(@Param("date") String date);
+
+    /**
+     * 查询用户某月的上班打卡时间
+     * @param date
+     * @param userId
+     * @return
+     */
+
+    @Select("SELECT\n" +
+            "\tattendance_table_work as attendanceTableWork,\n" +
+            "\tattendance_table_offwork AS attendanceTableOffwork,\n" +
+            "\tattendance_table_work_pm AS attendanceTableWorkPm,\n" +
+            "\tattendance_table_offwork_pm as  attendanceTableOffworkPm\n" +
+            "FROM\n" +
+            "\tattendance_table \n" +
+            "WHERE\n" +
+            "\tDATE_FORMAT( create_time, '%Y-%m' ) = #{date} \n" +
+            "\tAND user_id = #{userId}")
+    List<JSONObject> findDate(@Param("date")String date, @Param("userId")Long userId);
+
     @SuppressWarnings("unchecked")
     class SqlProvider {
         static final String[] READONLY_COLUMNS = new String[]{"OWNERID", "OWNERNAME", "OWNERENAME", "CREATIONDATE", "ID"};

+ 15 - 0
boman-web-core/src/main/java/com/boman/web/core/service/attendance/AttendanceService.java

@@ -59,4 +59,19 @@ public interface AttendanceService {
      * @return com.alibaba.fastjson.JSONObject
      */
     JSONObject clockOn(ClockOnDto dto);
+
+    /**
+     * 按月统计人员考勤信息
+     * @param date
+     * @return
+     */
+    AjaxResult statisticsByMonth(String date);
+
+    /**
+     * 查询用户某月的上班打卡时间
+     * @param date
+     * @param userId
+     * @return
+     */
+    AjaxResult findDate(String date,Long userId);
 }

+ 27 - 0
boman-web-core/src/main/java/com/boman/web/core/service/attendance/AttendanceServiceImpl.java

@@ -11,6 +11,7 @@ import com.boman.domain.constant.FormDataConstant;
 import com.boman.domain.dto.AjaxResult;
 import com.boman.domain.dto.ClockOnDto;
 import com.boman.domain.dto.FormDataDto;
+import com.boman.web.core.mapper.StandardlyMapper;
 import com.boman.web.core.service.TableServiceCmdService;
 import com.boman.web.core.service.attendance.rules.AttendanceRulesService;
 import com.boman.web.core.service.common.ICommonService;
@@ -19,6 +20,7 @@ import com.boman.web.core.utils.AuthUtils;
 import com.google.common.collect.Lists;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -54,6 +56,8 @@ public class AttendanceServiceImpl implements AttendanceService {
     private TableServiceCmdService cmdService;
     @Resource
     private IBaseSelectService selectService;
+    @Autowired
+    private StandardlyMapper standardlyMapper;
 
     /**
      * 功能描述: 根据tableName和userId查找当月考勤
@@ -295,6 +299,29 @@ public class AttendanceServiceImpl implements AttendanceService {
         return commitData;
     }
 
+    /**
+     * 按月统计人员考勤信息
+     * @param date
+     * @return
+     */
+    @Override
+    public AjaxResult statisticsByMonth(String date) {
+        List<JSONObject> jsonObjects = standardlyMapper.statisticsByMonth(date);
+        return AjaxResult.success(jsonObjects);
+    }
+
+    /**
+     * 查询用户某月的上班打卡时间
+     * @param date
+     * @param userId
+     * @return
+     */
+    @Override
+    public AjaxResult findDate(String date, Long userId) {
+        List<JSONObject>  jsonObjects= standardlyMapper.findDate(date, userId);
+        return AjaxResult.success(jsonObjects);
+    }
+
     /**
      * 功能描述: 保存打卡信息
      *

+ 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);