diff --git a/couplet-common/couplet-common-core/src/main/java/com/couplet/common/core/domain/PageResult.java b/couplet-common/couplet-common-core/src/main/java/com/couplet/common/core/domain/PageResult.java new file mode 100644 index 0000000..e96db7f --- /dev/null +++ b/couplet-common/couplet-common-core/src/main/java/com/couplet/common/core/domain/PageResult.java @@ -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 implements Serializable { + /** + * 总条数 + */ + private long total; + /** + * 结果集合 + */ + private List list; + public PageResult() { + } + public PageResult(long total, List list) { + this.total = total; + this.list = list; + } + public static PageResult toPageResult(long total, List list){ + return new PageResult(total , list); + } + public static Result> toResult(long total, List list){ + return Result.success(PageResult.toPageResult(total,list)); + } +} diff --git a/couplet-common/couplet-common-core/src/main/java/com/couplet/common/core/web/domain/BaseEntity.java b/couplet-common/couplet-common-core/src/main/java/com/couplet/common/core/web/domain/BaseEntity.java index 89f2da1..d3422d4 100644 --- a/couplet-common/couplet-common-core/src/main/java/com/couplet/common/core/web/domain/BaseEntity.java +++ b/couplet-common/couplet-common-core/src/main/java/com/couplet/common/core/web/domain/BaseEntity.java @@ -58,6 +58,7 @@ public class BaseEntity implements Serializable { /** * 备注 */ + @TableField(exist = false) private String remark; /** diff --git a/couplet-common/couplet-common-system/src/main/java/com/couplet/common/system/domain/SysDept.java b/couplet-common/couplet-common-system/src/main/java/com/couplet/common/system/domain/SysDept.java index 85f67b2..50b7ff0 100644 --- a/couplet-common/couplet-common-system/src/main/java/com/couplet/common/system/domain/SysDept.java +++ b/couplet-common/couplet-common-system/src/main/java/com/couplet/common/system/domain/SysDept.java @@ -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 children = new ArrayList(); public Long getDeptId () { diff --git a/couplet-modules/couplet-msg/pom.xml b/couplet-modules/couplet-msg/pom.xml new file mode 100644 index 0000000..43d94b1 --- /dev/null +++ b/couplet-modules/couplet-msg/pom.xml @@ -0,0 +1,20 @@ + + + 4.0.0 + + com.couplet + couplet-modules + 3.6.3 + + + couplet-msg + + + 17 + 17 + UTF-8 + + + diff --git a/couplet-modules/couplet-msg/src/test/java/com/couplet/msg/Msg.java b/couplet-modules/couplet-msg/src/test/java/com/couplet/msg/Msg.java new file mode 100644 index 0000000..7abfc7d --- /dev/null +++ b/couplet-modules/couplet-msg/src/test/java/com/couplet/msg/Msg.java @@ -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 hexDataList = new ArrayList() {{ + 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; + } +} diff --git a/couplet-modules/couplet-msg/src/test/java/com/couplet/msg/ParsingMsg.java b/couplet-modules/couplet-msg/src/test/java/com/couplet/msg/ParsingMsg.java new file mode 100644 index 0000000..c933c5c --- /dev/null +++ b/couplet-modules/couplet-msg/src/test/java/com/couplet/msg/ParsingMsg.java @@ -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 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); +// } +} diff --git a/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/controller/SysTroubleController.java b/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/controller/SysTroubleController.java index 766a579..af53d0c 100644 --- a/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/controller/SysTroubleController.java +++ b/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/controller/SysTroubleController.java @@ -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> list(@RequestBody coupletTroubleCode trouble) { - startPage(); - List list = troubleService.selectTroubleList(trouble); - return getDataTable(list); + public Result> list(TroubleResp troubleReq) { + PageResult result = troubleService.selectTroubleList(troubleReq); + return Result.success(result); + } + + /** + * 故障类型信息 + */ + @GetMapping("/troubleTypeList") + public List listType() { + return troubleService.selectTroubleListByType(); + } + + /** + * 故障等级信息 + */ + @GetMapping("/troubleGradeList") + public List 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(); } diff --git a/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/domain/coupletTroubleCode.java b/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/domain/CoupletTroubleCode.java similarity index 86% rename from couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/domain/coupletTroubleCode.java rename to couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/domain/CoupletTroubleCode.java index 9745629..22e5fc5 100644 --- a/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/domain/coupletTroubleCode.java +++ b/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/domain/CoupletTroubleCode.java @@ -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; } diff --git a/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/domain/coupletTroubleGrade.java b/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/domain/CoupletTroubleGrade.java similarity index 85% rename from couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/domain/coupletTroubleGrade.java rename to couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/domain/CoupletTroubleGrade.java index 0d9ecc3..a4eef19 100644 --- a/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/domain/coupletTroubleGrade.java +++ b/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/domain/CoupletTroubleGrade.java @@ -9,7 +9,7 @@ import lombok.Data; * @description */ @Data -public class coupletTroubleGrade { +public class CoupletTroubleGrade { private Integer gradeId; private String gradeName; } diff --git a/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/domain/coupletTroubleType.java b/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/domain/CoupletTroubleType.java similarity index 86% rename from couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/domain/coupletTroubleType.java rename to couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/domain/CoupletTroubleType.java index 408bfcc..aedb004 100644 --- a/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/domain/coupletTroubleType.java +++ b/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/domain/CoupletTroubleType.java @@ -9,7 +9,7 @@ import lombok.Data; * @description */ @Data -public class coupletTroubleType { +public class CoupletTroubleType { private Integer typeId; private String typeName; } diff --git a/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/domain/resp/TroubleResp.java b/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/domain/resp/TroubleResp.java new file mode 100644 index 0000000..5394d62 --- /dev/null +++ b/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/domain/resp/TroubleResp.java @@ -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; +} diff --git a/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/mapper/SysTroubleMapper.java b/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/mapper/SysTroubleMapper.java index fc06c16..e447574 100644 --- a/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/mapper/SysTroubleMapper.java +++ b/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/mapper/SysTroubleMapper.java @@ -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 { - List selectTroubleList(coupletTroubleCode trouble); +public interface SysTroubleMapper extends BaseMapper { + List selectTroubleList(TroubleResp troubleReq); + + List selectTroubleListByType(); + + List selectTroubleListByGrade(); // int addTrouble(TroubleAddReq troubleAddReq); diff --git a/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/service/SysTroubleService.java b/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/service/SysTroubleService.java index 2a66cde..abf803f 100644 --- a/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/service/SysTroubleService.java +++ b/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/service/SysTroubleService.java @@ -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 { - List selectTroubleList(coupletTroubleCode trouble); +public interface SysTroubleService extends IService { + PageResult selectTroubleList(TroubleResp troubleReq); + + List selectTroubleListByType(); + + List selectTroubleListByGrade(); // int addTrouble (TroubleAddReq troubleAddReq); diff --git a/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/service/impl/SysTroubleServiceImpl.java b/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/service/impl/SysTroubleServiceImpl.java index 8855cc8..5fc5d79 100644 --- a/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/service/impl/SysTroubleServiceImpl.java +++ b/couplet-modules/couplet-trouble/src/main/java/com/couplet/trouble/service/impl/SysTroubleServiceImpl.java @@ -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 implements SysTroubleService{ +public class SysTroubleServiceImpl extends ServiceImpl implements SysTroubleService{ @Autowired private SysTroubleMapper sysTroubleMapper; /** * 查询故障码列表 - * @param trouble + * @param troubleReq * @return */ @Override - public List selectTroubleList(coupletTroubleCode trouble) { - return sysTroubleMapper.selectTroubleList(trouble); + public PageResult selectTroubleList(TroubleResp troubleReq) { + PageHelper.startPage(troubleReq.getPageNum(), troubleReq.getPageSize()); + List troubleList = sysTroubleMapper.selectTroubleList(troubleReq); + PageInfo info = new PageInfo<>(troubleList); + return PageResult.toPageResult(info.getTotal(),troubleList); + } + + @Override + public List selectTroubleListByType() { + return sysTroubleMapper.selectTroubleListByType(); + } + + @Override + public List selectTroubleListByGrade() { + return sysTroubleMapper.selectTroubleListByGrade(); } /** diff --git a/couplet-modules/couplet-trouble/src/main/resources/mapper/trouble/SysTroubleMapper.xml b/couplet-modules/couplet-trouble/src/main/resources/mapper/trouble/SysTroubleMapper.xml index 24417e5..3f5189f 100644 --- a/couplet-modules/couplet-trouble/src/main/resources/mapper/trouble/SysTroubleMapper.xml +++ b/couplet-modules/couplet-trouble/src/main/resources/mapper/trouble/SysTroubleMapper.xml @@ -4,20 +4,20 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + - + - - + + 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 @@ -56,7 +56,12 @@ AND trouble_position like concat('%', #{troublePosition}, '%') - order by trouble_position desc + + + diff --git a/couplet-modules/pom.xml b/couplet-modules/pom.xml index 6594626..082ecd2 100644 --- a/couplet-modules/pom.xml +++ b/couplet-modules/pom.xml @@ -18,6 +18,7 @@ couplet-modules-vehicle couplet-modules-mqtt couplet-enterprisemanagement + couplet-msg couplet-modules