فهرست منبع

新增考勤异常批量审核接口

wangliang 1 سال پیش
والد
کامیت
2f47f28fab

+ 2 - 0
sop-business/src/main/java/com/qmth/sop/business/activiti/service/impl/ActivitiServiceImpl.java

@@ -165,6 +165,7 @@ public class ActivitiServiceImpl implements ActivitiService {
      * @return
      */
     @Override
+    @Transactional
     public Map<String, Object> taskApprove(FlowApproveParam flowApproveParam) throws InterruptedException {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         Map<String, Object> map = new HashMap<>();
@@ -394,6 +395,7 @@ public class ActivitiServiceImpl implements ActivitiService {
      * @return
      */
     @Override
+    @Transactional
     public Map<String, Object> formPropertiesGet(String flowDeploymentId,
                                                  Long flowId,
                                                  Long taskId) {

+ 30 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TBDingApplyService.java

@@ -7,6 +7,7 @@ import com.qmth.sop.business.bean.result.DingApplyUnDoneResult;
 import com.qmth.sop.business.entity.TBDingApply;
 import com.qmth.sop.common.enums.DingExceptionApproveEnum;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -70,4 +71,33 @@ public interface TBDingApplyService extends IService<TBDingApply> {
      * @return
      */
     Boolean flowApprove(Long taskId, DingExceptionApproveEnum dingExceptionApprove, Long userId) throws InterruptedException;
+
+    /**
+     * 更新考勤异常打卡时间
+     *
+     * @param dingExceptionNo
+     * @return
+     */
+    Boolean updateDingExceptionTime(String dingExceptionNo);
+
+    /**
+     * 考勤异常审核接口
+     *
+     * @param taskIds
+     * @param dingExceptionApprove
+     * @param userId
+     * @return
+     */
+    Boolean flowBatchApprove(List<Long> taskIds, DingExceptionApproveEnum dingExceptionApprove, Long userId) throws InterruptedException;
+
+    /**
+     * 审批公用方法
+     *
+     * @param taskId
+     * @param userId
+     * @param dingExceptionApprove
+     * @return
+     * @throws InterruptedException
+     */
+    public Boolean taskApprove(Long taskId, Long userId, DingExceptionApproveEnum dingExceptionApprove) throws InterruptedException;
 }

+ 66 - 2
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingApplyServiceImpl.java

@@ -16,10 +16,12 @@ import com.qmth.sop.business.service.BasicAttachmentService;
 import com.qmth.sop.business.service.TBDingApplyService;
 import com.qmth.sop.business.service.TBDingService;
 import com.qmth.sop.business.service.TFCustomFlowEntityService;
+import com.qmth.sop.common.contant.SpringContextHolder;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.DingExceptionApproveEnum;
 import com.qmth.sop.common.enums.ExceptionResultEnum;
 import com.qmth.sop.common.enums.FlowApprovePassEnum;
+import com.qmth.sop.common.enums.InOutTypeEnum;
 import com.qmth.sop.common.util.ServletUtil;
 import org.activiti.engine.TaskService;
 import org.activiti.engine.task.Task;
@@ -154,16 +156,78 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
      * @param dingExceptionApprove
      * @param userId
      * @return
+     * @throws InterruptedException
      */
     @Override
+    @Transactional
     public Boolean flowApprove(Long taskId, DingExceptionApproveEnum dingExceptionApprove, Long userId) throws InterruptedException {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         userId = Objects.nonNull(sysUser) ? sysUser.getId() : userId;
+        TBDingApplyService tbDingApplyService = SpringContextHolder.getBean(TBDingApplyService.class);
+        return tbDingApplyService.taskApprove(taskId, userId, dingExceptionApprove);
+    }
+
+    /**
+     * 更新考勤异常打卡时间
+     *
+     * @param dingExceptionNo
+     * @return
+     */
+    @Override
+    @Transactional
+    public Boolean updateDingExceptionTime(String dingExceptionNo) {
+        TBDingApply tbDingApply = this.getOne(new QueryWrapper<TBDingApply>().lambda().eq(TBDingApply::getDingExceptionNo, dingExceptionNo));
+        Optional.ofNullable(tbDingApply).orElseThrow(() -> ExceptionResultEnum.DING_APPLY_NO_DATA.exception());
+
+        TBDing tbDing = tbDingService.getById(tbDingApply.getDingId());
+        Optional.ofNullable(tbDing).orElseThrow(() -> ExceptionResultEnum.DING_NO_DATA.exception());
+
+        if (tbDingApply.getType() == InOutTypeEnum.IN) {
+            tbDing.setSignInTime(tbDingApply.getApplyTime());
+        } else if (tbDingApply.getType() == InOutTypeEnum.OUT) {
+            tbDing.setSignOutTime(tbDingApply.getApplyTime());
+        }
+        return tbDingService.updateById(tbDing);
+    }
+
+    /**
+     * 考勤异常审核接口
+     *
+     * @param taskIds
+     * @param dingExceptionApprove
+     * @param userId
+     * @return
+     * @throws InterruptedException
+     */
+    @Override
+    @Transactional
+    public Boolean flowBatchApprove(List<Long> taskIds, DingExceptionApproveEnum dingExceptionApprove, Long userId) throws InterruptedException {
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        userId = Objects.nonNull(sysUser) ? sysUser.getId() : userId;
+        TBDingApplyService tbDingApplyService = SpringContextHolder.getBean(TBDingApplyService.class);
+        for (Long l : taskIds) {
+            tbDingApplyService.taskApprove(l, userId, dingExceptionApprove);
+        }
+        return true;
+    }
+
+    /**
+     * 审批公用方法
+     *
+     * @param taskId
+     * @param userId
+     * @param dingExceptionApprove
+     * @return
+     * @throws InterruptedException
+     */
+    public Boolean taskApprove(Long taskId, Long userId, DingExceptionApproveEnum dingExceptionApprove) throws InterruptedException {
         Task task = taskService.createTaskQuery().taskId(String.valueOf(taskId)).singleResult();
         Optional.ofNullable(task).orElseThrow(() -> ExceptionResultEnum.FLOW_TASK_NO_DATA.exception());
 
         TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(new QueryWrapper<TFCustomFlowEntity>().lambda().eq(TFCustomFlowEntity::getFlowId, Long.parseLong(task.getProcessInstanceId())));
-        activitiService.taskApprove(new FlowApproveParam(taskId, FlowApprovePassEnum.PASS, Arrays.asList(String.valueOf(sysUser.getId())), tfCustomFlowEntity.getCrmNo(), dingExceptionApprove.getTitle()));
-        return true;
+        activitiService.taskApprove(new FlowApproveParam(taskId, FlowApprovePassEnum.PASS, Arrays.asList(String.valueOf(userId)), tfCustomFlowEntity.getCrmNo(), dingExceptionApprove.getTitle()));
+
+        TBDingApplyService tbDingApplyService = SpringContextHolder.getBean(TBDingApplyService.class);
+        return tbDingApplyService.updateDingExceptionTime(tfCustomFlowEntity.getCode());
     }
 }

+ 11 - 1
sop-business/src/main/resources/db/log/wangliang_update_log.sql

@@ -720,4 +720,14 @@ SET name='待审核-拒绝', url='Reject', `type`='LINK', parent_id=27, `sequenc
 WHERE id=137;
 INSERT INTO sys_privilege
 (id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
-VALUES(3021, '考勤异常审核接口', '/api/admin/ding/exception/apply/flow/approve', 'URL', 26, 4, 'AUTH', NULL, 1, 1, 0);
+VALUES(3021, '考勤异常审核接口', '/api/admin/ding/exception/apply/flow/approve', 'URL', 26, 4, 'AUTH', NULL, 1, 1, 0);
+
+UPDATE sys_privilege
+SET name='待审核-批量通过', url='BatchPass', `type`='BUTTON', parent_id=27, `sequence`=1, property='AUTH', related='3017,3022', enable=1, default_auth=0, front_display=1
+WHERE id=132;
+UPDATE sys_privilege
+SET name='待审核-批量拒绝', url='BatchReject', `type`='BUTTON', parent_id=27, `sequence`=2, property='AUTH', related='3017,3022', enable=1, default_auth=0, front_display=1
+WHERE id=135;
+INSERT INTO sys_privilege
+(id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
+VALUES(3022, '考勤异常批量审核接口', '/api/admin/ding/exception/apply/flow/batch/approve', 'URL', 26, 5, 'AUTH', NULL, 1, 1, 0);

+ 4 - 0
sop-common/src/main/java/com/qmth/sop/common/enums/ExceptionResultEnum.java

@@ -73,6 +73,10 @@ public enum ExceptionResultEnum {
 
     FLOW_APPROVE_LOG_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000023, "流程没有审批日志数据"),
 
+    DING_APPLY_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000024, "没有考勤异常申请数据"),
+
+    DING_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000025, "没有考勤数据"),
+
     /**
      * 401
      */

+ 10 - 0
sop-server/src/main/java/com/qmth/sop/server/api/TBDingApplyController.java

@@ -21,6 +21,7 @@ import javax.validation.Valid;
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
 import java.util.Date;
+import java.util.List;
 import java.util.Objects;
 
 /**
@@ -90,4 +91,13 @@ public class TBDingApplyController {
                               @ApiParam(value = "审核用户id") @RequestParam(required = false) Long userId) throws InterruptedException {
         return ResultUtil.ok(tbDingApplyService.flowApprove(taskId, dingExceptionApprove, userId));
     }
+
+    @ApiOperation(value = "考勤异常批量审核接口")
+    @RequestMapping(value = "/flow/batch/approve", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Result flowBatchApprove(@ApiParam(value = "流程任务id数组", required = true) @RequestParam List<Long> taskIds,
+                                   @ApiParam(value = "审核结果", required = true) @RequestParam DingExceptionApproveEnum dingExceptionApprove,
+                                   @ApiParam(value = "审核用户id") @RequestParam(required = false) Long userId) throws InterruptedException {
+        return ResultUtil.ok(tbDingApplyService.flowBatchApprove(taskIds, dingExceptionApprove, userId));
+    }
 }