package com.junmp.jyzb.controller;

import com.junmp.jyzb.api.bean.dto.LogDetailDto;
import com.junmp.jyzb.api.bean.dto.LogSummaryDto;
import com.junmp.jyzb.api.bean.dto.LogSummarySecondDto;
import com.junmp.jyzb.api.bean.dto.OrderLogDto;
import com.junmp.jyzb.api.bean.query.InventoryReq;
import com.junmp.jyzb.api.bean.query.LogDetailReq;
import com.junmp.jyzb.api.bean.query.LogSummaryReq;
import com.junmp.jyzb.api.bean.query.QueryLogSummarySecondReq;
import com.junmp.jyzb.api.bean.req.UpdatePoliceEquipmentReq;
import com.junmp.jyzb.entity.LogDetail;
import com.junmp.jyzb.entity.LogSummary;
import com.junmp.jyzb.service.*;
import com.junmp.v2.common.bean.request.ValidationApi;
import com.junmp.v2.common.bean.response.ApiRes;
import com.junmp.v2.db.api.page.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
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 javax.annotation.Resource;
import java.util.List;

@RestController
@Slf4j
@RequestMapping("/OutAndInRecords")
@Api(tags = "[业务]出入库模块")
public class OutAndInboundController {

    @Resource
    public LogSummaryService logSummaryService;

    @Resource
    private LogDetailService logDetailService;

    @Resource
    private OrderLogService orderLogService;

    @ApiOperation("/查看出入库详情")
    @PostMapping(path="/GetDetailByLogSumId",name="查看出入库详情#enable")
    public ApiRes<List<LogDetailDto>> GetDetailByLogSumId(@RequestBody @Validated(ValidationApi.detail.class) LogDetailReq req){
        return ApiRes.success(logDetailService.GetDetailByLogSumId(req));
    }

    //装备出入库记录（根据单据id,sizeId,typeId）
    @PostMapping(path="/ShowInOutRecordsByOrder",name="出入库单据查询展示（子单记录）#enable")
    @ApiOperation("出入库单据查询展示(子单的记录)")
    public ApiRes<List<LogDetailDto>> ShowInOutRecordsByOrder(@RequestBody @Validated(ValidationApi.detail.class) LogSummaryReq req){
        return ApiRes.success(logDetailService.ShowInOutRecordsByOrder(req));
    }


    @PostMapping(path = "/RecordSumByOrderId",name = "出入库单据查询展示（整个单子的记录）#enable")
    @ApiOperation("出入库单据查询展示（整个单子的记录）")
    public ApiRes<PageResult<LogSummaryDto>> RecordSumByOrderId (@RequestBody LogSummaryReq req){
        return ApiRes.success(logSummaryService.RecordSumByOrderId(req));
    }

    @PostMapping(path = "/RecordSumByOrderIdCount",name = "出入库单据查询展示（整个单子的记录）#enable")
    @ApiOperation("出入库单据查询展示（整个单子的记录）")
    public ApiRes<LogSummaryDto> RecordSumByOrderIdCount (@RequestBody LogSummaryReq req){
        return ApiRes.success(logSummaryService.RecordSumByOrderIdCount(req));
    }

    //装备出入库记录（根据条件查询）

    @PostMapping(path="/ShowInOutRecordsByItems",name="出入库记录条件查询展示#enable")
    @ApiOperation("出入库记录条件查询展示")
    public ApiRes<PageResult<LogSummary>> ShowInOutRecordsByItems(@RequestBody @Validated(ValidationApi.page.class) LogSummaryReq req){
        return ApiRes.success(logSummaryService.ShowInOutRecordsByItems(req));
    }

    @PostMapping(path="/ShowInOutRecordsByItemsCount",name="出入库记录条件查询展示合计#enable")
    @ApiOperation("出入库记录条件查询展示合计")
    public ApiRes<LogSummaryDto> ShowInOutRecordsByItemsCount(@RequestBody @Validated(ValidationApi.page.class) LogSummaryReq req){
        return ApiRes.success(logSummaryService.ShowInOutRecordsByItemsCount(req));
    }


    @PostMapping(path = "/ShowInOutRecords",name = "出入库数据展示#enable")
    @ApiOperation("出入库数据展示")
    public ApiRes<PageResult<LogSummary>> ShowInOutRecords(@RequestBody LogSummaryReq req){
        return ApiRes.success(logSummaryService.ShowInOutRecords(req));
    }


    //通过装备id查询某一件装备的出入库记录

    @PostMapping(path="/ShowInOutRecordsByEqs",name="出入库记录装备id查询展示#enable")
    @ApiOperation("出入库记录装备id查询展示")
    public ApiRes<PageResult<LogDetail>> getInOutRecords(@RequestBody @Validated(ValidationApi.page.class) InventoryReq req){
        return ApiRes.success(logDetailService.getInOutRecords(req));
    }

    @PostMapping(path="/ShowRecordsByOrderId",name="出入库以及记账过程#enable")
    @ApiOperation("出入库以及记账过程")
    public ApiRes<List<OrderLogDto>> ShowRecordsByOrderId(@RequestBody @Validated(ValidationApi.detail.class) LogSummaryReq req){
        return ApiRes.success(orderLogService.ShowRecordsByOrderId(req));
    }


    @PostMapping(path="/getSecondInfoByLogSumId",name="根据出入库汇总id查询二级信息#enable")
    @ApiOperation("根据出入库汇总id查询二级信息")
    public ApiRes<List<LogSummarySecondDto>> getSecondInfoByLogSumId(@RequestBody @Validated(ValidationApi.detail.class) QueryLogSummarySecondReq req){
        return ApiRes.success(orderLogService.getSecondInfoByLogSumId(req));
    }


}
