32 changed files with 2806 additions and 66 deletions
@ -0,0 +1,52 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.dto; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
|
|||
/** |
|||
* 楼栋信息 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-10-25 |
|||
*/ |
|||
@Data |
|||
public class BuildingTreeLevelDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
|
|||
private String id; |
|||
|
|||
private String pId; |
|||
|
|||
private String label; |
|||
|
|||
|
|||
private String level; |
|||
|
|||
private List<BuildingTreeLevelDTO> children; |
|||
|
|||
|
|||
|
|||
} |
@ -0,0 +1,119 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.dto.form; |
|||
|
|||
import com.epmet.commons.tools.validator.group.AddGroup; |
|||
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; |
|||
import com.epmet.commons.tools.validator.group.UpdateGroup; |
|||
import lombok.Data; |
|||
import org.hibernate.validator.constraints.Length; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
|
|||
@Data |
|||
public class IcBulidingFormDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
public interface DeleteGroup extends CustomerClientShowGroup { |
|||
} |
|||
|
|||
@NotBlank(message = "楼栋ID不能为空", groups = { UpdateGroup.class,DeleteGroup.class}) |
|||
private String buildingId; |
|||
|
|||
/** |
|||
* 组织id |
|||
*/ |
|||
@NotBlank(message = "组织id不能为空", groups = {AddGroup.class}) |
|||
private String agencyId; |
|||
|
|||
|
|||
/** |
|||
* 网格id |
|||
*/ |
|||
|
|||
private String gridId; |
|||
|
|||
|
|||
/** |
|||
* 小区id |
|||
*/ |
|||
@NotBlank(message = "小区id不能为空", groups = {AddGroup.class, UpdateGroup.class}) |
|||
private String neighborHoodId; |
|||
|
|||
/** |
|||
* 楼栋名称 |
|||
*/ |
|||
@NotBlank(message = "楼栋名称不能为空", groups = {AddGroup.class, UpdateGroup.class}) |
|||
@Length(max=10,message = "楼栋名称不能超过10个字", groups = {AddGroup.class, UpdateGroup.class}) |
|||
private String buildingName; |
|||
|
|||
/** |
|||
* 客户id |
|||
*/ |
|||
/* @NotBlank(message = "客户id不能为空", groups = {AddGroup.class, UpdateGroup.class}) |
|||
private String customerId;*/ |
|||
|
|||
/** |
|||
* 排序 |
|||
*/ |
|||
@NotBlank(message = "排序不能为空", groups = { UpdateGroup.class}) |
|||
private Integer sort = 0; |
|||
|
|||
/** |
|||
* 总单元数 |
|||
*/ |
|||
@NotBlank(message = "总单元数不能为空", groups = {AddGroup.class, UpdateGroup.class}) |
|||
private Integer totalUnitNum=1; |
|||
|
|||
/** |
|||
* 总楼层总数 |
|||
*/ |
|||
@NotBlank(message = "总楼层总数不能为空", groups = {AddGroup.class, UpdateGroup.class}) |
|||
private Integer totalFloorNum; |
|||
|
|||
/** |
|||
* 总户数 |
|||
*/ |
|||
@NotBlank(message = "总户数不能为空", groups = {AddGroup.class, UpdateGroup.class}) |
|||
private Integer totalHouseNum; |
|||
/** |
|||
* 坐标位置 |
|||
*/ |
|||
@NotBlank(message = "坐标位置不能为空", groups = { UpdateGroup.class}) |
|||
private String location; |
|||
|
|||
|
|||
/** |
|||
* 中心点位:经度 |
|||
*/ |
|||
@NotBlank(message = "经度不能为空", groups = {UpdateGroup.class}) |
|||
private String longitude; |
|||
|
|||
/** |
|||
* 中心点位:纬度 |
|||
*/ |
|||
@NotBlank(message = "维度不能为空", groups = {UpdateGroup.class}) |
|||
private String latitude; |
|||
|
|||
|
|||
|
|||
|
|||
} |
@ -0,0 +1,101 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.dto.form; |
|||
|
|||
import com.epmet.commons.tools.validator.group.AddGroup; |
|||
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; |
|||
import com.epmet.commons.tools.validator.group.UpdateGroup; |
|||
import lombok.Data; |
|||
import org.hibernate.validator.constraints.Length; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
|
|||
@Data |
|||
public class IcHouseFormDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
public interface DeleteGroup extends CustomerClientShowGroup { |
|||
} |
|||
|
|||
@NotBlank(message = "房屋ID不能为空", groups = { UpdateGroup.class,DeleteGroup.class}) |
|||
private String houseId; |
|||
|
|||
|
|||
/** |
|||
* 小区id |
|||
*/ |
|||
@NotBlank(message = "小区id不能为空", groups = {AddGroup.class, UpdateGroup.class}) |
|||
private String neighborHoodId; |
|||
|
|||
@NotBlank(message = "所属楼栋ID不能为空", groups = { UpdateGroup.class}) |
|||
private String belongBuildingId; |
|||
|
|||
/** |
|||
* 所属单元id |
|||
*/ |
|||
@NotBlank(message = "所属单元id不能为空", groups = {AddGroup.class, UpdateGroup.class}) |
|||
private String buildingUnitId; |
|||
|
|||
|
|||
|
|||
/** |
|||
* 门牌号 |
|||
*/ |
|||
@NotBlank(message = "门牌号不能为空", groups = {AddGroup.class, UpdateGroup.class}) |
|||
private String doorName; |
|||
|
|||
/** |
|||
* 房屋类型,这里存储字典value就可以 |
|||
*/ |
|||
@NotBlank(message = "房屋类型不能为空", groups = {AddGroup.class, UpdateGroup.class}) |
|||
private String houseType; |
|||
|
|||
/** |
|||
* 存储字典value |
|||
*/ |
|||
@NotBlank(message = "房屋用途不能为空", groups = {AddGroup.class, UpdateGroup.class}) |
|||
private String purpose; |
|||
|
|||
/** |
|||
* 1出租;0未出租 |
|||
*/ |
|||
@NotBlank(message = "是否出租不能为空", groups = {AddGroup.class, UpdateGroup.class}) |
|||
private Boolean rentFlag; |
|||
|
|||
/** |
|||
* 房主姓名 |
|||
*/ |
|||
@NotBlank(message = "房主姓名不能为空", groups = {AddGroup.class, UpdateGroup.class}) |
|||
private String ownerName; |
|||
|
|||
/** |
|||
* 房主电话 |
|||
*/ |
|||
@NotBlank(message = "房主电话不能为空", groups = {AddGroup.class, UpdateGroup.class}) |
|||
private String ownerPhone; |
|||
|
|||
/** |
|||
* 房主身份证号 |
|||
*/ |
|||
@NotBlank(message = "房主身份证号不能为空", groups = {AddGroup.class, UpdateGroup.class}) |
|||
private String ownerIdCard; |
|||
|
|||
} |
@ -0,0 +1,115 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.controller; |
|||
|
|||
import com.epmet.commons.tools.annotation.LoginUser; |
|||
import com.epmet.commons.tools.security.dto.TokenDto; |
|||
import com.epmet.commons.tools.utils.ExcelUtils; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.commons.tools.validator.ValidatorUtils; |
|||
import com.epmet.commons.tools.validator.group.AddGroup; |
|||
import com.epmet.commons.tools.validator.group.UpdateGroup; |
|||
import com.epmet.dto.BuildingTreeLevelDTO; |
|||
import com.epmet.dto.IcNeighborHoodDTO; |
|||
import com.epmet.dto.form.IcBulidingFormDTO; |
|||
import com.epmet.dto.form.IcNeighborHoodFormDTO; |
|||
import com.epmet.dto.form.ListIcNeighborHoodFormDTO; |
|||
import com.epmet.dto.result.IcNeighborHoodResultDTO; |
|||
import com.epmet.excel.IcNeighborHoodExcel; |
|||
import com.epmet.service.BuildingService; |
|||
import com.epmet.service.IcBuildingService; |
|||
import com.epmet.service.IcNeighborHoodService; |
|||
import com.epmet.service.NeighborHoodService; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
|
|||
/** |
|||
* 楼栋信息 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-10-25 |
|||
*/ |
|||
@Slf4j |
|||
@RestController |
|||
@RequestMapping("building") |
|||
public class BuildingController { |
|||
|
|||
|
|||
@Autowired |
|||
private NeighborHoodService neighborHoodService; |
|||
|
|||
@Autowired |
|||
private IcBuildingService icBuildingService; |
|||
@Autowired |
|||
private BuildingService buildingService; |
|||
|
|||
|
|||
|
|||
@PostMapping("buildinglist") |
|||
public Result houseList(@RequestBody ListIcNeighborHoodFormDTO formDTO){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class); |
|||
IcNeighborHoodResultDTO icNeighborHoodResultDTO = neighborHoodService.listNeighborhood(formDTO); |
|||
return new Result().ok(icNeighborHoodResultDTO); |
|||
|
|||
} |
|||
|
|||
@PostMapping("buildingadd") |
|||
public Result buildingAdd(@LoginUser TokenDto tokenDTO, @RequestBody IcBulidingFormDTO formDTO){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(formDTO, AddGroup.class); |
|||
String customerId = tokenDTO.getCustomerId(); |
|||
// String customerId = "123123";
|
|||
|
|||
buildingService.AddBuilding(customerId,formDTO); |
|||
return new Result().ok("保存成功"); |
|||
} |
|||
|
|||
@PostMapping("buildingupdate") |
|||
public Result buildingUpdate(@LoginUser TokenDto tokenDTO, @RequestBody IcBulidingFormDTO formDTO){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(formDTO, UpdateGroup.class); |
|||
String customerId = tokenDTO.getCustomerId(); |
|||
// String customerId = "123123";
|
|||
buildingService.UpdateBuilding(customerId,formDTO); |
|||
return new Result().ok("修改成功"); |
|||
} |
|||
|
|||
@PostMapping("buildingdel") |
|||
public Result buildingDel(@LoginUser TokenDto tokenDTO, @RequestBody IcBulidingFormDTO formDTO){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(formDTO, IcBulidingFormDTO.DeleteGroup.class); |
|||
String buildingId = formDTO.getBuildingId(); |
|||
buildingService.DelBuilding(buildingId); |
|||
return new Result(); |
|||
} |
|||
|
|||
@PostMapping("treelist") |
|||
public Result treeList(@LoginUser TokenDto tokenDTO){ |
|||
List<BuildingTreeLevelDTO> buildingTreeLevelDTOS =buildingService.treeList(tokenDTO.getUserId()); |
|||
return new Result().ok(buildingTreeLevelDTOS); |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,97 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.controller; |
|||
|
|||
import com.epmet.commons.tools.annotation.LoginUser; |
|||
import com.epmet.commons.tools.security.dto.TokenDto; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.commons.tools.validator.ValidatorUtils; |
|||
import com.epmet.commons.tools.validator.group.AddGroup; |
|||
import com.epmet.commons.tools.validator.group.UpdateGroup; |
|||
import com.epmet.dto.form.IcHouseFormDTO; |
|||
import com.epmet.dto.form.IcNeighborHoodFormDTO; |
|||
import com.epmet.dto.form.ListIcNeighborHoodFormDTO; |
|||
import com.epmet.dto.result.IcNeighborHoodResultDTO; |
|||
import com.epmet.service.HouseService; |
|||
import com.epmet.service.NeighborHoodService; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
|
|||
/** |
|||
* 房屋表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-10-25 |
|||
*/ |
|||
@Slf4j |
|||
@RestController |
|||
@RequestMapping("house") |
|||
public class HouseController { |
|||
|
|||
|
|||
@Autowired |
|||
private NeighborHoodService neighborHoodService; |
|||
|
|||
@Autowired |
|||
private HouseService houseService; |
|||
|
|||
|
|||
@PostMapping("houselist") |
|||
public Result houseList(@RequestBody ListIcNeighborHoodFormDTO formDTO){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class); |
|||
IcNeighborHoodResultDTO icNeighborHoodResultDTO = neighborHoodService.listNeighborhood(formDTO); |
|||
return new Result().ok(icNeighborHoodResultDTO); |
|||
|
|||
} |
|||
|
|||
@PostMapping("houseadd") |
|||
public Result houseAdd(@LoginUser TokenDto tokenDTO, @RequestBody IcHouseFormDTO formDTO){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(formDTO, AddGroup.class); |
|||
String customerId = tokenDTO.getCustomerId(); |
|||
// String customerId = "123123";
|
|||
|
|||
houseService.addHouse(customerId,formDTO); |
|||
return new Result(); |
|||
} |
|||
|
|||
@PostMapping("houseupdate") |
|||
public Result houseUpdate(@LoginUser TokenDto tokenDTO, @RequestBody IcHouseFormDTO formDTO){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(formDTO, UpdateGroup.class); |
|||
String customerId = tokenDTO.getCustomerId(); |
|||
// String customerId = "123123";
|
|||
houseService.updateHouse(customerId,formDTO); |
|||
return new Result(); |
|||
} |
|||
|
|||
@PostMapping("housedel") |
|||
public Result houseDel(@LoginUser TokenDto tokenDTO, @RequestBody IcHouseFormDTO formDTO){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(formDTO, IcNeighborHoodFormDTO.DeleteGroup.class); |
|||
houseService.delHouse(formDTO.getHouseId()); |
|||
return new Result(); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,121 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.excel; |
|||
|
|||
import cn.afterturn.easypoi.excel.annotation.Excel; |
|||
import lombok.Data; |
|||
import org.hibernate.validator.constraints.Length; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 楼栋信息 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-10-27 |
|||
*/ |
|||
@Data |
|||
public class IcBuildingExcel { |
|||
|
|||
/*@Excel(name = "楼栋主键") |
|||
private String id; |
|||
|
|||
@Excel(name = "客户id") |
|||
private String customerId; |
|||
|
|||
@Excel(name = "小区id") |
|||
private String neighborHoodId; |
|||
|
|||
@Excel(name = "片区id,neighbor_hood_part.id,可为空。") |
|||
private String partId; |
|||
|
|||
@Excel(name = "楼栋名称") |
|||
private String buildingName; |
|||
|
|||
@Excel(name = "楼栋类型,这里存储字典编码就可以") |
|||
private String type; |
|||
|
|||
@Excel(name = "排序") |
|||
private Integer sort; |
|||
|
|||
@Excel(name = "总单元数") |
|||
private Integer totalUnitNum; |
|||
|
|||
@Excel(name = "总楼层总数") |
|||
private Integer totalFloorNum; |
|||
|
|||
@Excel(name = "总户数") |
|||
private Integer totalHouseNum; |
|||
|
|||
@Excel(name = "中心点位:经度") |
|||
private String longitude; |
|||
|
|||
@Excel(name = "中心点位:纬度") |
|||
private String latitude; |
|||
|
|||
@Excel(name = "坐标位置") |
|||
private String coordinatePosition; |
|||
|
|||
@Excel(name = "删除标识 0未删除、1已删除") |
|||
private String delFlag; |
|||
|
|||
@Excel(name = "乐观锁") |
|||
private Integer revision; |
|||
|
|||
@Excel(name = "创建人") |
|||
private String createdBy; |
|||
|
|||
@Excel(name = "创建时间") |
|||
private Date createdTime; |
|||
|
|||
@Excel(name = "更新人") |
|||
private String updatedBy; |
|||
|
|||
@Excel(name = "更新时间") |
|||
private Date updatedTime;*/ |
|||
|
|||
@Excel(name = "所属组织") |
|||
@NotBlank(message = "所属组织不能位空") |
|||
private String agencyName; |
|||
|
|||
@Excel(name = "所属网格") |
|||
@NotBlank(message = "所属网格不能位空") |
|||
private String gridName; |
|||
|
|||
@Excel(name = "小区名称") |
|||
@NotBlank(message = "小区名称不能位空") |
|||
@Length(max=50,message = "小区名称不能超过50个字") |
|||
private String neighborHoodName; |
|||
|
|||
@Excel(name = "楼栋名称") |
|||
@NotBlank(message = "楼栋名称不能位空") |
|||
private String buildingName; |
|||
|
|||
@Excel(name = "单元数") |
|||
@NotBlank(message = "单元数不能位空") |
|||
private Integer totalUnitNum; |
|||
|
|||
@Excel(name = "层数") |
|||
@NotBlank(message = "层数不能位空") |
|||
private Integer totalFloorNum; |
|||
|
|||
@Excel(name = "户数") |
|||
@NotBlank(message = "户数不能位空") |
|||
private Integer totalHouseNum; |
|||
} |
@ -0,0 +1,139 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.excel; |
|||
|
|||
import cn.afterturn.easypoi.excel.annotation.Excel; |
|||
import lombok.Data; |
|||
import org.hibernate.validator.constraints.Length; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 房屋信息 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-10-27 |
|||
*/ |
|||
@Data |
|||
public class IcHouseExcel { |
|||
|
|||
/*@Excel(name = "房屋主键") |
|||
private String id; |
|||
|
|||
@Excel(name = "客户id") |
|||
private String customerId; |
|||
|
|||
@Excel(name = "小区id") |
|||
private String neighborHoodId; |
|||
|
|||
@Excel(name = "片区id,neighbor_hood_part.id,可为空。") |
|||
private String partId; |
|||
|
|||
@Excel(name = "所属楼栋id") |
|||
private String buildingId; |
|||
|
|||
@Excel(name = "所属单元id") |
|||
private String buildingUnitId; |
|||
|
|||
@Excel(name = "房屋名字后台插入时生成") |
|||
private String houseName; |
|||
|
|||
@Excel(name = "门牌号") |
|||
private String doorName; |
|||
|
|||
@Excel(name = "房屋类型,这里存储字典value就可以") |
|||
private String houseType; |
|||
|
|||
@Excel(name = "存储字典value") |
|||
private String purpose; |
|||
|
|||
@Excel(name = "1出租;0未出租") |
|||
private Integer rentFlag; |
|||
|
|||
@Excel(name = "房主姓名") |
|||
private String ownerName; |
|||
|
|||
@Excel(name = "房主电话") |
|||
private String ownerPhone; |
|||
|
|||
@Excel(name = "房主身份证号") |
|||
private String ownerIdCard; |
|||
|
|||
@Excel(name = "删除标识 0未删除、1已删除") |
|||
private String delFlag; |
|||
|
|||
@Excel(name = "乐观锁") |
|||
private Integer revision; |
|||
|
|||
@Excel(name = "创建人") |
|||
private String createdBy; |
|||
|
|||
@Excel(name = "创建时间") |
|||
private Date createdTime; |
|||
|
|||
@Excel(name = "更新人") |
|||
private String updatedBy; |
|||
|
|||
@Excel(name = "更新时间") |
|||
private Date updatedTime;*/ |
|||
|
|||
|
|||
|
|||
@Excel(name = "小区名称") |
|||
@NotBlank(message = "小区名称不能位空") |
|||
@Length(max=50,message = "小区名称不能超过50个字") |
|||
private String neighborHoodName; |
|||
|
|||
@Excel(name = "楼栋名称") |
|||
@NotBlank(message = "楼栋名称不能位空") |
|||
private String buildingName; |
|||
|
|||
@Excel(name = "单元号") |
|||
@NotBlank(message = "单元号不能位空") |
|||
private Integer buildingUnit; |
|||
|
|||
@Excel(name = "门牌号") |
|||
@NotBlank(message = "门牌号不能位空") |
|||
private String doorName; |
|||
|
|||
@Excel(name = "房屋类型") |
|||
@NotBlank(message = "房屋类型不能位空") |
|||
private String houseType; |
|||
|
|||
@Excel(name = "房屋用途") |
|||
@NotBlank(message = "房屋用途不能位空") |
|||
private String purpose; |
|||
|
|||
@Excel(name = "出租") |
|||
@NotBlank(message = "出租不能位空") |
|||
private String rentFlag; |
|||
|
|||
@Excel(name = "房主姓名") |
|||
@NotBlank(message = "房主姓名不能位空") |
|||
private String ownerName; |
|||
|
|||
@Excel(name = "房主电话") |
|||
@NotBlank(message = "房主电话不能位空") |
|||
private String ownerPhone; |
|||
|
|||
@Excel(name = "房主身份证号") |
|||
@NotBlank(message = "房主身份证号不能位空") |
|||
private String ownerIdCard; |
|||
|
|||
} |
@ -0,0 +1,123 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.excel; |
|||
|
|||
import cn.afterturn.easypoi.excel.annotation.Excel; |
|||
import com.epmet.commons.tools.validator.group.AddGroup; |
|||
import com.epmet.commons.tools.validator.group.UpdateGroup; |
|||
import lombok.Data; |
|||
import org.hibernate.validator.constraints.Length; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 小区表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-10-26 |
|||
*/ |
|||
@Data |
|||
public class IcNeighborHoodExcel { |
|||
|
|||
/*@Excel(name = "小区主键") |
|||
private String id; |
|||
|
|||
@Excel(name = "客户id") |
|||
private String customerId; |
|||
|
|||
@Excel(name = "小区名称") |
|||
private String neighborHoodName; |
|||
|
|||
@Excel(name = "组织id") |
|||
private String agencyId; |
|||
|
|||
@Excel(name = "上级组织id") |
|||
private String parentAgencyId; |
|||
|
|||
@Excel(name = "组织的所有上级组织id") |
|||
private String agencyPids; |
|||
|
|||
@Excel(name = "网格id") |
|||
private String gridId; |
|||
|
|||
@Excel(name = "详细地址") |
|||
private String address; |
|||
|
|||
@Excel(name = "备注") |
|||
private String remark; |
|||
|
|||
@Excel(name = "中心点位:经度") |
|||
private String longitude; |
|||
|
|||
@Excel(name = "中心点位:纬度") |
|||
private String latitude; |
|||
|
|||
@Excel(name = "坐标区域") |
|||
private String coordinates; |
|||
|
|||
@Excel(name = "坐标位置") |
|||
private String location; |
|||
|
|||
@Excel(name = "删除标识 0未删除、1已删除") |
|||
private String delFlag; |
|||
|
|||
@Excel(name = "乐观锁") |
|||
private Integer revision; |
|||
|
|||
@Excel(name = "创建人") |
|||
private String createdBy; |
|||
|
|||
@Excel(name = "创建时间") |
|||
private Date createdTime; |
|||
|
|||
@Excel(name = "更新人") |
|||
private String updatedBy; |
|||
|
|||
@Excel(name = "更新时间") |
|||
private Date updatedTime;*/ |
|||
|
|||
|
|||
|
|||
|
|||
@Excel(name = "所属组织") |
|||
@NotBlank(message = "所属组织不能位空") |
|||
private String agencyName; |
|||
|
|||
@Excel(name = "所属网格") |
|||
@NotBlank(message = "所属网格不能位空") |
|||
private String gridName; |
|||
|
|||
@Excel(name = "小区名称") |
|||
@NotBlank(message = "小区名称不能位空") |
|||
@Length(max=50,message = "小区名称不能超过50个字") |
|||
private String neighborHoodName; |
|||
|
|||
@Excel(name = "关联物业") |
|||
|
|||
private String propertyName; |
|||
|
|||
@Excel(name = "详细地址") |
|||
@NotBlank(message = "详细地址不能位空") |
|||
private String address; |
|||
|
|||
@Excel(name = "备注") |
|||
@Length(max=500,message = "备注不能超过500个字") |
|||
private String remark; |
|||
|
|||
} |
@ -0,0 +1,47 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.redis; |
|||
|
|||
import com.epmet.commons.tools.redis.RedisUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* 楼栋信息 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-10-27 |
|||
*/ |
|||
@Component |
|||
public class IcBuildingRedis { |
|||
@Autowired |
|||
private RedisUtils redisUtils; |
|||
|
|||
public void delete(Object[] ids) { |
|||
|
|||
} |
|||
|
|||
public void set(){ |
|||
|
|||
} |
|||
|
|||
public String get(String id){ |
|||
return null; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,47 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.redis; |
|||
|
|||
import com.epmet.commons.tools.redis.RedisUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* 房屋信息 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-10-27 |
|||
*/ |
|||
@Component |
|||
public class IcHouseRedis { |
|||
@Autowired |
|||
private RedisUtils redisUtils; |
|||
|
|||
public void delete(Object[] ids) { |
|||
|
|||
} |
|||
|
|||
public void set(){ |
|||
|
|||
} |
|||
|
|||
public String get(String id){ |
|||
return null; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,47 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.redis; |
|||
|
|||
import com.epmet.commons.tools.redis.RedisUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* 小区表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-10-26 |
|||
*/ |
|||
@Component |
|||
public class IcNeighborHoodRedis { |
|||
@Autowired |
|||
private RedisUtils redisUtils; |
|||
|
|||
public void delete(Object[] ids) { |
|||
|
|||
} |
|||
|
|||
public void set(){ |
|||
|
|||
} |
|||
|
|||
public String get(String id){ |
|||
return null; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,53 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.dto.BuildingTreeLevelDTO; |
|||
import com.epmet.dto.form.IcBulidingFormDTO; |
|||
import com.epmet.excel.IcBuildingExcel; |
|||
import com.epmet.excel.IcNeighborHoodExcel; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 楼栋 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-10-25 |
|||
*/ |
|||
public interface BuildingService { |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void UpdateBuilding(String customerId, IcBulidingFormDTO formDTO); |
|||
|
|||
/** |
|||
* 删除小区 |
|||
* @param buildingId |
|||
*/ |
|||
void DelBuilding(String buildingId); |
|||
|
|||
|
|||
void AddBuilding(String customerId, IcBulidingFormDTO formDTO); |
|||
|
|||
List<BuildingTreeLevelDTO> treeList(String customerId); |
|||
|
|||
void importExcel(String customerId, List<IcBuildingExcel> list); |
|||
} |
@ -0,0 +1,47 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.dto.form.IcHouseFormDTO; |
|||
import com.epmet.excel.IcHouseExcel; |
|||
import com.epmet.excel.IcNeighborHoodExcel; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 小区表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-10-25 |
|||
*/ |
|||
public interface HouseService { |
|||
|
|||
void addHouse(String customerId, IcHouseFormDTO formDTO); |
|||
|
|||
|
|||
void updateHouse(String customerId, IcHouseFormDTO formDTO); |
|||
|
|||
/** |
|||
* 删除小区 |
|||
* @param houseId |
|||
*/ |
|||
void delHouse(String houseId); |
|||
|
|||
|
|||
void importExcel(String customerId, List<IcHouseExcel> list); |
|||
} |
@ -0,0 +1,296 @@ |
|||
package com.epmet.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.epmet.commons.tools.utils.ConvertUtils; |
|||
import com.epmet.dao.*; |
|||
import com.epmet.dto.*; |
|||
import com.epmet.dto.form.IcBulidingFormDTO; |
|||
import com.epmet.dto.result.ExtStaffPermissionResultDTO; |
|||
import com.epmet.entity.*; |
|||
import com.epmet.excel.IcBuildingExcel; |
|||
import com.epmet.excel.IcNeighborHoodExcel; |
|||
import com.epmet.service.*; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
import org.springframework.util.CollectionUtils; |
|||
|
|||
import javax.annotation.Resource; |
|||
import java.util.*; |
|||
import java.util.function.Function; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Slf4j |
|||
@Service |
|||
public class BuildingServiceImpl implements BuildingService { |
|||
|
|||
|
|||
@Autowired |
|||
private IcBuildingService icBuildingService; |
|||
@Resource |
|||
private IcBuildingDao icBuildingDao; |
|||
|
|||
@Autowired |
|||
private IcBuildingUnitService icBuildingUnitService; |
|||
|
|||
@Resource |
|||
private IcHouseDao icHouseDao; |
|||
@Autowired |
|||
private IcHouseService icHouseService; |
|||
|
|||
@Resource |
|||
private CustomerAgencyDao customerAgencyDao; |
|||
@Resource |
|||
private CustomerGridDao customerGridDao; |
|||
@Resource |
|||
private IcNeighborHoodDao icNeighborHoodDao; |
|||
@Resource |
|||
private CustomerStaffAgencyDao customerStaffAgencyDao; |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void AddBuilding(String customerId, IcBulidingFormDTO formDTO) { |
|||
IcBuildingDTO icBuildingDTO= ConvertUtils.sourceToTarget(formDTO, IcBuildingDTO.class); |
|||
icBuildingDTO.setCustomerId(customerId); |
|||
IcBuildingEntity entity = ConvertUtils.sourceToTarget(icBuildingDTO, IcBuildingEntity.class); |
|||
icBuildingDao.insert(entity); |
|||
|
|||
//设置楼宇单元
|
|||
Integer totalUnitNum = formDTO.getTotalUnitNum(); |
|||
List<IcBuildingUnitEntity> unitList = new ArrayList<>(); |
|||
for(int i =0 ;i<totalUnitNum;i++){ |
|||
IcBuildingUnitEntity icBuildingUnit= new IcBuildingUnitEntity(); |
|||
icBuildingUnit.setBuildingId(entity.getId()); |
|||
icBuildingUnit.setUnitName(String.valueOf(i+1)); |
|||
icBuildingUnit.setUnitNum(String.valueOf(i+1)); |
|||
unitList.add(icBuildingUnit); |
|||
} |
|||
icBuildingUnitService.insertBatch(unitList); |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public List<BuildingTreeLevelDTO> treeList(String staffId) { |
|||
CustomerStaffAgencyDTO agency = customerStaffAgencyDao.selectLatestCustomerByStaff(staffId); |
|||
if(null == agency || StringUtils.isBlank(agency.getAgencyId())){ |
|||
log.error("com.epmet.service.impl.BuildingServiceImpl.treeList,没有找到工作人员所属的机关信息,用户Id:{}",staffId); |
|||
return new ArrayList<>(); |
|||
} |
|||
//1.获取所在组织及下级组织
|
|||
CustomerAgencyEntity customerAgency = customerAgencyDao.selectById(agency.getAgencyId()); |
|||
List<CustomerAgencyEntity> customerAgencyList = icBuildingDao.selectAgencyChildrenList(agency.getAgencyId()); |
|||
customerAgencyList.add(customerAgency); |
|||
|
|||
if(CollectionUtils.isEmpty(customerAgencyList)){ |
|||
return new ArrayList<>(); |
|||
} |
|||
|
|||
List<BuildingTreeLevelDTO> agencyList = customerAgencyList.stream().map(item -> { |
|||
BuildingTreeLevelDTO buildingTreeLevelDTO = new BuildingTreeLevelDTO(); |
|||
buildingTreeLevelDTO.setId(item.getId()); |
|||
buildingTreeLevelDTO.setPId(item.getPid()); |
|||
buildingTreeLevelDTO.setLabel(item.getOrganizationName()); |
|||
buildingTreeLevelDTO.setLevel(item.getLevel()); |
|||
buildingTreeLevelDTO.setChildren(new ArrayList<>()); |
|||
return buildingTreeLevelDTO; |
|||
}).collect(Collectors.toList()); |
|||
|
|||
|
|||
|
|||
//2.获取组织所在网格
|
|||
List<String> agencyIdList = customerAgencyList.stream().map(a->a.getId()).collect(Collectors.toList()); |
|||
// agencyIdList.add(customerAgency.getId());
|
|||
List<CustomerGridEntity> customerGridList = customerGridDao.selectList(new QueryWrapper<CustomerGridEntity>().lambda().in(CustomerGridEntity::getPid, agencyIdList)); |
|||
|
|||
if(CollectionUtils.isEmpty(customerGridList)){ |
|||
return covertToTree(customerAgency,agencyList); |
|||
} |
|||
|
|||
List<BuildingTreeLevelDTO> gridList = customerGridList.stream().map(item -> { |
|||
BuildingTreeLevelDTO buildingTreeLevelDTO = new BuildingTreeLevelDTO(); |
|||
buildingTreeLevelDTO.setId(item.getId()); |
|||
buildingTreeLevelDTO.setLabel(item.getGridName()); |
|||
buildingTreeLevelDTO.setLevel("grid"); |
|||
buildingTreeLevelDTO.setPId(item.getPid()); |
|||
buildingTreeLevelDTO.setChildren(new ArrayList<>()); |
|||
return buildingTreeLevelDTO; |
|||
}).collect(Collectors.toList()); |
|||
|
|||
|
|||
//3.获取网格下的所有小区
|
|||
List<String> gridIdList = customerGridList.stream().map(a->a.getId()).collect(Collectors.toList()); |
|||
List<IcNeighborHoodEntity> icNeighborHoodList = icNeighborHoodDao.selectList(new QueryWrapper<IcNeighborHoodEntity>().lambda().in(IcNeighborHoodEntity::getGridId, gridIdList)); |
|||
if(CollectionUtils.isEmpty(customerGridList)){ |
|||
agencyList.addAll(gridList); |
|||
return covertToTree(customerAgency,agencyList); |
|||
} |
|||
List<BuildingTreeLevelDTO> neighbourHoodList = icNeighborHoodList.stream().map(item -> { |
|||
BuildingTreeLevelDTO buildingTreeLevelDTO = new BuildingTreeLevelDTO(); |
|||
buildingTreeLevelDTO.setId(item.getId()); |
|||
buildingTreeLevelDTO.setPId(item.getGridId()); |
|||
buildingTreeLevelDTO.setLabel(item.getNeighborHoodName()); |
|||
buildingTreeLevelDTO.setLevel("neighbourHood"); |
|||
buildingTreeLevelDTO.setChildren(new ArrayList<>()); |
|||
return buildingTreeLevelDTO; |
|||
}).collect(Collectors.toList()); |
|||
|
|||
//3.获取小区下的所有楼宇
|
|||
List<String> neighborHoodIdList = icNeighborHoodList.stream().map(a->a.getId()).collect(Collectors.toList()); |
|||
List<IcBuildingEntity> icBuildingList = icBuildingDao.selectList(new QueryWrapper<IcBuildingEntity>().lambda().in(IcBuildingEntity::getNeighborHoodId, neighborHoodIdList)); |
|||
|
|||
if(CollectionUtils.isEmpty(neighborHoodIdList)){ |
|||
agencyList.addAll(gridList); |
|||
agencyList.addAll(neighbourHoodList); |
|||
return covertToTree(customerAgency,agencyList); |
|||
} |
|||
//组合封装
|
|||
|
|||
List<BuildingTreeLevelDTO> buildingList = icBuildingList.stream().map(item -> { |
|||
BuildingTreeLevelDTO buildingTreeLevelDTO = new BuildingTreeLevelDTO(); |
|||
buildingTreeLevelDTO.setId(item.getId()); |
|||
buildingTreeLevelDTO.setPId(item.getNeighborHoodId()); |
|||
buildingTreeLevelDTO.setLabel(item.getBuildingName()); |
|||
buildingTreeLevelDTO.setLevel("building"); |
|||
buildingTreeLevelDTO.setChildren(new ArrayList<>()); |
|||
return buildingTreeLevelDTO; |
|||
}).collect(Collectors.toList()); |
|||
|
|||
|
|||
|
|||
|
|||
//组织
|
|||
// gridList.stream()
|
|||
// Map<String, List<BuildingTreeLevelDTO>> gridMap = gridList.stream().collect(Collectors.groupingBy(e -> e.getPId()));
|
|||
// List<BuildingTreeLevelDTO> allList = agencyList.addAll(gridList)
|
|||
|
|||
agencyList.addAll(gridList); |
|||
agencyList.addAll(neighbourHoodList); |
|||
agencyList.addAll(buildingList); |
|||
return covertToTree(customerAgency,agencyList); |
|||
|
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void importExcel(String customerId, List<IcBuildingExcel> list) { |
|||
//导入
|
|||
if(CollectionUtils.isEmpty(list)){ |
|||
return ; |
|||
} |
|||
//查询所有组织和网格根据名字
|
|||
|
|||
|
|||
|
|||
//获取所有小区 list 根据组织和网格
|
|||
Set<String> neighborNameList = list.stream().map(item -> item.getNeighborHoodName()).collect(Collectors.toSet()); |
|||
Set<String> agencyNameList = list.stream().map(item -> item.getAgencyName()).collect(Collectors.toSet()); |
|||
Set<String> gridNameList = list.stream().map(item -> item.getGridName()).collect(Collectors.toSet()); |
|||
List<IcNeighborHoodEntity> neighborHoodList = icNeighborHoodDao.selectListByName(new ArrayList<String>(neighborNameList),new ArrayList<String>(agencyNameList),new ArrayList<String>(gridNameList)); |
|||
// List<IcNeighborHoodEntity> neighborHoodList = icNeighborHoodDao.selectList(new QueryWrapper<IcNeighborHoodEntity>().lambda().in(IcNeighborHoodEntity::getNeighborHoodName, neighborNameList));
|
|||
Map<String,IcNeighborHoodEntity> neighborHoodMap = neighborHoodList.stream().collect(Collectors.toMap(IcNeighborHoodEntity::getNeighborHoodName, Function.identity(),(key1, key2)->key1)); |
|||
|
|||
|
|||
//2.获取小区数据
|
|||
//封装数据
|
|||
List<IcBuildingEntity> buildingEntityList = new ArrayList<>(); |
|||
List<IcBuildingUnitEntity> icBuildingUnitEntityList = new ArrayList<>(); |
|||
for (IcBuildingExcel icBuildingExcel : list) { |
|||
IcBuildingEntity entity = new IcBuildingEntity(); |
|||
String uuid = UUID.randomUUID().toString().replace("-", ""); |
|||
entity.setId(uuid); |
|||
entity.setCustomerId(customerId); |
|||
entity.setNeighborHoodId(neighborHoodMap.get(icBuildingExcel.getNeighborHoodName()).getId()); |
|||
entity.setBuildingName(icBuildingExcel.getBuildingName()); |
|||
entity.setTotalUnitNum(icBuildingExcel.getTotalUnitNum()); |
|||
entity.setTotalFloorNum(icBuildingExcel.getTotalFloorNum()); |
|||
entity.setTotalHouseNum(icBuildingExcel.getTotalHouseNum()); |
|||
buildingEntityList.add(entity); |
|||
|
|||
Integer totalUnitNum = icBuildingExcel.getTotalUnitNum(); |
|||
//设置楼宇单元
|
|||
List<IcBuildingUnitEntity> unitList = new ArrayList<>(); |
|||
for(int i =0 ;i<totalUnitNum;i++){ |
|||
IcBuildingUnitEntity icBuildingUnit= new IcBuildingUnitEntity(); |
|||
icBuildingUnit.setBuildingId(uuid); |
|||
icBuildingUnit.setUnitName(String.valueOf(i+1)); |
|||
icBuildingUnit.setUnitNum(String.valueOf(i+1)); |
|||
unitList.add(icBuildingUnit); |
|||
} |
|||
icBuildingUnitEntityList.addAll(unitList); |
|||
} |
|||
//3.保存
|
|||
//4.新增单元
|
|||
icBuildingService.insertBatch(buildingEntityList); |
|||
icBuildingUnitService.insertBatch(icBuildingUnitEntityList); |
|||
|
|||
} |
|||
|
|||
|
|||
private List<BuildingTreeLevelDTO> covertToTree(CustomerAgencyEntity customerAgency,List<BuildingTreeLevelDTO> agencyList) { |
|||
BuildingTreeLevelDTO buildingTreeLevelDTO = new BuildingTreeLevelDTO(); |
|||
buildingTreeLevelDTO.setId(customerAgency.getId()); |
|||
buildingTreeLevelDTO.setLabel(customerAgency.getOrganizationName()); |
|||
buildingTreeLevelDTO.setLevel(customerAgency.getLevel()); |
|||
buildingTreeLevelDTO.setChildren(new ArrayList<>()); |
|||
recursionCovertToTree(buildingTreeLevelDTO,agencyList); |
|||
List<BuildingTreeLevelDTO> result = new ArrayList<>(); |
|||
result.add(buildingTreeLevelDTO); |
|||
return result; |
|||
} |
|||
|
|||
private void recursionCovertToTree(BuildingTreeLevelDTO parent, List<BuildingTreeLevelDTO> customerAgencyList) { |
|||
//获取子节点
|
|||
List<BuildingTreeLevelDTO> subList = customerAgencyList.stream().filter(item -> item.getPId().equals(parent.getId())).collect(Collectors.toList()); |
|||
|
|||
for(BuildingTreeLevelDTO agencyEntity :subList){ |
|||
recursionCovertToTree(agencyEntity,customerAgencyList); |
|||
} |
|||
parent.setChildren(subList); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
/** |
|||
* 更新 |
|||
* @param customerId |
|||
* @param formDTO |
|||
*/ |
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void UpdateBuilding(String customerId, IcBulidingFormDTO formDTO) { |
|||
IcBuildingDTO icBuilding= icBuildingService.get(formDTO.getBuildingId()); |
|||
|
|||
if(!icBuilding.getNeighborHoodId().equals(formDTO.getNeighborHoodId())){ |
|||
//更新对应房屋小区名
|
|||
List<IcHouseEntity> icHouseEntities = icHouseDao.selectList(new QueryWrapper<IcHouseEntity>().lambda().eq(IcHouseEntity::getBuildingId, formDTO.getBuildingId())); |
|||
icHouseEntities.forEach(item->{ |
|||
item.setNeighborHoodId(formDTO.getNeighborHoodId()); |
|||
}); |
|||
icHouseService.updateBatchById(icHouseEntities); |
|||
} |
|||
IcBuildingDTO icBuildingDTO= ConvertUtils.sourceToTarget(formDTO, IcBuildingDTO.class); |
|||
icBuildingDTO.setId(formDTO.getBuildingId()); |
|||
icBuildingDTO.setCustomerId(customerId); |
|||
icBuildingService.update(icBuildingDTO); |
|||
//更新楼宇单元
|
|||
//如果楼宇单元大于之前的楼宇单元,新增单元
|
|||
//如果小于,判断是否存在房屋,如果存在就提示不能更改
|
|||
|
|||
|
|||
} |
|||
|
|||
/** |
|||
* 删除 |
|||
* @param buildingId |
|||
*/ |
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void DelBuilding(String buildingId) { |
|||
//删除小区
|
|||
icBuildingService.deleteById(buildingId); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,152 @@ |
|||
package com.epmet.service.impl; |
|||
|
|||
import com.epmet.commons.tools.utils.ConvertUtils; |
|||
import com.epmet.dao.IcBuildingDao; |
|||
import com.epmet.dao.IcBuildingUnitDao; |
|||
import com.epmet.dao.IcHouseDao; |
|||
import com.epmet.dao.IcNeighborHoodDao; |
|||
import com.epmet.dto.IcBuildingDTO; |
|||
import com.epmet.dto.IcBuildingUnitDTO; |
|||
import com.epmet.dto.IcHouseDTO; |
|||
import com.epmet.dto.form.IcHouseFormDTO; |
|||
import com.epmet.entity.IcHouseEntity; |
|||
import com.epmet.excel.IcHouseExcel; |
|||
import com.epmet.service.HouseService; |
|||
import com.epmet.service.IcBuildingService; |
|||
import com.epmet.service.IcBuildingUnitService; |
|||
import com.epmet.service.IcHouseService; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
import org.springframework.util.CollectionUtils; |
|||
|
|||
import javax.annotation.Resource; |
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Slf4j |
|||
@Service |
|||
public class HouseServiceImpl implements HouseService { |
|||
|
|||
|
|||
|
|||
@Autowired |
|||
private IcHouseService icHouseService; |
|||
@Autowired |
|||
private IcBuildingService icBuildingService; |
|||
@Autowired |
|||
private IcBuildingUnitService icBuildingUnitService; |
|||
@Resource |
|||
private IcNeighborHoodDao icNeighborHoodDao; |
|||
@Resource |
|||
private IcBuildingDao icBuildingDao; |
|||
@Resource |
|||
private IcBuildingUnitDao icBuildingUnitDao; |
|||
@Resource |
|||
private IcHouseDao icHouseDao; |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void addHouse(String customerId, IcHouseFormDTO formDTO) { |
|||
IcHouseDTO icHouseDTO= ConvertUtils.sourceToTarget(formDTO, IcHouseDTO.class); |
|||
icHouseDTO.setCustomerId(customerId); |
|||
icHouseDTO.setRentFlag(formDTO.getRentFlag()?1:0); |
|||
|
|||
icHouseDTO.setHouseName(getHouseName(formDTO)); |
|||
icHouseService.save(icHouseDTO); |
|||
} |
|||
|
|||
private String getHouseName(IcHouseFormDTO formDTO){ |
|||
//设置房间名 楼栋-单元号-门牌号
|
|||
IcBuildingDTO icBuilding = icBuildingService.get(formDTO.getBuildingUnitId()); |
|||
IcBuildingUnitDTO icBuildingUnit = icBuildingUnitService.get(formDTO.getBuildingUnitId()); |
|||
String doorName = formDTO.getDoorName(); |
|||
String buildingName = Optional.ofNullable(icBuilding).map(u->u.getBuildingName()).orElse(""); |
|||
String unitName = Optional.ofNullable(icBuildingUnit).map(u->u.getUnitNum()).orElse(""); |
|||
return new StringBuilder().append(buildingName).append("-").append(unitName).append("-").append(doorName).toString(); |
|||
} |
|||
|
|||
/** |
|||
* 更新 |
|||
* @param customerId |
|||
* @param formDTO |
|||
*/ |
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void updateHouse(String customerId, IcHouseFormDTO formDTO) { |
|||
IcHouseDTO icHouseDTO = ConvertUtils.sourceToTarget(formDTO, IcHouseDTO.class); |
|||
icHouseDTO.setId(formDTO.getHouseId()); |
|||
icHouseDTO.setCustomerId(customerId); |
|||
icHouseDTO.setRentFlag(formDTO.getRentFlag()?1:0); |
|||
//设置
|
|||
icHouseDTO.setHouseName(getHouseName(formDTO)); |
|||
icHouseService.update(icHouseDTO); |
|||
} |
|||
|
|||
/** |
|||
* 删除 |
|||
* @param houseId |
|||
*/ |
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delHouse(String houseId) { |
|||
//删除小区
|
|||
icHouseService.deleteById(houseId); |
|||
} |
|||
|
|||
@Override |
|||
public void importExcel(String customerId, List<IcHouseExcel> list) { |
|||
//导入
|
|||
if(CollectionUtils.isEmpty(list)){ |
|||
return ; |
|||
} |
|||
//获取所有小区 list
|
|||
// List<String> neighborNameList = list.stream().map(item -> item.getNeighborHoodName()).collect(Collectors.toList());
|
|||
// List<IcNeighborHoodEntity> neighborHoodList = icNeighborHoodDao.selectList(new QueryWrapper<IcNeighborHoodEntity>().lambda().in(IcNeighborHoodEntity::getNeighborHoodName, neighborNameList));
|
|||
// Map<String,IcNeighborHoodEntity> neighborHoodMap = neighborHoodList.stream().collect(Collectors.toMap(IcNeighborHoodEntity::getNeighborHoodName, Function.identity(),(key1, key2)->key1));
|
|||
|
|||
//获取所有楼宇 list
|
|||
// List<String> buildingNameList = list.stream().map(item -> item.getBuildingName()).collect(Collectors.toList());
|
|||
|
|||
// icBuildingDao.selectList(new QueryWrapper<IcBuildingEntity>().lambda().in(IcBuildingEntity::getBuildingName, buildingNameList).in();
|
|||
Set<String> neighborNameList = list.stream().map(item -> item.getNeighborHoodName()).collect(Collectors.toSet()); |
|||
Set<String> buildingNameList = list.stream().map(item -> item.getBuildingName()).collect(Collectors.toSet()); |
|||
Set<Integer> buildingUnitList = list.stream().map(item -> item.getBuildingUnit()).collect(Collectors.toSet()); |
|||
List<Map<String,Object>> buildMapList = icBuildingDao.selectListByName(new ArrayList<String>(neighborNameList),new ArrayList<String>(buildingNameList),new ArrayList<Integer>(buildingUnitList)); |
|||
//转Map
|
|||
Map<String,Map<String,Object>> buildMap = new HashMap<>(); |
|||
buildMapList.forEach(item->{ |
|||
buildMap.put(item.get("neighborName")+","+item.get("buildingName")+","+item.get("unitNum"),item); |
|||
}); |
|||
//封装数据
|
|||
List<IcHouseEntity> houseEntityList = new ArrayList<>(); |
|||
for (IcHouseExcel icHouseExcel : list) { |
|||
IcHouseEntity entity = new IcHouseEntity(); |
|||
String uuid = UUID.randomUUID().toString().replace("-", ""); |
|||
entity.setId(uuid); |
|||
entity.setCustomerId(customerId); |
|||
Map<String,Object> item = buildMap.get(icHouseExcel.getNeighborHoodName()+","+icHouseExcel.getBuildingName()+","+icHouseExcel.getBuildingUnit()); |
|||
if(!CollectionUtils.isEmpty(item)){ |
|||
entity.setNeighborHoodId(String.valueOf(item.get("neighborId"))); |
|||
entity.setBuildingId(String.valueOf(item.get("buildingId"))); |
|||
entity.setBuildingUnitId(String.valueOf(item.get("buildingUnitId"))); |
|||
entity.setHouseName(icHouseExcel.getBuildingName()+"-"+icHouseExcel.getBuildingUnit()+"-"+icHouseExcel.getDoorName()); |
|||
} |
|||
entity.setDoorName(icHouseExcel.getDoorName()); |
|||
entity.setHouseType(icHouseExcel.getHouseType()); |
|||
entity.setPurpose(icHouseExcel.getPurpose()); |
|||
entity.setRentFlag("是".equals(icHouseExcel.getRentFlag())?1:0); |
|||
entity.setOwnerName(icHouseExcel.getOwnerName()); |
|||
entity.setOwnerPhone(icHouseExcel.getOwnerPhone()); |
|||
entity.setOwnerIdCard(icHouseExcel.getOwnerIdCard()); |
|||
houseEntityList.add(entity); |
|||
} |
|||
//3.保存
|
|||
//4.新增单元
|
|||
icHouseService.insertBatch(houseEntityList); |
|||
|
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,276 @@ |
|||
package com.epmet.util; |
|||
|
|||
import cn.afterturn.easypoi.excel.ExcelExportUtil; |
|||
import cn.afterturn.easypoi.excel.ExcelImportUtil; |
|||
import cn.afterturn.easypoi.excel.entity.ExportParams; |
|||
import cn.afterturn.easypoi.excel.entity.ImportParams; |
|||
import cn.afterturn.easypoi.excel.entity.TemplateExportParams; |
|||
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; |
|||
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; |
|||
import org.apache.commons.lang.StringUtils; |
|||
import org.apache.poi.ss.usermodel.Workbook; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.io.File; |
|||
import java.io.IOException; |
|||
import java.io.InputStream; |
|||
import java.net.URLEncoder; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.NoSuchElementException; |
|||
|
|||
public class ExcelPoiUtils { |
|||
/** |
|||
* excel 导出 |
|||
* |
|||
* @param list 数据列表 |
|||
* @param fileName 导出时的excel名称 |
|||
* @param response |
|||
*/ |
|||
public static void exportExcel(List<Map<String, Object>> list, String fileName, HttpServletResponse response) throws IOException { |
|||
defaultExport(list, fileName, response); |
|||
} |
|||
|
|||
/** |
|||
* 默认的 excel 导出 |
|||
* |
|||
* @param list 数据列表 |
|||
* @param fileName 导出时的excel名称 |
|||
* @param response |
|||
*/ |
|||
private static void defaultExport(List<Map<String, Object>> list, String fileName, HttpServletResponse response) throws IOException { |
|||
//把数据添加到excel表格中
|
|||
Workbook workbook = ExcelExportUtil.exportExcel(list, ExcelType.HSSF); |
|||
downLoadExcel(fileName, response, workbook); |
|||
} |
|||
|
|||
/** |
|||
* excel 导出 |
|||
* |
|||
* @param list 数据列表 |
|||
* @param pojoClass pojo类型 |
|||
* @param fileName 导出时的excel名称 |
|||
* @param response |
|||
* @param exportParams 导出参数(标题、sheet名称、是否创建表头,表格类型) |
|||
*/ |
|||
private static void defaultExport(List<?> list, Class<?> pojoClass, String fileName, HttpServletResponse response, ExportParams exportParams) throws IOException { |
|||
//把数据添加到excel表格中
|
|||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, pojoClass, list); |
|||
downLoadExcel(fileName, response, workbook); |
|||
} |
|||
|
|||
/** |
|||
* excel 导出 |
|||
* |
|||
* @param list 数据列表 |
|||
* @param pojoClass pojo类型 |
|||
* @param fileName 导出时的excel名称 |
|||
* @param exportParams 导出参数(标题、sheet名称、是否创建表头,表格类型) |
|||
* @param response |
|||
*/ |
|||
public static void exportExcel(List<?> list, Class<?> pojoClass, String fileName, ExportParams exportParams, HttpServletResponse response) throws IOException { |
|||
defaultExport(list, pojoClass, fileName, response, exportParams); |
|||
} |
|||
|
|||
/** |
|||
* excel 导出 |
|||
* |
|||
* @param list 数据列表 |
|||
* @param title 表格内数据标题 |
|||
* @param sheetName sheet名称 |
|||
* @param pojoClass pojo类型 |
|||
* @param fileName 导出时的excel名称 |
|||
* @param response |
|||
*/ |
|||
public static void exportExcel(List<?> list, String title, String sheetName, Class<?> pojoClass, String fileName, HttpServletResponse response) throws IOException { |
|||
defaultExport(list, pojoClass, fileName, response, new ExportParams(title, sheetName, ExcelType.XSSF)); |
|||
} |
|||
|
|||
|
|||
|
|||
/** |
|||
* excel 导出 |
|||
* |
|||
* @param list 数据列表 |
|||
* @param title 表格内数据标题 |
|||
* @param sheetName sheet名称 |
|||
* @param pojoClass pojo类型 |
|||
* @param fileName 导出时的excel名称 |
|||
* @param isCreateHeader 是否创建表头 |
|||
* @param response |
|||
*/ |
|||
public static void exportExcel(List<?> list, String title, String sheetName, Class<?> pojoClass, String fileName, boolean isCreateHeader, HttpServletResponse response) throws IOException { |
|||
ExportParams exportParams = new ExportParams(title, sheetName, ExcelType.XSSF); |
|||
exportParams.setCreateHeadRows(isCreateHeader); |
|||
defaultExport(list, pojoClass, fileName, response, exportParams); |
|||
} |
|||
/** |
|||
* 根据模板生成excel后导出 |
|||
* @param templatePath 模板路径 |
|||
* @param map 数据集合 |
|||
* @param fileName 文件名 |
|||
* @param response |
|||
* @throws IOException |
|||
*/ |
|||
public static void exportExcel(TemplateExportParams templatePath, Map<String, Object> map, String fileName, HttpServletResponse response) throws IOException { |
|||
Workbook workbook = ExcelExportUtil.exportExcel(templatePath, map); |
|||
downLoadExcel(fileName, response, workbook); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* excel下载 |
|||
* |
|||
* @param fileName 下载时的文件名称 |
|||
* @param response |
|||
* @param workbook excel数据 |
|||
*/ |
|||
private static void downLoadExcel(String fileName, HttpServletResponse response, Workbook workbook) throws IOException { |
|||
try { |
|||
response.setCharacterEncoding("UTF-8"); |
|||
response.setHeader("content-Type", "application/vnd.ms-excel"); |
|||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName + ".xlsx", "UTF-8")); |
|||
workbook.write(response.getOutputStream()); |
|||
} catch (Exception e) { |
|||
throw new IOException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
/** |
|||
* excel 导入 |
|||
* |
|||
* @param file excel文件 |
|||
* @param pojoClass pojo类型 |
|||
* @param <T> |
|||
* @return |
|||
*/ |
|||
public static <T> List<T> importExcel(MultipartFile file, Class<T> pojoClass) throws IOException { |
|||
return importExcel(file, 1, 1, pojoClass); |
|||
} |
|||
|
|||
/** |
|||
* excel 导入 |
|||
* |
|||
* @param filePath excel文件路径 |
|||
* @param titleRows 表格内数据标题行 |
|||
* @param headerRows 表头行 |
|||
* @param pojoClass pojo类型 |
|||
* @param <T> |
|||
* @return |
|||
*/ |
|||
public static <T> List<T> importExcel(String filePath, Integer titleRows, Integer headerRows, Class<T> pojoClass) throws IOException { |
|||
if (StringUtils.isBlank(filePath)) { |
|||
return null; |
|||
} |
|||
ImportParams params = new ImportParams(); |
|||
params.setTitleRows(titleRows); |
|||
params.setHeadRows(headerRows); |
|||
params.setNeedSave(true); |
|||
params.setSaveUrl("/excel/"); |
|||
try { |
|||
return ExcelImportUtil.importExcel(new File(filePath), pojoClass, params); |
|||
} catch (NoSuchElementException e) { |
|||
throw new IOException("模板不能为空"); |
|||
} catch (Exception e) { |
|||
throw new IOException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* excel 导入 |
|||
* |
|||
* @param file 上传的文件 |
|||
* @param titleRows 表格内数据标题行 |
|||
* @param headerRows 表头行 |
|||
* @param pojoClass pojo类型 |
|||
* @param <T> |
|||
* @return |
|||
*/ |
|||
public static <T> List<T> importExcel(MultipartFile file, Integer titleRows, Integer headerRows, Class<T> pojoClass) throws IOException { |
|||
if (file == null) { |
|||
return null; |
|||
} |
|||
try { |
|||
return importExcel(file.getInputStream(), titleRows, headerRows, pojoClass); |
|||
} catch (Exception e) { |
|||
throw new IOException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* excel 导入 |
|||
* |
|||
* @param inputStream 文件输入流 |
|||
* @param titleRows 表格内数据标题行 |
|||
* @param headerRows 表头行 |
|||
* @param pojoClass pojo类型 |
|||
* @param <T> |
|||
* @return |
|||
*/ |
|||
public static <T> List<T> importExcel(InputStream inputStream, Integer titleRows, Integer headerRows, Class<T> pojoClass) throws IOException { |
|||
if (inputStream == null) { |
|||
return null; |
|||
} |
|||
ImportParams params = new ImportParams(); |
|||
params.setTitleRows(titleRows); |
|||
params.setHeadRows(headerRows); |
|||
params.setSaveUrl("/excel/"); |
|||
params.setNeedSave(true); |
|||
try { |
|||
return ExcelImportUtil.importExcel(inputStream, pojoClass, params); |
|||
} catch (NoSuchElementException e) { |
|||
throw new IOException("excel文件不能为空"); |
|||
} catch (Exception e) { |
|||
throw new IOException(e.getMessage()); |
|||
} |
|||
} |
|||
/** |
|||
* excel 导入,有错误信息 |
|||
* |
|||
* @param file 上传的文件 |
|||
* @param pojoClass pojo类型 |
|||
* @param <T> |
|||
* @return |
|||
*/ |
|||
public static <T> ExcelImportResult<T> importExcelMore(MultipartFile file, Class<T> pojoClass) throws IOException { |
|||
if (file == null) { |
|||
return null; |
|||
} |
|||
try { |
|||
return importExcelMore(file.getInputStream(), pojoClass); |
|||
} catch (Exception e) { |
|||
throw new IOException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* excel 导入 |
|||
* |
|||
* @param inputStream 文件输入流 |
|||
* @param pojoClass pojo类型 |
|||
* @param <T> |
|||
* @return |
|||
*/ |
|||
private static <T> ExcelImportResult<T> importExcelMore(InputStream inputStream, Class<T> pojoClass) throws IOException { |
|||
if (inputStream == null) { |
|||
return null; |
|||
} |
|||
ImportParams params = new ImportParams(); |
|||
params.setTitleRows(1);//表格内数据标题行
|
|||
params.setHeadRows(1);//表头行
|
|||
params.setSaveUrl("/excel/"); |
|||
params.setNeedSave(true); |
|||
params.setNeedVerify(true); |
|||
try { |
|||
return ExcelImportUtil.importExcelMore(inputStream, pojoClass, params); |
|||
} catch (NoSuchElementException e) { |
|||
throw new IOException("excel文件不能为空"); |
|||
} catch (Exception e) { |
|||
throw new IOException(e.getMessage()); |
|||
} |
|||
} |
|||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue