feat:()优化代码

dev.protocol
sy200 2024-10-04 09:13:30 +08:00
parent 3ed255fe1e
commit d1440fb706
11 changed files with 72 additions and 21 deletions

View File

@ -4,7 +4,7 @@ import com.muyu.common.cache.CacheAbsBacis;
import com.muyu.domain.VehicleType;
/**
*
*
*/
public class VehicleTypeCacheService extends CacheAbsBacis<String, VehicleType> {
@Override

View File

@ -4,3 +4,4 @@ com.muyu.enterprise.cache.FenceCahceService
com.muyu.enterprise.cache.WarnRuleCacheService
com.muyu.enterprise.cache.WarnStrategyCacheService
com.muyu.enterprise.cache.MessageTemplateCacheService
com.muyu.enterprise.cache.VehicleTypeCacheService

View File

@ -0,0 +1,30 @@
package com.muyu.domain.req;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
*
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Tag(name = "绑定围栏组参数")
public class BoundFenceGroupReq {
/**
* Id
*/
private Long vehicleId;
/**
* Ids
*/
private List<Long> fenceGroupIds;
}

View File

@ -155,5 +155,4 @@ public class ElectController extends BaseController {
return Result.success(fences);
}
}

View File

@ -2,6 +2,7 @@ package com.muyu.enterprise.controller;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.common.system.domain.LoginUser;
import com.muyu.domain.req.BoundFenceGroupReq;
import com.muyu.enterprise.cache.VehicleCacheService;
import com.muyu.enterprise.service.VehicleService;
import com.muyu.common.core.domain.Result;
@ -144,9 +145,10 @@ public class VehicleController extends BaseController {
*/
@GetMapping("/addBoundFenceGroup")
@Operation(description = "车辆绑定围栏组")
public Result<String> boundFenceGroup(
@Validated @RequestBody BoundMiddle boundMiddle){
return null;
public Result boundFenceGroup(
@Validated @RequestBody BoundFenceGroupReq boundFenceGroupReq){
vehicleService.boundFenceGroup(boundFenceGroupReq);
return Result.success("绑定成功");
}
/**

View File

@ -30,11 +30,6 @@ public interface ElectMapper extends MPJBaseMapper<Fence> {
@Select("select * from fence where fence_id=#{fenceId}")
List<Fence> mapShow(@Param("fenceId") Long fenceId);
// /**
// * 根据id查询车辆
// */
// Fence boundFence(@Param("fenceId") Long fenceId);
/**
* ()
*/

View File

@ -28,7 +28,16 @@ public interface FencegroupMapper extends MPJBaseMapper<FenceGroup> {
@Select("SELECT g.fence_group_id,g.group_type,g.priority,g.`status`,f.fence_id, group_CONCAT( f.fence_name ) AS fence_name FROM fence_group g LEFT JOIN middle m ON m.fence_group_id = g.fence_group_id LEFT JOIN fence f ON m.fence_id = f.fence_id GROUP BY g.fence_group_id")
List<FenceGroup> showGroupList(FenceGroupReq req);
@Insert("INSERT INTO `vehicle-basic`.`middle` (`fence_id`, `fence_group_id`) VALUES <foreach collection=\"fenceIds\" item=\"id\" separator=\",\"> (#{id},#{fenceGroupId}) </foreach>")
// @Insert("INSERT INTO `vehicle-basic`.`middle` (`fence_id`, `fence_group_id`) VALUES <foreach collection='fenceIds' item='id' separator=','> (#{id},#{fenceGroupId}) </foreach>")
// @Insert({ "<script>", "INSERT INTO user_role (user_id, role_id) VALUES ", "<foreach collection='roleIds' item='roleId' separator=','>", "(#{userId}, #{roleId})", "</foreach>", "</script>" })
@Insert({
"<script>",
"INSERT INTO `vehicle-basic`.`middle` (fence_id, fence_group_id) VALUES ",
"<foreach collection='fenceIds' item='id' separator=','>",
"(#{id}, #{fenceGroupId})",
"</foreach>",
"</script>"
})
void addMiddle(@Param("fenceIds") Integer[] fenceIds,@Param("fenceGroupId") Long fenceGroupId);
}

View File

@ -2,8 +2,10 @@ package com.muyu.enterprise.mapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.muyu.domain.Vehicle;
import com.muyu.domain.req.BoundFenceGroupReq;
import com.muyu.domain.req.VehicleManageReq;
import com.muyu.domain.resp.VehicleManageResp;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
@ -28,11 +30,6 @@ public interface VehicleMapper extends MPJBaseMapper<Vehicle> {
*/
List<VehicleManageResp> findAll(VehicleManageReq vehicleManageReq);
/**
*
*/
void bindFenceGroup(@Param("fenceGroupIds") Integer[] fenceGroupIds, @Param("vehicleId") Long vehicleId);
/**
* vinid
* @param vehicleVin
@ -41,4 +38,19 @@ public interface VehicleMapper extends MPJBaseMapper<Vehicle> {
@Select("SELECT t.message_template_id FROM vehicle v LEFT JOIN vehicle_type t ON v.vehicle_type_id = t.vehicle_type_id WHERE v.vehicle_vin = #{vehicleVin}")
Long findByVehicleVin(String vehicleVin);
/**
*
* @param boundFenceGroupReq
*/
// @Insert("INSERT INTO `vehicle-basic`.`bound_middle` (`fence_group_id`,`vehicle_id`) VALUES <foreach collection=\"fenceGroupIds\" item=\"id\" separator=\",\"> (#{id},#{vehicleId}) </foreach>")
@Insert({
"<script>",
"INSERT INTO `vehicle-basic`.`bound_middle` (fence_group_id,vehicle_id) VALUES ",
"<foreach collection='fenceGroupIds' item='id' separator=','>",
"(#{id}, #{vehicleId})",
"</foreach>",
"</script>"
})
void boundFenceGroup(BoundFenceGroupReq boundFenceGroupReq);
}

View File

@ -2,6 +2,7 @@ package com.muyu.enterprise.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.domain.Vehicle;
import com.muyu.domain.req.BoundFenceGroupReq;
import com.muyu.domain.req.VehicleManageReq;
import com.muyu.domain.resp.VehicleManageResp;
import org.apache.ibatis.annotations.Param;
@ -36,6 +37,5 @@ public interface VehicleService extends IService<Vehicle> {
/**
*
*/
void bindFenceGroup(@Param("fenceGroupIds") Integer[] fenceGroupIds, @Param("vehicleId") Long vehicleId);
void boundFenceGroup(BoundFenceGroupReq boundFenceGroupReq);
}

View File

@ -48,7 +48,7 @@ public class ElectServiceImpl
String decode = fenceCahceService.decode(String.valueOf(list));
//将获取到的数据存到Redis
fenceCahceService.put(String.valueOf(decode),d);
// fenceCahceService.put(String.valueOf(decode),d);
return list;
}
//

View File

@ -5,6 +5,7 @@ import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.muyu.common.core.utils.StringUtils;
import com.muyu.domain.Vehicle;
import com.muyu.domain.VehicleType;
import com.muyu.domain.req.BoundFenceGroupReq;
import com.muyu.domain.req.VehicleManageReq;
import com.muyu.domain.resp.VehicleManageResp;
import com.muyu.enterprise.mapper.VehicleMapper;
@ -70,8 +71,10 @@ public class VehicleServiceImpl
}
@Override
public void bindFenceGroup(Integer[] fenceGroupIds, Long vehicleId) {
vehicleMapper.bindFenceGroup(fenceGroupIds, vehicleId);
public void boundFenceGroup(BoundFenceGroupReq boundFenceGroupReq) {
vehicleMapper.boundFenceGroup(boundFenceGroupReq);
}
}