Compare commits

..

No commits in common. "83756518ad0c16f3291fdfd78d1accfcb5f7e11d" and "45cb6b2a17c0bfad8415f1736c936825af9d8e69" have entirely different histories.

47 changed files with 88 additions and 397 deletions

View File

@ -4,10 +4,10 @@ server:
# nacos线上地址 # nacos线上地址
nacos: nacos:
addr: 123.57.152.124:8848 addr: 127.0.0.1:8848
user-name: nacos user-name: nacos
password: nacos password: nacos
namespace: yp namespace: wx
# Spring # Spring
spring: spring:
application: application:

View File

@ -1,5 +1,6 @@
package com.muyu.common.cache; package com.muyu.common.cache;
import com.muyu.common.core.web.domain.BaseEntity;
import com.muyu.common.redis.service.RedisService; import com.muyu.common.redis.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -22,7 +23,7 @@ public abstract class CacheAbsBasic <K, V> implements CacheBasic<K, V>{
public void put(K key, V value) { public void put(K key, V value) {
try { try {
redisService.setCacheObject(encode(key), value); redisService.setCacheObject(encode(key), value,30L,TimeUnit.MINUTES);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("运行时异常,异常信息为:{}"+e.getMessage()); throw new RuntimeException("运行时异常,异常信息为:{}"+e.getMessage());
} }

View File

@ -4,10 +4,10 @@ server:
# nacos线上地址 # nacos线上地址
nacos: nacos:
addr: 123.57.152.124:8848 addr: 127.0.0.1:8848
user-name: nacos user-name: nacos
password: nacos password: nacos
namespace: yp namespace: wx
# Spring # Spring
spring: spring:

View File

@ -1,49 +0,0 @@
package com.muyu.data.domain;
import com.muyu.domain.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @version 1.0
* @Author xie ya ru
* @Date 2024/10/6 20:21
* @
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class EnterpriseCommon {
/**
*
*/
private SysCar sysCar;
/**
*
*/
private WarnStrategy warnStrategy;
/**
*
*/
private WarnRule warnRule;
/**
*
*/
private List<CarAndGroupMiddle> carAndGroupMiddleList;
/**
*
*/
private List<FenceAndGroupMiddle> fenceAndGroupMiddles;
/**
*
*/
}

View File

@ -119,11 +119,6 @@
<artifactId>cloud-common-xxl</artifactId> <artifactId>cloud-common-xxl</artifactId>
</dependency> </dependency>
<!-- 获取缓存 -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>enterprise-cache</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -1,36 +0,0 @@
package com.muyu.data.warn;
import com.muyu.domain.SysCar;
import com.muyu.enterpise.cache.SysCarCacheService;
import com.muyu.enterpise.cache.SysCarTypeCacheService;
import org.springframework.stereotype.Component;
import org.apache.catalina.mapper.*;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
/**
* @version 1.0
* @Author xie ya ru
* @Date 2024/10/6 15:21
* @
*/
@Component
public class WarningJudgment {
@Resource
private SysCarCacheService sysCarCacheService;
@Resource
private SysCarTypeCacheService sysCarTypeCacheService;
@PostConstruct
public void getCache(){
}
}

View File

@ -4,10 +4,10 @@ server:
# nacos线上地址 # nacos线上地址
nacos: nacos:
addr: 123.57.152.124:8848 addr: 127.0.0.1:8848
user-name: nacos user-name: nacos
password: nacos password: nacos
namespace: yp namespace: wx
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all # SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
# Spring # Spring
spring: spring:

View File

@ -4,8 +4,6 @@ import com.muyu.common.cache.CacheAbsBasic;
import com.muyu.domain.SysCar; import com.muyu.domain.SysCar;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List;
/** /**
* @version 1.0 * @version 1.0
* @Author xie ya ru * @Author xie ya ru

View File

@ -1,32 +0,0 @@
package com.muyu.enterpise.cache;
import com.muyu.common.cache.CacheAbsBasic;
import com.muyu.domain.WarnStrategy;
import org.springframework.stereotype.Component;
/**
* @Authoryan
* @Packagecom.muyu.enterpise.cache
* @Projectplus
* @nameWarnStrategyCacjeService
* @Date2024/10/6 19:26
*/
@Component
public class WarnStrategyCacjeService extends CacheAbsBasic<String, WarnStrategy> {
@Override
public String keyPre() {
return "sysCarType:info:";
}
@Override
public String encode(String key) {
return super.encode(key);
}
@Override
public String decode(String key) {
return super.decode(key);
}
}

View File

@ -1,5 +1,3 @@
com.muyu.enterpise.cache.MessageValueCacheService com.muyu.enterpise.cache.MessageValueCacheService
com.muyu.enterpise.cache.SysCarCacheService com.muyu.enterpise.cache.SysCarCacheService
com.muyu.enterpise.cache.SysCarTypeCacheService com.muyu.enterpise.cache.SysCarTypeCacheService
com.muyu.enterpise.cache.WarnStrategyCacjeService

View File

@ -1,119 +0,0 @@
package com.muyu.domain;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Authoryan
* @Packagecom.muyu.domain
* @Projectplus
* @nameCars
* @Date2024/10/4 20:45
*/
@AllArgsConstructor
@Data
@NoArgsConstructor
@Builder
public class Cars {
/**
* id
*/
@Schema
private Integer id;
/**
* name
*/
@Schema
private String name;
/**
* w
*/
@Schema
private String w;
/**
* q
*/
@Schema
private String q;
/**
* e
*/
@Schema
private String e;
/**
* r
*/
@Schema
private String r;
/**
* t
*/
@Schema
private String t;
/**
* g
*/
@Schema
private String y;
/**
* a
*/
@Schema
private String a;
/**
* s
*/
@Schema
private String s;
/**
* d
*/
@Schema
private String d;
/**
* f
*/
@Schema
private String f;
/**
* g
*/
@Schema
private String g;
/**
* z
*/
@Schema
private String z;
/**
* x
*/
@Schema
private String x;
/**
* c
*/
@Schema
private String c;
}

View File

@ -56,4 +56,5 @@ public class FenceGroup {
.groupStates(states) .groupStates(states)
.build(); .build();
} }
} }

