Răsfoiți Sursa

add. 区协补卡申请

caozixuan 9 luni în urmă
părinte
comite
9288e76b5b

+ 43 - 36
sop-api/src/main/java/com/qmth/sop/server/api/TBDingApplyController.java

@@ -5,7 +5,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.sop.business.bean.result.DingApplyDoneResult;
 import com.qmth.sop.business.bean.result.DingApplyUnDoneResult;
+import com.qmth.sop.business.bean.result.SearchResult;
 import com.qmth.sop.business.bean.result.TBDingApplyViewResult;
+import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.TBDingApply;
 import com.qmth.sop.business.service.TBDingApplyService;
 import com.qmth.sop.common.annotation.OperationLog;
@@ -14,6 +16,7 @@ import com.qmth.sop.common.enums.DingExceptionApproveEnum;
 import com.qmth.sop.common.enums.LogTypeEnum;
 import com.qmth.sop.common.util.Result;
 import com.qmth.sop.common.util.ResultUtil;
+import com.qmth.sop.common.util.ServletUtil;
 import io.swagger.annotations.*;
 import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.*;
@@ -42,9 +45,10 @@ public class TBDingApplyController {
 
     @ApiOperation(value = "考勤异常申请接口")
     @RequestMapping(value = "/save", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "返回信息", response = Object.class) })
     @OperationLog(logType = LogTypeEnum.ADD)
-    public Result save(@Valid @ApiParam(value = "考勤异常申请信息", required = true) @RequestBody TBDingApply tbDingApply, BindingResult bindingResult) throws Exception {
+    public Result save(@Valid @ApiParam(value = "考勤异常申请信息", required = true) @RequestBody TBDingApply tbDingApply,
+            BindingResult bindingResult) throws Exception {
         if (bindingResult.hasErrors()) {
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
         }
@@ -53,61 +57,64 @@ public class TBDingApplyController {
 
     @ApiOperation(value = "考勤异常待审核接口")
     @RequestMapping(value = "/flow/task/un_done/list", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = DingApplyUnDoneResult.class)})
-    public Result flowTaskUnDoneList(@ApiParam(value = "服务单元id") @RequestParam(required = false) Long serviceId,
-                                     @ApiParam(value = "姓名") @RequestParam(required = false) String name,
-                                     @ApiParam(value = "供应商id") @RequestParam(required = false) Long supplierId,
-                                     @ApiParam(value = "客户名称") @RequestParam(required = false) String customName,
-                                     @ApiParam(value = "异常开始时间") @RequestParam(required = false) Long startTime,
-                                     @ApiParam(value = "异常结束时间") @RequestParam(required = false) Long endTime,
-                                     @ApiParam(value = "申请开始时间") @RequestParam(required = false) Long applyStartTime,
-                                     @ApiParam(value = "申请结束时间") @RequestParam(required = false) Long applyEndTime,
-                                     @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) throws Exception {
-        return ResultUtil.ok(tbDingApplyService.flowTaskUnDoneList(new Page<>(pageNumber, pageSize), serviceId, name, supplierId, customName, startTime, endTime, applyStartTime, applyEndTime));
+    @ApiResponses({ @ApiResponse(code = 200, message = "返回信息", response = DingApplyUnDoneResult.class) })
+    public Result flowTaskUnDoneList(@ApiParam(value = "服务单元id") @RequestParam(required = false) Long serviceId, @ApiParam(value = "姓名") @RequestParam(required = false) String name,
+            @ApiParam(value = "供应商id") @RequestParam(required = false) Long supplierId, @ApiParam(value = "客户名称") @RequestParam(required = false) String customName,
+            @ApiParam(value = "异常开始时间") @RequestParam(required = false) Long startTime, @ApiParam(value = "异常结束时间") @RequestParam(required = false) Long endTime,
+            @ApiParam(value = "申请开始时间") @RequestParam(required = false) Long applyStartTime, @ApiParam(value = "申请结束时间") @RequestParam(required = false) Long applyEndTime,
+            @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)
+            throws Exception {
+        return ResultUtil.ok(
+                tbDingApplyService.flowTaskUnDoneList(new Page<>(pageNumber, pageSize), serviceId, name, supplierId,
+                        customName, startTime, endTime, applyStartTime, applyEndTime));
     }
 
     @ApiOperation(value = "考勤异常已审核接口")
     @RequestMapping(value = "/flow/task/done/list", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = DingApplyDoneResult.class)})
