package vip.xiaonuo.biz.api.mini.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import vip.xiaonuo.auth.core.enums.SaClientTypeEnum;
import vip.xiaonuo.auth.core.pojo.SaBaseLoginUser;
import vip.xiaonuo.auth.modular.login.enums.AuthDeviceTypeEnum;
import vip.xiaonuo.auth.modular.login.service.AuthService;
import vip.xiaonuo.biz.api.DictOptions.param.DictOptionsParam;
import vip.xiaonuo.biz.api.DictOptions.service.DictOptionsService;
import vip.xiaonuo.biz.api.mini.entity.MiNiLoginParam;
import vip.xiaonuo.biz.api.mini.service.MiNiService;
import vip.xiaonuo.biz.api.wxapp.entity.WeiXinRes;
import vip.xiaonuo.biz.core.Const.BizStr;
import vip.xiaonuo.biz.modular.depotAccessRecord.entity.DepotAccessRecord;
import vip.xiaonuo.biz.modular.depotAccessRecord.service.DepotAccessRecordService;
import vip.xiaonuo.biz.modular.depotDevice.entity.DepotDevice;
import vip.xiaonuo.biz.modular.depotDevice.param.DepotDevicePageParam;
import vip.xiaonuo.biz.modular.depotDevice.service.DepotDeviceService;
import vip.xiaonuo.biz.modular.depotDeviceWarn.entity.DepotDeviceWarn;
import vip.xiaonuo.biz.modular.depotDeviceWarn.param.DepotDeviceWarnIdParam;
import vip.xiaonuo.biz.modular.depotDeviceWarn.param.DepotDeviceWarnPageParam;
import vip.xiaonuo.biz.modular.depotDeviceWarn.param.DepotDeviceWarnProcessParam;
import vip.xiaonuo.biz.modular.depotDeviceWarn.service.DepotDeviceWarnService;
import vip.xiaonuo.biz.modular.depotFlyerSiteLog.entity.DepotFlyerSiteLog;
import vip.xiaonuo.biz.modular.depotFlyerSiteLog.param.*;
import vip.xiaonuo.biz.modular.depotFlyerSiteLog.service.DepotFlyerSiteLogService;
import vip.xiaonuo.biz.modular.depotGrainInfo.entity.DepotGrainInfo;
import vip.xiaonuo.biz.modular.depotGrainInfo.param.DepotGrainInfoPageParam;
import vip.xiaonuo.biz.modular.depotGrainInfo.service.DepotGrainInfoService;
import vip.xiaonuo.biz.modular.depotGrainInfoWarn.entity.DepotGrainInfoWarn;
import vip.xiaonuo.biz.modular.depotGrainInfoWarn.param.DepotGrainInfoWarnPageParam;
import vip.xiaonuo.biz.modular.depotGrainInfoWarn.service.DepotGrainInfoWarnService;
import vip.xiaonuo.biz.modular.depotLoanGrant.entity.DepotLoanGrant;
import vip.xiaonuo.biz.modular.depotLoanGrant.param.DepotLoanGrantIdParam;
import vip.xiaonuo.biz.modular.depotLoanGrant.param.DepotLoanGrantPageParam;
import vip.xiaonuo.biz.modular.depotLoanGrant.service.DepotLoanGrantService;
import vip.xiaonuo.biz.modular.depotLockBook.entity.DepotLockBook;
import vip.xiaonuo.biz.modular.depotLockBook.param.DepotLockBookAddParam;
import vip.xiaonuo.biz.modular.depotLockBook.param.DepotLockBookEditParam;
import vip.xiaonuo.biz.modular.depotLockBook.param.DepotLockBookPageParam;
import vip.xiaonuo.biz.modular.depotLockBook.service.DepotLockBookService;
import vip.xiaonuo.biz.modular.depotRepayOrder.entity.DepotRepayOrder;
import vip.xiaonuo.biz.modular.depotRepayOrder.param.DepotRepayOrderApprovalParam;
import vip.xiaonuo.biz.modular.depotRepayOrder.param.DepotRepayOrderIdParam;
import vip.xiaonuo.biz.modular.depotRepayOrder.param.DepotRepayOrderPageParam;
import vip.xiaonuo.biz.modular.depotRepayOrder.service.DepotRepayOrderService;
import vip.xiaonuo.biz.modular.depotSampling.entity.DepotSampling;
import vip.xiaonuo.biz.modular.depotSampling.param.DepotSamplingAddParam;
import vip.xiaonuo.biz.modular.depotSampling.param.DepotSamplingEditParam;
import vip.xiaonuo.biz.modular.depotSampling.param.DepotSamplingPageParam;
import vip.xiaonuo.biz.modular.depotSampling.service.DepotSamplingService;
import vip.xiaonuo.biz.modular.depotTruckAdmitFlow.entity.DepotTruckAdmitFlow;
import vip.xiaonuo.biz.modular.depotTruckAdmitFlow.param.DepotTruckAdmitFlowPageParam;
import vip.xiaonuo.biz.modular.depotTruckAdmitFlow.service.DepotTruckAdmitFlowService;
import vip.xiaonuo.biz.modular.depotTruckBook.entity.DepotTruckBook;
import vip.xiaonuo.biz.modular.depotTruckBook.param.*;
import vip.xiaonuo.biz.modular.depotTruckBook.service.DepotTruckBookService;
import vip.xiaonuo.biz.modular.depotTruckLade.entity.DepotTruckLade;
import vip.xiaonuo.biz.modular.depotTruckLade.param.DepotTruckLadeAddPicParam;
import vip.xiaonuo.biz.modular.depotTruckLade.param.DepotTruckLadePageParam;
import vip.xiaonuo.biz.modular.depotTruckLade.service.DepotTruckLadeService;
import vip.xiaonuo.biz.modular.depotTruckWeighDouble.entity.DepotTruckWeighDouble;
import vip.xiaonuo.biz.modular.depotTruckWeighDouble.param.*;
import vip.xiaonuo.biz.modular.depotTruckWeighDouble.service.DepotTruckWeighDoubleService;
import vip.xiaonuo.biz.modular.depotTruckWeighPlug.entity.DepotTruckWeighPlug;
import vip.xiaonuo.biz.modular.depotTruckWeighPlug.param.DepotTruckWeighPlugAddParam;
import vip.xiaonuo.biz.modular.depotTruckWeighPlug.param.DepotTruckWeighPlugEditParam;
import vip.xiaonuo.biz.modular.depotTruckWeighPlug.param.DepotTruckWeighPlugIdParam;
import vip.xiaonuo.biz.modular.depotTruckWeighPlug.param.DepotTruckWeighPlugPageParam;
import vip.xiaonuo.biz.modular.depotTruckWeighPlug.service.DepotTruckWeighPlugService;
import vip.xiaonuo.biz.modular.depotUserOnlineLog.entity.DepotUserOnlineLog;
import vip.xiaonuo.biz.modular.depotUserOnlineLog.param.DepotUserOnlineLogAddParam;
import vip.xiaonuo.biz.modular.depotUserOnlineLog.param.DepotUserOnlineLogPageParam;
import vip.xiaonuo.biz.modular.depotUserOnlineLog.service.DepotUserOnlineLogService;
import vip.xiaonuo.biz.modular.depotWorkAlarm.entity.DepotWorkAlarm;
import vip.xiaonuo.biz.modular.depotWorkAlarm.param.DepotWorkAlarmPageParam;
import vip.xiaonuo.biz.modular.depotWorkAlarm.service.DepotWorkAlarmService;
import vip.xiaonuo.common.annotation.CommonLog;
import vip.xiaonuo.common.pojo.CommonResult;
import vip.xiaonuo.common.util.DatesUtil;
import vip.xiaonuo.sys.api.SysRoleApi;
import vip.xiaonuo.sys.modular.user.param.SysUserUpdatePwdParam;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Map;

