Browse Source

导入用户打卡数据开发第二版,导入数据库再做处理

anderx 1 year ago
parent
commit
e0656bd1f2

+ 14 - 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java

@@ -7,6 +7,7 @@ import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import com.ruoyi.system.domain.selectUserClockInput;
 import org.apache.commons.lang3.ArrayUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -302,8 +303,8 @@ public class SysUserController extends BaseController
      * 考勤与打卡核对表
      */
     @GetMapping("/selectUserClock")
-    public AjaxResult selectUserClock(@RequestParam(name = "status", required = false)Integer status) {
-        return AjaxResult.success(userService.selectUserClock(status));
+    public AjaxResult selectUserClock(selectUserClockInput in) {
+        return AjaxResult.success(userService.selectUserClock(in));
     }
 
     /**
@@ -314,4 +315,15 @@ public class SysUserController extends BaseController
 
         return AjaxResult.success(userService.UserClockDetails(id));
     }
+
+
+    /**
+     * 批量更新考勤
+     * @param type 0缺卡处理 1非加班 2加班
+     */
+    @PostMapping("/updateAllUserClock")
+    public AjaxResult updateAllUserClock(@RequestParam("type") Integer type) {
+        userService.updateAllUserClock(type);
+        return AjaxResult.success();
+    }
 }

+ 32 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/selectUserClockInput.java

@@ -0,0 +1,32 @@
+package com.ruoyi.system.domain;
+
+public class selectUserClockInput {
+    private Integer status;
+    private Integer clockStatus;
+
+    private Long userId;
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public Integer getClockStatus() {
+        return clockStatus;
+    }
+
+    public void setClockStatus(Integer clockStatus) {
+        this.clockStatus = clockStatus;
+    }
+}

+ 5 - 1
ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserRecordMapper.java

@@ -2,6 +2,7 @@ package com.ruoyi.system.mapper;
 
 import com.ruoyi.system.domain.UserRecord;
 import com.ruoyi.system.domain.UserRecordOut;
+import com.ruoyi.system.domain.selectUserClockInput;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -27,5 +28,8 @@ public interface UserRecordMapper {
     int updateByPrimaryKey(UserRecord record);
 
 
-    List<UserRecordOut> selectUserClock(@Param("userId") Long userId, @Param("status") Integer status);
+    List<UserRecordOut> selectUserClock(selectUserClockInput in);
+
+
+    void updateTypeDuration(@Param("userId") Long userId, @Param("type") Integer type);
 }

+ 8 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java

@@ -7,6 +7,7 @@ import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.system.domain.UserClockDtails;
 import com.ruoyi.system.domain.UserRecord;
 import com.ruoyi.system.domain.UserRecordOut;
+import com.ruoyi.system.domain.selectUserClockInput;
 
 /**
  * 用户 业务层
@@ -219,7 +220,13 @@ public interface ISysUserService
 
     void pushUserClock(List<Map<Integer, String>> maps);
 
-    List<UserRecordOut> selectUserClock(Integer status);
+    List<UserRecordOut> selectUserClock(selectUserClockInput in);
 
     UserRecordOut UserClockDetails(Long id);
+
+    /**
+     *
+     * @param type 0缺卡处理 1非加班 2加班
+     */
+    void updateAllUserClock(Integer type);
 }

+ 8 - 3
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java

@@ -819,9 +819,9 @@ public class SysUserServiceImpl implements ISysUserService
     }
 
     @Override
-    public List<UserRecordOut> selectUserClock(Integer status) {
-        Long userId=SecurityUtils.getUserId();
-        return  userRecordMapper.selectUserClock(userId,status);
+    public List<UserRecordOut> selectUserClock(selectUserClockInput in) {
+        in.setUserId(SecurityUtils.getUserId());
+        return  userRecordMapper.selectUserClock(in);
     }
 
 
@@ -880,4 +880,9 @@ public class SysUserServiceImpl implements ISysUserService
         return out;
     }
 
+    @Override
+    public void updateAllUserClock(Integer type) {
+        userRecordMapper.updateTypeDuration(SecurityUtils.getUserId(),type);
+    }
+
 }

+ 23 - 0
ruoyi-system/src/main/resources/mapper/UserRecordMapper.xml

@@ -145,6 +145,7 @@
         where   id = #{id,jdbcType=BIGINT} 
     </update>
 
+
     <resultMap id="OutMap" type="com.ruoyi.system.domain.UserRecordOut">
         <id property="id" column="id" jdbcType="BIGINT"/>
         <result property="ddUserId" column="dd_user_id" jdbcType="BIGINT"/>
@@ -172,5 +173,27 @@
         <if test="status != null">
             and a.status = #{status,jdbcType=INTEGER}
         </if>
+        <if test="clockStatus != null">
+            and a.clock_status = #{clockStatus,jdbcType=INTEGER}
+        </if>
     </select>
+
+    <update id="updateTypeDuration">
+        update user_record
+        set
+        <if test="type == 0 or type == 1">
+            status = 2,
+            check_duration = 7.5
+        </if>
+        <if test="type == 2">
+            check_duration = sum_duration
+        </if>
+        where create_id = #{userId,jdbcType=BIGINT}
+        <if test="type ==0">
+            and status = 1
+        </if>
+        <if test="type ==1 or type  ==2">
+            and status = 0
+        </if>
+    </update>
 </mapper>