Kaynağa Gözat

地磅数据

chenxiaofei 1 ay önce
ebeveyn
işleme
0db7036d93
30 değiştirilmiş dosya ile 2194 ekleme ve 1 silme
  1. 4 0
      iot-platform-common/pom.xml
  2. 11 0
      iot-platform-common/src/main/java/com/platform/exception/IotException.java
  3. 88 0
      iot-platform-common/src/main/java/com/platform/result/HttpV1Result.java
  4. 263 0
      iot-platform-common/src/main/java/com/platform/result/HttpV1Status.java
  5. 148 0
      iot-platform-common/src/main/java/com/platform/result/PageResult.java
  6. 8 1
      iot-platform-manager/pom.xml
  7. 92 0
      iot-platform-manager/src/main/java/com/platform/api/controller/KwsWeighbridgeController.java
  8. 636 0
      iot-platform-manager/src/main/java/com/platform/api/manager/KwsWeighbridgeManageService.java
  9. 48 0
      iot-platform-manager/src/main/java/com/platform/api/request/WeighbridgeDiffConfigReqVo.java
  10. 36 0
      iot-platform-manager/src/main/java/com/platform/api/request/WeighbridgePageReqVo.java
  11. 26 0
      iot-platform-manager/src/main/java/com/platform/api/request/WeighbridgeRestartReqVo.java
  12. 71 0
      iot-platform-manager/src/main/java/com/platform/api/request/WeighbridgeSaveReqVo.java
  13. 30 0
      iot-platform-manager/src/main/java/com/platform/api/request/WeighbridgeStatusReqVo.java
  14. 24 0
      iot-platform-manager/src/main/java/com/platform/api/response/PlatformEnterpriseResVo.java
  15. 25 0
      iot-platform-manager/src/main/java/com/platform/api/response/WeighbridgeDetailResVo.java
  16. 55 0
      iot-platform-manager/src/main/java/com/platform/api/response/WeighbridgeDiffConfigResVo.java
  17. 106 0
      iot-platform-manager/src/main/java/com/platform/api/response/WeighbridgePageResVo.java
  18. 78 0
      iot-platform-manager/src/main/java/com/platform/entity/KwsPrinter.java
  19. 88 0
      iot-platform-manager/src/main/java/com/platform/entity/KwsWeighbridge.java
  20. 62 0
      iot-platform-manager/src/main/java/com/platform/entity/KwsWeighbridgeDiffConfig.java
  21. 59 0
      iot-platform-manager/src/main/java/com/platform/entity/KwsWeighbridgeRecord.java
  22. 9 0
      iot-platform-manager/src/main/java/com/platform/mapper/KwsPrinterDao.java
  23. 9 0
      iot-platform-manager/src/main/java/com/platform/mapper/KwsWeighbridgeDao.java
  24. 12 0
      iot-platform-manager/src/main/java/com/platform/mapper/KwsWeighbridgeDiffConfigDao.java
  25. 10 0
      iot-platform-manager/src/main/java/com/platform/mapper/KwsWeighbridgeRecordDao.java
  26. 49 0
      iot-platform-manager/src/main/java/com/platform/service/KwsPrinterRepository.java
  27. 22 0
      iot-platform-manager/src/main/java/com/platform/service/KwsWeighbridgeDiffConfigRepository.java
  28. 55 0
      iot-platform-manager/src/main/java/com/platform/service/KwsWeighbridgeRecordRepository.java
  29. 60 0
      iot-platform-manager/src/main/java/com/platform/service/KwsWeighbridgeRepository.java
  30. 10 0
      pom.xml

+ 4 - 0
iot-platform-common/pom.xml

@@ -48,6 +48,10 @@
             <groupId>cn.hutool</groupId>
             <artifactId>hutool-extra</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.github.pagehelper</groupId>
+            <artifactId>pagehelper</artifactId>
+        </dependency>
     </dependencies>
     <build>
         <plugins>

+ 11 - 0
iot-platform-common/src/main/java/com/platform/exception/IotException.java

@@ -44,4 +44,15 @@ public class IotException extends RuntimeException {
         this.errorCode = errorCodeEnum.getCode();
         this.errorMsg = errorMsg;
     }
+
+    public IotException(int errorCodeEnum, String errorMsg) {
+        this.errorCode = String.valueOf(errorCodeEnum);
+        this.errorMsg = errorMsg;
+
+    }
+
+    public IotException( String errorMsg) {
+        this.errorCode = "60500";
+        this.errorMsg = errorMsg;
+    }
 }

+ 88 - 0
iot-platform-common/src/main/java/com/platform/result/HttpV1Result.java

@@ -0,0 +1,88 @@
+package com.platform.result;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * HTTP结果封装
+ * @author zk
+ * @date Oct 29, 2018
+ */
+@Data
+public class HttpV1Result implements Serializable {
+
+	private int code = HttpV1Status.SUCCESS_CODE;
+	private String msg = HttpV1Status.SUCCESS_MESSAGE;
+	private Object data;
+
+	public static HttpV1Result error() {
+		return error(HttpV1Status.GLOBAL_EXCEPTION_CODE, HttpV1Status.GLOBAL_EXCEPTION_MESSAGE);
+	}
+	
+	public static HttpV1Result error(String msg) {
+		return error(HttpV1Status.GLOBAL_EXCEPTION_CODE, msg);
+	}
+	
+	public static HttpV1Result error(int code, String msg) {
+		HttpV1Result r = new HttpV1Result();
+		r.setCode(code);
+		r.setMsg(msg);
+		return r;
+	}
+
+	public static HttpV1Result error(String msg, Object data) {
+		HttpV1Result r = new HttpV1Result();
+		r.setCode(HttpV1Status.GLOBAL_EXCEPTION_CODE);
+		r.setMsg(msg);
+		r.setData(data);
+		return r;
+	}
+
+	public static HttpV1Result error(int code, String msg, Object data) {
+		HttpV1Result r = new HttpV1Result();
+		r.setCode(code);
+		r.setMsg(msg);
+		r.setData(data);
+		return r;
+	}
+
+
+	public static HttpV1Result ok() {
+		return new HttpV1Result();
+	}
+
+	public static HttpV1Result ok(String msg) {
+		HttpV1Result r = new HttpV1Result();
+		r.setMsg(msg);
+		return r;
+	}
+	
+	public static HttpV1Result ok(Object data) {
+		HttpV1Result r = new HttpV1Result();
+		r.setData(data);
+		return r;
+	}
+
+    public static HttpV1Result ok(int code, String msg) {
+		HttpV1Result r = new HttpV1Result();
+        r.setCode(code);
+        r.setMsg(msg);
+        return r;
+    }
+
+	public static HttpV1Result ok(String msg, Object data) {
+		HttpV1Result r = new HttpV1Result();
+		r.setMsg(msg);
+		r.setData(data);
+		return r;
+	}
+
+    public static HttpV1Result ok(int code,String msg, Object data) {
+		HttpV1Result r = new HttpV1Result();
+        r.setCode(code);
+        r.setMsg(msg);
+        r.setData(data);
+        return r;
+    }
+}

+ 263 - 0
iot-platform-common/src/main/java/com/platform/result/HttpV1Status.java

@@ -0,0 +1,263 @@
+package com.platform.result;
+
+/**
+ * @Description 自定义接口请求状态码(和http请求码无关)
+ * @Author zk
+ * @Date 2019/5/13 0013
+ */
+public class HttpV1Status {
+
+    /**
+     * 成功状态码
+     */
+    public static final int SUCCESS_CODE = 60200;
+
+    /**
+     * 成功提示信息
+     */
+    public static final String SUCCESS_MESSAGE = "success";
+
+    /**
+     * 未登录状态码
+     */
+    public static final int UN_LOGIN_CODE = 60300;
+    /**
+     * 未登录提示信息
+     */
+    public static final String UN_LOGIN_MESSAGE = "您尚未登录,请先登录!";
+
+    /**
+     * 访问权限状态码
+     */
+    public static final int AUTHORITY_NO_CODE = 60403;
+    public static final String ACCESS_FIAL = "暂无该功能权限!";
+
+    /**
+     * 全局异常状态码
+     */
+    public static final int GLOBAL_EXCEPTION_CODE = 60500;
+
+    /**
+     * 完结贸易订单失败异常码
+     */
+    public static final int COMPLETE_TORDER_FAIL_CODE = 60666;
+
+    /**
+     * 商品上架失败异常码
+     */
+    public static final int GOODS_PUT_ON_SHELVES_FAIL_CODE = 60667;
+
+    /**
+     * 库存不足需确认状态码
+     */
+    public static final int STOCK_INSUFFICIENT_CONFIRM_CODE = 60668;
+
+    /**
+     * 全局异常提示信息
+     */
+    public static final String GLOBAL_EXCEPTION_MESSAGE = "攻城狮正在拼命优化,请您稍候再试!";
+
+    /**
+     * 参数缺失状态码
+     */
+    public static final int PARAMETERS_MISSING_CODE = 60600;
+    public static final String ID_MISSING = "id不能为空!";
+    public static final String ACCOUNT_MISSING = "用户账号必填!";
+    public static final String ACCOUNT_FREEZE = "用户账号不能重复冻结!";
+    public static final String ACCOUNT_UNFREEZE = "用户账号不能重复解冻!";
+    public static final String PWD_MISSING = "密码不能为空!";
+    public static final String TOKEN_MISSING = "token不能为空!";
+    public static final String TOKEN_ERROR = "非法token!";
+    public static final String CAPCHA_ERROR = "验证码无效!";
+    public static final String ADDRESS_EXISTS = "地点已存在,不可重复!";
+    public static final String INVALID_REQUEST = "无效的接口请求!";
+
+    /**
+     * 其他自定义状态码
+     */
+    public static final int CODE_60603 = 60603;
+    public static final String ENTCERTIFICATES_INVAILD = "您的企业资质已失效,暂没有权限访问,请尽快更新资质";
+    public static final String ENTCERTIFICATES_NOT_REGISTER = "您未做企业资质认证,暂没有权限访问";
+    public static final String ENTCERTIFICATES_NOT_PASS = "您的企业资质认证还在审核中,暂没有权限访问";
+
+
+    public static final int CODE_60604 = 60604;
+    public static final int CODE_60605 = 60605;
+    public static final int CODE_60606 = 60606;
+    public static final int CODE_60607 = 60607;
+    public static final int CODE_60608 = 60608;
+    public static final int CODE_60609 = 60609;
+    /**
+     * sentinel异常code定义
+     */
+    public static final int CODE_60701 = 60701;
+    public static final int CODE_60801 = 60801;
+    public static final int CODE_60901 = 60901;
+    public static final int CODE_601001 = 601001;
+    public static final int CODE_601101 = 601101;
+    public static final int CODE_601201 = 601201;
+
+    public static final String FLOW_EXCEPTION_ERROR_MESSAGE = "您的访问过于频繁,请稍后重试";
+    public static final String DEGRADE_EXCEPTION_ERROR_MESSAGE = "调用服务响应异常,请稍后重试";
+    public static final String PARAM_FLOW_EXCEPTION_ERROR_MESSAGE = "您对热点参数访问过于频繁,请稍后重试";
+    public static final String SYSTEM_BLOCK_EXCEPTION_ERROR_MESSAGE = "已触碰系统的红线规则,请检查访问参数";
+    public static final String AUTHORITY_EXCEPTION_ERROR_MESSAGE = "授权规则检测不同,请检查访问参数";
+    public static final String OTHER_EXCEPTION_ERROR_MESSAGE = "非法访问,请稍后重试";
+
+    /**
+     * 版本号和接口版本不对称状态码
+     */
+    public static final int VERSION_NOT_NEWEST_CODE = 60700;
+    /**
+     * 版本号和接口版本不对称提示信息
+     */
+    public static final String VERSION_NOT_NEWEST_MESSAGE = "当前版本较低,请更新升级后再试!";
+
+
+    /**
+     * 参数格式不正确状态码
+     */
+    public static final int PARAMETERS_PATTERN_ERROR_CODE = 60800;
+    /**
+     * 参数格式不正确提示信息
+     */
+    public static final String PARAMETERS_PATTERN_ERROR_MESSAGE = "参数格式不正确";
+    public static final String CONTACTS_ERROR = "联系人格式不正确";
+    public static final String CONTACTS_PHONE_ERROR = "联系人手机号格式不正确";
+    public static final String LEGAL_NAME_ERROR = "法人格式不正确";
+    public static final String LEGAL_PHONE_ERROR = "法人手机号格式不正确";
+    public static final String LEGAL_ID_CARD_ERROR = "法人身份证号格式不正确";
+    public static final String ENT_CODE_ERROR = "营业执照编号格式不正确";
+
+    /**
+     * 账号在别处登录状态码
+     */
+    public static final int ACCOUNT_OTHER_LOGIN_CODE = 60900;
+    /**
+     * 账号在别处登录提示信息
+     */
+    public static final String ACCOUNT_OTHER_LOGIN_MESSAGE = "您的账号已在其他设备登录,如非本人操作,请及时修改密码!";
+
+
+    /**
+     * token无效状态码
+     */
+    public static final int TOKEN_INVALID_CODE = 60901;
+    /**
+     * token无效提示信息
+     */
+    public static final String TOKEN_INVALID_MESSAGE = "由于您一段时间未操作,为了您的账户安全,请重新登录!";
+
+    /**
+     * 请求超过次数
+     */
+    public static final int FREQUENCY_OUT = 60902;
+    /**
+     * 请求超过次数提示信息
+     */
+    public static final String FREQUENCY_OUT_MESSAGE = "您的操作过于频繁,请刷新浏览器或稍候重试!";
+
+    /**
+     * 审核状态状态码
+     */
+    public static final int ACCOUNT_AUDIT_CODE = 60903;
+    /**
+     * 审核状态状提示信息
+     */
+    public static final String ACCOUNT_AUDIT_MESSAGE = "您所属企业企业资质审批未通过,请核实确认!";
+
+    /**
+     * 微信账号未绑定态码
+     */
+    public static final int WECHAR_BIND_CODE = 60904;
+    /**
+     * 微信账号未绑定提示信息
+     */
+    public static final String WECHAR_BIND_MESSAGE = "您的微信还未绑定危品汇账号!";
+
+    /**
+     * 自定义状态码,该状态码没有特殊含义,只是提供一个状态标识(目前提供9个,可自行扩展)
+     * 现作为校验失败的一类异常码
+     */
+    public static final int CODE_10301 = 10301;
+
+    /**
+     * 数据库的操作失败
+     */
+    public static final int CRUD_FAIL_CODE = 60601;
+    public static final String UPDATE_FAIL = "更新失败";
+    public static final String INSERT_FAIL = "新增失败";
+    public static final String DELETE_FAIL = "删除失败";
+
+    /**
+     * 未查询到相关信息
+     */
+    public static final int QUERY_FAIL_CODE = 60602;
+    public static final String ACCOUNT_NOT_EXISTS = "用户信息不存在或已失效";
+    public static final String ENT_NOT_EXISTS = "企业信息不存在或已失效";
+    public static final String DEPT_NOT_EXISTS = "机构信息不存在或已失效";
+    public static final String ENTCERTIFICATES_NOT_EXISTS = "未查询到企业资质信息";
+    public static final String ROLE_NOT_EXISTS = "未查询到关联的角色";
+    public static final String USER_DEPT_NOT_EXISTS = "未查询到用户-机构关联信息";
+    public static final String MENU_NOT_EXISTS = "未查询到菜单信息";
+    public static final String PARENT_MENU_NOT_EXISTS = "未查询到父菜单信息";
+    public static final String PARENT_UNIT_NOT_EXISTS = "未查询到父级单位信息";
+    public static final String COOPERATE_ATTRIBUTE_NOT_EXISTS = "未查询到已有的合作属性";
+    public static final String COOPERATE_NOT_EXISTS = "未查询到合作记录或已失效";
+    public static final String COOPERATE_CANCEL_EXISTS = "未查询到可撤销的记录";
+    public static final String ADDRESS_NOT_EXISTS = "未查询到地址记录或已失效";
+    public static final String CONTRACT_NOT_EXISTS = "未查询到合同或已失效";
+    public static final String BANNER_NOT_EXISTS = "未查询到banner数据或已失效";
+
+    /**
+     * 自定义提示消息
+     */
+    public static final String PASSWD_ERROR = "密码不正确";
+    public static final String PASSWD_REPEAT = "新密码与旧密码不能一样!";
+    public static final String CAPTCHA_ERROR = "验证码输入错误";
+    public static final String MSG_001 = "密码重置成功";
+    public static final String MSG_002 = "密码修改成功";
+    public static final String MSG_003 = "新增成功";
+    public static final String MSG_004 = "审批完成";
+    public static final String MSG_005 = "更新成功";
+    public static final String MSG_006 = "当前系统不允许绑定多个岗位!";
+    public static final String MSG_007 = "注册成功!";
+    public static final String MSG_008 = "删除成功!";
+    public static final String MSG_009 = "认证提交成功!";
+    public static final String MSG_010 = "绑定成功!";
+    public static final String MSG_011 = "当前企业还存在员工数据,不能删除!";
+    public static final String MSG_012 = "只能解除状态为合作中的记录!";
+    public static final String MSG_013 = "只能删除状态为已解除的记录!";
+    public static final String MSG_014 = "导出失败";
+    public static final String MSG_015 = "与对方企业存在待审核的合作关系,请撤销或者完成审核再申请!";
+    public static final String MSG_016 = "与对方企业已存在相同属性的合作关系!";
+    public static final String MSG_017 = "发起申请成功!";
+    public static final String MSG_018 = "撤销成功!";
+    public static final String MSG_019 = "只能操作正在审核中的记录!";
+    public static final String MSG_020 = "当前机构还存在员工数据,不能删除!";
+    public static final String MSG_021 = "不能重复设置默认地址!";
+    public static final String MSG_022 = "只能对草稿进行删除!";
+    public static final String MSG_023 = "解除成功!";
+    public static final String MSG_024 = "名称不能重复!";
+    public static final String MSG_025 = "禁止删除本人信息!";
+    public static final String MSG_026 = "资质认证审核中,请等待审核后再提交!";
+    public static final String MSG_027 = "一级机构不能删除!";
+    public static final String MSG_028 = "合同未签约,不能手动完结!";
+    public static final String MSG_029 = "合同编号超长!";
+    public static final String MSG_030 = "合同名称超长!";
+    public static final String MSG_031 = "您与所选企业存在未完结销售订单,当前无法删除!";
+    public static final String MSG_032 = "您与所选企业存在未完结托运承运订单,当前无法删除!";
+    public static final String MSG_033 = "当前企业资质在审核中,无法删除!";
+    public static final String MSG_034 = "您与所选企业存在未完结对账单,当前无法删除!";
+    public static final String MSG_035 = "地址信息已存在";
+
+    public static final String ENT_EXISTS = "企业已存在,不可重复!";
+    public static final String ACCOUNT_EXISTS = "用户账号已存在!";
+    public static final String DICTTYPE_EXISTS = "字典类型已存在,不可重复!";
+    public static final String DICT_EXISTS = "字典键值已存在,不可重复!";
+    public static final String PL34 = "3PL和4PL不能同时注册!";
+    public static final String ENT_CODE = "统一社会信用代码已存在!";
+    public static final String ENT_FAILED = "新增子企业,父级企业不能为空!";
+
+
+}

+ 148 - 0
iot-platform-common/src/main/java/com/platform/result/PageResult.java