@Api(tags = "微信小程序控制器")
@ApiSupport(author = "SNOWY_TEAM", order = 1)
@RestController
@Validated
public class MiNiController {

    @Resource
    MiNiService miNiService;
    @Resource
    AuthService authService;
    @Resource
    SysRoleApi sysRoleApi;

    /**
     * 小程序登录
     *
     * @author xuyuxiang
     * @date 2021/10/15 13:12
     **/
    @ApiOperationSupport(order = 3)
    @ApiOperation("小程序登录")
    @PostMapping("/api/mini/doLogin")
    public CommonResult<Object> doLogin(@RequestBody MiNiLoginParam param) {
        return CommonResult.data(miNiService.doLogin(param, SaClientTypeEnum.B.getValue()));
    }

    /**
     * 小程序退出登录
     *
     * @author xuyuxiang
     * @date 2021/10/15 13:12
     **/
    @ApiOperationSupport(order = 3)
    @ApiOperation("小程序退出登录")
    @PostMapping("/api/mini/doLogout")
    public CommonResult<Object> doLogout() {
        StpUtil.logout();
        return CommonResult.ok();
    }

    /**
     * 小程序修改用户密码
     *
     * @author xuyuxiang
     * @date 2021/10/15 13:12
     **/
    @ApiOperationSupport(order = 3)
    @ApiOperation("小程序修改用户密码")
    @PostMapping("/api/mini/updatePassword")
    public CommonResult<Object> updatePassword(@RequestBody @Valid SysUserUpdatePwdParam sysUserUpdatePwdParam) {
        miNiService.updatePassword(sysUserUpdatePwdParam, SaClientTypeEnum.B.getValue());
        return CommonResult.ok();
    }

    /**
     * 小程序获取用户信息
     *
     * @author xuyuxiang
     * @date 2021/10/15 13:12
     **/
    @ApiOperationSupport(order = 6)
    @ApiOperation("小程序获取用户信息")
    @PostMapping("/api/mini/getLoginUser")
    public CommonResult<Object> getLoginUser() {
        SaBaseLoginUser loginUser = authService.getLoginUser();
        Map<String, Object> map = BeanUtil.beanToMap(loginUser);
        map.put("roleNameList", sysRoleApi.getNameByCodes(loginUser.getRoleCodeList()));
        return CommonResult.data(map);
    }

    /**
     * openId 绑定
     *
     * @param param jsCode
     * @return ok
     */
    @ApiOperationSupport(order = 6)
    @ApiOperation("小程序绑定账号")
    @PostMapping("/api/mini/binding")
    public CommonResult<Object> binding(@RequestBody WeiXinRes param) {
        miNiService.binding(param);
        return CommonResult.ok();
    }

    @Resource
    DepotWorkAlarmService depotWorkAlarmService;

    /**
     * 小程序获取出入库异常分页
     *
     * @author xiang
     * @date 2023/09/18 11:09
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("小程序获取出入库异常分页")
    @SaCheckPermission("/biz/depotWorkAlarm/page")
    @CommonLog("小程序获取出入库异常分页")
    @GetMapping("/api/mini/depotWorkAlarm/page")
    public CommonResult<Page<DepotWorkAlarm>> page(DepotWorkAlarmPageParam depotWorkAlarmPageParam) {
        return CommonResult.data(depotWorkAlarmService.page(depotWorkAlarmPageParam));
    }

    /**
     * 小程序出入库异常处理
     *
     * @author xiang
     * @date 2023/09/18 11:09
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("小程序出入库异常处理")
    @SaCheckPermission("/biz/depotWorkAlarm/page")
    @CommonLog("小程序出入库异常处理")
    @PostMapping("/api/mini/depotWorkAlarm/processTo")
    public CommonResult<Object> processTo(@RequestBody DepotWorkAlarm param) {
        depotWorkAlarmService.processTo(param);
        return CommonResult.ok();
    }

    /**
     * 小程序获取出入库记录统计
     *
     * @author xiang
     * @date 2023/10/08 17:05
     */
    @ApiOperationSupport(order = 5)
    @ApiOperation("小程序获取出入库记录统计")
    @SaCheckPermission("/biz/depotWork/page")
    @CommonLog("小程序获取出入库记录统计")
    @GetMapping("/api/mini/depotWork/statsDate")
    public CommonResult<Object> statsDate(@Valid StatisticsParam param) {
        return CommonResult.data(miNiService.statsDate(param));
    }

    @Resource
    private DictOptionsService dictOptionsService;

    /**
     * 字典
     *
     * @author xuyuxiang
     * @date 2021/10/15 13:12
     **/
    @ApiOperationSupport(order = 3)
    @ApiOperation("小程序字典")
    @GetMapping("/api/mini/dict/tree")
    public CommonResult<Object> dict(DictOptionsParam dictOptionsParam) {
        return CommonResult.data(dictOptionsService.dictOptions(dictOptionsParam, AuthDeviceTypeEnum.MINI.getValue()));
    }

    @Resource
    private DepotGrainInfoService depotGrainInfoService;

    /**
     * 小程序获取企业客户档案分页
     *
     * @author xiang
     * @date 2023/09/14 15:00
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("小程序获取企业客户档案分页")
    @CommonLog("小程序获取企业客户档案分页")
    @SaCheckPermission("/biz/depotGrainInfo/page")
    @GetMapping("/api/mini/depotGrainInfo/page")
    public CommonResult<Object> page(DepotGrainInfoPageParam param) {
        return CommonResult.data(depotGrainInfoService.page(param));
    }

    /**
     * 小程序获取企业客户档案详情
     *
     * @author xiang
     * @date 2023/09/14 15:00
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("小程序获取企业客户档案信息")
    @SaCheckPermission("/biz/depotGrainInfo/page")
    @GetMapping("/api/mini/depotGrainInfo/detail")
    public CommonResult<Object> detail(DepotGrainInfo param) {
        return CommonResult.data(depotGrainInfoService.detail(param));
    }

    @Resource
    private DepotGrainInfoWarnService depotGrainInfoWarnService;

    /**
     * 小程序获取客户预警处理分页
     *
     * @author xiang
     * @date 2023/09/14 16:20
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("小程序获取客户预警处理分页")
    @SaCheckPermission("/biz/depotGrainInfoWarn/page")
    @GetMapping("/api/mini/depotGrainInfoWarn/page")
    public CommonResult<Page<DepotGrainInfoWarn>> page(DepotGrainInfoWarnPageParam depotGrainInfoWarnPageParam) {
        return CommonResult.data(depotGrainInfoWarnService.page(depotGrainInfoWarnPageParam));
    }

    @Resource
    private DepotTruckBookService depotTruckBookService;

    /**
     * 小程序获取车辆预约表分页
     *
     * @author xiang
     * @date 2023/09/13 09:21
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("小程序获取车辆预约表分页")
    @CommonLog("小程序获取车辆预约表分页")
    @GetMapping("/api/mini/depotTruckBook/page")
    public CommonResult<Page<DepotTruckBook>> page(DepotTruckBookPageParam truckBookPageParam) {
        DepotTruckBookPageParam param = BeanUtil.copyProperties(truckBookPageParam, DepotTruckBookPageParam.class);
        if (BizStr.KU_RU.equals(param.getDepotBizType())
                && BizStr.BOOK_RIGHT.equals(param.getBookState())
                && BizStr.STATE_APPROVAL_Y.equals(param.getDepotOpApprovalState()))
            param.setBizFlowName("扦样选择");
        return CommonResult.data(depotTruckBookService.page(param));
    }

    /**
     * 小程序添加车辆预约表
     *
     * @author xiang
     * @date 2023/09/13 09:21
     */
    @ApiOperationSupport(order = 2)
    @ApiOperation("小程序添加车辆预约表")
    @CommonLog("小程序添加车辆预约表")
    @PostMapping("/api/mini/depotTruckBook/add")
    public CommonResult<String> add(@RequestBody @Valid DepotTruckBookAddParam depotTruckBookAddParam) {
        depotTruckBookService.add(depotTruckBookAddParam);
        return CommonResult.ok();
    }

