package org.jeecg.modules.checkData.equipmentCheckData.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.modules.checkData.equipmentCheckData.dto.UseTurnoutRecordCheckDTO;
import org.jeecg.modules.checkData.equipmentCheckData.entity.UseTurnoutRecordCheck;
import org.jeecg.modules.checkData.equipmentCheckData.service.IUseTurnoutRecordCheckService;
import org.jeecg.modules.checkData.equipmentCheckData.vo.UseTurnoutRecordCheckDetailVO;
import org.jeecg.modules.checkData.equipmentCheckData.vo.UseTurnoutRecordCheckVO;
import org.jeecg.modules.utils.BeanCopyUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.jeecg.common.system.base.controller.JeecgController;

import java.util.*;

/**
 * <p>
 * 检查数据设备-设备检查记录数据-曲线磨耗情况检查-道岔使用情况检查数据 前端控制器
 * </p>
 *
 * @author hkl
 * @since 2023-07-09
 */
@RestController
@RequestMapping("/checkData/equipmentCheckData/useTurnoutRecordCheck")
@Api(tags = "检查数据设备-设备检查记录数据-曲线磨耗情况检查")
public class UseTurnoutRecordCheckController extends JeecgController<UseTurnoutRecordCheck, IUseTurnoutRecordCheckService> {

    @AutoLog(value = "检查数据设备-设备检查记录数据-曲线磨耗情况检查-分页列表查询")
    @ApiOperation(value = "检查数据设备-设备检查记录数据-曲线磨耗情况检查-分页列表查询", notes = "检查数据设备-设备检查记录数据-曲线磨耗情况检查-分页列表查询")
    @GetMapping(value = "/list")
    public Result<IPage<UseTurnoutRecordCheckVO>> queryPageList(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                UseTurnoutRecordCheckDTO dto) {
        Page<UseTurnoutRecordCheckVO> pageData = new Page<>(pageNo, pageSize);
        pageData = this.service.queryPageList(pageData, dto);
        return Result.OK(pageData);
    }

    @AutoLog(value = "检查数据设备-设备检查记录数据-曲线磨耗情况检查-获取道岔编号List")
    @ApiOperation(value = "检查数据设备-设备检查记录数据-曲线磨耗情况检查-获取道岔编号List", notes = "检查数据设备-设备检查记录数据-曲线磨耗情况检查-获取道岔编号List")
    @GetMapping(value = "/getTurnoutCodeList")
    public Result<List<Map<String, Object>>> getTurnoutCodeList(@ApiParam("设备检查记录主表id") String recordsMasterCheckId) {
        List<UseTurnoutRecordCheck> records = this.service.lambdaQuery()
                .eq(UseTurnoutRecordCheck::getRecordsMasterCheckId, recordsMasterCheckId)
                .list();

        List<Map<String, Object>> list = new ArrayList<>();
        for (UseTurnoutRecordCheck useTurnoutRecordCheck : records) {
            Map<String, Object> map = new HashMap<>();
            map.put("label", useTurnoutRecordCheck.getTurnoutCode());
            map.put("value", useTurnoutRecordCheck.getId());
            list.add(map);
        }
        return Result.OK(list);
    }


    @AutoLog(value = "检查数据设备-设备检查记录数据-曲线磨耗情况检查-道岔检查详情页")
    @ApiOperation(value = "检查数据设备-设备检查记录数据-曲线磨耗情况检查-道岔检查详情页", notes = "检查数据设备-设备检查记录数据-曲线磨耗情况检查-道岔检查详情页")
    @GetMapping(value = "/getDetail")
    public Result<UseTurnoutRecordCheckDetailVO> getDetail(@ApiParam("设备检查记录表id") String useTurnoutRecordId) {
        UseTurnoutRecordCheckDetailVO data = this.service.getDetail(useTurnoutRecordId);
        return Result.OK(data);
    }

}