@@ -0,0 +1,148 @@
+package com.platform.result;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.pagehelper.PageInfo;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description 分页结果相关
+ * @Author zk
+ * @Date 2019/5/14
+ */
+public class PageResult implements Serializable {
+
+    /**
+     * 当前页数
+     */
+    protected int page;
+    /**
+     * 每页显示条数
+     */
+    protected int pageSize;
+    /**
+     * 总条数
+     */
+    protected long size;
+    /**
+     * 总页数
+     */
+    protected int pages;
+    protected List list;
+
+    public PageResult(){
+
+    }
+
+    public PageResult(int page, int pageSize, List list){
+        this.page = page;
+        this.pageSize = pageSize;
+        if(list == null){
+            this.size = 0;
+            this.list = null;
+        }else{
+            this.size = list.size();
+            this.list = list.subList(pageSize * (page - 1),pageSize * page > size ? (int) size : pageSize * page);
+        }
+    }
+
+    public PageResult(int page, int pageSize, List list, int size){
+        this.page = page;
+        this.pageSize = pageSize;
+        if(list == null){
+            this.size = 0;
+            this.list = null;
+        }else{
+            this.size = size;
+            this.list = list;
+        }
+    }
+
+    public PageResult(PageInfo pageInfo){
+        this.page = pageInfo.getPageNum();
+        this.pageSize = pageInfo.getPageSize();
+        this.size = pageInfo.getTotal();
+        this.pages = pageInfo.getPages();
+        this.list = pageInfo.getList();
+    }
+
+    public static <T> PageResult build(Integer page, Integer pageSize, Long totalCount, List<T> records) {
+        PageResult pageResult = new PageResult();
+        pageResult.setPage(page);
+        pageResult.setPageSize(pageSize);
+        pageResult.setSize(totalCount);
+        pageResult.setPages((int) ((totalCount + pageSize - 1) / pageSize));
+        pageResult.setList(records);
+        return pageResult;
+    }
+
+    public static <T> PageResult of(IPage page, List<T> records) {
+        PageResult pageResult = new PageResult();
+        pageResult.setPage((int)page.getCurrent());
+        pageResult.setPageSize((int) page.getSize());
+        pageResult.setSize(page.getTotal());
+        // 修正总页数计算
+        pageResult.setPages((int) ((page.getTotal() + page.getSize() - 1) / page.getSize()));
+        pageResult.setList(records);
+        return pageResult;
+    }
+
+    public void setPageInfo(PageInfo pageInfo){
+        this.page = pageInfo.getPageNum();
+        this.pageSize = pageInfo.getPageSize();
+        this.size = pageInfo.getTotal();
+        this.pages = pageInfo.getPages();
+        this.list = pageInfo.getList();
+    }
+
+    public int getPage() {
+        return page;
+    }
+
+    public void setPage(int page) {
+        this.page = page;
+    }
+
+    public int getPageSize() {
+        return pageSize;
+    }
+
+    public void setPageSize(int pageSize) {
+        this.pageSize = pageSize;
+    }
+
+    public long getSize() {
+        return size;
+    }
+
+    public void setSize(long size) {
+        this.size = size;
+    }
+
+    public int getPages() {
+        return pages;
+    }
+
+    public void setPages(int pages) {
+        this.pages = pages;
+    }
+
+    public List getList() {
+        return list;
+    }
+
+    public void setList(List list) {
+        this.list = list;
+    }
+
+    public static int getPage(Map record) {
+        return record != null && record.get("page") != null ? Integer.parseInt(record.get("page").toString()) : 1;
+    }
+
+    public static int getPageSize(Map record) {
+        return record != null && record.get("pageSize") != null ? Integer.parseInt(record.get("pageSize").toString()) : 10;
+    }
+
+}

+ 8 - 1
iot-platform-manager/pom.xml

@@ -91,7 +91,14 @@
             <groupId>com.alibaba</groupId>
             <artifactId>druid-spring-boot-starter</artifactId>
         </dependency>
-
+        <dependency>
+            <groupId>com.github.pagehelper</groupId>
+            <artifactId>pagehelper</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+        </dependency>
     </dependencies>
 
 </project>

+ 92 - 0
iot-platform-manager/src/main/java/com/platform/api/controller/KwsWeighbridgeController.java

@@ -0,0 +1,92 @@
+package com.platform.api.controller;
+
+
+import com.platform.api.manager.KwsWeighbridgeManageService;
+import com.platform.api.request.*;
+import com.platform.result.HttpResult;
+import com.platform.result.HttpStatus;
+import com.platform.result.HttpV1Result;
+import com.platform.result.HttpV1Status;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 地磅控制器
+ */
+@RestController
+@RequestMapping("/kwsWeighbridge")
+@Tag(name = "地磅管理")
+@RequiredArgsConstructor
+public class KwsWeighbridgeController {
+
+    private final KwsWeighbridgeManageService kwsWeighbridgeManageService;
+
+    @PostMapping("/page")
+    @Operation(summary = "地磅分页查询")
+    public HttpV1Result page(@RequestBody WeighbridgePageReqVo reqVo) {
+        return HttpV1Result.ok(kwsWeighbridgeManageService.page(reqVo));
+    }
+
+    @GetMapping("/detail")
+    @Operation(summary = "地磅详情")
+    public HttpV1Result detail(@RequestParam Long id) {
+        return HttpV1Result.ok(kwsWeighbridgeManageService.detail(id));
+    }
+
+    @PostMapping("/add")
+    @Operation(summary = "新增地磅")
+    public HttpV1Result add(@RequestBody WeighbridgeSaveReqVo reqVo) {
+        kwsWeighbridgeManageService.add(reqVo);
+        return HttpV1Result.ok(HttpV1Status.MSG_003);
+    }
+
+    @PostMapping("/update")
+    @Operation(summary = "更新地磅")
+    public HttpV1Result update(@RequestBody WeighbridgeSaveReqVo reqVo) {
+        kwsWeighbridgeManageService.update(reqVo);
+        return HttpV1Result.ok(HttpV1Status.MSG_005);
+    }
+
+    @PostMapping("/updateStatus")
+    @Operation(summary = "更新地磅状态,停用启用接口")
+    public HttpV1Result updateStatus(@RequestBody WeighbridgeStatusReqVo reqVo) {
+        kwsWeighbridgeManageService.updateStatus(reqVo);
+        return HttpV1Result.ok(HttpV1Status.MSG_005);
+    }
+
+    @PostMapping("/updateDiffConfig")
+    @Operation(summary = "保存地磅差值配置")
+    public HttpV1Result updateDiffConfig(@RequestBody WeighbridgeDiffConfigReqVo reqVo) {
+        kwsWeighbridgeManageService.updateDiffConfig(reqVo);
+        return HttpV1Result.ok(HttpV1Status.MSG_005);
+    }
+
+    @GetMapping("/diffConfigDetail")
+    @Operation(summary = "获取地磅差值配置详情")
+    public HttpV1Result diffConfigDetail(@RequestParam Long entId) {
+        return HttpV1Result.ok(kwsWeighbridgeManageService.diffConfigDetail(entId));
+    }
+
+    @PostMapping("/restart")
+    @Operation(summary = "重启地磅")
+    public HttpV1Result restart(@RequestBody WeighbridgeRestartReqVo reqVo) {
+        kwsWeighbridgeManageService.restart(reqVo);
+        return HttpV1Result.ok("重启命令已记录");
+    }
+
+//    @GetMapping("/enterpriseOptions")
+//    @Operation(summary = "搜索企业选项")
+//    public HttpV1Result enterpriseOptions(@RequestParam(required = false) String keyword) {
+//        return HttpV1Result.ok(kwsWeighbridgeManageService.enterpriseOptions(keyword));
+//    }
+
+    @GetMapping("/checkUniqueCode")
+    @Operation(summary = "检查唯一编码可用性")
+    public HttpV1Result checkUniqueCode(@RequestParam String uniqueCode,
+                                      @RequestParam(required = false) Long id) {
+        return HttpV1Result.ok(kwsWeighbridgeManageService.checkUniqueCodeAvailable(uniqueCode, id));
+    }
+
+}

+ 636 - 0
iot-platform-manager/src/main/java/com/platform/api/manager/KwsWeighbridgeManageService.java

