eight
2024-12-18 289ecba11e7ebbb9a3d7aa884481978f760a97a4
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
package cn.lihu.jh.module.ecg.dal.mysql.devmanage;
 
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
 
import cn.lihu.jh.framework.common.pojo.PageResult;
import cn.lihu.jh.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.lihu.jh.framework.mybatis.core.mapper.BaseMapperX;
import cn.lihu.jh.module.ecg.dal.dataobject.devmanage.DeviceDO;
import cn.lihu.jh.module.ecg.dal.dataobject.devmanage.DeviceStatisticDO;
import cn.lihu.jh.module.ecg.dal.dataobject.jobrecord.JobRecordStatisticDO;
import org.apache.ibatis.annotations.*;
import cn.lihu.jh.module.ecg.controller.admin.devmanage.vo.*;
 
/**
 * 设备 Mapper
 *
 * @author majianbo
 */
@Mapper
public interface DeviceMapper extends BaseMapperX<DeviceDO> {
 
    default PageResult<DeviceDO> selectPage(DevicePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DeviceDO>()
                .eqIfPresent(DeviceDO::getDevId, reqVO.getDevId())
                .eqIfPresent(DeviceDO::getDevCodeIntrinsic, reqVO.getDevCodeIntrinsic())
                .eqIfPresent(DeviceDO::getDevCodeHosp, reqVO.getDevCodeHosp())
                .eqIfPresent(DeviceDO::getDevCodeDept, reqVO.getDevCodeDept())
                .inIfPresent(DeviceDO::getState, reqVO.getState())
                .eqIfPresent(DeviceDO::getCategory, reqVO.getCategory())
                .eqIfPresent(DeviceDO::getBrand, reqVO.getBrand())
                .eqIfPresent(DeviceDO::getModel, reqVO.getModel())
                .betweenIfPresent(DeviceDO::getPurchaseDate, reqVO.getPurchaseDate())
                .betweenIfPresent(DeviceDO::getCreateTime, reqVO.getCreateTime())
                .orderByAsc(DeviceDO::getStateDate));
    }
 
    @Select("select * from lihu.device where dev_id=#{devId}")
    @Results({
            @Result(property = "patDetails", column = "pat_details", typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler.class)
    })
    DeviceDO getDeviceByDevId(@Param("devId") String devId);
 
    @Update("update lihu.device set state=#{state}, state_date=#{stateDate} where dev_id=#{devId}")
    Integer updateDevState(@Param("devId") String devId, @Param("state") Integer state, @Param("stateDate") LocalDate stateDate);
 
    @Select("<script>" +
            "select category, state, count(1) as dev_count from lihu.device " +
            " <where> deleted = 0 " +
            "   <if test=\"category != null and category != ''\"> " +
            "     and category = #{category} " +
            "   </if> " +
            "   <if test=\"brand != null and brand != ''\"> " +
            "     and brand = #{brand} " +
            "   </if> " +
            "   <if test=\"model != null and model != ''\"> " +
            "     and model = #{model} " +
            "   </if> " +
            " </where> " +
            " group by category, state " +
            " order by category " +
            "</script>")
    List<DeviceStatisticDO> getDevStatistic(DevicePageReqVO pageReqVO);
 
}