初始化

master
Lu-aiLiang 2023-12-04 14:48:13 +08:00
parent 2716e42716
commit fb31cec0f5
27 changed files with 982 additions and 269 deletions

View File

@ -0,0 +1,26 @@
package com.fivegroup.fence.aop;
/**
* @program: cloud-server
* @description:
* @author: Mr.Wang
* @create: 2023-11-24 21:59
**/
import java.lang.annotation.*;
/**
*
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
@Documented
public @interface WebLog {
/**
*
* @return String
**/
String description() default "";
}

View File

@ -0,0 +1,122 @@
package com.fivegroup.fence.aop;
/**
* @program: cloud-server
* @description:
* @author: Mr.Wang
* @create: 2023-11-24 22:00
**/
import com.alibaba.nacos.shaded.com.google.gson.Gson;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
/**
*
*/
/**
* Servlet
*/
@Aspect
@Component
public class WebLogAspect {
private final static Logger logger=LoggerFactory.getLogger(WebLogAspect.class);
private static final Gson gson=new Gson();
private static final String LINE_SEPARATOR=System.lineSeparator();
/**
* @WebLog
*/
@Pointcut("@annotation(com.fivegroup.fence.aop.WebLog)")
public void webLog() {}
/**
*
*
* @param joinPoint
*/
@Before("webLog()")
public void doBefore(JoinPoint joinPoint) {
// 开始打印请求日志
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
if (attributes != null) {
HttpServletRequest request = attributes.getRequest();
// 获取 @WebLog 注解的描述信息
String methodDescription;
try {
methodDescription = getAspectLogDescription(joinPoint);
} catch (Exception e) {
methodDescription = "无法获取方法描述信息";
logger.error("获取方法描述信息时发生异常: ", e);
}
// 打印请求相关参数
logger.info("========================================== Start ==========================================");
logger.info("URL : {}", request.getRequestURL().toString());
logger.info("描述信息 : {}", methodDescription);
logger.info("HTTP 方法 : {}", request.getMethod());
logger.info("类方法 : {}.{}", joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName());
logger.info("IP : {}", request.getRemoteAddr());
logger.info("请求参数 : {}", gson.toJson(joinPoint.getArgs()));
}
}
/**
*
*/
@After("webLog()")
public void doAfter() {
logger.info("=========================================== End ==========================================={}", LINE_SEPARATOR);
}
/**
*
*
* @param proceedingJoinPoint
* @throws Throwable
*/
@Around("webLog()")
public Object doAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
long startTime = System.currentTimeMillis();
Object result = proceedingJoinPoint.proceed();
logger.info("响应参数 : {}", gson.toJson(result));
logger.info("时间消耗 : {} ms", System.currentTimeMillis() - startTime);
return result;
}
/**
*
*
* @param joinPoint
* @return
* @throws ClassNotFoundException
*/
private String getAspectLogDescription(JoinPoint joinPoint) throws ClassNotFoundException {
String targetName = joinPoint.getTarget().getClass().getName();
String methodName = joinPoint.getSignature().getName();
Object[] arguments = joinPoint.getArgs();
Class<?> targetClass = Class.forName(targetName);
Method[] methods = targetClass.getMethods();
for (Method method : methods) {
if (method.getName().equals(methodName) && method.getParameterTypes().length == arguments.length) {
WebLog webLog = method.getAnnotation(WebLog.class);
if (webLog != null) {
return webLog.description();
}
}
}
return "";
}
}

View File