@@ -0,0 +1,636 @@
+package com.platform.api.manager;
+
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+import com.platform.api.request.*;
+import com.platform.api.response.PlatformEnterpriseResVo;
+import com.platform.api.response.WeighbridgeDetailResVo;
+import com.platform.api.response.WeighbridgeDiffConfigResVo;
+import com.platform.api.response.WeighbridgePageResVo;
+import com.platform.entity.KwsPrinter;
+import com.platform.entity.KwsWeighbridge;
+import com.platform.entity.KwsWeighbridgeDiffConfig;
+import com.platform.exception.IotException;
+import com.platform.result.HttpV1Status;
+import com.platform.result.PageResult;
+import com.platform.service.*;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * 地磅管理服务类
+ * 提供地磅的增删改查、状态管理、误差配置及关联信息查询等功能
+ */
+@Service
+@RequiredArgsConstructor
+@Slf4j
+public class KwsWeighbridgeManageService {
+
+    /**
+     * 地磅数据访问层
+     */
+    private final KwsWeighbridgeRepository kwsWeighbridgeRepository;
+    /**
+     * 企业数据访问层
+     */
+   // private final KwsEnterpriseRepository kwsEnterpriseRepository;
+    /**
+     * 打印机数据访问层
+     */
+    private final KwsPrinterRepository kwsPrinterRepository;
+    /**
+     * 地磅误差配置数据访问层
+     */
+    private final KwsWeighbridgeDiffConfigRepository kwsWeighbridgeDiffConfigRepository;
+    /**
+     * 地磅记录数据访问层
+     */
+    private final KwsWeighbridgeRecordRepository kwsWeighbridgeRecordRepository;
+
+    private final ValidateLicensePlateService validateLicensePlateService;
+
+    /**
+     * 分页查询地磅列表
+     * <p>
+     * 根据请求参数中的企业名称解析出对应的企业ID集合,结合地磅名称进行分页查询。
+     * 若解析出的企业ID集合为空(例如普通用户无权限访问任何企业),则直接返回空结果。
+     *
+     * @param reqVo 分页查询请求参数,包含页码、每页大小、地磅名称、企业名称等
+     * @return 分页结果,包含地磅列表及总数
+     */
+    public PageResult page(WeighbridgePageReqVo reqVo) {
+        log.info("分页查询地磅列表, reqVo: {}", JSON.toJSONString(reqVo));
+        // 根据企业名称解析有权限访问的企业ID集合
+       // Set<Long> entIds = resolveQueryEntIds(reqVo.getEnterpriseName());
+        if (Objects.isNull(reqVo.getEntId())) {
+            // 若无有效企业ID,直接返回空分页结果
+            return PageResult.build(reqVo.getPageNum(), reqVo.getPageSize(), 0L, Collections.emptyList());
+        }
+        // 执行数据库分页查询
+        IPage<KwsWeighbridge> page = kwsWeighbridgeRepository.pageQuery(reqVo.getPageNum(), reqVo.getPageSize(),
+                reqVo.getWeighbridgeName(), reqVo.getEntId());
+        // 构建并返回响应结果
+        return PageResult.of(page, buildPageRes(page.getRecords()));
+    }
+
+    /**
+     * 获取地磅详情
+     * <p>
+     * 根据地磅ID查询地磅信息,并填充企业名称、打印机名称等关联信息。
+     *
+     * @param id 地磅ID
+     * @return 地磅详情响应对象
+     */
+    public WeighbridgeDetailResVo detail(Long id) {
+        log.info("获取地磅详情, id: {}", id);
+        // 获取并校验地磅实体(包含权限校验)
+        KwsWeighbridge weighbridge = getAndCheck(id);
+        WeighbridgeDetailResVo resVo = new WeighbridgeDetailResVo();
+        // 填充基础信息及关联名称
+        fillBaseRes(weighbridge,
+                printerNameMap(weighbridge.getPrinterId() == null ? Collections.emptySet() : Collections.singleton(weighbridge.getPrinterId())),
+                resVo);
+        // 设置误差配置JSON字符串
+        resVo.setDiffConfig(weighbridge.getDiffConfig());
+        return resVo;
+    }
+
+
+    /**
+     * 新增地磅信息
+     * <p>
+     * 校验请求参数合法性及唯一性后,创建新的地磅记录。
+     *
+     * @param reqVo 地磅保存请求参数
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void add(WeighbridgeSaveReqVo reqVo) {
+        log.info("新增地磅信息, reqVo: {}", JSON.toJSONString(reqVo));
+        // 校验请求参数(新增时excludeId为null)
+        validateSaveReq(reqVo, null);
+        Date now = new Date();
+        // 构建地磅实体对象
+        KwsWeighbridge weighbridge = new KwsWeighbridge()
+                .setEntId(reqVo.getEntId())
+                .setEntName(reqVo.getEntName())
+                .setWeighbridgeName(reqVo.getWeighbridgeName())
+                .setUniqueCode(reqVo.getUniqueCode())
+                .setOnlineStatus(defaultOnlineStatus(reqVo.getOnlineStatus()))
+                .setPrinterId(reqVo.getPrinterId())
+                .setDescription(reqVo.getDescription())
+                .setDiffConfig(reqVo.getDiffConfig())
+                .setStatus(0) // 默认启用
+                .setDelFlag(0) // 默认未删除
+                .setCreateBy(reqVo.getUserId())
+                .setCreateTime(now)
+                .setUpdateBy(reqVo.getUserId())
+                .setUpdateTime(now);
+        // 保存至数据库
+        if (!kwsWeighbridgeRepository.save(weighbridge)) {
+                throw new IotException(HttpV1Status.CRUD_FAIL_CODE, HttpV1Status.INSERT_FAIL);
+        }
+    }
+
+    /**
+     * 更新地磅信息
+     * <p>
+     * 校验请求参数及权限后,更新指定地磅的信息。
+     *
+     * @param reqVo 地磅保存请求参数,必须包含地磅ID
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void update(WeighbridgeSaveReqVo reqVo) {
+        log.info("更新地磅信息, reqVo: {}", JSON.toJSONString(reqVo));
+        if (reqVo.getId() == null) {
+            throw new IotException("地磅ID不能为空");
+        }
+        // 获取并校验原地磅信息
+        KwsWeighbridge weighbridge = getAndCheck(reqVo.getId());
+        // 校验请求参数(更新时需排除当前ID以检查唯一编码冲突)
+        validateSaveReq(reqVo, weighbridge.getId());
+        // 更新字段
+        weighbridge.setEntId(reqVo.getEntId());
+        weighbridge.setEntName(reqVo.getEntName());
+        weighbridge.setWeighbridgeName(reqVo.getWeighbridgeName());
+        weighbridge.setUniqueCode(reqVo.getUniqueCode());
+        weighbridge.setOnlineStatus(defaultOnlineStatus(reqVo.getOnlineStatus()));
+        weighbridge.setPrinterId(reqVo.getPrinterId());
+        weighbridge.setDescription(reqVo.getDescription());
+        weighbridge.setDiffConfig(reqVo.getDiffConfig());
+        weighbridge.setUpdateBy(reqVo.getUserId());
+        weighbridge.setUpdateTime(new Date());
+        // 执行更新
+        if (!kwsWeighbridgeRepository.updateById(weighbridge)) {
+            throw new IotException(HttpV1Status.CRUD_FAIL_CODE, HttpV1Status.UPDATE_FAIL);
+        }
+    }
+
+    /**
+     * 更新地磅状态
+     * <p>
+     * 仅允许将状态更新为0(启用)或1(停用)。
+     *
+     * @param reqVo 状态更新请求参数,包含地磅ID和目标状态
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void updateStatus(WeighbridgeStatusReqVo reqVo) {
+        log.info("更新地磅状态, reqVo: {}", JSON.toJSONString(reqVo));
+        if (reqVo.getId() == null) {
+            throw new IotException("地磅ID不能为空");
+        }
+        // 校验状态值合法性
+        if (!Objects.equals(reqVo.getStatus(), 0) && !Objects.equals(reqVo.getStatus(), 1)) {
+            throw new IotException("无效的地磅状态");
+        }
+        // 获取并校验地磅
+        KwsWeighbridge weighbridge = getAndCheck(reqVo.getId());
+        weighbridge.setStatus(reqVo.getStatus());
+        //weighbridge.setUpdateBy(LoginUserHolder.getUserId());
+        weighbridge.setUpdateTime(new Date());
+        if (!kwsWeighbridgeRepository.updateById(weighbridge)) {
+            throw new IotException(HttpV1Status.CRUD_FAIL_CODE, HttpV1Status.UPDATE_FAIL);
+        }
+    }
+
+    /**
+     * 更新地磅误差配置
+     * <p>
+     * 更新指定企业的误差配置表,并同步更新地磅主表中的误差配置JSON字段。
+     * 若配置不存在则新增,存在则更新。
+     *
+     * @param reqVo 误差配置请求参数,包含企业ID及各项误差值
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void updateDiffConfig(WeighbridgeDiffConfigReqVo reqVo) {
+        log.info("更新地磅误差配置, reqVo: {}", JSON.toJSONString(reqVo));
+        // 校验请求参数非空
+        validateDiffConfigReq(reqVo);
+        // 校验企业权限及状态
+       // checkEnterprise(reqVo.getEntId());
+        Date now = new Date();
+        // 查询现有配置
+        KwsWeighbridgeDiffConfig config = kwsWeighbridgeDiffConfigRepository.findByEntId(reqVo.getEntId());
+        if (config == null) {
+            // 新增配置
+            config = new KwsWeighbridgeDiffConfig()
+                    .setEntId(reqVo.getEntId())
+                    .setEntName(reqVo.getEntName())
+                    .setTareErrorValue(reqVo.getTareErrorValue())
+                    .setLoadErrorValue(reqVo.getLoadErrorValue())
+                    .setEmptyLoadValue(reqVo.getEmptyLoadValue())
+                    .setCreateBy(reqVo.getUserId())
+                    .setCreateTime(now)
+                    .setUpdateBy(reqVo.getUserId())
+                    .setUpdateTime(now)
+                    .setDelFlag(0);
+            if (!kwsWeighbridgeDiffConfigRepository.save(config)) {
+                throw new IotException(HttpV1Status.CRUD_FAIL_CODE, HttpV1Status.INSERT_FAIL);
+            }
+        } else {
+            // 更新配置
+            config.setTareErrorValue(reqVo.getTareErrorValue());
+            config.setLoadErrorValue(reqVo.getLoadErrorValue());
+            config.setEmptyLoadValue(reqVo.getEmptyLoadValue());
+            config.setUpdateBy(reqVo.getUserId());
+            config.setUpdateTime(now);
+            if (!kwsWeighbridgeDiffConfigRepository.updateById(config)) {
+                throw new IotException(HttpV1Status.CRUD_FAIL_CODE, HttpV1Status.UPDATE_FAIL);
+            }
+        }
+        // 同步更新地磅表中的误差配置JSON字段,确保数据一致性
+        kwsWeighbridgeRepository.updateDiffConfigByEntId(reqVo.getEntId(), buildDiffConfigJson(reqVo), reqVo.getEntId());
+    }
+
+    /**
+     * 获取地磅误差配置详情
+     * <p>
+     * 查询指定企业的误差配置信息。
+     *
+     * @param entId 企业ID
+     * @return 误差配置详情响应对象
+     */
+    public WeighbridgeDiffConfigResVo diffConfigDetail(Long entId) {
+        log.info("获取地磅误差配置详情, entId: {}", entId);
+        if (entId == null) {
+            throw new IotException("企业ID不能为空");
+        }
+        // 校验企业权限
+        //checkEnterprise(entId);
+        WeighbridgeDiffConfigResVo resVo = new WeighbridgeDiffConfigResVo();
+        resVo.setEntId(entId);
+        // 查询配置详情
+        KwsWeighbridgeDiffConfig config = kwsWeighbridgeDiffConfigRepository.findByEntId(entId);
+        if (config != null) {
+            resVo.setId(config.getId());
+            resVo.setTareErrorValue(config.getTareErrorValue());
+            resVo.setLoadErrorValue(config.getLoadErrorValue());
+            resVo.setEmptyLoadValue(config.getEmptyLoadValue());
+            resVo.setEnterpriseName(config.getEntName());
+        }
+        return resVo;
+    }
+
+
+    /**
+     * 重启地磅(更新最后重启时间)
+     * <p>
+     * 记录地磅最后一次重启的时间戳。
+     *
+     * @param reqVo 重启请求参数,包含地磅ID
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void restart(WeighbridgeRestartReqVo reqVo) {
+        log.info("重启地磅, reqVo: {}", JSON.toJSONString(reqVo));
+        if (reqVo.getId() == null) {
+            throw new IotException("地磅ID不能为空");
+        }
+        // 获取并校验地磅
+        KwsWeighbridge weighbridge = getAndCheck(reqVo.getId());
+        Date now = new Date();
+        weighbridge.setLastRestartTime(now);
+        weighbridge.setUpdateBy(reqVo.getUserId());
+        weighbridge.setUpdateTime(now);
+        if (!kwsWeighbridgeRepository.updateById(weighbridge)) {
+            throw new IotException(HttpV1Status.CRUD_FAIL_CODE, HttpV1Status.UPDATE_FAIL);
+        }
+    }
+
+    /**
+     * 获取企业选项列表
+     * <p>
+     * 根据当前用户权限获取可选的企业列表,支持关键词搜索。
+     * 管理员可查看所有企业,普通用户仅可查看授权范围内的企业。
+     *
+     * @param keyword 搜索关键词
+     * @return 企业选项列表
+     */
+//    public List<PlatformEnterpriseResVo> enterpriseOptions(String keyword) {
+//        log.info("获取企业选项列表, keyword: {}", keyword);
+//        // 获取当前用户授权的企业ID集合
+//        Set<Long> authEntIds = resolveAuthorizedEntIds();
+//        List<KwsEnterprise> enterpriseList;
+//        if (LoginUserHolder.isManager()) {
+//            // 管理员查询所有匹配的企业
+//            enterpriseList = kwsEnterpriseRepository.queryByEntIdAndName(null, keyword);
+//        } else if (authEntIds.isEmpty()) {
+//            // 普通用户无授权企业,返回空列表
+//            return Collections.emptyList();
+//        } else {
+//            // 普通用户查询授权范围内的匹配企业
+//            enterpriseList = kwsEnterpriseRepository.queryByEntIds(authEntIds, keyword);
+//        }
+//        // 转换为响应VO
+//        return enterpriseList.stream().map(item -> {
+//            PlatformEnterpriseResVo resVo = new PlatformEnterpriseResVo();
+//            resVo.setId(item.getId());
+//            resVo.setFirmName(item.getFirmName());
+//            return resVo;
+//        }).toList();
+//    }
+
+    /**
+     * 检查唯一编码是否可用
+     * <p>
+     * 用于前端实时校验或提交前校验,确保唯一编码未被其他地磅占用。
+     *
+     * @param uniqueCode 唯一编码
+     * @param id         地磅ID(更新时传入当前ID以排除自身)
+     * @return 是否可用
+     */
+    public boolean checkUniqueCodeAvailable(String uniqueCode, Long id) {
+        log.info("检查唯一编码是否可用, uniqueCode: {}, id: {}", uniqueCode, id);
+        if (StringUtils.isBlank(uniqueCode)) {
+            return false;
+        }
+        // 查询是否存在该编码的地磅
+        KwsWeighbridge exists = kwsWeighbridgeRepository.findByUniqueCode(uniqueCode.trim());
+        // 若不存在,或存在的记录即为当前记录,则视为可用
+        return exists == null || Objects.equals(exists.getId(), id);
+    }
+
+    /**
+     * 构建分页响应结果
+     * <p>
+     * 批量查询关联的企业名称和打印机名称,避免N+1查询问题,并组装响应VO列表。
+     *
+     * @param records 地磅记录列表
+     * @return 分页响应VO列表
+     */
+    private List<WeighbridgePageResVo> buildPageRes(List<KwsWeighbridge> records) {
+        if (records == null || records.isEmpty()) {
+            return Collections.emptyList();
+        }
+        // 批量获取企业名称映射
+       // Map<Long, String> entNameMap = enterpriseNameMap(records.stream().map(KwsWeighbridge::getEntId).collect(Collectors.toSet()));
+        // 批量获取打印机名称映射(过滤null ID)
+        Map<Long, String> printerNameMap = printerNameMap(records.stream().map(KwsWeighbridge::getPrinterId)
+                .filter(Objects::nonNull).collect(Collectors.toSet()));
+        List<WeighbridgePageResVo> result = new ArrayList<>(records.size());
+        for (KwsWeighbridge record : records) {
+            WeighbridgePageResVo resVo = new WeighbridgePageResVo();
+            // 填充单个记录的基础信息
+            fillBaseRes(record, printerNameMap, resVo);
+            result.add(resVo);
+        }
+        return result;
+    }
+
+    /**
+     * 填充基础响应信息
+     * <p>
+     * 将地磅实体数据及关联的名称映射填充到响应VO中,并转换状态枚举为中文描述。
+     *
+     * @param record        地磅实体
+     * @param printerNameMap 打印机名称映射
+     * @param resVo         响应VO
+     */
+    private void fillBaseRes(KwsWeighbridge record, Map<Long, String> printerNameMap,
+                             WeighbridgePageResVo resVo) {
+        resVo.setId(record.getId());
+        resVo.setEntId(record.getEntId());
+        resVo.setEnterpriseName(record.getEntName());
+        resVo.setWeighbridgeName(record.getWeighbridgeName());
+        resVo.setUniqueCode(record.getUniqueCode());
+        resVo.setOnlineStatus(record.getOnlineStatus());
+        // 转换在线状态:1-在线,0-离线
+        resVo.setOnlineStatusName(Objects.equals(record.getOnlineStatus(), 1) ? "在线" : "离线");
+        resVo.setPrinterId(record.getPrinterId());
+        resVo.setPrinterName(printerNameMap.getOrDefault(record.getPrinterId(), ""));
+        resVo.setDescription(record.getDescription());
+        resVo.setStatus(record.getStatus());
+        // 转换启用状态:0-启用,1-停用
+        resVo.setStatusName(Objects.equals(record.getStatus(), 0) ? "启用" : "停用");
+        resVo.setCreateTime(record.getCreateTime());
+        resVo.setLastRestartTime(record.getLastRestartTime());
+    }
+
+    /**
+     * 获取企业名称映射
+     * <p>
+     * 根据企业ID集合批量查询企业名称,返回ID到名称的Map。
+     *
+     * @param entIds 企业ID集合
+     * @return 企业ID到名称的映射
+     */
+//    private Map<Long, String> enterpriseNameMap(Collection<Long> entIds) {
+//        if (entIds == null || entIds.isEmpty()) {
+//            return Collections.emptyMap();
+//        }
+//        return kwsEnterpriseRepository.listByIds(entIds).stream()
+//                .collect(Collectors.toMap(KwsEnterprise::getId, KwsEnterprise::getFirmName, (a, b) -> a));
+//    }
+
+    /**
+     * 获取打印机名称映射
+     * <p>
+     * 根据打印机ID集合批量查询打印机名称,返回ID到名称的Map。
+     *
+     * @param printerIds 打印机ID集合
+     * @return 打印机ID到名称的映射
+     */
+    private Map<Long, String> printerNameMap(Collection<Long> printerIds) {
+        if (printerIds == null || printerIds.isEmpty()) {
+            return Collections.emptyMap();
+        }
+        return kwsPrinterRepository.listByIds(printerIds).stream()
+                .collect(Collectors.toMap(KwsPrinter::getId, KwsPrinter::getPrinterName, (a, b) -> a));
+    }
+
+    /**
+     * 校验地磅保存请求参数
+     * <p>
+     * 检查必填项、企业权限、打印机有效性及唯一编码冲突。
+     *
+     * @param reqVo     保存请求参数
+     * @param excludeId 排除的地磅ID(用于更新时排除自身,新增时为null)
+     */
+    private void validateSaveReq(WeighbridgeSaveReqVo reqVo, Long excludeId) {
+        if (reqVo.getEntId() == null) {
+            throw new IotException("企业ID不能为空");
+        }
+        if (StringUtils.isBlank(reqVo.getWeighbridgeName())) {
+            throw new IotException("地磅名称不能为空");
+        }
+        if (StringUtils.isBlank(reqVo.getUniqueCode())) {
+            throw new IotException("唯一编码不能为空");
+        }
+        // 校验企业是否存在且有权限操作
+       // checkEnterprise(reqVo.getEntId());
+        // 校验打印机是否属于该企业且可用
+        checkPrinter(reqVo.getEntId(), reqVo.getPrinterId());
+        // 校验唯一编码是否冲突
+        KwsWeighbridge exists = kwsWeighbridgeRepository.findByUniqueCode(reqVo.getUniqueCode().trim());
+        if (exists != null && !Objects.equals(exists.getId(), excludeId)) {
+            throw new IotException("唯一编码已存在");
+        }
+    }
+
+    /**
+     * 校验地磅误差配置请求参数
+     * <p>
+     * 检查企业ID及各项误差值是否为空。
+     *
+     * @param reqVo 误差配置请求参数
+     */
+    private void validateDiffConfigReq(WeighbridgeDiffConfigReqVo reqVo) {
+        if (reqVo.getEntId() == null) {
+            throw new IotException("企业ID不能为空");
+        }
+        if (reqVo.getTareErrorValue() == null) {
+            throw new IotException("皮重误差值不能为空");
+        }
+        if (reqVo.getLoadErrorValue() == null) {
+            throw new IotException("载重误差值不能为空");
+        }
+        if (reqVo.getEmptyLoadValue() == null) {
+            throw new IotException("空载值不能为空");
+        }
+    }
+
+    /**
+     * 校验打印机权限及状态
+     * <p>
+     * 确保指定的打印机ID属于当前企业且处于可用状态。
+     *
+     * @param entId     企业ID
+     * @param printerId 打印机ID
+     */
+    private void checkPrinter(Long entId, Long printerId) {
+        if (printerId == null) {
+            return;
+        }
+        KwsPrinter printer = kwsPrinterRepository.findAvailableById(printerId);
+        if (printer == null || !Objects.equals(printer.getEntId(), entId)) {
+            throw new IotException("该企业的打印机不可用");
+        }
+    }
+
+    /**
+     * 校验企业权限及状态
+     * <p>
+     * 确保当前用户有权限操作该企业,且企业未被删除或停用。
+     *
+     * @param entId 企业ID
+     */
+//    private void checkEnterprise(Long entId) {
+//        // 判断是否有权限:管理员或企业在授权列表中
+//        boolean allowed = LoginUserHolder.isManager() || resolveAuthorizedEntIds().contains(entId);
+//        if (!allowed) {
+//            throw new SystemException("无权操作该企业");
+//        }
+//        // 检查企业实体状态
+//        KwsEnterprise enterprise = kwsEnterpriseRepository.getById(entId);
+//        if (enterprise == null || Objects.equals(enterprise.getDelFlag(), 1) || Objects.equals(enterprise.getStatus(), 1)) {
+//            throw new SystemException(HttpStatus.ENT_NOT_EXISTS);
+//        }
+//    }
+
+    /**
+     * 获取并校验地磅信息
+     * <p>
+     * 根据地磅ID查询地磅,并校验其存在性及当前用户的操作权限。
+     *
+     * @param id 地磅ID
+     * @return 地磅实体
+     */
+    private KwsWeighbridge getAndCheck(Long id) {
+        KwsWeighbridge weighbridge = kwsWeighbridgeRepository.findAvailableById(id);
+        if (weighbridge == null) {
+            throw new IotException("地磅不存在");
+        }
+        // 非管理员需校验地磅所属企业是否在授权范围内
+//        if (!LoginUserHolder.isManager() && !resolveAuthorizedEntIds().contains(weighbridge.getEntId())) {
+//            throw new SystemException("无权操作该地磅");
+//        }
+        return weighbridge;
+    }
+
+    /**
+     * 解析查询条件中的企业ID集合
+     * <p>
+     * 根据企业名称关键词和用户权限,解析出可用于查询的地磅所属企业ID集合。
+     *
+     * @param enterpriseName 企业名称关键词
+     * @return 企业ID集合
+     */
+//    private Set<Long> resolveQueryEntIds(String enterpriseName) {
+//        Set<Long> authEntIds = resolveAuthorizedEntIds();
+//        List<KwsEnterprise> enterpriseList;
+//        if (LoginUserHolder.isManager()) {
+//            // 管理员可根据名称模糊查询所有企业
+//            enterpriseList = kwsEnterpriseRepository.queryByEntIdAndName(null, enterpriseName);
+//        } else if (authEntIds.isEmpty()) {
+//            // 普通用户无授权企业,返回空集合
+//            return Collections.emptySet();
+//        } else {
+//            // 普通用户在授权企业中根据名称模糊查询
+//            enterpriseList = kwsEnterpriseRepository.queryByEntIds(authEntIds, enterpriseName);
+//        }
+//        // 提取ID并去重,保持插入顺序
+//        return enterpriseList.stream().map(KwsEnterprise::getId).collect(Collectors.toCollection(LinkedHashSet::new));
+//    }
+
+    /**
+     * 解析当前用户授权的企业ID集合
+     * <p>
+     * 获取当前登录用户有权访问的所有企业ID,包括当前企业、授权企业及子企业。
+     * 管理员返回空集合,表示拥有所有权限(通常在业务逻辑中特殊处理)。
+     *
+     * @return 企业ID集合
+     */
+//    private Set<Long> resolveAuthorizedEntIds() {
+//        if (LoginUserHolder.isManager()) {
+//            return Collections.emptySet();
+//        }
+//        Set<Long> result = new LinkedHashSet<>();
+//        // 添加当前登录用户所属企业
+//        if (LoginUserHolder.getEntId() != null) {
+//            result.add(LoginUserHolder.getEntId());
+//        }
+//        // 添加额外授权的企业
+//        result.addAll(LoginUserHolder.getAuthEntIdList());
+//        // 添加子企业
+//        result.addAll(LoginUserHolder.getChildEntList());
+//        return result;
+//    }
+
+    /**
+     * 获取默认的在线状态
+     * <p>
+     * 若传入状态为1则返回1,否则默认返回0(离线)。
+     *
+     * @param onlineStatus 传入的在线状态
+     * @return 默认在线状态(1为在线,0为离线)
+     */
+    private Integer defaultOnlineStatus(Integer onlineStatus) {
+        return Objects.equals(onlineStatus, 1) ? 1 : 0;
+    }
+
+    /**
+     * 构建误差配置JSON字符串
+     * <p>
+     * 将误差配置请求参数转换为JSON字符串,用于存储在地磅表的diff_config字段中。
+     *
+     * @param reqVo 误差配置请求参数
+     * @return JSON字符串
+     */
+    private String buildDiffConfigJson(WeighbridgeDiffConfigReqVo reqVo) {
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("entId", reqVo.getEntId());
+        jsonObject.put("tareErrorValue", reqVo.getTareErrorValue());
+        jsonObject.put("loadErrorValue", reqVo.getLoadErrorValue());
+        jsonObject.put("emptyLoadValue", reqVo.getEmptyLoadValue());
+        return jsonObject.toJSONString();
+    }
+
+
+}

+ 48 - 0
iot-platform-manager/src/main/java/com/platform/api/request/WeighbridgeDiffConfigReqVo.java

@@ -0,0 +1,48 @@
+package com.platform.api.request;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 地磅差异配置请求参数
+ */
+@Data
+@Schema(description = "地磅差异配置请求参数")
+public class WeighbridgeDiffConfigReqVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 企业ID
+     */
+    @Schema(description = "企业ID")
+    private Long entId;
+
+    @Schema(description = "企业名称")
+    private String entName;
+
+    /**
+     * 皮重误差值(吨)
+     */
+    @Schema(description = "皮重误差值(吨)")
+    private BigDecimal tareErrorValue;
+
+    /**
+     * 毛重误差值(吨)
+     */
+    @Schema(description = "毛重误差值(吨)")
+    private BigDecimal loadErrorValue;
+
+    /**
+     * 空载重量值(吨)
+     */
+    @Schema(description = "空载重量值(吨)")
+    private BigDecimal emptyLoadValue;
+    @Schema(description = "用户id")
+    private Long userId;
+}

+ 36 - 0
iot-platform-manager/src/main/java/com/platform/api/request/WeighbridgePageReqVo.java

@@ -0,0 +1,36 @@
+package com.platform.api.request;
+
+
+import com.platform.request.PageRequest;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * 地磅分页查询请求。
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Schema(description = "地磅分页查询请求")
+public class WeighbridgePageReqVo extends PageRequest implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 企业名称模糊关键字。
+     */
+    @Schema(description = "企业名称模糊关键字")
+    private String enterpriseName;
+
+    /**
+     * 地磅名称模糊关键字。
+     */
+    @Schema(description = "地磅名称模糊关键字")
+    private String weighbridgeName;
+    @Schema(description = "企业id")
+    private Long entId;
+}

