Merge branch 'dev' of https://gitea.qinmian.online/wuzudaniu/cloud-plus-server into dev
# Conflicts: # cloud-modules/cloud-modules-enterprise/enterpise-service/src/main/java/com/muyu/enterpise/service/impl/CarFenceServiceMybaitsImpl.javadev.gateway
commit
3b2e16a39e
|
@ -3,9 +3,9 @@ package com.muyu.common.core.domain;
|
|||
import com.muyu.common.core.constant.Constants;
|
||||
import com.muyu.common.core.constant.HttpStatus;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
@ -15,7 +15,7 @@ import java.io.Serializable;
|
|||
* @author muyu
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Result<T> implements Serializable {
|
||||
|
@ -33,6 +33,7 @@ public class Result<T> implements Serializable {
|
|||
public static final int WARN = HttpStatus.WARN;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private int code;
|
||||
|
||||
private String msg;
|
||||
|
@ -96,8 +97,8 @@ public class Result<T> implements Serializable {
|
|||
private static <T> Result<T> restResult (T data, int code, String msg) {
|
||||
return Result.<T>builder()
|
||||
.code(code)
|
||||
.data(data)
|
||||
.msg(msg)
|
||||
.data(data)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package com.muyu.enterprise.cache;
|
||||
|
||||
import com.muyu.common.cache.CacheAbsBasic;
|
||||
import com.muyu.domain.CarInformation;
|
||||
|
||||
/**
|
||||
* 车辆缓存服务
|
||||
* @className: VehicleCacheService ️✈️
|
||||
* @author: Yang 鹏 🦅
|
||||
* @date: 2024/9/30 00:36 ⏰
|
||||
* @Version: 1.0
|
||||
* @description:
|
||||
*/
|
||||
public class VehicleCacheService extends CacheAbsBasic<String, CarInformation> {
|
||||
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "vehicle:info:";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decode(String key){
|
||||
return key.replace("vehicle:info:","");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -4,9 +4,10 @@ package com.muyu.enterpise.service.impl;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.domain.CarFence;
|
||||
import com.muyu.domain.CarMiddle;
|
||||
import com.muyu.domain.FenceAndGroupMiddle;
|
||||
import com.muyu.domain.CarAndGroupMiddle;
|
||||
import com.muyu.domain.FenceGroup;
|
||||
import com.muyu.domain.req.CarFenceAdd;
|
||||
|
||||
import com.muyu.enterpise.mapper.CarFenceServiceMybaitsMapper;
|
||||
import com.muyu.enterpise.service.CarFenceServiceMybaits;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
|
@ -31,55 +32,27 @@ public class CarFenceServiceMybaitsImpl extends ServiceImpl<CarFenceServiceMybai
|
|||
private CarFenceServiceMybaitsMapper carFenceServiceMybaitsMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 添加多对多围栏组
|
||||
* @param fenceGroupId
|
||||
* @param carFenceId
|
||||
*/
|
||||
@Override
|
||||
public void add(Integer fenceGroupId, List<Integer> carFenceId) {
|
||||
|
||||
for (Integer integer : carFenceId) {
|
||||
Integer addMiddle = carFenceServiceMybaitsMapper.addGroup(fenceGroupId,integer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加多对多围栏组
|
||||
*
|
||||
* @param fenceGroupId
|
||||
* @param carFences
|
||||
*/
|
||||
@Override
|
||||
public void addFenceGroup(Integer fenceGroupId, List<CarFenceAdd> carFences) {
|
||||
for (CarFenceAdd carFence : carFences) {
|
||||
Integer id = carFence.getId();
|
||||
Integer addMiddle = carFenceServiceMybaitsMapper.addFenceGroup(fenceGroupId,id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改围栏组状态
|
||||
* @param groupId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object updateFenceGroupById(Integer groupId) {
|
||||
carFenceServiceMybaitsMapper.updateFenceGroupById(groupId);
|
||||
return null;
|
||||
public boolean saveBatch(List<CarFenceAdd> carFences, Integer fenceGroupId) {
|
||||
List<CarMiddle> list = carFences.stream().map(carFenceAdd -> {
|
||||
CarMiddle carMiddle = new CarMiddle();
|
||||
carMiddle.setCarFenceId(carFenceAdd.getId());
|
||||
carMiddle.setCarGroupId(fenceGroupId);
|
||||
return carMiddle;
|
||||
}).toList();
|
||||
boolean b = this.saveBatch(list);
|
||||
return b;
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动围栏
|
||||
*/
|
||||
@Override
|
||||
public Object activate(Integer groupId) {
|
||||
carFenceServiceMybaitsMapper.activate(groupId);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据围栏组的id查询绑定的围栏的中间表
|
||||
|
@ -98,20 +71,9 @@ public class CarFenceServiceMybaitsImpl extends ServiceImpl<CarFenceServiceMybai
|
|||
return carFences;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据围栏组和车辆的id添加中间表
|
||||
*/
|
||||
@Override
|
||||
public void addFenceGroupAddCarMiddle(Integer id, List<FenceGroup> fenceGroups) {
|
||||
|
||||
//遍历集合
|
||||
for (FenceGroup fenceGroup : fenceGroups) {
|
||||
//获取围栏组的id
|
||||
Long groupId = fenceGroup.getGroupId();
|
||||
carFenceServiceMybaitsMapper.addFenceGroupAddCarMiddle(id,groupId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取绑定的围栏组
|
||||
|
@ -120,18 +82,22 @@ public class CarFenceServiceMybaitsImpl extends ServiceImpl<CarFenceServiceMybai
|
|||
@Override
|
||||
public List<FenceGroup> selectBoundGFenceGroup(Integer carId) {
|
||||
/*根据id查询围栏组的id*/
|
||||
List<FenceAndGroupMiddle> list = carFenceServiceMybaitsMapper.selectBoundGFenceGroup(carId);
|
||||
List<CarAndGroupMiddle> list = carFenceServiceMybaitsMapper.selectBoundGFenceGroup(carId);
|
||||
ArrayList<FenceGroup> fenceGroups = new ArrayList<>();
|
||||
|
||||
/*循环*/
|
||||
for (FenceAndGroupMiddle fenceAndGroupMiddle : list) {
|
||||
for (CarAndGroupMiddle fenceAndGroupMiddle : list) {
|
||||
/**
|
||||
* 获取围栏组的id
|
||||
*/
|
||||
Integer carGroupId = fenceAndGroupMiddle.getGroupId();
|
||||
Long carGroupId = fenceAndGroupMiddle.getGroupId();
|
||||
//获取围栏组的数据 并 存入list
|
||||
fenceGroups.add(carFenceServiceMybaitsMapper.selectGroup(carGroupId));
|
||||
}
|
||||
return fenceGroups;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue