Commit 224e9043060d9831cd08445ea8d91411e959ac34

Authored by panlinlin
1 parent d3578a95

修复更新设备和通道信息时检测字段是否存在

src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
... ... @@ -19,13 +19,42 @@ public interface DeviceChannelMapper {
19 19 "'${ipAddress}', ${port}, '${password}', ${PTZType}, ${status})")
20 20 int add(DeviceChannel channel);
21 21  
22   - @Update("UPDATE device_channel " +
23   - "SET name=#{name}, manufacture=#{manufacture}, model=#{model}, owner=#{owner}, civilCode=#{civilCode}, " +
24   - "block=#{block}, address=#{address}, parental=#{parental}, parentId=#{parentId}, safetyWay=#{safetyWay}, " +
25   - "registerWay=#{registerWay}, certNum=#{certNum}, certifiable=#{certifiable}, errCode=#{errCode}, secrecy=#{secrecy}, " +
26   - "ipAddress=#{ipAddress}, port=#{port}, password=#{password}, PTZType=#{PTZType}, status=#{status}, streamId=#{streamId}, " +
27   - "hasAudio=#{hasAudio}" +
28   - "WHERE deviceId=#{deviceId} AND channelId=#{channelId}")
  22 +// @Update("UPDATE device_channel " +
  23 +// "SET name=#{name}, manufacture=#{manufacture}, model=#{model}, owner=#{owner}, civilCode=#{civilCode}, " +
  24 +// "block=#{block}, address=#{address}, parental=#{parental}, parentId=#{parentId}, safetyWay=#{safetyWay}, " +
  25 +// "registerWay=#{registerWay}, certNum=#{certNum}, certifiable=#{certifiable}, errCode=#{errCode}, secrecy=#{secrecy}, " +
  26 +// "ipAddress=#{ipAddress}, port=#{port}, password=#{password}, PTZType=#{PTZType}, status=#{status}, streamId=#{streamId}, " +
  27 +// "hasAudio=#{hasAudio}" +
  28 +// "WHERE deviceId=#{deviceId} AND channelId=#{channelId}")
  29 +
  30 +
  31 + @Update(value = {" <script>" +
  32 + "UPDATE device_channel " +
  33 + "SET deviceId='${deviceId}'" +
  34 + "<if test=\"name != null\">, name='${name}'</if>" +
  35 + "<if test=\"manufacture != null\">, manufacture='${manufacture}'</if>" +
  36 + "<if test=\"model != null\">, model='${model}'</if>" +
  37 + "<if test=\"owner != null\">, owner='${owner}'</if>" +
  38 + "<if test=\"civilCode != null\">, civilCode='${civilCode}'</if>" +
  39 + "<if test=\"block != null\">, block='${block}'</if>" +
  40 + "<if test=\"address != null\">, address='${address}'</if>" +
  41 + "<if test=\"parental != null\">, parental=${parental}</if>" +
  42 + "<if test=\"parentId != null\">, parentId='${parentId}'</if>" +
  43 + "<if test=\"safetyWay != null\">, safetyWay=${safetyWay}</if>" +
  44 + "<if test=\"registerWay != null\">, registerWay=${registerWay}</if>" +
  45 + "<if test=\"certNum != null\">, certNum='${certNum}'</if>" +
  46 + "<if test=\"certifiable != null\">, certifiable=${certifiable}</if>" +
  47 + "<if test=\"errCode != null\">, errCode=${errCode}</if>" +
  48 + "<if test=\"secrecy != null\">, secrecy='${secrecy}'</if>" +
  49 + "<if test=\"ipAddress != null\">, ipAddress='${ipAddress}'</if>" +
  50 + "<if test=\"port != null\">, port=${port}</if>" +
  51 + "<if test=\"password != null\">, password='${password}'</if>" +
  52 + "<if test=\"PTZType != null\">, PTZType=${PTZType}</if>" +
  53 + "<if test=\"status != null\">, status='${status}'</if>" +
  54 + "<if test=\"streamId != null\">, streamId='${streamId}'</if>" +
  55 + "<if test=\"hasAudio != null\">, hasAudio='${hasAudio}'</if>" +
  56 + "WHERE deviceId='${deviceId}' AND channelId='${channelId}'"+
  57 + " </script>"})
29 58 int update(DeviceChannel channel);
30 59  
31 60 @Select(value = {" <script>" +
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java
... ... @@ -44,18 +44,21 @@ public interface DeviceMapper {
44 44 int add(Device device);
45 45  
46 46  
47   - @Update("UPDATE device " +
48   - "SET name=#{name}, " +
49   - "manufacturer=#{manufacturer}," +
50   - "model=#{model}," +
51   - "firmware=#{firmware}, " +
52   - "transport=#{transport}," +
53   - "streamMode=#{streamMode}, " +
54   - "ip=#{ip}, " +
55   - "port=#{port}, " +
56   - "hostAddress=#{hostAddress}, " +
57   - "online=#{online} " +
58   - "WHERE deviceId=#{deviceId}")
  47 + @Update(value = {" <script>" +
  48 + "UPDATE device " +
  49 + "SET deviceId='${deviceId}'" +
  50 + "<if test=\"name != null\">, name='${name}'</if>" +
  51 + "<if test=\"manufacturer != null\">, manufacturer='${manufacturer}'</if>" +
  52 + "<if test=\"model != null\">, model='${model}'</if>" +
  53 + "<if test=\"firmware != null\">, firmware='${firmware}'</if>" +
  54 + "<if test=\"transport != null\">, transport='${transport}'</if>" +
  55 + "<if test=\"streamMode != null\">, streamMode='${streamMode}'</if>" +
  56 + "<if test=\"ip != null\">, ip='${ip}'</if>" +
  57 + "<if test=\"port != null\">, port=${port}</if>" +
  58 + "<if test=\"hostAddress != null\">, hostAddress='${hostAddress}'</if>" +
  59 + "<if test=\"online != null\">, online=${online}</if>" +
  60 + "WHERE deviceId='${deviceId}'"+
  61 + " </script>"})
59 62 int update(Device device);
60 63  
61 64 @Select("SELECT *, (SELECT count(0) FROM device_channel WHERE deviceId=de.deviceId) as channelCount FROM device de")
... ...