Compare commits

...

2 Commits

Author SHA1 Message Date
031026 4d0a6e68f6 Merge remote-tracking branch 'origin/master' 2024-06-27 20:55:38 +08:00
031026 3611e00756 feat(新增报文解析配置) 2024-06-27 20:55:31 +08:00
21 changed files with 474 additions and 13 deletions

View File

@ -0,0 +1,28 @@
package com.muyu.clw.common.many.remote;
import com.muyu.clw.common.many.remote.factory.RemoteEnterpriseFallbackFactory;
import com.muyu.clw.common.many.remote.factory.RemoteMessageDataFallbackFactory;
import com.muyu.common.core.constant.ServiceNameConstants;
import com.muyu.common.core.domain.Result;
import com.muyu.domain.Enterprise;
import com.muyu.domain.MessageData;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.List;
/**
*
*
* @author muyu
*/
@FeignClient(
contextId = "remoteMessageDataService",
value = ServiceNameConstants.COMPANY_ENTERPRISE,
fallbackFactory = RemoteMessageDataFallbackFactory.class
)
public interface RemoteMessageDataService {
@GetMapping("/messageData/list")
public Result<List<MessageData>> enterpriseAllList();
}

View File

@ -0,0 +1,35 @@
package com.muyu.clw.common.many.remote.factory;
import com.muyu.clw.common.many.remote.RemoteEnterpriseService;
import com.muyu.clw.common.many.remote.RemoteMessageDataService;
import com.muyu.common.core.domain.Result;
import com.muyu.domain.Enterprise;
import com.muyu.domain.MessageData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @ClassName RemoteEnterpriseFallbackFactory
* @Author AnNan.Wang
* @Date 2024/6/7 21:55
*/
@Component
public class RemoteMessageDataFallbackFactory implements FallbackFactory<RemoteMessageDataService> {
private static final Logger log = LoggerFactory.getLogger(RemoteMessageDataFallbackFactory.class);
@Override
public RemoteMessageDataService create(Throwable cause) {
log.error("日志服务调用失败:{}", cause.getMessage());
return new RemoteMessageDataService() {
@Override
public Result<List<MessageData>> enterpriseAllList() {
return Result.error("报文配置获取失败:{}"+cause.getMessage());
}
};
}
}

View File

@ -0,0 +1,50 @@
package com.muyu.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.common.core.web.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
*
*
* @ClassName MessageData
* @Author AnNan.Wang
* @Date 2024/6/27 9:56
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("message_data")
public class MessageData extends BaseEntity {
/**
*
*/
@TableId(value = "id",type = IdType.AUTO)
private Long id;
/**
*
*/
private String messageLabel;
/**
* Key
*/
private String analyzeKey;
/**
*
*/
private String initiationPosition;
/**
*
*/
private String terminatePosition;
/**
*
*/
private String typeIdentification;
}

View File