View File

@ -88,7 +88,6 @@ public class SysCar extends BaseEntity{
.append("createTime", getCreateTime()) .append("createTime", getCreateTime())
.append("updateBy", getUpdateBy()) .append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime()) .append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString(); .toString();
} }
} }

View File

@ -31,7 +31,7 @@ public class SysCarType extends BaseEntity {
*/ */
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
@Schema(name = "车辆类型主键") @Schema(name = "车辆类型主键")
private String id; private Long id;
/** /**
* *

View File

@ -19,13 +19,6 @@
<dependencies> <dependencies>
<!-- Mybatis Plus 两大件-->
<dependency>
<groupId>com.github.yulichang</groupId>
<artifactId>mybatis-plus-join</artifactId>
<version>1.4.13</version>
</dependency>
<dependency> <dependency>
<groupId>com.muyu</groupId> <groupId>com.muyu</groupId>
<artifactId>enterpise-common</artifactId> <artifactId>enterpise-common</artifactId>

View File

@ -2,7 +2,7 @@ package com.muyu.controller;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.domain.FenceGroup; import com.muyu.domain.FenceGroup;
import com.muyu.enterpise.service.CarAndFenceGroupMiddleService; import com.muyu.service.CarAndFenceGroupMiddleService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;

View File

@ -1,10 +1,9 @@
package com.muyu.enterpise.controller; package com.muyu.controller;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.domain.FenceGroup; import com.muyu.domain.FenceGroup;
import com.muyu.domain.req.FenceGroupUpdateReq; import com.muyu.domain.req.FenceGroupUpdateReq;
import com.muyu.service.CarFenceUpdateService;
import com.muyu.enterpise.service.CarFenceUpdateService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -55,4 +54,5 @@ public class CarFenceUpdateController {
return Result.success("成功"); return Result.success("成功");
} }
} }

View File

@ -33,7 +33,7 @@ public class MessageValueController extends BaseController {
private MessageValueService messageValueService; private MessageValueService messageValueService;
@Autowired @Autowired
private MessageValueCacheService enterpiseCacheService; private MessageValueCacheService messageValueCacheService;
/** /**
* *
@ -56,7 +56,6 @@ public class MessageValueController extends BaseController {
@Operation(summary = "添加报文数据", description = "新增报文数据") @Operation(summary = "添加报文数据", description = "新增报文数据")
public Result<String> save(@RequestBody MessageValueAddReq messageValueAddReq){ public Result<String> save(@RequestBody MessageValueAddReq messageValueAddReq){
messageValueService.save(MessageValue.addBuild(messageValueAddReq)); messageValueService.save(MessageValue.addBuild(messageValueAddReq));
// enterpiseCacheService.put(String.valueOf(messageValueAddReq.getTemplateId()),MessageValue.addBuild(messageValueAddReq));
return Result.success("添加成功"); return Result.success("添加成功");
} }
@ -81,12 +80,4 @@ public class MessageValueController extends BaseController {
} }
@PostMapping({"/findByTemplateId/{stringVin}"})
@Operation(
summary = "根据车辆类型查询报文模版ID",
description = "根据车辆类型查询报文模版ID"
)
public Result<Long> findByTemplateId(@PathVariable("stringVin") String stringVin) {
return Result.success(this.messageValueService.findByTemplateId(stringVin), "查询成功");
}
} }

View File

@ -8,6 +8,7 @@ import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.domain.SysCar; import com.muyu.domain.SysCar;
import com.muyu.domain.req.SysCarReq; import com.muyu.domain.req.SysCarReq;
import com.muyu.domain.resp.SysCarResp; import com.muyu.domain.resp.SysCarResp;
import com.muyu.enterpise.cache.SysCarCacheService;
import com.muyu.enterpise.service.SysCarService; import com.muyu.enterpise.service.SysCarService;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -30,10 +31,13 @@ public class SysCarController extends BaseController
@Resource @Resource
private SysCarService sysCarService; private SysCarService sysCarService;
@Resource
private SysCarCacheService sysCarCacheService;
/** /**
* *
*/ */
@RequiresPermissions("saas:car:list") @RequiresPermissions("car:car:list")
@GetMapping("/list") @GetMapping("/list")
public Result<TableDataInfo<SysCarResp>> list(SysCarReq sysCarReq) public Result<TableDataInfo<SysCarResp>> list(SysCarReq sysCarReq)
{ {
@ -45,7 +49,7 @@ public class SysCarController extends BaseController
/** /**
* *
*/ */
@RequiresPermissions("saas:car:query") @RequiresPermissions("car:car:query")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
public Result<List<SysCar>> getInfo(@PathVariable("id") Long id) public Result<List<SysCar>> getInfo(@PathVariable("id") Long id)
{ {
@ -63,7 +67,9 @@ public class SysCarController extends BaseController
if (sysCarService.checkIdUnique(sysCar)) { if (sysCarService.checkIdUnique(sysCar)) {
return error("新增 车辆基础信息 '" + sysCar + "'失败,车辆基础信息已存在"); return error("新增 车辆基础信息 '" + sysCar + "'失败,车辆基础信息已存在");
} }
sysCar.setCreateBy(SecurityUtils.getUsername()); sysCar.setCreateBy(SecurityUtils.getUsername());
sysCarCacheService.put(sysCar.getCarVin(),sysCar);
return toAjax(sysCarService.save(sysCar)); return toAjax(sysCarService.save(sysCar));
} }

View File

@ -4,6 +4,7 @@ import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.controller.BaseController; import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo; import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.domain.SysCarType; import com.muyu.domain.SysCarType;
import com.muyu.enterpise.cache.SysCarTypeCacheService;
import com.muyu.enterpise.service.SysTypeService; import com.muyu.enterpise.service.SysTypeService;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -29,6 +30,9 @@ public class SysTypeController extends BaseController {
@Resource @Resource
private SysTypeService sysTypeService; private SysTypeService sysTypeService;
@Resource
private SysCarTypeCacheService sysCarTypeCacheService;
/** /**
* *
@ -37,6 +41,10 @@ public class SysTypeController extends BaseController {
public Result<TableDataInfo<SysCarType>> list() { public Result<TableDataInfo<SysCarType>> list() {
startPage(); startPage();
List<SysCarType> list = sysTypeService.selectSysTypeList(); List<SysCarType> list = sysTypeService.selectSysTypeList();
for (SysCarType sysCarType : list) {
sysCarTypeCacheService.put(String.valueOf(sysCarType.getId()),sysCarType);
}
return getDataTable(list); return getDataTable(list);
} }
} }

View File

@ -1,4 +1,4 @@
package com.muyu.enterpise.mapper; package com.muyu.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.common.core.web.controller.BaseController; import com.muyu.common.core.web.controller.BaseController;

View File

@ -54,7 +54,7 @@ public interface CarFenceServiceMybaitsMapper extends BaseMapper<CarMiddle> {
* @param id * @param id
* @param groupId * @param groupId
*/ */
void addFenceGroupAddCarMiddle(@Param("id") Integer id, @Param("groupId") Long groupId); void addFenceGroupAddCarMiddle(@Param("id") Integer id, @Param("groupId") Integer groupId);
/** /**
* *

View File

@ -1,4 +1,4 @@
package com.muyu.enterpise.mapper; package com.muyu.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.domain.CarFence; import com.muyu.domain.CarFence;

View File

@ -14,6 +14,5 @@ import org.apache.ibatis.annotations.Select;
*/ */
@Mapper @Mapper
public interface MessageValueMapper extends BaseMapper<MessageValue> { public interface MessageValueMapper extends BaseMapper<MessageValue> {
@Select({"SELECT sct.message_template_id FROM sys_car sc LEFT JOIN sys_car_type sct on sct.id = sc.car_type WHERE sc.car_vin = ${stringVin}"})
Long findByTemplateId(String stringVin);
} }

View File

@ -15,5 +15,5 @@ import java.util.List;
@Mapper @Mapper
public interface SysCarMapper extends BaseMapper<SysCar>{ public interface SysCarMapper extends BaseMapper<SysCar>{
List<SysCarResp> selectSysCarList(SysCar sysCar); // List<SysCarResp> selectSysCarList(SysCar sysCar);
} }

View File

@ -19,6 +19,6 @@ import java.util.List;
*/ */
public interface SysTypeMapper extends BaseMapper<SysCarType> { public interface SysTypeMapper extends BaseMapper<SysCarType> {
List<SysCarType> selectSysList(); // List<SysCarType> selectSysList();
} }

View File

@ -1,4 +1,4 @@
package com.muyu.enterpise.service; package com.muyu.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.domain.CarAndGroupMiddle; import com.muyu.domain.CarAndGroupMiddle;

View File

@ -1,4 +1,4 @@
package com.muyu.enterpise.service; package com.muyu.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.domain.CarFence; import com.muyu.domain.CarFence;

View File

@ -27,6 +27,6 @@ public interface MessageValueService extends IService<MessageValue> {
* @param str * @param str
*/ */
void test(String str); void test(String str);
Long findByTemplateId(String stringVin);
} }

View File

@ -1,11 +1,10 @@
package com.muyu.enterpise.service.impl; package com.muyu.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.domain.CarAndGroupMiddle; import com.muyu.domain.CarAndGroupMiddle;
import com.muyu.domain.FenceGroup; import com.muyu.domain.FenceGroup;
import com.muyu.mapper.CarAndFenceGroupMiddleMapper;
import com.muyu.enterpise.mapper.CarAndFenceGroupMiddleMapper; import com.muyu.service.CarAndFenceGroupMiddleService;
import com.muyu.enterpise.service.CarAndFenceGroupMiddleService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

View File

@ -1,11 +1,10 @@
package com.muyu.enterpise.service.impl; package com.muyu.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.domain.CarFence; import com.muyu.domain.CarFence;
import com.muyu.domain.FenceGroup; import com.muyu.domain.FenceGroup;
import com.muyu.mapper.CarFenceUpdateMapper;
import com.muyu.enterpise.mapper.CarFenceUpdateMapper; import com.muyu.service.CarFenceUpdateService;
import com.muyu.enterpise.service.CarFenceUpdateService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

View File

@ -10,7 +10,6 @@ import com.muyu.domain.resp.MessageValueListResp;
import com.muyu.enterpise.cache.MessageValueCacheService; import com.muyu.enterpise.cache.MessageValueCacheService;
import com.muyu.enterpise.mapper.MessageValueMapper; import com.muyu.enterpise.mapper.MessageValueMapper;
import com.muyu.enterpise.service.MessageValueService; import com.muyu.enterpise.service.MessageValueService;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -30,11 +29,10 @@ public class MessageValueServiceImpl
@Resource @Resource
private MessageValueMapper messageValueMapper; private MessageValueMapper messageValueMapper;
@Resource @Resource
private MessageValueCacheService messageValueCacheService; private MessageValueCacheService messageValueCacheService;
/** /**
* *
* @param messageValueReq * @param messageValueReq
@ -57,8 +55,6 @@ public class MessageValueServiceImpl
List<MessageValue> list = this.list(queryWrapper); List<MessageValue> list = this.list(queryWrapper);
messageValueCacheService.put(String.valueOf(messageValueReq.getMessageTemplateId()),list); messageValueCacheService.put(String.valueOf(messageValueReq.getMessageTemplateId()),list);
List<MessageValue> messageValues = messageValueCacheService.get(String.valueOf(messageValueReq.getMessageTemplateId()));
System.out.println("asoldonasond:"+messageValues);
return list.stream() return list.stream()
.map(messageValue -> MessageValueListResp.valueBuild( .map(messageValue -> MessageValueListResp.valueBuild(
messageValue messageValue
@ -81,10 +77,7 @@ public class MessageValueServiceImpl
} }
} }
@Override
public Long findByTemplateId(String stringVin) {
return messageValueMapper.findByTemplateId(stringVin);
}
} }

View File

@ -6,7 +6,6 @@ import com.muyu.common.domain.InformationData;
import com.muyu.domain.SysCar; import com.muyu.domain.SysCar;
import com.muyu.domain.req.SysCarReq; import com.muyu.domain.req.SysCarReq;
import com.muyu.domain.resp.SysCarResp; import com.muyu.domain.resp.SysCarResp;
import com.muyu.enterpise.cache.SysCarCacheService;
import com.muyu.enterpise.mapper.SysCarMapper; import com.muyu.enterpise.mapper.SysCarMapper;
import com.muyu.enterpise.service.SysCarService; import com.muyu.enterpise.service.SysCarService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -14,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -29,11 +29,9 @@ public class SysCarServiceImpl
@Autowired @Autowired
private SysCarMapper sysCarMapper; private SysCarMapper sysCarMapper;
@Autowired
private SysCarCacheService sysCarCacheService;
/** /**
* *
*
* @param id * @param id
* @return * @return
*/ */
@ -42,14 +40,13 @@ public class SysCarServiceImpl
LambdaQueryWrapper<SysCar> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SysCar> queryWrapper = new LambdaQueryWrapper<>();
Assert.notNull(id, "id不可为空"); Assert.notNull(id, "id不可为空");
queryWrapper.eq(SysCar::getId, id); queryWrapper.eq(SysCar::getId, id);
return this.getOne(queryWrapper); return this.getOne(queryWrapper);
} }
/** /**
* *
*
* @param sysCarReq * @param sysCarReq
* @return * @return
*/ */
@ -68,23 +65,13 @@ public class SysCarServiceImpl
if (StringUtils.isNotEmpty(sysCarReq.getCarModel())) { if (StringUtils.isNotEmpty(sysCarReq.getCarModel())) {
queryWrapper.eq(SysCar::getCarModel, sysCarReq.getCarModel()); queryWrapper.eq(SysCar::getCarModel, sysCarReq.getCarModel());
} }
if (null != sysCarReq.getCarType()) { if (null == sysCarReq.getCarType()) {
queryWrapper.eq(SysCar::getCarType, sysCarReq.getCarType()); queryWrapper.eq(SysCar::getCarType, sysCarReq.getCarType());
} }
if (null != sysCarReq.getState()) { if (null == sysCarReq.getState()) {
queryWrapper.eq(SysCar::getState, sysCarReq.getState()); queryWrapper.eq(SysCar::getState, sysCarReq.getState());
} }
//就是下面两个判断有问题 还有问题吗 没有我就下了
List<SysCar> list = this.list(queryWrapper); List<SysCar> list = this.list(queryWrapper);
for (SysCar sysCar : list) {
String carVin = sysCar.getCarVin();
//MQTTX是啥 跟MQ差不多 这样就行吧 OK 这个缓存 是老懂教我们的
sysCarCacheService.put(carVin, sysCar);
System.out.println("s够不够水电费健康发动机刚发打卡机这咋广发卡缴纳:"+carVin);
SysCar sysCar1 = sysCarCacheService.get(carVin);
System.out.println("asfih"+sysCar1);
}
return list.stream() return list.stream()
.map(SysCarResp::reverseResp) .map(SysCarResp::reverseResp)
.toList(); .toList();

View File

@ -30,7 +30,7 @@ public class SysTypeServiceImpl
*/ */
@Override @Override
public List<SysCarType> selectSysTypeList() { public List<SysCarType> selectSysTypeList() {
return sysTypeMapper.selectSysList(); return this.list();
} }

View File

@ -4,10 +4,8 @@ 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.muyu.common.core.utils.StringUtils; import com.muyu.common.core.utils.StringUtils;
import com.muyu.domain.WarnStrategy; import com.muyu.domain.WarnStrategy;
import com.muyu.enterpise.cache.WarnStrategyCacjeService;
import com.muyu.enterpise.mapper.WarnStrategyMapper; import com.muyu.enterpise.mapper.WarnStrategyMapper;
import com.muyu.enterpise.service.IWarnStrategyService; import com.muyu.enterpise.service.IWarnStrategyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
@ -22,9 +20,6 @@ public class WarnStrategyServiceImpl
extends ServiceImpl<WarnStrategyMapper, WarnStrategy> extends ServiceImpl<WarnStrategyMapper, WarnStrategy>
implements IWarnStrategyService { implements IWarnStrategyService {
@Autowired
private WarnStrategyCacjeService warnStrategyCacjeService;
/** /**
* *
* *
@ -61,15 +56,7 @@ public class WarnStrategyServiceImpl
if (null!=warnStrategy.getMsgId()){ if (null!=warnStrategy.getMsgId()){
queryWrapper.eq(WarnStrategy::getMsgId, warnStrategy.getMsgId()); queryWrapper.eq(WarnStrategy::getMsgId, warnStrategy.getMsgId());
} }
return this.list(queryWrapper);
List<WarnStrategy> list = this.list(queryWrapper);
for (WarnStrategy strategy : list) {
warnStrategyCacjeService.put(String.valueOf(strategy.getId()),strategy);
}
return list;
} }
/** /**

View File

@ -4,10 +4,10 @@ server:
# nacos线上地址 # nacos线上地址
nacos: nacos:
addr: 123.57.152.124:8848 addr: 127.0.0.1:8848
user-name: nacos user-name: nacos
password: nacos password: nacos
namespace: yp namespace: wx
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all # SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
# Spring # Spring
spring: spring:
@ -19,7 +19,7 @@ spring:
allow-bean-definition-overriding: true allow-bean-definition-overriding: true
application: application:
# 应用名称 # 应用名称
name: cloud-saas name: cloud-warn
profiles: profiles:
# 环境配置 # 环境配置
active: dev active: dev

View File

@ -4,10 +4,10 @@ server:
# nacos线上地址 # nacos线上地址
nacos: nacos:
addr: 123.57.152.124:8848 addr: 127.0.0.1:8848
user-name: nacos user-name: nacos
password: nacos password: nacos
namespace: yp namespace: wx
# Spring # Spring
spring: spring:

View File

@ -4,10 +4,10 @@ server:
# nacos线上地址 # nacos线上地址
nacos: nacos:
addr: 123.57.152.124:8848 addr: 127.0.0.1:8848
user-name: nacos user-name: nacos
password: nacos password: nacos
namespace: yp namespace: wx
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all # SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
# Spring # Spring
spring: spring:

View File

@ -10,9 +10,7 @@
</parent> </parent>
<artifactId>cloud-modules-parse</artifactId> <artifactId>cloud-modules-parse</artifactId>
<description>
cloud-modules-parse 协议解析
</description>
<properties> <properties>
<maven.compiler.source>17</maven.compiler.source> <maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target> <maven.compiler.target>17</maven.compiler.target>
@ -111,6 +109,7 @@
<dependency> <dependency>
<groupId>com.muyu</groupId> <groupId>com.muyu</groupId>
<artifactId>cloud-common-kafka</artifactId> <artifactId>cloud-common-kafka</artifactId>
<version>${muyu.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -10,13 +10,12 @@ import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.annotation.Resource;
/** /**
* @version 1.0 * @version 1.0
* @Author xie ya ru * @Author xie ya ru
* @Date 2024/9/26 15:31 * @Date 2024/9/26 15:31
* @ MQTT * @
*/ */
@ -27,15 +26,12 @@ import javax.annotation.Resource;
@NoArgsConstructor @NoArgsConstructor
public class MqttConsumerConfig { public class MqttConsumerConfig {
String topic = "yyy"; String topic = "xxx";
String content = "Message from MqttPublishSample"; String content = "Message from MqttPublishSample";
int qos = 2; int qos = 2;
String broker = "tcp://123.57.152.124:1883"; String broker = "tcp://123.57.152.124:1883";
String clientId = "xyr123456789"; String clientId = "xyr123456789";
@Resource
private ProcessData processData;
@PostConstruct @PostConstruct
public void connect() { public void connect() {
try { try {
@ -59,7 +55,7 @@ public class MqttConsumerConfig {
public void messageArrived(String s, MqttMessage mqttMessage) throws Exception { public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
String s1 = new String(mqttMessage.getPayload()); String s1 = new String(mqttMessage.getPayload());
System.out.println("接收到的主题是:" + s + "内容是:{}" + s1); System.out.println("接收到的主题是:" + s + "内容是:{}" + s1);
processData.DataConversion(s1); ProcessData.DataConversion(s1);
} }

View File

@ -11,10 +11,7 @@ import com.muyu.enterpise.cache.SysCarTypeCacheService;
import com.muyu.parse.uitl.DataParseUtil; import com.muyu.parse.uitl.DataParseUtil;
import com.muyu.remote.RemoteMessageValueService; import com.muyu.remote.RemoteMessageValueService;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.apache.kafka.clients.producer.Callback;
import org.apache.kafka.clients.producer.ProducerRecord; import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;
import org.springframework.context.annotation.Configuration;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
@ -27,29 +24,29 @@ import java.util.List;
* @ * @
*/ */
@Log4j2 @Log4j2
@Configuration
public class ProcessData { public class ProcessData {
@Resource
private static RemoteMessageValueService remoteMessageValueService;
//报文模版信息 //报文模版信息
@Resource @Resource
private MessageValueCacheService messageValueCacheService; private static MessageValueCacheService messageValueCacheService;
//车辆信息 //车辆信息
@Resource @Resource
private SysCarCacheService sysCarCacheService; private static SysCarCacheService sysCarCacheService;
//车辆类型信息 //车辆类型信息
@Resource @Resource
private SysCarTypeCacheService sysCarTypeCacheService; private static SysCarTypeCacheService sysCarTypeCacheService;
@Resource @Resource
private KafkaProducerConfig kafkaProducerConfig; private static KafkaProducerConfig kafkaProducerConfig;
private final static String topic = "sysCar_vin_topic"; private final static String topic = "sysCar_vin_topic";
public void DataConversion(String jsonVin ) { public static void DataConversion(String jsonVin ) {
//设置数组存储车辆数据 //设置数组存储车辆数据
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
String vin = DataParseUtil.dataParsing(jsonVin); String vin = DataParseUtil.dataParsing(jsonVin);
@ -82,7 +79,7 @@ public class ProcessData {
private void sendKafkaMessage(JSONObject jsonObject){ private static void sendKafkaMessage(JSONObject jsonObject){
ProducerRecord<Object, JSONObject> producerRecord = new ProducerRecord<>(topic, jsonObject); ProducerRecord<Object, JSONObject> producerRecord = new ProducerRecord<>(topic, jsonObject);
try { try {
kafkaProducerConfig.kafkaProducer().send(new ProducerRecord<>(topic,jsonObject.toString())); kafkaProducerConfig.kafkaProducer().send(new ProducerRecord<>(topic,jsonObject.toString()));

View File

@ -7,7 +7,7 @@ import lombok.extern.log4j.Log4j2;
* @version 1.0 * @version 1.0
* @Author xie ya ru * @Author xie ya ru
* @Date 2024/9/28 16:48 * @Date 2024/9/28 16:48
* @ * @
*/ */
@Log4j2 @Log4j2
public class DataParseUtil { public class DataParseUtil {

View File

@ -7,7 +7,7 @@ nacos:
addr: 123.57.152.124:8848 addr: 123.57.152.124:8848
user-name: nacos user-name: nacos
password: nacos password: nacos
namespace: yp namespace: xyr
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all # SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
# Spring # Spring
spring: spring:

View File

@ -4,10 +4,10 @@ server:
# nacos线上地址 # nacos线上地址
nacos: nacos:
addr: 123.57.152.124:8848 addr: 127.0.0.1:8848
user-name: nacos user-name: nacos
password: nacos password: nacos
namespace: yp namespace: wx
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all # SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
# Spring # Spring
spring: spring:

View File

@ -7,7 +7,7 @@ nacos:
addr: 123.57.152.124:8848 addr: 123.57.152.124:8848
user-name: nacos user-name: nacos
password: nacos password: nacos
namespace: yp namespace: lhd
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all # SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
# Spring # Spring
spring: spring:

View File

@ -4,10 +4,10 @@ server:
# nacos线上地址 # nacos线上地址
nacos: nacos:
addr: 123.57.152.124:8848 addr: 127.0.0.1:8848
user-name: nacos user-name: nacos
password: nacos password: nacos
namespace: yp namespace: wx
# Spring # Spring
spring: spring:

29
pom.xml
View File

@ -283,30 +283,11 @@
<version>${muyu.version}</version> <version>${muyu.version}</version>
</dependency> </dependency>
<dependency> <!-- <dependency>-->
<groupId>com.muyu</groupId> <!-- <groupId>com.muyu</groupId>-->
<artifactId>enterpise-remote</artifactId> <!-- <artifactId>enterpise-common</artifactId>-->
<version>${muyu.version}</version> <!-- <version>${muyu.version}</version>-->
</dependency> <!-- </dependency>-->
<!-- 实体类 -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>enterpise-common</artifactId>
<version>${muyu.version}</version>
</dependency>
<!-- 缓存框架 -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>enterprise-cache</artifactId>
<version>${muyu.version}</version>
</dependency>
<!-- kafka 公共配置 -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-kafka</artifactId>
<version>${muyu.version}</version>
</dependency>
<!-- <dependency>--> <!-- <dependency>-->
<!-- <groupId>com.muyu</groupId>--> <!-- <groupId>com.muyu</groupId>-->