package com.xiaopeng.maintenance.controller;
import com.xiaopeng.common.core.domain.R;
import com.xiaopeng.common.core.web.page.PageInfo;
import com.xiaopeng.common.security.service.TokenService;
import com.xiaopeng.maintenance.dto.*;
import com.xiaopeng.maintenance.service.IXpClockInService;
import com.xiaopeng.maintenance.vo.ClockInStatisticsDetailsVo;
import com.xiaopeng.maintenance.vo.ClockInStatisticsVo;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
/**
*
* 打卡明细 前端控制器
*
* 打卡管理 Controller
*
* @author xiaochen
* @since 2026-02-06
* @author mitao
* @date 2026-02-14
*/
@Slf4j
@RestController
@RequestMapping("")
public class XpClockInController {
@Autowired
private IXpClockInService xpClockInService;
@Autowired
private TokenService tokenService;
@ApiOperation(value = "校验是否在打卡范围内", tags = "运维APP-排班与考勤")
@PostMapping("/maintenance-app/api/v1/clock/verifyRange")
public R verifyRange(@RequestBody VerifyRangeDTO dto) {
return R.ok(xpClockInService.verifyRange(dto));
}
@ApiOperation(value = "上班打卡", tags = "运维APP-排班与考勤")
@PostMapping("/maintenance-app/api/v1/clock/clockIn")
public R clockIn(@RequestBody ClockDTO dto) {
Long id = tokenService.getLoginOperationUser().getId();
dto.setOperationsUserId(id);
return xpClockInService.clockIn(dto);
}
/**
* 检查用户是否上班中(内部接口)
*/
@GetMapping("/logan/inner/clock-in/checkWorkStatus")
@ApiOperation(value = "检查用户是否上班中", tags = {"内部接口"})
public R checkWorkStatus(@RequestParam("appUserId") Long appUserId) {
log.info("检查用户上班状态, appUserId={}", appUserId);
Integer workFlag = xpClockInService.checkWorkStatus(appUserId);
return R.ok(workFlag);
}
@ApiOperation(value = "下班打卡", tags = "运维APP-排班与考勤")
@PostMapping("/maintenance-app/api/v1/clock/clockOut")
public R clockOut(@RequestBody ClockDTO dto) {
Long id = tokenService.getLoginOperationUser().getId();
dto.setOperationsUserId(id);
return xpClockInService.clockOut(dto);
}
@ApiOperation(value = "排班考勤打卡统计列表", tags = {"管理后台-运维执行"})
@PostMapping("/api/v1/clock/getClockInStatistics")
public R> getClockInStatistics(@RequestBody ClockInStatisticsVo vo){
PageInfo clockInStatistics = xpClockInService.getClockInStatistics(vo);
return R.ok(clockInStatistics);
}
@ApiOperation(value = "排班考勤打卡统计导出", tags = {"管理后台-运维执行"})
@PostMapping("/api/v1/clock/exportClockInStatistics")
public void exportClockInStatistics(@RequestBody ClockInStatisticsVo vo, HttpServletResponse response){
xpClockInService.exportClockInStatistics(vo, response);
}
@ApiOperation(value = "排班考勤打卡统计详情列表", tags = {"管理后台-运维执行"})
@PostMapping("/api/v1/clock/getClockInStatisticsDetails")
public R getClockInStatisticsDetails(@RequestBody ClockInStatisticsDetailsVo query){
GetClockInStatisticsDetailsDto clockInStatisticsDetails = xpClockInService.getClockInStatisticsDetails(query);
return R.ok(clockInStatisticsDetails);
}
@ApiOperation(value = "排班考勤打卡统计详情导出", tags = {"管理后台-运维执行"})
@PostMapping("/api/v1/clock/exportClockInStatisticsDetails")
public void exportClockInStatisticsDetails(@RequestBody ClockInStatisticsDetailsVo query, HttpServletResponse response){
xpClockInService.exportClockInStatisticsDetails(query, response);
}
}