+ 26 - 0
iot-platform-manager/src/main/java/com/platform/api/request/WeighbridgeRestartReqVo.java

@@ -0,0 +1,26 @@
+package com.platform.api.request;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * 地磅重启请求。
+ */
+@Data
+@Schema(description = "地磅重启请求")
+public class WeighbridgeRestartReqVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 地磅ID。
+     */
+    @Schema(description = "地磅ID")
+    private Long id;
+    @Schema(description = "用户ID")
+    private Long userId;
+}

+ 71 - 0
iot-platform-manager/src/main/java/com/platform/api/request/WeighbridgeSaveReqVo.java

@@ -0,0 +1,71 @@
+package com.platform.api.request;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * 地磅保存请求。
+ */
+@Data
+@Schema(description = "地磅保存请求")
+public class WeighbridgeSaveReqVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键ID,编辑时必传。
+     */
+    @Schema(description = "主键ID,编辑时必传")
+    private Long id;
+
+    /**
+     * 企业ID。
+     */
+    @Schema(description = "企业ID")
+    private Long entId;
+
+    @Schema(description = "企业名称")
+    private String entName;
+
+    /**
+     * 地磅名称。
+     */
+    @Schema(description = "地磅名称")
+    private String weighbridgeName;
+
+    /**
+     * 唯一编码。
+     */
+    @Schema(description = "唯一编码")
+    private String uniqueCode;
+
+    /**
+     * 在线状态,0-离线,1-在线。
+     */
+    @Schema(description = "在线状态,0-离线,1-在线")
+    private Integer onlineStatus;
+
+    /**
+     * 关联打印机ID。
+     */
+    @Schema(description = "关联打印机ID")
+    private Long printerId;
+
+    /**
+     * 描述。
+     */
+    @Schema(description = "描述")
+    private String description;
+
+    /**
+     * 差异化配置JSON。
+     */
+    @Schema(description = "差异化配置JSON")
+    private String diffConfig;
+    @Schema(description = "用户id")
+    private Long userId;
+}

+ 30 - 0
iot-platform-manager/src/main/java/com/platform/api/request/WeighbridgeStatusReqVo.java

@@ -0,0 +1,30 @@
+package com.platform.api.request;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * 地磅状态更新请求。
+ */
+@Data
+@Schema(description = "地磅状态更新请求")
+public class WeighbridgeStatusReqVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 地磅ID。
+     */
+    @Schema(description = "地磅ID")
+    private Long id;
+
+    /**
+     * 启停状态,0-启用,1-停用。
+     */
+    @Schema(description = "启停状态,0-启用,1-停用")
+    private Integer status;
+}

+ 24 - 0
iot-platform-manager/src/main/java/com/platform/api/response/PlatformEnterpriseResVo.java

@@ -0,0 +1,24 @@
+package com.platform.api.response;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @author cxf
+ */
+@Data
+public class PlatformEnterpriseResVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 4558841182144772550L;
+
+    @Schema(description = "企业id")
+    private Long id;
+
+    @Schema(description = "企业名称")
+    private String firmName;
+
+}

+ 25 - 0
iot-platform-manager/src/main/java/com/platform/api/response/WeighbridgeDetailResVo.java

@@ -0,0 +1,25 @@
+package com.platform.api.response;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serial;
+
+/**
+ * 地磅详情响应。
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Schema(description = "地磅详情响应")
+public class WeighbridgeDetailResVo extends WeighbridgePageResVo {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 差异化配置JSON。
+     */
+    @Schema(description = "差异化配置JSON")
+    private String diffConfig;
+}

+ 55 - 0
iot-platform-manager/src/main/java/com/platform/api/response/WeighbridgeDiffConfigResVo.java

