From ec5581c2cac87ab2c1f8c6dd708555b6615fdd42 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Tue, 10 Dec 2024 17:31:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE=E5=B1=9E?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bonus/material/device/domain/DevInfo.java | 3 +++ .../material/device/domain/vo/DevInfoVo.java | 3 --- .../material/device/mapper/DevInfoMapper.java | 2 ++ .../device/service/impl/DevInfoServiceImpl.java | 17 ++++++++++++++++- .../mapper/material/device/DevInfoMapper.xml | 7 +++++++ 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/DevInfo.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/DevInfo.java index 9670359..2ec7bd1 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/DevInfo.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/DevInfo.java @@ -3,6 +3,7 @@ package com.bonus.material.device.domain; import com.bonus.common.biz.domain.BmFileInfo; import com.bonus.common.core.annotation.Excel; import com.bonus.common.core.web.domain.BaseEntity; +import com.bonus.material.device.domain.vo.DevInfoPropertyVo; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -255,4 +256,6 @@ public class DevInfo extends BaseEntity { @ApiModelProperty(value = "是否上传安全证书(0:否 1:是)") private Integer isSafeBook; + @ApiModelProperty(value = "自定义属性列表") + private List devInfoProperties; } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/vo/DevInfoVo.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/vo/DevInfoVo.java index 6c7dc02..3fe2f30 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/vo/DevInfoVo.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/vo/DevInfoVo.java @@ -151,7 +151,4 @@ public class DevInfoVo extends DevInfo { @ApiModelProperty(value = "结束时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private String endTime; - - @ApiModelProperty(value = "自定义属性列表") - private List devInfoProperties; } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java index 039062c..b0904ee 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java @@ -132,6 +132,8 @@ public interface DevInfoMapper { int deleteDevInfoProperties(@Param("maId")Long maId); + int batchDeleteDevInfoProperties(@Param("maIds")Long[] maIds); + int insertDevInfoProperties(@Param("maId")Long maId, @Param("list") List list); /** diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java index ba63fc2..a389772 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java @@ -22,7 +22,6 @@ import com.bonus.material.device.domain.vo.LeaseVo; import com.bonus.material.device.mapper.BmFileInfoMapper; import com.bonus.material.device.mapper.DevInfoMapper; import com.bonus.material.device.service.DevInfoService; -import com.bonus.material.ma.vo.MaTypeProperty; import com.bonus.system.api.model.LoginUser; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; @@ -337,6 +336,10 @@ public class DevInfoServiceImpl implements DevInfoService { if (saveSuccessNum == 0) { return AjaxResult.error("设备信息SQL保存失败,请修改后重试"); } + //保存自定义属性值 + if (!CollectionUtils.isEmpty(devInfo.getDevInfoProperties())) { + devInfoMapper.insertDevInfoProperties(devInfo.getMaId(), devInfo.getDevInfoProperties()); + } //把文件保存到附件中 AjaxResult error = uploadFiles(devInfo, userId, i); if (error != null) { @@ -370,6 +373,11 @@ public class DevInfoServiceImpl implements DevInfoService { if (insertedDraft == 0) { return AjaxResult.error("装备草稿保存失败,请修改后重试"); } + //保存自定义属性值 + if (!CollectionUtils.isEmpty(devInfo.getDevInfoProperties())) { + devInfoMapper.insertDevInfoProperties(devInfo.getMaId(), devInfo.getDevInfoProperties()); + } + //把文件保存到附件中 AjaxResult error = uploadFiles(devInfo, userId, i); if (error != null) { return error; @@ -453,6 +461,7 @@ public class DevInfoServiceImpl implements DevInfoService { * @param devInfo 设备信息 */ @Override + @Transactional(rollbackFor = Exception.class) public AjaxResult updateDevInfo(DevInfo devInfo) { if (devInfo.getMaId() == null) { return AjaxResult.error("设备ID为空,请携带设备信息修改"); @@ -461,6 +470,10 @@ public class DevInfoServiceImpl implements DevInfoService { if (deviceId != null && !deviceId.getMaId().equals(devInfo.getMaId())) { return AjaxResult.error("设备名称已存在,请修改后重试!"); }*/ + devInfoMapper.deleteDevInfoProperties(devInfo.getMaId()); + if (!CollectionUtils.isEmpty(devInfo.getDevInfoProperties())) { + devInfoMapper.insertDevInfoProperties(devInfo.getMaId(), devInfo.getDevInfoProperties()); + } return devInfoMapper.updateDevInfo(devInfo) > 0 ? AjaxResult.success("修改成功") : AjaxResult.error("修改失败"); } @@ -471,7 +484,9 @@ public class DevInfoServiceImpl implements DevInfoService { * @return 结果 */ @Override + @Transactional(rollbackFor = Exception.class) public int deleteDevInfoByMaIds(Long[] maIds) { + devInfoMapper.batchDeleteDevInfoProperties(maIds); return devInfoMapper.deleteDevInfoByMaIds(maIds); } diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml index 8347e62..548de13 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml @@ -542,6 +542,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" delete from ma_dev_info_properties where ma_id = #{maId} + + delete from ma_dev_info_properties where ma_id in + + #{maId} + + + insert into ma_dev_info_properties(ma_id, property_name, property_value, create_time)