    /**
     * 小程序获取车辆预约表详情
     *
     * @author xiang
     * @date 2023/09/13 09:21
     */
    @ApiOperationSupport(order = 5)
    @ApiOperation("小程序获取车辆预约表详情")
    @GetMapping("/api/mini/depotTruckBook/detail")
    public CommonResult<DepotTruckBook> detail(DepotTruckBook param) {
        return CommonResult.data(depotTruckBookService.detail(param));
    }

    /**
     * 小程序车辆预约表一级审批
     *
     * @author xiang
     * @date 2023/09/13 09:21
     */
    @ApiOperationSupport(order = 3)
    @ApiOperation("小程序车辆预约表一级审批")
    @CommonLog("小程序车辆预约表一级审批")
    @SaCheckPermission("/biz/depotTruckBook/depotOpApproval")
    @PostMapping("/api/mini/depotTruckBook/depotOpApproval")
    public CommonResult<String> depotOpApproval(@RequestBody @Valid DepotTruckBookApprovalParam param) {
        depotTruckBookService.depotOpApproval(param);
        return CommonResult.ok();
    }

    @Resource
    private DepotTruckAdmitFlowService depotTruckAdmitFlowService;

    /**
     * 小程序获取车辆接待流程表分页
     *
     * @author xiang
     * @date 2023/09/13 18:44
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("小程序获取车辆接待流程表分页")
    @SaCheckPermission("/biz/depotTruckAdmitFlow/page")
    @GetMapping("/api/mini/depotTruckAdmitFlow/page")
    public CommonResult<Page<DepotTruckAdmitFlow>> page(DepotTruckAdmitFlowPageParam depotTruckAdmitFlowPageParam) {
        return CommonResult.data(depotTruckAdmitFlowService.page(depotTruckAdmitFlowPageParam));
    }

    @Resource
    DepotTruckLadeService truckLadeService;

    /**
     * 小程序获取车辆装卸货管理表分页
     *
     * @author xiang
     * @date 2023/10/16 14:18
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("小程序获取车辆装卸货管理表分页")
    @CommonLog("小程序获取车辆装卸货管理表分页")
    @SaCheckPermission("/biz/depotTruckLade/page")
    @GetMapping("/api/mini/depotTruckLade/page")
    public CommonResult<Page<DepotTruckLade>> page(DepotTruckLadePageParam depotTruckLadePageParam) {
        return CommonResult.data(truckLadeService.page(depotTruckLadePageParam));
    }

    /**
     * 小程序获取车辆装卸货管理表详情
     *
     * @author xiang
     * @date 2023/10/16 14:18
     */
    @ApiOperationSupport(order = 5)
    @ApiOperation("小程序获取车辆装卸货管理表详情")
    @SaCheckPermission("/biz/depotTruckLade/detail")
    @GetMapping("/api/mini/depotTruckLade/detail")
    public CommonResult<DepotTruckLade> detail(@Valid DepotTruckLade param) {
        return CommonResult.data(truckLadeService.detail(param));
    }

    /**
     * 小程序添加车辆装卸货一次照片
     *
     * @author xiang
     * @date 2023/10/16 11:40
     */
    @ApiOperationSupport(order = 2)
    @ApiOperation("小程序添加车辆装卸货一次照片")
    @CommonLog("小程序添加车辆装卸货一次照片")
    @SaCheckPermission("/biz/depotTruckLade/add")
    @PostMapping("/api/mini/depotTruckLade/addOnePic")
    public CommonResult<String> addOnePic(@RequestBody @Valid DepotTruckLadeAddPicParam param) {
        truckLadeService.addOnePic(param);
        return CommonResult.ok();
    }

    /**
     * 小程序添加车辆装卸货二次照片
     *
     * @author xiang
     * @date 2023/10/16 11:40
     */
    @ApiOperationSupport(order = 2)
    @ApiOperation("小程序添加车辆装卸货二次照片")
    @CommonLog("小程序添加车辆装卸货二次照片")
    @SaCheckPermission("/biz/depotTruckLade/add")
    @PostMapping("/api/mini/depotTruckLade/addTwoPic")
    public CommonResult<String> addTwoPic(@RequestBody @Valid DepotTruckLadeAddPicParam param) {
        param.setShedName(null);
        truckLadeService.addTwoPic(param);
        return CommonResult.ok();
    }

