|
@ -19,6 +19,8 @@ package com.epmet.controller; |
|
|
|
|
|
|
|
|
import cn.afterturn.easypoi.excel.entity.TemplateExportParams; |
|
|
import cn.afterturn.easypoi.excel.entity.TemplateExportParams; |
|
|
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; |
|
|
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; |
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.epmet.commons.tools.annotation.LoginUser; |
|
|
import com.epmet.commons.tools.annotation.LoginUser; |
|
|
import com.epmet.commons.tools.exception.ErrorCode; |
|
|
import com.epmet.commons.tools.exception.ErrorCode; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
@ -28,12 +30,15 @@ import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
import com.epmet.commons.tools.validator.group.AddGroup; |
|
|
import com.epmet.commons.tools.validator.group.AddGroup; |
|
|
import com.epmet.commons.tools.validator.group.UpdateGroup; |
|
|
import com.epmet.commons.tools.validator.group.UpdateGroup; |
|
|
import com.epmet.constant.NeighborhoodConstant; |
|
|
import com.epmet.constant.NeighborhoodConstant; |
|
|
|
|
|
import com.epmet.dao.IcBuildingUnitDao; |
|
|
import com.epmet.dto.BuildingTreeLevelDTO; |
|
|
import com.epmet.dto.BuildingTreeLevelDTO; |
|
|
import com.epmet.dto.IcNeighborHoodDTO; |
|
|
import com.epmet.dto.IcNeighborHoodDTO; |
|
|
import com.epmet.dto.form.IcBulidingFormDTO; |
|
|
import com.epmet.dto.form.IcBulidingFormDTO; |
|
|
|
|
|
import com.epmet.dto.form.IcBulidingUnitFormDTO; |
|
|
import com.epmet.dto.form.IcNeighborHoodFormDTO; |
|
|
import com.epmet.dto.form.IcNeighborHoodFormDTO; |
|
|
import com.epmet.dto.form.ListIcNeighborHoodFormDTO; |
|
|
import com.epmet.dto.form.ListIcNeighborHoodFormDTO; |
|
|
import com.epmet.dto.result.IcNeighborHoodResultDTO; |
|
|
import com.epmet.dto.result.IcNeighborHoodResultDTO; |
|
|
|
|
|
import com.epmet.entity.IcBuildingUnitEntity; |
|
|
import com.epmet.excel.IcBuildingExcel; |
|
|
import com.epmet.excel.IcBuildingExcel; |
|
|
import com.epmet.excel.IcHouseExcel; |
|
|
import com.epmet.excel.IcHouseExcel; |
|
|
import com.epmet.excel.IcNeighborHoodExcel; |
|
|
import com.epmet.excel.IcNeighborHoodExcel; |
|
@ -77,13 +82,15 @@ public class BuildingController { |
|
|
private IcBuildingService icBuildingService; |
|
|
private IcBuildingService icBuildingService; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private BuildingService buildingService; |
|
|
private BuildingService buildingService; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private IcBuildingUnitDao icBuildingUnitDao; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("buildinglist") |
|
|
@PostMapping("buildinglist") |
|
|
public Result houseList(@RequestBody ListIcNeighborHoodFormDTO formDTO){ |
|
|
public Result houseList(@RequestBody ListIcNeighborHoodFormDTO formDTO){ |
|
|
//效验数据
|
|
|
//效验数据
|
|
|
ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class); |
|
|
ValidatorUtils.validateEntity(formDTO); |
|
|
IcNeighborHoodResultDTO icNeighborHoodResultDTO = buildingService.listBuilding(formDTO); |
|
|
IcNeighborHoodResultDTO icNeighborHoodResultDTO = buildingService.listBuilding(formDTO); |
|
|
return new Result().ok(icNeighborHoodResultDTO); |
|
|
return new Result().ok(icNeighborHoodResultDTO); |
|
|
|
|
|
|
|
@ -126,13 +133,12 @@ public class BuildingController { |
|
|
} |
|
|
} |
|
|
/** |
|
|
/** |
|
|
* 导出模板 |
|
|
* 导出模板 |
|
|
* @param formDTO |
|
|
|
|
|
* @param response |
|
|
* @param response |
|
|
* @throws Exception |
|
|
* @throws Exception |
|
|
*/ |
|
|
*/ |
|
|
@PostMapping("exporttemplate") |
|
|
@PostMapping("exporttemplate") |
|
|
public void exportTemplate(@RequestBody ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception { |
|
|
public void exportTemplate( HttpServletResponse response) throws Exception { |
|
|
ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class); |
|
|
|
|
|
TemplateExportParams templatePath = new TemplateExportParams("excel/building_template.xlsx"); |
|
|
TemplateExportParams templatePath = new TemplateExportParams("excel/building_template.xlsx"); |
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
map.put("maplist",new ArrayList<IcBuildingExcel>()); |
|
|
map.put("maplist",new ArrayList<IcBuildingExcel>()); |
|
@ -147,7 +153,7 @@ public class BuildingController { |
|
|
*/ |
|
|
*/ |
|
|
@RequestMapping("exportbuildinginfo") |
|
|
@RequestMapping("exportbuildinginfo") |
|
|
public void exportbuildinginfo(@RequestBody ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception { |
|
|
public void exportbuildinginfo(@RequestBody ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception { |
|
|
ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class); |
|
|
ValidatorUtils.validateEntity(formDTO); |
|
|
buildingService.exportBuildinginfo(formDTO,response); |
|
|
buildingService.exportBuildinginfo(formDTO,response); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
@ -161,7 +167,7 @@ public class BuildingController { |
|
|
@GetMapping("export") |
|
|
@GetMapping("export") |
|
|
public void export(HttpServletResponse response) throws Exception { |
|
|
public void export(HttpServletResponse response) throws Exception { |
|
|
ListIcNeighborHoodFormDTO formDTO = new ListIcNeighborHoodFormDTO(); |
|
|
ListIcNeighborHoodFormDTO formDTO = new ListIcNeighborHoodFormDTO(); |
|
|
ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class); |
|
|
ValidatorUtils.validateEntity(formDTO); |
|
|
buildingService.exportBuildinginfo(formDTO,response); |
|
|
buildingService.exportBuildinginfo(formDTO,response); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
@ -186,7 +192,7 @@ public class BuildingController { |
|
|
for ( IcBuildingExcel entity : failList) { |
|
|
for ( IcBuildingExcel entity : failList) { |
|
|
log.error("第{}行,{}",entity.getRowNum(),entity.getErrorMsg());//打印失败的行 和失败的信息
|
|
|
log.error("第{}行,{}",entity.getRowNum(),entity.getErrorMsg());//打印失败的行 和失败的信息
|
|
|
} |
|
|
} |
|
|
return new Result().error(8000,failList.get(0).getErrorMsg()); |
|
|
return new Result().error(8001,failList.get(0).getErrorMsg()); |
|
|
} |
|
|
} |
|
|
List<IcBuildingExcel> result =importResult.getList(); |
|
|
List<IcBuildingExcel> result =importResult.getList(); |
|
|
|
|
|
|
|
@ -194,5 +200,25 @@ public class BuildingController { |
|
|
return new Result().ok("导入成功"); |
|
|
return new Result().ok("导入成功"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 查看楼宇单元列表 |
|
|
|
|
|
* @param tokenDTO |
|
|
|
|
|
* @return |
|
|
|
|
|
* @throws IOException |
|
|
|
|
|
*/ |
|
|
|
|
|
@PostMapping("buildingunitlist") |
|
|
|
|
|
public Result buildingunitlist(@LoginUser TokenDto tokenDTO,@RequestBody IcBulidingUnitFormDTO icBulidingUnitFormDTO ){ |
|
|
|
|
|
ValidatorUtils.validateEntity(icBulidingUnitFormDTO); |
|
|
|
|
|
List<IcBuildingUnitEntity> icBuildingUnitEntityList = icBuildingUnitDao.selectList(new QueryWrapper<IcBuildingUnitEntity>().lambda().eq(IcBuildingUnitEntity::getBuildingId, icBulidingUnitFormDTO.getBuildingId())); |
|
|
|
|
|
List<JSONObject> result = new ArrayList<>(); |
|
|
|
|
|
icBuildingUnitEntityList.forEach(item->{ |
|
|
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
|
|
jsonObject.put("id",item.getId()); |
|
|
|
|
|
jsonObject.put("unitName",item.getUnitName()); |
|
|
|
|
|
jsonObject.put("unitNum",item.getUnitNum()); |
|
|
|
|
|
result.add(jsonObject); |
|
|
|
|
|
}); |
|
|
|
|
|
return new Result().ok(result); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |