Browse Source

1.1.0 修改地块显示bug

feature/v1.1.0
peihao 4 years ago
parent
commit
2eeaf634c5
  1. 4
      air/src/main/java/com/air/applets/dto/BlocksPreSaleTotalDto.java
  2. 29
      air/src/main/java/com/air/common/entity/ExcelConfig.java
  3. 2
      air/src/main/java/com/air/housing/mapper/BlocksMapper.java
  4. 8
      air/src/main/java/com/air/housing/service/impl/BlocksServiceImpl.java
  5. 73
      air/src/main/java/com/air/utils/ExcelUtil.java
  6. 2
      air/src/main/resources/mapper/BlocksMapper.xml

4
air/src/main/java/com/air/applets/dto/BlocksPreSaleTotalDto.java

@ -25,10 +25,10 @@ public class BlocksPreSaleTotalDto {
private double destroyTotalRate;
@ApiModelProperty(value = "预售住宅均价")
private double preSaleHousePrice;
private int preSaleHousePrice;
@ApiModelProperty(value = "预售商业均价")
private double preSaleBusinessPrice;
private int preSaleBusinessPrice;
@ApiModelProperty(value = "预售明细")
private String preSaleLicenseNo;

29
air/src/main/java/com/air/common/entity/ExcelConfig.java

@ -0,0 +1,29 @@
package com.air.common.entity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* excel配置实体
*
* @author peihao
* @date 2021-09-08
**/
@Api(value = "excel配置实体")
@Data
public class ExcelConfig {
@ApiModelProperty(value="列名")
private String titleName;
@ApiModelProperty(value="实体中对应字段名字")
private String fieldName;
@ApiModelProperty(value="值类型")
private String valueType;
@ApiModelProperty(value="枚举类型")
private String enumKey;
@ApiModelProperty(value="是否必传")
private boolean required;
@ApiModelProperty(value="当前的列索引")
private Integer column;
}

2
air/src/main/java/com/air/housing/mapper/BlocksMapper.java

@ -35,7 +35,7 @@ public interface BlocksMapper extends BaseMapper<Blocks> {
@SqlParser(filter = true)
BlocksPreSaleTotalDto getSaleInfo(@Param("landListedId") String landListedId);
BigDecimal getHouseAvgPrice(@Param("propertyType") String propertyType);
BigDecimal getHouseAvgPrice(@Param("propertyType") String propertyType,@Param("landListedId") String landListedId);
@SqlParser(filter = true)
List<BlocksPreSaleTotalDto> getHouseSaleInfo(Long housingEstatesId);

8
air/src/main/java/com/air/housing/service/impl/BlocksServiceImpl.java

@ -48,11 +48,11 @@ public class BlocksServiceImpl extends ServiceImpl<BlocksMapper, Blocks> impleme
}
// 住宅均价
BigDecimal preSaleHousePrice = baseMapper.getHouseAvgPrice("住宅");
BigDecimal preSaleHousePrice = baseMapper.getHouseAvgPrice("住宅",landListId);
//商业均价
BigDecimal preSaleBusinessPrice = baseMapper.getHouseAvgPrice("商业");
saleInfo.setPreSaleHousePrice(preSaleHousePrice.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
saleInfo.setPreSaleBusinessPrice(preSaleBusinessPrice.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
BigDecimal preSaleBusinessPrice = baseMapper.getHouseAvgPrice("商业",landListId);
saleInfo.setPreSaleHousePrice(preSaleHousePrice.setScale(0, BigDecimal.ROUND_HALF_UP).intValue());
saleInfo.setPreSaleBusinessPrice(preSaleBusinessPrice.setScale(0, BigDecimal.ROUND_HALF_UP).intValue());
return saleInfo;
}

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

@ -1,5 +1,7 @@
package com.air.utils;
import com.air.common.entity.ExcelConfig;
import com.cinderella.framework.common.core.exception.BusinessException;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
@ -9,8 +11,7 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
/**
* excel表格工具类
@ -94,4 +95,72 @@ public class ExcelUtil {
return result;
}
/*public static <T> List<T> importExcel(InputStream fileInputStream,int startSheet,int startRow,int startColumn,int titleRow,int titleColumn,String) throws IOException{
//读取文件的指定sheet
XSSFWorkbook workbook = new XSSFWorkbook(fileInputStream);
XSSFSheet sheet = workbook.getSheetAt(startSheet);
//读取表头,设置对应列索引
List<ExcelConfig> excelConfigList = new ArrayList<>();
XSSFRow sheetRow = sheet.getRow(titleRow);
for (int i = titleColumn;i<sheetRow.getPhysicalNumberOfCells();i++){
String cellStrValue = getCellStrValue(sheetRow.getCell(i));
Optional<ExcelConfig> excelConfig = excelConfigList.stream().filter(item -> item.getTitleName().equals(cellStrValue)).findAny();
if (excelConfig.isPresent()){
excelConfig.get().setColumn(i);
}
}
//判断是否有为空的数据
Optional<ExcelConfig> any = excelConfigList.stream().filter(e -> e.getColumn() == null).findAny();
if (any.isPresent()){
throw new BusinessException(any.get().getTitleName()+"列不能为空");
}
//读取数据
List<Map<String,Object>> mapList = new ArrayList<>();
for (int i = titleRow+1;i<sheet.getPhysicalNumberOfRows();i++){
Map<String,Object> map = new HashMap<>();
XSSFRow row = sheet.getRow(i);
for(int j = titleColumn;j<row.getPhysicalNumberOfCells();j++){
Optional<ExcelConfig> excelConfig = excelConfigList.stream().filter(e -> e.getColumn() == j).findAny();
map.put(excelConfig.get().getFieldName(),);
}
}
}
public static Object getCellString(XSSFCell cell,String valueType){
String cellStrValue = getCellStrValue(cell);
switch (valueType){
case "string":
break;
case "stringInt":
break;
case "int":
break;
case "date":
break;
case "enum":
break;
default:
return null;
}
}
public static String getCellStrValue(XSSFCell cell){
String value;
try {
value = cell.getRawValue();
} catch (Exception e) {
value = cell.toString();
}
return valueFormat(value);
}
private static String valueFormat(String value) {
value = StringUtils.isNotEmpty(value) ? value.trim() : value;
value = StringUtils.equals("-", value) ? "" : value;
return value;
}*/
}

2
air/src/main/resources/mapper/BlocksMapper.xml

@ -46,7 +46,7 @@
JOIN houses h ON h.block_id = b.block_id
join `format` f on f.format_id = b.format_id
WHERE
ab.main_land = 1 and f.property_type = #{propertyType}
ab.land_listed_id = #{landListedId} and ab.main_land = 1 and f.property_type = #{propertyType}
</select>
<select id="getHouseSaleInfo" resultType="com.air.applets.dto.BlocksPreSaleTotalDto">
SELECT

Loading…
Cancel
Save