Exemplo n.º 1
0
 public void saveBindDevList(String roomid, String[] binddeviceArr) throws Exception {
   // TODO Auto-generated method stub
   if (!"".equals(roomid)) {
     TRoomdevice roomdevice = new TRoomdevice();
     TRoomdeviceId id = new TRoomdeviceId();
     id.setRoomId(roomid);
     roomdevice.setId(id);
     List roomdeviceList = findRoomDevice(roomdevice);
     for (int i = 0; i < roomdeviceList.size(); i++) {
       TRoomdevice rd = (TRoomdevice) roomdeviceList.get(i);
       deleteRoomDevice(rd);
     }
     for (int j = 0; j < binddeviceArr.length; j++) {
       String binddevice = binddeviceArr[j];
       if (!"".equals(binddevice)) {
         TRoomdevice tmprd = new TRoomdevice();
         TRoomdeviceId rdid = new TRoomdeviceId();
         rdid.setRoomId(roomid);
         rdid.setDeviceId(Integer.valueOf(binddevice));
         tmprd.setId(rdid);
         saveRoomDevice(tmprd);
       }
     }
   }
 }
Exemplo n.º 2
0
  public List findRoomDevice(TRoomdevice roomdevice) throws Exception {

    StringBuffer query = new StringBuffer(" from TRoomdevice rd where 1=1 ");
    if (StringUtils.isNotEmpty(roomdevice.getId().getRoomId())) {
      query.append(" and  rd.id.roomId ='").append(roomdevice.getId().getRoomId()).append("'");
    }
    if (roomdevice.getId().getDeviceId() != null
        && !"".equals(roomdevice.getId().getDeviceId().toString())) {
      query.append(" and rd.id.deviceId =").append(roomdevice.getId().getDeviceId());
    }
    List result = roomDAO.find(query.toString());

    return result;
  }