zjh
2025-01-20 73a816fd2b1e29c25d615c85ce34b12b55c16ccf
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
package com.ltkj.hosp.mapper;
 
import java.util.Base64;
import java.util.List;
import java.util.Map;
 
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ltkj.hosp.domain.TjSampling;
import org.apache.ibatis.annotations.*;
 
/**
 * 体检采样管理Mapper接口
 *
 * @author ltkj_赵佳豪&李格
 * @date 2023-04-11
 */
@Mapper
public interface TjSamplingMapper extends BaseMapper<TjSampling> {
    /**
     * 查询体检采样管理
     *
     * @param id 体检采样管理主键
     * @return 体检采样管理
     */
    public TjSampling selectTjSamplingById(String id);
 
    /**
     * 查询体检采样管理列表
     *
     * @param tjSampling 体检采样管理
     * @return 体检采样管理集合
     */
    public List<TjSampling> selectTjSamplingList(TjSampling tjSampling);
 
    /**
     * 新增体检采样管理
     *
     * @param tjSampling 体检采样管理
     * @return 结果
     */
    public int insertTjSampling(TjSampling tjSampling);
 
    /**
     * 修改体检采样管理
     *
     * @param tjSampling 体检采样管理
     * @return 结果
     */
    public int updateTjSampling(TjSampling tjSampling);
 
    /**
     * 删除体检采样管理
     *
     * @param id 体检采样管理主键
     * @return 结果
     */
    public int deleteTjSamplingById(String id);
 
