From 6de91448441d3cab1b7287e6f792c6e7d6a09d46 Mon Sep 17 00:00:00 2001
From: sxu <602087911@qq.com>
Date: Mon, 5 Aug 2024 10:57:32 +0800
Subject: [PATCH 1/4] =?UTF-8?q?=E5=BA=93=E5=AD=98=E6=97=A5=E5=BF=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../com/bonus/sgzb/system/api/domain/BmNumLogs.java | 3 +++
.../java/com/bonus/sgzb/app/domain/BackApplyInfo.java | 3 +++
.../sgzb/app/service/impl/BackReceiveServiceImpl.java | 2 ++
.../sgzb/system/service/impl/BmNumLogsService.java | 1 +
.../main/resources/mapper/system/BmNumLogsMapper.xml | 10 ++++++----
sgzb-ui/src/views/inventoryLogs/index.vue | 3 ++-
6 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/domain/BmNumLogs.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/domain/BmNumLogs.java
index 4b3a60aa..08ae6870 100644
--- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/domain/BmNumLogs.java
+++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/domain/BmNumLogs.java
@@ -131,6 +131,9 @@ public class BmNumLogs extends BaseEntity {
@Excel(name = "报废数量")
private String scrapNum;
+ @Excel(name = "操作后库存")
+ private String postStoreNum;
+
@Excel(name = "出库类型 0编码出库 1数量出库 2成套出库")
private String manageType;
diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/BackApplyInfo.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/BackApplyInfo.java
index 9b416e81..25a70464 100644
--- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/BackApplyInfo.java
+++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/BackApplyInfo.java
@@ -236,4 +236,7 @@ public class BackApplyInfo {
/**0:未完成退料,可以撤回 1:已完成退料,不能撤回*/
private Integer isFinished;
+
+ /** 操作后库存 */
+ private String postStoreNum;
}
diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java
index 55070562..baca46c2 100644
--- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java
+++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java
@@ -259,6 +259,8 @@ public class BackReceiveServiceImpl implements BackReceiveService {
record.setPassNum(passNum);
record.setMaintenanceNum(maintenanceNum);
record.setScrapNum(scrapNum);
+ int postStoreNum = backReceiveMapper.getmaChineByCt(record);
+ record.setPostStoreNum(String.valueOf(postStoreNum));
}
} else {
throw new RuntimeException("typeId为空");
diff --git a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/BmNumLogsService.java b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/BmNumLogsService.java
index c5036845..d9d5c394 100644
--- a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/BmNumLogsService.java
+++ b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/BmNumLogsService.java
@@ -45,6 +45,7 @@ public class BmNumLogsService{
record.setPassNum(des.getPassNum()); //退料合格数量
record.setMaintenanceNum(des.getMaintenanceNum()); //退料维修数量
record.setScrapNum(des.getScrapNum()); //退料报废数量
+ record.setPostStoreNum(des.getPostStoreNum()); //操作后库存数
record.setManageType(des.getManageType());
record.setTaskId(des.getTaskId());
record.setTypeId(des.getTypeId());
diff --git a/sgzb-modules/sgzb-system/src/main/resources/mapper/system/BmNumLogsMapper.xml b/sgzb-modules/sgzb-system/src/main/resources/mapper/system/BmNumLogsMapper.xml
index 1357ddbf..00967889 100644
--- a/sgzb-modules/sgzb-system/src/main/resources/mapper/system/BmNumLogsMapper.xml
+++ b/sgzb-modules/sgzb-system/src/main/resources/mapper/system/BmNumLogsMapper.xml
@@ -21,6 +21,7 @@
+
@@ -39,7 +40,7 @@
select
bnl.id, bnl.model_title, bnl.`method`, bnl.task_id, bnl.type_id, bnl.pre_num, bnl.audit_num, bnl.pre_store_num, bnl.in_num, bnl.out_num,
bnl.back_num, bnl.pass_num, bnl.maintenance_num, bnl.scrap_num, bnl.`description`, bnl.json_result, bnl.create_time, bnl.creator, bnl.manage_type,
- bnl.remark, bnl.`status`, mt.type_name, mt1.type_name as type_parent_name, tt.code as task_name
+ bnl.remark, bnl.`status`, mt.type_name, mt1.type_name as type_parent_name, tt.code as task_name, bnl.post_store_num
from bm_num_logs bnl
left join ma_type mt on bnl.type_id = mt.type_id
inner join ma_type mt1 on mt.parent_id = mt1.type_id
@@ -51,7 +52,7 @@
select
bnl.id, bnl.model_title, bnl.`method`, bnl.task_id, bnl.type_id, bnl.pre_num, bnl.audit_num, bnl.pre_store_num, bnl.in_num, bnl.out_num,
bnl.back_num, bnl.pass_num, bnl.maintenance_num, bnl.scrap_num, bnl.`description`, bnl.json_result, bnl.create_time, bnl.creator, bnl.manage_type,
- bnl.remark, bnl.`status`, mt.type_name, mt1.type_name as type_parent_name, tt.code as task_name
+ bnl.remark, bnl.`status`, mt.type_name, mt1.type_name as type_parent_name, tt.code as task_name, bnl.post_store_num
from bm_num_logs bnl
left join ma_type mt on bnl.type_id = mt.type_id
inner join ma_type mt1 on mt.parent_id = mt1.type_id
@@ -78,13 +79,14 @@
description, json_result, create_time, creator, remark,
pre_num, input_num, out_num, audit_num, manage_type,
type_name, type_model_name, pre_store_num, in_num,
- back_num, pass_num, maintenance_num, scrap_num, `status`
+ back_num, pass_num, maintenance_num, scrap_num, `status`, post_store_num
)
values (#{modelTitle,jdbcType=VARCHAR}, #{method,jdbcType=VARCHAR}, #{taskId,jdbcType=VARCHAR}, #{typeId,jdbcType=INTEGER},
#{description,jdbcType=VARCHAR}, #{jsonResult,jdbcType=VARCHAR}, now(), #{creator,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR},
#{preNum,jdbcType=VARCHAR}, #{inputNum,jdbcType=VARCHAR}, #{outNum,jdbcType=VARCHAR}, #{auditNum,jdbcType=VARCHAR}, #{manageType,jdbcType=VARCHAR},
#{typeName,jdbcType=VARCHAR}, #{typeModelName,jdbcType=VARCHAR}, #{preStoreNum,jdbcType=VARCHAR}, #{inNum,jdbcType=VARCHAR},
- #{backNum,jdbcType=VARCHAR}, #{passNum,jdbcType=VARCHAR}, #{maintenanceNum,jdbcType=VARCHAR}, #{scrapNum,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}
+ #{backNum,jdbcType=VARCHAR}, #{passNum,jdbcType=VARCHAR}, #{maintenanceNum,jdbcType=VARCHAR}, #{scrapNum,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR},
+ #{postStoreNum,jdbcType=VARCHAR}
)
diff --git a/sgzb-ui/src/views/inventoryLogs/index.vue b/sgzb-ui/src/views/inventoryLogs/index.vue
index f343d829..e76b0fbc 100644
--- a/sgzb-ui/src/views/inventoryLogs/index.vue
+++ b/sgzb-ui/src/views/inventoryLogs/index.vue
@@ -43,6 +43,7 @@
+
@@ -50,7 +51,7 @@
异常
-
+
From da356b8535ff8599599b0bd6d65f5f924e9d4c00 Mon Sep 17 00:00:00 2001
From: sxu <602087911@qq.com>
Date: Mon, 5 Aug 2024 10:58:26 +0800
Subject: [PATCH 2/4] =?UTF-8?q?=E5=BA=93=E5=AD=98=E6=97=A5=E5=BF=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sgzb-ui/src/views/inventoryLogs/index.vue | 1 +
1 file changed, 1 insertion(+)
diff --git a/sgzb-ui/src/views/inventoryLogs/index.vue b/sgzb-ui/src/views/inventoryLogs/index.vue
index e76b0fbc..1450eae0 100644
--- a/sgzb-ui/src/views/inventoryLogs/index.vue
+++ b/sgzb-ui/src/views/inventoryLogs/index.vue
@@ -124,6 +124,7 @@ export default {
{ label: '合格数量', content: 'passNum' },
{ label: '维修数量', content: 'maintenanceNum' },
{ label: '报废数量', content: 'scrapNum' },
+ { label: '操作后库存', content: 'postStoreNum' },
{ label: '请求地址', content: 'method' },
],
logsDetailsInfo: {},
From 0f670f7ac5dcf4db64a8441808ca13b7fde628e7 Mon Sep 17 00:00:00 2001
From: 76164 <761646706@qq.com>
Date: Mon, 5 Aug 2024 13:20:05 +0800
Subject: [PATCH 3/4] =?UTF-8?q?IOT=E8=AE=BE=E5=A4=87=E7=BB=91=E5=AE=9A?=
=?UTF-8?q?=E6=9F=A5=E7=9C=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../sgzb/material/config/ExceptionEnum.java | 6 +
.../sgzb/material/config/FieldGenerator.java | 2 +-
.../controller/IotMachineController.java | 149 ++++++++++
.../bonus/sgzb/material/domain/IotCodeVo.java | 20 ++
.../bonus/sgzb/material/domain/IotDto.java | 79 ++++++
.../sgzb/material/domain/IotRecordVo.java | 37 +++
.../bonus/sgzb/material/domain/IotTypeVo.java | 21 ++
.../com/bonus/sgzb/material/domain/IotVo.java | 62 ++++
.../material/mapper/IotMachineMapper.java | 120 ++++++++
.../material/service/IotMachineService.java | 79 ++++++
.../service/impl/IotMachineServiceImpl.java | 268 ++++++++++++++++++
.../mapper/material/IotMachineMapper.xml | 207 ++++++++++++++
12 files changed, 1049 insertions(+), 1 deletion(-)
create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/IotMachineController.java
create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/IotCodeVo.java
create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/IotDto.java
create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/IotRecordVo.java
create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/IotTypeVo.java
create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/IotVo.java
create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/IotMachineMapper.java
create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/IotMachineService.java
create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/IotMachineServiceImpl.java
create mode 100644 sgzb-modules/sgzb-material/src/main/resources/mapper/material/IotMachineMapper.xml
diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/config/ExceptionEnum.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/config/ExceptionEnum.java
index 61c96253..8f844a74 100644
--- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/config/ExceptionEnum.java
+++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/config/ExceptionEnum.java
@@ -12,8 +12,14 @@ import lombok.Getter;
@AllArgsConstructor
public enum ExceptionEnum {
+ PARAM_NULL(1001, "参数为空"),
+ IOT_CODE_DUPLICATE(1002, "设备编号重复"),
+ IOT_TO_DELETE(1003, "该iot设备绑定相关类型设备,无法删除"),
+ SUCCESS(200, "操作成功"),
SAVE_TO_DATABASE(500, "新增保存失败,请联系管理员!!!"),
DELETE_TO_DATABASE(500, "删除失败,请联系管理员!!!"),
+ BIND_TO_DATABASE(500, "绑定失败,请联系管理员!!!"),
+ UN_BIND_TO_DATABASE(500, "解绑失败,请联系管理员!!!"),
UPDATE_TO_DATABASE(500, "修改失败,请联系管理员!!!");
private Integer code;
diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/config/FieldGenerator.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/config/FieldGenerator.java
index f546c64b..0d985289 100644
--- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/config/FieldGenerator.java
+++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/config/FieldGenerator.java
@@ -14,7 +14,7 @@ public class FieldGenerator {
public static String generateField() {
LocalDate today = LocalDate.now();
String currentDate = today.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
- // 生成UUID并取后4位,转换为纯数字类型
+ // 生成UUID并取后7位,转换为纯数字类型
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
String uuidLast4Digits = uuid.substring(uuid.length() - 7);
int uuidLast4DigitsNumeric = Integer.parseInt(uuidLast4Digits, 16);
diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/IotMachineController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/IotMachineController.java
new file mode 100644
index 00000000..53955838
--- /dev/null
+++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/IotMachineController.java
@@ -0,0 +1,149 @@
+package com.bonus.sgzb.material.controller;
+
+import com.bonus.sgzb.common.core.web.controller.BaseController;
+import com.bonus.sgzb.common.core.web.domain.AjaxResult;
+import com.bonus.sgzb.common.core.web.page.TableDataInfo;
+import com.bonus.sgzb.material.domain.IotDto;
+import com.bonus.sgzb.material.domain.IotRecordVo;
+import com.bonus.sgzb.material.domain.IotVo;
+import com.bonus.sgzb.material.service.IotMachineService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * @Author
+ * @create 2024/8/5
+ * iot设备管理控制层
+ */
+@Api(tags = " iot设备管理控制层")
+@RestController
+@RequestMapping("/iotMachine")
+@Slf4j
+public class IotMachineController extends BaseController {
+
+
+ @Resource
+ private IotMachineService iotMachineService;
+
+ /**
+ * 获取设备管理列表
+ */
+ @ApiOperation(value = "获取设备管理列表")
+ @GetMapping("/getIotList")
+ public TableDataInfo getIotList(IotDto iotDto) {
+ log.info("获取设备管理列表传参:{}", iotDto);
+ startPage();
+ List list = iotMachineService.getIotList(iotDto);
+ return getDataTable(list);
+ }
+
+ /**
+ * 添加或者修改设备
+ * @param iotDto
+ * @return
+ */
+ @ApiOperation("添加或者修改设备")
+ @PostMapping("/addOrUpdate")
+ public AjaxResult addOrUpdate(@Validated @RequestBody IotDto iotDto) {
+ log.info("添加或者修改设备传参:{}", iotDto);
+ if (iotDto.getIotId() != null) {
+ return iotMachineService.update(iotDto);
+ }
+ return iotMachineService.add(iotDto);
+ }
+
+ /**
+ * 删除设备
+ * @param iotId
+ * @return
+ */
+ @ApiOperation(value = "删除设备")
+ @DeleteMapping("/deleteById/{iotId}")
+ public AjaxResult deleteByIds(@PathVariable("iotId") Long iotId) {
+ log.info("删除设备传参:{}", iotId);
+ return iotMachineService.deleteById(iotId);
+ }
+
+ /**
+ * 绑定设备
+ * @param iotDto
+ * @return
+ */
+ @ApiOperation("绑定设备")
+ @PostMapping("/bind")
+ public AjaxResult bind(@Validated @RequestBody IotDto iotDto) {
+ log.info("绑定设备传参:{}", iotDto);
+ return iotMachineService.bind(iotDto);
+ }
+
+ /**
+ * 解绑设备
+ * @param iotDto
+ * @return
+ */
+ @ApiOperation("解绑设备")
+ @PostMapping("/unbind")
+ public AjaxResult unbind(@Validated @RequestBody IotDto iotDto) {
+ log.info("解绑设备传参:{}", iotDto);
+ return iotMachineService.unbind(iotDto);
+ }
+
+ /**
+ * 根据类型id查询设备绑定列表
+ * @param iotDto
+ * @return
+ */
+ @ApiOperation("根据类型id查询设备绑定列表")
+ @GetMapping("/getTypeList")
+ public TableDataInfo getTypeList(IotDto iotDto) {
+ startPage();
+ log.info("根据类型id查询设备绑定列表传参:{}", iotDto);
+ List typeList = iotMachineService.getTypeList(iotDto);
+ return getDataTable(typeList);
+ }
+
+ /**
+ * 根据iot设备类型查询设备编码
+ * @param iotDto
+ * @return
+ */
+ @ApiOperation("根据iot设备类型查询设备编码")
+ @GetMapping("/selectList")
+ public AjaxResult selectList(IotDto iotDto) {
+ log.info("根据iot设备类型查询设备编码:{}", iotDto);
+ return iotMachineService.selectList(iotDto);
+ }
+
+ /**
+ * 根据iot设备获取绑定记录(分页)
+ * @param iotDto
+ * @return
+ */
+ @ApiOperation("根据iot设备获取绑定记录(分页)")
+ @GetMapping("/getRecordList")
+ public TableDataInfo getRecordList(IotDto iotDto) {
+ startPage();
+ log.info("根据iot设备获取绑定记录(分页):{}", iotDto);
+ List list = iotMachineService.getRecordList(iotDto);
+ return getDataTable(list);
+ }
+
+ /**
+ * 根据iot设备获取绑定记录(全量不分页,供前端数据使用)
+ * @param iotDto
+ * @return
+ */
+ @ApiOperation("根据iot设备获取绑定记录(全量不分页,供前端数据使用)")
+ @GetMapping("/getRecordListAll")
+ public AjaxResult getRecordListAll(IotDto iotDto) {
+ List list = iotMachineService.getRecordList(iotDto);
+ return AjaxResult.success(list);
+ }
+
+}
diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/IotCodeVo.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/IotCodeVo.java
new file mode 100644
index 00000000..2da585e8
--- /dev/null
+++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/IotCodeVo.java
@@ -0,0 +1,20 @@
+package com.bonus.sgzb.material.domain;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @Author ma_sh
+ * @create 2024/7/11 15:21
+ */
+@Data
+public class IotCodeVo {
+
+ /** iot设备ID */
+ @ApiModelProperty(value = "iot设备ID")
+ private Long iotId;
+
+ /** iot设备编码 */
+ @ApiModelProperty(value = "iot设备编码")
+ private String iotCode;
+}
diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/IotDto.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/IotDto.java
new file mode 100644
index 00000000..fea8c85d
--- /dev/null
+++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/IotDto.java
@@ -0,0 +1,79 @@
+package com.bonus.sgzb.material.domain;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @Author ma_sh
+ * @create 2024/7/4 17:10
+ * iot设备管理传参dto
+ */
+@Data
+public class IotDto {
+
+ /** iot设备ID */
+ @ApiModelProperty(value = "iot设备ID")
+ private Long id;
+
+ /** iot设备ID */
+ @ApiModelProperty(value = "iot设备ID")
+ private Long iotId;
+
+ /** 类型id */
+ @ApiModelProperty(value = "类型id")
+ private Long typeId;
+
+ /** 被绑定机具编号 */
+ @ApiModelProperty(value = "被绑定机具编号")
+ private String maCode;
+
+ /** iot设备类型 */
+ @ApiModelProperty(value = "iot设备类型")
+ private String iotType;
+
+ @ApiModelProperty(value = "iot设备类型id")
+ private String iotTypeId;
+
+ /** iot设备编码 */
+ @ApiModelProperty(value = "iot设备编码")
+ private String iotCode;
+
+ /** iot设备状态 (0 在线, 1 下线)*/
+ @ApiModelProperty(value = "iot设备状态 (0 在线, 1 下线)")
+ private int iotStatus;
+
+ /** iot设备二维码 */
+ @ApiModelProperty(value = "iot设备二维码")
+ private String qrCode;
+
+ /** 创建人 */
+ @ApiModelProperty(value = "创建人")
+ private String createBy;
+
+ /** 创建时间 */
+ @ApiModelProperty(value = "创建时间")
+ private Date createTime;
+
+ /** 更新人 */
+ @ApiModelProperty(value = "更新人")
+ private String updateBy;
+
+ /** 更新时间 */
+ @ApiModelProperty(value = "更新时间")
+ private Date updateTime;
+
+ /** 绑定人 */
+ @ApiModelProperty(value = "绑定人")
+ private String binder;
+
+ /** 解绑人 */
+ @ApiModelProperty(value = "解绑人")
+ private String unBinder;
+
+ /** 关键字 */
+ @ApiModelProperty(value = "关键字")
+ private String keyWord;
+
+}
diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/IotRecordVo.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/IotRecordVo.java
new file mode 100644
index 00000000..afe17e49
--- /dev/null
+++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/IotRecordVo.java
@@ -0,0 +1,37 @@
+package com.bonus.sgzb.material.domain;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+
+/**
+ * @Author ma_sh
+ * @create 2024/7/11 15:55
+ * @Description iot绑定记录返回vo
+ */
+@Data
+public class IotRecordVo {
+
+ /** iot设备ID */
+ @ApiModelProperty(value = "iot设备ID")
+ private Long id;
+
+ @ApiModelProperty(value = "iot设备id")
+ private Long iotId;
+
+ @ApiModelProperty(value = "绑定类型id")
+ private Long typeId;
+
+ @ApiModelProperty(value = "绑定类型名称")
+ private String typeName;
+
+ @ApiModelProperty(value = "设备编码")
+ private String maCode;
+
+ @ApiModelProperty(value = "绑定时间")
+ private String bindTime;
+
+ /** 解绑时间 */
+ @ApiModelProperty(value = "解绑时间")
+ private String unBindTime;
+}
diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/IotTypeVo.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/IotTypeVo.java
new file mode 100644
index 00000000..b99b9e5f
--- /dev/null
+++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/IotTypeVo.java
@@ -0,0 +1,21 @@
+package com.bonus.sgzb.material.domain;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @Author ma_sh
+ * @create 2024/7/11 14:57
+ */
+@Data
+public class IotTypeVo {
+
+ @ApiModelProperty(value = "iot设备类型id")
+ private String iotTypeId;
+
+ @ApiModelProperty(value = "父级id")
+ private String pId;
+
+ @ApiModelProperty(value = "iot设备类型名称")
+ private String iotTypeName;
+}
diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/IotVo.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/IotVo.java
new file mode 100644
index 00000000..db0af274
--- /dev/null
+++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/IotVo.java
@@ -0,0 +1,62 @@
+package com.bonus.sgzb.material.domain;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @Author ma_sh
+ * @create 2024/7/4 17:00
+ * iot设备管理返回vo
+ */
+@Data
+public class IotVo {
+
+ /** iot设备ID */
+ @ApiModelProperty(value = "iot设备ID")
+ private Long id;
+
+ /** iot设备ID */
+ @ApiModelProperty(value = "iot设备ID")
+ private Long iotId;
+
+ /** iot设备类型 */
+ @ApiModelProperty(value = "iot设备类型")
+ private String iotType;
+
+ /** iot设备类型名称 */
+ @ApiModelProperty(value = "iot设备类型名称")
+ private String iotTypeName;
+
+ /** iot设备编码 */
+ @ApiModelProperty(value = "iot设备编码")
+ private String iotCode;
+
+ /** iot设备状态 (0 在线, 1 下线)*/
+ @ApiModelProperty(value = "iot设备状态 (0 在线, 1 下线)")
+ private int iotStatus;
+
+ /** iot设备二维码 */
+ @ApiModelProperty(value = "iot设备二维码")
+ private String qrCode;
+
+ /** iot设备绑定状态 (0 已绑定、1 未绑定)*/
+ @ApiModelProperty(value = "iot设备绑定状态 (0 已绑定、1 未绑定)")
+ private int bindStatus;
+
+ /** 绑定人 */
+ @ApiModelProperty(value = "绑定人")
+ private String binder;
+
+ /** 绑定时间 */
+ @ApiModelProperty(value = "绑定时间")
+ private String bindTime;
+
+ /** 解绑人 */
+ @ApiModelProperty(value = "解绑人")
+ private String unBinder;
+
+ /** 解绑时间 */
+ @ApiModelProperty(value = "解绑时间")
+ private String unBindTime;
+
+}
diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/IotMachineMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/IotMachineMapper.java
new file mode 100644
index 00000000..3b64019e
--- /dev/null
+++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/IotMachineMapper.java
@@ -0,0 +1,120 @@
+package com.bonus.sgzb.material.mapper;
+
+import com.bonus.sgzb.material.domain.*;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+/**
+ * @Author ma_sh
+ * @create 2024/7/4 16:28
+ * iot设备管理mapper层
+ */
+@Mapper
+public interface IotMachineMapper {
+
+ /**
+ * 根据iotCode查询iotCode是否存在
+ * @param iotDto
+ * @return
+ */
+ IotVo selectIotCode(IotDto iotDto);
+
+ /**
+ * 根据qrCode查询qrCode是否存在
+ * @param qrCode
+ * @return
+ */
+ int selectQrCode(String qrCode);
+
+ /**
+ * 添加iot设备
+ * @param iotDto
+ * @return
+ */
+ int add(IotDto iotDto);
+
+ /**
+ * 修改iot设备
+ * @param iotDto
+ * @return
+ */
+ int update(IotDto iotDto);
+
+ /**
+ * 根据iotCode查询iotCode是否存在
+ * @param iotDto
+ * @return
+ */
+ List getIotList(IotDto iotDto);
+
+ /**
+ * 根据iotId查询iotId是否存在
+ * @param iotId
+ * @return
+ */
+ IotVo selectById(Long iotId);
+
+ /**
+ * 根据iotId删除iot设备
+ * @param iotId
+ * @return
+ */
+ int deleteById(Long iotId);
+
+ /**
+ * 绑定iot设备
+ * @param iotDto
+ * @return
+ */
+ int bind(IotDto iotDto);
+
+ /**
+ * 更新绑定状态
+ * @param iotDto
+ * @return
+ */
+ int updateBindStatus(IotDto iotDto);
+
+ /**
+ * 解绑iot设备
+ * @param iotDto
+ * @return
+ */
+ int unbind(IotDto iotDto);
+
+ /**
+ * 更新解绑状态
+ * @param iotDto
+ * @return
+ */
+ int updateUnBindStatus(IotDto iotDto);
+
+ /**
+ * 根据类型id查询设备绑定列表
+ * @param iotDto
+ * @return
+ */
+ List getTypeList(IotDto iotDto);
+
+
+ /**
+ * 查询设备类型
+ * @return
+ */
+ List selectList();
+
+ /**
+ * 根据iotTypeId查询设备编码
+ * @param iotTypeId
+ * @return
+ */
+ List selectCodeList(String iotTypeId);
+
+ /**
+ * 根据iotTypeId查询设备编码
+ * @param iotDto
+ * @return
+ */
+ List getRecordList(IotDto iotDto);
+}
diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/IotMachineService.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/IotMachineService.java
new file mode 100644
index 00000000..c6da37c9
--- /dev/null
+++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/IotMachineService.java
@@ -0,0 +1,79 @@
+package com.bonus.sgzb.material.service;
+
+import com.bonus.sgzb.common.core.web.domain.AjaxResult;
+import com.bonus.sgzb.material.domain.IotDto;
+import com.bonus.sgzb.material.domain.IotRecordVo;
+import com.bonus.sgzb.material.domain.IotVo;
+
+import java.util.List;
+
+/**
+ * @Author ma_sh
+ * @create 2024/7/4 16:25
+ * iot设备管理服务层
+ */
+public interface IotMachineService {
+
+ /**
+ * 添加设备
+ * @param iotDto
+ * @return
+ */
+ AjaxResult add(IotDto iotDto);
+
+ /**
+ * 修改设备
+ * @param iotDto
+ * @return
+ */
+ AjaxResult update(IotDto iotDto);
+
+ /**
+ * 获取设备列表
+ * @param iotDto
+ * @return
+ */
+ List getIotList(IotDto iotDto);
+
+ /**
+ * 删除设备
+ * @param iotId
+ * @return
+ */
+ AjaxResult deleteById(Long iotId);
+
+ /**
+ * 绑定设备
+ * @param iotDto
+ * @return
+ */
+ AjaxResult bind(IotDto iotDto);
+
+ /**
+ * 解绑设备
+ * @param iotDto
+ * @return
+ */
+ AjaxResult unbind(IotDto iotDto);
+
+ /**
+ * 根据类型id查询设备绑定列表
+ * @param iotDto
+ * @return
+ */
+ List getTypeList(IotDto iotDto);
+
+ /**
+ * 根据iot设备类型查询设备编码
+ * @param iotDto
+ * @return
+ */
+ AjaxResult selectList(IotDto iotDto);
+
+ /**
+ * 获取设备记录列表
+ * @param iotDto
+ * @return
+ */
+ List getRecordList(IotDto iotDto);
+}
diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/IotMachineServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/IotMachineServiceImpl.java
new file mode 100644
index 00000000..3e739fed
--- /dev/null
+++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/IotMachineServiceImpl.java
@@ -0,0 +1,268 @@
+package com.bonus.sgzb.material.service.impl;
+
+import com.bonus.sgzb.common.core.web.domain.AjaxResult;
+import com.bonus.sgzb.common.security.utils.SecurityUtils;
+import com.bonus.sgzb.material.config.ExceptionEnum;
+import com.bonus.sgzb.material.config.FieldGenerator;
+import com.bonus.sgzb.material.domain.*;
+import com.bonus.sgzb.material.mapper.IotMachineMapper;
+import com.bonus.sgzb.material.service.IotMachineService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * iot设备管理实现层
+ * @author ma_sh
+ */
+@Service
+@Slf4j
+public class IotMachineServiceImpl implements IotMachineService {
+
+ @Resource
+ private IotMachineMapper iotMachineMapper;
+
+ /**
+ * 添加设备-保存
+ *
+ * @param iotDto
+ * @return
+ */
+ @Override
+ public AjaxResult add(IotDto iotDto) {
+ if (iotDto == null || iotDto.getIotCode() == null || iotDto.getIotType() == null) {
+ return AjaxResult.error(ExceptionEnum.PARAM_NULL.getCode(), ExceptionEnum.PARAM_NULL.getMsg());
+ }
+ //根据前端传入设备编号判重
+ IotVo iotVo = iotMachineMapper.selectIotCode(iotDto);
+ if (iotVo != null) {
+ return AjaxResult.error(ExceptionEnum.IOT_CODE_DUPLICATE.getCode(), ExceptionEnum.IOT_CODE_DUPLICATE.getMsg());
+ }
+ //后端生成二维码编号,需判重,确保表中数据唯一性
+ String qrCode = FieldGenerator.generateField();
+ // 设置最大尝试次数10,避免无限循环
+ int maxAttempts = 10;
+ for (int attempt = 0; attempt < maxAttempts; attempt++) {
+ if (iotMachineMapper.selectQrCode(qrCode) == 0) {
+ iotDto.setQrCode(qrCode);
+ // 找到唯一的qrCode,退出循环
+ break;
+ } else {
+ // 生成新的qrCode
+ qrCode = FieldGenerator.generateField();
+ }
+ }
+ iotDto.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString());
+ try {
+ // 进行设备添加
+ int res = iotMachineMapper.add(iotDto);
+ if (res == 0) {
+ // 如果添加失败,返回保存到数据库异常的错误信息
+ throw new RuntimeException(ExceptionEnum.SAVE_TO_DATABASE.getMsg());
+ } else {
+ // 添加成功,返回成功的消息和新增的记录数
+ return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), res);
+ }
+ } catch (Exception e) {
+ log.error("Error saving to database: " + e.getMessage());
+ // 捕获所有异常,返回通用的数据库操作异常信息
+ return AjaxResult.error(ExceptionEnum.SAVE_TO_DATABASE.getCode(), ExceptionEnum.SAVE_TO_DATABASE.getMsg());
+ }
+ }
+
+ /**
+ * 设备管理-修改
+ *
+ * @param iotDto
+ * @return
+ */
+ @Override
+ public AjaxResult update(IotDto iotDto) {
+ if (iotDto == null || iotDto.getIotId() == null) {
+ return AjaxResult.error(ExceptionEnum.PARAM_NULL.getCode(), ExceptionEnum.PARAM_NULL.getMsg());
+ }
+ IotVo iotVo = iotMachineMapper.selectIotCode(iotDto);
+ if (iotVo != null && !iotVo.getIotId().equals(iotDto.getIotId())) {
+ return AjaxResult.error(ExceptionEnum.IOT_CODE_DUPLICATE.getCode(), ExceptionEnum.IOT_CODE_DUPLICATE.getMsg());
+ }
+ iotDto.setUpdateBy(SecurityUtils.getLoginUser().getUserid().toString());
+ try {
+ //设备修改
+ int res = iotMachineMapper.update(iotDto);
+ if (res == 0) {
+ // 如果修改失败,返回修改到数据库异常的错误信息
+ throw new RuntimeException(ExceptionEnum.UPDATE_TO_DATABASE.getMsg());
+ } else {
+ // 修改成功,返回成功的消息和修改的记录数
+ return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), res);
+ }
+ } catch (Exception e) {
+ log.error("Error updating to database: " + e.getMessage());
+ //捕获异常
+ return AjaxResult.error(ExceptionEnum.UPDATE_TO_DATABASE.getCode(), ExceptionEnum.UPDATE_TO_DATABASE.getMsg());
+ }
+ }
+
+ /**
+ * 获取设备列表
+ *
+ * @param iotDto
+ * @return
+ */
+ @Override
+ public List getIotList(IotDto iotDto) {
+ return iotMachineMapper.getIotList(iotDto);
+ }
+
+ /**
+ * 删除设备
+ *
+ * @param iotId
+ * @return
+ */
+ @Override
+ public AjaxResult deleteById(Long iotId) {
+ //先进行判断,绑定设备的iot设备无法删除
+ IotVo iotVo = iotMachineMapper.selectById(iotId);
+ if (iotVo.getBindStatus() == 0) {
+ return AjaxResult.error(ExceptionEnum.IOT_TO_DELETE.getCode(), ExceptionEnum.IOT_TO_DELETE.getMsg());
+ }
+ try {
+ // 执行设备删除操作
+ int res = iotMachineMapper.deleteById(iotId);
+ if (res == 0) {
+ // 如果删除操作未成功,返回删除数据库异常的错误信息
+ return AjaxResult.error(ExceptionEnum.DELETE_TO_DATABASE.getCode(), ExceptionEnum.DELETE_TO_DATABASE.getMsg());
+ } else {
+ // 删除成功,返回成功的消息和受影响的记录数
+ return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), res);
+ }
+ } catch (Exception e) {
+ log.error("Error deleting from database: " + e.getMessage());
+ // 捕获所有异常,返回通用的数据库操作异常信息
+ return AjaxResult.error(ExceptionEnum.DELETE_TO_DATABASE.getCode(), ExceptionEnum.DELETE_TO_DATABASE.getMsg());
+ }
+ }
+
+ /**
+ * 绑定设备
+ *
+ * @param iotDto
+ * @return
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public AjaxResult bind(IotDto iotDto) {
+ if (iotDto == null || iotDto.getIotId() == null || iotDto.getMaCode() == null) {
+ return AjaxResult.error(ExceptionEnum.PARAM_NULL.getCode(), ExceptionEnum.PARAM_NULL.getMsg());
+ }
+ iotDto.setBinder(SecurityUtils.getLoginUser().getUserid().toString());
+ int res;
+ try {
+ //绑定设备
+ res = iotMachineMapper.bind(iotDto);
+ if (res == 0) {
+ throw new RuntimeException(ExceptionEnum.BIND_TO_DATABASE.getMsg());
+ }
+ //更新绑定状态
+ res = iotMachineMapper.updateBindStatus(iotDto);
+ if (res == 0) {
+ throw new RuntimeException(ExceptionEnum.UPDATE_TO_DATABASE.getMsg());
+ }
+ } catch (Exception e) {
+ log.error("设备绑定异常:{}", e.getMessage());
+ // 添加事务回滚逻辑,保证全部成功或者全部失败
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+ return AjaxResult.error(ExceptionEnum.UPDATE_TO_DATABASE.getCode(), ExceptionEnum.UPDATE_TO_DATABASE.getMsg());
+ }
+ return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), res);
+ }
+
+ /**
+ * 解绑设备
+ *
+ * @param iotDto
+ * @return
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public AjaxResult unbind(IotDto iotDto) {
+ if (iotDto == null || iotDto.getIotId() == null || iotDto.getMaCode() == null) {
+ return AjaxResult.error(ExceptionEnum.PARAM_NULL.getCode(), ExceptionEnum.PARAM_NULL.getMsg());
+ }
+ iotDto.setUnBinder(SecurityUtils.getLoginUser().getUserid().toString());
+ int res;
+ try {
+ //解绑设备
+ res = iotMachineMapper.unbind(iotDto);
+ if (res == 0) {
+ throw new RuntimeException(ExceptionEnum.UN_BIND_TO_DATABASE.getMsg());
+ }
+ //更新绑定状态
+ res = iotMachineMapper.updateUnBindStatus(iotDto);
+ if (res == 0) {
+ throw new RuntimeException(ExceptionEnum.UPDATE_TO_DATABASE.getMsg());
+ }
+ } catch (Exception e) {
+ log.error("设备解绑异常:{}", e.getMessage());
+ // 添加事务回滚逻辑,保证入库全部成功或者全部失败
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+ return AjaxResult.error(ExceptionEnum.UPDATE_TO_DATABASE.getCode(), ExceptionEnum.UPDATE_TO_DATABASE.getMsg());
+ }
+ return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), res);
+ }
+
+ /**
+ * 根据类型id查询设备绑定列表
+ *
+ * @param iotDto
+ * @return
+ */
+ @Override
+ public List getTypeList(IotDto iotDto) {
+ if (iotDto == null || iotDto.getMaCode() == null) {
+ throw new RuntimeException(ExceptionEnum.PARAM_NULL.getMsg());
+ }
+ List iotVoList = iotMachineMapper.getTypeList(iotDto);
+ return iotVoList;
+ }
+
+ /**
+ * 根据iot设备类型查询设备编码
+ *
+ * @param iotDto
+ * @return
+ */
+ @Override
+ public AjaxResult selectList(IotDto iotDto) {
+ if (iotDto != null && iotDto.getIotTypeId() != null) {
+ // 如果传入了iot设备类型,根据iot设备类型查询设备编码
+ List iotCodeList = iotMachineMapper.selectCodeList(iotDto.getIotTypeId());
+ return AjaxResult.success(iotCodeList);
+ } else {
+ // 如果iotDto为null或者iotDto的iotType为null,单独查询iot设备类型列表
+ List iotTypeList = iotMachineMapper.selectList();
+ return AjaxResult.success(iotTypeList);
+ }
+ }
+
+ /**
+ * 查询iot绑定记录
+ *
+ * @param iotDto
+ * @return
+ */
+ @Override
+ public List getRecordList(IotDto iotDto) {
+ if (iotDto == null || iotDto.getIotId() == null) {
+ throw new RuntimeException(ExceptionEnum.PARAM_NULL.getMsg());
+ }
+ List iotRecordList = iotMachineMapper.getRecordList(iotDto);
+ return iotRecordList;
+ }
+
+}
diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/IotMachineMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/IotMachineMapper.xml
new file mode 100644
index 00000000..e02e716e
--- /dev/null
+++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/IotMachineMapper.xml
@@ -0,0 +1,207 @@
+
+
+
+
+
+ insert into iot_machine
+
+ iot_type,
+ iot_code,
+ iot_status,
+ qr_code,
+ bind_status,
+ del_flag,
+ create_by,
+ create_time
+
+
+ #{iotType},
+ #{iotCode},
+ 0,
+ #{qrCode},
+ 1,
+ 0,
+ #{createBy},
+ NOW()
+
+
+
+
+ insert into iot_machine_bind
+
+ iot_id,
+ type_id,
+ ma_code,
+ binder,
+ bind_time
+
+
+ #{iotId},
+ #{typeId},
+ #{maCode},
+ #{binder},
+ NOW()
+
+
+
+
+ UPDATE iot_machine
+
+ iot_type = #{iotType},
+ iot_code = #{iotCode},
+ iot_status = #{iotStatus},
+ update_by = #{updateBy},
+ update_time = NOW()
+
+ WHERE id = #{iotId}
+
+
+
+ UPDATE iot_machine SET del_flag = '2' WHERE id = #{iotId}
+
+
+ UPDATE iot_machine SET bind_status = '0', update_time = NOW() WHERE id = #{iotId}
+
+
+ UPDATE iot_machine_bind SET unbinder = #{unBinder}, unbind_time = NOW() WHERE id = #{id}
+
+
+ UPDATE iot_machine SET bind_status = '1', update_time = NOW() WHERE id = #{iotId}
+
+
+
+
+
+
+
+
+
+
+
+
+
From 93a46f8842f57a57865bc642cd98df6e87e6909e Mon Sep 17 00:00:00 2001
From: sxu <602087911@qq.com>
Date: Mon, 5 Aug 2024 13:32:53 +0800
Subject: [PATCH 4/4] =?UTF-8?q?=E5=BA=93=E5=AD=98=E6=97=A5=E5=BF=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../bonus/sgzb/base/api/domain/LeaseOutDetails.java | 3 +++
.../service/impl/LeaseOutDetailsServiceImpl.java | 13 +++++++++++++
2 files changed, 16 insertions(+)
diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/LeaseOutDetails.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/LeaseOutDetails.java
index 499f54c0..f0fd3062 100644
--- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/LeaseOutDetails.java
+++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/LeaseOutDetails.java
@@ -176,4 +176,7 @@ public class LeaseOutDetails implements Serializable {
@ApiModelProperty(value = "数量出库 -> 操作前库存量")
private Integer num;
+ /** 操作后库存 */
+ private String postStoreNum;
+
}
\ No newline at end of file
diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/LeaseOutDetailsServiceImpl.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/LeaseOutDetailsServiceImpl.java
index 4aa3c6ea..bb20754c 100644
--- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/LeaseOutDetailsServiceImpl.java
+++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/LeaseOutDetailsServiceImpl.java
@@ -185,6 +185,7 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
if (res == 0) {
throw new RuntimeException("出库失败,插入结算记录失败");
}
+ record.setPostStoreNum(String.valueOf(getStorageNum(record)));
} else {
return AjaxResult.error("领料出库失败,机具库存不足");
}
@@ -264,6 +265,18 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
return 1;
}
+ private int getStorageNum(LeaseOutDetails record) {
+ if (StringUtils.isNull(record)) {
+ return 0;
+ }
+ //判断(ma_type 设备规格表)中的库存够不够出库的
+ MaType maType = leaseOutDetailsMapper.selectByTypeId(record);
+ if (maType != null) {
+ return maType.getNum().intValue();
+ }
+ return 0;
+ }
+
private int checkStorageNumCt(LeaseOutDetails record) {
int res = 0;
double outNum = 0.1;