Browse Source

1.1.0 新增参拍记录导出接口,批量删除接口;修改导出方法

feature/v1.1.0
peihao 4 years ago
parent
commit
4a9c1f1964
  1. 36
      air/src/main/java/com/air/land/controller/AuctionRecordController.java
  2. 6
      air/src/main/java/com/air/land/controller/LandListedController.java
  3. 4
      air/src/main/java/com/air/land/controller/LandToListController.java
  4. 2
      air/src/main/java/com/air/land/mapper/AuctionRecordMapper.java
  5. 2
      air/src/main/java/com/air/land/service/AuctionRecordService.java
  6. 10
      air/src/main/java/com/air/land/service/LandListedService.java
  7. 9
      air/src/main/java/com/air/land/service/LandToListService.java
  8. 30
      air/src/main/java/com/air/land/service/impl/AuctionRecordServiceImpl.java
  9. 20
      air/src/main/java/com/air/land/service/impl/LandListedServiceImpl.java
  10. 18
      air/src/main/java/com/air/land/service/impl/LandToListServiceImpl.java
  11. 18
      air/src/main/java/com/air/utils/ExcelUtil.java
  12. 15
      air/src/main/resources/mapper/AuctionRecordMapper.xml
  13. BIN
      air/src/main/resources/templates/excel/auction_record.xlsx

36
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<Long> ids) {
return R.ok(auctionRecordService.removeByIds(ids));
}
/**
@ -110,4 +116,24 @@ public class AuctionRecordController {
public R<List<AuctionRecord>> 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<Long> auctionRecordIds) throws IOException {
List<List<String>> 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);
}
}

6
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<String> landListedIds) {
return R.ok(landListedService.removeByIds(landListedIds));
public R removeByIds(@RequestBody List<String> landListedIds) {
return R.ok(landListedService.removeLandByIds(landListedIds),"删除成功");
}
/**
@ -214,7 +214,7 @@ public class LandListedController {
List<List<String>> 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();

4
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<String> proposedseriaIds) {
return R.ok(landToListService.removeByIds(proposedseriaIds));
return R.ok(landToListService.removeLandToListByIds(proposedseriaIds));
}
@ -194,7 +194,7 @@ public class LandToListController {
List<List<String>> 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();

2
air/src/main/java/com/air/land/mapper/AuctionRecordMapper.java

@ -17,4 +17,6 @@ import java.util.List;
public interface AuctionRecordMapper extends BaseMapper<AuctionRecord> {
List<AuctionRecord> selectPages(Page page, @Param("param") AuctionRecordPageVo recordPageVo);
List<AuctionRecord> getAuctionRecords(@Param("ids") List<Long> ids);
}

2
air/src/main/java/com/air/land/service/AuctionRecordService.java

@ -29,6 +29,8 @@ public interface AuctionRecordService extends IService<AuctionRecord> {
*/
List<AuctionRecord> readRecordExcel(MultipartFile file);
List<List<String>> getAuctionRecord(List<Long> auctionRecordIds);
IPage<AuctionRecord> selectPage(Page page, AuctionRecordPageVo recordPageVo);
}

10
air/src/main/java/com/air/land/service/LandListedService.java

@ -80,4 +80,14 @@ public interface LandListedService extends IService<LandListed> {
* @return
**/
Integer selectId();
/**
* 删除已挂牌地块及经纬度数据
* @author peihao
* @param landListedIds 已挂牌id集合
* @date 2021/9/1
* @return
**/
boolean removeLandByIds(List<String> landListedIds);
}

9
air/src/main/java/com/air/land/service/LandToListService.java

@ -35,4 +35,13 @@ public interface LandToListService extends IService<LandToList> {
**/
Integer selectId();
/**
* 删除拟挂牌地块及经纬度数据
* @author peihao
* @param landListedIds 拟挂牌id集合
* @date 2021/9/1
* @return
**/
boolean removeLandToListByIds(List<String> landListedIds);
}

30
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<AuctionRecordMapper, A
return readAuction(file.getInputStream(), 0, 7, 21);
}
@Override
public List<List<String>> getAuctionRecord(List<Long> auctionRecordIds) {
List<AuctionRecord> auctionRecords = baseMapper.getAuctionRecords(auctionRecordIds);
if (CollectionUtil.isEmpty(auctionRecords)){
throw new BusinessException("未查询到企业参拍记录");
}
return entityToList(auctionRecords);
}
@Override
public IPage<AuctionRecord> selectPage(Page page, AuctionRecordPageVo recordPageVo) {
List<AuctionRecord> auctionRecords = baseMapper.selectPages(page, recordPageVo);
@ -133,6 +144,25 @@ public class AuctionRecordServiceImpl extends ServiceImpl<AuctionRecordMapper, A
return result;
}
private List<List<String>> entityToList(List<AuctionRecord> auctionRecords){
List<List<String>> result = new ArrayList<>(auctionRecords.size());
auctionRecords.forEach(auctionRecord -> {
List<String> 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 {

20
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<LandListedMapper, LandListed> implements LandListedService {
@Autowired
private LandListedLonLatService listedLonLatService;
@Override
public R<Page<LandListedDto>> getLandListedByDate(QueryPage page, LandListedAppletsVo appletsVo) {
Page<LandListedDto> page1 = page.toPage();
@ -104,8 +112,10 @@ public class LandListedServiceImpl extends ServiceImpl<LandListedMapper, LandLis
@Override
public List<List<String>> getLandList(List<String> ids) {
// List<LandListed> landListeds = this.list();
List<LandListed> landListeds = this.listByIds(ids);
if (CollectionUtil.isEmpty(landListeds)){
throw new BusinessException("未查询到已挂牌地块数据!");
}
List<List<String>> list = new ArrayList<>();
landListeds.forEach(landListed -> {
list.add(entityToList(landListed));
@ -136,6 +146,14 @@ public class LandListedServiceImpl extends ServiceImpl<LandListedMapper, LandLis
return baseMapper.selectId();
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean removeLandByIds(List<String> landListedIds){
this.removeByIds(landListedIds);
listedLonLatService.remove(Wrappers.<LandListedLonLat>query().lambda().in(LandListedLonLat::getLandListedId,landListedIds));
return true;
}
/**
* 导入地块数据
*

18
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<LandToListMapper, LandToL
private LandListedMapper landListedMapper;
private LandToListLonLatService landToListLonLatService;
@Transactional(rollbackFor = Exception.class)
@Override
public R<Boolean> sendLandList(String proposedseriaId) {
@ -69,6 +76,9 @@ public class LandToListServiceImpl extends ServiceImpl<LandToListMapper, LandToL
@Override
public List<List<String>> getLandList(List<String> ids) {
List<LandToList> landListeds = this.listByIds(ids);
if (CollectionUtil.isEmpty(landListeds)){
throw new BusinessException("未查询到拟挂牌地块数据!");
}
List<List<String>> list = new ArrayList<>();
landListeds.forEach(landListed -> {
list.add(entityToList(landListed));
@ -103,6 +113,14 @@ public class LandToListServiceImpl extends ServiceImpl<LandToListMapper, LandToL
return baseMapper.selectId();
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean removeLandToListByIds(List<String> proposedseriaIds){
this.removeByIds(proposedseriaIds);
landToListLonLatService.remove(Wrappers.<LandToListLonLat>query().lambda().in(LandToListLonLat::getProposedseriaId,proposedseriaIds));
return true;
}
/**
* 导入拟挂牌地块数据
*

18
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<List<String>> dataList, InputStream inputStream) throws IOException {
public static XSSFWorkbook exportLandListedExcel(List<List<String>> 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<String> 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;

15
air/src/main/resources/mapper/AuctionRecordMapper.xml

@ -37,4 +37,19 @@
order by ar.create_date desc
</select>
<select id="getAuctionRecords" resultType="com.air.land.entity.AuctionRecord">
SELECT
ar.*,
ll.land_code landCode
FROM
auction_record ar
JOIN land_listed ll ON ar.land_listed_id = ll.land_listed_id
where ar.auction_record_id in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
order by ar.create_date desc
</select>
</mapper>

BIN
air/src/main/resources/templates/excel/auction_record.xlsx

Binary file not shown.
Loading…
Cancel
Save