package com.junmp.jyzb.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.junmp.jyzb.api.bean.dto.*;
import com.junmp.jyzb.api.bean.dto.tjDto.*;
import com.junmp.jyzb.api.bean.query.InventoryReq;
import com.junmp.jyzb.api.bean.query.InventorySumReq;
import com.junmp.jyzb.api.bean.query.tjReq.TjEqsSumReq;
import com.junmp.jyzb.entity.InventorySummary;
import com.junmp.jyzb.entity.VieWarrantyGroup;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface InventorySummaryMapper  extends BaseMapper<InventorySummary> {

    //用于出库单中的装备选择
    List<InventorySumDto> GetInventorySumInfo(@Param("req") InventorySumReq req);

    //根据仓库id删除装备汇总信息
    boolean deleteByWarehouse(@Param("list") List<WarehouseDto> allWarehouse);

    boolean getSumByWarehouse(@Param("list") List<WarehouseDto> allWarehouse,@Param("brokenNumberDays")Integer brokenNumberDays);

    //根据单警柜删除装备汇总信息
    boolean deleteByCabinet(@Param("cabinetId") String cabinetId);

    boolean getSumByCabinet(@Param("cabinetId") String cabinetId,@Param("brokenNumberDays")Integer brokenNumberDays);

    InventorySummary getTotalNumberAndPrice(@Param("req") InventorySumReq req);

    InventorySummary EquipmentStatistics(@Param("req") InventorySumReq req);

    List<InventorySummary> selectByEqs(@Param("orgId") Long orgId);


    //根据组织机构,仓库,type,size,unitprice查询库存汇总信息
    List<InventorySummary> selectSumByItems(@Param("list") List<Object[]> searchCriteria);
    List<InventorySummary> selectSum(@Param("list") List<Object[]> searchCriteria);

    //根据组织机构查询报表中的本级及下一级信息
    List<TjOrgEqsDto> getByOrgId(@Param("orgId") Long orgId);

    List<EqsSumDto> getEqsByOrgId(@Param("list") List<Long> collect1,@Param("sizeId") String sizeId,@Param("typeId") String typeId);

    List<TjOrgEqsDto> test(@Param("req") InventoryReq req);

    TjOrgEqsDto GetInvSelfSum(@Param("orgId") String orgId,@Param("typeId") String typeId,@Param("sizeName") String sizeName,@Param("typeName") String typeName);
    TjOrgEqsDto GetInvSum(@Param("orgId") String orgId,@Param("typeId") String typeId,@Param("sizeName") String sizeName,@Param("typeName") String typeName);
    TjOrgEqsDto GetSumLeve4(@Param("orgId") String orgId,@Param("typeId") String typeId,@Param("sizeName") String sizeName,@Param("sql") Integer sql,@Param("typeName") String typeName);

    List<TjOrgEqsSizeDto> GetInvSumBySize(@Param("orgId") String orgId, @Param("typeId") String typeId, @Param("sizeName") String sizeName, @Param("typeName") String typeName);


    List<TjOrgEqsDto> selectDynamicView();

    void insertToSummary(@Param("summaryTableName") String summaryTableName,
                         @Param("sourceTableName") String sourceTableName,
                         @Param("warrantyThreshold") Integer warrantyThreshold);

    List<TjOrgEqsDto> selectViewOrgeqsSum();
//    List<TjOrgEqsDto> getTotalDataDetail(@Param("orgId") String orgId, @Param("typeIdsList") List<String> typeIdsList,
//                                         @Param("sizeNameList") List<String> sizeNameList, @Param("levelNum") Integer levelNum);
    List<TjOrgEqsDto> getTotalDataDetail(@Param("orgId") String orgId, @Param("typeIdsList") List<String> typeIdsList,
                                         @Param("sizeNameList") List<String> sizeNameList, @Param("levelNum") Integer levelNum,
                                         @Param("level")Integer level,@Param("column")String column,
                                         @Param("order")String order,@Param("levelFlag")Integer levelFlag,
                                         @Param("typeName")String typeName);

    void useViewOrgeqs(@Param("sql") String sql,@Param("orgId") Long orgId,@Param("sql1") String sql1);

    List<String>  getTotalData(@Param("orgId") String orgId);
    //获取合计
    FinalTjOrgEqsDto getSumByViewOrgeqsSum();

    List<InventorySumDto> TjOrgEqsDetail(@Param("orgId") Long orgId, @Param("typeIdsList") List<String> typeIdsList,
                                         @Param("sizeNameList") List<String> sizeNameList,
                                         @Param("column")String column, @Param("order") String order,
                                         @Param("typeName") String typeName);


    List<InventorySumDto> selectTotalNum(@Param("orgId") Long orgId,@Param("list") List<Object[]> searchCriteria );

    int GetEquipmentSummarySum(@Param("req") InventorySumReq req);

    List<InventorySummary> GetEquipmentSummary(@Param("req") InventorySumReq req,
                                               @Param("pageNo") Long pageNo,
                                               @Param("pageSize") Long pageSize);

    InventorySummary GetEquipmentSummaryTotalCount(@Param("req") InventorySumReq req,
                                                   @Param("pageNo") Long pageNo,
                                                   @Param("pageSize") Long pageSize);

    List<InventorySummary> GetEquipmentSummaryDetail(@Param("req") InventorySumReq req);

    int selectSumByItemsCount(@Param("req") InventoryReq req);

    List<InventoryDto> GetDetailByTerms(@Param("req") InventoryReq req);

    void useViewOrgIdInSubordinate(@Param("sql") String sql);

    void useViewOrgIdInLevel(@Param("sql") String sql,@Param("orgId") Long orgId);

    List<Long> selectOrgIds(@Param("orgId") Long orgId);

    void setWarrantyInventoryAction(@Param("orgId") Long orgId);

    void setDestoryGroupAction();

    void setWarrantyGroupAction(@Param("orgId") Long orgId);

    void deleteByOrgId(@Param("orgId") Long orgId,@Param("locationId") String locationId);

    void UpdateSummaryDestoryNumber();

    void UpdateSummaryBrokenNumber();
    void updateWarrantyToBroken();

    void UpdateSummaryExpireNumber();

    void clearMysql();

    List<TypeSizeDto> showInvsSummaryTypeList(@Param("req") InventorySummary req);


    List<InventorySummary> getEquipmentInfo(@Param("req") InventorySumReq req,@Param("pageNo") Long pageNo, @Param("pageSize") Long pageSize);

    int getEquipmentInfoSum(@Param("req") InventorySumReq req);

    List<VieWarrantyGroup> getWarrantyGroup();

//    List<String> getWarrantyInventory();

    int getEqsSumByOrgSum(@Param("req") TjEqsSumReq req);

    List<TjEqsSumDto> getEqsSumByOrg(@Param("req")TjEqsSumReq req,@Param("pageNo") Long pageNo, @Param("pageSize") Long pageSize);

    List<TjEqsSumDto> TJEqsSumByOrgDetail(@Param("req") TjEqsSumReq req);

    FinalTjRqsSumDto TjEqsSumByOrgSum(@Param("req") TjEqsSumReq req);

    List<InventorySummary> getSummary(@Param("req") InventorySumReq req);
}