diff --git a/air/src/main/java/com/air/land/controller/AuctionRecordController.java b/air/src/main/java/com/air/land/controller/AuctionRecordController.java index 1322159..1863a21 100644 --- a/air/src/main/java/com/air/land/controller/AuctionRecordController.java +++ b/air/src/main/java/com/air/land/controller/AuctionRecordController.java @@ -5,6 +5,7 @@ import com.air.land.entity.AuctionRecord; import com.air.land.service.AuctionRecordService; import com.air.land.vo.AuctionRecordPageVo; import com.air.land.vo.AuctionRecordVo; +import com.air.utils.ExcelUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -13,12 +14,17 @@ import com.cinderella.framework.common.data.mybatis.QueryPage; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.util.List; @@ -91,13 +97,13 @@ public class AuctionRecordController { /** * 通过id删除参拍记录表 * - * @param id + * @param ids * @return R */ - @ApiOperation(value = "通过id删除参拍记录表", notes = "通过id删除参拍记录表") - @DeleteMapping("/{id}") - public R removeById(@PathVariable Long id) { - return R.ok(auctionRecordService.removeById(id)); + @ApiOperation(value = "通过ids删除参拍记录表", notes = "通过ids删除参拍记录表") + @DeleteMapping + public R removeByIds(@RequestBody List ids) { + return R.ok(auctionRecordService.removeByIds(ids)); } /** @@ -110,4 +116,24 @@ public class AuctionRecordController { public R> importRecordExcel(@RequestParam(value="uploadFile") MultipartFile file){ return R.ok(auctionRecordService.readRecordExcel(file)); } + + /** + * 导出地块参拍记录 + * + * @author peihao + * @date 2021/5/25 + **/ + @ApiOperation(value = "导出地块参拍记录", notes = "导出地块参拍记录") + @GetMapping("/exportRecordExcel") + public void exportLandListExcel(HttpServletResponse response, @RequestParam List auctionRecordIds) throws IOException { + List> recordList = auctionRecordService.getAuctionRecord(auctionRecordIds); + InputStream resourceAsStream = LandListedController.class.getClassLoader().getResourceAsStream("templates/excel/auction_record.xlsx"); + // 读取excel模板 + XSSFWorkbook wb = ExcelUtil.exportLandListedExcel(recordList,resourceAsStream,1); + response.setContentType("application/vnd.ms-excel;charset=utf-8"); + response.setHeader("Content-Disposition", "attachment;filename=report.xlsx"); + OutputStream outputStream = response.getOutputStream(); + wb.write(outputStream); + } + } diff --git a/air/src/main/java/com/air/land/controller/LandListedController.java b/air/src/main/java/com/air/land/controller/LandListedController.java index 9cb6c57..8648937 100644 --- a/air/src/main/java/com/air/land/controller/LandListedController.java +++ b/air/src/main/java/com/air/land/controller/LandListedController.java @@ -169,8 +169,8 @@ public class LandListedController { */ @ApiOperation(value = "通过id删除已挂牌地块", notes = "通过id删除已挂牌地块") @DeleteMapping - public R removeById(@RequestBody List landListedIds) { - return R.ok(landListedService.removeByIds(landListedIds)); + public R removeByIds(@RequestBody List landListedIds) { + return R.ok(landListedService.removeLandByIds(landListedIds),"删除成功"); } /** @@ -214,7 +214,7 @@ public class LandListedController { List> landList = landListedService.getLandList(ids); InputStream resourceAsStream = LandListedController.class.getClassLoader().getResourceAsStream("templates/excel/exportLandList.xlsx"); // 读取excel模板 - XSSFWorkbook wb = ExcelUtil.exportLandListedExcel(landList,resourceAsStream); + XSSFWorkbook wb = ExcelUtil.exportLandListedExcel(landList,resourceAsStream,2); response.setContentType("application/vnd.ms-excel;charset=utf-8"); response.setHeader("Content-Disposition", "attachment;filename=report.xlsx"); OutputStream outputStream = response.getOutputStream(); diff --git a/air/src/main/java/com/air/land/controller/LandToListController.java b/air/src/main/java/com/air/land/controller/LandToListController.java index a83643e..e0aaee6 100644 --- a/air/src/main/java/com/air/land/controller/LandToListController.java +++ b/air/src/main/java/com/air/land/controller/LandToListController.java @@ -155,7 +155,7 @@ public class LandToListController { @ApiOperation(value = "通过id删除拟挂牌地块", notes = "通过id删除拟挂牌地块") @DeleteMapping public R removeById(@RequestBody List proposedseriaIds) { - return R.ok(landToListService.removeByIds(proposedseriaIds)); + return R.ok(landToListService.removeLandToListByIds(proposedseriaIds)); } @@ -194,7 +194,7 @@ public class LandToListController { List> landList = landToListService.getLandList(ids); InputStream resourceAsStream = LandListedController.class.getClassLoader().getResourceAsStream("templates/excel/exportLandToList.xlsx"); // 读取excel模板 - XSSFWorkbook wb = ExcelUtil.exportLandListedExcel(landList,resourceAsStream); + XSSFWorkbook wb = ExcelUtil.exportLandListedExcel(landList,resourceAsStream,2); response.setContentType("application/vnd.ms-excel;charset=utf-8"); response.setHeader("Content-Disposition","attachment;filename=report.xlsx"); OutputStream outputStream = response.getOutputStream(); diff --git a/air/src/main/java/com/air/land/mapper/AuctionRecordMapper.java b/air/src/main/java/com/air/land/mapper/AuctionRecordMapper.java index f4593eb..f42252b 100644 --- a/air/src/main/java/com/air/land/mapper/AuctionRecordMapper.java +++ b/air/src/main/java/com/air/land/mapper/AuctionRecordMapper.java @@ -17,4 +17,6 @@ import java.util.List; public interface AuctionRecordMapper extends BaseMapper { List selectPages(Page page, @Param("param") AuctionRecordPageVo recordPageVo); + + List getAuctionRecords(@Param("ids") List ids); } diff --git a/air/src/main/java/com/air/land/service/AuctionRecordService.java b/air/src/main/java/com/air/land/service/AuctionRecordService.java index 8f72398..dcf560f 100644 --- a/air/src/main/java/com/air/land/service/AuctionRecordService.java +++ b/air/src/main/java/com/air/land/service/AuctionRecordService.java @@ -29,6 +29,8 @@ public interface AuctionRecordService extends IService { */ List readRecordExcel(MultipartFile file); + List> getAuctionRecord(List auctionRecordIds); + IPage selectPage(Page page, AuctionRecordPageVo recordPageVo); } diff --git a/air/src/main/java/com/air/land/service/LandListedService.java b/air/src/main/java/com/air/land/service/LandListedService.java index ea92103..19aa55d 100644 --- a/air/src/main/java/com/air/land/service/LandListedService.java +++ b/air/src/main/java/com/air/land/service/LandListedService.java @@ -80,4 +80,14 @@ public interface LandListedService extends IService { * @return **/ Integer selectId(); + + + /** + * 删除已挂牌地块及经纬度数据 + * @author peihao + * @param landListedIds 已挂牌id集合 + * @date 2021/9/1 + * @return + **/ + boolean removeLandByIds(List landListedIds); } diff --git a/air/src/main/java/com/air/land/service/LandToListService.java b/air/src/main/java/com/air/land/service/LandToListService.java index b5965c7..7aebda9 100644 --- a/air/src/main/java/com/air/land/service/LandToListService.java +++ b/air/src/main/java/com/air/land/service/LandToListService.java @@ -35,4 +35,13 @@ public interface LandToListService extends IService { **/ Integer selectId(); + /** + * 删除拟挂牌地块及经纬度数据 + * @author peihao + * @param landListedIds 拟挂牌id集合 + * @date 2021/9/1 + * @return + **/ + boolean removeLandToListByIds(List landListedIds); + } diff --git a/air/src/main/java/com/air/land/service/impl/AuctionRecordServiceImpl.java b/air/src/main/java/com/air/land/service/impl/AuctionRecordServiceImpl.java index 3891b4f..9496122 100644 --- a/air/src/main/java/com/air/land/service/impl/AuctionRecordServiceImpl.java +++ b/air/src/main/java/com/air/land/service/impl/AuctionRecordServiceImpl.java @@ -1,5 +1,6 @@ package com.air.land.service.impl; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.IoUtil; @@ -14,6 +15,7 @@ import com.air.land.vo.AuctionRecordPageVo; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.cinderella.framework.common.core.exception.BusinessException; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.apache.poi.xssf.usermodel.XSSFCell; @@ -75,6 +77,15 @@ public class AuctionRecordServiceImpl extends ServiceImpl> getAuctionRecord(List auctionRecordIds) { + List auctionRecords = baseMapper.getAuctionRecords(auctionRecordIds); + if (CollectionUtil.isEmpty(auctionRecords)){ + throw new BusinessException("未查询到企业参拍记录"); + } + return entityToList(auctionRecords); + } + @Override public IPage selectPage(Page page, AuctionRecordPageVo recordPageVo) { List auctionRecords = baseMapper.selectPages(page, recordPageVo); @@ -133,6 +144,25 @@ public class AuctionRecordServiceImpl extends ServiceImpl> entityToList(List auctionRecords){ + List> result = new ArrayList<>(auctionRecords.size()); + auctionRecords.forEach(auctionRecord -> { + List list = new ArrayList<>(); + list.add(auctionRecord.getLandCode()); + list.add(auctionRecord.getRanking()); + list.add(auctionRecord.getRaiseEnterprise()); + list.add(auctionRecord.getRaisePrice()); + list.add(auctionRecord.getNominalFloorPrice()); + list.add(auctionRecord.getPercentUnpaidTransfers()); + list.add(auctionRecord.getActualFloorPrice()); + list.add(auctionRecord.getPremiumRate()); + list.add(auctionRecord.getFinalRound()); + list.add(auctionRecord.getWinnerEnterprises()); + result.add(list); + }); + return result; + } + private String getCellValue(XSSFCell cell) { String value; try { diff --git a/air/src/main/java/com/air/land/service/impl/LandListedServiceImpl.java b/air/src/main/java/com/air/land/service/impl/LandListedServiceImpl.java index d105423..dd6e895 100644 --- a/air/src/main/java/com/air/land/service/impl/LandListedServiceImpl.java +++ b/air/src/main/java/com/air/land/service/impl/LandListedServiceImpl.java @@ -7,10 +7,13 @@ import com.air.applets.vo.LandVo; import com.air.land.dto.LandListedDto; import com.air.land.dto.LandListedStatisticsDto; import com.air.land.entity.LandListed; +import com.air.land.entity.LandListedLonLat; import com.air.land.mapper.LandListedMapper; +import com.air.land.service.LandListedLonLatService; import com.air.land.service.LandListedService; import com.air.land.vo.LandListedAppletsVo; import com.air.utils.DateUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.cinderella.framework.common.core.exception.BusinessException; @@ -22,7 +25,9 @@ import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; @@ -42,6 +47,9 @@ import java.util.List; @Service public class LandListedServiceImpl extends ServiceImpl implements LandListedService { + @Autowired + private LandListedLonLatService listedLonLatService; + @Override public R> getLandListedByDate(QueryPage page, LandListedAppletsVo appletsVo) { Page page1 = page.toPage(); @@ -104,8 +112,10 @@ public class LandListedServiceImpl extends ServiceImpl> getLandList(List ids) { -// List landListeds = this.list(); List landListeds = this.listByIds(ids); + if (CollectionUtil.isEmpty(landListeds)){ + throw new BusinessException("未查询到已挂牌地块数据!"); + } List> list = new ArrayList<>(); landListeds.forEach(landListed -> { list.add(entityToList(landListed)); @@ -136,6 +146,14 @@ public class LandListedServiceImpl extends ServiceImpl landListedIds){ + this.removeByIds(landListedIds); + listedLonLatService.remove(Wrappers.query().lambda().in(LandListedLonLat::getLandListedId,landListedIds)); + return true; + } + /** * 导入地块数据 * diff --git a/air/src/main/java/com/air/land/service/impl/LandToListServiceImpl.java b/air/src/main/java/com/air/land/service/impl/LandToListServiceImpl.java index dda7ab0..ca5a46e 100644 --- a/air/src/main/java/com/air/land/service/impl/LandToListServiceImpl.java +++ b/air/src/main/java/com/air/land/service/impl/LandToListServiceImpl.java @@ -1,6 +1,7 @@ package com.air.land.service.impl; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.air.applets.dto.LandDto; @@ -9,12 +10,16 @@ import com.air.applets.vo.LandVo; import com.air.common.Constant; import com.air.enums.LandListStatusEnum; import com.air.land.entity.LandListed; +import com.air.land.entity.LandListedLonLat; import com.air.land.entity.LandToList; +import com.air.land.entity.LandToListLonLat; import com.air.land.mapper.LandListedMapper; import com.air.land.mapper.LandToListMapper; +import com.air.land.service.LandToListLonLatService; import com.air.land.service.LandToListService; import com.air.utils.DateUtil; import com.air.utils.ExcelUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.cinderella.framework.common.core.exception.BusinessException; @@ -49,6 +54,8 @@ public class LandToListServiceImpl extends ServiceImpl sendLandList(String proposedseriaId) { @@ -69,6 +76,9 @@ public class LandToListServiceImpl extends ServiceImpl> getLandList(List ids) { List landListeds = this.listByIds(ids); + if (CollectionUtil.isEmpty(landListeds)){ + throw new BusinessException("未查询到拟挂牌地块数据!"); + } List> list = new ArrayList<>(); landListeds.forEach(landListed -> { list.add(entityToList(landListed)); @@ -103,6 +113,14 @@ public class LandToListServiceImpl extends ServiceImpl proposedseriaIds){ + this.removeByIds(proposedseriaIds); + landToListLonLatService.remove(Wrappers.query().lambda().in(LandToListLonLat::getProposedseriaId,proposedseriaIds)); + return true; + } + /** * 导入拟挂牌地块数据 * diff --git a/air/src/main/java/com/air/utils/ExcelUtil.java b/air/src/main/java/com/air/utils/ExcelUtil.java index ff67777..7f83427 100644 --- a/air/src/main/java/com/air/utils/ExcelUtil.java +++ b/air/src/main/java/com/air/utils/ExcelUtil.java @@ -22,25 +22,33 @@ public class ExcelUtil { /** - * 已挂牌地块数据导出 + * 数据导出 * * @param dataList 导出数据 * @param inputStream 模板流 + * @param startRow 开始导出行 * @return * @author peihao * @date 2021/6/17 **/ - public static XSSFWorkbook exportLandListedExcel(List> dataList, InputStream inputStream) throws IOException { + public static XSSFWorkbook exportLandListedExcel(List> dataList, InputStream inputStream,int startRow) throws IOException { // 读取excel模板 XSSFWorkbook wb = new XSSFWorkbook(inputStream); XSSFSheet sheet = wb.getSheetAt(0); - //获取表头 + //填充数据 for (int i = 0; i < dataList.size(); i++) { - XSSFRow sheetRow = sheet.getRow(i + 2); + XSSFRow sheetRow = sheet.getRow(i + startRow); + if (sheetRow == null){ + sheetRow = sheet.createRow(i+startRow); + } List list = dataList.get(i); for (int j = 0; j < list.size(); j++) { String value = list.get(j); - sheetRow.getCell(j).setCellValue(value); + XSSFCell cell = sheetRow.getCell(j); + if (cell == null){ + cell = sheetRow.createCell(j); + } + cell.setCellValue(value); } } return wb; diff --git a/air/src/main/resources/mapper/AuctionRecordMapper.xml b/air/src/main/resources/mapper/AuctionRecordMapper.xml index fc3d7af..11dd97e 100644 --- a/air/src/main/resources/mapper/AuctionRecordMapper.xml +++ b/air/src/main/resources/mapper/AuctionRecordMapper.xml @@ -37,4 +37,19 @@ order by ar.create_date desc + + + diff --git a/air/src/main/resources/templates/excel/auction_record.xlsx b/air/src/main/resources/templates/excel/auction_record.xlsx new file mode 100644 index 0000000..2618974 Binary files /dev/null and b/air/src/main/resources/templates/excel/auction_record.xlsx differ