赵文轩
2024-06-13 e9faaf0c4667ba54477c7365ac9f3e7cefebbdae
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
package com.ltkj.hosp.mapper;
 
import java.util.Date;
import java.util.List;
import java.util.Map;
 
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ltkj.hosp.domain.TjCustomer;
import com.ltkj.hosp.domain.TjOrder;
import com.ltkj.hosp.vodomain.LineChartsVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
 
/**
 * 体检记录Mapper接口
 *
 * @author ltkj
 * @date 2022-11-21
 */
@Mapper
public interface TjOrderMapper extends BaseMapper<TjOrder> {
    /**
     * 查询体检记录
     *
     * @param orderId 体检记录主键
     * @return 体检记录
     */
    public TjOrder selectTjOrderByOrderId(Long orderId);
 
    /**
     * 查询体检记录列表
     *
     * @param tjOrder 体检记录
     * @return 体检记录集合
     */
    public List<TjOrder> selectTjOrderList(TjOrder tjOrder);
 
 
    public List<TjOrder> selectExportOrderList(TjOrder tjOrder);
 
//    /*
//    * 根据tjNumber查询体检记录
//    * */
//    public List<TjOrder> selectTjOrderListByTjNumber(Long tjNumber);
 
    /**
     * 新增体检记录
     *
     * @param tjOrder 体检记录
     * @return 结果
     */
    public int insertTjOrder(TjOrder tjOrder);
 
    /**
     * 修改体检记录
     *
     * @param tjOrder 体检记录
     * @return 结果
     */
    public int updateTjOrder(TjOrder tjOrder);
 
    /**
     * 删除体检记录
     *
     * @param orderId 体检记录主键
     * @return 结果
     */
    public int deleteTjOrderByOrderId(Long orderId);
 