@ -0,0 +1,109 @@
package com.fivegroup.fence.controller;
import com.alibaba.fastjson.JSONObject;
import com.fivegroup.common.core.domain.Result;
import com.fivegroup.fence.aop.WebLog;
import com.fivegroup.fence.domain.Wall;
import com.fivegroup.fence.domain.WallTag;
import com.fivegroup.fence.domain.req.AddWall;
import com.fivegroup.fence.service.WallService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* @author LuHaoXiang
* @version 23.11.30 - 20:24
*/
@RestController
@ResponseBody
@RequestMapping("/wall")
@Log4j2
public class WallController {
@Autowired
private WallService wallService;
@Autowired
private HttpServletRequest request;
;
/**
* :
*
* @param
* @return
*/
@GetMapping("/list")
@WebLog(description = "请求了查询所有电子围栏请求")
public Result<List<Wall>> list() {
Result<List<Wall>> result = wallService.list();
return Result.success(result.getData());
}
/**
* :
*
* @param addWall
* @return
*/
@PostMapping("/insert")
@WebLog(description = "请求了添加电子围栏请求")
public Result<String> insert(@RequestBody AddWall addWall) {
Result<String> result = wallService.insert(addWall);
return Result.success();
}
@PostMapping("/delete/{id}")
@WebLog(description = "删除电子围栏")
public Result<String> delete(@PathVariable Integer id) {
Result<String> result = wallService.delete(id);
return Result.success();
}
@PostMapping("/allWallTag")
@WebLog(description = "获取所有电子围栏标签")
public Result<List<WallTag>> allWallTag() {
Result<List<WallTag>> result = wallService.allWallTag();
return result;
}
/**
* : XXX
*
* @param id
* @return
*/
@PostMapping("/findTagId/{id}")
@WebLog(description = "获取对应标签下的电子围栏")
public Result<List<Wall>> findTagId(@PathVariable Integer id) {
Result<List<Wall>> result = wallService.findTagId(id);
return result;
}
/**
* : vi
* @param vin
* @return
* */
@PostMapping("/inWall/{vin}")
@WebLog(description = "根据车的vin找到绑定的电子围栏")
public Result<List<Wall>> inWall(@PathVariable String vin){
Result<List<Wall>> result = wallService.inWall(vin);
return result;
}
@PostMapping("/inRedis/{vin}")
@WebLog(description = "根据 车的vin 存入redis")
public Result<String> inRedis(@PathVariable String vin){
log.info("功能XXX请求URI【{}】,请求方式:【{}】,请求参数:【{}】",
request.getRequestURI(), request.getMethod(), vin);
Result<String> result = wallService.inRedis(vin);
log.info("功能XXX请求URI【{}】,请求方式:【{}】,响应结果:【{}】",
request.getRequestURI(), request.getMethod(), JSONObject.toJSONString(result));
return result;
}
}

View File