    @Resource
    private DepotTruckWeighDoubleService depotTruckWeighDoubleService;

    /**
     * 小程序获取双次过磅记录表分页
     *
     * @author xiang
     * @date 2023/10/08 17:05
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("小程序获取双次过磅记录表分页")
    @SaCheckPermission("/biz/depotTruckWeighDouble/page")
    @GetMapping("/api/mini/depotTruckWeighDouble/page")
    public CommonResult<Page<DepotTruckWeighDouble>> page(DepotTruckWeighDoublePageParam depotTruckWeighDoublePageParam) {
        return CommonResult.data(depotTruckWeighDoubleService.page(depotTruckWeighDoublePageParam));
    }

    /**
     * 小程序获取双次过磅记录表详情
     *
     * @author xiang
     * @date 2023/10/08 17:05
     */
    @ApiOperationSupport(order = 5)
    @ApiOperation("小程序获取双次过磅记录表详情")
    @SaCheckPermission("/biz/depotTruckWeighDouble/page")
    @GetMapping("/api/mini/depotTruckWeighDouble/detail")
    public CommonResult<DepotTruckWeighDouble> detail(@Valid DepotTruckWeighDoubleIdParam param) {
        return CommonResult.data(depotTruckWeighDoubleService.detail(param.getId(), param.getTruckBookId()));
    }

    /**
     * 小程序获取双次过磅记录统计
     *
     * @author xiang
     * @date 2023/10/08 17:05
     */
    @ApiOperationSupport(order = 5)
    @ApiOperation("小程序获取双次过磅记录统计")
    @SaCheckPermission("/biz/depotTruckWeighDouble/page")
    @GetMapping("/api/mini/depotTruckWeighDouble/statistics")
    public CommonResult<Object> statistics(@Valid StatisticsParam param) {
        return CommonResult.data(miNiService.statistics(param));
    }

    @Resource
    DepotTruckWeighPlugService depotTruckWeighPlugService;

    /**
     * 小程序获取车辆称重补单表分页
     *
     * @author xiang
     * @date 2023/11/27 08:54
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("小程序获取车辆称重补单表分页")
    @SaCheckPermission("/biz/depotTruckWeighPlug/page")
    @GetMapping("/api/mini/depotTruckWeighPlug/page")
    public CommonResult<Page<DepotTruckWeighPlug>> page(DepotTruckWeighPlugPageParam depotTruckWeighPlugPageParam) {
        return CommonResult.data(depotTruckWeighPlugService.page(depotTruckWeighPlugPageParam));
    }

    /**
     * 小程序双次过磅记录人工补单
     *
     * @author xiang
     * @date 2023/10/08 17:05
     */
    @ApiOperationSupport(order = 5)
    @ApiOperation("小程序双次过磅记录人工补单")
    @CommonLog("小程序双次过磅记录人工补单")
    @SaCheckPermission("/biz/depotTruckWeighPlug/add")
    @PostMapping("/api/mini/depotTruckWeighPlug/add")
    public CommonResult<Object> add(@RequestBody @Valid DepotTruckWeighPlugAddParam param) {
        depotTruckWeighPlugService.add(param);
        return CommonResult.ok();
    }

    /**
     * 小程序人工补单审批
     *
     * @author xiang
     * @date 2023/10/08 17:05
     */
    @ApiOperationSupport(order = 5)
    @ApiOperation("小程序人工补单审批")
    @CommonLog("小程序人工补单审批")
    @SaCheckPermission("/biz/depotTruckWeighPlug/edit")
    @PostMapping("/api/mini/depotTruckWeighPlug/bankOpApproval")
    public CommonResult<Object> bankOpApproval(@RequestBody @Valid DepotTruckWeighPlugEditParam param) {
        depotTruckWeighPlugService.bankOpApproval(param);
        return CommonResult.ok();
    }

    /**
     * 小程序获取车辆称重补单表详情
     *
     * @author xiang
     * @date 2023/11/27 08:54
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("小程序获取车辆称重补单表详情")
    @SaCheckPermission("/biz/depotTruckWeighPlug/page")
    @GetMapping("/api/mini/depotTruckWeighPlug/detail")
    public CommonResult<DepotTruckWeighPlug> detail(@Valid DepotTruckWeighPlugIdParam depotTruckWeighPlugIdParam) {
        return CommonResult.data(depotTruckWeighPlugService.detail(depotTruckWeighPlugIdParam));
    }

    @Resource
    DepotAccessRecordService accessRecordService;

    /**
     * 小程序获取车辆进出场详情
     *
     * @author xiang
     * @date 2023/09/13 16:37
     */
    @ApiOperationSupport(order = 5)
    @ApiOperation("小程序获取车辆进出场详情")
    @GetMapping("/api/mini/depotAccessRecord/detail")
    public CommonResult<DepotAccessRecord> detail(DepotAccessRecord param) {
        return CommonResult.data(accessRecordService.detail(param));
    }

