shudonghui 1 ano atrás
pai
commit
d6d9b21788

+ 2 - 1
sop-api/src/main/java/com/qmth/sop/server/api/TBDingController.java

@@ -147,9 +147,10 @@ public class TBDingController {
             @ApiParam(value = "SOP流水号(模糊查询)", required = false) @RequestParam(required = false) String sopNo,
             @ApiParam(value = "考勤类型", required = false) @RequestParam(required = false) InOutTypeEnum type,
             @ApiParam(value = "考勤结果", required = false) @RequestParam(required = false) DingResultEnum status,
+            @ApiParam(value = "考勤异常数", required = false) @RequestParam(required = false) Long abnormal,
             @ApiParam(value = "分页页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
             @ApiParam(value = "分页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
-        IPage<TBDingAttendanceResult> resultIPage = tBDingService.attendanceQuery(new Page<>(pageNumber, pageSize), serviceId, userName, startTime, endTime, supplierId, custom, sopNo, type, status);
+        IPage<TBDingAttendanceResult> resultIPage = tBDingService.attendanceQuery(new Page<>(pageNumber, pageSize), serviceId, userName, startTime, endTime, supplierId, custom, sopNo, type, status,abnormal);
 
         return ResultUtil.ok(resultIPage);
     }

+ 4 - 3
sop-business/src/main/java/com/qmth/sop/business/bean/result/TBDingAttendanceCountResult.java

@@ -7,6 +7,7 @@ import com.alibaba.excel.annotation.write.style.HeadStyle;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
+import javax.swing.event.DocumentListener;
 import java.io.Serializable;
 
 /**
@@ -27,7 +28,7 @@ public class TBDingAttendanceCountResult implements Serializable {
     @ApiModelProperty(value = "累计人天")
     Long allDays;
     @ApiModelProperty(value = "累计工时")
-    Long allHours;
+    Double allHours;
 
     public Long getTotal() {
         return total;
@@ -53,11 +54,11 @@ public class TBDingAttendanceCountResult implements Serializable {
         this.allDays = allDays;
     }
 
-    public Long getAllHours() {
+    public Double getAllHours() {
         return allHours;
     }
 
-    public void setAllHours(Long allHours) {
+    public void setAllHours(Double allHours) {
         this.allHours = allHours;
     }
 }

+ 2 - 2
sop-business/src/main/java/com/qmth/sop/business/mapper/TBDingMapper.java

@@ -36,11 +36,11 @@ public interface TBDingMapper extends BaseMapper<TBDing> {
 
     TBDingCountResult count(@Param("serviceId") Long serviceId, @Param("createId") Long createId, @Param("userName") String userName, @Param("supplierId") Long supplierId, @Param("custom") String custom, @Param("sopNo") String sopNo, @Param("dpr") DataPermissionDto dpr);
 
-    IPage<TBDingAttendanceResult> attendanceQuery(IPage<Map> iPage, @Param("serviceId") Long serviceId, @Param("userName") String userName, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("supplierId") Long supplierId, @Param("custom") String custom, @Param("sopNo") String sopNo, @Param("type") String type, @Param("status") String status, @Param("dpr")DataPermissionDto dpr);
+    IPage<TBDingAttendanceResult> attendanceQuery(IPage<Map> iPage, @Param("serviceId") Long serviceId, @Param("userName") String userName, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("supplierId") Long supplierId, @Param("custom") String custom, @Param("sopNo") String sopNo, @Param("type") String type, @Param("status") String status, @Param("dpr")DataPermissionDto dpr,@Param("abnormal")Long abnormal);
 
     TBDingAttendanceCountResult attendanceCount(@Param("serviceId") Long serviceId, @Param("userName") String userName, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("supplierId") Long supplierId, @Param("custom") String custom, @Param("sopNo") String sopNo, @Param("dpr")DataPermissionDto dpr);
 
-    List<TBDingAttendanceResult> attendanceQuery(@Param("serviceId") Long serviceId, @Param("userName") String userName, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("supplierId") Long supplierId, @Param("custom") String custom, @Param("sopNo") String sopNo, @Param("type") String type, @Param("status") String status);
+    List<TBDingAttendanceResult> attendanceQuery(@Param("serviceId") Long serviceId, @Param("userName") String userName, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("supplierId") Long supplierId, @Param("custom") String custom, @Param("sopNo") String sopNo, @Param("type") String type, @Param("status") String status,@Param("abnormal")Long abnormal);
 
     /**
      * 根据用户id查询打卡信息

+ 2 - 2
sop-business/src/main/java/com/qmth/sop/business/service/TBDingService.java

@@ -65,11 +65,11 @@ public interface TBDingService extends IService<TBDing> {
 
     TBDingCountResult count(Long serviceId, Long createId, String userName, Long supplierId, String custom, String sopNo);
 
-    IPage<TBDingAttendanceResult> attendanceQuery(IPage<Map> iPage, Long serviceId, String userName, Long startTime, Long endTime, Long supplierId, String custom, String sopNo, InOutTypeEnum type, DingResultEnum status);
+    IPage<TBDingAttendanceResult> attendanceQuery(IPage<Map> iPage, Long serviceId, String userName, Long startTime, Long endTime, Long supplierId, String custom, String sopNo, InOutTypeEnum type, DingResultEnum status,Long abnormal);
 
     TBDingAttendanceCountResult attendanceCount(Long serviceId, String userName, Long startTime, Long endTime, Long supplierId, String custom, String sopNo);
 
-    List<TBDingAttendanceResult> attendanceQuery(Long serviceId, String userName, Long startTime, Long endTime, Long supplierId, String custom, String sopNo, InOutTypeEnum type, DingResultEnum status);
+    List<TBDingAttendanceResult> attendanceQuery(Long serviceId, String userName, Long startTime, Long endTime, Long supplierId, String custom, String sopNo, InOutTypeEnum type, DingResultEnum status,Long abnormal);
 
     /**
      * 根据sop单号构建打卡日期表单

+ 5 - 4
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingServiceImpl.java

@@ -21,6 +21,7 @@ import com.qmth.sop.common.util.FileUtil;
 import com.qmth.sop.common.util.ServletUtil;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.time.DateFormatUtils;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
@@ -446,11 +447,11 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
     }
 
     @Override
-    public IPage<TBDingAttendanceResult> attendanceQuery(IPage<Map> iPage, Long serviceId, String userName, Long startTime, Long endTime, Long supplierId, String custom, String sopNo, InOutTypeEnum type, DingResultEnum status) {
+    public IPage<TBDingAttendanceResult> attendanceQuery(IPage<Map> iPage, Long serviceId, String userName, Long startTime, Long endTime, Long supplierId, String custom, String sopNo, InOutTypeEnum type, DingResultEnum status,Long abnormal) {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         Long userId = requestUser.getId();
         DataPermissionDto dpr = sysUserService.buildUserDataPermission(userId);
-        return this.baseMapper.attendanceQuery(iPage, serviceId, userName, startTime, endTime, supplierId, custom, sopNo, Objects.nonNull(type) ? type.name() : null, Objects.nonNull(status) ? status.name() : null, dpr);
+        return this.baseMapper.attendanceQuery(iPage, serviceId, userName, startTime, endTime, supplierId, custom, sopNo, Objects.nonNull(type) ? type.name() : null, Objects.nonNull(status) ? status.name() : null, dpr,abnormal);
     }
 
     @Override
@@ -462,8 +463,8 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
     }
 
     @Override
-    public List<TBDingAttendanceResult> attendanceQuery(Long serviceId, String userName, Long startTime, Long endTime, Long supplierId, String custom, String sopNo, InOutTypeEnum type, DingResultEnum status) {
-        return this.baseMapper.attendanceQuery(serviceId, userName, startTime, endTime, supplierId, custom, sopNo, Objects.nonNull(type) ? type.name() : null, Objects.nonNull(status) ? status.name() : null);
+    public List<TBDingAttendanceResult> attendanceQuery(Long serviceId, String userName, Long startTime, Long endTime, Long supplierId, String custom, String sopNo, InOutTypeEnum type, DingResultEnum status,Long abnormal) {
+        return this.baseMapper.attendanceQuery(serviceId, userName, startTime, endTime, supplierId, custom, sopNo, Objects.nonNull(type) ? type.name() : null, Objects.nonNull(status) ? status.name() : null,abnormal);
     }
 
     @Override

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/templete/service/impl/TaskLogicServiceImpl.java

@@ -362,7 +362,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         File fileTemp = null;
         try {
             fileTemp = SystemConstant.getFileTempVar(SystemConstant.XLSX_PREFIX);
-            List<TBDingAttendanceResult> tbDingAttendanceResults = tbDingService.attendanceQuery((Long) map.get("serviceId"), (String) map.get("userName"), (Long) map.get("startTime"), (Long) map.get("endTime"), (Long) map.get("supplierId"), (String) map.get("custom"), (String) map.get("sopNo"), (InOutTypeEnum) map.get("type"), (DingResultEnum) map.get("status"));
+            List<TBDingAttendanceResult> tbDingAttendanceResults = tbDingService.attendanceQuery((Long) map.get("serviceId"), (String) map.get("userName"), (Long) map.get("startTime"), (Long) map.get("endTime"), (Long) map.get("supplierId"), (String) map.get("custom"), (String) map.get("sopNo"), (InOutTypeEnum) map.get("type"), (DingResultEnum) map.get("status"),(Long) map.get("abnormal"));
 
 //            tbDingAttendanceResults.forEach(e -> {
 //                //e.setStatus(FlowStatusEnum.convertToEnum(e.getStatus()).getTitle());

+ 31 - 99
sop-business/src/main/resources/mapper/TBDingMapper.xml

@@ -90,97 +90,7 @@
 
         </select>
 
-<!--    <select id="query" resultType="com.qmth.sop.business.bean.result.TBDingCountQueryResult">-->
-<!--        SELECT * from (-->
-<!--        SELECT-->
-<!--        bs.NAME service,-->
-<!--        d.sop_no,-->
-<!--        c.NAME custom,-->
-<!--        ua.province,-->
-<!--        ua.city,-->
-<!--        crm.exam_start_time,-->
-<!--        crm.exam_end_time,-->
-<!--        u.real_name user_name,-->
-<!--        ua.`code` user_no,-->
-<!--        r.`name` role_name,-->
-<!--        s.NAME supplier,-->
-<!--        count( d.id ) attendance,-->
-<!--        SUM( CASE WHEN d.date_type = 'WEEKDAY' THEN 1 ELSE 0 END ) weekdays,-->
-<!--        SUM( CASE WHEN d.date_type = 'WEEKEND' THEN 1 ELSE 0 END ) weekends,-->
-<!--        SUM( CASE WHEN d.date_type = 'LEGAL_HOLIDAYS' THEN 1 ELSE 0 END ) holidays,-->
-<!--        SUM( CASE WHEN d.sign_out_time is not null and d.sign_in_time is not null   THEN TIMESTAMPDIFF(HOUR, DATE_FORMAT(FROM_UNIXTIME(d.sign_out_time), '%Y-%m-%d %H:%i:%s'), DATE_FORMAT(FROM_UNIXTIME(d.sign_in_time), '%Y-%m-%d %H:%i:%s')) ELSE 0 END ) work_hours,-->
-<!--        DATEDIFF(DATE_FORMAT(FROM_UNIXTIME(crm.exam_start_time), '%Y-%m-%d'), DATE_FORMAT(FROM_UNIXTIME(crm.exam_end_time), '%Y-%m-%d'))-count( d.id )+1 violation_days,-->
-<!--        f.`status`,-->
-<!--        sub.real_name submitter,-->
-<!--        f.create_time submission_time ,-->
-<!--        d.service_id,-->
-<!--        f.create_id,-->
-<!--        s.id supplier_id-->
 
-<!--        FROM-->
-<!--        t_b_ding d-->
-<!--        LEFT JOIN sys_user u ON u.id = d.user_id-->
-<!--        LEFT JOIN t_b_user_archives ua ON u.mobile_number = ua.mobile_number-->
-<!--        LEFT JOIN t_b_user_archives_supplier us ON us.user_archives_id = ua.id-->
-<!--        LEFT JOIN t_b_service bs ON bs.id = d.service_id-->
-<!--        LEFT JOIN t_b_sop_info sop ON sop.crm_no = d.crm_no-->
-<!--        AND sop.sop_no = d.sop_no-->
-<!--        LEFT JOIN t_b_engineer_allocation ea ON ea.crm_no = d.crm_no-->
-<!--        AND ea.sop_no = d.sop_no-->
-<!--        LEFT JOIN sys_role r ON ea.role_id = r.id-->
-<!--        LEFT JOIN t_b_crm crm ON crm.crm_no = d.crm_no-->
-<!--        LEFT JOIN sys_custom c ON c.id = sop.custom_id-->
-<!--        LEFT JOIN t_f_flow_approve f ON f.flow_id = d.flow_id-->
-<!--        LEFT JOIN sys_user sub ON sub.id = f.create_id-->
-<!--        LEFT JOIN sys_supplier s ON s.id = us.supplier_id-->
-<!--        GROUP BY-->
-<!--        bs.NAME,-->
-<!--        d.sop_no,-->
-<!--        c.NAME,-->
-<!--        ua.province,-->
-<!--        ua.city,-->
-<!--        crm.exam_start_time,-->
-<!--        crm.exam_end_time,-->
-<!--        u.real_name,-->
-<!--        ua.`code`,-->
-<!--        r.`name`,-->
-<!--        s.NAME,-->
-<!--        f.`status`,-->
-<!--        f.create_id,-->
-<!--        f.create_time,-->
-<!--        d.service_id,-->
-<!--        s.id  ) a-->
-
-<!--        <where>-->
-<!--            <if test="serviceId != null and serviceId != ''">-->
-<!--                and a.service_id = #{serviceId}-->
-<!--            </if>-->
-<!--            <if test="status != null and status != ''">-->
-<!--                and a.status = #{status}-->
-<!--            </if>-->
-<!--            <if test="createId != null and createId != ''">-->
-<!--                and a.create_id = #{create_id}-->
-<!--            </if>-->
-<!--            <if test="userName != null and userName != ''">-->
-<!--                and a.real_name like concat('%', #{userName} , '%')-->
-<!--            </if>-->
-<!--            <if test="supplierId != null and supplierId != ''">-->
-<!--                and a.supplier_id = #{supplierId}-->
-<!--            </if>-->
-<!--            <if test="custom != null and custom != ''">-->
-<!--                and a.name like concat('%', #{custom} , '%')-->
-<!--            </if>-->
-<!--            <if test="sopNo != null and sopNo != ''">-->
-<!--                and a.sop_no like concat('%', #{sopNo} , '%')-->
-<!--            </if>-->
-<!--            <if test="days != null and days != '' ">-->
-<!--                <![CDATA[-->
-<!--               and a.days > #{days}-->
-<!--               ]]>-->
-<!--            </if>-->
-<!--        </where>-->
-
-<!--    </select>-->
 
 
     <select id="count" resultType="com.qmth.sop.business.bean.result.TBDingCountResult">
@@ -313,6 +223,26 @@
             <if test="status != null and status != ''">
                 and a.status = #{status}
             </if>
+            <if test="abnormal != null and abnormal != ''">
+                and a.user_id in (    SELECT x.user_id from(
+
+                SELECT
+
+                d.user_id,sum(case when d.sign_time is null then 1 else 0 end) count
+                FROM
+                (
+                SELECT d.*,d.axis_in_x AS axis_x, d.axis_in_y AS axis_y,d.sign_in_address address, d.sign_in_time sign_time,'IN' AS type FROM t_b_ding d UNION ALL
+                SELECT d.*,d.axis_out_x AS axis_x, d.axis_out_y AS axis_y,d.sign_out_address address, d.sign_out_time sign_time,'OUT' AS type FROM t_b_ding d
+                where
+                d.sign_out_time is not null  or
+                (d.sign_out_time is  null and
+                date_format(from_unixtime(d.create_time/1000),'%Y-%m-%d') != date_format(now(),'%Y-%m-%d'))
+                ) d
+
+                GROUP BY d.user_id
+
+                )x where x.count>=#{abnormal})
+            </if>
             <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
                 <choose>
                     <when test="dpr.hasBusiness">
@@ -341,20 +271,22 @@
     <select id="attendanceCount" resultType="com.qmth.sop.business.bean.result.TBDingAttendanceCountResult">
         SELECT
         count( d.id ) total,
-        SUM( CASE WHEN f.`status`!='FINISH' THEN 1 ELSE 0 END ) abnormal,
-        SUM( CASE WHEN f.`status`='FINISH' THEN 1 ELSE 0 END ) all_days,
-        SUM( CASE WHEN f.`status`='FINISH'  THEN TIMESTAMPDIFF(HOUR, DATE_FORMAT(FROM_UNIXTIME(d.sign_out_time), '%Y-%m-%d %H:%i:%s'), DATE_FORMAT(FROM_UNIXTIME(d.sign_in_time), '%Y-%m-%d %H:%i:%s')) ELSE 0 END ) all_hours
+        sum( CASE WHEN d.sign_in_time IS NULL THEN 1 ELSE 0 END )+ sum( CASE WHEN d.sign_out_time IS NULL THEN 1 ELSE 0 END ) abnormal,
+        SUM( CASE WHEN d.sign_in_time IS NOT NULL AND d.sign_out_time IS NOT NULL THEN 1 ELSE 0 END ) all_days,
+        SUM( CASE WHEN d.sign_in_time IS NOT NULL AND d.sign_out_time IS NOT NULL THEN
+        (d.sign_out_time-d.sign_in_time)
+        ELSE 0
+        END
+        )/1000/60/60 all_hours
         FROM
         t_b_ding d
         LEFT JOIN sys_user u ON u.id = d.user_id
         LEFT JOIN t_b_user_archives ua ON u.mobile_number = ua.mobile_number
         LEFT JOIN t_b_user_archives_supplier us ON us.user_archives_id = ua.id
-        LEFT JOIN t_b_sop_info sop ON sop.crm_no = d.crm_no
-        AND sop.sop_no = d.sop_no
-        LEFT JOIN sys_custom c ON c.id = sop.custom_id
-        LEFT JOIN t_f_flow_approve f ON f.flow_id = d.flow_id
-        LEFT JOIN t_b_service tbs ON d.service_id = tbs.id AND tbs.enable
-        LEFT JOIN t_b_crm tbc ON d.crm_no = tbc.crm_no
+        LEFT JOIN t_b_crm crm ON crm.crm_no = d.crm_no
+        LEFT JOIN sys_custom c ON c.id = crm.custom_id
+
+        LEFT JOIN t_b_service tbs ON d.service_id = tbs.id
 
         <where>