@ -2,9 +2,9 @@ package com.fivegroup.fence.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.fivegroup.common.core.domain.Result; import com.fivegroup.common.core.domain.Result;
import com.fivegroup.fence.domain.Fence; import com.fivegroup.fence.aop.WebLog;
import com.fivegroup.fence.domain.in.FenceIn; import com.fivegroup.fence.domain.WallTag;
import com.fivegroup.fence.service.FenceService; import com.fivegroup.fence.service.WallTagService;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
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.*;
@ -14,63 +14,72 @@ import java.util.List;
/** /**
* @author LuHaoXiang * @author LuHaoXiang
* @version 23.11.29 - 18:32 * @version 23.12.1 - 21:47
*/ */
@RestController @RestController
@RequestMapping("/fence") @ResponseBody
@RequestMapping("/walltag")
@Log4j2 @Log4j2
public class FenceController { public class WallTagController {
@Autowired @Autowired
private FenceService fenceService; private WallTagService wallTagService;
@Autowired @Autowired
private HttpServletRequest request; private HttpServletRequest request;
@PostMapping("/allFence")
public Result<List<Fence>> allFence() {
log.info("功能XXX请求URI【{}】,请求方式:【{}】,请求参数:【{}】",
request.getRequestURI(), request.getMethod(), JSONObject.toJSONString(null));
Result<List<Fence>> result = fenceService.allFence();
log.info("功能XXX请求URI【{}】,请求方式:【{}】,响应结果:【{}】",
request.getRequestURI(), request.getMethod(), JSONObject.toJSONString(result));
return result;
}
/** /**
* : XXX * :
* *
* @param fenceIn * @param
* @return * @return
*/ */
@PostMapping("/addFence") @PostMapping("/list")
public Result<String> addFence(@RequestBody FenceIn fenceIn) { @WebLog(description = "下拉空- 全部的电子围栏标签")
log.info("功能XXX请求URI【{}】,请求方式:【{}】,请求参数:【{}】", public Result<List<WallTag>> list() {
request.getRequestURI(), request.getMethod(), JSONObject.toJSONString(fenceIn)); Result<List<WallTag>> result = wallTagService.list();
Result<String> result = fenceService.addFence(fenceIn);
log.info("功能XXX请求URI【{}】,请求方式:【{}】,响应结果:【{}】",
request.getRequestURI(), request.getMethod(), JSONObject.toJSONString(result));
return result; return result;
} }
/** /**
* : XXX * : XXX
* @param fence * @param wallTag
* @return * @return
* */ * */
@PostMapping("/updFence") @PostMapping("/addwalltag")
public Result<String> updFence(@RequestBody Fence fence){ @WebLog(description = "添加 - 电子围栏标签")
public Result<String> addWallTag(@RequestBody WallTag wallTag){
Result<String> result = wallTagService.addWallTag(wallTag);
return result;
}
@PostMapping("/updwalltag")
@WebLog(description = "修改 - 电子围栏标签")
public Result<String> updwalltag(@RequestBody WallTag wallTag){
log.info("功能XXX请求URI【{}】,请求方式:【{}】,请求参数:【{}】", log.info("功能XXX请求URI【{}】,请求方式:【{}】,请求参数:【{}】",
request.getRequestURI(), request.getMethod(), JSONObject.toJSONString(fence)); request.getRequestURI(), request.getMethod(), JSONObject.toJSONString(wallTag));
Result<String> result = fenceService.updFence(fence); Result<String> result = wallTagService.updwalltag(wallTag);
log.info("功能XXX请求URI【{}】,请求方式:【{}】,响应结果:【{}】", log.info("功能XXX请求URI【{}】,请求方式:【{}】,响应结果:【{}】",
request.getRequestURI(), request.getMethod(), JSONObject.toJSONString(result)); request.getRequestURI(), request.getMethod(), JSONObject.toJSONString(result));
return result; return result;
} }
@PostMapping("/delFence/{id}") @PostMapping("/delwalltag/{id}")
public Result<String> delFence(@PathVariable String id){ @WebLog(description = "删除 - 电子围栏标签")
public Result<String> delwalltag(@PathVariable Integer id){
log.info("功能XXX请求URI【{}】,请求方式:【{}】,请求参数:【{}】", log.info("功能XXX请求URI【{}】,请求方式:【{}】,请求参数:【{}】",
request.getRequestURI(), request.getMethod(), JSONObject.toJSONString(id)); request.getRequestURI(), request.getMethod(), id);
Result<String> result = fenceService.delFence(id); Result<String> result = wallTagService.delwalltag(id);
log.info("功能XXX请求URI【{}】,请求方式:【{}】,响应结果:【{}】",
request.getRequestURI(), request.getMethod(), JSONObject.toJSONString(result));
return result;
}
@PostMapping("/inWall/{vin}")
@WebLog(description = "判断-- 车与电子围栏的关系")
public Result<String> inWall(@PathVariable String vin){
log.info("功能XXX请求URI【{}】,请求方式:【{}】,请求参数:【{}】",
request.getRequestURI(), request.getMethod(), JSONObject.toJSONString(vin));
Result<String> result = wallTagService.inWall(vin);
log.info("功能XXX请求URI【{}】,请求方式:【{}】,响应结果:【{}】", log.info("功能XXX请求URI【{}】,请求方式:【{}】,响应结果:【{}】",
request.getRequestURI(), request.getMethod(), JSONObject.toJSONString(result)); request.getRequestURI(), request.getMethod(), JSONObject.toJSONString(result));
return result; return result;

View File

@ -0,0 +1,116 @@
package com.fivegroup.fence.domain;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
*
* @author LuHaoXiang
* @version 23.12.2 - 20:18
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Car {
/**
* id
* */
private Integer cerId;
/**
* vin
* */
private String vin;
/**
*
* */
private double lng;
/**
*
* */
private double lat;
/**
*
* */
private String speed;
/**
*
* */
private String mileage;
/**
*
* */
private String voltage;
/**
*
* */
private String current;
/**
*
* */
private String resistance;
/**
*
* */
private String grade;
/**
*
* */
private String accelerate;
/**
*
* */
private String brake;
/**
*
* */
private String fuelConsumption;
/***
*
*/
private String motorSpeed;
/***
*
*/
private String motorTorque;
/**
*
* */
private String motorTemperature;
/**
*
* */
private String motorCurrent;
/***
*
*/
private String batteryVoltage;
/**
*
* */
private String maxPower;
/**
*
* */
private String minTemperature;
/**
*
* */
private String status;
/**
*
* */
private String chargeStatus;
/**
*
* */
}

View File

@ -1,43 +0,0 @@
package com.fivegroup.fence.domain;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
/**
* @author LuHaoXiang
* @version 23.11.29 - 18:37
*/
@Data
@Builder
@AllArgsConstructor
public class Fence {
/**
* id
* */
@NotEmpty(message = "不能空")
private Integer fenceId;
/**
*
* */
@NotEmpty(message = "不能空")
private String fenceName;
/**
*
* */
@NotEmpty(message = "不能空")
private String lals;
/**
*
* */
@NotEmpty(message = "不能空")
private Integer act;
/**
*
* */
@NotEmpty(message = "不能空")
private Integer start;
}

View File

@ -1,20 +0,0 @@
package com.fivegroup.fence.domain;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author LuHaoXiang
* @version 23.11.29 - 19:38
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class FenceTag {
private Integer fenceTapId;
private String fenceTapName;
}

View File

@ -0,0 +1,22 @@
package com.fivegroup.fence.domain;
import lombok.Data;
import lombok.ToString;
/**
*
* @author LuHaoXiang
* @version 23.11.30 - 20:15
*/
@Data
@ToString
public class Point {
private double lng;
private double lat;
public Point(double lng, double lat) {
this.lng = lng;
this.lat = lat;
}
}

View File

@ -0,0 +1,61 @@
package com.fivegroup.fence.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
*
* @author LuHaoXiang
* @version 23.11.30 - 20:06
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("wall")
public class Wall {
@TableId(type = IdType.AUTO)
private Integer wallId;
/**
*
*/
private String wallName;
/**
*
*/
private String wallData;
/**s
*
*/
private Integer status;
/**
*
*/
private Integer alarmType;
/**
* id
*/
private Integer wallTagId;
// /**
// * 字段属性:创建人
// */
// private String createdBy;
// /**
// * 字段属性:创建时间
// */
// private Date createdTime;
// /**
// * 字段属性:更新人
// */
// private String updatedBy;
// /**
// * 字段属性:更新时间
// */
// private Date updatedTime;
}

View File

@ -0,0 +1,29 @@
package com.fivegroup.fence.domain;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
*
* @author LuHaoXiang
* @version 23.11.30 - 20:07
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("wall_tag")
public class WallTag {
/**
*
* */
private String wallTagId;
/**
*
* */
private String wallTagName;
}

View File

@ -1,34 +0,0 @@
package com.fivegroup.fence.domain.in;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
/**
* @author LuHaoXiang
* @version 23.11.29 - 19:06
*/
@Data
public class FenceIn {
/**
*
* */
@NotEmpty(message = "不能空")
private String fenceName;
/**
*
* */
@NotEmpty(message = "不能空")
private String lals;
/**
*
* */
@NotEmpty(message = "不能空")
private Integer act;
/**
*
* */
@NotEmpty(message = "不能空")
private Integer start = 1;
}

View File

@ -0,0 +1,28 @@
package com.fivegroup.fence.domain.out;
import lombok.Data;
/**
* @author LuHaoXiang
* @version 23.12.1 - 23:54
*/
@Data
public class CarTag {
/**
* id
* */
private String vin;
/**
*
* */
private String lals;
/**
*
* */
private String lng;
/**
*
* */
private String lag;
}

View File

@ -0,0 +1,23 @@
package com.fivegroup.fence.domain.req;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
*
* @author LuHaoXiang
* @version 23.11.30 - 20:10
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AddWall {
private Integer wallId;
private String wallName;
private String wallData;
private Integer status;
private Integer alarmType;
private Integer wallTagId;
}

View File

@ -0,0 +1,25 @@
package com.fivegroup.fence.domain.req;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author LuHaoXiang
* @version 23.12.1 - 23:48
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class AddWallTag {
/**
* id
* */
private Integer wallTagId;
/**
*
* */
private String wallTagName;
}

View File

@ -1,23 +0,0 @@
package com.fivegroup.fence.mapper;
import com.fivegroup.fence.domain.Fence;
import com.fivegroup.fence.domain.in.FenceIn;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author LuHaoXiang
* @version 23.11.29 - 18:33
*/
@Mapper
public interface FenceMapper {
List<Fence> allFence();
int addFence(FenceIn fenceIn);
int updFence(Fence fence);
int delFence(@Param("id") String id);
}

View File

@ -0,0 +1,32 @@
package com.fivegroup.fence.mapper;
import com.fivegroup.common.core.domain.Result;
import com.fivegroup.fence.domain.Wall;
import com.fivegroup.fence.domain.WallTag;
import com.fivegroup.fence.domain.req.AddWall;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author LuHaoXiang
* @version 23.11.30 - 20:26
*/
@Mapper
public interface WallMapper {
List<Wall> list();
int insert(AddWall addWall);
int delete(@Param("id") Integer id);
List<WallTag> allWallTag();
Result<List<Wall>> findTagId(@Param("id") Integer id);
List<Wall> carWall(String vin);
List<Wall> findVinWall(@Param("vin") String vin);
}

View File

@ -0,0 +1,27 @@
package com.fivegroup.fence.mapper;
import com.fivegroup.fence.domain.WallTag;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author LuHaoXiang
* @version 23.12.1 - 21:49
*/
@Mapper
public interface WallTagMapper {
// 所有的电子围栏标签
List<WallTag> list();
//新增电子围栏
int addWallTag(WallTag wallTag);
// 修改电子围栏
int updwalltag(WallTag wallTag);
//删除电子围栏
int delwalltag(@Param("id") Integer id);
// 查询车辆绑定的电子围栏标签
List<WallTag> inWall(@Param("vin") String vin);
}

View File

@ -1,22 +0,0 @@
package com.fivegroup.fence.service;
import com.fivegroup.common.core.domain.Result;
import com.fivegroup.fence.domain.Fence;
import com.fivegroup.fence.domain.in.FenceIn;
import java.util.List;
/**
* @author LuHaoXiang
* @version 23.11.29 - 18:33
*/
public interface FenceService {
Result<List<Fence>> allFence();
Result<String> addFence(FenceIn fenceIn);
Result<String> updFence(Fence fence);
Result<String> delFence(String id);
}

View File

@ -0,0 +1,31 @@
package com.fivegroup.fence.service;
import com.fivegroup.common.core.domain.Result;
import com.fivegroup.fence.domain.Wall;
import com.fivegroup.fence.domain.WallTag;
import com.fivegroup.fence.domain.req.AddWall;
import java.util.List;
/**
* @author LuHaoXiang
* @version 23.11.30 - 20:25
*/
public interface WallService {
Result<List<Wall>> list();
Result<String> insert(AddWall addWall);
Result<String> delete(Integer id);
Result<List<WallTag>> allWallTag();
Result<List<Wall>> findTagId(Integer id);
Result<List<Wall>> inWall(String vin);
Result<String> inRedis(String vin);
}

View File

@ -0,0 +1,23 @@
package com.fivegroup.fence.service;
import com.fivegroup.common.core.domain.Result;
import com.fivegroup.fence.domain.WallTag;
import java.util.List;
/**
* @author LuHaoXiang
* @version 23.12.1 - 21:48
*/
public interface WallTagService {
Result<List<WallTag>> list();
Result<String> addWallTag(WallTag wallTag);
Result<String> updwalltag(WallTag wallTag);
Result<String> delwalltag(Integer id);
Result<String> inWall(String vin);
}

View File

@ -1,64 +0,0 @@
package com.fivegroup.fence.service.impl;
import com.fivegroup.common.core.domain.Result;
import com.fivegroup.fence.domain.Fence;
import com.fivegroup.fence.domain.in.FenceIn;
import com.fivegroup.fence.mapper.FenceMapper;
import com.fivegroup.fence.service.FenceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author LuHaoXiang
* @version 23.11.29 - 18:33
*/
@Service
public class FenceServiceImpl implements FenceService {
@Autowired
private FenceMapper fenceMapper;
@Override
public Result<List<Fence>> allFence() {
List<Fence> list = fenceMapper.allFence();
return Result.success(list);
}
@Override
public Result<String> addFence(FenceIn fenceIn) {
int i = fenceMapper.addFence(fenceIn);
if (i != 1){
return Result.error();
}
if (i == 1){
return Result.success();
}
return Result.error();
}
@Override
public Result<String> updFence(Fence fence) {
int i = fenceMapper.updFence(fence);
if (i != 1){
return Result.error();
}
if (i == 1){
return Result.success();
}
return Result.error();
}
@Override
public Result<String> delFence(String id) {
int i = fenceMapper.delFence(id);
if (i != 1){
return Result.error();
}
if (i == 1){
return Result.success();
}
return Result.error();
}
}

View File

@ -0,0 +1,110 @@
package com.fivegroup.fence.service.impl;
import com.fivegroup.common.core.domain.Result;
import com.fivegroup.fence.domain.Wall;
import com.fivegroup.fence.domain.WallTag;
import com.fivegroup.fence.domain.req.AddWall;
import com.fivegroup.fence.mapper.WallMapper;
import com.fivegroup.fence.service.WallService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author LuHaoXiang
* @version 23.11.30 - 20:26
*/
@Service
public class WallServiceImpl implements WallService {
@Autowired
private WallMapper wallMapper;
/**
* @return
*/
@Override
public Result<List<Wall>> list() {
List<Wall> list = wallMapper.list();
return Result.success(list);
}
/**
* @param addWall
* @return
*/
@Override
public Result<String> insert(AddWall addWall) {
int i = wallMapper.insert(addWall);
if (i == 1) {
return Result.success("添加成功");
}else {
return Result.error();
}
}
/**
* @param id
* @return
*/
@Override
public Result<String> delete(Integer id) {
int i = wallMapper.delete(id);
if ( i == 1){
return Result.success();
}else {
return Result.error();
}
}
/**
* @return
*/
@Override
public Result<List<WallTag>> allWallTag() {
List<WallTag> list = wallMapper.allWallTag();
if (list.size() == 0) {
return Result.error();
}
return Result.success(list);
}
/**
* @param id
* @return
*/
@Override
public Result<List<Wall>> findTagId(Integer id) {
Result<List<Wall>> result = wallMapper.findTagId(id);
return result;
}
/**
* @param vin
* @return
*/
@Override
public Result<List<Wall>> inWall(String vin) {
//获取车绑定的电子围栏
List<Wall> list = wallMapper.carWall(vin);
if (list.size()== 0) {
return Result.success(null,"该车没有绑定电子围栏");
}
//判断
return Result.success(list);
}
/**
* @param vin
* @return
*/
@Override
public Result<String> inRedis(String vin) {
return null;
}
}

View File

@ -0,0 +1,82 @@
package com.fivegroup.fence.service.impl;
import com.fivegroup.common.core.domain.Result;
import com.fivegroup.fence.domain.WallTag;
import com.fivegroup.fence.mapper.WallTagMapper;
import com.fivegroup.fence.service.WallTagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author LuHaoXiang
* @version 23.12.1 - 21:48
*/
@Service
public class WallTagServiceImpl implements WallTagService {
@Autowired
private WallTagMapper wallTagMapper;
/**
* @return
*/
@Override
public Result<List<WallTag>> list() {
List<WallTag> list = wallTagMapper.list();
return Result.success(list);
}
/**
* @param wallTag
* @return
*/
@Override
public Result<String> addWallTag(WallTag wallTag) {
int i = wallTagMapper.addWallTag(wallTag);
if (i != 1){
return Result.error();
}
return Result.success();
}
/**
* @param wallTag
* @return
*/
@Override
public Result<String> updwalltag(WallTag wallTag) {
int i = wallTagMapper.updwalltag(wallTag);
if(i != 1){
return Result.error();
}
return Result.success();
}
/**
* @param id
* @return
*/
@Override
public Result<String> delwalltag(Integer id) {
int i = wallTagMapper.delwalltag(id);
if (i != 1){
return Result.error();
}
return Result.success();
}
/**
* @param vin
* @return
*/
@Override
public Result<String> inWall(String vin) {
List<WallTag> list = wallTagMapper.inWall(vin);
return null;
}
}

View File

@ -1,27 +0,0 @@
<?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.fivegroup.fence.mapper.FenceMapper">
<insert id="addFence">
INSERT INTO `boss`.`fence` ( `fence_id`, `fence_name`, `lals`, `act`, `start` )
VALUES
( null, #{fenceName}, #{lals}, #{act}, 1 );
</insert>
<update id="updFence">
UPDATE `boss`.`fence`
SET `fence_name` = #{fenceName},
`lals` = #{lals},
`act` = #{lals},
`start` = #{start}
WHERE
`fence_id` = #{fenceId}
</update>
<delete id="delFence">
DELETE FROM `boss`.`fence`
WHERE
`fence_id` = #{fenceId}
</delete>
<select id="allFence" resultType="com.fivegroup.fence.domain.Fence">
SELECT * FROM fence
</select>
</mapper>

View File

@ -0,0 +1,42 @@
<?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.fivegroup.fence.mapper.WallMapper">
<insert id="insert">
INSERT INTO `car`.`t_wall` ( `wall_id`, `wall_name`, `wall_data`, `status`, `alarm_type`, `wall_tag_id` )
VALUES
( #{wallId}, #{wallName}, #{wallData}, 1, #{alarmType}, #{wallTagId} );
</insert>
<delete id="delete">
delete
from t_wall
where wall_id = #{id}
</delete>
<select id="list" resultType="com.fivegroup.fence.domain.Wall">
SELECT * FROM t_wall
</select>
<select id="allWallTag" resultType="com.fivegroup.fence.domain.WallTag">
SELECT * FROM t_wall_tag
</select>
<select id="findTagId" resultType="java.util.List">
SELECT
w.*
FROM
t_wall_and_tag wat
left join t_wall w on wat.wall_id = w.wall_id
where
wat.tag_id = #{id}
</select>
<select id="carWall" resultType="com.fivegroup.fence.domain.Wall">
SELECT
w.*
FROM
t_tag_car tc
LEFT JOIN t_wall_and_tag wat ON tc.tag_id = wat.tag_id
LEFT JOIN t_wall w ON w.wall_id = wat.wall_id
where tc.car_id = #{vin}
</select>
<select id="findVinWall" resultType="com.fivegroup.fence.domain.Wall">
select * from t_tag_wall where car_id = #{vin}
</select>
</mapper>

View File

@ -0,0 +1,29 @@
<?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.fivegroup.fence.mapper.WallTagMapper">
<insert id="addWallTag">
insert into t_wall_tag
(wall_tag_id,wall_tag_name)
values
(null,#{wallTagName})
</insert>
<update id="updwalltag">
update
t_wall_tag
set wall_tag_name = #{wallTagName}
where
wall_tag_id = #{wallTagId}
</update>
<delete id="delwalltag">
delete from t_wall_tag
where
wall_tag_id = #{id}
</delete>
<select id="list" resultType="com.fivegroup.fence.domain.WallTag">
SELECT * FROM t_wall
</select>
<select id="inWall" resultType="com.fivegroup.fence.domain.WallTag">
SELECT
</select>
</mapper>

View File

@ -1,6 +1,6 @@
# Tomcat # Tomcat
server: server:
port: 9100 port: 9101
# Spring # Spring
spring: spring: