Browse Source
# Conflicts: # epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.javamaster
66 changed files with 3703 additions and 63 deletions
@ -0,0 +1,150 @@ |
|||
package com.epmet.dto; |
|||
|
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2022/2/13 4:32 下午 |
|||
* @DESC |
|||
*/ |
|||
@Data |
|||
public class ImportGeneralDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -345610717773879687L; |
|||
|
|||
/** |
|||
* 组织名、ID |
|||
*/ |
|||
private String agencyName; |
|||
private String agencyId; |
|||
|
|||
/** |
|||
* agencyId的pid |
|||
*/ |
|||
private String pid; |
|||
private String pids; |
|||
|
|||
/** |
|||
* 网格名、ID |
|||
*/ |
|||
private String gridName; |
|||
private String gridId; |
|||
|
|||
/** |
|||
* 小区名、ID |
|||
*/ |
|||
private String neighborHoodName; |
|||
private String neighborHoodId; |
|||
|
|||
/** |
|||
* 所属楼栋、ID |
|||
*/ |
|||
private String buildingName; |
|||
private String buildingId; |
|||
|
|||
/** |
|||
* 房屋类型 |
|||
*/ |
|||
private String type; |
|||
|
|||
/** |
|||
* 单元数 |
|||
*/ |
|||
private Integer totalUnitNum = NumConstant.ONE; |
|||
|
|||
/** |
|||
* 层数 |
|||
*/ |
|||
private Integer totalFloorNum; |
|||
|
|||
/** |
|||
* 户数 |
|||
*/ |
|||
private Integer totalHouseNum; |
|||
|
|||
/** |
|||
* 单元号、ID |
|||
*/ |
|||
private Integer buildingUnit; |
|||
private String buildingUnitId; |
|||
|
|||
/** |
|||
* 门牌号 |
|||
*/ |
|||
private String doorName; |
|||
|
|||
/** |
|||
* 房屋类型 |
|||
*/ |
|||
private String houseType; |
|||
|
|||
/** |
|||
* 房屋用途 |
|||
*/ |
|||
private String purpose; |
|||
|
|||
/** |
|||
* 是否出租 |
|||
*/ |
|||
private String rentFlagString; |
|||
private Integer rentFlag; |
|||
|
|||
/** |
|||
* 姓名 |
|||
*/ |
|||
private String ownerName; |
|||
|
|||
/** |
|||
* 电话 |
|||
*/ |
|||
private String ownerPhone; |
|||
|
|||
/** |
|||
* 身份证 |
|||
*/ |
|||
private String ownerIdCard; |
|||
|
|||
/** |
|||
* 行号 |
|||
*/ |
|||
private Integer num; |
|||
|
|||
/** |
|||
* 关联物业 |
|||
*/ |
|||
private String propertyName; |
|||
|
|||
/** |
|||
* 详细地址 |
|||
*/ |
|||
private String address; |
|||
|
|||
/** |
|||
* 备注 |
|||
*/ |
|||
private String remark; |
|||
|
|||
/** |
|||
* 房屋ID |
|||
*/ |
|||
private String houseId; |
|||
|
|||
private String houseName; |
|||
|
|||
private String customerId; |
|||
|
|||
private Boolean existStatus = false; |
|||
|
|||
/** |
|||
* 楼栋重复状态 |
|||
*/ |
|||
private Boolean buildingExistStatus = false; |
|||
|
|||
/** |
|||
* 小区重复状态 |
|||
*/ |
|||
private Boolean neighborHoodExistStatus = false; |
|||
} |
@ -0,0 +1,42 @@ |
|||
package com.epmet.dto; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2022/2/13 8:51 上午 |
|||
* @DESC |
|||
*/ |
|||
@Data |
|||
public class NeighborHoodAndManagementDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -7500263771019585308L; |
|||
|
|||
private String gridId; |
|||
|
|||
/** |
|||
* 小区ID |
|||
*/ |
|||
private String id; |
|||
|
|||
private String gridName; |
|||
|
|||
/** |
|||
* 小区名字 |
|||
*/ |
|||
private String neighborHoodName; |
|||
private String neighborHoodId; |
|||
|
|||
/** |
|||
* 物业ID |
|||
*/ |
|||
private String propertyId; |
|||
|
|||
/** |
|||
* 物业名字 |
|||
*/ |
|||
private String propertyName; |
|||
|
|||
} |
@ -0,0 +1,34 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2022/2/12 10:38 上午 |
|||
* @DESC |
|||
*/ |
|||
@Data |
|||
public class ImportInfoFormDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -3978921489168201769L; |
|||
|
|||
public interface ImportInfoForm{} |
|||
|
|||
/** |
|||
* 选中的组织ID |
|||
*/ |
|||
@NotBlank(message = "orgId不能为空",groups = ImportInfoForm.class) |
|||
private String orgId; |
|||
|
|||
/** |
|||
* 组织类型 agency:组织,grid:网格,neighborHood:小区,building:楼栋 |
|||
*/ |
|||
@NotBlank(message = "orgType不能为空",groups = ImportInfoForm.class) |
|||
private String orgType; |
|||
|
|||
private String customerId; |
|||
private String userId; |
|||
} |
@ -0,0 +1,31 @@ |
|||
package com.epmet.dto.result; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2022/2/15 9:25 上午 |
|||
* @DESC |
|||
*/ |
|||
@Data |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
public class ImportResultDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -5817164530837181890L; |
|||
|
|||
/** |
|||
* 未导入的行号 |
|||
*/ |
|||
private List<Integer> nums; |
|||
|
|||
/** |
|||
* 总条数 |
|||
*/ |
|||
private Integer num; |
|||
} |
@ -0,0 +1,31 @@ |
|||
package com.epmet.dto.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2022/2/12 2:15 下午 |
|||
* @DESC |
|||
*/ |
|||
@Data |
|||
public class InfoByNamesResultDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 264490056071606346L; |
|||
|
|||
private String gridId; |
|||
private String agencyId; |
|||
|
|||
private String gridName; |
|||
private String agencyName; |
|||
|
|||
private String pid; |
|||
|
|||
private String pids; |
|||
|
|||
private String parentAgencyId; |
|||
|
|||
private String agencyPids; |
|||
|
|||
} |
@ -0,0 +1,38 @@ |
|||
package com.epmet.model; |
|||
|
|||
import com.alibaba.excel.annotation.ExcelProperty; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2022/2/15 10:07 上午 |
|||
* @DESC |
|||
*/ |
|||
@Data |
|||
public class BuildingInfoModel { |
|||
|
|||
@ExcelProperty(value = "所属组织") |
|||
private String agencyName; |
|||
|
|||
@ExcelProperty(value = "所属网格") |
|||
private String gridName; |
|||
|
|||
@ExcelProperty(value = "小区名称") |
|||
private String neighborHoodName; |
|||
|
|||
@ExcelProperty(value = "楼栋名称") |
|||
private String buildingName; |
|||
|
|||
@ExcelProperty(value = "楼栋类型") |
|||
private String type; |
|||
|
|||
@ExcelProperty(value = "单元数") |
|||
private Integer totalUnitNum; |
|||
|
|||
@ExcelProperty(value = "层数") |
|||
private Integer totalFloorNum; |
|||
|
|||
@ExcelProperty(value = "户数") |
|||
private Integer totalHouseNum; |
|||
|
|||
} |
@ -0,0 +1,52 @@ |
|||
package com.epmet.model; |
|||
|
|||
import com.alibaba.excel.annotation.ExcelProperty; |
|||
import lombok.Data; |
|||
import org.hibernate.validator.constraints.Length; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2022/2/13 1:26 下午 |
|||
* @DESC |
|||
*/ |
|||
@Data |
|||
public class HouseInfoModel { |
|||
|
|||
@ExcelProperty(value = "所属组织") |
|||
private String agencyName; |
|||
|
|||
@ExcelProperty(value = "所属网格") |
|||
private String gridName; |
|||
|
|||
@ExcelProperty(value = "所属小区") |
|||
@Length(max=50,message = "不能超过50个字") |
|||
private String neighborHoodName; |
|||
|
|||
@ExcelProperty(value = "所属楼栋") |
|||
private String buildingName; |
|||
|
|||
@ExcelProperty(value = "单元号") |
|||
private Integer buildingUnit; |
|||
|
|||
@ExcelProperty(value = "门牌号") |
|||
private String doorName; |
|||
|
|||
@ExcelProperty(value = "房屋类型") |
|||
private String houseType; |
|||
|
|||
@ExcelProperty(value = "房屋用途") |
|||
private String purpose; |
|||
|
|||
@ExcelProperty(value = "出租") |
|||
private String rentFlagString; |
|||
|
|||
@ExcelProperty(value = "房主姓名") |
|||
private String ownerName; |
|||
|
|||
@ExcelProperty(value = "房主电话") |
|||
private String ownerPhone; |
|||
|
|||
@ExcelProperty(value = "房主身份证") |
|||
private String ownerIdCard; |
|||
|
|||
} |
@ -0,0 +1,325 @@ |
|||
package com.epmet.model; |
|||
|
|||
import com.alibaba.excel.context.AnalysisContext; |
|||
import com.alibaba.excel.event.AnalysisEventListener; |
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import com.epmet.commons.tools.exception.EpmetException; |
|||
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|||
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; |
|||
import com.epmet.commons.tools.redis.common.bean.GridInfoCache; |
|||
import com.epmet.commons.tools.utils.ConvertUtils; |
|||
import com.epmet.constant.CustomerGridConstant; |
|||
import com.epmet.dao.IcBuildingDao; |
|||
import com.epmet.dto.ImportGeneralDTO; |
|||
import com.epmet.dto.form.ImportInfoFormDTO; |
|||
import com.epmet.dto.result.ImportResultDTO; |
|||
import com.epmet.enums.BuildingTypeEnums; |
|||
import com.epmet.redis.IcHouseRedis; |
|||
import com.epmet.service.IcNeighborHoodService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.util.CollectionUtils; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2022/2/15 10:06 上午 |
|||
* @DESC |
|||
*/ |
|||
public class ImportBuildingInfoListener extends AnalysisEventListener<BuildingInfoModel> { |
|||
|
|||
List<Integer> nums = new ArrayList<>(); |
|||
Integer num = NumConstant.ZERO; |
|||
|
|||
List<ImportGeneralDTO> needDisposeList = new ArrayList<>(); |
|||
List<ImportGeneralDTO> needInsertList = new ArrayList<>(); |
|||
|
|||
String gridName = null; |
|||
String agencyName = null; |
|||
|
|||
Map<String, Object> gridInfos = null; |
|||
List<ImportGeneralDTO> gridInfoDTOs = null; |
|||
Map<String, Object> neighborHoodInfos = null; |
|||
List<ImportGeneralDTO> neighborHoodInfoDTOs = null; |
|||
ImportGeneralDTO neighborHoodGeneralDTO = null; |
|||
Map<String, Object> buildingInfos = null; |
|||
List<ImportGeneralDTO> buildingInfoDTOs = null; |
|||
ImportGeneralDTO buildingGeneralDTO = null; |
|||
|
|||
private ImportInfoFormDTO formDTO; |
|||
private IcHouseRedis icHouseRedis; |
|||
private IcBuildingDao icBuildingDao; |
|||
private IcNeighborHoodService neighborHoodService; |
|||
|
|||
public ImportBuildingInfoListener(ImportInfoFormDTO formDTO, IcHouseRedis icHouseRedis,IcBuildingDao icBuildingDao,IcNeighborHoodService neighborHoodService){ |
|||
this.formDTO = formDTO; |
|||
this.icHouseRedis = icHouseRedis; |
|||
this.icBuildingDao = icBuildingDao; |
|||
this.neighborHoodService = neighborHoodService; |
|||
} |
|||
|
|||
@Override |
|||
public void invoke(BuildingInfoModel data, AnalysisContext context) { |
|||
if (null == data){ |
|||
return; |
|||
} |
|||
num = num + NumConstant.ONE; |
|||
ImportGeneralDTO dto = ConvertUtils.sourceToTarget(data, ImportGeneralDTO.class); |
|||
dto.setNum(num); |
|||
dto.setCustomerId(formDTO.getCustomerId()); |
|||
// 应产品要求添加
|
|||
if (StringUtils.isNotBlank(dto.getType()) && (!dto.getType().equals("商品房") && !dto.getType().equals("自建房")) && !dto.getType().equals("别墅")){ |
|||
nums.add(num); |
|||
return; |
|||
} |
|||
dto.setType(BuildingTypeEnums.getKeyByValue(dto.getType())); |
|||
if (formDTO.getOrgType().equals(CustomerGridConstant.NEIGHBORHOOD)){ |
|||
disposeNeighborHoodBuilding(dto); |
|||
}else if (formDTO.getOrgType().equals(CustomerGridConstant.GRID)){ |
|||
disposeGridBuilding(dto); |
|||
}else if (formDTO.getOrgType().equals(CustomerGridConstant.AGENCY)){ |
|||
disposeAgencyBuilding(dto); |
|||
} |
|||
// 数据筛选完毕,当num每满100条,处理一次
|
|||
if (num%NumConstant.ONE_HUNDRED == NumConstant.ZERO){ |
|||
finalDispose(); |
|||
} |
|||
} |
|||
|
|||
public void finalDispose(){ |
|||
if (CollectionUtils.isEmpty(needDisposeList)){ |
|||
return; |
|||
} |
|||
Map<String, Long> groupByAllName = needDisposeList.stream().collect(Collectors.groupingBy( |
|||
n -> n.getAgencyName() + "_" + n.getGridName() + "_" + |
|||
n.getNeighborHoodName() + "_" + n.getBuildingName(), Collectors.counting())); |
|||
groupByAllName.forEach((k,v) -> { |
|||
if (Integer.valueOf(v.toString()).compareTo(1) > 0){ |
|||
for (ImportGeneralDTO r : needDisposeList) { |
|||
if (k.equals(r.getAgencyName() + "_" + r.getGridName() + "_" + |
|||
r.getNeighborHoodName() + "_" + r.getBuildingName())){ |
|||
// 集合里重复的
|
|||
if (r.getExistStatus()){ |
|||
nums.add(r.getNum()); |
|||
} |
|||
r.setExistStatus(true); |
|||
} |
|||
} |
|||
} |
|||
}); |
|||
Map<Boolean, List<ImportGeneralDTO>> groupByStatus = needDisposeList.stream().collect(Collectors.groupingBy(ImportGeneralDTO::getExistStatus)); |
|||
List<ImportGeneralDTO> importGeneralDTOS = groupByStatus.get(false); |
|||
if (!CollectionUtils.isEmpty(importGeneralDTOS)){ |
|||
List<ImportGeneralDTO> importInfo = neighborHoodService.getImportInfo(formDTO, importGeneralDTOS); |
|||
Map<Boolean, List<ImportGeneralDTO>> groupByBuildingExistStatus = importInfo.stream().collect(Collectors.groupingBy(ImportGeneralDTO::getBuildingExistStatus)); |
|||
List<ImportGeneralDTO> existList = groupByBuildingExistStatus.get(true); |
|||
if (!CollectionUtils.isEmpty(existList)){ |
|||
existList.forEach(e -> { |
|||
nums.add(e.getNum()); |
|||
}); |
|||
} |
|||
} |
|||
// 清除
|
|||
needDisposeList = new ArrayList<>(); |
|||
needInsertList = new ArrayList<>(); |
|||
gridName = null; |
|||
agencyName = null; |
|||
gridInfos = null; |
|||
gridInfoDTOs = null; |
|||
neighborHoodInfos = null; |
|||
neighborHoodInfoDTOs = null; |
|||
neighborHoodGeneralDTO = null; |
|||
buildingInfos = null; |
|||
buildingInfoDTOs = null; |
|||
buildingGeneralDTO = null; |
|||
} |
|||
|
|||
public void fillData(ImportGeneralDTO dto, String orgType){ |
|||
if (orgType.equals(CustomerGridConstant.GRID) || orgType.equals(CustomerGridConstant.AGENCY)){ |
|||
List<String> gridIds = new ArrayList<>(); |
|||
if (orgType.equals(CustomerGridConstant.GRID)){ |
|||
gridIds = Arrays.asList(formDTO.getOrgId()); |
|||
}else if (orgType.equals(CustomerGridConstant.AGENCY)){ |
|||
gridIds = gridInfoDTOs.stream().map(m -> m.getGridId()).collect(Collectors.toList()); |
|||
} |
|||
neighborHoodInfos = null == neighborHoodInfos ? getNeighborHoodInfos(gridIds) : neighborHoodInfos; |
|||
Object cacheNeighBorHood = icHouseRedis.getTemporaryCacheNeighBorHood(formDTO.getCustomerId(), formDTO.getUserId(), formDTO.getOrgId() + "_" + dto.getNeighborHoodName()); |
|||
// 赋值小区ID
|
|||
dto.setNeighborHoodId(null == cacheNeighBorHood ? "" : cacheNeighBorHood.toString()); |
|||
} |
|||
if (StringUtils.isNotBlank(dto.getNeighborHoodId())){ |
|||
//小区ID不为空赋值楼栋ID
|
|||
buildingInfos = null == buildingInfos ? getBuildingInfos(dto.getNeighborHoodId()) : buildingInfos; |
|||
Object cacheBuilding = icHouseRedis.getTemporaryCacheBuilding(formDTO.getCustomerId(), formDTO.getUserId(), dto.getNeighborHoodId() + "_" + dto.getBuildingName()); |
|||
dto.setBuildingId(null == cacheBuilding ? "" : cacheBuilding.toString()); |
|||
if (StringUtils.isNotBlank(dto.getBuildingId())){ |
|||
// 说明数据库已存在此楼栋,不需添加
|
|||
nums.add(num); |
|||
}else { |
|||
needDisposeList.add(dto); |
|||
} |
|||
}else { |
|||
needDisposeList.add(dto); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @Description 左侧树点击小区时调用 |
|||
* @param dto |
|||
* @author zxc |
|||
* @date 2022/2/15 10:41 上午 |
|||
*/ |
|||
public void disposeNeighborHoodBuilding(ImportGeneralDTO dto){ |
|||
neighborHoodGeneralDTO = null == neighborHoodGeneralDTO ? icBuildingDao.selectNeighborHoodById(formDTO.getOrgId()) : neighborHoodGeneralDTO; |
|||
//排除不是本小区的
|
|||
if (!dto.getNeighborHoodName().equals(neighborHoodGeneralDTO.getNeighborHoodName())){ |
|||
nums.add(num); |
|||
}else { |
|||
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(neighborHoodGeneralDTO.getGridId()); |
|||
if (null == gridInfo){ |
|||
throw new EpmetException("查询网格失败..."); |
|||
} |
|||
// 1.排除网格名不一样但小区名一样 2.排除组织不一样,网格一样,小区一样
|
|||
if ((!gridInfo.getGridName().equals(dto.getGridName()) && neighborHoodGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName())) || |
|||
(!gridInfo.getAgencyName().equals(dto.getAgencyName()) && gridInfo.getGridName().equals(dto.getGridName()) && neighborHoodGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName()))){ |
|||
nums.add(num); |
|||
return; |
|||
} |
|||
dto.setNeighborHoodId(formDTO.getOrgId()); |
|||
dto.setGridId(neighborHoodGeneralDTO.getGridId()); |
|||
dto.setAgencyId(neighborHoodGeneralDTO.getAgencyId()); |
|||
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); |
|||
if (null == agencyInfo){ |
|||
throw new EpmetException("查询组织信息失败..."); |
|||
} |
|||
dto.setPid(agencyInfo.getPid()); |
|||
dto.setPids(agencyInfo.getPids()); |
|||
// 填充各种ID
|
|||
fillData(dto,CustomerGridConstant.NEIGHBORHOOD); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @Description 左侧树点击网格时调用 |
|||
* @param dto |
|||
* @author zxc |
|||
* @date 2022/2/15 10:41 上午 |
|||
*/ |
|||
public void disposeGridBuilding(ImportGeneralDTO dto){ |
|||
gridName = null == gridName ? icBuildingDao.selectGridNameById(formDTO.getOrgId()) : gridName; |
|||
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(formDTO.getOrgId()); |
|||
if (null == gridInfo){ |
|||
throw new EpmetException("查询网格失败..."); |
|||
} |
|||
//排除不是本网格的 gridName不一样排除,gridName一样但是agencyName不一样也得排除
|
|||
if (dto.getGridName().compareTo(gridName) != 0 || (!dto.getAgencyName().equals(gridInfo.getAgencyName()) && dto.getGridName().equals(gridName))){ |
|||
nums.add(num); |
|||
}else { |
|||
//
|
|||
dto.setGridId(formDTO.getOrgId()); |
|||
dto.setAgencyId(gridInfo.getPid()); |
|||
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); |
|||
if (null == agencyInfo){ |
|||
throw new EpmetException("查询组织信息失败..."); |
|||
} |
|||
dto.setPid(agencyInfo.getPid()); |
|||
dto.setPids(agencyInfo.getPids()); |
|||
// 填充各种ID
|
|||
fillData(dto, CustomerGridConstant.GRID); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @Description 左侧树点击组织时调用 |
|||
* @param dto |
|||
* @author zxc |
|||
* @date 2022/2/15 10:41 上午 |
|||
*/ |
|||
public void disposeAgencyBuilding(ImportGeneralDTO dto){ |
|||
agencyName = null == agencyName ? icBuildingDao.selectAgencyNameById(formDTO.getOrgId()) : agencyName; |
|||
//排除不是本组织的
|
|||
if (!dto.getAgencyName().equals(agencyName)){ |
|||
nums.add(num); |
|||
}else { |
|||
// 根据组织查询出所有网格,甩出不是本组织下的网格
|
|||
gridInfos = null == gridInfos ? getGridInfos(formDTO.getOrgId()) : gridInfos; |
|||
if (null == gridInfos){ |
|||
// 组织下确实不存在网格
|
|||
nums.add(num); |
|||
return; |
|||
} |
|||
// 根据网格名对比,没有找到的就把行号加入到未执行成功队列中
|
|||
Object cacheGridName = icHouseRedis.getTemporaryCacheGrid(formDTO.getCustomerId(), formDTO.getUserId(), dto.getGridName()); |
|||
if (null == cacheGridName){ |
|||
nums.add(num); |
|||
return; |
|||
} |
|||
dto.setGridId(cacheGridName.toString()); |
|||
dto.setAgencyId(formDTO.getOrgId()); |
|||
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); |
|||
if (null == agencyInfo){ |
|||
throw new EpmetException("查询组织信息失败..."); |
|||
} |
|||
dto.setPid(agencyInfo.getPid()); |
|||
dto.setPids(agencyInfo.getPids()); |
|||
// 填充各种ID
|
|||
fillData(dto,CustomerGridConstant.AGENCY); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @Description 获取网格信息 |
|||
* @param orgId |
|||
* @author zxc |
|||
* @date 2022/2/14 9:57 上午 |
|||
*/ |
|||
public Map<String,Object> getGridInfos(String orgId){ |
|||
gridInfoDTOs = icBuildingDao.selectAllGridByOrgId(orgId); |
|||
gridInfos = gridInfoDTOs.stream().collect(Collectors.toMap(n -> n.getGridName(), n -> n.getGridId())); |
|||
icHouseRedis.setTemporaryCacheGrid(formDTO.getCustomerId(), gridInfos, formDTO.getUserId()); |
|||
return gridInfos; |
|||
} |
|||
|
|||
/** |
|||
* @Description 获取网格下的小区 |
|||
* @param gridIds |
|||
* @author zxc |
|||
* @date 2022/2/14 10:16 上午 |
|||
*/ |
|||
public Map<String,Object> getNeighborHoodInfos(List<String> gridIds){ |
|||
neighborHoodInfoDTOs = icBuildingDao.selectAllNeighborHoodByGridIds(gridIds); |
|||
neighborHoodInfos = neighborHoodInfoDTOs.stream().collect(Collectors.toMap(n -> n.getGridId() + "_" + n.getNeighborHoodName(), n -> n.getNeighborHoodId())); |
|||
icHouseRedis.setTemporaryCacheNeighBorHood(formDTO.getCustomerId(), neighborHoodInfos, formDTO.getUserId()); |
|||
return neighborHoodInfos; |
|||
} |
|||
|
|||
/** |
|||
* @Description 获取小区下的楼栋 |
|||
* @param neighborHoodId |
|||
* @author zxc |
|||
* @date 2022/2/14 1:32 下午 |
|||
*/ |
|||
public Map<String,Object> getBuildingInfos(String neighborHoodId){ |
|||
buildingInfoDTOs = icBuildingDao.selectAllBuildingByNeighborHoodId(neighborHoodId); |
|||
buildingInfos = buildingInfoDTOs.stream().collect(Collectors.toMap(n -> n.getNeighborHoodId() + "_" + n.getBuildingName(), n -> n.getBuildingId())); |
|||
icHouseRedis.setTemporaryCacheBuilding(formDTO.getCustomerId(), buildingInfos, formDTO.getUserId()); |
|||
return buildingInfos; |
|||
} |
|||
|
|||
@Override |
|||
public void doAfterAllAnalysed(AnalysisContext context) { |
|||
finalDispose(); |
|||
// 删除缓存
|
|||
icHouseRedis.delTemporaryCacheGrids(formDTO.getCustomerId(), formDTO.getUserId()); |
|||
icHouseRedis.delTemporaryCacheNeighBorHood(formDTO.getCustomerId(), formDTO.getUserId()); |
|||
icHouseRedis.delTemporaryCacheBuilding(formDTO.getCustomerId(), formDTO.getUserId()); |
|||
icHouseRedis.delTemporaryCacheBuildingUnit(formDTO.getCustomerId(), formDTO.getUserId()); |
|||
icHouseRedis.delTemporaryCacheHouses(formDTO.getCustomerId(), formDTO.getUserId()); |
|||
// 放结果
|
|||
icHouseRedis.setImportResultDTO(formDTO.getCustomerId(), formDTO.getUserId(), new ImportResultDTO(nums,num)); |
|||
} |
|||
} |
@ -0,0 +1,450 @@ |
|||
package com.epmet.model; |
|||
|
|||
import com.alibaba.excel.context.AnalysisContext; |
|||
import com.alibaba.excel.event.AnalysisEventListener; |
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import com.epmet.commons.tools.exception.EpmetException; |
|||
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|||
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; |
|||
import com.epmet.commons.tools.redis.common.bean.GridInfoCache; |
|||
import com.epmet.commons.tools.utils.ConvertUtils; |
|||
import com.epmet.constant.CustomerGridConstant; |
|||
import com.epmet.dao.IcBuildingDao; |
|||
import com.epmet.dto.ImportGeneralDTO; |
|||
import com.epmet.dto.form.ImportInfoFormDTO; |
|||
import com.epmet.dto.result.ImportResultDTO; |
|||
import com.epmet.entity.IcHouseEntity; |
|||
import com.epmet.enums.HousePurposeEnums; |
|||
import com.epmet.enums.HouseRentFlagEnums; |
|||
import com.epmet.enums.HouseTypeEnums; |
|||
import com.epmet.redis.IcHouseRedis; |
|||
import com.epmet.service.IcHouseService; |
|||
import com.epmet.service.IcNeighborHoodService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
import org.springframework.util.CollectionUtils; |
|||
|
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2022/2/13 1:25 下午 |
|||
* @DESC |
|||
*/ |
|||
public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoModel> { |
|||
|
|||
List<Integer> nums = new ArrayList<>(); |
|||
Integer num = NumConstant.ZERO; |
|||
|
|||
List<ImportGeneralDTO> needDisposeList = new ArrayList<>(); |
|||
List<ImportGeneralDTO> needInsertList = new ArrayList<>(); |
|||
|
|||
String gridName = null; |
|||
String agencyName = null; |
|||
|
|||
Map<String, Object> gridInfos = null; |
|||
List<ImportGeneralDTO> gridInfoDTOs = null; |
|||
Map<String, Object> neighborHoodInfos = null; |
|||
List<ImportGeneralDTO> neighborHoodInfoDTOs = null; |
|||
ImportGeneralDTO neighborHoodGeneralDTO = null; |
|||
Map<String, Object> buildingInfos = null; |
|||
List<ImportGeneralDTO> buildingInfoDTOs = null; |
|||
ImportGeneralDTO buildingGeneralDTO = null; |
|||
Map<String, Object> buildingUnitInfos = null; |
|||
List<ImportGeneralDTO> buildingUnitInfoDTOs = null; |
|||
|
|||
private ImportInfoFormDTO formDTO; |
|||
private IcBuildingDao icBuildingDao; |
|||
private IcHouseRedis icHouseRedis; |
|||
private IcNeighborHoodService neighborHoodService; |
|||
private IcHouseService icHouseService; |
|||
|
|||
public ImportHouseInfoListener(ImportInfoFormDTO formDTO,IcBuildingDao icBuildingDao, IcHouseRedis icHouseRedis,IcNeighborHoodService neighborHoodService, IcHouseService icHouseService){ |
|||
this.formDTO = formDTO; |
|||
this.icBuildingDao = icBuildingDao; |
|||
this.icHouseRedis = icHouseRedis; |
|||
this.neighborHoodService = neighborHoodService; |
|||
this.icHouseService = icHouseService; |
|||
} |
|||
|
|||
@Override |
|||
public void invoke(HouseInfoModel data, AnalysisContext context) { |
|||
if (null == data){ |
|||
return; |
|||
} |
|||
num = num + NumConstant.ONE; |
|||
ImportGeneralDTO dto = ConvertUtils.sourceToTarget(data, ImportGeneralDTO.class); |
|||
dto.setNum(num); |
|||
dto.setCustomerId(formDTO.getCustomerId()); |
|||
// 应产品要求
|
|||
if (StringUtils.isNotBlank(dto.getHouseType()) ){ |
|||
if( !"楼房".equals(dto.getHouseType()) && !dto.getHouseType().equals("平房") && !dto.getHouseType().equals("别墅") ){ |
|||
nums.add(num); |
|||
return; |
|||
} |
|||
} |
|||
dto.setHouseType(HouseTypeEnums.getKeyByValue(dto.getHouseType())); |
|||
|
|||
if (StringUtils.isNotBlank(dto.getPurpose()) && (!dto.getPurpose().equals("住宅") && |
|||
!dto.getPurpose().equals("商业") && |
|||
!dto.getPurpose().equals("办公") && |
|||
!dto.getPurpose().equals("工业") && |
|||
!dto.getPurpose().equals("仓储") && |
|||
!dto.getPurpose().equals("商住混用") && |
|||
!dto.getPurpose().equals("其他")) ){ |
|||
nums.add(num); |
|||
return; |
|||
} |
|||
dto.setPurpose(HousePurposeEnums.getKeyByValue(dto.getPurpose())); |
|||
if (StringUtils.isNotBlank(dto.getRentFlagString()) && (!dto.getRentFlagString().equals("是") && !dto.getRentFlagString().equals("否"))){ |
|||
nums.add(num); |
|||
return; |
|||
} |
|||
dto.setRentFlag(HouseRentFlagEnums.getCodeByName(dto.getRentFlagString())); |
|||
dto.setHouseName(dto.getBuildingName()+"-"+dto.getBuildingUnit()+"-"+dto.getDoorName()); |
|||
if (formDTO.getOrgType().equals(CustomerGridConstant.BUILDING)){ |
|||
disposeBuildingHouse(dto); |
|||
}else if (formDTO.getOrgType().equals(CustomerGridConstant.NEIGHBORHOOD)){ |
|||
disposeNeighborHoodHouse(dto); |
|||
}else if (formDTO.getOrgType().equals(CustomerGridConstant.GRID)){ |
|||
disposeGridHouse(dto); |
|||
}else if (formDTO.getOrgType().equals(CustomerGridConstant.AGENCY)){ |
|||
disposeAgencyHouse(dto); |
|||
} |
|||
// 数据筛选完毕,当num每满100条,处理一次
|
|||
if (num%NumConstant.ONE_HUNDRED == NumConstant.ZERO){ |
|||
finalDispose(); |
|||
} |
|||
} |
|||
|
|||
public void finalDispose(){ |
|||
if (!CollectionUtils.isEmpty(needDisposeList)){ |
|||
List<ImportGeneralDTO> importInfo = neighborHoodService.getImportInfo(formDTO, needDisposeList); |
|||
needInsertList.addAll(importInfo); |
|||
} |
|||
if (CollectionUtils.isEmpty(needInsertList)){ |
|||
return; |
|||
} |
|||
Map<String, Long> collect = needInsertList.stream().collect(Collectors.groupingBy(n -> n.getBuildingUnitId() + "_" + n.getDoorName(), Collectors.counting())); |
|||
collect.forEach((k,v) -> { |
|||
if (Integer.valueOf(v.toString()).compareTo(1) > 0){ |
|||
for (ImportGeneralDTO r : needInsertList) { |
|||
if (k.equals(r.getBuildingUnitId()+"_"+r.getDoorName())){ |
|||
// 集合里重复的
|
|||
if (r.getExistStatus()){ |
|||
nums.add(r.getNum()); |
|||
} |
|||
r.setExistStatus(true); |
|||
} |
|||
} |
|||
} |
|||
}); |
|||
// 根据单元ID_doorName查询已存在的
|
|||
List<String> ids = needInsertList.stream().map(m -> m.getBuildingUnitId() + "_" + m.getDoorName()).distinct().collect(Collectors.toList()); |
|||
List<String> existHouses = icBuildingDao.selectExistHouse(ids); |
|||
existHouses.forEach(e -> { |
|||
for (ImportGeneralDTO n : needInsertList) { |
|||
if ((n.getBuildingUnitId()+"_"+n.getDoorName()).equals(e)){ |
|||
// 库里存在的
|
|||
if (n.getExistStatus()){ |
|||
nums.add(n.getNum()); |
|||
} |
|||
n.setExistStatus(true); |
|||
} |
|||
} |
|||
}); |
|||
// 根据存在状态分组
|
|||
Map<Boolean, List<ImportGeneralDTO>> groupByExistStatus = needInsertList.stream().collect(Collectors.groupingBy(ImportGeneralDTO::getExistStatus)); |
|||
List<ImportGeneralDTO> importGeneralDTOS = groupByExistStatus.get(false); |
|||
houseInsert(importGeneralDTOS); |
|||
// 清除
|
|||
needDisposeList = new ArrayList<>(); |
|||
needInsertList = new ArrayList<>(); |
|||
gridName = null; |
|||
agencyName = null; |
|||
gridInfos = null; |
|||
gridInfoDTOs = null; |
|||
neighborHoodInfos = null; |
|||
neighborHoodInfoDTOs = null; |
|||
neighborHoodGeneralDTO = null; |
|||
buildingInfos = null; |
|||
buildingInfoDTOs = null; |
|||
buildingGeneralDTO = null; |
|||
buildingUnitInfos = null; |
|||
buildingUnitInfoDTOs = null; |
|||
} |
|||
|
|||
/** |
|||
* @Description 左侧树点击楼栋时调用 |
|||
* @param dto |
|||
* @author zxc |
|||
* @date 2022/2/14 3:23 下午 |
|||
*/ |
|||
public void disposeBuildingHouse(ImportGeneralDTO dto){ |
|||
buildingGeneralDTO = null == buildingGeneralDTO ? icBuildingDao.selectBuildingById(formDTO.getOrgId()) : buildingGeneralDTO; |
|||
// 排除不是本楼的
|
|||
if (!dto.getBuildingName().equals(buildingGeneralDTO.getBuildingName())){ |
|||
nums.add(num); |
|||
}else { |
|||
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(buildingGeneralDTO.getGridId()); |
|||
if (null == gridInfo){ |
|||
throw new EpmetException("查询网格失败..."); |
|||
} |
|||
// 排除 1、小区名不一样&&楼栋名一样 2、网格名不一样&&小区名一样&&楼名一样 3、组织名不一样&&网格名一样&&小区名一样&&楼名一样
|
|||
if ((!buildingGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName()) && buildingGeneralDTO.getBuildingName().equals(dto.getBuildingName())) |
|||
|| (!gridInfo.getGridName().equals(dto.getGridName())&&buildingGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName()) && buildingGeneralDTO.getBuildingName().equals(dto.getBuildingName())) |
|||
|| (!gridInfo.getAgencyName().equals(dto.getAgencyName())&&gridInfo.getGridName().equals(dto.getGridName())&&buildingGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName()) && buildingGeneralDTO.getBuildingName().equals(dto.getBuildingName()))){ |
|||
nums.add(num); |
|||
return; |
|||
} |
|||
dto.setBuildingId(formDTO.getOrgId()); |
|||
dto.setNeighborHoodId(buildingGeneralDTO.getNeighborHoodId()); |
|||
dto.setGridId(buildingGeneralDTO.getGridId()); |
|||
dto.setAgencyId(buildingGeneralDTO.getAgencyId()); |
|||
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); |
|||
if (null == agencyInfo){ |
|||
throw new EpmetException("查询组织信息失败..."); |
|||
} |
|||
dto.setPid(agencyInfo.getPid()); |
|||
dto.setPids(agencyInfo.getPids()); |
|||
dto.setType(buildingGeneralDTO.getType()); |
|||
dto.setTotalHouseNum(buildingGeneralDTO.getTotalHouseNum()); |
|||
dto.setTotalFloorNum(buildingGeneralDTO.getTotalFloorNum()); |
|||
dto.setTotalUnitNum(buildingGeneralDTO.getTotalUnitNum()); |
|||
// 补充单元ID
|
|||
buildingUnitInfos = null == buildingUnitInfos ? getBuildingUnitInfos(dto.getBuildingId()) : buildingUnitInfos; |
|||
Object cacheBuildingUnit = icHouseRedis.getTemporaryCacheBuildingUnit(formDTO.getCustomerId(), formDTO.getUserId(), dto.getBuildingId() + "_" + dto.getBuildingUnit()); |
|||
dto.setBuildingUnitId(null == cacheBuildingUnit ? "" : cacheBuildingUnit.toString()); |
|||
if (StringUtils.isNotBlank(dto.getBuildingUnitId())){ |
|||
// 所有ID补充完毕,不需调用补用方法
|
|||
needInsertList.add(dto); |
|||
}else { |
|||
needDisposeList.add(dto); |
|||
} |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @Description 左侧树点击小区时调用 |
|||
* @param dto |
|||
* @author zxc |
|||
* @date 2022/2/14 3:23 下午 |
|||
*/ |
|||
public void disposeNeighborHoodHouse(ImportGeneralDTO dto){ |
|||
neighborHoodGeneralDTO = null == neighborHoodGeneralDTO ? icBuildingDao.selectNeighborHoodById(formDTO.getOrgId()) : neighborHoodGeneralDTO; |
|||
//排除不是本小区的
|
|||
if (!dto.getNeighborHoodName().equals(neighborHoodGeneralDTO.getNeighborHoodName())){ |
|||
nums.add(num); |
|||
}else { |
|||
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(neighborHoodGeneralDTO.getGridId()); |
|||
if (null == gridInfo){ |
|||
throw new EpmetException("查询网格失败..."); |
|||
} |
|||
// 1.排除网格名不一样但小区名一样 2.排除组织不一样,网格一样,小区一样
|
|||
if ((!gridInfo.getGridName().equals(dto.getGridName()) && neighborHoodGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName())) || |
|||
(!gridInfo.getAgencyName().equals(dto.getAgencyName()) && gridInfo.getGridName().equals(dto.getGridName()) && neighborHoodGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName()))){ |
|||
nums.add(num); |
|||
return; |
|||
} |
|||
dto.setNeighborHoodId(formDTO.getOrgId()); |
|||
dto.setGridId(neighborHoodGeneralDTO.getGridId()); |
|||
dto.setAgencyId(neighborHoodGeneralDTO.getAgencyId()); |
|||
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); |
|||
if (null == agencyInfo){ |
|||
throw new EpmetException("查询组织信息失败..."); |
|||
} |
|||
dto.setPid(agencyInfo.getPid()); |
|||
dto.setPids(agencyInfo.getPids()); |
|||
// 填充各种ID
|
|||
fillData(dto,CustomerGridConstant.NEIGHBORHOOD); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @Description 左侧树点击网格时调用 |
|||
* @param dto |
|||
* @author zxc |
|||
* @date 2022/2/14 2:14 下午 |
|||
*/ |
|||
public void disposeGridHouse(ImportGeneralDTO dto){ |
|||
gridName = null == gridName ? icBuildingDao.selectGridNameById(formDTO.getOrgId()) : gridName; |
|||
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(formDTO.getOrgId()); |
|||
if (null == gridInfo){ |
|||
throw new EpmetException("查询网格失败..."); |
|||
} |
|||
//排除不是本网格的 gridName不一样排除,gridName一样但是agencyName不一样也得排除
|
|||
if (dto.getGridName().compareTo(gridName) != 0 || (!dto.getAgencyName().equals(gridInfo.getAgencyName()) && dto.getGridName().equals(gridName))){ |
|||
nums.add(num); |
|||
}else { |
|||
//
|
|||
dto.setGridId(formDTO.getOrgId()); |
|||
dto.setAgencyId(gridInfo.getPid()); |
|||
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); |
|||
if (null == agencyInfo){ |
|||
throw new EpmetException("查询组织信息失败..."); |
|||
} |
|||
dto.setPid(agencyInfo.getPid()); |
|||
dto.setPids(agencyInfo.getPids()); |
|||
// 填充各种ID
|
|||
fillData(dto, CustomerGridConstant.GRID); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @Description 左侧树点击组织时调用 |
|||
* @param dto |
|||
* @author zxc |
|||
* @date 2022/2/14 1:35 下午 |
|||
*/ |
|||
public void disposeAgencyHouse(ImportGeneralDTO dto){ |
|||
agencyName = null == agencyName ? icBuildingDao.selectAgencyNameById(formDTO.getOrgId()) : agencyName; |
|||
//排除不是本组织的
|
|||
if (!dto.getAgencyName().equals(agencyName)){ |
|||
nums.add(num); |
|||
}else { |
|||
// 根据组织查询出所有网格,甩出不是本组织下的网格
|
|||
gridInfos = null == gridInfos ? getGridInfos(formDTO.getOrgId()) : gridInfos; |
|||
if (null == gridInfos){ |
|||
// 组织下确实不存在网格
|
|||
nums.add(num); |
|||
return; |
|||
} |
|||
// 根据网格名对比,没有找到的就把行号加入到未执行成功队列中
|
|||
Object cacheGridName = icHouseRedis.getTemporaryCacheGrid(formDTO.getCustomerId(), formDTO.getUserId(), dto.getGridName()); |
|||
if (null == cacheGridName){ |
|||
nums.add(num); |
|||
return; |
|||
} |
|||
dto.setGridId(cacheGridName.toString()); |
|||
dto.setAgencyId(formDTO.getOrgId()); |
|||
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); |
|||
if (null == agencyInfo){ |
|||
throw new EpmetException("查询组织信息失败..."); |
|||
} |
|||
dto.setPid(agencyInfo.getPid()); |
|||
dto.setPids(agencyInfo.getPids()); |
|||
// 填充各种ID
|
|||
fillData(dto, CustomerGridConstant.AGENCY); |
|||
} |
|||
} |
|||
|
|||
public void fillData(ImportGeneralDTO dto, String orgType){ |
|||
if (orgType.equals(CustomerGridConstant.GRID) || orgType.equals(CustomerGridConstant.AGENCY)){ |
|||
List<String> gridIds = new ArrayList<>(); |
|||
if (orgType.equals(CustomerGridConstant.GRID)){ |
|||
gridIds = Arrays.asList(formDTO.getOrgId()); |
|||
}else if (orgType.equals(CustomerGridConstant.AGENCY)){ |
|||
gridIds = gridInfoDTOs.stream().map(m -> m.getGridId()).collect(Collectors.toList()); |
|||
} |
|||
neighborHoodInfos = null == neighborHoodInfos ? getNeighborHoodInfos(gridIds) : neighborHoodInfos; |
|||
Object cacheNeighBorHood = icHouseRedis.getTemporaryCacheNeighBorHood(formDTO.getCustomerId(), formDTO.getUserId(), dto.getGridId() + "_" + dto.getNeighborHoodName()); |
|||
// 赋值小区ID
|
|||
dto.setNeighborHoodId(null == cacheNeighBorHood ? "" : cacheNeighBorHood.toString()); |
|||
} |
|||
if (StringUtils.isNotBlank(dto.getNeighborHoodId())){ |
|||
//小区ID不为空赋值楼栋ID
|
|||
buildingInfos = null == buildingInfos ? getBuildingInfos(dto.getNeighborHoodId()) : buildingInfos; |
|||
Object cacheBuilding = icHouseRedis.getTemporaryCacheBuilding(formDTO.getCustomerId(), formDTO.getUserId(), dto.getNeighborHoodId() + "_" + dto.getBuildingName()); |
|||
dto.setBuildingId(null == cacheBuilding ? "" : cacheBuilding.toString()); |
|||
if (StringUtils.isNotBlank(dto.getBuildingId())){ |
|||
// 楼栋ID不为空赋值单元ID
|
|||
buildingUnitInfos = null == buildingUnitInfos ? getBuildingUnitInfos(dto.getBuildingId()) : buildingUnitInfos; |
|||
Object cacheBuildingUnit = icHouseRedis.getTemporaryCacheBuildingUnit(formDTO.getCustomerId(), formDTO.getUserId(), dto.getBuildingId() + "_" + dto.getBuildingUnit()); |
|||
dto.setBuildingUnitId(null == cacheBuildingUnit ? "" : cacheBuildingUnit.toString()); |
|||
if (StringUtils.isNotBlank(dto.getBuildingUnitId())){ |
|||
// 所有ID补充完毕,不需调用补用方法
|
|||
needInsertList.add(dto); |
|||
}else { |
|||
needDisposeList.add(dto); |
|||
} |
|||
}else { |
|||
needDisposeList.add(dto); |
|||
} |
|||
}else { |
|||
needDisposeList.add(dto); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @Description 获取网格信息 |
|||
* @param orgId |
|||
* @author zxc |
|||
* @date 2022/2/14 9:57 上午 |
|||
*/ |
|||
public Map<String,Object> getGridInfos(String orgId){ |
|||
gridInfoDTOs = icBuildingDao.selectAllGridByOrgId(orgId); |
|||
gridInfos = gridInfoDTOs.stream().collect(Collectors.toMap(n -> n.getGridName(), n -> n.getGridId())); |
|||
icHouseRedis.setTemporaryCacheGrid(formDTO.getCustomerId(), gridInfos, formDTO.getUserId()); |
|||
return gridInfos; |
|||
} |
|||
|
|||
/** |
|||
* @Description 获取网格下的小区 |
|||
* @param gridIds |
|||
* @author zxc |
|||
* @date 2022/2/14 10:16 上午 |
|||
*/ |
|||
public Map<String,Object> getNeighborHoodInfos(List<String> gridIds){ |
|||
neighborHoodInfoDTOs = icBuildingDao.selectAllNeighborHoodByGridIds(gridIds); |
|||
neighborHoodInfos = neighborHoodInfoDTOs.stream().collect(Collectors.toMap(n -> n.getGridId() + "_" + n.getNeighborHoodName(), n -> n.getNeighborHoodId())); |
|||
icHouseRedis.setTemporaryCacheNeighBorHood(formDTO.getCustomerId(), neighborHoodInfos, formDTO.getUserId()); |
|||
return neighborHoodInfos; |
|||
} |
|||
|
|||
/** |
|||
* @Description 获取小区下的楼栋 |
|||
* @param neighborHoodId |
|||
* @author zxc |
|||
* @date 2022/2/14 1:32 下午 |
|||
*/ |
|||
public Map<String,Object> getBuildingInfos(String neighborHoodId){ |
|||
buildingInfoDTOs = icBuildingDao.selectAllBuildingByNeighborHoodId(neighborHoodId); |
|||
buildingInfos = buildingInfoDTOs.stream().collect(Collectors.toMap(n -> n.getNeighborHoodId() + "_" + n.getBuildingName(), n -> n.getBuildingId())); |
|||
icHouseRedis.setTemporaryCacheBuilding(formDTO.getCustomerId(), buildingInfos, formDTO.getUserId()); |
|||
return buildingInfos; |
|||
} |
|||
|
|||
/** |
|||
* @Description 获取楼栋下的单元 |
|||
* @param buildingId |
|||
* @author zxc |
|||
* @date 2022/2/14 2:04 下午 |
|||
*/ |
|||
public Map<String,Object> getBuildingUnitInfos(String buildingId){ |
|||
buildingUnitInfoDTOs = icBuildingDao.selectAllBuildingUnitByBuildingId(buildingId); |
|||
if (!CollectionUtils.isEmpty(buildingUnitInfoDTOs)){ |
|||
buildingUnitInfos = buildingUnitInfoDTOs.stream().collect(Collectors.toMap(n -> n.getBuildingId() + "_" + n.getBuildingUnit(), n -> n.getBuildingUnitId())); |
|||
icHouseRedis.setTemporaryCacheBuildingUnit(formDTO.getCustomerId(), buildingUnitInfos, formDTO.getUserId()); |
|||
} |
|||
return buildingInfos; |
|||
} |
|||
|
|||
@Override |
|||
public void doAfterAllAnalysed(AnalysisContext context) { |
|||
finalDispose(); |
|||
// 删除缓存
|
|||
icHouseRedis.delTemporaryCacheGrids(formDTO.getCustomerId(), formDTO.getUserId()); |
|||
icHouseRedis.delTemporaryCacheNeighBorHood(formDTO.getCustomerId(), formDTO.getUserId()); |
|||
icHouseRedis.delTemporaryCacheBuilding(formDTO.getCustomerId(), formDTO.getUserId()); |
|||
icHouseRedis.delTemporaryCacheBuildingUnit(formDTO.getCustomerId(), formDTO.getUserId()); |
|||
icHouseRedis.delTemporaryCacheHouses(formDTO.getCustomerId(), formDTO.getUserId()); |
|||
// 放结果
|
|||
icHouseRedis.setImportResultDTO(formDTO.getCustomerId(), formDTO.getUserId(), new ImportResultDTO(nums,num)); |
|||
|
|||
} |
|||
|
|||
/** |
|||
* @Description 房屋信息插入 |
|||
* @param houses |
|||
* @author zxc |
|||
* @date 2022/2/14 5:21 下午 |
|||
*/ |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void houseInsert(List<ImportGeneralDTO> houses){ |
|||
if (!CollectionUtils.isEmpty(houses)){ |
|||
icHouseService.insertBatch(ConvertUtils.sourceToTarget(houses, IcHouseEntity.class)); |
|||
} |
|||
} |
|||
|
|||
} |
@ -0,0 +1,285 @@ |
|||
package com.epmet.model; |
|||
|
|||
import com.alibaba.excel.context.AnalysisContext; |
|||
import com.alibaba.excel.event.AnalysisEventListener; |
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import com.epmet.commons.tools.exception.EpmetException; |
|||
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|||
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; |
|||
import com.epmet.commons.tools.redis.common.bean.GridInfoCache; |
|||
import com.epmet.commons.tools.utils.ConvertUtils; |
|||
import com.epmet.constant.CustomerGridConstant; |
|||
import com.epmet.dao.IcBuildingDao; |
|||
import com.epmet.dao.IcPropertyManagementDao; |
|||
import com.epmet.dto.ImportGeneralDTO; |
|||
import com.epmet.dto.NeighborHoodAndManagementDTO; |
|||
import com.epmet.dto.form.ImportInfoFormDTO; |
|||
import com.epmet.dto.result.ImportResultDTO; |
|||
import com.epmet.entity.IcNeighborHoodPropertyEntity; |
|||
import com.epmet.entity.IcPropertyManagementEntity; |
|||
import com.epmet.redis.IcHouseRedis; |
|||
import com.epmet.service.IcNeighborHoodService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.util.CollectionUtils; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2022/2/15 2:16 下午 |
|||
* @DESC |
|||
*/ |
|||
public class ImportNeighborHoodInfoListener extends AnalysisEventListener<NeighborHoodInfoModel> { |
|||
|
|||
List<Integer> nums = new ArrayList<>(); |
|||
Integer num = NumConstant.ZERO; |
|||
|
|||
List<ImportGeneralDTO> needDisposeList = new ArrayList<>(); |
|||
List<ImportGeneralDTO> needInsertList = new ArrayList<>(); |
|||
|
|||
String gridName = null; |
|||
String agencyName = null; |
|||
|
|||
Map<String, Object> gridInfos = null; |
|||
List<ImportGeneralDTO> gridInfoDTOs = null; |
|||
Map<String, Object> neighborHoodInfos = null; |
|||
List<ImportGeneralDTO> neighborHoodInfoDTOs = null; |
|||
ImportGeneralDTO neighborHoodGeneralDTO = null; |
|||
|
|||
private ImportInfoFormDTO formDTO; |
|||
private IcHouseRedis icHouseRedis; |
|||
private IcBuildingDao icBuildingDao; |
|||
private IcNeighborHoodService neighborHoodService; |
|||
private IcPropertyManagementDao propertyManagementDao; |
|||
|
|||
public ImportNeighborHoodInfoListener(ImportInfoFormDTO formDTO, IcHouseRedis icHouseRedis,IcBuildingDao icBuildingDao,IcNeighborHoodService neighborHoodService, IcPropertyManagementDao propertyManagementDao){ |
|||
this.formDTO = formDTO; |
|||
this.icHouseRedis = icHouseRedis; |
|||
this.icBuildingDao = icBuildingDao; |
|||
this.neighborHoodService = neighborHoodService; |
|||
this.propertyManagementDao = propertyManagementDao; |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public void invoke(NeighborHoodInfoModel data, AnalysisContext context) { |
|||
if (null == data){ |
|||
return; |
|||
} |
|||
num = num + NumConstant.ONE; |
|||
ImportGeneralDTO dto = ConvertUtils.sourceToTarget(data, ImportGeneralDTO.class); |
|||
dto.setNum(num); |
|||
dto.setCustomerId(formDTO.getCustomerId()); |
|||
if (formDTO.getOrgType().equals(CustomerGridConstant.GRID)){ |
|||
disposeGridNeighborHood(dto); |
|||
}else if (formDTO.getOrgType().equals(CustomerGridConstant.AGENCY)){ |
|||
disposeAgencyNeighborHood(dto); |
|||
} |
|||
// 数据筛选完毕,当num每满100条,处理一次
|
|||
if (num%NumConstant.ONE_HUNDRED == NumConstant.ZERO){ |
|||
finalDispose(); |
|||
} |
|||
} |
|||
|
|||
public void finalDispose(){ |
|||
if (CollectionUtils.isEmpty(needDisposeList)){ |
|||
return; |
|||
} |
|||
Map<String, Long> groupByAllName = needDisposeList.stream().collect(Collectors.groupingBy( |
|||
n -> n.getAgencyName() + "_" + n.getGridName() + "_" + n.getNeighborHoodName(), Collectors.counting())); |
|||
groupByAllName.forEach((k,v) -> { |
|||
if (Integer.valueOf(v.toString()).compareTo(1) > 0){ |
|||
for (ImportGeneralDTO r : needDisposeList) { |
|||
if (k.equals(r.getAgencyName() + "_" + r.getGridName() + "_" + r.getNeighborHoodName())){ |
|||
// 集合里重复的
|
|||
if (r.getExistStatus()){ |
|||
nums.add(r.getNum()); |
|||
} |
|||
r.setExistStatus(true); |
|||
} |
|||
} |
|||
} |
|||
}); |
|||
Map<Boolean, List<ImportGeneralDTO>> groupByStatus = needDisposeList.stream().collect(Collectors.groupingBy(ImportGeneralDTO::getExistStatus)); |
|||
List<ImportGeneralDTO> importGeneralDTOS = groupByStatus.get(false); |
|||
if (!CollectionUtils.isEmpty(importGeneralDTOS)){ |
|||
List<ImportGeneralDTO> importInfo = neighborHoodService.getImportInfo(formDTO, importGeneralDTOS); |
|||
Map<Boolean, List<ImportGeneralDTO>> groupByBuildingExistStatus = importInfo.stream().collect(Collectors.groupingBy(ImportGeneralDTO::getNeighborHoodExistStatus)); |
|||
List<ImportGeneralDTO> existList = groupByBuildingExistStatus.get(true); |
|||
if (!CollectionUtils.isEmpty(existList)){ |
|||
existList.forEach(e -> { |
|||
nums.add(e.getNum()); |
|||
}); |
|||
} |
|||
List<ImportGeneralDTO> notExistList = groupByBuildingExistStatus.get(false); |
|||
if (!CollectionUtils.isEmpty(notExistList)){ |
|||
// 物业表插入
|
|||
List<String> propertyNames = notExistList.stream().filter(n -> StringUtils.isNotBlank(n.getPropertyName())).map(m -> m.getPropertyName()).distinct().collect(Collectors.toList()); |
|||
List<String> disposePropertyNames = notExistList.stream().filter(n -> StringUtils.isNotBlank(n.getPropertyName())).map(m -> m.getPropertyName()).distinct().collect(Collectors.toList()); |
|||
if (!CollectionUtils.isEmpty(propertyNames)){ |
|||
List<String> existPropertyNames = propertyManagementDao.selectExistNames(propertyNames); |
|||
disposePropertyNames.removeAll(existPropertyNames); |
|||
List<IcPropertyManagementEntity> propertyManagementEntities = new ArrayList<>(); |
|||
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(disposePropertyNames)){ |
|||
disposePropertyNames.forEach(name -> { |
|||
IcPropertyManagementEntity e = new IcPropertyManagementEntity(); |
|||
e.setName(name); |
|||
propertyManagementEntities.add(e); |
|||
}); |
|||
} |
|||
neighborHoodService.insertPropertyManagement(propertyManagementEntities); |
|||
|
|||
// 小区物业关系表插入
|
|||
List<NeighborHoodAndManagementDTO> neighborHoodAndManagementDTOS = ConvertUtils.sourceToTarget(notExistList, NeighborHoodAndManagementDTO.class); |
|||
List<IcPropertyManagementEntity> propertyManagementInfos = propertyManagementDao.selectIdByName(propertyNames); |
|||
neighborHoodAndManagementDTOS.forEach(n -> propertyManagementInfos.stream().filter(p -> p.getName().equals(n.getPropertyName())) |
|||
.forEach(p -> { |
|||
n.setPropertyId(p.getId()); |
|||
n.setNeighborHoodId(n.getNeighborHoodId()); |
|||
})); |
|||
List<IcNeighborHoodPropertyEntity> icNeighborHoodPropertyEntities = ConvertUtils.sourceToTarget(neighborHoodAndManagementDTOS, IcNeighborHoodPropertyEntity.class); |
|||
neighborHoodService.neighborHoodPropertyInsert(icNeighborHoodPropertyEntities); |
|||
} |
|||
} |
|||
} |
|||
|
|||
// 清除
|
|||
needDisposeList = new ArrayList<>(); |
|||
needInsertList = new ArrayList<>(); |
|||
gridName = null; |
|||
agencyName = null; |
|||
gridInfos = null; |
|||
gridInfoDTOs = null; |
|||
neighborHoodInfos = null; |
|||
neighborHoodInfoDTOs = null; |
|||
neighborHoodGeneralDTO = null; |
|||
} |
|||
|
|||
/** |
|||
* @Description 左侧树点击网格时调用 |
|||
* @param dto |
|||
* @author zxc |
|||
* @date 2022/2/15 2:37 下午 |
|||
*/ |
|||
public void disposeGridNeighborHood(ImportGeneralDTO dto){ |
|||
gridName = null == gridName ? icBuildingDao.selectGridNameById(formDTO.getOrgId()) : gridName; |
|||
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(formDTO.getOrgId()); |
|||
if (null == gridInfo){ |
|||
throw new EpmetException("查询网格失败..."); |
|||
} |
|||
//排除不是本网格的 gridName不一样排除,gridName一样但是agencyName不一样也得排除
|
|||
if (dto.getGridName().compareTo(gridName) != 0 || (!dto.getAgencyName().equals(gridInfo.getAgencyName()) && dto.getGridName().equals(gridName))){ |
|||
nums.add(num); |
|||
}else { |
|||
//
|
|||
dto.setGridId(formDTO.getOrgId()); |
|||
dto.setAgencyId(gridInfo.getPid()); |
|||
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); |
|||
if (null == agencyInfo){ |
|||
throw new EpmetException("查询组织信息失败..."); |
|||
} |
|||
dto.setPid(agencyInfo.getPid()); |
|||
dto.setPids(agencyInfo.getPids()); |
|||
fillData(dto,CustomerGridConstant.GRID); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @Description 左侧树点击组织时调用 |
|||
* @param dto |
|||
* @author zxc |
|||
* @date 2022/2/15 2:37 下午 |
|||
*/ |
|||
public void disposeAgencyNeighborHood(ImportGeneralDTO dto){ |
|||
agencyName = null == agencyName ? icBuildingDao.selectAgencyNameById(formDTO.getOrgId()) : agencyName; |
|||
//排除不是本组织的
|
|||
if (!dto.getAgencyName().equals(agencyName)){ |
|||
nums.add(num); |
|||
}else { |
|||
// 根据组织查询出所有网格,甩出不是本组织下的网格
|
|||
gridInfos = null == gridInfos ? getGridInfos(formDTO.getOrgId()) : gridInfos; |
|||
if (null == gridInfos){ |
|||
// 组织下确实不存在网格
|
|||
nums.add(num); |
|||
return; |
|||
} |
|||
// 根据网格名对比,没有找到的就把行号加入到未执行成功队列中
|
|||
Object cacheGridName = icHouseRedis.getTemporaryCacheGrid(formDTO.getCustomerId(), formDTO.getUserId(), dto.getGridName()); |
|||
if (null == cacheGridName){ |
|||
nums.add(num); |
|||
return; |
|||
} |
|||
dto.setGridId(cacheGridName.toString()); |
|||
dto.setAgencyId(formDTO.getOrgId()); |
|||
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); |
|||
if (null == agencyInfo){ |
|||
throw new EpmetException("查询组织信息失败..."); |
|||
} |
|||
dto.setPid(agencyInfo.getPid()); |
|||
dto.setPids(agencyInfo.getPids()); |
|||
fillData(dto,CustomerGridConstant.AGENCY); |
|||
} |
|||
} |
|||
|
|||
public void fillData(ImportGeneralDTO dto,String orgType){ |
|||
List<String> gridIds = new ArrayList<>(); |
|||
if (orgType.equals(CustomerGridConstant.GRID)){ |
|||
gridIds = Arrays.asList(formDTO.getOrgId()); |
|||
}else if (orgType.equals(CustomerGridConstant.AGENCY)){ |
|||
gridIds = gridInfoDTOs.stream().map(m -> m.getGridId()).collect(Collectors.toList()); |
|||
} |
|||
neighborHoodInfos = null == neighborHoodInfos ? getNeighborHoodInfos(gridIds) : neighborHoodInfos; |
|||
Object cacheNeighBorHood = icHouseRedis.getTemporaryCacheNeighBorHood(formDTO.getCustomerId(), formDTO.getUserId(), dto.getGridId() + "_" + dto.getNeighborHoodName()); |
|||
// 赋值小区ID
|
|||
dto.setNeighborHoodId(null == cacheNeighBorHood ? "" : cacheNeighBorHood.toString()); |
|||
if (StringUtils.isNotBlank(dto.getNeighborHoodId())){ |
|||
// 小区已存在
|
|||
nums.add(dto.getNum()); |
|||
}else { |
|||
needDisposeList.add(dto); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @Description 获取网格信息 |
|||
* @param orgId |
|||
* @author zxc |
|||
* @date 2022/2/14 9:57 上午 |
|||
*/ |
|||
public Map<String,Object> getGridInfos(String orgId){ |
|||
gridInfoDTOs = icBuildingDao.selectAllGridByOrgId(orgId); |
|||
gridInfos = gridInfoDTOs.stream().collect(Collectors.toMap(n -> n.getGridName(), n -> n.getGridId())); |
|||
icHouseRedis.setTemporaryCacheGrid(formDTO.getCustomerId(), gridInfos, formDTO.getUserId()); |
|||
return gridInfos; |
|||
} |
|||
|
|||
/** |
|||
* @Description 获取网格下的小区 |
|||
* @param gridIds |
|||
* @author zxc |
|||
* @date 2022/2/14 10:16 上午 |
|||
*/ |
|||
public Map<String,Object> getNeighborHoodInfos(List<String> gridIds){ |
|||
neighborHoodInfoDTOs = icBuildingDao.selectAllNeighborHoodByGridIds(gridIds); |
|||
neighborHoodInfos = neighborHoodInfoDTOs.stream().collect(Collectors.toMap(n -> n.getGridId() + "_" + n.getNeighborHoodName(), n -> n.getNeighborHoodId())); |
|||
icHouseRedis.setTemporaryCacheNeighBorHood(formDTO.getCustomerId(), neighborHoodInfos, formDTO.getUserId()); |
|||
return neighborHoodInfos; |
|||
} |
|||
|
|||
@Override |
|||
public void doAfterAllAnalysed(AnalysisContext context) { |
|||
finalDispose(); |
|||
// 删除缓存
|
|||
icHouseRedis.delTemporaryCacheGrids(formDTO.getCustomerId(), formDTO.getUserId()); |
|||
icHouseRedis.delTemporaryCacheNeighBorHood(formDTO.getCustomerId(), formDTO.getUserId()); |
|||
icHouseRedis.delTemporaryCacheBuilding(formDTO.getCustomerId(), formDTO.getUserId()); |
|||
icHouseRedis.delTemporaryCacheBuildingUnit(formDTO.getCustomerId(), formDTO.getUserId()); |
|||
icHouseRedis.delTemporaryCacheHouses(formDTO.getCustomerId(), formDTO.getUserId()); |
|||
// 放结果
|
|||
icHouseRedis.setImportResultDTO(formDTO.getCustomerId(), formDTO.getUserId(), new ImportResultDTO(nums,num)); |
|||
} |
|||
} |
@ -0,0 +1,32 @@ |
|||
package com.epmet.model; |
|||
|
|||
import com.alibaba.excel.annotation.ExcelProperty; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2022/2/15 2:15 下午 |
|||
* @DESC |
|||
*/ |
|||
@Data |
|||
public class NeighborHoodInfoModel { |
|||
|
|||
@ExcelProperty(value = "所属组织") |
|||
private String agencyName; |
|||
|
|||
@ExcelProperty(value = "所属网格") |
|||
private String gridName; |
|||
|
|||
@ExcelProperty(value = "小区名称") |
|||
private String neighborHoodName; |
|||
|
|||
@ExcelProperty(value = "关联物业") |
|||
private String propertyName; |
|||
|
|||
@ExcelProperty(value = "详细地址") |
|||
private String address; |
|||
|
|||
@ExcelProperty(value = "备注") |
|||
private String remark; |
|||
|
|||
} |
@ -0,0 +1,2 @@ |
|||
ALTER TABLE `epmet_gov_org`.`ic_neighbor_hood` |
|||
MODIFY COLUMN `ADDRESS` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '详细地址' AFTER `GRID_ID`; |
@ -0,0 +1,99 @@ |
|||
package com.epmet.dto; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
import lombok.Data; |
|||
|
|||
|
|||
/** |
|||
* 党员风采分类字典表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-02-12 |
|||
*/ |
|||
@Data |
|||
public class IcPartymemberStyleCategoryDictDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 楼栋主键 |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 客户id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 上级分类ID 顶级此列存储0 |
|||
*/ |
|||
private String pid; |
|||
|
|||
/** |
|||
* 所有上级分类ID英文顿号隔开,顶级此列存储0 |
|||
*/ |
|||
private String pids; |
|||
|
|||
/** |
|||
* 分类编码,分类编码+customer_id唯一;从1000开始 |
|||
*/ |
|||
private String categoryCode; |
|||
|
|||
/** |
|||
* 上级分类编码 |
|||
*/ |
|||
private String parentCategoryCode; |
|||
|
|||
/** |
|||
* 分类名称 |
|||
*/ |
|||
private String categoryName; |
|||
|
|||
/** |
|||
* 分类级别1,2,3,4.... 目前只有一级 |
|||
*/ |
|||
private Integer level; |
|||
|
|||
/** |
|||
* 排序 |
|||
*/ |
|||
private Integer sort; |
|||
|
|||
/** |
|||
* 0:可用;1:被禁用。默认0 |
|||
*/ |
|||
private Boolean beDisabled; |
|||
|
|||
/** |
|||
* 删除标识 0未删除、1已删除 |
|||
*/ |
|||
private String delFlag; |
|||
|
|||
/** |
|||
* 乐观锁 |
|||
*/ |
|||
private Integer revision; |
|||
|
|||
/** |
|||
* 创建人 |
|||
*/ |
|||
private String createdBy; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createdTime; |
|||
|
|||
/** |
|||
* 更新人 |
|||
*/ |
|||
private String updatedBy; |
|||
|
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
private Date updatedTime; |
|||
|
|||
} |
@ -0,0 +1,36 @@ |
|||
package com.epmet.resi.partymember.dto.partymember.form; |
|||
|
|||
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; |
|||
import lombok.Data; |
|||
import org.hibernate.validator.constraints.Length; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 【党员风采分类】添加或修改分类 |
|||
*/ |
|||
@Data |
|||
public class AddStyleCategoryFormDTO implements Serializable { |
|||
public interface AddUserInternalGroup { |
|||
} |
|||
|
|||
public interface AddUserShowGroup extends CustomerClientShowGroup { |
|||
} |
|||
|
|||
@NotBlank(message = "customerId不能为空", groups = AddUserInternalGroup.class) |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 分类名称 |
|||
*/ |
|||
@NotBlank(message = "分类名称不能为空", groups = AddUserShowGroup.class) |
|||
@Length(max = 10, groups = AddUserShowGroup.class) |
|||
private String categoryName; |
|||
|
|||
/** |
|||
* 主键 |
|||
*/ |
|||
private String categoryId; |
|||
|
|||
} |
@ -0,0 +1,15 @@ |
|||
package com.epmet.resi.partymember.dto.partymember.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
|
|||
@Data |
|||
public class StyleCategoryCommonFormDTO implements Serializable { |
|||
private static final long serialVersionUID = -291713921309878763L; |
|||
public interface AddUserInternalGroup {} |
|||
@NotBlank(message = "customerId不能为空",groups = AddUserInternalGroup.class) |
|||
private String customerId; |
|||
} |
@ -0,0 +1,21 @@ |
|||
package com.epmet.resi.partymember.dto.partymember.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
|
|||
@Data |
|||
public class StyleSelectListFormDTO implements Serializable { |
|||
|
|||
public interface AddUserInternalGroup {} |
|||
@NotBlank(message = "customerId不能为空",groups = AddUserInternalGroup.class) |
|||
private String customerId; |
|||
|
|||
/** |
|||
* query:查询条件用;新增或者编辑:addorupdate |
|||
*/ |
|||
@NotBlank(message = "type不能为空",groups = AddUserInternalGroup.class) |
|||
private String type; |
|||
} |
@ -0,0 +1,23 @@ |
|||
package com.epmet.resi.partymember.dto.partymember.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import javax.validation.constraints.NotNull; |
|||
import java.io.Serializable; |
|||
|
|||
@Data |
|||
public class StyleShowListFormDTO implements Serializable { |
|||
public interface AddUserInternalGroup { |
|||
} |
|||
|
|||
@NotBlank(message = "userId不能为空", groups = AddUserInternalGroup.class) |
|||
private String userId; |
|||
@NotBlank(message = "customerId不能为空", groups = AddUserInternalGroup.class) |
|||
private String customerId; |
|||
|
|||
@NotNull(message = "pageNo不能为空", groups = AddUserInternalGroup.class) |
|||
private Integer pageNo; |
|||
@NotNull(message = "pageSize不能为空", groups = AddUserInternalGroup.class) |
|||
private Integer pageSize; |
|||
} |
@ -0,0 +1,30 @@ |
|||
package com.epmet.resi.partymember.dto.partymember.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import javax.validation.constraints.NotNull; |
|||
import java.io.Serializable; |
|||
|
|||
|
|||
@Data |
|||
public class UpdateStyleCategoryFormDTO implements Serializable { |
|||
public interface DeleteInternalGroup { |
|||
} |
|||
public interface UpdateStatusInternalGroup { |
|||
} |
|||
/** |
|||
* 主键 |
|||
*/ |
|||
@NotBlank(message = "categoryId不能为空", groups = {DeleteInternalGroup.class,UpdateStatusInternalGroup.class}) |
|||
private String categoryId; |
|||
|
|||
/** |
|||
* 0:可用;1:被禁用。默认0 |
|||
*/ |
|||
@NotNull(message = "beDisabled不能为空", groups = {UpdateStatusInternalGroup.class}) |
|||
private Boolean beDisabled; |
|||
|
|||
|
|||
private String userId; |
|||
} |
@ -0,0 +1,27 @@ |
|||
package com.epmet.resi.partymember.dto.partymember.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 【党员风采分类】列表查询 |
|||
*/ |
|||
@Data |
|||
public class StyleCategoryDictResDTO implements Serializable { |
|||
/** |
|||
* 主键 |
|||
*/ |
|||
private String categoryId; |
|||
|
|||
/** |
|||
* 分类名称 |
|||
*/ |
|||
private String categoryName; |
|||
|
|||
/** |
|||
* 0:可用;1:被禁用。默认0 |
|||
*/ |
|||
private Boolean beDisabled; |
|||
|
|||
} |
@ -0,0 +1,101 @@ |
|||
package com.epmet.modules.partymember.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.modules.partymember.service.IcPartymemberStyleCategoryDictService; |
|||
import com.epmet.resi.partymember.dto.partymember.form.AddStyleCategoryFormDTO; |
|||
import com.epmet.resi.partymember.dto.partymember.form.StyleCategoryCommonFormDTO; |
|||
import com.epmet.resi.partymember.dto.partymember.form.StyleSelectListFormDTO; |
|||
import com.epmet.resi.partymember.dto.partymember.form.UpdateStyleCategoryFormDTO; |
|||
import com.epmet.resi.partymember.dto.partymember.result.StyleCategoryDictResDTO; |
|||
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; |
|||
|
|||
import java.util.List; |
|||
|
|||
|
|||
/** |
|||
* 党员风采分类字典表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-02-12 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("stylecategorydict") |
|||
public class IcPartymemberStyleCategoryDictController { |
|||
|
|||
@Autowired |
|||
private IcPartymemberStyleCategoryDictService icPartymemberStyleCategoryDictService; |
|||
|
|||
/** |
|||
* 【党员风采分类】列表查询 |
|||
* @param formDTO |
|||
* @return |
|||
*/ |
|||
@PostMapping("list") |
|||
public Result<List<StyleCategoryDictResDTO>> list(@RequestBody StyleCategoryCommonFormDTO formDTO){ |
|||
ValidatorUtils.validateEntity(formDTO,StyleCategoryCommonFormDTO.AddUserInternalGroup.class); |
|||
return new Result<List<StyleCategoryDictResDTO>>().ok(icPartymemberStyleCategoryDictService.queryList(formDTO.getCustomerId())); |
|||
} |
|||
|
|||
/** |
|||
* 【党员风采分类】添加或修改分类 |
|||
* @param formDTO |
|||
* @return |
|||
*/ |
|||
@PostMapping("addorupdate") |
|||
public Result addOrUpdate(@RequestBody AddStyleCategoryFormDTO formDTO){ |
|||
ValidatorUtils.validateEntity(formDTO, AddStyleCategoryFormDTO.AddUserInternalGroup.class,AddStyleCategoryFormDTO.AddUserShowGroup.class); |
|||
icPartymemberStyleCategoryDictService.addOrUpdate(formDTO); |
|||
return new Result(); |
|||
} |
|||
|
|||
/** |
|||
* 【党员风采分类】删除分类:删除的分类如果已经使用过,清空已经使用的记录,修改时需要重新选择, |
|||
* @param formDTO |
|||
* @return |
|||
*/ |
|||
@PostMapping("delete") |
|||
public Result delete(@LoginUser TokenDto tokenDto, @RequestBody UpdateStyleCategoryFormDTO formDTO){ |
|||
formDTO.setUserId(tokenDto.getUserId()); |
|||
ValidatorUtils.validateEntity(formDTO,UpdateStyleCategoryFormDTO.DeleteInternalGroup.class); |
|||
icPartymemberStyleCategoryDictService.delete(formDTO); |
|||
return new Result(); |
|||
} |
|||
|
|||
/** |
|||
* 【党员风采分类】启用或禁用 |
|||
* @param tokenDto |
|||
* @param formDTO |
|||
* @return |
|||
*/ |
|||
@PostMapping("updatestatus") |
|||
public Result updateStatus(@LoginUser TokenDto tokenDto, @RequestBody UpdateStyleCategoryFormDTO formDTO){ |
|||
formDTO.setUserId(tokenDto.getUserId()); |
|||
ValidatorUtils.validateEntity(formDTO,UpdateStyleCategoryFormDTO.UpdateStatusInternalGroup.class); |
|||
icPartymemberStyleCategoryDictService.updateStatus(formDTO); |
|||
return new Result(); |
|||
} |
|||
|
|||
/** |
|||
* 党员风采-分类下拉框 |
|||
* 查询条件中:展示所有未删除的 |
|||
* 新增活修改党员风采:展示可用的 |
|||
* |
|||
* @param formDTO |
|||
* @return |
|||
*/ |
|||
@PostMapping("select-list") |
|||
public Result<List<StyleCategoryDictResDTO>> list(@RequestBody StyleSelectListFormDTO formDTO) { |
|||
ValidatorUtils.validateEntity(formDTO, StyleSelectListFormDTO.AddUserInternalGroup.class); |
|||
return new Result<List<StyleCategoryDictResDTO>>().ok(icPartymemberStyleCategoryDictService.selectList(formDTO)); |
|||
} |
|||
|
|||
|
|||
|
|||
} |
@ -0,0 +1,20 @@ |
|||
package com.epmet.modules.partymember.dao; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.modules.partymember.entity.IcPartymemberStyleCategoryDictEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
/** |
|||
* 党员风采分类字典表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-02-12 |
|||
*/ |
|||
@Mapper |
|||
public interface IcPartymemberStyleCategoryDictDao extends BaseDao<IcPartymemberStyleCategoryDictEntity> { |
|||
|
|||
Integer getMaxCategoryCode(String customerId); |
|||
|
|||
int updateToDel(@Param("categoryId") String categoryId,@Param("userId") String userId); |
|||
} |
@ -0,0 +1,66 @@ |
|||
package com.epmet.modules.partymember.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
/** |
|||
* 党员风采分类字典表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-02-12 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("ic_partymember_style_category_dict") |
|||
public class IcPartymemberStyleCategoryDictEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 客户id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 上级分类ID 顶级此列存储0 |
|||
*/ |
|||
private String pid; |
|||
|
|||
/** |
|||
* 所有上级分类ID英文顿号隔开,顶级此列存储0 |
|||
*/ |
|||
private String pids; |
|||
|
|||
/** |
|||
* 分类编码,分类编码+customer_id唯一;从1000开始 |
|||
*/ |
|||
private String categoryCode; |
|||
|
|||
/** |
|||
* 上级分类编码 |
|||
*/ |
|||
private String parentCategoryCode; |
|||
|
|||
/** |
|||
* 分类名称 |
|||
*/ |
|||
private String categoryName; |
|||
|
|||
/** |
|||
* 分类级别1,2,3,4.... 目前只有一级 |
|||
*/ |
|||
private Integer level; |
|||
|
|||
/** |
|||
* 排序 |
|||
*/ |
|||
private Integer sort; |
|||
|
|||
/** |
|||
* 0:可用;1:被禁用。默认0 |
|||
*/ |
|||
private Boolean beDisabled; |
|||
|
|||
} |
@ -0,0 +1,57 @@ |
|||
package com.epmet.modules.partymember.service; |
|||
|
|||
import com.epmet.commons.mybatis.service.BaseService; |
|||
import com.epmet.modules.partymember.entity.IcPartymemberStyleCategoryDictEntity; |
|||
import com.epmet.resi.partymember.dto.partymember.form.AddStyleCategoryFormDTO; |
|||
import com.epmet.resi.partymember.dto.partymember.form.StyleSelectListFormDTO; |
|||
import com.epmet.resi.partymember.dto.partymember.form.UpdateStyleCategoryFormDTO; |
|||
import com.epmet.resi.partymember.dto.partymember.result.StyleCategoryDictResDTO; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 党员风采分类字典表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-02-12 |
|||
*/ |
|||
public interface IcPartymemberStyleCategoryDictService extends BaseService<IcPartymemberStyleCategoryDictEntity> { |
|||
|
|||
/** |
|||
* 【党员风采分类】列表查询 |
|||
* @param customerId |
|||
* @return |
|||
*/ |
|||
List<StyleCategoryDictResDTO> queryList(String customerId); |
|||
|
|||
/** |
|||
* 党员风采分类】添加或修改分类 |
|||
* @param formDTO |
|||
*/ |
|||
void addOrUpdate(AddStyleCategoryFormDTO formDTO); |
|||
|
|||
/** |
|||
* 删除的分类如果已经使用过,清空已经使用的记录,修改时需要重新选择, |
|||
* @param formDTO |
|||
*/ |
|||
void delete(UpdateStyleCategoryFormDTO formDTO); |
|||
|
|||
/** |
|||
* 【党员风采分类】启用或禁用 |
|||
* 新增党员风采时不显示已经禁用的分类,已经使用了禁用的分类正常显示, |
|||
* @param formDTO |
|||
*/ |
|||
void updateStatus(UpdateStyleCategoryFormDTO formDTO); |
|||
|
|||
/** |
|||
* 党员风采-分类下拉框 |
|||
* @param formDTO |
|||
* @return |
|||
*/ |
|||
List<StyleCategoryDictResDTO> selectList(StyleSelectListFormDTO formDTO); |
|||
|
|||
IcPartymemberStyleCategoryDictEntity get(String categoryId); |
|||
|
|||
Map<String, IcPartymemberStyleCategoryDictEntity> getCategoryDictMap(String customerId); |
|||
} |
@ -0,0 +1,183 @@ |
|||
package com.epmet.modules.partymember.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|||
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|||
import com.epmet.commons.tools.exception.EpmetException; |
|||
import com.epmet.modules.partymember.dao.IcPartymemberStyleCategoryDictDao; |
|||
import com.epmet.modules.partymember.dao.IcPartymemberStyleDao; |
|||
import com.epmet.modules.partymember.entity.IcPartymemberStyleCategoryDictEntity; |
|||
import com.epmet.modules.partymember.service.IcPartymemberStyleCategoryDictService; |
|||
import com.epmet.resi.partymember.dto.partymember.form.AddStyleCategoryFormDTO; |
|||
import com.epmet.resi.partymember.dto.partymember.form.StyleSelectListFormDTO; |
|||
import com.epmet.resi.partymember.dto.partymember.form.UpdateStyleCategoryFormDTO; |
|||
import com.epmet.resi.partymember.dto.partymember.result.StyleCategoryDictResDTO; |
|||
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 java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* 党员风采分类字典表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-02-12 |
|||
*/ |
|||
@Service |
|||
public class IcPartymemberStyleCategoryDictServiceImpl extends BaseServiceImpl<IcPartymemberStyleCategoryDictDao, IcPartymemberStyleCategoryDictEntity> implements IcPartymemberStyleCategoryDictService { |
|||
|
|||
@Autowired |
|||
private IcPartymemberStyleDao icPartymemberStyleDao; |
|||
|
|||
/** |
|||
* 【党员风采分类】列表查询 |
|||
* |
|||
* @param customerId |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public List<StyleCategoryDictResDTO> queryList(String customerId) { |
|||
LambdaQueryWrapper<IcPartymemberStyleCategoryDictEntity> queryWrapper = new LambdaQueryWrapper<>(); |
|||
queryWrapper.eq(IcPartymemberStyleCategoryDictEntity::getCustomerId, customerId); |
|||
queryWrapper.orderByDesc(IcPartymemberStyleCategoryDictEntity::getSort); |
|||
List<IcPartymemberStyleCategoryDictEntity> list = baseDao.selectList(queryWrapper); |
|||
List<StyleCategoryDictResDTO> resultList = new ArrayList<>(); |
|||
for (IcPartymemberStyleCategoryDictEntity entity : list) { |
|||
StyleCategoryDictResDTO resDTO = new StyleCategoryDictResDTO(); |
|||
resDTO.setCategoryId(entity.getId()); |
|||
resDTO.setCategoryName(entity.getCategoryName()); |
|||
resDTO.setBeDisabled(entity.getBeDisabled()); |
|||
resultList.add(resDTO); |
|||
} |
|||
return resultList; |
|||
} |
|||
|
|||
/** |
|||
* 党员风采分类】添加或修改分类 |
|||
* |
|||
* @param formDTO |
|||
*/ |
|||
@Transactional(rollbackFor = Exception.class) |
|||
@Override |
|||
public void addOrUpdate(AddStyleCategoryFormDTO formDTO) { |
|||
//校验分类名称是否唯一
|
|||
LambdaQueryWrapper<IcPartymemberStyleCategoryDictEntity> queryWrapper = new LambdaQueryWrapper<>(); |
|||
queryWrapper.eq(IcPartymemberStyleCategoryDictEntity::getCustomerId, formDTO.getCustomerId()) |
|||
.eq(IcPartymemberStyleCategoryDictEntity::getCategoryName, formDTO.getCategoryName()) |
|||
.ne(StringUtils.isNotBlank(formDTO.getCategoryId()), IcPartymemberStyleCategoryDictEntity::getId, formDTO.getCategoryId()); |
|||
Integer cout = baseDao.selectCount(queryWrapper); |
|||
if (cout > NumConstant.ZERO) { |
|||
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "分类名称已存在", "分类名称已存在"); |
|||
} |
|||
if (StringUtils.isNotBlank(formDTO.getCategoryId())) { |
|||
//更新分类名称
|
|||
LambdaUpdateWrapper<IcPartymemberStyleCategoryDictEntity> updateWrapper = new LambdaUpdateWrapper<>(); |
|||
updateWrapper.set(IcPartymemberStyleCategoryDictEntity::getCategoryName, formDTO.getCategoryName()); |
|||
updateWrapper.eq(IcPartymemberStyleCategoryDictEntity::getId, formDTO.getCategoryId()); |
|||
baseDao.update(null, updateWrapper); |
|||
return; |
|||
} |
|||
IcPartymemberStyleCategoryDictEntity insert = new IcPartymemberStyleCategoryDictEntity(); |
|||
insert.setCategoryName(formDTO.getCategoryName()); |
|||
insert.setCustomerId(formDTO.getCustomerId()); |
|||
insert.setPid(NumConstant.ZERO_STR); |
|||
insert.setPids(NumConstant.ZERO_STR); |
|||
// 查询 当前客户下最大的一级分类数。
|
|||
Integer maxCategoryCode = baseDao.getMaxCategoryCode(formDTO.getCustomerId()); |
|||
if (NumConstant.ZERO == maxCategoryCode) { |
|||
maxCategoryCode = 1001; |
|||
} else { |
|||
maxCategoryCode++; |
|||
} |
|||
insert.setCategoryCode(String.valueOf(maxCategoryCode)); |
|||
insert.setParentCategoryCode(NumConstant.ZERO_STR); |
|||
insert.setLevel(NumConstant.ONE); |
|||
|
|||
LambdaQueryWrapper<IcPartymemberStyleCategoryDictEntity> maxSortWrapper = new LambdaQueryWrapper<>(); |
|||
maxSortWrapper.eq(IcPartymemberStyleCategoryDictEntity::getCustomerId, formDTO.getCustomerId()) |
|||
.orderByDesc(IcPartymemberStyleCategoryDictEntity::getSort).last("limit 1"); |
|||
IcPartymemberStyleCategoryDictEntity max = baseDao.selectOne(maxSortWrapper); |
|||
insert.setSort(null == max ? NumConstant.ONE : max.getSort() + NumConstant.ONE); |
|||
insert.setBeDisabled(false); |
|||
baseDao.insert(insert); |
|||
} |
|||
|
|||
/** |
|||
* 删除的分类如果已经使用过,清空已经使用的记录,修改时需要重新选择, |
|||
* |
|||
* @param formDTO |
|||
*/ |
|||
@Transactional(rollbackFor = Exception.class) |
|||
@Override |
|||
public void delete(UpdateStyleCategoryFormDTO formDTO) { |
|||
baseDao.updateToDel(formDTO.getCategoryId(),formDTO.getUserId()); |
|||
icPartymemberStyleDao.clearCategry(formDTO.getCategoryId(),formDTO.getUserId()); |
|||
} |
|||
|
|||
/** |
|||
* 【党员风采分类】启用或禁用 |
|||
* 新增党员风采时不显示已经禁用的分类,已经使用了禁用的分类正常显示, |
|||
* |
|||
* @param formDTO |
|||
*/ |
|||
@Override |
|||
public void updateStatus(UpdateStyleCategoryFormDTO formDTO) { |
|||
LambdaUpdateWrapper<IcPartymemberStyleCategoryDictEntity> updateWrapper = new LambdaUpdateWrapper<>(); |
|||
updateWrapper.set(IcPartymemberStyleCategoryDictEntity::getBeDisabled, formDTO.getBeDisabled()) |
|||
.set(IcPartymemberStyleCategoryDictEntity::getUpdatedBy, formDTO.getUserId()) |
|||
.set(IcPartymemberStyleCategoryDictEntity::getUpdatedTime, new Date()); |
|||
updateWrapper.eq(IcPartymemberStyleCategoryDictEntity::getId, formDTO.getCategoryId()); |
|||
baseDao.update(null, updateWrapper); |
|||
} |
|||
|
|||
/** |
|||
* 党员风采-分类下拉框 |
|||
* |
|||
* @param formDTO |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public List<StyleCategoryDictResDTO> selectList(StyleSelectListFormDTO formDTO) { |
|||
LambdaQueryWrapper<IcPartymemberStyleCategoryDictEntity> queryWrapper = new LambdaQueryWrapper<>(); |
|||
queryWrapper.eq(IcPartymemberStyleCategoryDictEntity::getCustomerId, formDTO.getCustomerId()); |
|||
if("addorupdate".equals(formDTO.getType())){ |
|||
//查询可用的
|
|||
queryWrapper.eq(IcPartymemberStyleCategoryDictEntity::getBeDisabled,false); |
|||
} |
|||
queryWrapper.orderByAsc(IcPartymemberStyleCategoryDictEntity::getSort); |
|||
List<IcPartymemberStyleCategoryDictEntity> list = baseDao.selectList(queryWrapper); |
|||
List<StyleCategoryDictResDTO> resultList = new ArrayList<>(); |
|||
for (IcPartymemberStyleCategoryDictEntity entity : list) { |
|||
StyleCategoryDictResDTO resDTO = new StyleCategoryDictResDTO(); |
|||
resDTO.setCategoryId(entity.getId()); |
|||
resDTO.setCategoryName(entity.getCategoryName()); |
|||
resDTO.setBeDisabled(entity.getBeDisabled()); |
|||
resultList.add(resDTO); |
|||
} |
|||
return resultList; |
|||
} |
|||
|
|||
@Override |
|||
public IcPartymemberStyleCategoryDictEntity get(String categoryId) { |
|||
return baseDao.selectById(categoryId); |
|||
} |
|||
|
|||
@Override |
|||
public Map<String, IcPartymemberStyleCategoryDictEntity> getCategoryDictMap(String customerId) { |
|||
LambdaQueryWrapper<IcPartymemberStyleCategoryDictEntity> queryWrapper = new LambdaQueryWrapper<>(); |
|||
queryWrapper.eq(IcPartymemberStyleCategoryDictEntity::getCustomerId, customerId); |
|||
List<IcPartymemberStyleCategoryDictEntity> list=baseDao.selectList(queryWrapper); |
|||
Map<String, IcPartymemberStyleCategoryDictEntity> map=new HashMap<>(); |
|||
if(!CollectionUtils.isEmpty(list)){ |
|||
map=list.stream().collect(Collectors.toMap(IcPartymemberStyleCategoryDictEntity::getCategoryName, m -> m, (k1, k2) -> k1)); |
|||
} |
|||
return map; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,23 @@ |
|||
CREATE TABLE `ic_partymember_style_category_dict` ( |
|||
`ID` varchar(64) NOT NULL COMMENT '楼栋主键', |
|||
`CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户id', |
|||
`PID` varchar(64) CHARACTER SET utf8 NOT NULL COMMENT '上级分类ID 顶级此列存储0', |
|||
`PIDS` varchar(512) CHARACTER SET utf8 NOT NULL COMMENT '所有上级分类ID英文顿号隔开,顶级此列存储0', |
|||
`CATEGORY_CODE` varchar(64) CHARACTER SET utf8 NOT NULL COMMENT '分类编码,分类编码+customer_id唯一;从1000开始', |
|||
`PARENT_CATEGORY_CODE` varchar(64) CHARACTER SET utf8 NOT NULL COMMENT '上级分类编码', |
|||
`CATEGORY_NAME` varchar(128) CHARACTER SET utf8 NOT NULL COMMENT '分类名称', |
|||
`LEVEL` int(10) NOT NULL COMMENT '分类级别1,2,3,4.... 目前只有一级', |
|||
`SORT` int(10) unsigned NOT NULL COMMENT '排序', |
|||
`BE_DISABLED` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0:可用;1:被禁用。默认0', |
|||
`DEL_FLAG` varchar(1) NOT NULL DEFAULT '0' COMMENT '删除标识 0未删除、1已删除', |
|||
`REVISION` int(11) NOT NULL DEFAULT '0' COMMENT '乐观锁', |
|||
`CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', |
|||
`CREATED_TIME` datetime NOT NULL COMMENT '创建时间', |
|||
`UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', |
|||
`UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', |
|||
PRIMARY KEY (`ID`) |
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='党员风采分类字典表'; |
|||
|
|||
|
|||
alter table ic_partymember_style add COLUMN CATEGORY_ID VARCHAR(64) comment '分类主键' AFTER MAIN_DEED; |
|||
alter table ic_partymember_style add COLUMN CATEGORY_CODE VARCHAR(64) comment '分类编码' after CATEGORY_ID; |
@ -0,0 +1 @@ |
|||
alter table ic_partymember_style add COLUMN GRID_PIDS VARCHAR(255) comment '网格的所有上级' after GRID_ID; |
@ -0,0 +1,18 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.epmet.modules.partymember.dao.IcPartymemberStyleCategoryDictDao"> |
|||
|
|||
<select id="getMaxCategoryCode" parameterType="java.lang.String" resultType="java.lang.Integer"> |
|||
SELECT |
|||
IFNULL( MAX(CATEGORY_CODE), 0) |
|||
FROM |
|||
ic_partymember_style_category_dict |
|||
WHERE CUSTOMER_ID = #{customerId} |
|||
</select> |
|||
|
|||
<update id="updateToDel" parameterType="map"> |
|||
update ic_partymember_style_category_dict set del_flag='1',UPDATED_BY=#{userId},UPDATED_TIME=now() |
|||
where id=#{categoryId} |
|||
</update> |
|||
</mapper> |
Loading…
Reference in new issue