-    public Result flowTaskDoneList(@ApiParam(value = "服务单元id") @RequestParam(required = false) Long serviceId,
-                                   @ApiParam(value = "姓名") @RequestParam(required = false) String name,
-                                   @ApiParam(value = "供应商id") @RequestParam(required = false) Long supplierId,
-                                   @ApiParam(value = "审核结果") @RequestParam(required = false) DingExceptionApproveEnum dingExceptionApprove,
-                                   @ApiParam(value = "客户名称") @RequestParam(required = false) String customName,
-                                   @ApiParam(value = "异常开始时间") @RequestParam(required = false) Long startTime,
-                                   @ApiParam(value = "异常结束时间") @RequestParam(required = false) Long endTime,
-                                   @ApiParam(value = "申请开始时间") @RequestParam(required = false) Long applyStartTime,
-                                   @ApiParam(value = "申请结束时间") @RequestParam(required = false) Long applyEndTime,
-                                   @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) throws Exception {
-        return ResultUtil.ok(tbDingApplyService.flowTaskDoneList(new Page<>(pageNumber, pageSize), serviceId, name, supplierId, dingExceptionApprove, customName, startTime, endTime, applyStartTime, applyEndTime));
+    @ApiResponses({ @ApiResponse(code = 200, message = "返回信息", response = DingApplyDoneResult.class) })
+    public Result flowTaskDoneList(@ApiParam(value = "服务单元id") @RequestParam(required = false) Long serviceId, @ApiParam(value = "姓名") @RequestParam(required = false) String name,
+            @ApiParam(value = "供应商id") @RequestParam(required = false) Long supplierId, @ApiParam(value = "审核结果") @RequestParam(required = false) DingExceptionApproveEnum dingExceptionApprove,
+            @ApiParam(value = "客户名称") @RequestParam(required = false) String customName, @ApiParam(value = "异常开始时间") @RequestParam(required = false) Long startTime,
+            @ApiParam(value = "异常结束时间") @RequestParam(required = false) Long endTime, @ApiParam(value = "申请开始时间") @RequestParam(required = false) Long applyStartTime,
+            @ApiParam(value = "申请结束时间") @RequestParam(required = false) Long applyEndTime, @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)
+            throws Exception {
+        return ResultUtil.ok(
+                tbDingApplyService.flowTaskDoneList(new Page<>(pageNumber, pageSize), serviceId, name, supplierId,
+                        dingExceptionApprove, customName, startTime, endTime, applyStartTime, applyEndTime));
     }
 
     @ApiOperation(value = "考勤异常审核接口")
     @RequestMapping(value = "/flow/approve", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "返回信息", response = Object.class) })
     @OperationLog(logType = LogTypeEnum.UN_KNOW)
-    public Result flowApprove(@ApiParam(value = "流程任务id", required = true) @RequestParam Long taskId,
-                              @ApiParam(value = "审核结果", required = true) @RequestParam DingExceptionApproveEnum dingExceptionApprove,
-                              @ApiParam(value = "审核用户id") @RequestParam(required = false) Long userId) throws InterruptedException {
+    public Result flowApprove(@ApiParam(value = "流程任务id", required = true) @RequestParam Long taskId, @ApiParam(value = "审核结果", required = true) @RequestParam DingExceptionApproveEnum dingExceptionApprove,
+            @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)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "返回信息", response = Object.class) })
     @OperationLog(logType = LogTypeEnum.UN_KNOW)
-    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 {
+    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));
     }
 
     @ApiOperation(value = "考勤异常详情接口")
     @RequestMapping(value = "/view", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = TBDingApplyViewResult.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "返回信息", response = TBDingApplyViewResult.class) })
     public Result view(@ApiParam(value = "主键", required = true) @RequestParam Long id) {
         return ResultUtil.ok(tbDingApplyService.view(id));
     }
+
+    @ApiOperation(value = "补卡申请-区协查询审核人")
+    @RequestMapping(value = "/find_region_coordinator_auditor", method = RequestMethod.POST)
+    @ApiResponses({ @ApiResponse(code = 200, message = "返回信息", response = SearchResult.class) })
+    public Result findRegionCoordinatorAuditor(@ApiParam(value = "服务单元id", required = true) @RequestParam Long serviceId) {
+        SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
+        return ResultUtil.ok(tbDingApplyService.findRegionCoordinatorAuditor(serviceId, requestUser.getId()));
+    }
 }

