feat (farm): 租户导入/出
-
This commit is contained in:
@@ -100,13 +100,11 @@ public class BaseInfoController {
|
|||||||
@GetMapping("/export-excel")
|
@GetMapping("/export-excel")
|
||||||
@Operation(summary = "导出基地 Excel")
|
@Operation(summary = "导出基地 Excel")
|
||||||
@ApiAccessLog(operateType = EXPORT)
|
@ApiAccessLog(operateType = EXPORT)
|
||||||
public void exportBaseInfoExcel(@Valid BaseInfoPageReqVO pageReqVO,
|
public void exportBaseInfoExcel(@Valid BaseInfoPageReqVO pageReqVO, HttpServletResponse response) throws IOException {
|
||||||
HttpServletResponse response) throws IOException {
|
|
||||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
List<BaseInfoDO> list = baseInfoService.getBaseInfoPage(pageReqVO).getList();
|
List<BaseInfoDO> list = baseInfoService.getBaseInfoPage(pageReqVO).getList();
|
||||||
// 导出 Excel
|
// 导出 Excel
|
||||||
ExcelUtils.write(response, "基地.xls", "数据", BaseInfoRespVO.class,
|
ExcelUtils.write(response, "基地.xls", "数据", BaseInfoRespVO.class, BeanUtils.toBean(list, BaseInfoRespVO.class));
|
||||||
BeanUtils.toBean(list, BaseInfoRespVO.class));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/base/plot/list")
|
@GetMapping("/base/plot/list")
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.farm.controller.admin.managementcenter.baseinfo;
|
package cn.iocoder.yudao.module.farm.controller.admin.managementcenter.baseinfo;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.baseinfo.vo.*;
|
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.baseinfo.vo.*;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.baseinfo.vo.wx.RegularPlotInfoRespVO;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
@@ -24,6 +23,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.IMPORT;
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
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;
|
||||||
|
|
||||||
@@ -33,6 +33,7 @@ import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.module.farm.dal.dataobject.plotinfo.PlotInfoDO;
|
import cn.iocoder.yudao.module.farm.dal.dataobject.plotinfo.PlotInfoDO;
|
||||||
import cn.iocoder.yudao.module.farm.service.plotinfo.PlotInfoService;
|
import cn.iocoder.yudao.module.farm.service.plotinfo.PlotInfoService;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@Tag(name = "管理中心 - 基地规划 - 基地/地块")
|
@Tag(name = "管理中心 - 基地规划 - 基地/地块")
|
||||||
@RestController
|
@RestController
|
||||||
@@ -104,6 +105,22 @@ public class PlotInfoController {
|
|||||||
BeanUtils.toBean(list, PlotInfoRespVO.class));
|
BeanUtils.toBean(list, PlotInfoRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/plot-lessee/export-excel")
|
||||||
|
@Operation(summary = "导出户主 Excel")
|
||||||
|
@ApiAccessLog(operateType = EXPORT)
|
||||||
|
public void exportPlotLesseeInfoExcel(HttpServletResponse response) throws IOException {
|
||||||
|
List<PlotLesseeForExportExcelRespVO> list = plotInfoService.getPlotLesseeInfo();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "户主.xls", "数据", PlotLesseeForExportExcelRespVO.class, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/plot-lessee/import-excel")
|
||||||
|
@Operation(summary = "导入户主 Excel")
|
||||||
|
@ApiAccessLog(operateType = IMPORT)
|
||||||
|
public CommonResult<Boolean> importPlotLesseeInfoExcel(@RequestParam("file")MultipartFile file) throws IOException {
|
||||||
|
List<PlotLesseeForImportExcelRespVO> list = ExcelUtils.read(file, PlotLesseeForImportExcelRespVO.class);
|
||||||
|
plotInfoService.setPlotLesseeInfo(list);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -32,12 +32,12 @@ public class PlotLesseeDetailsRespVO {
|
|||||||
private String leasePhone;
|
private String leasePhone;
|
||||||
|
|
||||||
@Schema(description = "租赁开始日期")
|
@Schema(description = "租赁开始日期")
|
||||||
@ExcelProperty("租赁开始日期")
|
@ExcelProperty("租赁开始日期 (yyyy-MM-dd)")
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
private String leaseStartDate;
|
private String leaseStartDate;
|
||||||
|
|
||||||
@Schema(description = "租赁接口日期")
|
@Schema(description = "租赁接口日期")
|
||||||
@ExcelProperty("租赁接口日期")
|
@ExcelProperty("租赁接口日期 (yyyy-MM-dd)")
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
private String leaseEndDate;
|
private String leaseEndDate;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package cn.iocoder.yudao.module.farm.controller.admin.managementcenter.baseinfo.vo;
|
||||||
|
|
||||||
|
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.Data;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 地块户主 - 导出")
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class PlotLesseeForExportExcelRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "基地名称")
|
||||||
|
@ExcelProperty("基地名称")
|
||||||
|
private String baseName;
|
||||||
|
|
||||||
|
@Schema(description = "地块名称")
|
||||||
|
@ExcelProperty("地块名称")
|
||||||
|
private String plotName;
|
||||||
|
|
||||||
|
@Schema(description = "户主姓名")
|
||||||
|
@ExcelProperty("户主姓名")
|
||||||
|
private String leaseName;
|
||||||
|
|
||||||
|
@Schema(description = "户主身份证号码")
|
||||||
|
@ExcelProperty("户主身份证号码")
|
||||||
|
private String leaseIdCard;
|
||||||
|
|
||||||
|
@Schema(description = "户主手机号码")
|
||||||
|
@ExcelProperty("户主手机号码")
|
||||||
|
private String leasePhone;
|
||||||
|
|
||||||
|
@Schema(description = "租赁开始日期")
|
||||||
|
@ExcelProperty("租赁开始日期 (yyyy-MM-dd)")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private String leaseStartDate;
|
||||||
|
|
||||||
|
@Schema(description = "租赁接口日期")
|
||||||
|
@ExcelProperty("租赁接口日期 (yyyy-MM-dd)")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private String leaseEndDate;
|
||||||
|
|
||||||
|
public PlotLesseeForExportExcelRespVO(String baseName, String plotName) {
|
||||||
|
this.baseName = baseName;
|
||||||
|
this.plotName = plotName;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package cn.iocoder.yudao.module.farm.controller.admin.managementcenter.baseinfo.vo;
|
||||||
|
|
||||||
|
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.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 地块户主 - 导入")
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = false)
|
||||||
|
public class PlotLesseeForImportExcelRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "基地名称")
|
||||||
|
@ExcelProperty("基地名称")
|
||||||
|
private String baseName;
|
||||||
|
|
||||||
|
@Schema(description = "地块名称")
|
||||||
|
@ExcelProperty("地块名称")
|
||||||
|
private String plotName;
|
||||||
|
|
||||||
|
@Schema(description = "户主姓名")
|
||||||
|
@ExcelProperty("户主姓名")
|
||||||
|
private String leaseName;
|
||||||
|
|
||||||
|
@Schema(description = "户主身份证号码")
|
||||||
|
@ExcelProperty("户主身份证号码")
|
||||||
|
private String leaseIdCard;
|
||||||
|
|
||||||
|
@Schema(description = "户主手机号码")
|
||||||
|
@ExcelProperty("户主手机号码")
|
||||||
|
private String leasePhone;
|
||||||
|
|
||||||
|
@Schema(description = "租赁开始日期")
|
||||||
|
@ExcelProperty("租赁开始日期 (yyyy-MM-dd)")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private LocalDate leaseStartDate;
|
||||||
|
|
||||||
|
@Schema(description = "租赁接口日期")
|
||||||
|
@ExcelProperty("租赁接口日期 (yyyy-MM-dd)")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private LocalDate leaseEndDate;
|
||||||
|
|
||||||
|
public PlotLesseeForImportExcelRespVO(String baseName, String plotName) {
|
||||||
|
this.baseName = baseName;
|
||||||
|
this.plotName = plotName;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.farm.service.plotinfo;
|
package cn.iocoder.yudao.module.farm.service.plotinfo;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.baseinfo.vo.PlotInfoPageReqVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.baseinfo.vo.*;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.baseinfo.vo.PlotInfoSaveReqVO;
|
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.baseinfo.vo.PlotLesseeDetailsRespVO;
|
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.baseinfo.vo.PlotLesseeInfoRespVO;
|
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.baseinfo.vo.wx.RegularPlotInfoRespVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.baseinfo.vo.wx.RegularPlotInfoRespVO;
|
||||||
import cn.iocoder.yudao.module.farm.dal.dataobject.plotinfo.PlotInfoDO;
|
import cn.iocoder.yudao.module.farm.dal.dataobject.plotinfo.PlotInfoDO;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
@@ -59,6 +56,14 @@ public interface PlotInfoService {
|
|||||||
*/
|
*/
|
||||||
PlotLesseeInfoRespVO getPlotLesseeInfo(String id);
|
PlotLesseeInfoRespVO getPlotLesseeInfo(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出户主信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<PlotLesseeForExportExcelRespVO> getPlotLesseeInfo();
|
||||||
|
|
||||||
|
void setPlotLesseeInfo(List<PlotLesseeForImportExcelRespVO> req);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过基地ID获取地块集合
|
* 通过基地ID获取地块集合
|
||||||
* @param baseId
|
* @param baseId
|
||||||
|
|||||||
@@ -193,6 +193,43 @@ public class PlotInfoServiceImpl implements PlotInfoService {
|
|||||||
return plotLesseeDetailsRespVO;
|
return plotLesseeDetailsRespVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PlotLesseeForExportExcelRespVO> getPlotLesseeInfo() {
|
||||||
|
|
||||||
|
Map<String, String> baseNameMap = baseInfoMapper.selectList().stream().collect(Collectors.toMap(BaseInfoDO::getId, BaseInfoDO::getName, (v1, v2) -> v1));
|
||||||
|
List<PlotInfoDO> plotInfoDOS = plotInfoMapper.selectList(PlotInfoDO::getPlotLeaseStatus, CommonConstants.NO_CODE);
|
||||||
|
return plotInfoDOS.stream().map(p -> new PlotLesseeForExportExcelRespVO(baseNameMap.get(p.getBaseId()), p.getPlotName())).toList();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPlotLesseeInfo(List<PlotLesseeForImportExcelRespVO> req) {
|
||||||
|
|
||||||
|
Map<String, String> collect = plotLesseeMapper.selectList().stream().collect(Collectors.toMap(PlotLesseeDO::getPlotName, PlotLesseeDO::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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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.setLeaseStatus(CommonConstants.YES_CODE);
|
||||||
|
plotLesseeMapper.updateById(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PlotInfoDO> getPlotInfos(String baseId) {
|
public List<PlotInfoDO> getPlotInfos(String baseId) {
|
||||||
// 员工集合 <id,name>
|
// 员工集合 <id,name>
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package cn.iocoder.yudao.module.farm.utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: .doc 模板工具类
|
||||||
|
* @author: binda
|
||||||
|
* @date: 2025/10/23 16:37
|
||||||
|
*/
|
||||||
|
public class DocTemplateWithListUtil {
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user