王佳豪
2021-06-26 718f604deb342b0bee6c588bb44e22ced3371fb8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
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<LocationBean> queryLocationList(@Param("spage")int spage,@Param("epage")int epage);
    public List<LocationBean> 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<LocationBean> 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<LocationBean> 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);
}