3/28Dxd提交2

server_five_liuyunhu
dongxiaodong 2024-03-31 15:01:17 +08:00
parent 21045e1d5a
commit 77045a3977
16 changed files with 260 additions and 43 deletions

View File

@ -0,0 +1,34 @@
package com.couplet.common.core.domain;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @author DongZl
* @description:
*/
@Data
public class PageResult<T> implements Serializable {
/**
*
*/
private long total;
/**
*
*/
private List<T> list;
public PageResult() {
}
public PageResult(long total, List<T> list) {
this.total = total;
this.list = list;
}
public static <T> PageResult<T> toPageResult(long total, List<T> list){
return new PageResult(total , list);
}
public static <T> Result<PageResult<T>> toResult(long total, List<T> list){
return Result.success(PageResult.toPageResult(total,list));
}
}

View File

@ -58,6 +58,7 @@ public class BaseEntity implements Serializable {
/**
*
*/
@TableField(exist = false)
private String remark;
/**

View File

@ -1,5 +1,8 @@
package com.couplet.common.system.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.couplet.common.core.web.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
@ -82,11 +85,13 @@ public class SysDept extends BaseEntity {
/**
*
*/
@TableField(exist = false)
private String parentName;
/**
*
*/
@TableField(exist = false)
private List<SysDept> children = new ArrayList<SysDept>();
public Long getDeptId () {

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.couplet</groupId>
<artifactId>couplet-modules</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>couplet-msg</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

View File

@ -0,0 +1,44 @@
package com.couplet.msg;
import java.util.ArrayList;
import java.util.List;
/**
* @author DongXiaoDong
* @version 1.0
* @date 2024/3/30 14:40
* @description
*/
public class Msg {
private static final List<String> hexDataList = new ArrayList<String>() {{
add("56 49 4e 31 32 33 34 35 36 37 38 39 44 49 4a 45 34 31 37 31 31 37 36 34 31 30 34 35 30 36 31 31 36 2e 36 36 34 33 38 30 30 33 39 2e 35 33 31 39 39 30 30 37 32 2e 30 30 30 33 31 2e 33 37 36 30 30 30 30 30 32 32 30 30 30 30 32 32 30 30 30 38 35 32 30 30 30 30 30 30 44 30 30 38 30 39 2e 36 30 30 39 34 30 30 30 30 35 38 39 30 36 36 37 39 30 39 33 30 30 30 30 32 30 33 30 30 32 30 33 30 30 30 30 30 34 34 32 38 32 2e 35 35 30 30 30 30 31 34 30 30 30 30 38 30 37 30 30 30 30 37 34 34 30 30 30 33 30 30 30 34 30 30 30 39 35 30 30 30 30 35 38 30 30 30 30 35 34 30 30 30 30 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 24");
}};
public static void main(String[] args) {
for (String hexData : hexDataList) {
int checksum = calculateChecksum(hexData);
System.out.println("Checksum: " + Integer.toHexString(checksum & 0xFF).toUpperCase());
}
}
private static int calculateChecksum(String hexData) {
// 将空格删除并将字符串转换为字符数组
String[] hexArray = hexData.replaceAll("\\s", "").split("");
// 将十六进制字符转换为字节数组
byte[] bytes = new byte[hexArray.length / 2];
for (int i = 0; i < hexArray.length; i += 2) {
String hex = hexArray[i] + hexArray[i + 1];
bytes[i / 2] = (byte) Integer.parseInt(hex, 16);
}
// 计算校验和
int sum = 0;
for (byte b : bytes) {
sum += b;
}
// 取低位字节
return sum & 0xFF;
}
}

View File

@ -0,0 +1,36 @@
package com.couplet.msg;
import java.util.ArrayList;
import java.util.List;
/**
* @author DongXiaoDong
* @version 1.0
* @date 2024/3/30 11:39
* @description
*/
public class ParsingMsg {
private static final List<String> msgList = new ArrayList<>(){{
add("7E 56 49 4e 31 32 33 34 35 36 37 38 39 44 49 4a 45 34 31 37 31 31 37 36 34 31 30 34 35 30 36 31 31 36 2e 36 36 34 33 38 30 30 33 39 2e 35 33 31 39 39 30 30 37 32 2e 30 30 30 33 31 2e 33 37 36 30 30 30 30 30 32 32 30 30 30 30 32 32 30 30 30 38 35 32 30 30 30 30 30 30 44 30 30 38 30 39 2e 36 30 30 39 34 30 30 30 30 35 38 39 30 36 36 37 39 30 39 33 30 30 30 30 32 30 33 30 30 32 30 33 30 30 30 30 30 34 34 32 38 32 2e 35 35 30 30 30 30 31 34 30 30 30 30 38 30 37 30 30 30 30 37 34 34 30 30 30 33 30 30 30 34 30 30 30 39 35 30 30 30 30 35 38 30 30 30 30 35 34 30 30 30 30 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 24 7E");
}};
public static void main(String[] args) {
for (String string : msgList) {
String substring = string.substring(2, string.length() - 2);
System.out.println(substring);
}
}
// private static String decodeHexString(String hexString) {
// //将第一个和最后一个字符删除
// hexString = hexString.substring(2, hexString.length() - 2);
//
// //将十六进制字符转换为字节数组
//// byte[] bytes = new byte[hexArray.length / 2];
//// for (int i = 0; i < hexArray.length; i +=2) {
//// String hex = hexArray[i] + hexArray[i + 1];
//// bytes[i / 2] = (byte) Integer.parseInt(hex, 16);
//// }
// return new String(hexString);
// }
}

View File

@ -1,18 +1,19 @@
package com.couplet.trouble.controller;
import com.couplet.common.core.domain.PageResult;
import com.couplet.common.core.domain.Result;
import com.couplet.common.core.web.controller.BaseController;
import com.couplet.common.core.web.page.TableDataInfo;
import com.couplet.common.log.annotation.Log;
import com.couplet.common.log.enums.BusinessType;
import com.couplet.trouble.domain.coupletTroubleCode;
import com.couplet.trouble.domain.req.TroubleUpdReq;
import com.couplet.trouble.domain.CoupletTroubleCode;
import com.couplet.trouble.domain.CoupletTroubleGrade;
import com.couplet.trouble.domain.CoupletTroubleType;
import com.couplet.trouble.domain.resp.TroubleResp;
import com.couplet.trouble.service.SysTroubleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
@ -28,13 +29,28 @@ public class SysTroubleController extends BaseController {
private SysTroubleService troubleService;
/**
*
*
*/
@GetMapping("/troubleList")
public Result<TableDataInfo<coupletTroubleCode>> list(@RequestBody coupletTroubleCode trouble) {
startPage();
List<coupletTroubleCode> list = troubleService.selectTroubleList(trouble);
return getDataTable(list);
public Result<PageResult<CoupletTroubleCode>> list(TroubleResp troubleReq) {
PageResult<CoupletTroubleCode> result = troubleService.selectTroubleList(troubleReq);
return Result.success(result);
}
/**
*
*/
@GetMapping("/troubleTypeList")
public List<CoupletTroubleType> listType() {
return troubleService.selectTroubleListByType();
}
/**
*
*/
@GetMapping("/troubleGradeList")
public List<CoupletTroubleGrade> listGrade() {
return troubleService.selectTroubleListByGrade();
}
/**
@ -42,16 +58,16 @@ public class SysTroubleController extends BaseController {
*/
@Log(title = "新增故障码数据", businessType = BusinessType.INSERT)
@PostMapping("insertTrouble")
public Result<?> insert(@Validated @RequestBody coupletTroubleCode troubleAddReq) {
public Result<?> insert(@Validated @RequestBody CoupletTroubleCode troubleAddReq) {
return toAjax(troubleService.save(troubleAddReq));
}
/**
*
*
*/
@Log(title = "修改故障码数据",businessType = BusinessType.UPDATE)
@PostMapping("updateTrouble")
public Result<?> edit(@Validated @RequestBody coupletTroubleCode troubleUpdReq) {
public Result<?> edit(@Validated @RequestBody CoupletTroubleCode troubleUpdReq) {
return toAjax(troubleService.updateById(troubleUpdReq));
}
@ -60,7 +76,7 @@ public class SysTroubleController extends BaseController {
*/
@Log(title = "删除故障码",businessType = BusinessType.DELETE)
@GetMapping("/remove/{troubleId}")
public Result<?> remove(@PathVariable Long troubleId) {
public Result<?> remove(@PathVariable Integer troubleId) {
troubleService.removeById(troubleId);
return success();
}

View File

@ -3,7 +3,6 @@ package com.couplet.trouble.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.couplet.common.core.annotation.Excel;
import com.couplet.common.core.web.domain.BaseEntity;
import lombok.*;
import lombok.experimental.SuperBuilder;
@ -18,7 +17,7 @@ import lombok.experimental.SuperBuilder;
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class coupletTroubleCode {
public class CoupletTroubleCode {
/**
* id
*/
@ -53,10 +52,12 @@ public class coupletTroubleCode {
/**
* Id
*/
private Integer troubleTypeId;
@Excel(name = "故障类型Id")
private Integer typeId;
/**
* Id
*/
private Integer troubleGradeId;
@Excel(name = "故障等级Id")
private Integer gradeId;
}

View File

@ -9,7 +9,7 @@ import lombok.Data;
* @description
*/
@Data
public class coupletTroubleGrade {
public class CoupletTroubleGrade {
private Integer gradeId;
private String gradeName;
}

View File

@ -9,7 +9,7 @@ import lombok.Data;
* @description
*/
@Data
public class coupletTroubleType {
public class CoupletTroubleType {
private Integer typeId;
private String typeName;
}

View File

@ -0,0 +1,26 @@
package com.couplet.trouble.domain.resp;
import com.couplet.trouble.domain.CoupletTroubleCode;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author DongXiaoDong
* @version 1.0
* @date 2024/3/30 19:22
* @description
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class TroubleResp extends CoupletTroubleCode implements Serializable {
private Integer pageNum=1;
private Integer pageSize=5;
private String troubleCode;
private String troublePosition;
}

View File

@ -1,9 +1,10 @@
package com.couplet.trouble.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.couplet.trouble.domain.coupletTroubleCode;
import com.couplet.trouble.domain.req.TroubleAddReq;
import com.couplet.trouble.domain.req.TroubleUpdReq;
import com.couplet.trouble.domain.CoupletTroubleCode;
import com.couplet.trouble.domain.CoupletTroubleGrade;
import com.couplet.trouble.domain.CoupletTroubleType;
import com.couplet.trouble.domain.resp.TroubleResp;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@ -15,8 +16,12 @@ import java.util.List;
* @description
*/
@Mapper
public interface SysTroubleMapper extends BaseMapper<coupletTroubleCode> {
List<coupletTroubleCode> selectTroubleList(coupletTroubleCode trouble);
public interface SysTroubleMapper extends BaseMapper<CoupletTroubleCode> {
List<CoupletTroubleCode> selectTroubleList(TroubleResp troubleReq);
List<CoupletTroubleType> selectTroubleListByType();
List<CoupletTroubleGrade> selectTroubleListByGrade();
// int addTrouble(TroubleAddReq troubleAddReq);

View File

@ -1,9 +1,11 @@
package com.couplet.trouble.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.couplet.trouble.domain.coupletTroubleCode;
import com.couplet.trouble.domain.req.TroubleAddReq;
import com.couplet.trouble.domain.req.TroubleUpdReq;
import com.couplet.common.core.domain.PageResult;
import com.couplet.trouble.domain.CoupletTroubleCode;
import com.couplet.trouble.domain.CoupletTroubleGrade;
import com.couplet.trouble.domain.CoupletTroubleType;
import com.couplet.trouble.domain.resp.TroubleResp;
import java.util.List;
@ -13,8 +15,12 @@ import java.util.List;
* @date 2024/3/26 22:38
* @description
*/
public interface SysTroubleService extends IService<coupletTroubleCode> {
List<coupletTroubleCode> selectTroubleList(coupletTroubleCode trouble);
public interface SysTroubleService extends IService<CoupletTroubleCode> {
PageResult<CoupletTroubleCode> selectTroubleList(TroubleResp troubleReq);
List<CoupletTroubleType> selectTroubleListByType();
List<CoupletTroubleGrade> selectTroubleListByGrade();
// int addTrouble (TroubleAddReq troubleAddReq);

View File

@ -1,11 +1,15 @@
package com.couplet.trouble.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.couplet.trouble.domain.coupletTroubleCode;
import com.couplet.trouble.domain.req.TroubleAddReq;
import com.couplet.trouble.domain.req.TroubleUpdReq;
import com.couplet.common.core.domain.PageResult;
import com.couplet.trouble.domain.CoupletTroubleCode;
import com.couplet.trouble.domain.CoupletTroubleGrade;
import com.couplet.trouble.domain.CoupletTroubleType;
import com.couplet.trouble.domain.resp.TroubleResp;
import com.couplet.trouble.mapper.SysTroubleMapper;
import com.couplet.trouble.service.SysTroubleService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -18,19 +22,32 @@ import java.util.List;
* @description
*/
@Service
public class SysTroubleServiceImpl extends ServiceImpl<SysTroubleMapper, coupletTroubleCode> implements SysTroubleService{
public class SysTroubleServiceImpl extends ServiceImpl<SysTroubleMapper, CoupletTroubleCode> implements SysTroubleService{
@Autowired
private SysTroubleMapper sysTroubleMapper;
/**
*
* @param trouble
* @param troubleReq
* @return
*/
@Override
public List<coupletTroubleCode> selectTroubleList(coupletTroubleCode trouble) {
return sysTroubleMapper.selectTroubleList(trouble);
public PageResult<CoupletTroubleCode> selectTroubleList(TroubleResp troubleReq) {
PageHelper.startPage(troubleReq.getPageNum(), troubleReq.getPageSize());
List<CoupletTroubleCode> troubleList = sysTroubleMapper.selectTroubleList(troubleReq);
PageInfo<CoupletTroubleCode> info = new PageInfo<>(troubleList);
return PageResult.toPageResult(info.getTotal(),troubleList);
}
@Override
public List<CoupletTroubleType> selectTroubleListByType() {
return sysTroubleMapper.selectTroubleListByType();
}
@Override
public List<CoupletTroubleGrade> selectTroubleListByGrade() {
return sysTroubleMapper.selectTroubleListByGrade();
}
/**

View File

@ -4,20 +4,20 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.couplet.trouble.mapper.SysTroubleMapper">
<resultMap type="com.couplet.trouble.domain.coupletTroubleCode" id="SysTroubleResult">
<resultMap type="com.couplet.trouble.domain.CoupletTroubleCode" id="SysTroubleResult">
<id property="troubleId" column="trouble_id"/>
<result property="troubleCode" column="trouble_code"/>
<result property="troubleGradeId" column="trouble_gradeId"/>
<result property="troubleValue" column="trouble_value"/>
<result property="troublePosition" column="trouble_position"/>
<result property="troubleTag" column="trouble_tag"/>
<result property="troubleTypeId" column="trouble_typeId"/>
<result property="troubleValue" column="trouble_value"/>
<result property="typeId" column="type_id"/>
<result property="gradeId" column="grade_id"/>
</resultMap>
<sql id="selectTroubleVo">
select t.*,g.grade_name,y.type_name from couplet_trouble_code t
LEFT JOIN couplet_trouble_grade g on t.trouble_grade_id = g.grade_id
LEFT JOIN couplet_trouble_type y on t.trouble_type_id= y.type_id
LEFT JOIN couplet_trouble_grade g on t.grade_id = g.grade_id
LEFT JOIN couplet_trouble_type y on t.type_id= y.type_id
</sql>
<!-- <insert id="addTrouble">-->
<!-- insert into couplet_trouble_code (trouble_code,trouble_position,trouble_value,trouble_tag,trouble_type_id,trouble_grade_id)-->
@ -56,7 +56,12 @@
AND trouble_position like concat('%', #{troublePosition}, '%')
</if>
</where>
order by trouble_position desc
</select>
<select id="selectTroubleListByType" resultType="com.couplet.trouble.domain.CoupletTroubleType">
select * from couplet_trouble_type
</select>
<select id="selectTroubleListByGrade" resultType="com.couplet.trouble.domain.CoupletTroubleGrade">
select * from couplet_trouble_grade
</select>

View File

@ -18,6 +18,7 @@
<module>couplet-modules-vehicle</module>
<module>couplet-modules-mqtt</module>
<module>couplet-enterprisemanagement</module>
<module>couplet-msg</module>
</modules>
<artifactId>couplet-modules</artifactId>