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/DevInfoPropertyVo.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/vo/DevInfoPropertyVo.java index 316091c..eb2c688 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/vo/DevInfoPropertyVo.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/vo/DevInfoPropertyVo.java @@ -6,10 +6,6 @@ import lombok.Data; @Data public class DevInfoPropertyVo { - /** 物资ID */ - @ApiModelProperty(value = "物资ID") - private Long maId; - /** 属性名称 */ @ApiModelProperty(value = "属性名称") private String propertyName; 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..0e1e20c 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 @@ -128,10 +128,12 @@ public interface DevInfoMapper { List selectDevInfoLists(DevInfoVo devInfo); - List selectDevInfoProperties(); + List selectDevInfoProperties(@Param("maId")Long maId); 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..5ae430c 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; @@ -138,6 +137,9 @@ public class DevInfoServiceImpl implements DevInfoService { if (!CollectionUtils.isEmpty(leaseList)) { devInfoVo.setLeaseList(leaseList); } + //查询自定义属性 + List properties = devInfoMapper.selectDevInfoProperties(maId); + devInfoVo.setDevInfoProperties(properties); } return devInfoVo; } @@ -337,6 +339,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 +376,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 +464,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 +473,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 +487,9 @@ public class DevInfoServiceImpl implements DevInfoService { * @return 结果 */ @Override + @Transactional(rollbackFor = Exception.class) public int deleteDevInfoByMaIds(Long[] maIds) { + devInfoMapper.batchDeleteDevInfoProperties(maIds); return devInfoMapper.deleteDevInfoByMaIds(maIds); } @@ -533,13 +551,7 @@ public class DevInfoServiceImpl implements DevInfoService { @Override public List selectDevInfoLists(DevInfoVo devInfo) { devInfo.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId().toString()); - List devInfoVos = devInfoMapper.selectDevInfoLists(devInfo); - List devInfoProperties = devInfoMapper.selectDevInfoProperties(); - Map> map = devInfoProperties.stream().collect(Collectors.groupingBy(DevInfoPropertyVo::getMaId)); - for (DevInfoVo devInfos : devInfoVos) { - devInfos.setDevInfoProperties(map.get(devInfos.getMaId())); - } - return devInfoVos; + return devInfoMapper.selectDevInfoLists(devInfo); } /** 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..d81161c 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 @@ -532,16 +532,23 @@ 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)