3 files deleted
8 files added
22 files modified
New file |
| | |
| | | package com.moral.config; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.context.MessageSource; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import com.moral.common.util.ValidateUtil; |
| | | |
| | | |
| | | @Component |
| | | public class InjectionConfig { |
| | | |
| | | @Resource |
| | | MessageSource resources; |
| | | |
| | | @PostConstruct |
| | | private void init() { |
| | | ValidateUtil.setResources(resources); |
| | | } |
| | | } |
New file |
| | |
| | | package com.moral.config;
|
| | |
|
| | | import org.springframework.context.annotation.Bean;
|
| | | import org.springframework.context.annotation.Configuration;
|
| | | import org.springframework.context.support.ResourceBundleMessageSource;
|
| | | import org.springframework.web.servlet.LocaleResolver;
|
| | | import org.springframework.web.servlet.i18n.SessionLocaleResolver;
|
| | |
|
| | | @Configuration
|
| | | public class MessageSourceConfig {
|
| | | @Bean(name="localeResolver")
|
| | | public LocaleResolver localeResolverBean() {
|
| | | return new SessionLocaleResolver();
|
| | | }
|
| | |
|
| | | @Bean(name="messageSource")
|
| | | public ResourceBundleMessageSource resourceBundleMessageSource(){
|
| | | ResourceBundleMessageSource source=new ResourceBundleMessageSource();
|
| | | source.setBasename("i18n/exceptions");
|
| | | return source;
|
| | | }
|
| | | } |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | |
|
| | | import com.github.pagehelper.PageHelper;
|
| | | import com.moral.common.bean.PageBean;
|
| | | import com.moral.common.bean.ResultBean;
|
| | | import com.moral.entity.Device;
|
| | | import com.moral.entity.MonitorPoint;
|
| | | import com.moral.entity.OperateUser;
|
| | | import com.moral.entity.Organization;
|
| | | import com.moral.service.DeviceService;
|
| | | import com.moral.service.MonitorPointService;
|
| | | import com.moral.service.OperateUserService;
|
| | | import com.moral.service.OrganizationService;
|
| | |
|
| | | @RestController
|
| | | @RequestMapping(value = "mobile")
|
| | |
| | |
|
| | | @Resource
|
| | | private DeviceService deviceService;
|
| | |
|
| | | @Resource
|
| | | private OrganizationService organizationService;
|
| | |
|
| | | @Resource
|
| | | private MonitorPointService monitorPointService;
|
| | |
|
| | | // 1登录
|
| | | @GetMapping(value = "accountlogin")
|
| | |
| | | }
|
| | |
|
| | | @GetMapping(value = "getEquInfoByMac")
|
| | | public void getEquInfoByMac(String mac) {
|
| | | public ResultBean<Device> getDeviceByMac(String mac) {
|
| | | Device device = deviceService.getDeviceByMac(mac);
|
| | | return new ResultBean<Device>(device);
|
| | | }
|
| | |
|
| | | @GetMapping(value = "getMpointsByAreaName")
|
| | | public void getMpointsByAreaName(String areaName) {
|
| | | public ResultBean<List<MonitorPoint>> getMonitorPointsByAreaName(String areaName) {
|
| | | List<MonitorPoint> monitorPoints = monitorPointService.getMonitorPointsByAreaName(areaName);
|
| | | return new ResultBean<List<MonitorPoint>>(monitorPoints);
|
| | | }
|
| | |
|
| | | @GetMapping(value = "getOrgsByAreaName")
|
| | | public void getOrgsByAreaName(String areaName) {
|
| | |
|
| | | public ResultBean<List<Organization>> getOrganizationsByAreaName(String areaName) {
|
| | | List<Organization> organizations = organizationService.getOrganizationsByAreaName(areaName);
|
| | | return new ResultBean<List<Organization>>(organizations);
|
| | | }
|
| | | }
|
| | |
| | | import static com.moral.common.util.RedisUtil.hasKey;
|
| | | import static com.moral.common.util.ResourceUtil.getValue;
|
| | | import static com.moral.common.util.WebUtils.getParametersStartingWith;
|
| | | import static org.springframework.util.ObjectUtils.isEmpty;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.io.InputStreamReader;
|
| | |
| | | import com.alibaba.fastjson.JSON;
|
| | | import com.alibaba.fastjson.JSONReader;
|
| | | import com.alibaba.fastjson.TypeReference;
|
| | | import com.moral.common.exception.BusinessException;
|
| | | import com.moral.common.util.ValidateUtil;
|
| | | import com.moral.service.AccountService;
|
| | | import com.moral.service.DeviceService;
|
| | |
| | | */
|
| | | @GetMapping("sensor-standard")
|
| | | public Map<String, Object> getStandardBySensor(@RequestParam("macKey") String macKey) {
|
| | | ValidateUtil.notEmpty(macKey, "param.is.null");
|
| | | Map<String, Object> result = new HashMap<String, Object>();
|
| | | ValidateUtil.notEmpty(macKey, "参数不能为空!");
|
| | | result.put("standard", getValue(macKey + "-standard"));
|
| | | return result;
|
| | | }
|
| | |
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import javax.persistence.Id;
|
| | |
|
| | | import lombok.Data;
|
| | |
|
| | | @Data
|
| | | public class Account {
|
| | | private Integer id;
|
| | | /**
|
| | | * This field was generated by MyBatis Generator. This field corresponds to the database column account.id
|
| | | * @mbggenerated Thu Dec 07 16:17:21 CST 2017
|
| | | */
|
| | | @Id
|
| | | private Integer id;
|
| | |
|
| | | /**
|
| | | * This field was generated by MyBatis Generator. This field corresponds to the database column account.account_name
|
| | | * @mbggenerated Thu Dec 07 16:17:21 CST 2017
|
| | | */
|
| | | private String accountName;
|
| | |
|
| | | /**
|
| | | * This field was generated by MyBatis Generator. This field corresponds to the database column account.password
|
| | | * @mbggenerated Thu Dec 07 16:17:21 CST 2017
|
| | | */
|
| | | private String password;
|
| | |
|
| | | /**
|
| | | * This field was generated by MyBatis Generator. This field corresponds to the database column account.organization_id
|
| | | * @mbggenerated Thu Dec 07 16:17:21 CST 2017
|
| | | */
|
| | | private Integer organizationId;
|
| | |
|
| | | /**
|
| | | * This field was generated by MyBatis Generator. This field corresponds to the database column account.email
|
| | | * @mbggenerated Thu Dec 07 16:17:21 CST 2017
|
| | | */
|
| | | private String email;
|
| | |
|
| | | /**
|
| | | * This field was generated by MyBatis Generator. This field corresponds to the database column account.mobile
|
| | | * @mbggenerated Thu Dec 07 16:17:21 CST 2017
|
| | | */
|
| | | private String mobile;
|
| | |
|
| | | /**
|
| | | * This field was generated by MyBatis Generator. This field corresponds to the database column account.weixin
|
| | | * @mbggenerated Thu Dec 07 16:17:21 CST 2017
|
| | | */
|
| | | private String weixin;
|
| | |
|
| | | /**
|
| | | * This field was generated by MyBatis Generator. This field corresponds to the database column account.is_delete
|
| | | * @mbggenerated Thu Dec 07 16:17:21 CST 2017
|
| | | */
|
| | | private String isDelete;
|
| | |
|
| | | /**
|
| | | * This field was generated by MyBatis Generator. This field corresponds to the database column account.create_time
|
| | | * @mbggenerated Thu Dec 07 16:17:21 CST 2017
|
| | | */
|
| | | private Date createTime;
|
| | |
|
| | | /**
|
| | | * This field was generated by MyBatis Generator. This field corresponds to the database column account.expire_time
|
| | | * @mbggenerated Thu Dec 07 16:17:21 CST 2017
|
| | | */
|
| | | private Date expireTime;
|
| | |
|
| | | } |
| | |
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import javax.persistence.Id;
|
| | |
|
| | | import lombok.Data;
|
| | |
|
| | |
|
| | |
| | | * This field was generated by MyBatis Generator. This field corresponds to the database column device.id
|
| | | * @mbggenerated Wed Nov 29 16:17:59 CST 2017
|
| | | */
|
| | | @Id
|
| | | private Integer id;
|
| | | /**
|
| | | * This field was generated by MyBatis Generator. This field corresponds to the database column device.name
|
New file |
| | |
| | | package com.moral.entity;
|
| | |
|
| | | import javax.persistence.Id;
|
| | |
|
| | | import lombok.Data;
|
| | |
|
| | | @Data
|
| | | public class MonitorPoint {
|
| | | /**
|
| | | * This field was generated by MyBatis Generator.
|
| | | * This field corresponds to the database column monitor_point.id
|
| | | *
|
| | | * @mbggenerated Thu Dec 07 16:40:22 CST 2017
|
| | | */
|
| | | @Id
|
| | | private Integer id;
|
| | |
|
| | | /**
|
| | | * This field was generated by MyBatis Generator.
|
| | | * This field corresponds to the database column monitor_point.name
|
| | | *
|
| | | * @mbggenerated Thu Dec 07 16:40:22 CST 2017
|
| | | */
|
| | | private String name;
|
| | |
|
| | | /**
|
| | | * This field was generated by MyBatis Generator.
|
| | | * This field corresponds to the database column monitor_point.longitude
|
| | | *
|
| | | * @mbggenerated Thu Dec 07 16:40:22 CST 2017
|
| | | */
|
| | | private Float longitude;
|
| | |
|
| | | /**
|
| | | * This field was generated by MyBatis Generator.
|
| | | * This field corresponds to the database column monitor_point.latitude
|
| | | *
|
| | | * @mbggenerated Thu Dec 07 16:40:22 CST 2017
|
| | | */
|
| | | private Float latitude;
|
| | |
|
| | | /**
|
| | | * This field was generated by MyBatis Generator.
|
| | | * This field corresponds to the database column monitor_point.province_code
|
| | | *
|
| | | * @mbggenerated Thu Dec 07 16:40:22 CST 2017
|
| | | */
|
| | | private Integer provinceCode;
|
| | |
|
| | | /**
|
| | | * This field was generated by MyBatis Generator.
|
| | | * This field corresponds to the database column monitor_point.city_code
|
| | | *
|
| | | * @mbggenerated Thu Dec 07 16:40:22 CST 2017
|
| | | */
|
| | | private Integer cityCode;
|
| | |
|
| | | /**
|
| | | * This field was generated by MyBatis Generator.
|
| | | * This field corresponds to the database column monitor_point.area_code
|
| | | *
|
| | | * @mbggenerated Thu Dec 07 16:40:22 CST 2017
|
| | | */
|
| | | private Integer areaCode;
|
| | |
|
| | | /**
|
| | | * This field was generated by MyBatis Generator.
|
| | | * This field corresponds to the database column monitor_point.organization_id
|
| | | *
|
| | | * @mbggenerated Thu Dec 07 16:40:22 CST 2017
|
| | | */
|
| | | private Integer organizationId;
|
| | |
|
| | | /**
|
| | | * This field was generated by MyBatis Generator.
|
| | | * This field corresponds to the database column monitor_point.address
|
| | | *
|
| | | * @mbggenerated Thu Dec 07 16:40:22 CST 2017
|
| | | */
|
| | | private String address;
|
| | |
|
| | | /**
|
| | | * This field was generated by MyBatis Generator.
|
| | | * This field corresponds to the database column monitor_point.is_delete
|
| | | *
|
| | | * @mbggenerated Thu Dec 07 16:40:22 CST 2017
|
| | | */
|
| | | private String isDelete;
|
| | |
|
| | | /**
|
| | | * This field was generated by MyBatis Generator.
|
| | | * This field corresponds to the database column monitor_point.description
|
| | | *
|
| | | * @mbggenerated Thu Dec 07 16:40:22 CST 2017
|
| | | */
|
| | | private String description;
|
| | | } |
| | |
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import javax.persistence.Id;
|
| | |
|
| | | import lombok.Data;
|
| | |
|
| | | @Data
|
| | | public class OperateUser {
|
| | | @Id
|
| | | private Integer id;
|
| | |
|
| | | private String jobNumber;
|
| | |
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import javax.persistence.Id;
|
| | |
|
| | | import lombok.Data;
|
| | |
|
| | | @Data
|
| | | public class Organization {
|
| | | private Integer id;
|
| | | /**
|
| | | * This field was generated by MyBatis Generator. This field corresponds to the database column organization.id
|
| | | * @mbggenerated Thu Dec 07 15:18:16 CST 2017
|
| | | */
|
| | | @Id
|
| | | private Integer id;
|
| | |
|
| | | private String name;
|
| | | /**
|
| | | * This field was generated by MyBatis Generator. This field corresponds to the database column organization.name
|
| | | * @mbggenerated Thu Dec 07 15:18:16 CST 2017
|
| | | */
|
| | | private String name;
|
| | |
|
| | | private Integer rank;
|
| | | /**
|
| | | * This field was generated by MyBatis Generator. This field corresponds to the database column organization.rank
|
| | | * @mbggenerated Thu Dec 07 15:18:16 CST 2017
|
| | | */
|
| | | private Integer rank;
|
| | |
|
| | | private Integer provinceCode;
|
| | | /**
|
| | | * This field was generated by MyBatis Generator. This field corresponds to the database column organization.province_code
|
| | | * @mbggenerated Thu Dec 07 15:18:16 CST 2017
|
| | | */
|
| | | private Integer provinceCode;
|
| | |
|
| | | private Integer cityCode;
|
| | | /**
|
| | | * This field was generated by MyBatis Generator. This field corresponds to the database column organization.city_code
|
| | | * @mbggenerated Thu Dec 07 15:18:16 CST 2017
|
| | | */
|
| | | private Integer cityCode;
|
| | |
|
| | | private Integer areaCode;
|
| | | /**
|
| | | * This field was generated by MyBatis Generator. This field corresponds to the database column organization.area_code
|
| | | * @mbggenerated Thu Dec 07 15:18:16 CST 2017
|
| | | */
|
| | | private Integer areaCode;
|
| | |
|
| | | private String address;
|
| | | /**
|
| | | * This field was generated by MyBatis Generator. This field corresponds to the database column organization.address
|
| | | * @mbggenerated Thu Dec 07 15:18:16 CST 2017
|
| | | */
|
| | | private String address;
|
| | |
|
| | | private String telephone;
|
| | | /**
|
| | | * This field was generated by MyBatis Generator. This field corresponds to the database column organization.telephone
|
| | | * @mbggenerated Thu Dec 07 15:18:16 CST 2017
|
| | | */
|
| | | private String telephone;
|
| | |
|
| | | private String email;
|
| | | /**
|
| | | * This field was generated by MyBatis Generator. This field corresponds to the database column organization.email
|
| | | * @mbggenerated Thu Dec 07 15:18:16 CST 2017
|
| | | */
|
| | | private String email;
|
| | |
|
| | | private String isDelete;
|
| | | /**
|
| | | * This field was generated by MyBatis Generator. This field corresponds to the database column organization.is_delete
|
| | | * @mbggenerated Thu Dec 07 15:18:16 CST 2017
|
| | | */
|
| | | private String isDelete;
|
| | |
|
| | | private Date createTime;
|
| | | /**
|
| | | * This field was generated by MyBatis Generator. This field corresponds to the database column organization.create_time
|
| | | * @mbggenerated Thu Dec 07 15:18:16 CST 2017
|
| | | */
|
| | | private Date createTime;
|
| | |
|
| | | private Date expireTime;
|
| | | /**
|
| | | * This field was generated by MyBatis Generator. This field corresponds to the database column organization.expire_time
|
| | | * @mbggenerated Thu Dec 07 15:18:16 CST 2017
|
| | | */
|
| | | private Date expireTime;
|
| | |
|
| | | private String description;
|
| | | /**
|
| | | * This field was generated by MyBatis Generator. This field corresponds to the database column organization.description
|
| | | * @mbggenerated Thu Dec 07 15:18:16 CST 2017
|
| | | */
|
| | | private String description;
|
| | |
|
| | | } |
| | |
| | | package com.moral.entity;
|
| | |
|
| | | import javax.persistence.Id;
|
| | |
|
| | | import lombok.Data;
|
| | |
|
| | | @Data
|
| | | public class OrganizationRelation {
|
| | | @Id
|
| | | private Integer id;
|
| | |
|
| | | private Integer parentId;
|
| | |
| | | import com.moral.entity.Account;
|
| | |
|
| | | public interface AccountMapper extends BaseMapper<Account> {
|
| | |
|
| | | List<Map<String, Object>> getRoleNameByAccountId(Integer accountId);
|
| | | } |
New file |
| | |
| | | package com.moral.mapper;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.moral.common.mapper.BaseMapper;
|
| | | import com.moral.entity.MonitorPoint;
|
| | |
|
| | | public interface MonitorPointMapper extends BaseMapper<MonitorPoint>{
|
| | |
|
| | | List<MonitorPoint> getMonitorPointsByAreaName(String areaName);
|
| | | } |
| | |
| | | package com.moral.mapper;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.moral.common.mapper.BaseMapper;
|
| | | import com.moral.entity.Organization;
|
| | |
|
| | | public interface OrganizationMapper extends BaseMapper<Organization> {
|
| | |
|
| | | List<Organization> getOrganizationsByAreaName(String areaName);
|
| | | } |
| | |
| | | package com.moral.service;
|
| | |
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import com.moral.entity.Account;
|
| | |
| | |
|
| | | Map<String, Object> screenLogin(Map<String, Object> parameters);
|
| | |
|
| | | List<Account> getAccountLists(String account, String password);
|
| | |
|
| | | List<Account> getAccountList(String account);
|
| | | Account getAccountByAccountName(String account);
|
| | |
|
| | | void setOrgIdsByAccount(Map<String, Object> parameters);
|
| | |
|
| | |
| | | void saveOrUpdateDevice(Device device);
|
| | |
|
| | | List<Device> getInstallDevicesByOperateUser(Integer uid, Integer pageIndex, Integer pageSize);
|
| | |
|
| | | Device getDeviceByMac(String mac);
|
| | | }
|
New file |
| | |
| | | package com.moral.service;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.moral.entity.MonitorPoint;
|
| | |
|
| | | public interface MonitorPointService {
|
| | |
|
| | | List<MonitorPoint> getMonitorPointsByAreaName(String areaName);
|
| | |
|
| | | }
|
| | |
| | | package com.moral.service;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.moral.entity.OperateUser;
|
| | |
|
| | | public interface OperateUserService {
|
| | |
|
| | | List<OperateUser> getUserList(String mobile);
|
| | | OperateUser getOperateUserByMobile(String mobile);
|
| | |
|
| | | OperateUser mobileLogin(String mobile, String password);
|
| | |
|
| | |
| | | package com.moral.service;
|
| | |
|
| | | import java.util.List;
|
| | | import java.util.Set;
|
| | |
|
| | | import com.moral.entity.Organization;
|
| | |
|
| | | public interface OrganizationService {
|
| | |
|
| | | Set<Integer> getChildOrganizationIds(Integer orgId);
|
| | |
|
| | | List<Organization> getOrganizationsByAreaName(String areaName);
|
| | |
|
| | | }
|
| | |
| | | import static org.springframework.util.ObjectUtils.isEmpty;
|
| | |
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.Set;
|
| | |
|
| | |
| | | import com.moral.service.AccountService;
|
| | | import com.moral.service.OrganizationService;
|
| | |
|
| | | import tk.mybatis.mapper.entity.Example;
|
| | |
|
| | | @Service
|
| | | public class AccountServiceImpl implements AccountService {
|
| | |
|
| | |
| | | @Override
|
| | | public Map<String, Object> screenLogin(Map<String, Object> parameters) {
|
| | | Map<String, Object> result = new HashMap<String, Object>();
|
| | | Example example = new Example(Account.class);
|
| | | String password = md5((String) parameters.get("account"));
|
| | | example.or().andEqualTo("accountName",parameters.get("account")).andEqualTo("password",password);
|
| | | List<Account> accounts = accountMapper.selectByExample(example);
|
| | | if (isEmpty(accounts) || accounts.size() != 1) {
|
| | | Account account = new Account();
|
| | | account.setAccountName((String) parameters.get("account"));
|
| | | account.setPassword(md5((String) parameters.get("password")));
|
| | | account = accountMapper.selectOne(account);
|
| | | if (isEmpty(account)) {
|
| | | result.put("msg", "用户名及密码输入错误!");
|
| | | } else {
|
| | | Account account = accounts.get(0);
|
| | | if (IS_DELETE_FALSE.equals(account.getIsDelete())) {
|
| | | result.put("msg", "登录成功!");
|
| | | result.put("accountId", account.getId());
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Account> getAccountLists(String accountName, String password) {
|
| | | Example example = new Example(Account.class);
|
| | | example.or().andEqualTo("accountName",accountName).andEqualTo("password",password);
|
| | | return accountMapper.selectByExample(example);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Account> getAccountList(String accountName) {
|
| | | Example example = new Example(Account.class);
|
| | | example.or().andEqualTo("accountName",accountName);
|
| | | return accountMapper.selectByExample(example);
|
| | | public Account getAccountByAccountName(String accountName) {
|
| | | Account account = new Account();
|
| | | account.setAccountName(accountName);
|
| | | return accountMapper.selectOne(account);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | import org.springframework.util.ObjectUtils;
|
| | |
|
| | | import com.github.pagehelper.PageHelper;
|
| | | import com.moral.common.exception.BusinessException;
|
| | | import com.moral.common.util.ValidateUtil;
|
| | | import com.moral.entity.Device;
|
| | | import com.moral.mapper.DeviceMapper;
|
| | | import com.moral.service.AccountService;
|
| | | import com.moral.service.DeviceService;
|
| | |
|
| | | import tk.mybatis.mapper.entity.Example;
|
| | |
|
| | | @Service
|
| | | public class DeviceServiceImpl implements DeviceService {
|
| | |
| | |
|
| | | @Override
|
| | | public void saveOrUpdateDevice(Device device) {
|
| | | ValidateUtil.notNull(device, "参数不可为空");
|
| | | ValidateUtil.notEmpty(device.getMac(), "参数不可为空");
|
| | | Example example = new Example(Device.class);
|
| | | example.or().andEqualTo("mac",device.getMac());
|
| | | List<Device> devices = deviceMapper.selectByExample(example);
|
| | | ValidateUtil.notNull(device, "param.is.null");
|
| | | ValidateUtil.notEmpty(device.getMac(), "param.is.null");
|
| | | Device queryDevice = new Device();
|
| | | queryDevice.setMac(device.getMac());
|
| | | queryDevice = deviceMapper.selectOne(queryDevice);
|
| | | Date operateDate = new Date();
|
| | | device.setInstallTime(operateDate);
|
| | | if (ObjectUtils.isEmpty(devices)) {
|
| | | if (ObjectUtils.isEmpty(queryDevice)) {
|
| | | device.setCreateTime(operateDate);
|
| | | device.setState("4");
|
| | | deviceMapper.insertSelective(device);
|
| | | }else if (devices.size() > 1) {
|
| | | throw new BusinessException("设备信息异常,联系管理员!");
|
| | | }else {
|
| | | device.setId(devices.get(0).getId());
|
| | | device.setId(queryDevice.getId());
|
| | | deviceMapper.updateByPrimaryKeySelective(device);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Device> getInstallDevicesByOperateUser(Integer uid, Integer pageIndex, Integer pageSize) {
|
| | | Example example = new Example(Device.class);
|
| | | example.or().andEqualTo("operateUserId",uid);
|
| | | Device device = new Device();
|
| | | device.setOperateUserId(uid);
|
| | | PageHelper.startPage(pageIndex, pageSize);
|
| | | List<Device> devices = deviceMapper.selectByExample(example);
|
| | | List<Device> devices = deviceMapper.select(device);
|
| | | return devices;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Device getDeviceByMac(String mac) {
|
| | | ValidateUtil.notEmpty(mac, "param.is.null");
|
| | | Device device = new Device();
|
| | | device.setMac(mac);
|
| | | device = deviceMapper.selectOne(device);
|
| | | return device;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.moral.service.impl;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.moral.entity.MonitorPoint;
|
| | | import com.moral.mapper.MonitorPointMapper;
|
| | | import com.moral.service.MonitorPointService;
|
| | |
|
| | | @Service
|
| | | public class MonitorPointServiceImpl implements MonitorPointService {
|
| | | @Resource
|
| | | private MonitorPointMapper monitorPointMapper;
|
| | |
|
| | | @Override
|
| | | public List<MonitorPoint> getMonitorPointsByAreaName(String areaName) {
|
| | | return monitorPointMapper.getMonitorPointsByAreaName(areaName);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | package com.moral.service.impl;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
| | | import com.moral.mapper.OperateUserMapper;
|
| | | import com.moral.service.OperateUserService;
|
| | |
|
| | | import tk.mybatis.mapper.entity.Example;
|
| | |
|
| | | @Service
|
| | | public class OperateUserServiceImpl implements OperateUserService {
|
| | |
|
| | |
| | | private OperateUserMapper operateUserMapper;
|
| | |
|
| | | @Override
|
| | | public List<OperateUser> getUserList(String mobile) {
|
| | | Example example = new Example(OperateUser.class);
|
| | | example.or().andEqualTo("mobile", mobile);
|
| | | return operateUserMapper.selectByExample(example);
|
| | | public OperateUser getOperateUserByMobile(String mobile) {
|
| | | OperateUser operateUser = new OperateUser();
|
| | | operateUser.setMobile(mobile);
|
| | | return operateUserMapper.selectOne(operateUser);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public OperateUser mobileLogin(String mobile, String password) {
|
| | | Example example = new Example(OperateUser.class);
|
| | | example.or().andEqualTo("mobile", mobile).andEqualTo("password", Crypto.md5(password));
|
| | | List<OperateUser> operateUsers = operateUserMapper.selectByExample(example);
|
| | | if (ObjectUtils.isEmpty(operateUsers) || operateUsers.size() > 1) {
|
| | | OperateUser operateUser = new OperateUser();
|
| | | operateUser.setMobile(mobile);
|
| | | operateUser.setPassword(Crypto.md5(password));
|
| | | operateUser = operateUserMapper.selectOne(operateUser);
|
| | | if (ObjectUtils.isEmpty(operateUser)) {
|
| | | throw new BusinessException("用户名或密码错误,登陆失败!");
|
| | | }else {
|
| | | OperateUser operateUser = operateUsers.get(0);
|
| | | operateUser.setPassword(password);
|
| | | return operateUser;
|
| | | }
|
| | |
| | | import com.moral.mapper.OrganizationRelationMapper;
|
| | | import com.moral.service.OrganizationService;
|
| | |
|
| | | import tk.mybatis.mapper.entity.Example;
|
| | |
|
| | | @Service
|
| | | public class OrganizationServiceImpl implements OrganizationService {
|
| | |
|
| | |
| | | public Set<Integer> getChildOrganizationIds(Integer orgId){
|
| | | Set<Integer> orgIds = new HashSet<Integer>();
|
| | | orgIds.add(orgId);
|
| | | Example example = new Example(OrganizationRelation.class);
|
| | | example.or().andEqualTo("parentId",orgId);
|
| | | OrganizationRelation relation = new OrganizationRelation();
|
| | | relation.setParentId(orgId);
|
| | | Organization organization = organizationMapper.selectByPrimaryKey(orgId);
|
| | | if (IS_DELETE_FALSE.equals(organization.getIsDelete())) {
|
| | | List<OrganizationRelation> organizationRelations = organizationRelationMapper.selectByExample(example);
|
| | | List<OrganizationRelation> organizationRelations = organizationRelationMapper.select(relation);
|
| | | for (OrganizationRelation organizationRelation : organizationRelations) {
|
| | | Set<Integer> organizationIds = getChildOrganizationIds(organizationRelation.getParentId());
|
| | | orgIds.addAll(organizationIds);
|
| | |
| | | return orgIds;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Organization> getOrganizationsByAreaName(String areaName) {
|
| | | List<Organization> organizations = organizationMapper.getOrganizationsByAreaName(areaName);
|
| | | return organizations;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | mongodb: |
| | | uri: mongodb://47.96.171.62:27017/monitor |
| | | |
| | | #mybatis: |
| | | # mapper-locations: classpath*:/mapper/*Mapper.xml |
| | | # type-aliases-package: com.moral.entity |
| | | mybatis: |
| | | mapper-locations: classpath*:/mapper/*Mapper.xml |
| | | type-aliases-package: com.moral.entity |
New file |
| | |
| | | param.is.null=\u53C2\u6570\u4E3A\u7A7A |
| | | name.is.null=\u540D\u79F0\u4E3A\u7A7A |
| | | value.is.null=\u53D6\u503C\u4E3A\u7A7A |
| | | id.error=\u975E\u6CD5\u7684id\uFF1A{0} |
| | | |
| | | name.repeat=\u540D\u79F0\u5DF2\u7ECF\u5B58\u5728 |
| | | |
| | | no.permission=\u6CA1\u6709\u6743\u9650 |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?>
|
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
| | | <mapper namespace="com.moral.mapper.AccountMapper"> |
| | | <resultMap id="BaseResultMap" type="com.moral.entity.Account"> |
| | | <id column="id" jdbcType="INTEGER" property="id" /> |
| | | <result column="account_name" jdbcType="VARCHAR" property="accountName" /> |
| | | <result column="password" jdbcType="VARCHAR" property="password" /> |
| | | <result column="organization_id" jdbcType="INTEGER" property="organizationId" /> |
| | | <result column="email" jdbcType="VARCHAR" property="email" /> |
| | | <result column="mobile" jdbcType="VARCHAR" property="mobile" /> |
| | | <result column="weixin" jdbcType="VARCHAR" property="weixin" /> |
| | | <result column="is_delete" jdbcType="CHAR" property="isDelete" /> |
| | | <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> |
| | | <result column="expire_time" jdbcType="TIMESTAMP" property="expireTime" /> |
| | | </resultMap> |
| | |
|
| | | <select id="getRoleNameByAccountId" resultType="map"> |
| | | SELECT |
| | | r.role_name |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?>
|
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
| | | <mapper namespace="com.moral.mapper.DeviceMapper"> |
| | | <resultMap id="BaseResultMap" type="com.moral.entity.Device"> |
| | | <!-- |
| | | WARNING - @mbggenerated |
| | | This element is automatically generated by MyBatis Generator, do not modify. |
| | | This element was generated on Wed Nov 29 16:17:59 CST 2017. |
| | | --> |
| | | <id column="id" jdbcType="INTEGER" property="id" /> |
| | | <result column="name" jdbcType="VARCHAR" property="name" /> |
| | | <result column="address" jdbcType="VARCHAR" property="address" /> |
| | | <result column="longitude" jdbcType="REAL" property="longitude" /> |
| | | <result column="latitude" jdbcType="REAL" property="latitude" /> |
| | | <result column="mac" jdbcType="VARCHAR" property="mac" /> |
| | | <result column="operate_user_id" jdbcType="INTEGER" property="operateUserId" /> |
| | | <result column="state" jdbcType="CHAR" property="state" /> |
| | | <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> |
| | | <result column="install_time" jdbcType="TIMESTAMP" property="installTime" /> |
| | | <result column="monitor_point_id" jdbcType="INTEGER" property="monitorPointId" /> |
| | | <result column="device_version_id" jdbcType="INTEGER" property="deviceVersionId" /> |
| | | </resultMap> |
| | | <select id="getDeviceStatesByAccount" resultType="map"> |
| | | SELECT |
| | | COUNT( d.state ) count, |
| | |
| | | </if> |
| | | GROUP BY d.state |
| | | </select> |
| | |
|
| | | <select id="getSensorsByDevice" resultType="map"> |
| | | SELECT |
| | | s.`key`, |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?>
|
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
| | | <mapper namespace="com.moral.mapper.HistoryMapper"> |
| | | |
| | | <select id="getDayAQIByDevice" resultType="map"> |
| | | <select id="getDayAQIByDevice" resultType="map"> |
| | | SELECT |
| | | AVG(value -> '$.e1') e1, |
| | | AVG(value -> '$.e2') e2, |
| | |
| | | history |
| | | WHERE |
| | | mac = #{mac} |
| | | AND time > #{start} |
| | | AND time >= #{start} |
| | | AND time < #{end} |
| | | </select> |
| | | </select> |
| | | |
| | | <select id="getAllSensorAverageByDevice" resultType="java.util.LinkedHashMap"> |
| | | SELECT
|
| | |
| | | <if test="orgIds != null and orgIds.size > 0">
|
| | | LEFT JOIN monitor_point_organization mpo ON mpo.monitor_point_id = mp.id
|
| | | AND mpo.organization_id IN
|
| | | <foreach close=")" collection="orgIds" item="listItem" open="(" separator=",">
|
| | | <foreach collection="orgIds" open="(" separator="," close=")" item="listItem">
|
| | | #{listItem}
|
| | | </foreach>
|
| | | </if>
|
| | | WHERE
|
| | | mp.area_code = #{areaCode}
|
| | | AND h.time > #{start} |
| | | AND h.time >= #{start} |
| | | AND h.time < #{end}
|
| | | AND h.mac = d.mac
|
| | | AND d.monitor_point_id = mp.id
|
| | |
| | | monitor_point mp
|
| | | WHERE
|
| | | mp.area_code = #{areaCode}
|
| | | AND h.time > #{start} |
| | | AND h.time >= #{start} |
| | | AND h.time < #{end}
|
| | | <if test="orgIds != null and orgIds.size > 0">
|
| | | AND mp.organization_id IN
|
| | | <foreach collection="orgIds" open="(" separator="," close=")" item="listItem" >
|
| | | <foreach collection="orgIds" open="(" separator="," close=")" item="listItem">
|
| | | #{listItem}
|
| | | </foreach>
|
| | | </if>
|
| | |
| | | ORDER BY
|
| | | time
|
| | | </select>
|
| | | |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?>
|
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
| | | <mapper namespace="com.moral.mapper.MonitorPointMapper" >
|
| | | <select id="getMonitorPointsByAreaName" resultType="com.moral.entity.MonitorPoint">
|
| | | SELECT
|
| | | mp.* |
| | | FROM
|
| | | monitor_point mp,
|
| | | area a |
| | | WHERE
|
| | | mp.area_code = a.area_code |
| | | AND a.area_name = #{areaName}
|
| | | </select>
|
| | | </mapper> |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?>
|
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
| | | <mapper namespace="com.moral.mapper.OrganizationMapper" >
|
| | | <resultMap id="BaseResultMap" type="com.moral.entity.Organization" >
|
| | | <id column="id" property="id" jdbcType="INTEGER" />
|
| | | <result column="name" property="name" jdbcType="VARCHAR" />
|
| | | <result column="rank" property="rank" jdbcType="INTEGER" />
|
| | | <result column="province_code" property="provinceCode" jdbcType="INTEGER" />
|
| | | <result column="city_code" property="cityCode" jdbcType="INTEGER" />
|
| | | <result column="area_code" property="areaCode" jdbcType="INTEGER" />
|
| | | <result column="address" property="address" jdbcType="VARCHAR" />
|
| | | <result column="telephone" property="telephone" jdbcType="VARCHAR" />
|
| | | <result column="email" property="email" jdbcType="VARCHAR" />
|
| | | <result column="is_delete" property="isDelete" jdbcType="CHAR" />
|
| | | <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
|
| | | <result column="expire_time" property="expireTime" jdbcType="TIMESTAMP" />
|
| | | <result column="description" property="description" jdbcType="VARCHAR" />
|
| | | </resultMap>
|
| | |
|
| | | <?xml version="1.0" encoding="UTF-8"?>
|
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
| | | <mapper namespace="com.moral.mapper.OrganizationMapper"> |
| | | <select id="getOrganizationsByAreaName" resultType="com.moral.entity.Organization"> |
| | | SELECT |
| | | o.* |
| | | FROM |
| | | organization o, |
| | | area a |
| | | WHERE |
| | | o.area_code = a.area_code |
| | | AND a.area_name = #{areaName} |
| | | </select> |
| | | </mapper> |