package com.JN.demo.zmquotation.mapper;

import com.JN.demo.zmquotation.dto.MaterialDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @ClassName MaterialMapper
 * @Description TODO
 * @Author JIAL
 * @Date 2024/2/21 8:16
 * @Version 1.0
 */
@Mapper
public interface MaterialMapper {
    @Select("  SELECT [cb_name] as material_name\n" +
            "        ,[cb_cj] as factory_price\n" +
            "        ,[cb_cbj] as cost_price\n" +
            "        ,[cb_zl] as net_volume\n" +
            "        ,[cb_gspj] as inventory\n" +
            "        ,[cbpj_zl] as weigh_inv\n" +
            "        ,[CB_bz] as standard\n" +
            "        ,[cb_xx] as model\n" +
            "        ,[cb_gg] as specification\n" +
            "        ,[cb_dy] as voltage\n" +
            "        ,[cb_cljg] as mat_price\n" +
            "        ,[tdtjg] as total_copper_consume\n" +
            "        ,[ldtjg] as total_aluminum_consume\n" +
            "        ,[rgsdf] as total_l_h_cost\n" +
            "        ,[cb_zqf]as steam_fee\n" +
            "        ,ROW_NUMBER() OVER(Order by [cb_name]) AS RowId\n" +
            "    FROM [zm_erp2].[dbo].[view_cb_material]\n" +
            "    WHERE [cb_name] like '${precMaterialName}%' and [cb_name] like '%${vagueMaterialName}%' and [cb_gg] like '%${vagueModel}%'")
    List<MaterialDto> queryMaterialListByParam(String precMaterialName, String vagueMaterialName, String vagueModel);


    @Select(" SELECT \n" +
            "\tCOUNT(*) AS total\n" +
            "  FROM [zm_erp2].[dbo].[view_cb_material]\n" +
            "  WHERE [cb_name] like '${precMaterialName}%' and [cb_name] like '%${vagueMaterialName}%' and [cb_gg] like '%${vagueModel}%'")
    Integer queryMaterialListCount(String precMaterialName, String vagueMaterialName, String vagueModel);
}
