liujie
2026-06-09 c96fbe6b0aeb413a17c429133ee6d81d138144b9
xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/controller/XpCruiseCheckInRuleController.java
@@ -1,25 +1,38 @@
package com.xiaopeng.maintenance.controller;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xiaopeng.api.model.maintenance.XpCruiseCheckInRecord;
import com.xiaopeng.api.vo.account.LoginOperationUser;
import com.xiaopeng.common.core.domain.R;
import com.xiaopeng.common.core.web.page.PageInfo;
import com.xiaopeng.common.log.annotation.AdminOperationLog;
import com.xiaopeng.common.log.enums.AdminBusinessType;
import com.xiaopeng.common.log.enums.AdminOperationType;
import com.xiaopeng.common.security.service.TokenService;
import com.xiaopeng.maintenance.dto.XpCruiseCheckInRuleDto;
import com.xiaopeng.maintenance.dto.XpCruiseCheckInRuleListPageDto;
import com.xiaopeng.maintenance.model.vo.AppXpCruiseCheckInLocationVo;
import com.xiaopeng.maintenance.model.vo.AppXpCruiseCheckInRuleVo;
import com.xiaopeng.maintenance.model.vo.CheckInMessageVo;
import com.xiaopeng.maintenance.model.vo.RealTimePositionVo;
import com.xiaopeng.maintenance.service.IXpCruiseCheckInRecordService;
import com.xiaopeng.maintenance.service.IXpCruiseCheckInRuleService;
import com.xiaopeng.maintenance.vo.XpCruiseCheckInRecordQuery;
import com.xiaopeng.maintenance.vo.XpCruiseCheckInRecordVO;
import com.xiaopeng.maintenance.vo.*;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.List;
/**
@@ -27,6 +40,7 @@
 */
@RestController
@RequestMapping("")
@Slf4j
public class XpCruiseCheckInRuleController {
    @Resource
@@ -62,11 +76,12 @@
    @ApiOperation(value = "巡游打卡操作", tags = {"运维APP-个人中心"})
    @PostMapping("/maintenance-app/api/v1/cruiseCheckInRule/saveCruiseCheckInRecord")
    public R<?> saveCruiseCheckInRecord(@RequestBody XpCruiseCheckInRecord dto){
    public R<XpCruiseCheckInRecord> saveCruiseCheckInRecord(@RequestBody XpCruiseCheckInRecord dto){
        LoginOperationUser loginOperationUser = tokenService.getLoginOperationUser();
        dto.setOperationsUserId(loginOperationUser.getId());
        xpCruiseCheckInRuleService.saveCruiseCheckInRecord(dto);
        return R.ok();
        Long id = xpCruiseCheckInRuleService.saveCruiseCheckInRecord(dto);
        XpCruiseCheckInRecord cruiseCheckInRecordInfo = xpCruiseCheckInRecordService.getById(id);
        return R.ok(cruiseCheckInRecordInfo);
    }
@@ -86,13 +101,76 @@
            @ApiImplicitParam(value = "任务id", name = "id", required = true, dataType = "Integer"),
            @ApiImplicitParam(value = "打卡点位id", name = "locationId", required = true, dataType = "Long")
    })
    @GetMapping("/maintenance-app/api/v1/cruiseCheckInRule/getCruiseCheckInRecordInfo/{id}/{locationId}")
    public R<XpCruiseCheckInRecord> getCruiseCheckInRecordInfo(@PathVariable("id") Integer id, @PathVariable("locationId") Long locationId) {
        LoginOperationUser loginOperationUser = tokenService.getLoginOperationUser();
        XpCruiseCheckInRecord cruiseCheckInRecordInfo = xpCruiseCheckInRuleService.getCruiseCheckInRecordInfo(id, locationId, loginOperationUser.getId());
        return R.ok(cruiseCheckInRecordInfo);
    }
    @ApiOperation(value = "查询巡游打卡规则列表", tags = {"管理后台-巡游打卡规则管理"})
    @PostMapping("/maintenance-admin/api/v1/cruiseCheckInRecord/getXpCruiseCheckInRuleListPage")
    public R<Page<XpCruiseCheckInRuleListPage>> getXpCruiseCheckInRuleListPage(XpCruiseCheckInRuleListPageDto dto){
        Page<XpCruiseCheckInRuleListPage> pageInfo = PageInfo.of(dto.getPageNum(), dto.getPageSize());
        List<XpCruiseCheckInRuleListPage> xpCruiseCheckInRuleListPage = xpCruiseCheckInRuleService.getXpCruiseCheckInRuleListPage(pageInfo, dto);
        pageInfo.setRecords(xpCruiseCheckInRuleListPage);
        return R.ok(pageInfo);
    }
    @ApiOperation(value = "添加巡游打卡规则", tags = {"管理后台-巡游打卡规则管理"})
    @PostMapping("/maintenance-admin/api/v1/cruiseCheckInRecord/addXpCruiseCheckInRule")
    @AdminOperationLog(
            businessType = AdminBusinessType.CRUISE_CHECK_IN_RULE_MANAGEMENT,
            operationType = AdminOperationType.ADD,
            content = "添加巡游打卡规则",
            appendRequestData = true
    )
    public R<?> addXpCruiseCheckInRule(@RequestBody XpCruiseCheckInRuleDto dto){
        xpCruiseCheckInRuleService.addXpCruiseCheckInRule(dto);
        return R.ok();
    }
    @ApiOperation(value = "编辑巡游打卡规则", tags = {"管理后台-巡游打卡规则管理"})
    @PostMapping("/maintenance-admin/api/v1/cruiseCheckInRecord/updateXpCruiseCheckInRule")
    @AdminOperationLog(
            businessType = AdminBusinessType.CRUISE_CHECK_IN_RULE_MANAGEMENT,
            operationType = AdminOperationType.EDIT,
            content = "编辑巡游打卡规则",
            appendRequestData = true
    )
    public R<?> updateXpCruiseCheckInRule(@RequestBody XpCruiseCheckInRuleDto dto){
        xpCruiseCheckInRuleService.updateXpCruiseCheckInRule(dto);
        return R.ok();
    }
    @ApiOperation(value = "删除巡游打卡规则", tags = {"管理后台-巡游打卡规则管理"})
    @PostMapping("/maintenance-admin/api/v1/cruiseCheckInRecord/delXpCruiseCheckInRule/{id}")
    @AdminOperationLog(
            businessType = AdminBusinessType.CRUISE_CHECK_IN_RULE_MANAGEMENT,
            operationType = AdminOperationType.DELETE,
            contentExpression = "'删除巡游打卡规则,id=' + #p0",
            appendRequestData = false
    )
    public R<?> delXpCruiseCheckInRule(@PathVariable("id") Integer id){
        xpCruiseCheckInRuleService.removeById(id);
        return R.ok();
    }
    @ApiOperation(value = "获取打卡规则详情", tags = {"管理后台-巡游打卡规则管理"})
    @PostMapping("/maintenance-admin/api/v1/cruiseCheckInRecord/getXpCruiseCheckInRuleInfo/{id}")
    public R<XpCruiseCheckInRuleInfoVo> getXpCruiseCheckInRuleInfo(@PathVariable("id") Integer id){
        XpCruiseCheckInRuleInfoVo xpCruiseCheckInRuleInfo = xpCruiseCheckInRuleService.getXpCruiseCheckInRuleInfo(id);
        return R.ok(xpCruiseCheckInRuleInfo);
    }
    @ApiOperation(value = "查询巡游打卡记录列表", tags = {"管理后台-巡游打卡管理"})
    @PostMapping("/maintenance-admin/api/v1/cruiseCheckInRecord/pageList")