@@ -0,0 +1,55 @@
+package com.platform.api.response;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * Weighbridge diff config response.
+ */
+@Data
+@Schema(description = "Weighbridge diff config response")
+public class WeighbridgeDiffConfigResVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * Config id.
+     */
+    @Schema(description = "Config id")
+    private Long id;
+
+    /**
+     * Enterprise id.
+     */
+    @Schema(description = "Enterprise id")
+    private Long entId;
+
+    /**
+     * Enterprise name.
+     */
+    @Schema(description = "Enterprise name")
+    private String enterpriseName;
+
+    /**
+     * Tare error value in ton.
+     */
+    @Schema(description = "Tare error value in ton")
+    private BigDecimal tareErrorValue;
+
+    /**
+     * Load error value in ton.
+     */
+    @Schema(description = "Load error value in ton")
+    private BigDecimal loadErrorValue;
+
+    /**
+     * Empty load value in ton.
+     */
+    @Schema(description = "Empty load value in ton")
+    private BigDecimal emptyLoadValue;
+}

+ 106 - 0
iot-platform-manager/src/main/java/com/platform/api/response/WeighbridgePageResVo.java

@@ -0,0 +1,106 @@
+package com.platform.api.response;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 地磅分页响应。
+ */
+@Data
+@Schema(description = "地磅分页响应")
+public class WeighbridgePageResVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键ID。
+     */
+    @Schema(description = "主键ID")
+    private Long id;
+
+    /**
+     * 企业ID。
+     */
+    @Schema(description = "企业ID")
+    private Long entId;
+
+    /**
+     * 企业名称。
+     */
+    @Schema(description = "企业名称")
+    private String enterpriseName;
+
+    /**
+     * 地磅名称。
+     */
+    @Schema(description = "地磅名称")
+    private String weighbridgeName;
+
+    /**
+     * 唯一编码。
+     */
+    @Schema(description = "唯一编码")
+    private String uniqueCode;
+
+    /**
+     * 在线状态,0-离线,1-在线。
+     */
+    @Schema(description = "在线状态,0-离线,1-在线")
+    private Integer onlineStatus;
+
+    /**
+     * 在线状态名称。
+     */
+    @Schema(description = "在线状态名称")
+    private String onlineStatusName;
+
+    /**
+     * 关联打印机ID。
+     */
+    @Schema(description = "关联打印机ID")
+    private Long printerId;
+
+    /**
+     * 关联打印机名称。
+     */
+    @Schema(description = "关联打印机名称")
+    private String printerName;
+
+    /**
+     * 描述。
+     */
+    @Schema(description = "描述")
+    private String description;
+
+    /**
+     * 启停状态,0-启用,1-停用。
+     */
+    @Schema(description = "启停状态,0-启用,1-停用")
+    private Integer status;
+
+    /**
+     * 启停状态名称。
+     */
+    @Schema(description = "启停状态名称")
+    private String statusName;
+
+    /**
+     * 创建时间。
+     */
+    @Schema(description = "创建时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date createTime;
+
+    /**
+     * 最近重启时间。
+     */
+    @Schema(description = "最近重启时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date lastRestartTime;
+}

+ 78 - 0
iot-platform-manager/src/main/java/com/platform/entity/KwsPrinter.java

@@ -0,0 +1,78 @@
+package com.platform.entity;
+
+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 com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 打印机
+ */
+@Data
+@Accessors(chain = true)
+@TableName("kws_printer")
+public class KwsPrinter implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    @TableId(type = IdType.ASSIGN_ID)
+    private Long id;
+
+    @TableField("ent_id")
+    private Long entId;
+
+    @TableField("printer_name")
+    private String printerName;
+
+    /**
+     * 打印机类型,如:热敏打印机、墨带打印机
+     */
+    @TableField("printer_type")
+    private String printerType;
+
+    /**
+     * 可使用寿命
+     */
+    @TableField("useful_life")
+    private String usefulLife;
+
+    /**
+     * 在线状态: 0-离线, 1-在线
+     */
+    @TableField("online_status")
+    private Integer onlineStatus;
+
+    /**
+     * 启停状态: 0-启用, 1-停用
+     */
+    @TableField("status")
+    private Integer status;
+
+    @TableField("create_by")
+    private Long createBy;
+
+    @TableField("create_time")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date createTime;
+
+    @TableField("update_by")
+    private Long updateBy;
+
+    @TableField("update_time")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date updateTime;
+
+    @TableField("del_flag")
+    private Integer delFlag;
+
+    @TableField("remark")
+    private String remark;
+}

+ 88 - 0
iot-platform-manager/src/main/java/com/platform/entity/KwsWeighbridge.java

@@ -0,0 +1,88 @@
+package com.platform.entity;
+
+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 com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 无人地磅
+ */
+@Data
+@Accessors(chain = true)
+@TableName("kws_weighbridge")
+public class KwsWeighbridge implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    @TableId(type = IdType.ASSIGN_ID)
+    private Long id;
+
+    @TableField("ent_id")
+    private Long entId;
+
+    @TableField("ent_name")
+    private String entName;
+
+    @TableField("weighbridge_name")
+    private String weighbridgeName;
+
+    @TableField("unique_code")
+    private String uniqueCode;
+
+    /**
+     * 在线状态: 0-离线, 1-在线
+     */
+    @TableField("online_status")
+    private Integer onlineStatus;
+
+    @TableField("printer_id")
+    private Long printerId;
+
+    @TableField("description")
+    private String description;
+
+    /**
+     * 差异化配置,先用 JSON 字符串承载
+     */
+    @TableField("diff_config")
+    private String diffConfig;
+
+    @TableField("last_restart_time")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date lastRestartTime;
+
+    /**
+     * 启停状态: 0-启用, 1-停用
+     */
+    @TableField("status")
+    private Integer status;
+
+    @TableField("create_by")
+    private Long createBy;
+
+    @TableField("create_time")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date createTime;
+
+    @TableField("update_by")
+    private Long updateBy;
+
+    @TableField("update_time")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date updateTime;
+
+    @TableField("del_flag")
+    private Integer delFlag;
+
+    @TableField("remark")
+    private String remark;
+}

+ 62 - 0
iot-platform-manager/src/main/java/com/platform/entity/KwsWeighbridgeDiffConfig.java

@@ -0,0 +1,62 @@
+package com.platform.entity;
+
+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 com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 地磅差异化配置。
+ */
+@Data
+@Accessors(chain = true)
+@TableName("kws_weighbridge_diff_config")
+public class KwsWeighbridgeDiffConfig implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    @TableId(type = IdType.ASSIGN_ID)
+    private Long id;
+
+    @TableField("ent_id")
+    private Long entId;
+    @TableField("ent_name")
+    private String entName;
+
+
+    @TableField("tare_error_value")
+    private BigDecimal tareErrorValue;
+
+    @TableField("load_error_value")
+    private BigDecimal loadErrorValue;
+
+    @TableField("empty_load_value")
+    private BigDecimal emptyLoadValue;
+
+    @TableField("create_by")
+    private Long createBy;
+
+    @TableField("create_time")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date createTime;
+
+    @TableField("update_by")
+    private Long updateBy;
+
+    @TableField("update_time")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date updateTime;
+
+    @TableField("del_flag")
+    private Integer delFlag;
+}

+ 59 - 0
iot-platform-manager/src/main/java/com/platform/entity/KwsWeighbridgeRecord.java

@@ -0,0 +1,59 @@
+package com.platform.entity;
+
+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 com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 地磅称重记录
+ */
+@Data
+@Accessors(chain = true)
+@TableName("kws_weighbridge_record")
+public class KwsWeighbridgeRecord implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    @TableId(type = IdType.ASSIGN_ID)
+    private Long id;
+
+    @TableField("weighbridge_id")
+    private Long weighbridgeId;
+
+    @TableField("truck_no")
+    private String truckNo;
+
+    @TableField("weight")
+    private BigDecimal weight;
+
+    @TableField("receive_time")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date receiveTime;
+
+    @TableField("create_by")
+    private Long createBy;
+
+    @TableField("create_time")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date createTime;
+
+    @TableField("update_by")
+    private Long updateBy;
+
+    @TableField("update_time")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date updateTime;
+
+    @TableField("del_flag")
+    private Integer delFlag;
+}

+ 9 - 0
iot-platform-manager/src/main/java/com/platform/mapper/KwsPrinterDao.java

@@ -0,0 +1,9 @@
+package com.platform.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.platform.entity.KwsPrinter;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface KwsPrinterDao extends BaseMapper<KwsPrinter> {
+}

+ 9 - 0
iot-platform-manager/src/main/java/com/platform/mapper/KwsWeighbridgeDao.java

@@ -0,0 +1,9 @@
+package com.platform.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.platform.entity.KwsWeighbridge;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface KwsWeighbridgeDao extends BaseMapper<KwsWeighbridge> {
+}

+ 12 - 0
iot-platform-manager/src/main/java/com/platform/mapper/KwsWeighbridgeDiffConfigDao.java

@@ -0,0 +1,12 @@
+package com.platform.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.platform.entity.KwsWeighbridgeDiffConfig;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 地磅差异化配置 Mapper。
+ */
+@Mapper
+public interface KwsWeighbridgeDiffConfigDao extends BaseMapper<KwsWeighbridgeDiffConfig> {
+}

+ 10 - 0
iot-platform-manager/src/main/java/com/platform/mapper/KwsWeighbridgeRecordDao.java

@@ -0,0 +1,10 @@
+package com.platform.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+import com.platform.entity.KwsWeighbridgeRecord;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface KwsWeighbridgeRecordDao extends BaseMapper<KwsWeighbridgeRecord> {
+}

+ 49 - 0
iot-platform-manager/src/main/java/com/platform/service/KwsPrinterRepository.java

