feat (farm): 租户导入/出
-
This commit is contained in:
@@ -87,8 +87,12 @@ public class BaseInfoRespVO {
|
||||
private String plotManager;
|
||||
@Schema(description = "地块坐标")
|
||||
private String plotPoint;
|
||||
private Integer plotLeaseStatus;
|
||||
private String plotLeaseStatusName;
|
||||
@Schema(description = "网格信息")
|
||||
private List<GridInfo> gridOverviewList;
|
||||
@Schema(description = "户主流转信息")
|
||||
private List<PlotLesseeDetailsRespVO> lesseeList;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@@ -4,10 +4,14 @@ import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Schema(description = "管理后台 - 地块户主 - 导出")
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ExcelIgnoreUnannotated
|
||||
public class PlotLesseeForExportExcelRespVO {
|
||||
|
||||
|
||||
@@ -4,13 +4,17 @@ import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Schema(description = "管理后台 - 地块户主 - 导入")
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = false)
|
||||
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.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.SneakyThrows;
|
||||
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.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.ErrorCodeConstants.*;
|
||||
|
||||
@@ -307,10 +309,15 @@ public class BaseInfoServiceImpl implements BaseInfoService {
|
||||
private List<BaseInfoRespVO.PlotInfo> packagePlotInfo(Map<String, String> employeeMap, List<PlotInfoDO> plotList) {
|
||||
List<BaseInfoRespVO.PlotInfo> targetList = new ArrayList<>();
|
||||
for (PlotInfoDO aDo : plotList) {
|
||||
String plotManager = employeeMap.getOrDefault(aDo.getEmployeeId(), "系统");
|
||||
// 网格
|
||||
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()));
|
||||
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);
|
||||
}
|
||||
return targetList;
|
||||
|
||||
@@ -479,12 +479,12 @@ public class DeviceInfoServiceImpl implements DeviceInfoService {
|
||||
// 获取设备商数据
|
||||
switch (typeCode) {
|
||||
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);
|
||||
rows.addAll(rows1);
|
||||
break;
|
||||
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);
|
||||
rows.addAll(rows2);
|
||||
break;
|
||||
@@ -538,6 +538,9 @@ public class DeviceInfoServiceImpl implements DeviceInfoService {
|
||||
List<DeviceMonitorDataRespVO.Row> rows = new ArrayList<>();
|
||||
|
||||
RealTimeDataRespVO realTimeDataRespVO = (RealTimeDataRespVO) soilInfo.getRealTimeData().getData();
|
||||
if (ObjectUtils.isEmpty(realTimeDataRespVO)) {
|
||||
return rows;
|
||||
}
|
||||
List<RealTimeDataRespVO.DeviceInfo> data = realTimeDataRespVO.getData();
|
||||
for (RealTimeDataRespVO.DeviceInfo d : data) {
|
||||
rows.add(new DeviceMonitorDataRespVO.Row(name, ONLINE_MAP.get(d.getStatus()), ""));
|
||||
|
||||
@@ -125,4 +125,6 @@ public interface PlotInfoService {
|
||||
* @return
|
||||
*/
|
||||
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.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.*;
|
||||
import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
@@ -205,27 +204,42 @@ public class PlotInfoServiceImpl implements PlotInfoService {
|
||||
@Override
|
||||
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) {
|
||||
if (!collect.containsKey(e.getPlotName())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ObjectUtils.isEmpty(e.getLeaseName()) || ObjectUtils.isEmpty(e.getLeaseIdCard())
|
||||
|| ObjectUtils.isEmpty(e.getLeasePhone() ) || ObjectUtils.isEmpty(e.getLeaseStartDate()) || ObjectUtils.isEmpty(e.getLeaseEndDate())) {
|
||||
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();
|
||||
target.setId(collect.get(e.getPlotName()));
|
||||
target.setLeaseName(e.getLeaseName());
|
||||
target.setLeaseIdCard(e.getLeaseIdCard());
|
||||
target.setLeasePhone(e.getLeasePhone());
|
||||
target.setLeaseStartDate(e.getLeaseStartDate());
|
||||
target.setLeaseEndDate(e.getLeaseEndDate());
|
||||
|
||||
target.setId(IdUtil.fastUUID());
|
||||
target.setTenantId(String.valueOf(getLoginUser().getTenantId()));
|
||||
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);
|
||||
}
|
||||
|
||||
@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