From 34b15e7f767f926e8a0285d551ea8f5a3f991d85 Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Thu, 18 Jan 2024 22:18:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=AE=BE=E5=A4=87=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2SQL=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 | 6 +- .../zc/business/entity/EntityDcDevice.java | 44 --------- .../zc/business/mapper/DcDeviceMapper.java | 4 + .../zc/business/service/IDcDeviceService.java | 7 +- .../service/impl/DcDeviceServiceImpl.java | 35 ++------ .../mapper/business/DcDeviceMapper.xml | 89 +++++++++++++++++++ 6 files changed, 110 insertions(+), 75 deletions(-) delete mode 100644 zc-business/src/main/java/com/zc/business/entity/EntityDcDevice.java create mode 100644 zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml 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 818030af..8b036887 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 @@ -1,5 +1,6 @@ package com.zc.business.domain; +import com.baomidou.mybatisplus.annotation.TableField; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -50,5 +51,8 @@ public class DcDevice { private Date createTime; @ApiModelProperty("修改时间") private Date updateTime; - + @TableField(exist = false) + private String longitude; + @TableField(exist = false) + private String latitude; } 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 deleted file mode 100644 index 1997b422..00000000 --- a/zc-business/src/main/java/com/zc/business/entity/EntityDcDevice.java +++ /dev/null @@ -1,44 +0,0 @@ -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/mapper/DcDeviceMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcDeviceMapper.java index 40d4dcc7..c9250885 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcDeviceMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcDeviceMapper.java @@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.zc.business.domain.DcDevice; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 设备Mapper接口 * @@ -11,4 +13,6 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface DcDeviceMapper extends BaseMapper { + + List selectDcDeviceList(DcDevice dcDevice); } 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 7d715f11..3943272d 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 @@ -4,7 +4,6 @@ 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; @@ -45,7 +44,7 @@ public interface IDcDeviceService extends IService { * @param dcDevice 参数 * @return 结果 */ - List pageDevice(DcDevice dcDevice); + List pageDevice(DcDevice dcDevice); /** * 获取设备列表 @@ -53,7 +52,7 @@ public interface IDcDeviceService extends IService { * @param dcDevice 参数 * @return 结果 */ - List listDevice(DcDevice dcDevice); + List listDevice(DcDevice dcDevice); /** * 批量修改设备 @@ -70,7 +69,7 @@ public interface IDcDeviceService extends IService { * @param id 设备ID * @return 设备信息 */ - EntityDcDevice getDevice(String id); + DcDevice 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 f3e1aba6..a0f9b336 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 @@ -8,7 +8,6 @@ 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; @@ -17,7 +16,6 @@ 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; @@ -34,6 +32,9 @@ public class DcDeviceServiceImpl extends ServiceImpl i private IDcProductService dcProdurtService; @Resource private IDcStakeMarkService dcStakeMarkService; + @Resource + private DcDeviceMapper dcDeviceMapper; + public LambdaQueryWrapper deviceQueryWrapper(DcDevice dcDevice) { @@ -226,18 +227,10 @@ public class DcDeviceServiceImpl extends ServiceImpl i * @return 分页查询结果 */ @Override - public List pageDevice(DcDevice dcDevice) { + public List pageDevice(DcDevice dcDevice) { // 分页 PageUtils.startPage(); - 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; + return dcDeviceMapper.selectDcDeviceList(dcDevice); } /** @@ -247,16 +240,8 @@ public class DcDeviceServiceImpl extends ServiceImpl i * @return 查询结果 */ @Override - 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; + public List listDevice(DcDevice dcDevice) { + return dcDeviceMapper.selectDcDeviceList(dcDevice); } /** @@ -282,16 +267,14 @@ public class DcDeviceServiceImpl extends ServiceImpl i * @return 查询结果 */ @Override - public EntityDcDevice getDevice(String id) { + public DcDevice 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 device; } @Override diff --git a/zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml b/zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml new file mode 100644 index 00000000..f855bdc0 --- /dev/null +++ b/zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, + iot_device_id, + group_id, + product_id, + stake_mark_id, + direction, + device_name, + device_code, + device_type, + installation_Date, + production_date, + durable_years, + installation_site, + use_state, + other_config, + remark, + create_time, + update_time + from dc_device + + + + + +