| | |
| | | Properties properties = new Properties();
|
| | | properties.setProperty("offsetAsPageNum","true");
|
| | | properties.setProperty("rowBoundsWithCount","true");
|
| | | properties.setProperty("pageSizeZero","true");
|
| | | properties.setProperty("reasonable","true");
|
| | | properties.setProperty("dialect","mysql"); //配置mysql数据库的方言
|
| | | pageHelper.setProperties(properties);
|
| | |
| | | package com.moral.controller;
|
| | |
|
| | | import static com.moral.common.util.WebUtils.getParametersStartingWith;
|
| | |
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
|
| | | import org.springframework.web.bind.annotation.CrossOrigin;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestParam;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | |
|
| | | import com.moral.common.bean.ResultBean;
|
| | |
| | | * @return the install devices by operate user
|
| | | */
|
| | | @GetMapping(value = "myRelease")
|
| | | public ResultBean<List<Device>> getInstallDevicesByOperateUser(Integer uid, Integer pageIndex, Integer pageSize) {
|
| | | public ResultBean<List<Device>> getInstallDevicesByOperateUser(@RequestParam(value="uid", required=true)Integer uid, @RequestParam(defaultValue="0")Integer pageIndex, @RequestParam(defaultValue="0")Integer pageSize) {
|
| | | List<Device> devices = deviceService.getInstallDevicesByOperateUser(uid,pageIndex,pageSize);
|
| | | return new ResultBean<List<Device>>(devices);
|
| | | }
|
| | |
| | | * @return the device by mac
|
| | | */
|
| | | @GetMapping(value = "getEquInfoByMac")
|
| | | public ResultBean<Device> getDeviceByMac(String mac) {
|
| | | public ResultBean<Device> getDeviceByMac(@RequestParam(value="mac", required=true)String mac) {
|
| | | Device device = deviceService.getDeviceByMac(mac);
|
| | | return new ResultBean<Device>(device);
|
| | | }
|
| | |
| | | * @return the monitor points by area name
|
| | | */
|
| | | @GetMapping(value = "getMpointsByAreaName")
|
| | | public ResultBean<List<MonitorPoint>> getMonitorPointsByAreaName(String areaName) {
|
| | | List<MonitorPoint> monitorPoints = monitorPointService.getMonitorPointsByAreaName(areaName);
|
| | | public ResultBean<List<MonitorPoint>> getMonitorPointsByAreaName(HttpServletRequest request) {
|
| | | Map<String, Object> parameters = getParametersStartingWith(request, null);
|
| | | List<MonitorPoint> monitorPoints = monitorPointService.getMonitorPointsByAreaName(parameters);
|
| | | return new ResultBean<List<MonitorPoint>>(monitorPoints);
|
| | | }
|
| | |
|
| | |
| | | * @return the organizations by area name
|
| | | */
|
| | | @GetMapping(value = "getOrgsByAreaName")
|
| | | public ResultBean<List<Organization>> getOrganizationsByAreaName(String areaName) {
|
| | | List<Organization> organizations = organizationService.getOrganizationsByAreaName(areaName);
|
| | | public ResultBean<List<Organization>> getOrganizationsByAreaName(HttpServletRequest request) {
|
| | | Map<String, Object> parameters = getParametersStartingWith(request, null);
|
| | | List<Organization> organizations = organizationService.getOrganizationsByAreaName(parameters);
|
| | | return new ResultBean<List<Organization>>(organizations);
|
| | | }
|
| | | }
|
| | |
| | | import org.springframework.web.bind.annotation.RestController;
|
| | |
|
| | | import com.moral.common.exception.BusinessException;
|
| | | import com.moral.common.util.ValidateUtil;
|
| | | import com.moral.service.DeviceService;
|
| | | import com.moral.service.HistoryService;
|
| | |
|
| | |
| | | Object mac = parameters.get("mac");
|
| | | Object time = parameters.get("time");
|
| | | Object type = parameters.get("type");
|
| | | if (isEmpty(mac) || isEmpty(time) || isEmpty(type)) {
|
| | | result.put("msg", "参数不能为空!");
|
| | | ValidateUtil.notNull(mac, "param.is.null");
|
| | | ValidateUtil.notNull(time, "param.is.null");
|
| | | ValidateUtil.notNull(type, "param.is.null");
|
| | | List<Map<String, Object>> sensors = deviceService.getSensorsByDevice(mac.toString());
|
| | | List<Map<String, Object>> sensorsAverage = historyService.getSensorsAverageByDevice4Report(parameters,sensors);
|
| | | if (isEmpty(sensorsAverage)) {
|
| | | result.put("msg", "无有效数据");
|
| | | } else {
|
| | | List<Map<String, Object>> sensors = deviceService.getSensorsByDevice(mac.toString());
|
| | | List<Map<String, Object>> sensorsAverage = historyService.getSensorsAverageByDevice4Report(parameters,sensors);
|
| | | if (isEmpty(sensorsAverage)) {
|
| | | result.put("msg", "无有效数据");
|
| | | } else {
|
| | | String[][] exportColumn = new String[sensors.size() + 1][];
|
| | | exportColumn[0] = new String[] { "时间", "20", "time" };
|
| | | for (int i = 0; i < sensors.size(); i++) {
|
| | | String name = (String) sensors.get(i).get("name");
|
| | | String key = (String) sensors.get(i).get("key");
|
| | | exportColumn[i + 1] = new String[] { name, "10", key };
|
| | | }
|
| | | |
| | | OutputStream outputStream = exportData(response, time + "_" + mac + "_" + type, sensorsAverage, exportColumn);
|
| | | outputStream.flush();
|
| | | outputStream.close();
|
| | | String[][] exportColumn = new String[sensors.size() + 1][];
|
| | | exportColumn[0] = new String[] { "时间", "20", "time" };
|
| | | for (int i = 0; i < sensors.size(); i++) {
|
| | | String name = (String) sensors.get(i).get("name");
|
| | | String key = (String) sensors.get(i).get("key");
|
| | | exportColumn[i + 1] = new String[] { name, "10", key };
|
| | | }
|
| | | |
| | | OutputStream outputStream = exportData(response, time + "_" + mac + "_" + type, sensorsAverage, exportColumn);
|
| | | outputStream.flush();
|
| | | outputStream.close();
|
| | | }
|
| | | } catch (BusinessException be) {
|
| | | be.printStackTrace();
|
| | |
| | | */
|
| | | @GetMapping("equipment-state")
|
| | | public Map<String, Object> getDeviceStatesByAccount(HttpServletRequest request) {
|
| | | Map<String, Object> result = new LinkedHashMap<String, Object>();
|
| | | Map<String, Object> parameters = getParametersStartingWith(request, null);
|
| | | if (!parameters.containsKey("accountId")) {
|
| | | result.put("msg", "参数不能为空!");
|
| | | } else {
|
| | | result = deviceService.getDeviceStatesByAccount(parameters);
|
| | | }
|
| | | return result;
|
| | | return deviceService.getDeviceStatesByAccount(parameters);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | */
|
| | | @GetMapping("day-aqi")
|
| | | public Map<String, Object> getDayAQIByDevice(HttpServletRequest request) {
|
| | | Map<String, Object> result = new HashMap<String, Object>();
|
| | | Map<String, Object> parameters = getParametersStartingWith(request, null);
|
| | | if (!parameters.containsKey("mac")) {
|
| | | result.put("msg", "参数不能为空!");
|
| | | } else {
|
| | | result = historyService.getDayAQIByDevice(parameters);
|
| | | }
|
| | | return result;
|
| | | return historyService.getDayAQIByDevice(parameters);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | */
|
| | | @GetMapping("all-average")
|
| | | public Map<String, Object> getAllSensorAverageByDevice(HttpServletRequest request) {
|
| | | Map<String, Object> result = new LinkedHashMap<String, Object>();
|
| | | Map<String, Object> parameters = getParametersStartingWith(request, null);
|
| | | if (!(parameters.containsKey("areaCode") && parameters.containsKey("accountId"))) {
|
| | | result.put("msg", "参数不能为空!");
|
| | | } else {
|
| | | result = historyService.getAllSensorAverageByDevice(parameters);
|
| | | }
|
| | | return result;
|
| | | return historyService.getAllSensorAverageByDevice(parameters);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | */
|
| | | @GetMapping("sensor-average")
|
| | | public Map<String, Object> getDeviceRankingBySensorAverage(HttpServletRequest request) {
|
| | | Map<String, Object> result = new HashMap<String, Object>();
|
| | | Map<String, Object> parameters = getParametersStartingWith(request, null);
|
| | | if (!(parameters.containsKey("areaCode") && parameters.containsKey("accountId")
|
| | | && parameters.containsKey("macKey"))) {
|
| | | result.put("msg", "参数不能为空!");
|
| | | } else {
|
| | | result = historyService.getDeviceRankingBySensorAverage(parameters);
|
| | | }
|
| | | return result;
|
| | | return historyService.getDeviceRankingBySensorAverage(parameters);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | */
|
| | | @GetMapping("month-sensor-average")
|
| | | public Map<String, Object> getMonthAverageBySensor(HttpServletRequest request) {
|
| | | Map<String, Object> result = new HashMap<String, Object>();
|
| | | Map<String, Object> parameters = getParametersStartingWith(request, null);
|
| | | if (!(parameters.containsKey("mac") && parameters.containsKey("macKey"))) {
|
| | | result.put("msg", "参数不能为空!");
|
| | | } else {
|
| | | result = historyService.getMonthAverageBySensor(parameters);
|
| | | }
|
| | | return result;
|
| | | return historyService.getMonthAverageBySensor(parameters);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | package com.moral.mapper;
|
| | |
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import com.moral.common.mapper.BaseMapper;
|
| | | import com.moral.entity.MonitorPoint;
|
| | |
|
| | | public interface MonitorPointMapper extends BaseMapper<MonitorPoint>{
|
| | |
|
| | | List<MonitorPoint> getMonitorPointsByAreaName(String areaName);
|
| | | List<MonitorPoint> getMonitorPointsByAreaName(Map<String, Object> parameters);
|
| | | } |
| | |
| | | package com.moral.mapper;
|
| | |
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import com.moral.common.mapper.BaseMapper;
|
| | | import com.moral.entity.Organization;
|
| | |
|
| | | public interface OrganizationMapper extends BaseMapper<Organization> {
|
| | |
|
| | | List<Organization> getOrganizationsByAreaName(String areaName);
|
| | | List<Organization> getOrganizationsByAreaName(Map<String, Object> parameters);
|
| | | } |
| | |
| | | package com.moral.service;
|
| | |
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import com.moral.entity.MonitorPoint;
|
| | |
|
| | | public interface MonitorPointService {
|
| | |
|
| | | List<MonitorPoint> getMonitorPointsByAreaName(String areaName);
|
| | | List<MonitorPoint> getMonitorPointsByAreaName(Map<String, Object> parameters);
|
| | |
|
| | | }
|
| | |
| | | package com.moral.service;
|
| | |
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.Set;
|
| | |
|
| | | import com.moral.entity.Organization;
|
| | |
| | |
|
| | | Set<Integer> getChildOrganizationIds(Integer orgId);
|
| | |
|
| | | List<Organization> getOrganizationsByAreaName(String areaName);
|
| | | List<Organization> getOrganizationsByAreaName(Map<String, Object> parameters);
|
| | |
|
| | | }
|
| | |
| | |
|
| | | @Override
|
| | | public Map<String, Object> getDeviceStatesByAccount(Map<String, Object> parameters) {
|
| | | ValidateUtil.notNull(parameters.get("accountId"), "param.is.null");
|
| | | Map<String, Object> result = new HashMap<String, Object>();
|
| | | accountService.setOrgIdsByAccount(parameters);
|
| | | List<Map<String, Object>> list = deviceMapper.getDeviceStatesByAccount(parameters);
|
| | |
| | |
|
| | | @Override
|
| | | public List<Device> getInstallDevicesByOperateUser(Integer uid, Integer pageIndex, Integer pageSize) {
|
| | | ValidateUtil.notNull(uid, "param.is.null");
|
| | | Device device = new Device();
|
| | | device.setOperateUserId(uid);
|
| | | PageHelper.startPage(pageIndex, pageSize);
|
| | |
| | | import com.moral.common.exception.BusinessException;
|
| | | import com.moral.common.util.CalculateUtils;
|
| | | import com.moral.common.util.ResourceUtil;
|
| | | import com.moral.common.util.ValidateUtil;
|
| | | import com.moral.mapper.HistoryMapper;
|
| | | import com.moral.service.AccountService;
|
| | | import com.moral.service.HistoryService;
|
| | |
| | |
|
| | | @Override
|
| | | public Map<String, Object> getAllSensorAverageByDevice(Map<String, Object> parameters) {
|
| | | ValidateUtil.notNull(parameters.get("areaCode"), "param.is.null");
|
| | | ValidateUtil.notNull(parameters.get("accountId"), "param.is.null"); |
| | | accountService.setOrgIdsByAccount(parameters);
|
| | | Date date = new Date();
|
| | | // 当前时间 -10分钟
|
| | |
| | |
|
| | | @Override
|
| | | public Map<String, Object> getDeviceRankingBySensorAverage(Map<String, Object> parameters) {
|
| | | Map<String, Object> result = new LinkedHashMap<String, Object>();
|
| | | ValidateUtil.notNull(parameters.get("areaCode"), "param.is.null");
|
| | | ValidateUtil.notNull(parameters.get("accountId"), "param.is.null"); |
| | | ValidateUtil.notNull(parameters.get("macKey"), "param.is.null"); |
| | |
|
| | | Map<String, Object> result = new LinkedHashMap<String, Object>();
|
| | | accountService.setOrgIdsByAccount(parameters);
|
| | | Date date = new Date();
|
| | | // 当前时间 -1小时
|
| | |
| | |
|
| | | @Override
|
| | | public Map<String, Object> getDayAQIByDevice(Map<String, Object> parameters) {
|
| | | ValidateUtil.notNull(parameters.get("mac"), "param.is.null");
|
| | | Map<String, Object> resultMap = new HashMap<String, Object>();
|
| | | Date date = new Date();
|
| | | // 昨日00:00:00
|
| | |
| | |
|
| | | @Override
|
| | | public Map<String, Object> getMonthAverageBySensor(Map<String, Object> parameters) {
|
| | | ValidateUtil.notNull(parameters.get("mac"), "param.is.null"); |
| | | ValidateUtil.notNull(parameters.get("macKey"), "param.is.null"); |
| | | Map<String, Object> result = new HashMap<String, Object>();
|
| | | Date date = new Date();
|
| | | Long end = truncate(date, Calendar.DATE).getTime(), start;
|
| | |
| | | package com.moral.service.impl;
|
| | |
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.moral.common.util.ValidateUtil;
|
| | | import com.moral.entity.MonitorPoint;
|
| | | import com.moral.mapper.MonitorPointMapper;
|
| | | import com.moral.service.MonitorPointService;
|
| | |
| | | private MonitorPointMapper monitorPointMapper;
|
| | |
|
| | | @Override
|
| | | public List<MonitorPoint> getMonitorPointsByAreaName(String areaName) {
|
| | | return monitorPointMapper.getMonitorPointsByAreaName(areaName);
|
| | | public List<MonitorPoint> getMonitorPointsByAreaName(Map<String, Object> parameters) {
|
| | | ValidateUtil.notNull(parameters.get("areaName"), "param.is.null");
|
| | | return monitorPointMapper.getMonitorPointsByAreaName(parameters);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | import com.moral.common.exception.BusinessException;
|
| | | import com.moral.common.util.Crypto;
|
| | | import com.moral.common.util.ValidateUtil;
|
| | | import com.moral.entity.OperateUser;
|
| | | import com.moral.mapper.OperateUserMapper;
|
| | | import com.moral.service.OperateUserService;
|
| | |
| | |
|
| | | @Override
|
| | | public OperateUser mobileLogin(String mobile, String password) {
|
| | | ValidateUtil.notEmpty(mobile, "param.is.null");
|
| | | ValidateUtil.notEmpty(password, "param.is.null");
|
| | | OperateUser operateUser = new OperateUser();
|
| | | operateUser.setMobile(mobile);
|
| | | operateUser.setPassword(Crypto.md5(password));
|
| | |
| | | @Override
|
| | | @Transactional
|
| | | public OperateUser updatePassword(Integer uid, String password, String newPassword) {
|
| | | ValidateUtil.notNull(uid, "param.is.null");
|
| | | ValidateUtil.notEmpty(password, "param.is.null");
|
| | | ValidateUtil.notEmpty(newPassword, "param.is.null");
|
| | | OperateUser operateUser = operateUserMapper.selectByPrimaryKey(uid);
|
| | | if (ObjectUtils.isEmpty(operateUser) || !Crypto.md5(password).equals(operateUser.getPassword())) {
|
| | | throw new BusinessException("旧密码错误,修改密码失败!");
|
| | |
| | |
|
| | | import java.util.HashSet;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.Set;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.moral.common.exception.ValidateException;
|
| | | import com.moral.common.util.ValidateUtil;
|
| | | import com.moral.entity.Organization;
|
| | | import com.moral.entity.OrganizationRelation;
|
| | | import com.moral.mapper.OrganizationMapper;
|
| | |
| | | return orgIds;
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public List<Organization> getOrganizationsByAreaName(String areaName) {
|
| | | List<Organization> organizations = organizationMapper.getOrganizationsByAreaName(areaName);
|
| | | public List<Organization> getOrganizationsByAreaName(Map<String, Object> parameters) {
|
| | | ValidateUtil.notNull(parameters.get("areaName"), "param.is.null");
|
| | | List<Organization> organizations = organizationMapper.getOrganizationsByAreaName(parameters);
|
| | | return organizations;
|
| | | }
|
| | |
|
| | |
| | | mp.*
|
| | | FROM
|
| | | monitor_point mp,
|
| | | area a |
| | | area a
|
| | | <if test="cityName != null">
|
| | | ,city c |
| | | </if>
|
| | | WHERE
|
| | | mp.area_code = a.area_code
|
| | | AND a.area_name = #{areaName}
|
| | | AND a.area_name = #{areaName}
|
| | | <if test="cityName != null">
|
| | | AND c.city_name = #{cityName}
|
| | | AND mp.city_code = c.city_code
|
| | | </if>
|
| | | </select>
|
| | | </mapper> |
| | |
| | | FROM |
| | | organization o, |
| | | area a |
| | | <if test="cityName != null">
|
| | | ,city c |
| | | </if>
|
| | | WHERE |
| | | o.area_code = a.area_code |
| | | AND a.area_name = #{areaName} |
| | | AND a.area_name = #{areaName} |
| | | <if test="cityName != null">
|
| | | AND c.city_name = #{cityName}
|
| | | AND o.city_code = c.city_code
|
| | | </if>
|
| | | </select> |
| | | </mapper> |