    /**
     * 批量删除体检采样管理
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteTjSamplingByIds(String[] ids);
 
 
    @Select({"<script>","SELECT GROUP_CONCAT(a.pro_id SEPARATOR ',')proId,GROUP_CONCAT(a.pro_name SEPARATOR ' + ') proName FROM tj_sampling a WHERE a.deleted=0 AND a.id " +
            "IN ","<foreach collection='ids' item='id' open='(' separator=',' close=')'>",
            "#{id}",
            "</foreach>",
            "</script>"})
    Map<String, Object> hebingCaiYangInFo(@Param("ids") List<String> ids);
 
 
    @Select({"<script>","SELECT COUNT(*) FROM(" +
            "SELECT GROUP_CONCAT(a.pro_id SEPARATOR ',')proId,GROUP_CONCAT(a.pro_name SEPARATOR ' + ') proName FROM tj_sampling a WHERE a.deleted=0 AND a.id " +
            "IN ","<foreach collection='ids' item='id' open='(' separator=',' close=')'>",
            "#{id}",
            "</foreach>", "GROUP BY a.specimen_type_code) aa" +
            "</script>"})
    int panduanshifoukeyihebing(@Param("ids") List<String> ids);
 
 
 
//    @Update({"<script>","UPDATE tj_sampling a SET a.parent_id=#{parentId} WHERE a.id " +
//            "IN ","<foreach collection='ids' item='id' open='(' separator=',' close=')'>",
//            "#{id}",
//            "</foreach>",
//            "</script>"})
    boolean updateHeBingXm(@Param("ids") List<String> ids,@Param("parentId")String parentId);
 
 
    @Select({"<script>","SELECT COUNT(*) FROM tj_sampling a " +
            "WHERE a.deleted=0 AND  a.is_merge=1 AND a.id IN ","<foreach collection='ids' item='id' open='(' separator=',' close=')'>",
            "#{id}",
            "</foreach>",
            "</script>"})
    int pdsfczhbxm(@Param("ids") List<String> ids);
 
    @Select({"<script>","SELECT * FROM tj_sampling a " +
            "WHERE a.deleted=0 AND a.is_merge=1 AND a.id IN ","<foreach collection='ids' item='id' open='(' separator=',' close=')'>",
            "#{id}",
            "</foreach>",
            "</script>"})
    TjSampling getTjSamplingByHb(@Param("ids") List<String> ids);
 
 
    @Select({"<script>","SELECT * FROM tj_sampling a " +
            "WHERE a.deleted=0 AND !ISNULL(a.parent_id) AND a.is_merge=0 AND a.id IN ","<foreach collection='ids' item='id' open='(' separator=',' close=')'>",
            "#{id}",
            "</foreach>",
            "</script>"})
    List<TjSampling> getTjSamplingListByHb(@Param("ids") List<String> ids);
 
 
    @Delete({"<script>","DELETE FROM tj_sampling  WHERE id " +
            "IN ","<foreach collection='ids' item='id' open='(' separator=',' close=')'>",
            "#{id}",
            "</foreach>",
            "</script>"})
    boolean deletedTjSamplingListByHb(@Param("ids") List<String> ids);
 
 
//    @Update({"<script>","UPDATE tj_sampling a SET a.parent_id=null WHERE a.id " +
//            "IN ","<foreach collection='ids' item='id' open='(' separator=',' close=')'>",
//            "#{id}",
//            "</foreach>",
//            "</script>"})
    boolean updateHeBingXms(@Param("ids") List<String> ids);
 
    @Delete("DELETE FROM tj_sampling WHERE tj_num = #{tjNum} AND cus_id = #{userId}")
    int deleteByTjNumAndCusId(@Param("tjNum") String tjNum,@Param("userId") Long userId);
 
    @Delete({
            "<script>",
            "DELETE FROM tj_sampling WHERE tj_num = #{tjNum} AND cus_id = #{userId} and jxbz in ",
            "<foreach collection='ids' item='id' open='(' separator=',' close=')'>",
            "#{id}",
            "</foreach>",
            "</script>"
    })
    int deleteByTjNumAndCusIdAndJxbz(@Param("tjNum") String tjNum,@Param("userId") Long userId,@Param("ids")List<String> ids);
 
 
    @Delete("DELETE FROM tj_sampling WHERE tj_num = #{tjNum} AND cus_id = #{userId} and jxbz = #{jxbz} ")
    int deleteByTjNumAndCusIdAndJxbzo(@Param("tjNum") String tjNum,@Param("userId") Long userId,@Param("jxbz")String jxbz);
 
 
    @Select({"<script>","SELECT\n" +
            "  IFNULL(GROUP_CONCAT( aa.pro_name SEPARATOR ' ; ' ),NULL)\n" +
            "FROM\n" +
            "  (\n" +
            "  SELECT\n" +
            "    a.jyxmdm,\n" +
            "    a.pro_name,\n" +
            "    b.jyxmmc,\n" +
            "    b.jybbdm,\n" +
            "    b.jyfldm \n" +
            "  FROM\n" +
            "    `tj_sampling` a\n" +
            "    LEFT JOIN ltkj_jyxmzd b ON a.jyxmdm = b.jyxmdm   WHERE a.id " +
            "IN ","<foreach collection='ids' item='id' open='(' separator=',' close=')'>",
            "#{id}",
            "</foreach>"
            +") aa " + "WHERE\n" + "  aa.jyfldm NOT IN ( SELECT c.flbm FROM lis_jyflhb c);",
            "</script>"})
    String getBuKeHebingProName(@Param("ids")List<String> ids);
 
    @Select("SELECT COUNT( 1 ) FROM(\n" +
            "\tSELECT\n" +
            "\t\ta.jyxmdm,\n" +
            "\t\tb.jyfldm \n" +
            "\tFROM\n" +
            "\t\t`tj_sampling` a\n" +
            "\t\tLEFT JOIN ltkj_jyxmzd b ON a.jyxmdm = b.jyxmdm \n" +
            "\tWHERE\n" +
            "\t\ta.id = #{id} \n" +
            "\t) aa WHERE aa.jyfldm NOT IN ( SELECT c.flbm FROM lis_jyflhb c )")
    int isMergeItem(@Param("id") String id);
 
 
    @Update("UPDATE tj_sampling a SET\n" +
            "a.update_time=SYSDATE(),\n" +
            "a.update_by= #{userName},\n" +
            "a.update_id= #{userId},\n" +
            "a.create_id = #{userId}\n"+
            "WHERE a.tj_num=#{tjNum}")
    boolean updateUserIdByTjNum(@Param("tjNum")String tjNum,@Param("userName")String userName,@Param("userId") String userId);
 
    @Update("UPDATE tj_sampling a SET\n" +
            "a.update_time=SYSDATE(),\n" +
            "a.update_by= #{userName},\n" +
            "a.update_id= #{userId},\n" +
            "a.create_id = #{userId}\n"+
            "WHERE a.tj_num=#{tjNum} AND a.jxbz = #{jxbz}")
    boolean updateUserIdByTjNumAndJxbz(@Param("tjNum")String tjNum,@Param("userName")String userName,@Param("userId") String userId,@Param("jxbz") String jxbz);
}