@@ -103,9 +181,52 @@
    @ApiOperation(value = "查询巡游打卡记录详情", tags = {"管理后台-巡游打卡管理"})
    @GetMapping("/maintenance-admin/api/v1/cruiseCheckInRecord/{id}")
    public R<XpCruiseCheckInRecordVO> pageList(@PathVariable("id")Long id) {
    public R<XpCruiseCheckInRecordVO> detail(@PathVariable("id")Long id) {
        XpCruiseCheckInRecordVO xpCruiseCheckInRecordVO = xpCruiseCheckInRecordService.detail(id);
        return R.ok(xpCruiseCheckInRecordVO);
    }
    @ApiOperation(value = "巡游打卡统计", tags = {"管理后台-巡游打卡管理"})
    @PostMapping("/maintenance-admin/api/v1/cruiseCheckInRecord/statistic")
    public R<List<XpCruiseCheckInStatisticsVO>> pageList(@RequestBody XpCruiseCheckInStatisticsQuery  query) {
        return R.ok(xpCruiseCheckInRecordService.statistics(query));
    }
    @ApiOperation(value = "查询巡游打卡记录列表导出", tags = {"管理后台-巡游打卡管理"})
    @PostMapping("/maintenance-admin/api/v1/cruiseCheckInRecord/export")
    @AdminOperationLog(
            businessType = AdminBusinessType.CRUISE_CHECK_IN_RULE_MANAGEMENT,
            operationType = AdminOperationType.EXPORT,
            content = "导出巡游打卡记录",
            appendRequestData = true
    )
    public R<PageInfo<XpCruiseCheckInRecordVO>> pageListExport(@RequestBody XpCruiseCheckInRecordQuery query, HttpServletResponse response) {
        List<XpCruiseCheckInRecordVO> list = xpCruiseCheckInRecordService.all(query);
        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), XpCruiseCheckInRecordVO.class, list);
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");
        ServletOutputStream outputStream = null;
        try {
            String fileName = URLEncoder.encode("巡游打卡记录.xls", "utf-8");
            response.setHeader("Content-disposition", "attachment;filename=" + fileName);
            outputStream = response.getOutputStream();
            workbook.write(outputStream);
            outputStream.flush();
        } catch (IOException e) {
            log.error("导出巡游打卡记录失败", e);
        } finally {
            try {
                if (outputStream != null) {
                    outputStream.close();
                }
                if (workbook != null) {
                    workbook.close();
                }
            } catch (IOException e) {
                log.error("关闭输出流失败", e);
            }
        }
        return R.ok();
    }
}