fengxiang
2018-02-05 f1e25082a58c8cb57dd45d226d3a94f4af4a0677
src/main/java/com/moral/service/impl/DeviceServiceImpl.java
@@ -4,8 +4,10 @@
import javax.annotation.Resource;
import com.github.pagehelper.Page;
import com.moral.common.bean.Constants;
import com.moral.common.bean.PageBean;
import com.moral.common.bean.PageResult;
import com.moral.common.util.ExampleUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -57,11 +59,6 @@
   }
   
   @Override
   public List<Map<String, Object>> getSensorsByDevice(String mac) {
      return deviceMapper.getSensorsByDevice(mac);
   }
   @Override
   @Transactional
   public void saveOrUpdateDevice(Device device) {
      ValidateUtil.notNull(device, "param.is.null");
@@ -102,6 +99,18 @@
   }
   @Override
   public PageResult query(Integer orgId, String deviceName, Integer pageSize, Integer pageNo) {
      if(!ObjectUtils.isEmpty(pageSize)&&!ObjectUtils.isEmpty(pageNo)){
         PageHelper.startPage(pageNo,pageSize);
      }
      List list = deviceMapper.selectByOrgIdAndDevName(orgId,deviceName);
      if(list instanceof Page){
         return new PageResult(((Page) list).getTotal(),list);
      }
      return new PageResult(null,list);
   }
   @Override
   public PageBean queryByPageBean(PageBean pageBean) {
      Example example = ExampleUtil.generateExample(ENTITY_CLASS,pageBean);
      List<Example.Criteria> criteriaList = example.getOredCriteria();
@@ -136,4 +145,27 @@
      }
   }
   @Override
   public void addOrModify(Device device){
      try{
         if(device.getId()==null){
            device.setIsDelete(Constants.IS_DELETE_FALSE);
            deviceMapper.insertSelective(device);
         }else{
            deviceMapper.updateByPrimaryKeySelective(device);
         }
      }
      catch (Exception ex){
         throw  ex;
      }
   }
   @Override
   public List<Device> getDevicesByMonitorPointId(Integer monitorPointId) {
      Device device = new Device();
      device.setMonitorPointId(monitorPointId);
      device.setIsDelete(Constants.IS_DELETE_FALSE);
      return deviceMapper.select(device);
   }
}