feat (farm): 租户导入/出
-
This commit is contained in:
@@ -87,8 +87,12 @@ public class BaseInfoRespVO {
|
|||||||
private String plotManager;
|
private String plotManager;
|
||||||
@Schema(description = "地块坐标")
|
@Schema(description = "地块坐标")
|
||||||
private String plotPoint;
|
private String plotPoint;
|
||||||
|
private Integer plotLeaseStatus;
|
||||||
|
private String plotLeaseStatusName;
|
||||||
@Schema(description = "网格信息")
|
@Schema(description = "网格信息")
|
||||||
private List<GridInfo> gridOverviewList;
|
private List<GridInfo> gridOverviewList;
|
||||||
|
@Schema(description = "户主流转信息")
|
||||||
|
private List<PlotLesseeDetailsRespVO> lesseeList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
@@ -4,10 +4,14 @@ import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
|||||||
import cn.idev.excel.annotation.ExcelProperty;
|
import cn.idev.excel.annotation.ExcelProperty;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 地块户主 - 导出")
|
@Schema(description = "管理后台 - 地块户主 - 导出")
|
||||||
@Data
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
@ExcelIgnoreUnannotated
|
@ExcelIgnoreUnannotated
|
||||||
public class PlotLesseeForExportExcelRespVO {
|
public class PlotLesseeForExportExcelRespVO {
|
||||||
|
|
||||||
|
|||||||
@@ -4,13 +4,17 @@ import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
|||||||
import cn.idev.excel.annotation.ExcelProperty;
|
import cn.idev.excel.annotation.ExcelProperty;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 地块户主 - 导入")
|
@Schema(description = "管理后台 - 地块户主 - 导入")
|
||||||
@Data
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
@Accessors(chain = false)
|
@Accessors(chain = false)
|
||||||
public class PlotLesseeForImportExcelRespVO {
|
public class PlotLesseeForImportExcelRespVO {
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
@@ -50,6 +51,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
|
||||||
|
import static cn.iocoder.yudao.module.farm.enums.CommonConstants.LEASE_STATUS_MAP;
|
||||||
import static cn.iocoder.yudao.module.farm.enums.CommonConstants.PLOT_TYPE_NAME_MAP;
|
import static cn.iocoder.yudao.module.farm.enums.CommonConstants.PLOT_TYPE_NAME_MAP;
|
||||||
import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.*;
|
import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
@@ -307,10 +309,15 @@ public class BaseInfoServiceImpl implements BaseInfoService {
|
|||||||
private List<BaseInfoRespVO.PlotInfo> packagePlotInfo(Map<String, String> employeeMap, List<PlotInfoDO> plotList) {
|
private List<BaseInfoRespVO.PlotInfo> packagePlotInfo(Map<String, String> employeeMap, List<PlotInfoDO> plotList) {
|
||||||
List<BaseInfoRespVO.PlotInfo> targetList = new ArrayList<>();
|
List<BaseInfoRespVO.PlotInfo> targetList = new ArrayList<>();
|
||||||
for (PlotInfoDO aDo : plotList) {
|
for (PlotInfoDO aDo : plotList) {
|
||||||
String plotManager = employeeMap.getOrDefault(aDo.getEmployeeId(), "系统");
|
// 网格
|
||||||
List<BaseInfoRespVO.GridInfo> gridInfos = this.packageGridInfo(aDo.getId());
|
List<BaseInfoRespVO.GridInfo> gridInfos = this.packageGridInfo(aDo.getId());
|
||||||
|
// 户主
|
||||||
|
List<PlotLesseeDetailsRespVO> lesseeList = plotInfoService.getPlotLesseeList2(aDo.getId());
|
||||||
|
String plotManager = employeeMap.getOrDefault(aDo.getEmployeeId(), "系统");
|
||||||
String typeName = PLOT_TYPE_NAME_MAP.get(Integer.valueOf(aDo.getType()));
|
String typeName = PLOT_TYPE_NAME_MAP.get(Integer.valueOf(aDo.getType()));
|
||||||
BaseInfoRespVO.PlotInfo target = new BaseInfoRespVO.PlotInfo(Integer.valueOf(aDo.getType()),typeName,aDo.getId(), aDo.getPlotName(), aDo.getPlotColor(), BigDecimalUtil.roundedViaMath( aDo.getPlotArea()), plotManager, aDo.getPoint(), gridInfos);
|
BaseInfoRespVO.PlotInfo target = new BaseInfoRespVO.PlotInfo(Integer.valueOf(aDo.getType()),typeName,aDo.getId(), aDo.getPlotName(), aDo.getPlotColor(),
|
||||||
|
BigDecimalUtil.roundedViaMath( aDo.getPlotArea()), plotManager, aDo.getPoint(),
|
||||||
|
aDo.getPlotLeaseStatus(), LEASE_STATUS_MAP.get(aDo.getPlotLeaseStatus()),gridInfos,lesseeList);
|
||||||
targetList.add(target);
|
targetList.add(target);
|
||||||
}
|
}
|
||||||
return targetList;
|
return targetList;
|
||||||
|
|||||||
@@ -479,12 +479,12 @@ public class DeviceInfoServiceImpl implements DeviceInfoService {
|
|||||||
// 获取设备商数据
|
// 获取设备商数据
|
||||||
switch (typeCode) {
|
switch (typeCode) {
|
||||||
case DEVICE_TYPE_SOIL:
|
case DEVICE_TYPE_SOIL:
|
||||||
DeviceInfoDetailV2RespVO.SoilInfo soilInfo = getSoilInfo(d.getDeviceUniqueId(), d.getPlotId(), 12,Long.valueOf(d.getTenantId()));
|
DeviceInfoDetailV2RespVO.SoilInfo soilInfo = getSoilInfo(d.getDeviceUniqueId(), d.getPlotId(), 12,Long.valueOf(tenantId));
|
||||||
List<DeviceMonitorDataRespVO.Row> rows1 = this.getSoilData(d.getDeviceName(), soilInfo);
|
List<DeviceMonitorDataRespVO.Row> rows1 = this.getSoilData(d.getDeviceName(), soilInfo);
|
||||||
rows.addAll(rows1);
|
rows.addAll(rows1);
|
||||||
break;
|
break;
|
||||||
case DEVICE_TYPE_WF:
|
case DEVICE_TYPE_WF:
|
||||||
DeviceInfoDetailV2RespVO.WfInfo wfInfo = getWfInfo(d.getDeviceUniqueId(), d.getPlotId(),Long.valueOf(d.getTenantId()));
|
DeviceInfoDetailV2RespVO.WfInfo wfInfo = getWfInfo(d.getDeviceUniqueId(), d.getPlotId(),Long.valueOf(tenantId));
|
||||||
List<DeviceMonitorDataRespVO.Row> rows2 = this.getWfData( wfInfo);
|
List<DeviceMonitorDataRespVO.Row> rows2 = this.getWfData( wfInfo);
|
||||||
rows.addAll(rows2);
|
rows.addAll(rows2);
|
||||||
break;
|
break;
|
||||||
@@ -538,6 +538,9 @@ public class DeviceInfoServiceImpl implements DeviceInfoService {
|
|||||||
List<DeviceMonitorDataRespVO.Row> rows = new ArrayList<>();
|
List<DeviceMonitorDataRespVO.Row> rows = new ArrayList<>();
|
||||||
|
|
||||||
RealTimeDataRespVO realTimeDataRespVO = (RealTimeDataRespVO) soilInfo.getRealTimeData().getData();
|
RealTimeDataRespVO realTimeDataRespVO = (RealTimeDataRespVO) soilInfo.getRealTimeData().getData();
|
||||||
|
if (ObjectUtils.isEmpty(realTimeDataRespVO)) {
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
List<RealTimeDataRespVO.DeviceInfo> data = realTimeDataRespVO.getData();
|
List<RealTimeDataRespVO.DeviceInfo> data = realTimeDataRespVO.getData();
|
||||||
for (RealTimeDataRespVO.DeviceInfo d : data) {
|
for (RealTimeDataRespVO.DeviceInfo d : data) {
|
||||||
rows.add(new DeviceMonitorDataRespVO.Row(name, ONLINE_MAP.get(d.getStatus()), ""));
|
rows.add(new DeviceMonitorDataRespVO.Row(name, ONLINE_MAP.get(d.getStatus()), ""));
|
||||||
|
|||||||
@@ -125,4 +125,6 @@ public interface PlotInfoService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<PlotLesseeDetailsRespVO> getPlotLesseeList(String plotId);
|
List<PlotLesseeDetailsRespVO> getPlotLesseeList(String plotId);
|
||||||
|
|
||||||
|
List<PlotLesseeDetailsRespVO> getPlotLesseeList2(String plotId);
|
||||||
}
|
}
|
||||||
@@ -31,8 +31,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
|
||||||
import static cn.iocoder.yudao.module.farm.enums.CommonConstants.LEASE_STATUS_MAP;
|
import static cn.iocoder.yudao.module.farm.enums.CommonConstants.*;
|
||||||
import static cn.iocoder.yudao.module.farm.enums.CommonConstants.PLOT_TYPE_NAME_MAP;
|
|
||||||
import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.*;
|
import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -205,27 +204,42 @@ public class PlotInfoServiceImpl implements PlotInfoService {
|
|||||||
@Override
|
@Override
|
||||||
public void setPlotLesseeInfo(List<PlotLesseeForImportExcelRespVO> req) {
|
public void setPlotLesseeInfo(List<PlotLesseeForImportExcelRespVO> req) {
|
||||||
|
|
||||||
Map<String, String> collect = plotLesseeMapper.selectList().stream().collect(Collectors.toMap(PlotLesseeDO::getPlotName, PlotLesseeDO::getId, (v1, v2) -> v1));
|
Map<String, String> baseNameMap = baseInfoMapper.selectList().stream().collect(Collectors.toMap(BaseInfoDO::getId, BaseInfoDO::getName, (v1, v2) -> v1));
|
||||||
|
Map<String, String> plotNameMap = plotInfoMapper.selectList().stream().collect(Collectors.toMap(PlotInfoDO::getPlotName, PlotInfoDO::getId, (v1, v2) -> v1));
|
||||||
for (PlotLesseeForImportExcelRespVO e : req) {
|
for (PlotLesseeForImportExcelRespVO e : req) {
|
||||||
if (!collect.containsKey(e.getPlotName())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ObjectUtils.isEmpty(e.getLeaseName()) || ObjectUtils.isEmpty(e.getLeaseIdCard())
|
if (ObjectUtils.isEmpty(e.getLeaseName()) || ObjectUtils.isEmpty(e.getLeaseIdCard())
|
||||||
|| ObjectUtils.isEmpty(e.getLeasePhone() ) || ObjectUtils.isEmpty(e.getLeaseStartDate()) || ObjectUtils.isEmpty(e.getLeaseEndDate())) {
|
|| ObjectUtils.isEmpty(e.getLeasePhone() ) || ObjectUtils.isEmpty(e.getLeaseStartDate()) || ObjectUtils.isEmpty(e.getLeaseEndDate())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlotInfoDO plotInfoDO = plotInfoMapper.selectOne(PlotInfoDO::getPlotName, e.getPlotName());
|
||||||
|
|
||||||
|
if (ObjectUtils.isEmpty(plotInfoDO)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新地块信息
|
||||||
|
plotInfoDO.setPlotLeaseStatus(YES_CODE);
|
||||||
|
plotInfoMapper.updateById(plotInfoDO);
|
||||||
|
|
||||||
|
// 插入户主信息
|
||||||
PlotLesseeDO target = new PlotLesseeDO();
|
PlotLesseeDO target = new PlotLesseeDO();
|
||||||
target.setId(collect.get(e.getPlotName()));
|
|
||||||
target.setLeaseName(e.getLeaseName());
|
target.setLeaseName(e.getLeaseName());
|
||||||
target.setLeaseIdCard(e.getLeaseIdCard());
|
target.setLeaseIdCard(e.getLeaseIdCard());
|
||||||
target.setLeasePhone(e.getLeasePhone());
|
target.setLeasePhone(e.getLeasePhone());
|
||||||
target.setLeaseStartDate(e.getLeaseStartDate());
|
target.setLeaseStartDate(e.getLeaseStartDate());
|
||||||
target.setLeaseEndDate(e.getLeaseEndDate());
|
target.setLeaseEndDate(e.getLeaseEndDate());
|
||||||
|
|
||||||
|
target.setId(IdUtil.fastUUID());
|
||||||
|
target.setTenantId(String.valueOf(getLoginUser().getTenantId()));
|
||||||
target.setLeaseStatus(CommonConstants.YES_CODE);
|
target.setLeaseStatus(CommonConstants.YES_CODE);
|
||||||
plotLesseeMapper.updateById(target);
|
|
||||||
|
target.setBaseId(plotInfoDO.getBaseId());
|
||||||
|
target.setBaseName(baseNameMap.get(plotInfoDO.getBaseId()));
|
||||||
|
target.setPlotId(plotInfoDO.getId());
|
||||||
|
target.setPlotName(plotInfoDO.getPlotName());
|
||||||
|
plotLesseeMapper.insert(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -350,4 +364,15 @@ public class PlotInfoServiceImpl implements PlotInfoService {
|
|||||||
|
|
||||||
return BeanUtils.toBean(list, PlotLesseeDetailsRespVO.class);
|
return BeanUtils.toBean(list, PlotLesseeDetailsRespVO.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PlotLesseeDetailsRespVO> getPlotLesseeList2(String plotId) {
|
||||||
|
LambdaQueryWrapperX<PlotLesseeDO> x = new LambdaQueryWrapperX<>();
|
||||||
|
x.eq(PlotLesseeDO::getDeleted, CommonConstants.NO_CODE);
|
||||||
|
x.eq(PlotLesseeDO::getLeaseStatus, YES_CODE);
|
||||||
|
x.eq(PlotLesseeDO::getPlotId, plotId);
|
||||||
|
List<PlotLesseeDO> list = plotLesseeMapper.selectList(x);
|
||||||
|
|
||||||
|
return BeanUtils.toBean(list, PlotLesseeDetailsRespVO.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user