    @Resource
    private DepotSamplingService depotSamplingService;

    /**
     * 小程序扦样单分页
     *
     * @author xiang
     * @date 2023/09/13 16:37
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("小程序扦样单分页")
    @SaCheckPermission("/biz/depotSampling/page")
    @GetMapping("/api/mini/depotSampling/page")
    public CommonResult<Page<DepotSampling>> page(DepotSamplingPageParam depotSamplingPageParam) {
        return CommonResult.data(depotSamplingService.page(depotSamplingPageParam));
    }

    /**
     * 小程序扦样单详情
     *
     * @author xiang
     * @date 2023/09/13 16:37
     */
    @ApiOperationSupport(order = 5)
    @ApiOperation("小程序扦样单详情")
    @GetMapping("/api/mini/depotSampling/detail")
    public CommonResult<DepotSampling> detail(DepotSampling param) {
        return CommonResult.data(depotSamplingService.detail(param));
    }

    /**
     * 小程序扦样单添加
     *
     * @author xiang
     * @date 2023/09/13 16:37
     */
    @ApiOperationSupport(order = 2)
    @ApiOperation("小程序扦样单添加")
    @CommonLog("小程序扦样单添加")
    @SaCheckPermission("/biz/depotSampling/add")
    @PostMapping("/api/mini/depotSampling/add")
    public CommonResult<String> add(@RequestBody @Valid DepotSamplingAddParam param) {
        depotSamplingService.addSampling(param);
        return CommonResult.ok();
    }

    /**
     * 小程序扦样单驳回
     *
     * @author xiang
     * @date 2023/09/13 16:37
     */
    @ApiOperationSupport(order = 5)
    @ApiOperation("小程序扦样单驳回")
    @CommonLog("小程序扦样单驳回")
    @RequestMapping("/api/mini/depotSampling/reject")
    public CommonResult<DepotSampling> reject(@RequestBody DepotSampling param) {
        depotSamplingService.reject(param.getTruckBookId());
        return CommonResult.ok();
    }

    /**
     * 小程序扦样单二级审批确认
     *
     * @author xiang
     * @date 2023/09/13 09:21
     */
    @ApiOperationSupport(order = 3)
    @ApiOperation("小程序扦样单二级审批确认")
    @CommonLog("小程序扦样单二级审批确认")
    @SaCheckPermission("/biz/depotSampling/bankOpApproval")
    @PostMapping("/api/mini/depotSampling/bankOpApproval")
    public CommonResult<String> bankOpApproval(@RequestBody @Valid DepotSamplingEditParam param) {
        depotSamplingService.edit(new DepotSamplingEditParam(param.getId(), param.getSaveState(), DatesUtil.forDateTime()));
        return CommonResult.ok();
    }

    @Resource
    private DepotLockBookService depotLockBookService;

    /**
     * 小程序获取电子锁预约分页
     *
     * @author xiang
     * @date 2023/09/14 09:44
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("小程序获取电子锁预约分页")
    @SaCheckPermission("/biz/depotLockBook/page")
    @GetMapping("/api/mini/depotLockBook/page")
    public CommonResult<Page<DepotLockBook>> page(DepotLockBookPageParam param) {
        if (BizStr.STATE_CONFIRM_G.equals(param.getBankOpApprovalState()))
            param.setBankOpApprovalState(BizStr.STATE_APPROVAL_N);
        else if (BizStr.STATE_CONFIRM_Y.equals(param.getBankOpApprovalState()))
            param.setBankOpApprovalState(BizStr.STATE_APPROVAL_PASS_Y + BizStr.STATE_APPROVAL_PASS_G);
        return CommonResult.data(depotLockBookService.page(param));
    }

    /**
     * 小程序添加电子锁预约
     *
     * @author xiang
     * @date 2023/09/14 09:44
     */
    @ApiOperationSupport(order = 2)
    @ApiOperation("小程序添加电子锁预约")
    @CommonLog("小程序添加电子锁预约")
    @SaCheckPermission("/biz/depotLockBook/add")
    @PostMapping("/api/mini/depotLockBook/add")
    public CommonResult<String> add(@RequestBody @Valid DepotLockBookAddParam depotLockBookAddParam) {
        depotLockBookService.add(depotLockBookAddParam);
        return CommonResult.ok();
    }

    /**
     * 小程序电子锁预约二级审批
     *
     * @author xiang
     * @date 2023/09/14 09:44
     */
    @ApiOperationSupport(order = 3)
    @ApiOperation("小程序电子锁预约二级审批")
    @CommonLog("小程序电子锁预约二级审批")
    @SaCheckPermission("/biz/depotLockBook/bankOpApproval")
    @PostMapping("/api/mini/depotLockBook/bankOpApproval")
    public CommonResult<String> bankOpApproval(@RequestBody @Valid DepotLockBookEditParam param) {
        depotLockBookService.edit(new DepotLockBookEditParam(param.getId(), param.getBankOpApprovalState(), param.getBankOpApprovalRemark()));
        return CommonResult.ok();
    }

