更新完善了部分模块
This commit is contained in:
parent
3ef744a46f
commit
6d4416a510
@ -7,6 +7,8 @@ import com.ruoyi.project.hit.service.PupuEquipmentService;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/hit/equipment")
|
@RequestMapping("/hit/equipment")
|
||||||
public class PupuEquipmentController extends BaseController {
|
public class PupuEquipmentController extends BaseController {
|
||||||
@ -23,4 +25,10 @@ public class PupuEquipmentController extends BaseController {
|
|||||||
return toAjax(pupuEquipmentService.del(equipmentId));
|
return toAjax(pupuEquipmentService.del(equipmentId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/selectByStoreId/{storeId}")
|
||||||
|
public AjaxResult selectByStoreId(@PathVariable(value = "storeId") Integer storeId){
|
||||||
|
List<PupuEquipment> pupuEquipments = pupuEquipmentService.selectByStoreId(storeId);
|
||||||
|
return AjaxResult.success(pupuEquipments);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.ruoyi.project.hit.controller;
|
|||||||
|
|
||||||
import com.ruoyi.framework.web.controller.BaseController;
|
import com.ruoyi.framework.web.controller.BaseController;
|
||||||
import com.ruoyi.framework.web.domain.AjaxResult;
|
import com.ruoyi.framework.web.domain.AjaxResult;
|
||||||
|
import com.ruoyi.framework.web.page.TableDataInfo;
|
||||||
import com.ruoyi.project.hit.domain.PupuStore;
|
import com.ruoyi.project.hit.domain.PupuStore;
|
||||||
import com.ruoyi.project.hit.service.PupuStoreService;
|
import com.ruoyi.project.hit.service.PupuStoreService;
|
||||||
import com.ruoyi.project.hit.service.PupuUserService;
|
import com.ruoyi.project.hit.service.PupuUserService;
|
||||||
@ -9,6 +10,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/hit/store")
|
@RequestMapping("/hit/store")
|
||||||
public class PupuStoreController extends BaseController {
|
public class PupuStoreController extends BaseController {
|
||||||
@ -33,6 +37,17 @@ public class PupuStoreController extends BaseController {
|
|||||||
@DeleteMapping("/del/{storeId}")
|
@DeleteMapping("/del/{storeId}")
|
||||||
public AjaxResult del(@PathVariable(value = "storeId")Integer storeId){
|
public AjaxResult del(@PathVariable(value = "storeId")Integer storeId){
|
||||||
return toAjax(pupuStoreService.del(storeId));
|
return toAjax(pupuStoreService.del(storeId));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部门店信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/select")
|
||||||
|
public TableDataInfo select(){
|
||||||
|
List<Map<String,Object>> select = pupuStoreService.select();
|
||||||
|
return getDataTable(select);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -71,5 +71,17 @@ public class PupuUpsHistoryController extends BaseController {
|
|||||||
return getDataTable(select);
|
return getDataTable(select);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查看当前设备最新历史记录
|
||||||
|
* @param upsId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/selectLatestHistory/{upsId}")
|
||||||
|
public AjaxResult selectLatestHistory(@PathVariable(value = "upsId")Integer upsId){
|
||||||
|
return AjaxResult.success(pupuUpsHistoryService.selectLatestHistory(upsId));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,15 @@ import com.ruoyi.framework.web.domain.AjaxResult;
|
|||||||
import com.ruoyi.project.hit.domain.PupuUser;
|
import com.ruoyi.project.hit.domain.PupuUser;
|
||||||
import com.ruoyi.project.hit.domain.vo.UserLoginVO;
|
import com.ruoyi.project.hit.domain.vo.UserLoginVO;
|
||||||
import com.ruoyi.project.hit.service.PupuUserService;
|
import com.ruoyi.project.hit.service.PupuUserService;
|
||||||
|
import com.ruoyi.project.hit.util.JwtUtil;
|
||||||
import com.ruoyi.project.hit.util.webSocket.WsServerEndpoint;
|
import com.ruoyi.project.hit.util.webSocket.WsServerEndpoint;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/hit/user")
|
@RequestMapping("/hit/user")
|
||||||
@ -19,12 +22,16 @@ public class PupuUserController extends BaseController {
|
|||||||
private PupuUserService pupuUserService;
|
private PupuUserService pupuUserService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private WsServerEndpoint wsServerEndpoint;
|
private RedisTemplate redisTemplate;
|
||||||
|
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
public AjaxResult login(@RequestBody UserLoginVO userLoginVO){
|
public AjaxResult login(@RequestBody UserLoginVO userLoginVO){
|
||||||
PupuUser loginer = pupuUserService.login(userLoginVO);
|
PupuUser loginer = pupuUserService.login(userLoginVO);
|
||||||
if(loginer!=null){
|
if(loginer!=null){
|
||||||
return AjaxResult.success(loginer);
|
String token = JwtUtil.generateToken(userLoginVO.getUserName());
|
||||||
|
System.out.println("token:"+token);
|
||||||
|
redisTemplate.opsForValue().set(token,loginer,60, TimeUnit.MILLISECONDS);
|
||||||
|
return AjaxResult.success(token);
|
||||||
}else {
|
}else {
|
||||||
return AjaxResult.error("账号或密码错误");
|
return AjaxResult.error("账号或密码错误");
|
||||||
}
|
}
|
||||||
@ -33,9 +40,5 @@ public class PupuUserController extends BaseController {
|
|||||||
public AjaxResult register(@Validated @RequestBody PupuUser pupuUser){
|
public AjaxResult register(@Validated @RequestBody PupuUser pupuUser){
|
||||||
return toAjax(pupuUserService.register(pupuUser));
|
return toAjax(pupuUserService.register(pupuUser));
|
||||||
}
|
}
|
||||||
@GetMapping("/aa")
|
|
||||||
public void aa() throws Exception {
|
|
||||||
wsServerEndpoint.sendAllUser("67");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,15 @@ public class PupuStore implements Serializable {
|
|||||||
@NotBlank(message = "纬度不能为空")
|
@NotBlank(message = "纬度不能为空")
|
||||||
private String latitude;
|
private String latitude;
|
||||||
|
|
||||||
|
@NotBlank(message = "省不能为空")
|
||||||
|
private String province;
|
||||||
|
|
||||||
|
@NotBlank(message = "市不能为空")
|
||||||
|
private String city;
|
||||||
|
|
||||||
|
@NotBlank(message = "县/区不能为空")
|
||||||
|
private String district;
|
||||||
|
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
package com.ruoyi.project.hit.domain.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
@ -16,6 +16,8 @@ import java.util.List;
|
|||||||
public interface PupuUpsHistoryMapper extends BaseMapper<PupuUpsHistory> {
|
public interface PupuUpsHistoryMapper extends BaseMapper<PupuUpsHistory> {
|
||||||
|
|
||||||
List<HashMap> select(UpsHistoryVO upsHistoryVO);
|
List<HashMap> select(UpsHistoryVO upsHistoryVO);
|
||||||
|
|
||||||
|
List<HashMap> selectLatestHistory(Integer upsId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ package com.ruoyi.project.hit.service;
|
|||||||
import com.ruoyi.project.hit.domain.PupuEquipment;
|
import com.ruoyi.project.hit.domain.PupuEquipment;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author HP
|
* @author HP
|
||||||
* @description 针对表【pupu_equipment】的数据库操作Service
|
* @description 针对表【pupu_equipment】的数据库操作Service
|
||||||
@ -13,4 +15,6 @@ public interface PupuEquipmentService extends IService<PupuEquipment> {
|
|||||||
int add(PupuEquipment pupuEquipment);
|
int add(PupuEquipment pupuEquipment);
|
||||||
|
|
||||||
int del(Integer equipmentId);
|
int del(Integer equipmentId);
|
||||||
|
|
||||||
|
List<PupuEquipment> selectByStoreId(Integer storeId);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,9 @@ package com.ruoyi.project.hit.service;
|
|||||||
import com.ruoyi.project.hit.domain.PupuStore;
|
import com.ruoyi.project.hit.domain.PupuStore;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author HP
|
* @author HP
|
||||||
* @description 针对表【pupu_store】的数据库操作Service
|
* @description 针对表【pupu_store】的数据库操作Service
|
||||||
@ -13,4 +16,6 @@ public interface PupuStoreService extends IService<PupuStore> {
|
|||||||
int add(PupuStore pupuStore);
|
int add(PupuStore pupuStore);
|
||||||
|
|
||||||
int del(Integer storeId);
|
int del(Integer storeId);
|
||||||
|
|
||||||
|
List<Map<String, Object>> select();
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import com.ruoyi.project.hit.domain.vo.UpsHistoryVO;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author HP
|
* @author HP
|
||||||
@ -15,4 +16,8 @@ import java.util.List;
|
|||||||
public interface PupuUpsHistoryService extends IService<PupuUpsHistory> {
|
public interface PupuUpsHistoryService extends IService<PupuUpsHistory> {
|
||||||
|
|
||||||
List<HashMap> select(UpsHistoryVO upsHistoryVO);
|
List<HashMap> select(UpsHistoryVO upsHistoryVO);
|
||||||
|
|
||||||
|
Map<String, Object> selectLatestHistory(Integer upsId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author HP
|
* @author HP
|
||||||
@ -54,6 +55,13 @@ public class PupuEquipmentServiceImpl extends ServiceImpl<PupuEquipmentMapper, P
|
|||||||
pupuLogService.add(new PupuLog("设备删除",2,new Date()));
|
pupuLogService.add(new PupuLog("设备删除",2,new Date()));
|
||||||
return pupuEquipmentMapper.deleteById(equipmentId);
|
return pupuEquipmentMapper.deleteById(equipmentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PupuEquipment> selectByStoreId(Integer storeId) {
|
||||||
|
LambdaQueryWrapper<PupuEquipment> wrapper=new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(PupuEquipment::getStoreId,storeId);
|
||||||
|
return pupuEquipmentMapper.selectList(wrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.ruoyi.project.hit.service.impl;
|
package com.ruoyi.project.hit.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.ruoyi.project.hit.domain.PupuLog;
|
import com.ruoyi.project.hit.domain.PupuLog;
|
||||||
import com.ruoyi.project.hit.domain.PupuStore;
|
import com.ruoyi.project.hit.domain.PupuStore;
|
||||||
@ -9,7 +10,7 @@ import com.ruoyi.project.hit.mapper.PupuStoreMapper;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Date;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author HP
|
* @author HP
|
||||||
@ -36,6 +37,29 @@ public class PupuStoreServiceImpl extends ServiceImpl<PupuStoreMapper, PupuStore
|
|||||||
pupuLogService.add(new PupuLog("门店删除",2,new Date()));
|
pupuLogService.add(new PupuLog("门店删除",2,new Date()));
|
||||||
return pupuStoreMapper.deleteById(storeId);
|
return pupuStoreMapper.deleteById(storeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> select() {
|
||||||
|
LambdaQueryWrapper<PupuStore> wrapper=new LambdaQueryWrapper<>();
|
||||||
|
List<PupuStore> pupuStores = pupuStoreMapper.selectList(wrapper);
|
||||||
|
|
||||||
|
List<Map<String,Object>> list=new ArrayList<>();
|
||||||
|
for (PupuStore pupuStore : pupuStores) {
|
||||||
|
Map<String,Object> map=new HashMap<>();
|
||||||
|
map.put("storeId",pupuStore.getStoreId());
|
||||||
|
String[] arr={pupuStore.getLongitude(),pupuStore.getLatitude()};
|
||||||
|
map.put("lnglat",arr);
|
||||||
|
map.put("province",pupuStore.getProvince());
|
||||||
|
map.put("city",pupuStore.getCity());
|
||||||
|
map.put("district",pupuStore.getDistrict());
|
||||||
|
map.put("name",pupuStore.getStoreName());
|
||||||
|
map.put("state",pupuStore.getStatus());
|
||||||
|
list.add(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author HP
|
* @author HP
|
||||||
@ -25,6 +26,16 @@ public class PupuUpsHistoryServiceImpl extends ServiceImpl<PupuUpsHistoryMapper,
|
|||||||
public List<HashMap> select(UpsHistoryVO upsHistoryVO) {
|
public List<HashMap> select(UpsHistoryVO upsHistoryVO) {
|
||||||
return pupuUpsHistoryMapper.select(upsHistoryVO);
|
return pupuUpsHistoryMapper.select(upsHistoryVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> selectLatestHistory(Integer upsId) {
|
||||||
|
List<HashMap> list = pupuUpsHistoryMapper.selectLatestHistory(upsId);
|
||||||
|
Map<String,Object> objectMap=new HashMap<>();
|
||||||
|
for (HashMap map : list) {
|
||||||
|
objectMap.put((String) map.get("identifier"),map.get("value"));
|
||||||
|
}
|
||||||
|
return objectMap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
41
src/main/java/com/ruoyi/project/hit/util/JwtUtil.java
Normal file
41
src/main/java/com/ruoyi/project/hit/util/JwtUtil.java
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package com.ruoyi.project.hit.util;
|
||||||
|
import io.jsonwebtoken.Claims;
|
||||||
|
import io.jsonwebtoken.Jwts;
|
||||||
|
import io.jsonwebtoken.SignatureAlgorithm;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class JwtUtil {
|
||||||
|
|
||||||
|
private static final String SECRET_KEY = "your_secret_key"; // 用于签名的密钥
|
||||||
|
|
||||||
|
// 生成JWT
|
||||||
|
public static String generateToken(String username) {
|
||||||
|
Date now = new Date();
|
||||||
|
Date expiryDate = new Date(now.getTime() + 1000 * 60 * 60 * 1); // 有效期1小时
|
||||||
|
|
||||||
|
return Jwts.builder()
|
||||||
|
.setSubject(username)
|
||||||
|
.setIssuedAt(now)
|
||||||
|
.setExpiration(expiryDate)
|
||||||
|
.signWith(SignatureAlgorithm.HS512, SECRET_KEY)
|
||||||
|
.compact();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 解析JWT
|
||||||
|
public static Claims parseToken(String token) {
|
||||||
|
return Jwts.parser()
|
||||||
|
.setSigningKey(SECRET_KEY)
|
||||||
|
.parseClaimsJws(token)
|
||||||
|
.getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证JWT
|
||||||
|
public static boolean isTokenValid(String token) {
|
||||||
|
try {
|
||||||
|
Jwts.parser().setSigningKey(SECRET_KEY).parseClaimsJws(token);
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,35 +0,0 @@
|
|||||||
package com.ruoyi.project.hit.util;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.data.redis.connection.RedisConnection;
|
|
||||||
import org.springframework.data.redis.core.Cursor;
|
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
|
||||||
import org.springframework.data.redis.core.ScanOptions;
|
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class ScheduledTasks {
|
|
||||||
|
|
||||||
// 定时任务,每30秒执行一次
|
|
||||||
// @Scheduled(fixedRate = 3000)
|
|
||||||
public void reportCurrentTime1() {
|
|
||||||
System.out.println(11);
|
|
||||||
long l = System.currentTimeMillis();
|
|
||||||
Map<Integer, Long> upsMap = Util1.upsMap;
|
|
||||||
for (Map.Entry<Integer, Long> entry : upsMap.entrySet()) {
|
|
||||||
if(l-entry.getValue()>=30000){
|
|
||||||
System.out.println(entry.getKey());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,43 @@
|
|||||||
|
package com.ruoyi.project.hit.util.interceptor;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class HitInterceptor implements HandlerInterceptor {
|
||||||
|
@Autowired
|
||||||
|
private RedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||||
|
String token = request.getHeader("Authorization");
|
||||||
|
System.out.println("token:" +token);
|
||||||
|
String path = request.getRequestURI();
|
||||||
|
if (path.startsWith("/hit") && !"/hit/user/register".equals(path) && !"/hit/user/login".equals(path) && token != null) {
|
||||||
|
// 拦截除了/hit/user之外的所有/hit开头的请求
|
||||||
|
// 这里可以添加你的处理逻辑,比如重定向、返回错误信息等
|
||||||
|
if(redisTemplate.hasKey(token)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false; // 返回false表示拦截器链中断,不再继续执行后续的Controller
|
||||||
|
}
|
||||||
|
// 放行/hit/user请求
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
|
||||||
|
// 可以在这里处理请求处理之后、视图渲染之前的逻辑
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
||||||
|
// 可以在这里处理视图渲染之后的逻辑
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.ruoyi.project.hit.util.interceptor;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class WebConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
|
/*@Autowired
|
||||||
|
private HitInterceptor hitInterceptor;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
registry.addInterceptor(hitInterceptor)
|
||||||
|
.addPathPatterns("/hit/**") // 拦截所有/hit开头的请求
|
||||||
|
.excludePathPatterns("/hit/user/register")
|
||||||
|
.excludePathPatterns("/hit/user/login"); // 但不拦截/hit/user
|
||||||
|
}*/
|
||||||
|
}
|
@ -8,7 +8,10 @@
|
|||||||
<id property="storeId" column="store_id" jdbcType="INTEGER"/>
|
<id property="storeId" column="store_id" jdbcType="INTEGER"/>
|
||||||
<result property="storeName" column="store_name" jdbcType="VARCHAR"/>
|
<result property="storeName" column="store_name" jdbcType="VARCHAR"/>
|
||||||
<result property="longitude" column="longitude" jdbcType="VARCHAR"/>
|
<result property="longitude" column="longitude" jdbcType="VARCHAR"/>
|
||||||
<result property="latitude" column="dimensionality" jdbcType="VARCHAR"/>
|
<result property="latitude" column="latitude" jdbcType="VARCHAR"/>
|
||||||
|
<result property="province" column="province" jdbcType="VARCHAR"/>
|
||||||
|
<result property="city" column="city" jdbcType="VARCHAR"/>
|
||||||
|
<result property="district" column="district" jdbcType="VARCHAR"/>
|
||||||
<result property="status" column="status" jdbcType="INTEGER"/>
|
<result property="status" column="status" jdbcType="INTEGER"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
@ -54,4 +54,30 @@
|
|||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectLatestHistory" resultType="java.util.HashMap">
|
||||||
|
SELECT
|
||||||
|
ph.identifier,
|
||||||
|
ph.time,
|
||||||
|
ph.value,
|
||||||
|
ph.data_type,
|
||||||
|
ph.name,
|
||||||
|
ph.access_mode
|
||||||
|
FROM
|
||||||
|
pupu_ups_history ph
|
||||||
|
INNER JOIN (
|
||||||
|
SELECT
|
||||||
|
identifier,
|
||||||
|
MAX(time) AS max_time
|
||||||
|
FROM
|
||||||
|
pupu_ups_history
|
||||||
|
WHERE
|
||||||
|
ups_id = #{upsId}
|
||||||
|
GROUP BY
|
||||||
|
identifier
|
||||||
|
) latest_records ON ph.identifier = latest_records.identifier AND ph.time = latest_records.max_time
|
||||||
|
WHERE
|
||||||
|
ph.ups_id = #{upsId};
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
Loading…
Reference in New Issue
Block a user