diff --git a/src/main/java/com/gxwebsoft/yxe/controller/YxeAuditController.java b/src/main/java/com/gxwebsoft/yxe/controller/YxeAuditController.java new file mode 100644 index 0000000..bd47a8e --- /dev/null +++ b/src/main/java/com/gxwebsoft/yxe/controller/YxeAuditController.java @@ -0,0 +1,99 @@ +package com.gxwebsoft.yxe.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.gxwebsoft.common.core.web.ApiResult; +import com.gxwebsoft.common.core.web.BaseController; +import com.gxwebsoft.common.system.entity.User; +import com.gxwebsoft.yxe.entity.YxeSelfReport; +import com.gxwebsoft.yxe.entity.YxeShare; +import com.gxwebsoft.yxe.entity.YxeUserTask; +import com.gxwebsoft.yxe.entity.YxeVisitReport; +import com.gxwebsoft.yxe.service.YxeSelfReportService; +import com.gxwebsoft.yxe.service.YxeShareService; +import com.gxwebsoft.yxe.service.YxeUserTaskService; +import com.gxwebsoft.yxe.service.YxeVisitReportService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * 审核中心控制器 + * + * @author Codex + * @since 2026-10-12 + */ +@Api(tags = "审核中心") +@RestController +@RequestMapping("/api/yxe/yxe-audit") +public class YxeAuditController extends BaseController { + + /** 药动销审核覆盖的任务分类:日常驻店、培训/拜访(与审核页 cateIdList=1,3 保持一致) */ + private static final Integer[] MOVEMENT_CATE_IDS = {1, 3}; + + /** 跑店/巡店的任务分类 */ + private static final Integer STORE_VISIT_CATE_ID = 4; + + /** 用户任务:1 已完成待审核(审核页「待审核」对应的库值) */ + private static final Integer TASK_STATUS_PENDING_AUDIT = 1; + + /** 填报与药分享:0 待审核 */ + private static final Integer STATUS_PENDING_AUDIT = 0; + + @Resource + private YxeUserTaskService yxeUserTaskService; + @Resource + private YxeSelfReportService yxeSelfReportService; + @Resource + private YxeVisitReportService yxeVisitReportService; + @Resource + private YxeShareService yxeShareService; + + @ApiOperation("待审核数量统计") + @GetMapping("/pending-count") + public ApiResult pendingCount() { + User loginUser = getLoginUser(); + // 审核入口只对审核员开放,非审核员不下发全站待审量,直接返回 0 + if (loginUser == null || !Integer.valueOf(1).equals(loginUser.getCanAuth())) { + return success(emptyCount()); + } + // 口径与审核页各类型「待审核」列表的总数一致,保证入口徽标与列表条数对得上 + long movement = yxeUserTaskService.count(new LambdaQueryWrapper() + .in(YxeUserTask::getCateId, (Object[]) MOVEMENT_CATE_IDS) + .eq(YxeUserTask::getStatus, TASK_STATUS_PENDING_AUDIT)); + long storeVisit = yxeUserTaskService.count(new LambdaQueryWrapper() + .eq(YxeUserTask::getCateId, STORE_VISIT_CATE_ID) + .eq(YxeUserTask::getStatus, TASK_STATUS_PENDING_AUDIT)); + long selfReport = yxeSelfReportService.count(new LambdaQueryWrapper() + .eq(YxeSelfReport::getStatus, STATUS_PENDING_AUDIT)); + long visitReport = yxeVisitReportService.count(new LambdaQueryWrapper() + .eq(YxeVisitReport::getStatus, STATUS_PENDING_AUDIT)); + long exchange = yxeShareService.count(new LambdaQueryWrapper() + .eq(YxeShare::getStatus, STATUS_PENDING_AUDIT)); + + Map data = new LinkedHashMap<>(); + data.put("total", movement + storeVisit + selfReport + visitReport + exchange); + data.put("movement", movement); + data.put("storeVisit", storeVisit); + data.put("selfReport", selfReport); + data.put("visitReport", visitReport); + data.put("exchange", exchange); + return success(data); + } + + private Map emptyCount() { + Map data = new LinkedHashMap<>(); + data.put("total", 0L); + data.put("movement", 0L); + data.put("storeVisit", 0L); + data.put("selfReport", 0L); + data.put("visitReport", 0L); + data.put("exchange", 0L); + return data; + } +}