    /**
     * 批量删除体检记录
     *
     * @param orderIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteTjOrderByOrderIds(Long[] orderIds);
 
 
    @Select(" select * from tj_order where 1 = 1 and deleted=0  and user_id = #{cusId}")
    List<TjOrder> getOrderList(Long cusId);
 
 
    List<TjOrder> getOrderList1();
 
//    @Select("select aa.date,\n" +
//            "      sum(if(c.tj_type='团队', ifnull(c.coun,0),0)) as tdcoun,\n" +
//            "      sum(if(c.tj_type='个人', ifnull(c.coun,0),0)) as grcoun,\n" +
//            "      sum(if(c.tj_type='报告', ifnull(c.coun,0),0)) as bgcoun \n" +
//            "  from (\n" +
//            "      SELECT date_sub(CURDATE(),interval @i:=@i+1 day) as date\n" +
//            "      from (select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all \n" +
//            "            select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all   \n" +
//            "            select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all  \n" +
//            "            select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all  \n" +
//            "            select 1 union all select 1) as a,\n" +
//            "            (select @i:= -1) b) aa \n" +
//            "  left join (\n" +
//            "      select date_format(create_time, '%Y-%m-%d') dat, tj_type, count(*) coun\n" +
//            "      from tj_order where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(create_time)\n" +
//            "      group by date_format(create_time, '%Y-%m-%d'),tj_type\n" +
//            "      union\n" +
//            "      select date_format(report_time, '%Y-%m-%d') dat, '报告' tj_type, count(*) coun\n" +
//            "      from tj_order where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(create_time)\n" +
//            "      group by date_format(report_time, '%Y-%m-%d')\n" +
//            "      ) c on c.dat =aa.date\n" +
//            "group by aa.date")
//    List<Map<Object, Object>> getLine();
 
    @Select("select aa.date,\n" +
            "      sum(if(c.tj_type='团队', ifnull(c.coun,0),0)) as tdcoun,\n" +
            "      sum(if(c.tj_type='个人', ifnull(c.coun,0),0)) as grcoun,\n" +
            "      sum(if(c.tj_type='报告', ifnull(c.coun,0),0)) as bgcoun \n" +
            "  from (\n" +
            "      SELECT date_sub(CURDATE(),interval @i:=@i+1 day) as date\n" +
            "      from (select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all \n" +
            "            select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all   \n" +
            "            select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all  \n" +
            "            select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all  \n" +
            "            select 1 union all select 1) as a,\n" +
            "            (select @i:= -1) b) aa \n" +
            "  left join (\n" +
            "      select date_format(create_time, '%Y-%m-%d') dat, tj_type, count(*) coun\n" +
            "      from tj_order where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(create_time)\n" +
            "      group by date_format(create_time, '%Y-%m-%d'),tj_type\n" +
            "      union\n" +
            "      select date_format(report_time, '%Y-%m-%d') dat, '报告' tj_type, count(*) coun\n" +
            "      from tj_order where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(create_time)\n" +
            "      group by date_format(report_time, '%Y-%m-%d')\n" +
            "      ) c on c.dat =aa.date\n" +
            "group by aa.date")
    List<LineChartsVo> getLine();
 
 
    @Select("SELECT * FROM tj_order WHERE tj_number RLIKE #{tjNum} AND deleted='0' ORDER BY create_time DESC")
    public List<TjOrder> getOrderListByLikeTjNum(@Param("tjNum") String tjNum);
 
 
    @Select("SELECT * FROM tj_order WHERE user_id = #{cusId} AND deleted='0' ORDER BY create_time DESC")
    public List<TjOrder> getOrderListByCusId(@Param("cusId") String cusId);
 
    @Select("SELECT * FROM tj_order WHERE tj_number = #{tjNum} AND deleted='0' ")
    public TjOrder getOrderByTjNum(String tjNum);
 
    List<TjOrder> getTjOrderList(@Param("tjNum")String tjNum,
                                 @Param("checkStatus")Integer checkStatus,
                                 @Param("compId")Long compId,
                                 @Param("beginTime") Date beginTime,
                                 @Param("endTime") Date endTime);
 
 
    List<TjOrder> getWCsTjOrderList(@Param("tjNum")String tjNum,
                                 @Param("compId")Long compId,
                                 @Param("beginTime") Date beginTime,
                                 @Param("endTime") Date endTime);
 
    List<TjOrder> getYCsTjOrderList(@Param("tjNum")String tjNum,
                                    @Param("compId")Long compId,
                                    @Param("beginTime") Date beginTime,
                                    @Param("endTime") Date endTime);
 
 
    List<TjOrder> getCsTjOrderList1(@Param("tjNum")String tjNum,
                                   @Param("checkStatus")Integer checkStatus,
                                   @Param("compId")Long compId,
                                   @Param("beginTime") Date beginTime,
                                   @Param("endTime") Date endTime);
 
    @Select("SELECT * FROM tj_order WHERE  deleted='0' and user_id = #{userId}  AND !ISNULL(finish_time)")
    List<TjOrder> getTjOrderListByCusId(Long userId);
 
    @Select("SELECT * FROM tj_order WHERE  deleted='0' and user_id = #{userId}  AND !ISNULL(finish_time)")
    List<TjOrder> getCsTjOrderListByCusId(Long userId);
 
 
    @Select("SELECT * FROM tj_order WHERE  deleted='0' and  user_id = #{userId}  AND !ISNULL(finish_time) " +
            "and !ISNULL(confirm_time) ")
    List<TjOrder> getCsTjOrderListByCusId1(Long userId);
 
 
    @Select("SELECT GROUP_CONCAT( DISTINCT b.pro_name  SEPARATOR ';' ) aa FROM tj_order_remark a" +
            " LEFT JOIN tj_project b ON a.pro_id=b.pro_id WHERE a.deleted=0 AND a.tj_number= #{tjNum} AND a.type !=2")
    String getHistoryTjOrderProByTjNum(String tjNum);
 
 
    @Select("SELECT * FROM tj_order WHERE  deleted='0' and user_id =#{userId}" +
            "  AND !ISNULL(finish_time) ORDER BY create_time DESC LIMIT 1")
    TjOrder getLastTjOrderListByCusId(Long userId);
 
 
    //存储过程专用接口(总检)
    List<List<?>> getCunChuGuoChengCustomerList(Map<String,Object> map);
 
 
    //存储过程专用接口(初审)
    List<List<?>> getCsCunChuGuoChengCustomerList(Map<String,Object> map);
 
 
    @Select("SELECT count(*) FROM tj_order a WHERE  a.deleted=0 and  a.card_id=#{cardId}")
    int selectTjOrderByCardId(String cardId);
 
 
    @Select("SELECT a.card_id FROM tj_order a WHERE a.deleted=0")
    List<String> selectTjOrderByCardId1();
 
 
    @Select("SELECT a.order_id FROM tj_order_detail a WHERE a.order_id=#{orderId} AND !ISNULL(a.flowing_water_id) GROUP BY a.order_id ")
    String  isPayByTjNum(String orderId);
 
    /**
     * 查询导检单详情
     * @param tjNumber 体检单号
     * @return
     */
    @Select("SELECT  @num :=  @num + 1 AS xh, d.dept_name ksmc, d.official_web ksdz, e.tjxm FROM sys_dept d JOIN ( select aa.ksmc,GROUP_CONCAT( DISTINCT aa.pro_name ORDER BY aa.pro_name DESC SEPARATOR ';' ) tjxm  from ( SELECT (case when f.ksmc in ('临检室','化验室','','') or c.pro_name like '%测定%' then '检验科'      when c.pro_name like '%心电图%' then '心电图室'  when f.ksmc='x光室' or c.pro_name like '%X线摄影%'  then '放射科'  when c.pro_name like '%色觉%' then '眼科' \t\t\t\twhen c.pro_name like '%超%' or c.pro_name like '%多普勒%' then 'B超室'  when (replace(f.ksmc,' ','')='' or f.ksmc is null) and c.dept_id<>'100' then  d.dept_name when c.pro_name like '%CT%' then 'CT室'  else '体检中心' end ) ksmc, c.pro_name FROM tj_order a JOIN tj_order_detail b ON b.order_id = a.order_id JOIN tj_project c ON c.pro_id = b.pro_id  left join his_mxfyxm e on e.mxfyxmbm=c.his_xmbm left join ltkj_his_dept f on f.ksbm = CONCAT('00',(case when e.hsks is null then '' else e.hsks end)) join sys_dept d on d.dept_id=c.dept_id WHERE a.tj_number =  #{tjNumber} ) aa  GROUP BY ksmc ) e ON e.ksmc = d.dept_name , (SELECT @num := 0) a WHERE d.parent_id = '100' ORDER BY xh")
    List<Map<String ,String >> selectDjdInfo(@Param("tjNumber")String tjNumber);
 