+ 14 - 5
sop-business/src/main/java/com/qmth/sop/business/service/TBDingApplyService.java

@@ -2,9 +2,7 @@ package com.qmth.sop.business.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.qmth.sop.business.bean.result.DingApplyDoneResult;
-import com.qmth.sop.business.bean.result.DingApplyUnDoneResult;
-import com.qmth.sop.business.bean.result.TBDingApplyViewResult;
+import com.qmth.sop.business.bean.result.*;
 import com.qmth.sop.business.entity.TBDingApply;
 import com.qmth.sop.common.enums.DingExceptionApproveEnum;
 
@@ -44,7 +42,8 @@ public interface TBDingApplyService extends IService<TBDingApply> {
      * @param applyEndTime
      * @return
      */
-    IPage<DingApplyUnDoneResult> flowTaskUnDoneList(IPage<Map> iPage, Long serviceId, String name, Long supplierId, String customName, Long startTime, Long endTime, Long applyStartTime, Long applyEndTime) throws Exception;
+    IPage<DingApplyUnDoneResult> flowTaskUnDoneList(IPage<Map> iPage, Long serviceId, String name, Long supplierId,
+            String customName, Long startTime, Long endTime, Long applyStartTime, Long applyEndTime) throws Exception;
 
     /**
      * 异常已审核接口
@@ -61,7 +60,8 @@ public interface TBDingApplyService extends IService<TBDingApply> {
      * @param applyEndTime
      * @return
      */
-    IPage<DingApplyDoneResult> flowTaskDoneList(IPage<Map> iPage, Long serviceId, String name, Long supplierId, DingExceptionApproveEnum dingExceptionApprove, String customName, Long startTime, Long endTime, Long applyStartTime, Long applyEndTime) throws Exception;
+    IPage<DingApplyDoneResult> flowTaskDoneList(IPage<Map> iPage, Long serviceId, String name, Long supplierId,
+            DingExceptionApproveEnum dingExceptionApprove, String customName, Long startTime, Long endTime, Long applyStartTime, Long applyEndTime) throws Exception;
 
     /**
      * 考勤异常审核接口
@@ -110,4 +110,13 @@ public interface TBDingApplyService extends IService<TBDingApply> {
      * @return
      */
     TBDingApplyViewResult view(Long id);
+
+    /**
+     * 查询区域协调人补卡的审核人集合
+     *
+     * @param serviceId 服务单元id
+     * @param userId    用户id
+     * @return 审核人集合(大区经理集合)
+     */
+    List<SearchResult> findRegionCoordinatorAuditor(Long serviceId, Long userId);
 }

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

