diff --git a/cloud-modules/cloud-modules-data-processing/src/main/resources/bootstrap.yml b/cloud-modules/cloud-modules-data-processing/src/main/resources/bootstrap.yml index 4473a03..b40171b 100644 --- a/cloud-modules/cloud-modules-data-processing/src/main/resources/bootstrap.yml +++ b/cloud-modules/cloud-modules-data-processing/src/main/resources/bootstrap.yml @@ -1,6 +1,5 @@ # Tomcat server: -<<<<<<<< HEAD:cloud-modules/cloud-modules-data-processing/src/main/resources/bootstrap.yml port: 9711 # nacos线上地址 @@ -9,16 +8,6 @@ nacos: user-name: nacos password: nacos namespace: one-saas -======== - port: 10010 - -# nacos线上地址 -nacos: - addr: 110.42.213.184:8848 - user-name: nacos - password: nacos - namespace: icecream ->>>>>>>> dev.saas.customer:cloud-modules/cloud-modules-openbusiness/cloud-modules-openbusiness-server/src/main/resources/bootstrap.yml # SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all # Spring spring: @@ -37,11 +26,7 @@ spring: allow-bean-definition-overriding: true application: # 应用名称 -<<<<<<<< HEAD:cloud-modules/cloud-modules-data-processing/src/main/resources/bootstrap.yml name: cloud-data-processing -======== - name: cloud-car ->>>>>>>> dev.saas.customer:cloud-modules/cloud-modules-openbusiness/cloud-modules-openbusiness-server/src/main/resources/bootstrap.yml profiles: # 环境配置 active: dev @@ -50,19 +35,19 @@ spring: discovery: # 服务注册地址 server-addr: ${nacos.addr} -# # nacos用户名 -# username: ${nacos.user-name} -# # nacos密码 -# password: ${nacos.password} + # nacos用户名 + username: ${nacos.user-name} + # nacos密码 + password: ${nacos.password} # 命名空间 namespace: ${nacos.namespace} config: # 服务注册地址 server-addr: ${nacos.addr} -# # nacos用户名 -# username: ${nacos.user-name} -# # nacos密码 -# password: ${nacos.password} + # nacos用户名 + username: ${nacos.user-name} + # nacos密码 + password: ${nacos.password} # 命名空间 namespace: ${nacos.namespace} # 配置文件格式 @@ -84,7 +69,4 @@ logging: level: com.muyu.system.mapper: DEBUG -<<<<<<<< HEAD:cloud-modules/cloud-modules-data-processing/src/main/resources/bootstrap.yml cacheNames: fault,fence,warming -======== ->>>>>>>> dev.saas.customer:cloud-modules/cloud-modules-openbusiness/cloud-modules-openbusiness-server/src/main/resources/bootstrap.yml diff --git a/cloud-modules/cloud-modules-openbusiness/cloud-modules-openbusiness-server/src/main/java/com/muyu/openbusiness/mapper/StationMessageMapper.java b/cloud-modules/cloud-modules-openbusiness/cloud-modules-openbusiness-server/src/main/java/com/muyu/openbusiness/mapper/StationMessageMapper.java index c777f54..89219de 100644 --- a/cloud-modules/cloud-modules-openbusiness/cloud-modules-openbusiness-server/src/main/java/com/muyu/openbusiness/mapper/StationMessageMapper.java +++ b/cloud-modules/cloud-modules-openbusiness/cloud-modules-openbusiness-server/src/main/java/com/muyu/openbusiness/mapper/StationMessageMapper.java @@ -1,6 +1,6 @@ package com.muyu.openbusiness.mapper; -import com.github.yulichang.base.MPJBaseMapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.muyu.openbusiness.domain.Messages; import org.apache.ibatis.annotations.Mapper; diff --git a/cloud-modules/cloud-modules-openbusiness/cloud-modules-openbusiness-server/src/main/resources/bootstrap.yml b/cloud-modules/cloud-modules-openbusiness/cloud-modules-openbusiness-server/src/main/resources/bootstrap.yml index a1c92e8..b42a5b6 100644 --- a/cloud-modules/cloud-modules-openbusiness/cloud-modules-openbusiness-server/src/main/resources/bootstrap.yml +++ b/cloud-modules/cloud-modules-openbusiness/cloud-modules-openbusiness-server/src/main/resources/bootstrap.yml @@ -19,7 +19,7 @@ spring: allow-bean-definition-overriding: true application: # 应用名称 - name: cloud-parsing + name: cloud-car profiles: # 环境配置 active: dev diff --git a/cloud-modules/cloud-modules-parsing/pom.xml b/cloud-modules/cloud-modules-parsing/pom.xml new file mode 100644 index 0000000..7f2fd25 --- /dev/null +++ b/cloud-modules/cloud-modules-parsing/pom.xml @@ -0,0 +1,121 @@ + + + 4.0.0 + + com.muyu + cloud-modules + 3.6.3 + + + cloud-modules-parsing + + cloud-modules-parsing 协议解析模块 + + + 17 + 17 + UTF-8 + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + + org.springframework.boot + spring-boot-starter-actuator + + + + + com.mysql + mysql-connector-j + + + + + com.muyu + cloud-common-datasource + + + + + com.muyu + cloud-common-datascope + + + + + com.muyu + cloud-common-log + + + + + com.muyu + cloud-common-api-doc + + + + + com.muyu + cloud-common-xxl + + + + com.muyu + cloud-common-rabbit + + + + org.bouncycastle + bcpkix-jdk15on + 1.70 + + + + com.muyu + cloud-common-kafka + + + + org.eclipse.paho + org.eclipse.paho.client.mqttv3 + 1.2.2 + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + diff --git a/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/CloudParsingApplication.java b/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/CloudParsingApplication.java new file mode 100644 index 0000000..673e3c5 --- /dev/null +++ b/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/CloudParsingApplication.java @@ -0,0 +1,22 @@ +package com.muyu.parsing; + +import com.muyu.common.security.annotation.EnableCustomConfig; +import com.muyu.common.security.annotation.EnableMyFeignClients; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * 系统模块 + * + * @author muyu + */ +@EnableCustomConfig +//@EnableCustomSwagger2 +@EnableMyFeignClients +@SpringBootApplication +public class CloudParsingApplication { + public static void main(String[] args) { + SpringApplication.run(CloudParsingApplication.class, args); + } + +} diff --git a/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/controller/SysCarMessageController.java b/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/controller/SysCarMessageController.java new file mode 100644 index 0000000..32b038c --- /dev/null +++ b/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/controller/SysCarMessageController.java @@ -0,0 +1,182 @@ +package com.muyu.parsing.controller; + +import com.alibaba.fastjson2.JSONObject; +import com.muyu.common.core.domain.Result; +import com.muyu.common.core.utils.poi.ExcelUtil; +import com.muyu.common.core.web.controller.BaseController; +import com.muyu.common.kafka.constants.KafkaConstants; +import com.muyu.common.security.annotation.RequiresPermissions; +import com.muyu.parsing.domain.KafKaData; +import com.muyu.parsing.domain.SysCarMessage; +import com.muyu.parsing.domain.resp.SysMessageResp; +import com.muyu.parsing.service.ISysCarMessageService; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.apache.kafka.clients.producer.KafkaProducer; +import org.apache.kafka.clients.producer.ProducerConfig; +import org.apache.kafka.clients.producer.ProducerRecord; +import org.apache.kafka.common.serialization.StringSerializer; +import org.eclipse.paho.client.mqttv3.*; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; + +/** + * 车辆报文记录Controller + * + * @author muyu + * @date 2024-09-18 + */ +@Slf4j +@RestController +@RequestMapping("/messageInfo") +public class SysCarMessageController extends BaseController { + @Resource + private ISysCarMessageService sysCarMessageService; + @Resource + private KafkaProducer kafkaProducer; + static String TEST = "56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56"; + +// @Autowired +// private KafkaTemplate kafkaTemplate; + + + /** + * 查询车辆报文记录列表 + */ +// @RequiresPermissions("message:message:list") + @Transactional + @GetMapping("/list") + public Result> list(SysCarMessage sysCarMessage) throws ExecutionException, InterruptedException { + + List list = sysCarMessageService.selectSysCarMessageList(sysCarMessage); + if (list == null || list.isEmpty()) { + return Result.error(); //为空返回错误信息 + } + List kafKaDataList = new ArrayList<>(); + String[] test = TEST.split(" "); + String[] results = new String[list.size()]; +// HashMap> futures = new HashMap<>(); + for (SysCarMessage carMessage : list) { + int start = Integer.parseInt(carMessage.getMessageStartIndex()) - 1; + int end = Integer.parseInt(carMessage.getMessageEndIndex()); + StringBuilder hexBuilder = new StringBuilder(); + for (int i = start; i < end; i++) { + hexBuilder.append(test[i]); + } + String hex = hexBuilder.toString(); + char[] result = new char[hex.length() / 2]; + for (int x = 0; x < hex.length(); x += 2) { + int high = Character.digit(hex.charAt(x), 16); + int low = Character.digit(hex.charAt(x + 1), 16); + result[x / 2] = (char) ((high << 4) + low); + } + String value = new String(result); + kafKaDataList.add(KafKaData.builder() + .key(carMessage.getMessageTypeCode()) + .label(carMessage.getMessageTypeCode()) + .value(value) + .type("String") + .build()); + } + +// String jsonString = """ +// [{ +// "key": "vin", +// "label": "VIN码", +// "type": "String", +// "value": "vin131413534474" +// },{ +// "key": "timestamp", +// "label": "时间戳", +// "type": "String", +// "value": "1727525252127" +// },{ +// "key": "latitude", +// "label": "纬度", +// "type": "String", +// "value": "66.898" +// },{ +// "key": "longitude", +// "label": "经度", +// "type": "String", +// "value": "99.124" +// }]"""; + String jsonString = JSONObject.toJSONString(kafKaDataList); + ProducerRecord producerRecord = new ProducerRecord<>(KafkaConstants.KafkaTopic, jsonString); + kafkaProducer.send(producerRecord); + log.info("消息发送成功:{}", jsonString); + return Result.success(list); + } + + + @RequiresPermissions("message:message:dobList") + @GetMapping("/dobList") + public Result> dobList(SysMessageResp sysMessageResp) { + List list = sysCarMessageService.dobList(sysMessageResp); + return Result.success(list); + } + + + /** + * 导出车辆报文记录列表 + */ + @RequiresPermissions("message:message:export") + @PostMapping("/export") + public void export(HttpServletResponse response, SysCarMessage sysCarMessage) { + List list = sysCarMessageService.selectSysCarMessageList(sysCarMessage); + ExcelUtil util = new ExcelUtil(SysCarMessage.class); + util.exportExcel(response, list, "车辆报文记录数据"); + } + + /** + * 获取车辆报文记录详细信息 + */ + @RequiresPermissions("message:message:query") + @GetMapping(value = "/{id}") + public Result> getInfo(@PathVariable("id") Long id) { + return success(sysCarMessageService.selectSysCarMessageById(id)); + } + + /** + * 新增车辆报文记录 + */ + @RequiresPermissions("message:message:add") + @PostMapping + public Result add( + @Validated @RequestBody SysCarMessage sysCarMessage) { + if (sysCarMessageService.checkIdUnique(sysCarMessage)) { + return error("新增 车辆报文记录 '" + sysCarMessage + "'失败,车辆报文记录已存在"); + } + return toAjax(sysCarMessageService.save(sysCarMessage)); + } + + /** + * 修改车辆报文记录 + */ + @RequiresPermissions("message:message:edit") + @PutMapping + public Result edit( + @Validated @RequestBody SysCarMessage sysCarMessage) { + if (!sysCarMessageService.checkIdUnique(sysCarMessage)) { + return error("修改 车辆报文记录 '" + sysCarMessage + "'失败,车辆报文记录不存在"); + } + return toAjax(sysCarMessageService.updateById(sysCarMessage)); + } + + /** + * 删除车辆报文记录 + */ + @RequiresPermissions("message:message:remove") + @DeleteMapping("/{ids}") + public Result remove(@PathVariable("ids") Long[] ids) { + sysCarMessageService.removeBatchByIds(Arrays.asList(ids)); + return success(); + } + +} diff --git a/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/domain/KafKaData.java b/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/domain/KafKaData.java new file mode 100644 index 0000000..c188170 --- /dev/null +++ b/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/domain/KafKaData.java @@ -0,0 +1,26 @@ +package com.muyu.parsing.domain; + +import lombok.*; + +import java.io.Serializable; + +/** + * 报文消息 ktlv + * + * @ClassName KafKaData + * @Description 描述 + * @Author Chen + * @Date 2024/9/28 20:41 + */ + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +@ToString// +public class KafKaData implements Serializable { + private String key; + private String value; + private String type; + private String label; +} diff --git a/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/domain/SysCarMessage.java b/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/domain/SysCarMessage.java new file mode 100644 index 0000000..8683e7b --- /dev/null +++ b/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/domain/SysCarMessage.java @@ -0,0 +1,67 @@ +package com.muyu.parsing.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.muyu.common.core.annotation.Excel; +import lombok.*; +import lombok.experimental.SuperBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.io.Serializable; + +/** + * 车辆报文记录对象 sys_car_message + * + * @author muyu + * @date 2024-09-18 + */ + +@Data +@Setter +@Getter +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +@TableName("sys_car_message") +public class SysCarMessage implements Serializable { + private static final long serialVersionUID = 1L; + + /** 自增主键 */ + @TableId( type = IdType.AUTO) + private Long id; + + /** 车辆型号编码 */ + @Excel(name = "车辆型号编码") + private String modelCode; + + /** 车辆报文类型编码 */ + @Excel(name = "i") + private String messageTypeCode; + + /** 开始位下标 */ + @Excel(name = "开始位下标") + private String messageStartIndex; + + /** 结束位下标 */ + @Excel(name = "结束位下标") + private String messageEndIndex; + + /** 报文分类 */ + @Excel(name = "报文分类") + private String messageType; + + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("modelCode", getModelCode()) + .append("messageTypeCode", getMessageTypeCode()) + .append("messageStartIndex", getMessageStartIndex()) + .append("messageEndIndex", getMessageEndIndex()) + .append("messageType", getMessageType()) + .toString(); + } +} diff --git a/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/domain/resp/SysMessageResp.java b/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/domain/resp/SysMessageResp.java new file mode 100644 index 0000000..b218863 --- /dev/null +++ b/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/domain/resp/SysMessageResp.java @@ -0,0 +1,22 @@ +package com.muyu.parsing.domain.resp; + +import lombok.Data; + +/** + * 车辆报文类型对象 sys_message_type + * + * @author muyu + * @date 2024-09-18 + */ + +@Data +public class SysMessageResp { + private static final long serialVersionUID = 1L; + private Long id; + private String modelCode; + private String messageTypeCode; + private String messageStartIndex; + private String messageEndIndex; + private String messageType; + private String messageName; +} diff --git a/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/mapper/SysCarMessageMapper.java b/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/mapper/SysCarMessageMapper.java new file mode 100644 index 0000000..df2e16a --- /dev/null +++ b/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/mapper/SysCarMessageMapper.java @@ -0,0 +1,20 @@ +package com.muyu.parsing.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +import com.muyu.parsing.domain.SysCarMessage; +import com.muyu.parsing.domain.resp.SysMessageResp; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 车辆报文记录Mapper接口 + * + * @author muyu + * @date 2024-09-18 + */ +@Mapper +public interface SysCarMessageMapper extends BaseMapper{ + ListdobList(SysMessageResp sysMessageResp); +} diff --git a/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/mqtt/MqttTest.java b/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/mqtt/MqttTest.java new file mode 100644 index 0000000..43dd7d8 --- /dev/null +++ b/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/mqtt/MqttTest.java @@ -0,0 +1,127 @@ +package com.muyu.parsing.mqtt; + +import com.alibaba.fastjson2.JSONObject; +import com.muyu.common.kafka.constants.KafkaConstants; +import com.muyu.parsing.domain.KafKaData; +import com.muyu.parsing.domain.SysCarMessage; +import com.muyu.parsing.service.impl.SysCarMessageServiceImpl; +import lombok.extern.slf4j.Slf4j; +import org.apache.kafka.clients.producer.KafkaProducer; +import org.apache.kafka.clients.producer.ProducerRecord; +import org.eclipse.paho.client.mqttv3.*; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; + + +/** + * mqtt + * + * @ClassName MqttTest + * @Description 描述 + * @Author Chen + * @Date 2024/9/28 23:49 + */ +@Slf4j +@Component +public class MqttTest { + private static final Integer ID = 1; + private static final Integer CODE = 1; + + @Resource + private KafkaProducer kafkaProducer; + @Resource + private SysCarMessageServiceImpl sysCarMessageService; + + @PostConstruct + public void Test() { + String topic = "vehicle"; + String content = "Message from MqttPublishSample"; + int qos = 2; + String broker = "tcp://106.15.136.7:1883"; + String clientId = "JavaSample"; + + try { + // 第三个参数为空,默认持久化策略 + MqttClient sampleClient = new MqttClient(broker, clientId); + MqttConnectOptions connOpts = new MqttConnectOptions(); + connOpts.setCleanSession(true); + System.out.println("Connecting to broker: " + broker); + sampleClient.connect(connOpts); + sampleClient.subscribe(topic, 0); + sampleClient.setCallback(new MqttCallback() { + // 连接丢失 + @Override + public void connectionLost(Throwable throwable) { + + } + + // 连接成功 + @Override + public void messageArrived(String s, MqttMessage mqttMessage) throws Exception { + List list = sysCarMessageService.selectSysCarMessageLists(ID); + String string = new String(mqttMessage.getPayload()); + log.info(new String(mqttMessage.getPayload())); + List kafKaDataList = new ArrayList<>(); + String[] test = string.split(" "); +// String[] results = new String[list.size()]; + for (SysCarMessage carMessage : list) { + int start = Integer.parseInt(carMessage.getMessageStartIndex()) - 1; + int end = Integer.parseInt(carMessage.getMessageEndIndex()); + StringBuilder hexBuilder = new StringBuilder(); + for (int i = start; i < end; i++) { + hexBuilder.append(test[i]); + } + String hex = hexBuilder.toString(); + char[] result = new char[hex.length() / 2]; + for (int x = 0; x < hex.length(); x += 2) { + int high = Character.digit(hex.charAt(x), 16); + int low = Character.digit(hex.charAt(x + 1), 16); + result[x / 2] = (char) ((high << 4) + low); + } + String value = new String(result); + kafKaDataList.add(KafKaData.builder() + .key(carMessage.getMessageTypeCode()) + .label(carMessage.getMessageTypeCode()) + .value(value) + .type(carMessage.getMessageType()) + .build()); + } + kafKaDataList.add(KafKaData.builder() + .key("firmCode") + .label("企业编码") + .value("firm01") + .type("String") + .build()); + String jsonString = JSONObject.toJSONString(kafKaDataList); + + ProducerRecord producerRecord = new ProducerRecord<>(KafkaConstants.KafkaTopic, jsonString); + kafkaProducer.send(producerRecord); + log.info("kafka投产:{}", jsonString); +// HashMap stringStringHashMap = new HashMap<>(); +// kafKaDataList.forEach(data -> stringStringHashMap.put(data.getKey(), data.getValue())); +// jsonString = JSONObject.toJSONString(stringStringHashMap); +// System.out.println(jsonString); + } + + + // 接收信息 + @Override + public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) { + + } + + }); + } catch (MqttException me) { + System.out.println("reason " + me.getReasonCode()); + System.out.println("msg " + me.getMessage()); + System.out.println("loc " + me.getLocalizedMessage()); + System.out.println("cause " + me.getCause()); + System.out.println("excep " + me); + me.printStackTrace(); + } + } +} diff --git a/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/service/ISysCarMessageService.java b/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/service/ISysCarMessageService.java new file mode 100644 index 0000000..66338af --- /dev/null +++ b/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/service/ISysCarMessageService.java @@ -0,0 +1,44 @@ +package com.muyu.parsing.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.muyu.parsing.domain.SysCarMessage; +import com.muyu.parsing.domain.resp.SysMessageResp; + + +import java.util.List; + +/** + * 车辆报文记录Service接口 + * + * @author muyu + * @date 2024-09-18 + */ +public interface ISysCarMessageService extends IService { + + ListdobList(SysMessageResp sysMessageResp); + /** + * 精确查询车辆报文记录 + * + * @param id 车辆报文记录主键 + * @return 车辆报文记录 + */ + public SysCarMessage selectSysCarMessageById(Long id); + + /** + * 查询车辆报文记录列表 + * + * @param sysCarMessage 车辆报文记录 + * @return 车辆报文记录集合 + */ + public List selectSysCarMessageList(SysCarMessage sysCarMessage); + + /** + * 判断 车辆报文记录 id是否唯一 + * @param sysCarMessage 车辆报文记录 + * @return 结果 + */ + Boolean checkIdUnique(SysCarMessage sysCarMessage); + +// Boolean checkById(SysCarMessage sysCarMessage); + +} diff --git a/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/service/impl/SysCarMessageServiceImpl.java b/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/service/impl/SysCarMessageServiceImpl.java new file mode 100644 index 0000000..2b7bdc8 --- /dev/null +++ b/cloud-modules/cloud-modules-parsing/src/main/java/com/muyu/parsing/service/impl/SysCarMessageServiceImpl.java @@ -0,0 +1,97 @@ +package com.muyu.parsing.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + +import com.muyu.common.core.utils.StringUtils; +import com.muyu.parsing.domain.SysCarMessage; +import com.muyu.parsing.domain.resp.SysMessageResp; +import com.muyu.parsing.mapper.SysCarMessageMapper; +import com.muyu.parsing.service.ISysCarMessageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +import java.util.List; + +/** + * 车辆报文记录Service业务层处理 + * + * @author muyu + * @date 2024-09-18 + */ +@Service +public class SysCarMessageServiceImpl + extends ServiceImpl + implements ISysCarMessageService { + @Autowired + private SysCarMessageMapper mapper; + + @Override + public List dobList(SysMessageResp sysMessageResp) { + return mapper.dobList(sysMessageResp); + } + + /** + * 精确查询车辆报文记录 + * + * @param id 车辆报文记录主键 + * @return 车辆报文记录 + */ + @Override + public SysCarMessage selectSysCarMessageById(Long id) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + Assert.notNull(id, "id不可为空"); + queryWrapper.eq(SysCarMessage::getId, id); + return this.getOne(queryWrapper); + } + + + /** + * 查询车辆报文记录列表 + * + * @param sysCarMessage 车辆报文记录 + * @return 车辆报文记录 + */ + @Override + public List selectSysCarMessageList(SysCarMessage sysCarMessage) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + if (StringUtils.isNotEmpty(sysCarMessage.getModelCode())) { + queryWrapper.eq(SysCarMessage::getModelCode, sysCarMessage.getModelCode()); + } + if (StringUtils.isNotEmpty(sysCarMessage.getMessageType())) { + queryWrapper.eq(SysCarMessage::getMessageType, sysCarMessage.getMessageType()); + } + return this.list(queryWrapper); + } + + /** + * 唯一 判断 + * + * @param sysCarMessage 车辆报文记录 + * @return 车辆报文记录 + */ + @Override + public Boolean checkIdUnique(SysCarMessage sysCarMessage) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(SysCarMessage::getId, sysCarMessage.getId()); + return this.count(queryWrapper) > 0; + } + + public List selectSysCarMessageLists(int id) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(SysCarMessage::getModelCode, id); +// queryWrapper.eq(SysCarMessage::getMessageType, modelCode); + return this.list(queryWrapper); + } +// +// @Override +// public Boolean checkById(SysMessageType sysMessageType) { +// LambdaQueryWrapper sysCarMessageLambdaQueryWrapper = new LambdaQueryWrapper<>(); +// sysCarMessageLambdaQueryWrapper.eq(SysCarMessage::getMessageType, sysMessageType); +//// sysCarMessageLambdaQueryWrapper.eq(SysCarMessage::getMessageType, sysMessageType); +// sysCarMessageLambdaQueryWrapper.eq(SysCarMessage::get, sysMessageType); +//// return this.count(sysCarMessageLambdaQueryWrapper) > 0; +// } + +} diff --git a/cloud-modules/cloud-modules-parsing/src/main/resources/banner.txt b/cloud-modules/cloud-modules-parsing/src/main/resources/banner.txt new file mode 100644 index 0000000..0dd5eee --- /dev/null +++ b/cloud-modules/cloud-modules-parsing/src/main/resources/banner.txt @@ -0,0 +1,2 @@ +Spring Boot Version: ${spring-boot.version} +Spring Application Name: ${spring.application.name} diff --git a/cloud-modules/cloud-modules-parsing/src/main/resources/bootstrap.yml b/cloud-modules/cloud-modules-parsing/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..e940514 --- /dev/null +++ b/cloud-modules/cloud-modules-parsing/src/main/resources/bootstrap.yml @@ -0,0 +1,77 @@ +# Tomcat +server: + port: 10010 + +# nacos线上地址 +nacos: + addr: 49.235.136.60:8848 + user-name: nacos + password: nacos + namespace: wyh +# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all +# Spring +spring: + amqp: + deserialization: + trust: + all: true + main: + allow-bean-definition-overriding: true + application: + # 应用名称 + name: cloud-parsing + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: ${nacos.addr} + # # nacos用户名 + # username: ${nacos.user-name} + # # nacos密码 + # password: ${nacos.password} + # 命名空间 + namespace: ${nacos.namespace} + config: + # 服务注册地址 + server-addr: ${nacos.addr} + # # nacos用户名 + # username: ${nacos.user-name} + # # nacos密码 + # password: ${nacos.password} + # 命名空间 + namespace: ${nacos.namespace} + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + # 系统共享配置 + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + # 系统环境Config共享配置 + - application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + # xxl-job 配置文件 + - application-xxl-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + # rabbit 配置文件 + - application-rabbit-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} +logging: + level: + com.muyu.system.mapper: DEBUG +#mqtt: +# host:tcp://172.0.0.1:1883 +# userName: root +# passWord: 11 +### MQTT## +mqtt: + host: tcp://192.168.10.198:1883 + userName: root + passWord: 123456 + qos: 1 + clientId: ClientId_local #ClientId_local必须唯一 比如你已经定了叫ABC 那你就一直叫ABC 其他地方就不要使用ABC了 + timeout: 10 + keepalive: 20 + topic1: A/pick/warn/# #符号是代表整个warn下面的全部子主题 没有理解的话 可以百度仔细理解一下 + topic2: A/cmd/resp + topic3: ABCF + topic4: ABCH diff --git a/cloud-modules/cloud-modules-parsing/src/main/resources/logback/dev.xml b/cloud-modules/cloud-modules-parsing/src/main/resources/logback/dev.xml new file mode 100644 index 0000000..d1b5629 --- /dev/null +++ b/cloud-modules/cloud-modules-parsing/src/main/resources/logback/dev.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + ${log.pattern} + + + + + + ${log.path}/info.log + + + + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/error.log + + + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + ERROR + + ACCEPT + + DENY + + + + + + + + + + + + + + + + + + diff --git a/cloud-modules/cloud-modules-parsing/src/main/resources/logback/prod.xml b/cloud-modules/cloud-modules-parsing/src/main/resources/logback/prod.xml new file mode 100644 index 0000000..76a0d8f --- /dev/null +++ b/cloud-modules/cloud-modules-parsing/src/main/resources/logback/prod.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + ${log.sky.pattern} + + + + + + ${log.path}/info.log + + + + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/error.log + + + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + + + ERROR + + ACCEPT + + DENY + + + + + + + + ${log.sky.pattern} + + + + + + + + + + + + + + + + + + + + diff --git a/cloud-modules/cloud-modules-parsing/src/main/resources/logback/test.xml b/cloud-modules/cloud-modules-parsing/src/main/resources/logback/test.xml new file mode 100644 index 0000000..76a0d8f --- /dev/null +++ b/cloud-modules/cloud-modules-parsing/src/main/resources/logback/test.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + ${log.sky.pattern} + + + + + + ${log.path}/info.log + + + + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/error.log + + + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + + + ERROR + + ACCEPT + + DENY + + + + + + + + ${log.sky.pattern} + + + + + + + + + + + + + + + + + + + + diff --git a/cloud-modules/pom.xml b/cloud-modules/pom.xml index 8abfb62..82e9797 100644 --- a/cloud-modules/pom.xml +++ b/cloud-modules/pom.xml @@ -14,6 +14,7 @@ cloud-modules-file cloud-modules-openbusiness cloud-modules-data-processing + cloud-modules-parsing cloud-modules