运维app getEquInfoByMac api
| | |
| | |
|
| | | import static com.moral.common.util.WebUtils.getParametersStartingWith;
|
| | |
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | |
| | | import com.moral.util.MessageUtils;
|
| | | import com.taobao.api.ApiException;
|
| | | import org.apache.commons.lang3.StringUtils;
|
| | | import org.springframework.cglib.beans.BeanMap;
|
| | | import org.springframework.web.bind.annotation.*;
|
| | |
|
| | | import com.moral.common.bean.AppData;
|
| | |
| | | * @return the device by mac
|
| | | */
|
| | | @GetMapping("getEquInfoByMac")
|
| | | public AppData<Device> getDeviceByMac(@RequestParam(value="mac", required=true)String mac) {
|
| | | Device device = deviceService.getDeviceByMac(mac);
|
| | | return new AppData<Device>(device);
|
| | | public AppData<Map> getDeviceByMac(@RequestParam(value="mac", required=true)String mac) {
|
| | | Device device = deviceService.getDeviceByMac(mac,false);//不从缓存取
|
| | | Map<String,Object> deviceMap = new HashMap<>(BeanMap.create(device));
|
| | | deviceMap.put("monitorpointDetail",deviceMap.get("monitorPoint"));
|
| | | deviceMap.remove("monitorPoint");
|
| | | return new AppData<Map>(deviceMap);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * Send SMS
|
| | | *
|
| | | * @param mobile
|
| | | * @param username
|
| | | * @param password
|
| | | * @param code
|
| | | * @return
|
| | | */
|
| | | @PostMapping("password")
|
| | |
| | | private OperateUser operateUser;
|
| | | @Transient
|
| | | private DeviceVersion deviceVersion;
|
| | | //@Transient
|
| | | //private MonitorPoint monitorPoint;
|
| | | @Transient
|
| | | private MonitorPoint monitorPoint;
|
| | | @Transient
|
| | | private List<Integer> organizationIds;
|
| | |
|
| | | @Transient
|
| | | private MonitorPoint monitorpointDetail;
|
| | | } |
| | |
| | |
|
| | | List<Device> getInstallDevicesByOperateUser(Integer uid, Integer pageIndex, Integer pageSize);
|
| | |
|
| | | Device getDeviceByMac(String mac);
|
| | | Device getDeviceByMac(String mac, boolean fromCache);
|
| | |
|
| | | Device getDeviceByMac(String mac);
|
| | |
|
| | | List<Device> query(Map<String,Object> map);
|
| | | PageResult query(Integer orgId, String deviceName,Integer pageSize,Integer pageNo);
|
| | |
| | | device.setId(queryDevice.getId());
|
| | | deviceMapper.updateByPrimaryKeySelective(device);
|
| | | }
|
| | | //刷新redis里的信息
|
| | | refreshDeviceInRedis(device);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | List<Device> devices = deviceMapper.select(device);
|
| | | return devices;
|
| | | }
|
| | | @Override
|
| | | public Device getDeviceByMac (String mac ,boolean fromCache){
|
| | | if(fromCache){
|
| | | Device device = getDeviceFromRedis(mac);
|
| | | if(device==null) {
|
| | | device = deviceMapper.selectWithOrgIdsByMac(mac);
|
| | | if(device!=null){
|
| | | setDeviceToRedis(mac,device);
|
| | | }
|
| | | }
|
| | | return device;
|
| | | }else {
|
| | | return deviceMapper.selectWithOrgIdsByMac(mac);
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * 默认会从缓存取
|
| | | * @param mac
|
| | | * @return
|
| | | */
|
| | | @Override
|
| | | public Device getDeviceByMac(String mac) {
|
| | | Device device = getDeviceFromRedis(mac);
|
| | | if(device==null) {
|
| | | device = deviceMapper.selectWithOrgIdsByMac(mac);
|
| | | if(device!=null){
|
| | | setDeviceToRedis(mac,device);
|
| | | }
|
| | | }
|
| | | return device;
|
| | |
|
| | | return getDeviceByMac(mac,true);
|
| | | }
|
| | | /*
|
| | | * 获取报警阀值在redis里的key
|
| | |
| | | </select> |
| | | <select id="selectWithOrgIdsByMac" parameterType="java.lang.String" resultMap="BaseResultWithOrgIdsMap"> |
| | | select |
| | | id,device_version_id,mac,monitor_point_id |
| | | from device |
| | | where mac = #{mac,jdbcType=VARCHAR} |
| | | dev.*, |
| | | mpt.name as monitor_point_name |
| | | from device dev |
| | | left join monitor_point mpt on dev.monitor_point_id = mpt.id |
| | | where dev.mac = #{mac,jdbcType=VARCHAR} |
| | | </select> |
| | | |
| | | <select id="getDeviceCountByRegion" resultType="java.lang.Integer"> |