    @Resource
    private DepotFlyerSiteLogService depotFlyerSiteLogService;

    /**
     * 小程序获取飞行监管分页
     *
     * @author xiang
     * @date 2023/09/19 09:12
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("小程序获取飞行监管分页")
    @SaCheckPermission("/biz/depotFlyerSiteLog/page")
    @GetMapping("/api/mini/depotFlyerSiteLog/page")
    public CommonResult<Page<DepotFlyerSiteLog>> page(DepotFlyerSiteLogPageParam depotFlyerSiteLogPageParam) {
        return CommonResult.data(depotFlyerSiteLogService.page(depotFlyerSiteLogPageParam));
    }

    /**
     * 获小程序取飞行监管详情
     *
     * @author xiang
     * @date 2023/09/19 09:12
     */
    @ApiOperationSupport(order = 5)
    @ApiOperation("小程序获取飞行监管详情")
    @SaCheckPermission("/biz/depotFlyerSiteLog/detail")
    @GetMapping("/api/mini/depotFlyerSiteLog/detail")
    public CommonResult<DepotFlyerSiteLog> detail(@Valid DepotFlyerSiteLogIdParam depotFlyerSiteLogIdParam) {
        return CommonResult.data(depotFlyerSiteLogService.detail(depotFlyerSiteLogIdParam));
    }

    /**
     * 小程序添加飞行监管
     *
     * @author xiang
     * @date 2023/09/19 09:12
     */
    @ApiOperationSupport(order = 2)
    @ApiOperation("小程序添加飞行监管")
    @CommonLog("小程序添加飞行监管")
    @SaCheckPermission("/biz/depotFlyerSiteLog/add")
    @PostMapping("/api/mini/depotFlyerSiteLog/add")
    public CommonResult<String> add(@RequestBody @Valid DepotFlyerSiteLogAddParam depotFlyerSiteLogAddParam) {
        depotFlyerSiteLogService.add(depotFlyerSiteLogAddParam);
        return CommonResult.ok();
    }

    /**
     * 小程序飞行监管处理中
     *
     * @author xiang
     * @date 2023/09/19 09:12
     */
    @ApiOperationSupport(order = 2)
    @ApiOperation("小程序飞行监管处理中")
    @CommonLog("小程序飞行监管处理中")
    @SaCheckPermission("/biz/depotFlyerSiteLog/edit")
    @PostMapping("/api/mini/depotFlyerSiteLog/processTo")
    public CommonResult<String> processTo(@RequestBody @Valid DepotFlyerSiteLogEditProcessParam param) {
        depotFlyerSiteLogService.edit(new DepotFlyerSiteLogEditParam(param.getId(), param.getSaveState(), param.getSaveMsg(), param.getFile()));
        return CommonResult.ok();
    }

    /**
     * 小程序飞行监管处理完成
     *
     * @author xiang
     * @date 2023/09/19 09:12
     */
    @ApiOperationSupport(order = 2)
    @ApiOperation("小程序飞行监管处理完成")
    @CommonLog("小程序飞行监管处理完成")
    @SaCheckPermission("/biz/depotFlyerSiteLog/edit")
    @PostMapping("/api/mini/depotFlyerSiteLog/processFinish")
    public CommonResult<String> processFinish(@RequestBody @Valid DepotFlyerSiteLogEditParam param) {
        depotFlyerSiteLogService.processFinish(param);
        return CommonResult.ok();
    }

    @Resource
    private DepotDeviceService depotDeviceService;