    /**
     * 查询导检单用户信息
     * @param tjNumber
     * @return
     */
    @Select("select c.tj_number tjh,a.cus_name tjname, b.dict_label sex,a.create_time tjsj,ifnull(d.cn_name,'') dwmc,a.cus_phone lxdh\n" +
            "from tj_order c \n" +
            " join tj_customer a on  a.cus_id= c.user_id \n" +
            " join (select dict_value,dict_label from  sys_dict_data where dict_type='sys_user_sex') b on b.dict_value = a.cus_sex\n" +
            " left join dict_comp d on d.drug_manufacturer_id = c.firm_id\n" +
            "where c.tj_number=#{tjNumber}")
    Map<String ,Object > selectDjdUserInfo(@Param("tjNumber")String tjNumber);
 
 
    @Select("SELECT a.jcsqdh FROM ltkj_outpinexamapply a WHERE a.cardId=#{cardId}")
    String getHuoQuJcsqdh(String cardId);
    @Delete("DELETE FROM ltkj_outpinexamapply WHERE cardId=#{cardId}")
    Boolean delHuoQuJcsqdh(String cardId);
 
 
 
    @Select("SELECT a.jysqdh FROM ltkj_outpintestapply a WHERE a.cardId=#{cardId} ")
    String getHuoQuJysqdh(String cardId);
    @Delete("DELETE FROM ltkj_outpintestapply WHERE cardId=#{cardId}")
    Boolean delHuoQuJysqdh(String cardId);
 
    @Select("SELECT a.zlczh FROM ltkj_outpintreatapply a WHERE a.cardid=#{cardId}")
    String getHuoQuZlsqdh(String cardId);
 
    @Delete("DELETE FROM ltkj_outpintreatapply WHERE cardid=#{cardId}")
    Boolean delHuoQuZlsqdh(String cardId);
}