@@ -0,0 +1,49 @@
+package com.platform.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.platform.entity.KwsPrinter;
+import com.platform.mapper.KwsPrinterDao;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Repository;
+
+import java.util.Collection;
+import java.util.List;
+
+@Repository
+public class KwsPrinterRepository extends ServiceImpl<KwsPrinterDao, KwsPrinter> {
+
+    public IPage<KwsPrinter> pageQuery(int pageNum, int pageSize, String printerName, Collection<Long> entIds) {
+        return page(new Page<>(pageNum, pageSize), Wrappers.<KwsPrinter>lambdaQuery()
+                .eq(KwsPrinter::getDelFlag, 0)
+                .like(StringUtils.isNotBlank(printerName), KwsPrinter::getPrinterName, printerName)
+                .in(entIds != null && !entIds.isEmpty(), KwsPrinter::getEntId, entIds)
+                .orderByDesc(KwsPrinter::getCreateTime)
+                .orderByDesc(KwsPrinter::getId));
+    }
+
+    public KwsPrinter findAvailableById(Long id) {
+        return getOne(Wrappers.<KwsPrinter>lambdaQuery()
+                .eq(KwsPrinter::getId, id)
+                .eq(KwsPrinter::getDelFlag, 0)
+                .last("limit 1"));
+    }
+
+    public KwsPrinter findByEntIdAndName(Long entId, String printerName) {
+        return getOne(Wrappers.<KwsPrinter>lambdaQuery()
+                .eq(KwsPrinter::getDelFlag, 0)
+                .eq(KwsPrinter::getEntId, entId)
+                .eq(KwsPrinter::getPrinterName, printerName)
+                .last("limit 1"));
+    }
+
+    public List<KwsPrinter> listByEntId(Long entId) {
+        return list(Wrappers.<KwsPrinter>lambdaQuery()
+                .eq(KwsPrinter::getDelFlag, 0)
+                .eq(KwsPrinter::getStatus, 0)
+                .eq(KwsPrinter::getEntId, entId)
+                .orderByDesc(KwsPrinter::getCreateTime));
+    }
+}

+ 22 - 0
iot-platform-manager/src/main/java/com/platform/service/KwsWeighbridgeDiffConfigRepository.java

@@ -0,0 +1,22 @@
+package com.platform.service;
+
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+import com.platform.entity.KwsWeighbridgeDiffConfig;
+import com.platform.mapper.KwsWeighbridgeDiffConfigDao;
+import org.springframework.stereotype.Repository;
+
+/**
+ * 地磅差异化配置仓储。
+ */
+@Repository
+public class KwsWeighbridgeDiffConfigRepository extends ServiceImpl<KwsWeighbridgeDiffConfigDao, KwsWeighbridgeDiffConfig> {
+
+    public KwsWeighbridgeDiffConfig findByEntId(Long entId) {
+        return getOne(Wrappers.<KwsWeighbridgeDiffConfig>lambdaQuery()
+                .eq(KwsWeighbridgeDiffConfig::getEntId, entId)
+                .eq(KwsWeighbridgeDiffConfig::getDelFlag, 0)
+                .last("limit 1"));
+    }
+}

+ 55 - 0
iot-platform-manager/src/main/java/com/platform/service/KwsWeighbridgeRecordRepository.java

@@ -0,0 +1,55 @@
+package com.platform.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.platform.entity.KwsWeighbridgeRecord;
+import com.platform.mapper.KwsWeighbridgeRecordDao;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Repository;
+
+import java.math.BigDecimal;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+
+@Repository
+public class KwsWeighbridgeRecordRepository extends ServiceImpl<KwsWeighbridgeRecordDao, KwsWeighbridgeRecord> {
+
+    public IPage<KwsWeighbridgeRecord> pageQuery(int pageNum, int pageSize, Collection<Long> weighbridgeIds,
+                                                 String truckNo, BigDecimal minWeight, BigDecimal maxWeight,
+                                                 Date createStartTime, Date createEndTime,
+                                                 Date receiveStartTime, Date receiveEndTime) {
+        return page(new Page<>(pageNum, pageSize), Wrappers.<KwsWeighbridgeRecord>lambdaQuery()
+                .eq(KwsWeighbridgeRecord::getDelFlag, 0)
+                .in(weighbridgeIds != null && !weighbridgeIds.isEmpty(), KwsWeighbridgeRecord::getWeighbridgeId, weighbridgeIds)
+                .like(StringUtils.isNotBlank(truckNo), KwsWeighbridgeRecord::getTruckNo, truckNo)
+                .ge(minWeight != null, KwsWeighbridgeRecord::getWeight, minWeight)
+                .le(maxWeight != null, KwsWeighbridgeRecord::getWeight, maxWeight)
+                .ge(createStartTime != null, KwsWeighbridgeRecord::getCreateTime, createStartTime)
+                .le(createEndTime != null, KwsWeighbridgeRecord::getCreateTime, createEndTime)
+                .ge(receiveStartTime != null, KwsWeighbridgeRecord::getReceiveTime, receiveStartTime)
+                .le(receiveEndTime != null, KwsWeighbridgeRecord::getReceiveTime, receiveEndTime)
+                .orderByDesc(KwsWeighbridgeRecord::getCreateTime)
+                .orderByDesc(KwsWeighbridgeRecord::getId));
+    }
+
+    public List<KwsWeighbridgeRecord> listQuery(Collection<Long> weighbridgeIds,
+                                                String truckNo, BigDecimal minWeight, BigDecimal maxWeight,
+                                                Date createStartTime, Date createEndTime,
+                                                Date receiveStartTime, Date receiveEndTime) {
+        return list(Wrappers.<KwsWeighbridgeRecord>lambdaQuery()
+                .eq(KwsWeighbridgeRecord::getDelFlag, 0)
+                .in(weighbridgeIds != null && !weighbridgeIds.isEmpty(), KwsWeighbridgeRecord::getWeighbridgeId, weighbridgeIds)
+                .like(StringUtils.isNotBlank(truckNo), KwsWeighbridgeRecord::getTruckNo, truckNo)
+                .ge(minWeight != null, KwsWeighbridgeRecord::getWeight, minWeight)
+                .le(maxWeight != null, KwsWeighbridgeRecord::getWeight, maxWeight)
+                .ge(createStartTime != null, KwsWeighbridgeRecord::getCreateTime, createStartTime)
+                .le(createEndTime != null, KwsWeighbridgeRecord::getCreateTime, createEndTime)
+                .ge(receiveStartTime != null, KwsWeighbridgeRecord::getReceiveTime, receiveStartTime)
+                .le(receiveEndTime != null, KwsWeighbridgeRecord::getReceiveTime, receiveEndTime)
+                .orderByDesc(KwsWeighbridgeRecord::getCreateTime)
+                .orderByDesc(KwsWeighbridgeRecord::getId));
+    }
+}

+ 60 - 0
iot-platform-manager/src/main/java/com/platform/service/KwsWeighbridgeRepository.java

@@ -0,0 +1,60 @@
+package com.platform.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+import com.platform.entity.KwsWeighbridge;
+import com.platform.mapper.KwsWeighbridgeDao;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Repository;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Objects;
+
+@Repository
+public class KwsWeighbridgeRepository extends ServiceImpl<KwsWeighbridgeDao, KwsWeighbridge> {
+
+    public IPage<KwsWeighbridge> pageQuery(int pageNum, int pageSize, String weighbridgeName, Long entId) {
+        return page(new Page<>(pageNum, pageSize), Wrappers.<KwsWeighbridge>lambdaQuery()
+                .eq(KwsWeighbridge::getDelFlag, 0)
+                .like(StringUtils.isNotBlank(weighbridgeName), KwsWeighbridge::getWeighbridgeName, weighbridgeName)
+                .eq(Objects.nonNull(entId) , KwsWeighbridge::getEntId, entId)
+                .orderByDesc(KwsWeighbridge::getCreateTime)
+                .orderByDesc(KwsWeighbridge::getId));
+    }
+
+    public KwsWeighbridge findAvailableById(Long id) {
+        return getOne(Wrappers.<KwsWeighbridge>lambdaQuery()
+                .eq(KwsWeighbridge::getId, id)
+                .eq(KwsWeighbridge::getDelFlag, 0)
+                .last("limit 1"));
+    }
+
+    public KwsWeighbridge findByUniqueCode(String uniqueCode) {
+        return getOne(Wrappers.<KwsWeighbridge>lambdaQuery()
+                .eq(KwsWeighbridge::getUniqueCode, uniqueCode)
+                .eq(KwsWeighbridge::getDelFlag, 0)
+                .last("limit 1"));
+    }
+
+    public List<KwsWeighbridge> listByNameAndCode(String weighbridgeName, String uniqueCode, Collection<Long> entIds) {
+        return list(Wrappers.<KwsWeighbridge>lambdaQuery()
+                .eq(KwsWeighbridge::getDelFlag, 0)
+                .like(StringUtils.isNotBlank(weighbridgeName), KwsWeighbridge::getWeighbridgeName, weighbridgeName)
+                .like(StringUtils.isNotBlank(uniqueCode), KwsWeighbridge::getUniqueCode, uniqueCode)
+                .in(entIds != null && !entIds.isEmpty(), KwsWeighbridge::getEntId, entIds)
+                .orderByDesc(KwsWeighbridge::getCreateTime));
+    }
+
+    public boolean updateDiffConfigByEntId(Long entId, String diffConfig, Long updateBy) {
+        return update(Wrappers.<KwsWeighbridge>lambdaUpdate()
+                .eq(KwsWeighbridge::getEntId, entId)
+                .eq(KwsWeighbridge::getDelFlag, 0)
+                .set(KwsWeighbridge::getDiffConfig, diffConfig)
+                .set(KwsWeighbridge::getUpdateBy, updateBy)
+                .set(KwsWeighbridge::getUpdateTime, new java.util.Date()));
+    }
+}

+ 10 - 0
pom.xml

@@ -151,7 +151,17 @@
 				<artifactId>druid-spring-boot-starter</artifactId>
 				<version>1.2.24</version>
 			</dependency>
+			<dependency>
+				<groupId>com.github.pagehelper</groupId>
+				<artifactId>pagehelper</artifactId>
+				<version>5.3.2</version>
+			</dependency>
 
+			<dependency>
+				<groupId>com.alibaba</groupId>
+				<artifactId>fastjson</artifactId>
+				<version>2.0.38</version>
+			</dependency>
 		</dependencies>
 	</dependencyManagement>