From ed6583e35d759af41b9b305bdb31014f655011af Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Thu, 18 Jan 2024 17:53:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=BB=8F=E7=BA=AC=E5=BA=A6?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/zc/business/domain/DcDevice.java | 2 + .../zc/business/entity/EntityDcDevice.java | 44 +++++++++++++++++ .../zc/business/service/IDcDeviceService.java | 10 ++-- .../service/impl/DcDeviceServiceImpl.java | 47 ++++++++++++++++--- 4 files changed, 94 insertions(+), 9 deletions(-) create mode 100644 zc-business/src/main/java/com/zc/business/entity/EntityDcDevice.java diff --git a/zc-business/src/main/java/com/zc/business/domain/DcDevice.java b/zc-business/src/main/java/com/zc/business/domain/DcDevice.java index a4531100..c4db3bf9 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcDevice.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcDevice.java @@ -26,6 +26,8 @@ public class DcDevice { private String direction; @ApiModelProperty("设备名称") private String deviceName; + @ApiModelProperty("设备编号") + private String deviceCode; @ApiModelProperty("设备类型") private Integer deviceType; @ApiModelProperty("安装日期") diff --git a/zc-business/src/main/java/com/zc/business/entity/EntityDcDevice.java b/zc-business/src/main/java/com/zc/business/entity/EntityDcDevice.java new file mode 100644 index 00000000..1997b422 --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/entity/EntityDcDevice.java @@ -0,0 +1,44 @@ +package com.zc.business.entity; + +import com.zc.business.domain.DcDevice; +import com.zc.business.domain.DcStakeMark; +import io.swagger.annotations.ApiModel; +import lombok.Data; + + +@Data +@ApiModel(value = "EntityDcDevice", description = "设备返回参数") +public class EntityDcDevice extends DcDevice { + + private String longitude; + private String latitude; + + public EntityDcDevice EstablishEntityDcDevice(DcDevice device, DcStakeMark dcStakeMark) { + EntityDcDevice entityDcDevice = new EntityDcDevice(); + + entityDcDevice.setId(device.getId()); + entityDcDevice.setIotDeviceId(device.getIotDeviceId()); + entityDcDevice.setGroupId(device.getGroupId()); + entityDcDevice.setProductId(device.getProductId()); + entityDcDevice.setStakeMarkId(device.getStakeMarkId()); + entityDcDevice.setDirection(device.getDirection()); + entityDcDevice.setDeviceCode(device.getDeviceCode()); + entityDcDevice.setDeviceName(device.getDeviceName()); + entityDcDevice.setDeviceType(device.getDeviceType()); + entityDcDevice.setInstallationDate(device.getInstallationDate()); + entityDcDevice.setProductionDate(device.getProductionDate()); + entityDcDevice.setDurableYears(device.getDurableYears()); + entityDcDevice.setInstallationSite(device.getInstallationSite()); + entityDcDevice.setUseState(device.getUseState()); + entityDcDevice.setOtherConfig(device.getOtherConfig()); + entityDcDevice.setRemark(device.getRemark()); + entityDcDevice.setCreateTime(device.getCreateTime()); + entityDcDevice.setUpdateTime(device.getUpdateTime()); + if (dcStakeMark != null) { + entityDcDevice.setLongitude(dcStakeMark.getLongitude()); + entityDcDevice.setLatitude(dcStakeMark.getLatitude()); + } + return entityDcDevice; + + } +} diff --git a/zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java b/zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java index 8500cb57..7d355556 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java @@ -3,6 +3,8 @@ package com.zc.business.service; import com.baomidou.mybatisplus.extension.service.IService; import com.zc.business.domain.DcDevice; +import com.zc.business.domain.DcStakeMark; +import com.zc.business.entity.EntityDcDevice; import java.util.List; @@ -43,7 +45,7 @@ public interface IDcDeviceService extends IService { * @param dcDevice 参数 * @return 结果 */ - List pageDevice(DcDevice dcDevice); + List pageDevice(DcDevice dcDevice); /** * 获取设备列表 @@ -51,7 +53,7 @@ public interface IDcDeviceService extends IService { * @param dcDevice 参数 * @return 结果 */ - List listDevice(DcDevice dcDevice); + List listDevice(DcDevice dcDevice); /** @@ -60,5 +62,7 @@ public interface IDcDeviceService extends IService { * @param id 设备ID * @return 设备信息 */ - DcDevice getDevice(String id); + EntityDcDevice getDevice(String id); + + DcStakeMark exampleQueryTheAssociatedPileNumber(DcDevice dcDevice); } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java index 6182ed76..256bfdd4 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java @@ -7,13 +7,17 @@ import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.PageUtils; import com.zc.business.domain.DcDevice; import com.zc.business.domain.DcProduct; +import com.zc.business.domain.DcStakeMark; +import com.zc.business.entity.EntityDcDevice; import com.zc.business.mapper.DcDeviceMapper; import com.zc.business.service.IDcDeviceService; import com.zc.business.service.IDcProductService; +import com.zc.business.service.IDcStakeMarkService; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Objects; @@ -28,6 +32,8 @@ public class DcDeviceServiceImpl extends ServiceImpl i @Resource private IDcProductService dcProdurtService; + @Resource + private IDcStakeMarkService dcStakeMarkService; public LambdaQueryWrapper deviceQueryWrapper(DcDevice dcDevice) { @@ -220,10 +226,18 @@ public class DcDeviceServiceImpl extends ServiceImpl i * @return 分页查询结果 */ @Override - public List pageDevice(DcDevice dcDevice) { + public List pageDevice(DcDevice dcDevice) { // 分页 PageUtils.startPage(); - return list(deviceQueryWrapper(dcDevice)); + List list = list(deviceQueryWrapper(dcDevice)); + ArrayList entityDcDevices = new ArrayList<>(); + for (DcDevice device : list) { + DcStakeMark dcStakeMark = exampleQueryTheAssociatedPileNumber(device); + EntityDcDevice entityDcDevice = new EntityDcDevice(); + EntityDcDevice entityDcDevice1 = entityDcDevice.EstablishEntityDcDevice(device, dcStakeMark); + entityDcDevices.add(entityDcDevice1); + } + return entityDcDevices; } /** @@ -233,8 +247,16 @@ public class DcDeviceServiceImpl extends ServiceImpl i * @return 查询结果 */ @Override - public List listDevice(DcDevice dcDevice) { - return list(deviceQueryWrapper(dcDevice)); + public List listDevice(DcDevice dcDevice) { + List list = list(deviceQueryWrapper(dcDevice)); + ArrayList entityDcDevices = new ArrayList<>(); + for (DcDevice device : list) { + DcStakeMark dcStakeMark = exampleQueryTheAssociatedPileNumber(device); + EntityDcDevice entityDcDevice = new EntityDcDevice(); + EntityDcDevice entityDcDevice1 = entityDcDevice.EstablishEntityDcDevice(device, dcStakeMark); + entityDcDevices.add(entityDcDevice1); + } + return entityDcDevices; } /** @@ -244,15 +266,28 @@ public class DcDeviceServiceImpl extends ServiceImpl i * @return 查询结果 */ @Override - public DcDevice getDevice(String id) { + public EntityDcDevice getDevice(String id) { // 检查设备id是否重复 DcDevice device = getById(id); if (Objects.isNull(device)) { throw new ServiceException("设备ID[" + id + "]不存在", HttpStatus.BAD_REQUEST); } + DcStakeMark dcStakeMark = exampleQueryTheAssociatedPileNumber(device); + EntityDcDevice entityDcDevice = new EntityDcDevice(); + return entityDcDevice.EstablishEntityDcDevice(device, dcStakeMark); + } - return getById(id); + @Override + public DcStakeMark exampleQueryTheAssociatedPileNumber(DcDevice dcDevice) { + DcStakeMark dcStakeMark = new DcStakeMark(); + dcStakeMark.setDirection(dcDevice.getDirection()); + dcStakeMark.setId(dcDevice.getStakeMarkId()); + List dcStakeMarks = dcStakeMarkService.listStakeMark(dcStakeMark); + if (dcStakeMarks.size() == 1) { + return dcStakeMarks.get(0); + } + return new DcStakeMark(); } }