|
@@ -18,7 +18,6 @@ import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
-@Component
|
|
|
|
public class MnpBuildingListener extends AnalysisEventListener<MnpBuildingExcel> {
|
|
public class MnpBuildingListener extends AnalysisEventListener<MnpBuildingExcel> {
|
|
|
|
|
|
private List<MnpBuilding> list = new ArrayList<>();
|
|
private List<MnpBuilding> list = new ArrayList<>();
|
|
@@ -31,17 +30,18 @@ public class MnpBuildingListener extends AnalysisEventListener<MnpBuildingExcel>
|
|
|
|
|
|
private JSONObject jsonObject;
|
|
private JSONObject jsonObject;
|
|
|
|
|
|
- @Autowired
|
|
|
|
private MnpBuildingService buildingService;
|
|
private MnpBuildingService buildingService;
|
|
- @Autowired
|
|
|
|
private ParkFloorDiscService floorDiscService;
|
|
private ParkFloorDiscService floorDiscService;
|
|
- @Autowired
|
|
|
|
private ParkInfoService parkInfoService;
|
|
private ParkInfoService parkInfoService;
|
|
- @Autowired
|
|
|
|
private SysDictService sysDictService;
|
|
private SysDictService sysDictService;
|
|
|
|
|
|
|
|
|
|
- public MnpBuildingListener(JSONObject jsonObject) {
|
|
|
|
|
|
+ public MnpBuildingListener(MnpBuildingService buildingService,ParkFloorDiscService floorDiscService,
|
|
|
|
+ ParkInfoService parkInfoService,SysDictService sysDictService, JSONObject jsonObject) {
|
|
|
|
+ this.buildingService = buildingService;
|
|
|
|
+ this.floorDiscService = floorDiscService;
|
|
|
|
+ this.parkInfoService = parkInfoService;
|
|
|
|
+ this.sysDictService = sysDictService;
|
|
this.jsonObject = jsonObject;
|
|
this.jsonObject = jsonObject;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -54,6 +54,9 @@ public class MnpBuildingListener extends AnalysisEventListener<MnpBuildingExcel>
|
|
@Override
|
|
@Override
|
|
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
|
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
|
|
|
|
|
|
|
+
|
|
|
|
+ // 入驻类型字典
|
|
|
|
+ List<Map<String, String>> buildStructure = sysDictService.selectDictList("BUILD_STRUCTURE");
|
|
if(CollectionUtils.isNotEmpty(excelList)){
|
|
if(CollectionUtils.isNotEmpty(excelList)){
|
|
MnpBuilding data;
|
|
MnpBuilding data;
|
|
MnpBuildingExcel excel = null;
|
|
MnpBuildingExcel excel = null;
|
|
@@ -89,12 +92,113 @@ public class MnpBuildingListener extends AnalysisEventListener<MnpBuildingExcel>
|
|
if (StringUtils.isEmpty(excel.getArea())) {
|
|
if (StringUtils.isEmpty(excel.getArea())) {
|
|
throw new RuntimeException("总面积为空");
|
|
throw new RuntimeException("总面积为空");
|
|
}
|
|
}
|
|
|
|
+ try {
|
|
|
|
+ data.setArea(Double.valueOf(excel.getArea()));
|
|
|
|
+ }catch (NumberFormatException e){
|
|
|
|
+ throw new RuntimeException("总面积格式有误");
|
|
|
|
+ }
|
|
// 住宅面积
|
|
// 住宅面积
|
|
if (StringUtils.isEmpty(excel.getResidentialArea())) {
|
|
if (StringUtils.isEmpty(excel.getResidentialArea())) {
|
|
throw new RuntimeException("住宅面积为空");
|
|
throw new RuntimeException("住宅面积为空");
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ try {
|
|
|
|
+ data.setResidentialArea(Double.valueOf(excel.getResidentialArea()));
|
|
|
|
+ }catch (NumberFormatException e){
|
|
|
|
+ throw new RuntimeException("住宅面积格式有误");
|
|
|
|
+ }
|
|
|
|
+ // 非住宅面积
|
|
|
|
+ if (StringUtils.isEmpty(excel.getUnResidentialArea())) {
|
|
|
|
+ throw new RuntimeException("非住宅面积为空");
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ data.setUnResidentialArea(Double.valueOf(excel.getUnResidentialArea()));
|
|
|
|
+ }catch (NumberFormatException e){
|
|
|
|
+ throw new RuntimeException("非住宅面积格式有误");
|
|
|
|
+ }
|
|
|
|
+ // 占地面积
|
|
|
|
+ if (StringUtils.isEmpty(excel.getCoverAnArea())) {
|
|
|
|
+ throw new RuntimeException("占地面积为空");
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ data.setCoverAnArea(Double.valueOf(excel.getCoverAnArea()));
|
|
|
|
+ }catch (NumberFormatException e){
|
|
|
|
+ throw new RuntimeException("占地面积格式有误");
|
|
|
|
+ }
|
|
|
|
+ // 地下面积
|
|
|
|
+ if (StringUtils.isEmpty(excel.getUndergroundArea())) {
|
|
|
|
+ throw new RuntimeException("地下面积为空");
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ data.setUndergroundArea(Double.valueOf(excel.getUndergroundArea()));
|
|
|
|
+ }catch (NumberFormatException e){
|
|
|
|
+ throw new RuntimeException("地下面积格式有误");
|
|
|
|
+ }
|
|
|
|
+ // 房号
|
|
|
|
+ if (StringUtils.isNotEmpty(excel.getRoomNum())) {
|
|
|
|
+ data.setRoomNum(excel.getRoomNum());
|
|
|
|
+ }
|
|
|
|
+ // 房号
|
|
|
|
+ if (StringUtils.isNotEmpty(excel.getRoomNum())) {
|
|
|
|
+ throw new RuntimeException("房号为空");
|
|
|
|
+ }
|
|
|
|
+ data.setRoomNum(excel.getRoomNum());
|
|
|
|
+ // 套数
|
|
|
|
+ if (StringUtils.isNotEmpty(excel.getNumberInfo())) {
|
|
|
|
+ throw new RuntimeException("套数为空");
|
|
|
|
+ }
|
|
|
|
+ data.setNumberInfo(excel.getNumberInfo());
|
|
|
|
+ // 总层数
|
|
|
|
+ if (StringUtils.isNotEmpty(excel.getFloors())) {
|
|
|
|
+ throw new RuntimeException("总层数为空");
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ data.setFloors(Integer.valueOf(excel.getFloors()));
|
|
|
|
+ }catch (NumberFormatException e){
|
|
|
|
+ throw new RuntimeException("总层数格式有误");
|
|
|
|
+ }
|
|
|
|
+ // 地上层数
|
|
|
|
+ if (StringUtils.isNotEmpty(excel.getOvergroundFloors())) {
|
|
|
|
+ throw new RuntimeException("地上层数为空");
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ data.setOvergroundFloors(Integer.valueOf(excel.getOvergroundFloors()));
|
|
|
|
+ }catch (NumberFormatException e){
|
|
|
|
+ throw new RuntimeException("地上层数格式有误");
|
|
|
|
+ }
|
|
|
|
+ // 地下层数
|
|
|
|
+ if (StringUtils.isNotEmpty(excel.getUndergroundFloors())) {
|
|
|
|
+ throw new RuntimeException("地下层数为空");
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ data.setUndergroundFloors(Integer.valueOf(excel.getUndergroundFloors()));
|
|
|
|
+ }catch (NumberFormatException e){
|
|
|
|
+ throw new RuntimeException("地下层数格式有误");
|
|
|
|
+ }
|
|
|
|
+ // 结构
|
|
|
|
+ if (StringUtils.isNotEmpty(excel.getStructure())) {
|
|
|
|
+ throw new RuntimeException("结构为空");
|
|
|
|
+ }
|
|
|
|
+ for (Map<String, String> stringStringMap : buildStructure) {
|
|
|
|
+ if (stringStringMap.get("label").equals(excel.getStructure())) {
|
|
|
|
+ data.setStructure(stringStringMap.get("value"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 没匹配上的情况
|
|
|
|
+ if(StringUtils.isEmpty(data.getStructure())){
|
|
|
|
+ throw new RuntimeException("第" + (i + 3) + "行,入驻类型格式有误");
|
|
|
|
+ }
|
|
|
|
+ // 行政区划
|
|
|
|
+ if (StringUtils.isNotEmpty(excel.getRegionalismCode())) {
|
|
|
|
+ throw new RuntimeException("行政区划为空");
|
|
|
|
+ }
|
|
|
|
+ data.setRegionalismCode(excel.getRegionalismCode());
|
|
|
|
+ // 地号
|
|
|
|
+ if (StringUtils.isNotEmpty(excel.getLandCode())) {
|
|
|
|
+ throw new RuntimeException("地号为空");
|
|
|
|
+ }
|
|
|
|
+ data.setLandCode(excel.getLandCode());
|
|
|
|
+ data.setRemark(excel.getRemark());
|
|
|
|
+ data.setPriceRemark(excel.getPriceRemark());
|
|
count = list.size();
|
|
count = list.size();
|
|
jsonObject.put("successCount", count);
|
|
jsonObject.put("successCount", count);
|
|
jsonObject.put("errorList", badList);
|
|
jsonObject.put("errorList", badList);
|