package com.slcf.dao; import java.util.List; import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; import org.springframework.stereotype.Repository; import com.slcf.bean.LocationCondition; import com.slcf.pojo.LocationBean; @Repository public interface LocationDao { /** * 添加 * @param location * @return */ @Insert("insert into asr_loc_mast(loc_no,loc_sts,crn_no,row1,bay1,lev1,loc_type,modi_user,modi_time) " + " values(#{loc_no},#{loc_sts},#{crn_no},#{row1},#{bay1},#{lev1},#{loc_type},#{modi_user},getdate())") public int insertLocation(LocationBean location); //分页查询所有信息 // @Select("select top (#{epage}) * from asr_loc_mast where loc_no not in " // @Select("select top (#{epage}) a.*,b.loc_desc loc_sts_name from asr_loc_mast a,asr_bas_loc_type b where a.loc_sts=b.loc_sts and loc_no not in " // + " (select top (#{spage}) loc_no from asr_loc_mast order by loc_no asc) order by loc_no asc") // public List queryLocationList(@Param("spage")int spage,@Param("epage")int epage); public List queryLocationList(LocationCondition locationCon); // //统计所有数据总数量 // @Select("select count(*) from asr_loc_mast") // public int getLocationCount(); //根据过滤条件统计总数量 public int getLocationCount(LocationCondition locationCon); /** * 查询所有 * @return */ @Select("select * from asr_loc_mast order by loc_no asc") public List getLocationList(); /** * 根据id查询信息 * @param id * @return */ @Select("select *,loc_desc loc_sts_name from asr_loc_mast a,asr_bas_loc_type b where a.loc_sts=b.loc_sts and loc_no=#{id}") public LocationBean getLocationById(String id); //更新 // @Update("update asr_loc_mast set loc_sts=#{loc_sts},crn_no=#{crn_no},row1=#{row1},bay1=#{bay1}," // + " lev1=#{lev1},loc_type=#{loc_type},modi_user=#{modi_user},modi_time=getdate() " // + " where loc_no=#{loc_no}") //更新 @Update("update asr_loc_mast set loc_sts=#{loc_sts},modi_user=#{modi_user},modi_time=getdate() " + " where loc_no=#{loc_no}") public int upLocation(LocationBean location); //根据id删除工作信息 @Delete("delete from asr_loc_mast where loc_no=#{id}") public int delLocationById(String id); //根据id删除工作信息 @Delete("delete from asr_loc_mast") public int resetLocation(); /** * 查询钢架号 * @return */ @Select("select row1,convert(varchar,row1)+'排' as rowName from asr_loc_mast group by row1 order by row1 asc") public List getRowList(); //查询入库可用库位 @Select("select top 1 * from asr_loc_mast where row1=#{row1} and loc_sts='O' and loc_type=#{loc_type} order by loc_type desc ,lev1 asc,bay1 asc") public LocationBean getLocNo(@Param("row1")int row1, @Param("loc_type")int loc_type); /** * 库位号拼成字符串返回 * @return */ // @Select("select * from asr_loc_mast where loc_sts=#{loc_sts} order by loc_no asc") @Select("select distinct stuff((select ',' + loc_no from asr_loc_mast where loc_sts=#{loc_sts} for xml path('')),1,1,'') locs " + "from asr_loc_mast a where loc_sts=#{loc_sts}") public String getLocationListBySts(@Param("loc_sts")String loc_sts); /** * 根据id查询信息 * @param id * @return */ @Select("select top 1 loc_no from asr_loc_mast where loc_sts=#{loc_sts} order by row1,bay1,lev1") public String getLocationBySts(String loc_sts); /** * 根据barcode查找库位号 * @param loc_sts * @return */ @Select("select top 1 loc_no from asr_loc_mast where barcode=#{barcode} order by row1,bay1,lev1") public String getLocationByBarcode(String barcode); }