Browse Source

导出bug修改

release/v1.0.0
yueminglinxia 4 years ago
parent
commit
7a3a21666d
  1. 152
      air/src/main/java/com/air/land/service/impl/LandListedServiceImpl.java
  2. 6
      air/src/main/java/com/air/utils/DateUtil.java
  3. 1
      air/src/main/java/com/air/utils/ExcelUtil.java
  4. BIN
      air/src/main/resources/templates/excel/exportLandList.xlsx

152
air/src/main/java/com/air/land/service/impl/LandListedServiceImpl.java

@ -1,5 +1,7 @@
package com.air.land.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.air.land.dto.LandListedDto;
import com.air.land.dto.LandListedStatisticsDto;
import com.air.land.entity.LandListed;
@ -8,6 +10,7 @@ import com.air.land.service.LandListedService;
import com.air.land.vo.LandListedAppletsVo;
import com.air.utils.DateUtil;
import com.air.utils.ExcelUtil;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cinderella.framework.common.core.exception.BusinessException;
@ -17,6 +20,7 @@ import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
@ -63,8 +67,11 @@ public class LandListedServiceImpl extends ServiceImpl<LandListedMapper, LandLis
dataList.forEach(data ->{
try {
LandListed landListed = listToEntity(data);
list.add(landListed);
if(ObjectUtil.isNotEmpty(landListed)){
list.add(landListed);
}
}catch (Exception e){
e.printStackTrace();
new BusinessException("导入已挂牌地块数据转换出错");
}
});
@ -83,72 +90,83 @@ public class LandListedServiceImpl extends ServiceImpl<LandListedMapper, LandLis
private LandListed listToEntity(List<String> data) {
LandListed landListed = new LandListed();
landListed.setAnnoId(data.get(0));
landListed.setLandCode(data.get(1));
landListed.setLandPosition(data.get(2));
landListed.setLandUsage(data.get(3));
landListed.setLandTransferSquare(data.get(4));
landListed.setLandTransferMu(data.get(5));
landListed.setTotalConsArea(data.get(6));
landListed.setPlotRatio(data.get(7));
landListed.setBuildingDensity(data.get(8));
landListed.setGreenSpaceRatio(data.get(9));
landListed.setHeighPermitted(data.get(10));
landListed.setRemiseYears(data.get(11));
landListed.setTransferPrice(data.get(12));
landListed.setStartingFloorPrice(data.get(13));
landListed.setBidMargin(data.get(14));
landListed.setBizRemark(data.get(15));
landListed.setAnnoDate(DateUtil.fromLocalDateTime(data.get(16),"yyyy-MM-dd"));
landListed.setAuctionDate(DateUtil.fromLocalDateTime(data.get(17),"yyyy-MM-dd"));
landListed.setLicensedArea(data.get(18));
landListed.setBizSpace(data.get(19));
landListed.setCommerceSpace(data.get(20));
landListed.setRemark(data.get(21));
landListed.setAllocationCapacity(data.get(22));
landListed.setAllocationNotCapacity(data.get(23));
landListed.setGeologicHazard(data.get(24));
landListed.setCivilAirDefence(data.get(25));
landListed.setSpecialPlan(data.get(26));
landListed.setAssemblyBuilding(data.get(27));
landListed.setGreenBuilding(data.get(28));
landListed.setOtherConditions(data.get(29));
landListed.setPercentFinishedHousing(data.get(30));
landListed.setBiddingConditions(data.get(31));
landListed.setHookForm(data.get(32));
landListed.setFirstGovernance(data.get(33));
landListed.setLandEnterprises(data.get(33));
landListed.setPaymentRhythm(data.get(34));
landListed.setBargainor(data.get(35));
landListed.setCity(data.get(36));
landListed.setCanton(data.get(37));
landListed.setSpecialZone(data.get(38));
landListed.setLoopWire(data.get(39));
landListed.setBigGroup(data.get(40));
landListed.setSmallGroup(data.get(41));
landListed.setOvePosition(data.get(42));
landListed.setLonLatBd(data.get(43));
landListed.setAnnoId(data.get(44));
landListed.setLandPosition(data.get(45));
landListed.setTransferMode(data.get(46));
landListed.setAssignee(data.get(47));
landListed.setLandEnterpriseShort(data.get(48));
landListed.setDealPrice(data.get(49));
landListed.setPremiumRate(data.get(50));
landListed.setCommercialSelfRatio(data.get(51));
landListed.setHomeSelfRatio(data.get(52));
landListed.setPercentUnpaid(data.get(53));
landListed.setTalenApartmentArea(data.get(54));
landListed.setParticipatingEnterprises(data.get(55));
landListed.setProjectStatus(data.get(56));
landListed.setBuildingName(data.get(57));
landListed.setProjectCompany(data.get(58));
landListed.setConfirmationTime(DateUtil.fromLocalDateTime(data.get(59),"yyyy-MM-dd"));
landListed.setTradingEnterprises(data.get(60));
landListed.setPartner(data.get(61));
landListed.setConductEnterprise(data.get(62));
landListed.setFirstOpenTime(DateUtil.fromLocalDateTime(data.get(63),"yyyy-MM-dd"));
return landListed;
if(StrUtil.isNotEmpty(data.get(0)) && StrUtil.isNotEmpty(data.get(1))){
landListed.setAnnoId(data.get(0));
landListed.setLandCode(data.get(1));
landListed.setLandPosition(data.get(2));
landListed.setLandUsage(data.get(3));
landListed.setLandTransferSquare(data.get(4));
landListed.setLandTransferMu(data.get(5));
landListed.setTotalConsArea(data.get(6));
landListed.setPlotRatio(data.get(7));
landListed.setBuildingDensity(data.get(8));
landListed.setGreenSpaceRatio(data.get(9));
landListed.setHeighPermitted(data.get(10));
landListed.setRemiseYears(data.get(11));
landListed.setTransferPrice(data.get(12));
landListed.setStartingFloorPrice(data.get(13));
landListed.setBidMargin(data.get(14));
landListed.setBizRemark(data.get(15));
if(StrUtil.isNotEmpty(data.get(16))){
landListed.setAnnoDate(DateUtil.fromLocalDateTime(data.get(16),"yyyy-MM-dd"));
}
if(StrUtil.isNotEmpty(data.get(17))){
landListed.setAuctionDate( DateUtil.fromLocalDateTime(data.get(17),"yyyy-MM-dd"));
}
landListed.setLicensedArea(data.get(18));
landListed.setBizSpace(data.get(19));
landListed.setCommerceSpace(data.get(20));
landListed.setRemark(data.get(21));
landListed.setAllocationCapacity(data.get(22));
landListed.setAllocationNotCapacity(data.get(23));
landListed.setGeologicHazard(data.get(24));
landListed.setCivilAirDefence(data.get(25));
landListed.setSpecialPlan(data.get(26));
landListed.setAssemblyBuilding(data.get(27));
landListed.setGreenBuilding(data.get(28));
landListed.setOtherConditions(data.get(29));
landListed.setPercentFinishedHousing(data.get(30));
landListed.setBiddingConditions(data.get(31));
landListed.setHookForm(data.get(32));
landListed.setFirstGovernance(data.get(33));
landListed.setLandEnterprises(data.get(33));
landListed.setPaymentRhythm(data.get(34));
landListed.setBargainor(data.get(35));
landListed.setCity(data.get(36));
landListed.setCanton(data.get(37));
landListed.setSpecialZone(data.get(38));
landListed.setLoopWire(data.get(39));
landListed.setBigGroup(data.get(40));
landListed.setSmallGroup(data.get(41));
landListed.setOvePosition(data.get(42));
landListed.setLonLatBd(data.get(43));
landListed.setAnnoId(data.get(44));
landListed.setLandPosition(data.get(45));
landListed.setTransferMode(data.get(46));
landListed.setAssignee(data.get(47));
landListed.setLandEnterpriseShort(data.get(48));
landListed.setDealPrice(data.get(49));
landListed.setPremiumRate(data.get(50));
landListed.setCommercialSelfRatio(data.get(51));
landListed.setHomeSelfRatio(data.get(52));
landListed.setPercentUnpaid(data.get(53));
landListed.setTalenApartmentArea(data.get(54));
landListed.setParticipatingEnterprises(data.get(55));
landListed.setProjectStatus(data.get(56));
landListed.setBuildingName(data.get(57));
landListed.setProjectCompany(data.get(58));
if(StrUtil.isNotEmpty(data.get(59))){
landListed.setConfirmationTime(DateUtil.fromLocalDateTime(data.get(59),"yyyy-MM-dd"));
}
landListed.setTradingEnterprises(data.get(60));
landListed.setPartner(data.get(61));
landListed.setConductEnterprise(data.get(62));
if(StrUtil.isNotEmpty(data.get(63))){
landListed.setFirstOpenTime(DateUtil.fromLocalDateTime(data.get(63),"yyyy-MM-dd"));
}
return landListed;
}
return null;
}
private List<String> entityToList(LandListed data) {

6
air/src/main/java/com/air/utils/DateUtil.java

@ -1,6 +1,7 @@
package com.air.utils;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
@ -56,7 +57,8 @@ public class DateUtil {
**/
public static LocalDateTime fromLocalDateTime(String dateString,String pattern) {
DateTimeFormatter fmt = DateTimeFormatter.ofPattern(pattern);
return LocalDateTime.parse(dateString, fmt);
LocalDate ld = LocalDate.parse(dateString, fmt);
return LocalDateTime.of(ld, LocalDateTime.now().toLocalTime());
}
/**
@ -68,7 +70,7 @@ public class DateUtil {
**/
public static String fromString(LocalDateTime dateString,String pattern) {
if(null == dateString){
return new String();
return "";
}
DateTimeFormatter fmt = DateTimeFormatter.ofPattern(pattern);
return fmt.format(dateString);

1
air/src/main/java/com/air/utils/ExcelUtil.java

@ -25,7 +25,6 @@ public class ExcelUtil {
XSSFWorkbook wb = new XSSFWorkbook(inputStream);
XSSFSheet sheet = wb.getSheetAt(0);
//获取表头
XSSFRow row = sheet.getRow(1);
for (int i = 0; i < dataList.size(); i++) {
XSSFRow sheetRow = sheet.getRow(i + 2);
List<String> list = dataList.get(i);

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

Binary file not shown.
Loading…
Cancel
Save