    /**
     * 小程序获取设备列表分页
     *
     * @author xiang
     * @date 2023/09/19 10:12
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("小程序获取设备列表分页")
    @SaCheckPermission("/biz/depotDevice/page")
    @GetMapping("/api/mini/depotDevice/page")
    public CommonResult<Page<DepotDevice>> page(DepotDevicePageParam depotDevicePageParam) {
        return CommonResult.data(depotDeviceService.page(depotDevicePageParam));
    }

    @Resource
    DepotDeviceWarnService deviceWarnService;

    /**
     * 小程序获取设备离线预警分页
     *
     * @author xiang
     * @date 2023/09/19 10:12
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("小程序获取设备离线预警分页")
    @SaCheckPermission("/biz/depotDeviceWarn/page")
    @GetMapping("/api/mini/depotDeviceWarn/page")
    public CommonResult<Page<DepotDeviceWarn>> page(DepotDeviceWarnPageParam param) {
        return CommonResult.data(deviceWarnService.page(param));
    }

    /**
     * 小程序获取设备离线预警详情
     *
     * @author xiang
     * @date 2023/09/19 10:12
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("小程序获取设备离线预警分页")
    @SaCheckPermission("/biz/depotDeviceWarn/page")
    @GetMapping("/api/mini/depotDeviceWarn/detail")
    public CommonResult<DepotDeviceWarn> detail(@Valid DepotDeviceWarnIdParam param) {
        return CommonResult.data(deviceWarnService.detail(param));
    }

    /**
     * 小程序设备离线预警处理
     *
     * @author xiang
     * @date 2023/09/19 10:12
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("小程序设备离线预警处理")
    @CommonLog("小程序设备离线预警处理")
    @SaCheckPermission("/biz/depotDeviceWarn/page")
    @PostMapping("/api/mini/depotDeviceWarn/processTo")
    public CommonResult<Object> processTo(@RequestBody @Valid DepotDeviceWarnProcessParam param) {
        deviceWarnService.processTo(param);
        return CommonResult.ok();
    }

    @Resource
    private DepotUserOnlineLogService userOnlineLogService;

    /**
     * 小程序获取人员签到
     *
     * @author xiang
     * @date 2023/09/19 10:12
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("小程序添加人员签到")
    @CommonLog("小程序添加人员签到")
    @SaCheckPermission("/biz/depotUserOnlineLog/page")
    @GetMapping("/api/mini/depotUserOnlineLog/page")
    public CommonResult<Page<DepotUserOnlineLog>> page(DepotUserOnlineLogPageParam param) {
        return CommonResult.data(userOnlineLogService.page(param));
    }

    /**
     * 小程序获取自己签到
     *
     * @author xiang
     * @date 2023/09/19 10:12
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("小程序获取自己签到")
    @CommonLog("小程序获取自己签到")
    @SaCheckPermission("/biz/depotUserOnlineLog/page")
    @GetMapping("/api/mini/depotUserOnlineLog/pageSelf")
    public CommonResult<Page<DepotUserOnlineLog>> pageSelf(DepotUserOnlineLogPageParam param) {
        param.setCreateUser(StpUtil.getLoginIdAsString());
        return CommonResult.data(userOnlineLogService.page(param));
    }

    /**
     * 小程序添加人员签到
     *
     * @author xiang
     * @date 2023/09/19 10:12
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("小程序添加人员签到")
    @CommonLog("小程序添加人员签到")
    @SaCheckPermission("/biz/depotUserOnlineLog/add")
    @PostMapping("/api/mini/depotUserOnlineLog/add")
    public CommonResult<Object> add(@RequestBody DepotUserOnlineLogAddParam param) {
        userOnlineLogService.add(param);
        return CommonResult.ok();
    }

    @Resource
    private DepotLoanGrantService depotLoanGrantService;

    /**
     * 获取入库放款单分页
     *
     * @author xiang
     * @date 2023/09/18 16:03
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("获取入库放款单分页")
    @SaCheckPermission("/biz/depotLoanGrant/page")
    @GetMapping("/api/mini/depotLoanGrant/page")
    public CommonResult<Page<DepotLoanGrant>> page(DepotLoanGrantPageParam depotLoanGrantPageParam) {
        return CommonResult.data(depotLoanGrantService.page(depotLoanGrantPageParam));
    }

    /**
     * 获取入库放款单详情
     *
     * @author xiang
     * @date 2023/09/18 16:03
     */
    @ApiOperationSupport(order = 5)
    @ApiOperation("获取入库放款单详情")
    @SaCheckPermission("/biz/depotLoanGrant/page")
    @GetMapping("/api/mini/depotLoanGrant/detail")
    public CommonResult<Object> detail(@Valid DepotLoanGrantIdParam depotLoanGrantIdParam) {
        return CommonResult.data(depotLoanGrantService.detail(depotLoanGrantIdParam));
    }

    @Resource
    private DepotRepayOrderService depotRepayOrderService;

    /**
     * 小程序获取出库还款分页
     *
     * @author xiang
     * @date 2023/09/18 16:45
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("小程序获取出库还款分页")
    @SaCheckPermission("/biz/depotRepayOrder/page")
    @GetMapping("/api/mini/depotRepayOrder/page")
    public CommonResult<Page<DepotRepayOrder>> page(DepotRepayOrderPageParam depotRepayOrderPageParam) {
        return CommonResult.data(depotRepayOrderService.page(depotRepayOrderPageParam));
    }

    /**
     * 小程序获取出库还款详情
     *
     * @author xiang
     * @date 2023/09/18 16:45
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("小程序获取出库还款详情")
    @SaCheckPermission("/biz/depotRepayOrder/page")
    @GetMapping("/api/mini/depotRepayOrder/detail")
    public CommonResult<Object> detail(@Valid DepotRepayOrderIdParam depotRepayOrderIdParam) {
        return CommonResult.data(depotRepayOrderService.detail(depotRepayOrderIdParam));
    }

    /**
     * 小程序出库还款二级确认审批
     *
     * @author xiang
     * @date 2023/09/18 16:45
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("小程序出库还款二级确认审批")
    @CommonLog("小程序出库还款二级确认审批")
    @SaCheckPermission("/biz/depotRepayOrder/bankOpApproval")
    @PostMapping("/api/mini/depotRepayOrder/bankOpApproval")
    public CommonResult<String> bankOpApproval(@RequestBody @Valid DepotRepayOrderApprovalParam param) {
        depotRepayOrderService.bankOpApproval(param);
        return CommonResult.ok();
    }

}