@@ -147,7 +147,7 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
     @Override
     public List<String> listByServiceId(Long serviceId, Long userId, String sopNo) {
         SysUser sysUser = sysUserService.getById(userId);
-        Optional.ofNullable(sysUser).orElseThrow(() -> ExceptionResultEnum.USER_NO_EXISTS.exception());
+        Optional.ofNullable(sysUser).orElseThrow(ExceptionResultEnum.USER_NO_EXISTS::exception);
 
         //        if (sysUser.getSource() == UserSourceEnum.SYSTEM) {
         //            throw ExceptionResultEnum.ERROR.exception("非档案用户不能发起异常补卡申请");

+ 30 - 12
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingApplyServiceImpl.java

@@ -33,6 +33,7 @@ import org.springframework.util.CollectionUtils;
 import javax.annotation.Resource;
 import java.util.*;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * <p>
@@ -116,19 +117,15 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
         if (count == 0) {
             throw ExceptionResultEnum.ERROR.exception("该用户剩余补卡次数为0");
         }
-
-        TBCrmDetail tbCrmDetail = null;
-        if (Objects.nonNull(sopNo)) {
-            tbCrmDetail = tbCrmDetailService.findBySopNo(sopNo);
+        List<String> approveUserIds = new ArrayList<>();
+        if (SystemConstant.strNotNull(sopNo)){
+            List<String> sysUserRoleList = sysUserRoleService.listByServiceId(serviceId, sysUser.getId(), sopNo);
+            approveUserIds.addAll(sysUserRoleList);
+        } else {
+            // 区协选定审核人
+            List<String> sysUserRoleList = tbDingApply.getApproveUserIds();
+            approveUserIds.addAll(sysUserRoleList);
         }
-        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(
-                Objects.nonNull(tbCrmDetail) ? tbCrmDetail.getSopNo() : null,
-                Objects.nonNull(tbCrmDetail) ? tbCrmDetail.getId() : null, crmNo);
-        Optional.ofNullable(crmProjectResult).orElseThrow(ExceptionResultEnum.CRM_NO_NO_DATA::exception);
-
-        List<String> sysUserRoleList = sysUserRoleService.listByServiceId(crmProjectResult.getServiceUnitId(),
-                sysUser.getId(), sopNo);
-        List<String> approveUserIds = new ArrayList<>(sysUserRoleList);
         FlowApproveParam flowApproveParam = new FlowApproveParam(tbDingApply.getFlowDeploymentId(),
                 FlowApprovePassEnum.START, approveUserIds, crmNo);
         flowApproveParam.setApproveRemark(FlowApprovePassEnum.START.getTitle());
@@ -557,4 +554,25 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
         return new TBDingApplyViewResult(crmProjectResult, tbDingApply, taskIdList, flowTaskHistoryList,
                 currFlowTaskResult, flowApproveHistoryList);
     }
+
+    @Override
+    public List<SearchResult> findRegionCoordinatorAuditor(Long serviceId, Long userId) {
+        List<SearchResult> result = new ArrayList<>();
+        List<TBUserArchivesAllocation> tbUserArchivesAllocationList = tbUserArchivesAllocationService.list(new QueryWrapper<TBUserArchivesAllocation>().lambda()
+                .eq(TBUserArchivesAllocation::getServiceId, serviceId).eq(TBUserArchivesAllocation::getUserId, userId).eq(TBUserArchivesAllocation::getSopRoleType, SopRoleTypeEnum.REGION_COORDINATOR));
+        List<String> crmNoList = tbUserArchivesAllocationList.stream().map(TBUserArchivesAllocation::getCrmNo).distinct().collect(Collectors.toList());
+        if (!CollectionUtils.isEmpty(crmNoList)) {
+            List<TBCrm> tbCrmList = tbCrmService.list(new QueryWrapper<TBCrm>().lambda().in(TBCrm::getCrmNo, crmNoList));
+            List<Long> leaderIdList = tbCrmList.stream().map(TBCrm::getLeadId).distinct().collect(Collectors.toList());
+            if (!CollectionUtils.isEmpty(leaderIdList)) {
+                result = sysUserService.listByIds(leaderIdList).stream().flatMap(e -> {
+                    SearchResult searchResult = new SearchResult();
+                    searchResult.setId(e.getId());
+                    searchResult.setValue(e.getRealName());
+                    return Stream.of(searchResult);
+                }).collect(Collectors.toList());
+            }
+        }
+        return result;
+    }
 }

+ 3 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBUserArchivesServiceImpl.java

@@ -638,6 +638,9 @@ public class TBUserArchivesServiceImpl extends ServiceImpl<TBUserArchivesMapper,
     public boolean containsRegionCoordinator(Long userId) {
         UserArchivesResult userArchivesResult = tbUserArchivesService.findUserArchivesByArchivesIdORUserId(null,
                 userId);
+        if (Objects.isNull(userArchivesResult)){
+            return false;
+        }
         List<RoleResult> roleInfoList = userArchivesResult.getRoleInfoList();
         // 判断是否包含区域协调人身份
         return roleInfoList.stream().anyMatch(e -> RoleTypeEnum.REGION_COORDINATOR.name().equals(e.getRoleType()));

+ 3 - 0
sop-business/src/main/resources/db/log/caozixuan_update_log.sql

@@ -172,3 +172,6 @@ INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, e
 INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2101', '工时统计-批量导出', '/api/admin/tb/ding/statistic/export', 'URL', '29', '2', 'AUTH', '1', '1', '0');
 INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, related, enable, default_auth, front_display) VALUES ('2102', '搜索', 'Select', 'BUTTON', '29', '1', 'AUTH', '2100', '1', '0', '1');
 INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, related, enable, default_auth, front_display) VALUES ('2103', '导出统计结果', 'Export', 'BUTTON', '29', '2', 'AUTH', '2101', '1', '0', '1');
+
+-- 2024-09-10
+INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, related, enable, default_auth, front_display) VALUES ('2104', '补卡申请-区协查询审核人', '/api/admin/ding/exception/apply/find_region_coordinator_auditor', 'URL', '26', '2', 'SYS', NULL, '1', '1', '0');