@ -1,12 +1,24 @@
package com.muyu.authentication;
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration;
import com.muyu.authentication.mapper.EnterpriseMapper;
import com.muyu.common.core.domain.Result;
import com.muyu.common.security.annotation.EnableCustomConfig;
import com.muyu.common.security.annotation.EnableMyFeignClients;
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
import com.muyu.domain.Enterprise;
import io.netty.handler.address.DynamicAddressConnectHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.data.redis.core.StringRedisTemplate;
import java.util.ArrayList;
import java.util.List;
/**
*
@ -21,4 +33,5 @@ public class MuYuCompanyApplication {
public static void main (String[] args) {
SpringApplication.run(MuYuCompanyApplication.class, args);
}
}

View File

@ -34,7 +34,7 @@ public class EnterpriseController extends BaseController
/**
*
*/
@RequiresPermissions("authentication:enterprise:list")
// @RequiresPermissions("authentication:enterprise:list")
@GetMapping("/list")
public Result<TableDataInfo<Enterprise>> list(Enterprise enterprise)
{

View File

@ -0,0 +1,34 @@
package com.muyu.authentication.controller;
import com.muyu.authentication.service.MessageDataService;
import com.muyu.common.core.domain.Result;
import com.muyu.domain.MessageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* Controller
*
* @ClassName MessageDataController
* @Author AnNan.Wang
* @Date 2024/6/27 10:27
*/
@RestController
@RequestMapping("/messageData")
public class MessageDataController {
@Autowired
private MessageDataService messageDataService;
@GetMapping("/list")
public Result<List<MessageData>> list(){
return Result.success(
messageDataService.messageList()
);
}
}

View File

@ -0,0 +1,15 @@
package com.muyu.authentication.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.domain.MessageData;
/**
* Mapper
*
* @author AnNan.Wang
* @ClassName: MessageDataMapper
* @createTime: 2024/6/27 10:33
*/
public interface MessageDataMapper extends BaseMapper<MessageData> {
}

View File

@ -0,0 +1,19 @@
package com.muyu.authentication.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.domain.MessageData;
import java.util.List;
/**
* Service
*
* @author AnNan.Wang
* @ClassName: MessageDataService
* @createTime: 2024/6/27 10:30
*/
public interface MessageDataService extends IService<MessageData> {
List<MessageData> messageList();
}

View File

@ -19,9 +19,11 @@ import com.muyu.common.system.domain.SysUser;
import com.muyu.common.system.remote.RemoteUserService;
import com.muyu.domain.vo.EnterpriseReq;
import com.muyu.many.domain.Message.MessageData;
import com.muyu.many.forewarning.EarlyWarning;
import lombok.extern.log4j.Log4j2;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import com.muyu.domain.Enterprise;
@ -40,6 +42,8 @@ public class EnterpriseServiceImpl extends ServiceImpl<EnterpriseMapper,Enterpri
@Autowired
private EnterpriseMapper enterpriseMapper;
@Autowired
private ApplicationEventPublisher applicationEventPublisher;
/**
*
*

View File

@ -0,0 +1,31 @@
package com.muyu.authentication.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.authentication.mapper.MessageDataMapper;
import com.muyu.authentication.service.MessageDataService;
import com.muyu.domain.MessageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
*
*
* @ClassName MessageDataServiceImpl
* @Author AnNan.Wang
* @Date 2024/6/27 10:31
*/
@Service
public class MessageDataServiceImpl extends ServiceImpl<MessageDataMapper, MessageData>
implements MessageDataService {
@Autowired
private MessageDataMapper messageDataMapper;
@Override
public List<MessageData> messageList() {
return messageDataMapper.selectList(null);
}
}

View File

@ -0,0 +1,57 @@
package com.muyu.many.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
*
*
* @ClassName MessageAnalysis
* @Author AnNan.Wang
* @Date 2024/6/26 18:38
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("message_analysis")
public class MessageAnalysis {
/**
*
*/
@TableId(value = "id",type = IdType.AUTO)
private Long id;
/**
* ID
*/
private Long vehicleId;
/**
* key
*/
private String analyzeKey;
/**
*
*/
private Integer analyzeStart;
/**
*
*/
private Integer ent;
/**
*
*/
private String lable;
/**
*
*/
private String type;
}

View File

@ -112,6 +112,9 @@ public class Vehicle extends BaseEntity {
@ApiModelProperty(name = "车辆类型", value = "车辆类型")
private String vehicleType;
@Excel(name = "报文")
@ApiModelProperty(name = "报文", value = "报文")
private String messageDetail;
/** 电子围栏ID */
@Excel(name = "电子围栏ID")
@ApiModelProperty(name = "电子围栏ID", value = "电子围栏ID")

View File

@ -0,0 +1,27 @@
package com.muyu.many.forewarning;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.springframework.context.ApplicationEvent;
import java.io.Serializable;
/**
*
*
* @ClassName EarlyWarning
* @Author AnNan.Wang
* @Date 2024/6/25 9:37
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class EarlyWarning implements Serializable {
private Integer id;
private String name;
}

View File

@ -1,16 +1,30 @@
package com.muyu.authentication;
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration;
import com.alibaba.fastjson.JSON;
import com.muyu.authentication.mapper.MessageAnalysisMapper;
import com.muyu.authentication.mapper.VehicleMapper;
import com.muyu.clw.common.many.datasource.holder.DynamicDataSourceHolder;
import com.muyu.clw.common.many.remote.RemoteEnterpriseService;
import com.muyu.common.core.domain.Result;
import com.muyu.common.security.annotation.EnableCustomConfig;
import com.muyu.common.security.annotation.EnableMyFeignClients;
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
import com.muyu.domain.Enterprise;
import com.muyu.many.domain.MessageAnalysis;
import com.muyu.many.domain.Vehicle;
import org.apache.commons.collections4.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.jdbc.DataSourceHealthIndicator;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.EnableScheduling;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
*
*
@ -21,8 +35,35 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@EnableCustomSwagger2
@EnableMyFeignClients
@SpringBootApplication
public class MuYuManyApplication {
public class MuYuManyApplication implements ApplicationRunner {
public static void main (String[] args) {
SpringApplication.run(MuYuManyApplication.class, args);
}
@Autowired
private RemoteEnterpriseService remoteEnterpriseService;
@Autowired
private VehicleMapper vehicleMapper;
@Autowired
private RedisTemplate<String,String> redisTemplate;
@Autowired
private MessageAnalysisMapper messageAnalysisMapper;
@Override
public void run(ApplicationArguments args) throws Exception {
Result<List<Enterprise>> enterprised = remoteEnterpriseService.enterpriseAllList();
List<Enterprise> enterpriseList = enterprised.getData();
for (Enterprise enterprise1 : enterpriseList) {
String ent = "ent_" + enterprise1.getContactPhone().substring(enterprise1.getContactPhone().length() - 4);
DynamicDataSourceHolder.setDynamicDataSourceKey(ent);
List<Vehicle> vehicles = vehicleMapper.selectList(null);
List<MessageAnalysis> messageAnalyses = messageAnalysisMapper.selectList(null);
for (Vehicle vehicle : vehicles) {
redisTemplate.opsForValue().set(vehicle.getVin(), JSON.toJSONString(messageAnalyses),4,TimeUnit.HOURS);
}
}
}
}

View File

@ -29,10 +29,4 @@ public class ManyEnterpriseController {
);
}
// @PostMapping("/manyEnterpriseAdd")
// public Result<String> manyEnterpriseAdd(@RequestBody Enterprise enterprise,@RequestHeader("ent_code")String key){
// return Result.success(
// manyEnterpriseService.manyEnterpriseAdd(enterprise,key)
// );
// }
}

View File

@ -0,0 +1,34 @@
package com.muyu.authentication.controller;
import com.muyu.authentication.service.MessageAnalysisService;
import com.muyu.common.core.domain.Result;
import com.muyu.many.domain.MessageAnalysis;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* Controller
*
* @ClassName MessageAnalysisController
* @Author AnNan.Wang
* @Date 2024/6/26 18:40
*/
@RestController
@RequestMapping("/messageAnalysis")
public class MessageAnalysisController {
@Autowired
private MessageAnalysisService messageAnalysisService;
@PostMapping("/messageAnalysisAdd")
public Result<String> messageAnalysisAdd(@RequestBody List<MessageAnalysis> messageAnalysisList){
return messageAnalysisService.messageAnalysisAdd(messageAnalysisList);
}
}

View File

@ -11,5 +11,4 @@ import com.muyu.many.domain.Enterprise ;
* @createTime: 2024/6/6 15:52
*/
public interface ManyEnterpriseMapper extends BaseMapper<Enterprise> {
int enterpriseInsert(Enterprise enterprise);
}

View File

@ -0,0 +1,15 @@
package com.muyu.authentication.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.many.domain.MessageAnalysis;
/**
* Mapper
*
* @author AnNan.Wang
* @ClassName: MessageAnalysisMapper
* @createTime: 2024/6/26 18:44
*/
public interface MessageAnalysisMapper extends BaseMapper<MessageAnalysis> {
}

View File

@ -0,0 +1,19 @@
package com.muyu.authentication.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.common.core.domain.Result;
import com.muyu.many.domain.MessageAnalysis;
import java.util.List;
/**
* Service
*
* @author AnNan.Wang
* @ClassName: MessageAnalysisService
* @createTime: 2024/6/26 18:41
*/
public interface MessageAnalysisService extends IService<MessageAnalysis> {
Result<String> messageAnalysisAdd(List<MessageAnalysis> messageAnalysisList);
}

View File

@ -0,0 +1,42 @@
package com.muyu.authentication.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.authentication.mapper.MessageAnalysisMapper;
import com.muyu.authentication.service.MessageAnalysisService;
import com.muyu.common.core.domain.Result;
import com.muyu.many.domain.MessageAnalysis;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
*
*
* @ClassName MessageAnalysisServiceImpl
* @Author AnNan.Wang
* @Date 2024/6/26 18:43
*/
@Service
public class MessageAnalysisServiceImpl extends ServiceImpl<MessageAnalysisMapper, MessageAnalysis>
implements MessageAnalysisService {
@Autowired
private MessageAnalysisMapper messageAnalysisMapper;
@Override
public Result<String> messageAnalysisAdd(List<MessageAnalysis> messageAnalysisList) {
for (MessageAnalysis messageAnalysis : messageAnalysisList) {
messageAnalysisMapper.insert(
MessageAnalysis.builder()
.analyzeKey(messageAnalysis.getAnalyzeKey())
.analyzeStart(messageAnalysis.getAnalyzeStart())
.ent(messageAnalysis.getEnt())
.lable(messageAnalysis.getLable())
.type(messageAnalysis.getType())
.build()
);
}
return Result.success();
}
}

View File

@ -19,6 +19,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="mileage" column="mileage" />
<result property="registrationDate" column="registration_date" />
<result property="licenseNumber" column="license_number" />
<result property="messageDetail" column="message_detail" />
<result property="vehicleType" column="vehicle_type" />
<result property="fenceId" column="fence_id" />
<result property="createBy" column="create_by" />
@ -29,6 +30,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectVehicleVo">
select id, vin, brand, model, production_date, body_type, color, engine_capacity, fuel_type, transmission, drive_type, mileage, registration_date, license_number, vehicle_type, fence_id, create_by, create_time, update_by, update_time, remark from vehicle
select id, vin, brand, model, production_date, body_type, color, engine_capacity, fuel_type, transmission, drive_type, mileage, registration_date, license_number, vehicle_type, fence_id, create_by, create_time, update_by, update_time, remark,message_detail from vehicle
</sql>
</mapper>