Browse Source

上传经纬度优化

develop
zhaoxianglong 10 months ago
parent
commit
ed6583e35d
  1. 2
      zc-business/src/main/java/com/zc/business/domain/DcDevice.java
  2. 44
      zc-business/src/main/java/com/zc/business/entity/EntityDcDevice.java
  3. 10
      zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java
  4. 47
      zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java

2
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("安装日期")

44
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;
}
}

10
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<DcDevice> {
* @param dcDevice 参数
* @return 结果
*/
List<DcDevice> pageDevice(DcDevice dcDevice);
List<EntityDcDevice> pageDevice(DcDevice dcDevice);
/**
* 获取设备列表
@ -51,7 +53,7 @@ public interface IDcDeviceService extends IService<DcDevice> {
* @param dcDevice 参数
* @return 结果
*/
List<DcDevice> listDevice(DcDevice dcDevice);
List<EntityDcDevice> listDevice(DcDevice dcDevice);
/**
@ -60,5 +62,7 @@ public interface IDcDeviceService extends IService<DcDevice> {
* @param id 设备ID
* @return 设备信息
*/
DcDevice getDevice(String id);
EntityDcDevice getDevice(String id);
DcStakeMark exampleQueryTheAssociatedPileNumber(DcDevice dcDevice);
}

47
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<DcDeviceMapper, DcDevice> i
@Resource
private IDcProductService dcProdurtService;
@Resource
private IDcStakeMarkService dcStakeMarkService;
public LambdaQueryWrapper<DcDevice> deviceQueryWrapper(DcDevice dcDevice) {
@ -220,10 +226,18 @@ public class DcDeviceServiceImpl extends ServiceImpl<DcDeviceMapper, DcDevice> i
* @return 分页查询结果
*/
@Override
public List<DcDevice> pageDevice(DcDevice dcDevice) {
public List<EntityDcDevice> pageDevice(DcDevice dcDevice) {
// 分页
PageUtils.startPage();
return list(deviceQueryWrapper(dcDevice));
List<DcDevice> list = list(deviceQueryWrapper(dcDevice));
ArrayList<EntityDcDevice> 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<DcDeviceMapper, DcDevice> i
* @return 查询结果
*/
@Override
public List<DcDevice> listDevice(DcDevice dcDevice) {
return list(deviceQueryWrapper(dcDevice));
public List<EntityDcDevice> listDevice(DcDevice dcDevice) {
List<DcDevice> list = list(deviceQueryWrapper(dcDevice));
ArrayList<EntityDcDevice> 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<DcDeviceMapper, DcDevice> 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<DcStakeMark> dcStakeMarks = dcStakeMarkService.listStakeMark(dcStakeMark);
if (dcStakeMarks.size() == 1) {
return dcStakeMarks.get(0);
}
return new DcStakeMark();
}
}

Loading…
Cancel
Save