Browse Source
Conflicts: epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/PatrolRoutineWorkServiceImpl.javadev
102 changed files with 5055 additions and 500 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,323 @@ |
|||
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())){ |
|||
// 集合里重复的
|
|||
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.getAgencyId()) : 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 orgId |
|||
* @author zxc |
|||
* @date 2022/2/14 1:32 下午 |
|||
*/ |
|||
public Map<String,Object> getBuildingInfos(String orgId){ |
|||
buildingInfoDTOs = icBuildingDao.selectAllBuildingByNeighborHoodId(orgId); |
|||
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,449 @@ |
|||
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().filter(n -> StringUtils.isNotBlank(n.getBuildingUnitId())).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)){ |
|||
// 库里存在的
|
|||
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.getAgencyId()) : 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.getAgencyId()) : 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 orgId){ |
|||
buildingInfoDTOs = icBuildingDao.selectAllBuildingByNeighborHoodId(orgId); |
|||
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 orgId |
|||
* @author zxc |
|||
* @date 2022/2/14 2:04 下午 |
|||
*/ |
|||
public Map<String,Object> getBuildingUnitInfos(String orgId){ |
|||
buildingUnitInfoDTOs = icBuildingDao.selectAllBuildingUnitByBuildingId(orgId); |
|||
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,283 @@ |
|||
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())){ |
|||
// 集合里重复的
|
|||
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> |
|||
@ -0,0 +1,26 @@ |
|||
package com.epmet.constant; |
|||
|
|||
/** |
|||
* 导入任务的业务类型常量 |
|||
*/ |
|||
public interface ImportTaskConstants { |
|||
/** |
|||
* 居民 |
|||
*/ |
|||
String BIZ_TYPE_RESI = "resi"; |
|||
|
|||
/** |
|||
* 处理状态:处理中 |
|||
*/ |
|||
String PROCESS_STATUS_PROCESSING = "processing"; |
|||
|
|||
/** |
|||
* 处理状态:成功 |
|||
*/ |
|||
String PROCESS_STATUS_FINISHED_SUCCESS = "finished_success"; |
|||
|
|||
/** |
|||
* 处理状态:完成,但未完全成功 |
|||
*/ |
|||
String PROCESS_STATUS_FINISHED_FAIL = "finished_fail"; |
|||
} |
|||
@ -0,0 +1,47 @@ |
|||
package com.epmet.dto.form.patrol; |
|||
|
|||
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; |
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Description 网格员例行工作 |
|||
* @Author sun |
|||
*/ |
|||
@Data |
|||
public class GridMemberRoutineWorkFormDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -3522636529743412120L; |
|||
public interface RoutineWork extends CustomerClientShowGroup {} |
|||
public interface RoutineWorkDetail extends CustomerClientShowGroup {} |
|||
|
|||
/** |
|||
* 网格Id |
|||
*/ |
|||
@NotBlank(message = "网格Id不能为空", groups = RoutineWork.class) |
|||
private String gridId; |
|||
|
|||
/** |
|||
* 例行工作Id |
|||
*/ |
|||
@NotBlank(message = "例行工作Id不能为空", groups = RoutineWorkDetail.class) |
|||
private String routineWorkId; |
|||
|
|||
/** |
|||
* 当前页 |
|||
*/ |
|||
private Integer pageNo = 1; |
|||
|
|||
/** |
|||
* 每页记录数 |
|||
*/ |
|||
private Integer pageSize = 20; |
|||
|
|||
//token中客户Id
|
|||
private String customerId; |
|||
//token中用户Id
|
|||
private String staffId; |
|||
|
|||
} |
|||
@ -0,0 +1,84 @@ |
|||
package com.epmet.dto.result; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import com.fasterxml.jackson.annotation.JsonIgnore; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @Description 网格员例行工作详情 |
|||
* @Author sun |
|||
*/ |
|||
@Data |
|||
public class RoutineWorkDetailResultDTO implements Serializable { |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 例行工作Id |
|||
*/ |
|||
private String routineWorkId; |
|||
/** |
|||
* 网格Id |
|||
*/ |
|||
private String gridId; |
|||
/** |
|||
* 网格名称 |
|||
*/ |
|||
private String gridName; |
|||
/** |
|||
* 网格员Id |
|||
*/ |
|||
private String staffId; |
|||
/** |
|||
* 网格员姓名 |
|||
*/ |
|||
private String staffName; |
|||
/** |
|||
* 提交日期 |
|||
*/ |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
|||
private Date submitTime; |
|||
/** |
|||
* 事项类型名称,一类-二类 |
|||
*/ |
|||
private String workTypeName; |
|||
/** |
|||
* 重点人员是否在当地 |
|||
*/ |
|||
private String isKeyPeopleLocateName; |
|||
/** |
|||
* 重点人员现状 |
|||
*/ |
|||
private String keyPeopleStatus; |
|||
/** |
|||
* 事项名称 |
|||
*/ |
|||
private String title; |
|||
/** |
|||
* 是否异常 |
|||
*/ |
|||
private String isNormalName; |
|||
/** |
|||
* 发生日期 |
|||
*/ |
|||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
|||
private Date happenTime; |
|||
/** |
|||
* 发生地点 |
|||
*/ |
|||
private String address; |
|||
/** |
|||
* 事项简述 |
|||
*/ |
|||
private String workContent; |
|||
|
|||
//例行工作一类编码
|
|||
@JsonIgnore |
|||
private String allPCode; |
|||
//例行工作二类编码
|
|||
@JsonIgnore |
|||
private String workTypeCode; |
|||
|
|||
} |
|||
@ -0,0 +1,63 @@ |
|||
package com.epmet.dto.result; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import com.fasterxml.jackson.annotation.JsonIgnore; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Description 网格员例行工作列表 |
|||
* @Author sun |
|||
*/ |
|||
@Data |
|||
public class RoutineWorkListResultDTO implements Serializable { |
|||
private static final long serialVersionUID = 1L; |
|||
/** |
|||
* 总条数 |
|||
*/ |
|||
private Integer total = 0; |
|||
|
|||
/** |
|||
* 集合对象 |
|||
*/ |
|||
private List<RoutineWorkList> list; |
|||
|
|||
@Data |
|||
public static class RoutineWorkList { |
|||
/** |
|||
* 例行工作Id |
|||
*/ |
|||
private String routineWorkId; |
|||
|
|||
/** |
|||
* 标题 |
|||
*/ |
|||
private String title; |
|||
|
|||
/** |
|||
* 提交日期 |
|||
*/ |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
|||
private Date submitTime; |
|||
|
|||
/** |
|||
* 工作类型[一类-二类名称] |
|||
*/ |
|||
private String workTypeName; |
|||
|
|||
/** |
|||
* 是否异常 |
|||
*/ |
|||
private String isNormalName; |
|||
//例行工作一类编码
|
|||
@JsonIgnore |
|||
private String allPCode; |
|||
//例行工作二类编码
|
|||
@JsonIgnore |
|||
private String workTypeCode; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
package com.epmet.dto.result; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import com.fasterxml.jackson.annotation.JsonIgnore; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @Description 网格员例行工作数据统计 |
|||
* @Author sun |
|||
*/ |
|||
@Data |
|||
public class StatsdataResultDTO implements Serializable { |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 巡查总次数 |
|||
*/ |
|||
private Integer patrolTotal; |
|||
|
|||
/** |
|||
* 巡查时长(xx小时xx分钟) |
|||
*/ |
|||
private String totalTime; |
|||
@JsonIgnore |
|||
private Integer totalNum; |
|||
|
|||
/** |
|||
* 例行工作总次数 |
|||
*/ |
|||
private Integer routineWorkCount; |
|||
|
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
package com.epmet.dao; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.entity.ImportTaskEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-02-15 |
|||
*/ |
|||
@Mapper |
|||
public interface ImportTaskDao extends BaseDao<ImportTaskEntity> { |
|||
|
|||
/** |
|||
* 完成导入 |
|||
* @param taskId 任务id |
|||
* @param processStatus 处理状态 |
|||
* @param operatorId 操作者id |
|||
* @param resultDesc 结果文字描述 |
|||
* @param resultDescFile 结果描述文件 |
|||
* @return |
|||
*/ |
|||
int finish(@Param("taskId") String taskId, |
|||
@Param("process_status") String processStatus, |
|||
@Param("operatorId") String operatorId, |
|||
@Param("resultDesc") String resultDesc, |
|||
@Param("resultDescFile") String resultDescFile); |
|||
} |
|||
@ -0,0 +1,48 @@ |
|||
package com.epmet.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
|
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-02-15 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("import_task") |
|||
public class ImportTaskEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 业务类型。resi:居民;楼栋:building;房屋:house。依次补充 |
|||
*/ |
|||
private String bizType; |
|||
|
|||
/** |
|||
* 处理状态。processing:处理中;finished:完成; |
|||
*/ |
|||
private String processStatus; |
|||
|
|||
/** |
|||
* 谁导入的 |
|||
*/ |
|||
private String operatorId; |
|||
|
|||
/** |
|||
* 开始导入的时间 |
|||
*/ |
|||
private Date startTime; |
|||
|
|||
private String resultDescFile; |
|||
|
|||
private String resultDesc; |
|||
|
|||
} |
|||
@ -1,73 +0,0 @@ |
|||
package com.epmet.excel.handler; |
|||
|
|||
import com.alibaba.excel.context.AnalysisContext; |
|||
import com.alibaba.excel.event.AnalysisEventListener; |
|||
import com.alibaba.fastjson.JSON; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 创建一个监听器 |
|||
*/ |
|||
@Slf4j |
|||
public class DynamicEasyExcelListener extends AnalysisEventListener<Map<Integer, String>> { |
|||
|
|||
/** |
|||
* 表头数据(存储所有的表头数据) |
|||
*/ |
|||
private List<Map<Integer, String>> headList = new ArrayList<>(); |
|||
|
|||
/** |
|||
* 数据体 |
|||
*/ |
|||
private List<Map<Integer, String>> dataList = new ArrayList<>(); |
|||
// Map<Integer, String> dataList = new HashMap<>();
|
|||
|
|||
/** |
|||
* 这里会一行行的返回头 |
|||
* |
|||
* @param headMap |
|||
* @param context |
|||
*/ |
|||
@Override |
|||
public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) { |
|||
//log.info("解析到一条头数据:{}", JSON.toJSONString(headMap));
|
|||
//存储全部表头数据
|
|||
headList.add(headMap); |
|||
} |
|||
|
|||
/** |
|||
* 这个每一条数据解析都会来调用 |
|||
* |
|||
* @param data |
|||
* one row value. Is is same as {@link AnalysisContext#readRowHolder()} |
|||
* @param context |
|||
*/ |
|||
@Override |
|||
public void invoke(Map<Integer, String> data, AnalysisContext context) { |
|||
//log.info("解析到一条数据:{}", JSON.toJSONString(data));
|
|||
dataList.add(data); |
|||
} |
|||
|
|||
/** |
|||
* 所有数据解析完成了 都会来调用 |
|||
* |
|||
* @param context |
|||
*/ |
|||
@Override |
|||
public void doAfterAllAnalysed(AnalysisContext context) { |
|||
// 这里也要保存数据,确保最后遗留的数据也存储到数据库
|
|||
//log.info("所有数据解析完成!");
|
|||
} |
|||
|
|||
public List<Map<Integer, String>> getHeadList() { |
|||
return headList; |
|||
} |
|||
|
|||
public List<Map<Integer, String>> getDataList() { |
|||
return dataList; |
|||
} |
|||
} |
|||
@ -0,0 +1,189 @@ |
|||
package com.epmet.excel.handler; |
|||
|
|||
import com.alibaba.excel.context.AnalysisContext; |
|||
import com.alibaba.excel.event.AnalysisEventListener; |
|||
import com.epmet.dto.result.FormItemResult; |
|||
import com.epmet.service.impl.IcResiUserImportServiceImpl; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* 创建一个监听器 |
|||
*/ |
|||
@Slf4j |
|||
public class IcResiImportDynamicExcelListener extends AnalysisEventListener<Map<Integer, String>> { |
|||
|
|||
/** |
|||
* 一次性导入的条数 |
|||
*/ |
|||
private static final Integer ONCE_BATCH_IMPORT_ITEMS_SIZE = 2000; |
|||
|
|||
/** |
|||
* 客户id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 当前操作人的AgencyId |
|||
*/ |
|||
private String currUserAgencyId; |
|||
|
|||
/** |
|||
* 当前用户ID |
|||
*/ |
|||
private String currentUserId; |
|||
|
|||
/** |
|||
* 当前用户agencyId |
|||
*/ |
|||
private String currUserAgencyPids; |
|||
|
|||
/** |
|||
* 数据库表名 |
|||
*/ |
|||
private String tableName; |
|||
|
|||
private IcResiUserImportServiceImpl icResiUserImportService; |
|||
|
|||
/** |
|||
* item列表 |
|||
*/ |
|||
private List<FormItemResult> formItemList; |
|||
|
|||
/** |
|||
* 是否是基础信息表 |
|||
*/ |
|||
private Boolean isPrimary; |
|||
|
|||
/** |
|||
* 有几行是表头 |
|||
*/ |
|||
private Integer headRowNumber; |
|||
|
|||
/** |
|||
* key:itemId |
|||
* value:ColumnWrapper 列封装信息,列基础信息和列值 |
|||
*/ |
|||
private Map<String, IcResiUserImportServiceImpl.ColumnWrapper> itemIdAndColumnWrapper; |
|||
|
|||
/** |
|||
* 被丢弃的header,原因:checkbox的情况下,选项在表格中是多列,但是在item中不存在 |
|||
*/ |
|||
private Map<Integer, String> abandonedHeaders; |
|||
|
|||
/** |
|||
* 表头数据(存储所有的表头数据) |
|||
*/ |
|||
private List<Map<Integer, String>> headList = new ArrayList<>(); |
|||
|
|||
/** |
|||
* 数据体 |
|||
*/ |
|||
private List<Map<Integer, String>> dataList = new ArrayList<>(); |
|||
// Map<Integer, String> dataList = new HashMap<>();
|
|||
|
|||
|
|||
public IcResiImportDynamicExcelListener(IcResiUserImportServiceImpl icResiUserImportService, String customerId, |
|||
String currentUserId, String currUserAgencyId, |
|||
String currUserAgencyPids, Boolean isPrimary, String tableName, |
|||
List<FormItemResult> formItemList, Integer headRowNumber) { |
|||
|
|||
this.customerId = customerId; |
|||
this.icResiUserImportService = icResiUserImportService; |
|||
this.formItemList = formItemList; |
|||
this.isPrimary = isPrimary; |
|||
this.currentUserId = currentUserId; |
|||
this.currUserAgencyId = currUserAgencyId; |
|||
this.currUserAgencyPids = currUserAgencyPids; |
|||
this.tableName = tableName; |
|||
this.headRowNumber = headRowNumber; |
|||
} |
|||
|
|||
/** |
|||
* 这里会一行行的返回头 |
|||
* |
|||
* @param headMap |
|||
* @param context |
|||
*/ |
|||
@Override |
|||
public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) { |
|||
headList.add(headMap); |
|||
|
|||
if (headList.size() < headRowNumber) { |
|||
return; |
|||
} |
|||
|
|||
// 合并多级表头到一个list中,key为列序号
|
|||
Map<Integer, List<String>> headers = icResiUserImportService.mergeMultiLevelHeadLabels(headList); |
|||
|
|||
// 清洗表头数据,通过items剔除,并且得到options
|
|||
abandonedHeaders = icResiUserImportService.removeAndGetOptionsFromHeaders(headers, formItemList); |
|||
|
|||
// 交换表头信息,以label连起来的string作为key,列号的列表作为value
|
|||
HashMap<String, List<Integer>> combinedHeaders = icResiUserImportService.exchangeKeyAndValueOfHeaders(headers); |
|||
|
|||
// 得到客户配置item数据。<"兴趣爱好:兴趣特长", item对象>
|
|||
Map<String, FormItemResult> customizedLabelCompbinedItemsMap = formItemList.stream().collect( |
|||
Collectors.toMap(formItem -> { |
|||
String groupLabel = formItem.getGroupLabel(); |
|||
String label = formItem.getLabel(); |
|||
if (StringUtils.isNotBlank(groupLabel)) { |
|||
return groupLabel.concat(":").concat(label); |
|||
} else { |
|||
return label; |
|||
} |
|||
}, formItem -> formItem) |
|||
); |
|||
|
|||
itemIdAndColumnWrapper = icResiUserImportService.convertExcelHeaders2DBColumnWrappers(customizedLabelCompbinedItemsMap, combinedHeaders); |
|||
} |
|||
|
|||
/** |
|||
* 这个每一条数据解析都会来调用 |
|||
* |
|||
* @param data |
|||
* one row value. Is is same as {@link AnalysisContext#readRowHolder()} |
|||
* @param context |
|||
*/ |
|||
@Override |
|||
public void invoke(Map<Integer, String> data, AnalysisContext context) { |
|||
// 每2000条数据处理一次
|
|||
dataList.add(data); |
|||
|
|||
// 达到了批量导入的阈值,执行一次持久化
|
|||
if (dataList.size() >= ONCE_BATCH_IMPORT_ITEMS_SIZE) { |
|||
execPersistant(); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 所有数据解析完成了会调用 |
|||
* 此处也要判断,然后执行持久化,因为最后一部分数据,达不到批量阈值,不能漏掉,在最后结束的时候给他执行进去 |
|||
* @param context |
|||
*/ |
|||
@Override |
|||
public void doAfterAllAnalysed(AnalysisContext context) { |
|||
if (dataList.size() != 0) { |
|||
execPersistant(); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 执行持久化 |
|||
*/ |
|||
private void execPersistant() { |
|||
// 持久化
|
|||
if (isPrimary) { |
|||
icResiUserImportService.persistIcResiBaseInfo(itemIdAndColumnWrapper, dataList, currUserAgencyId, abandonedHeaders, currUserAgencyPids, currentUserId, tableName); |
|||
} else { |
|||
icResiUserImportService.persistIcResiExtraInfo(itemIdAndColumnWrapper, dataList, currUserAgencyId, abandonedHeaders, currentUserId, tableName, customerId); |
|||
} |
|||
dataList.clear(); |
|||
} |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
package com.epmet.service; |
|||
|
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-02-15 |
|||
*/ |
|||
public interface ImportTaskService { |
|||
|
|||
/** |
|||
* 检查指定类型该用户是否存在处理中的导入任务 |
|||
* @param operatorId 操作者ID |
|||
* @param bizType 业务类型。resi:居民 |
|||
* @return |
|||
*/ |
|||
boolean existsProcessingTask(String operatorId, String bizType); |
|||
|
|||
/** |
|||
* 创建处理任务 |
|||
* @param operatorId |
|||
* @param bizType |
|||
*/ |
|||
String createProcessTask(String operatorId, String bizType); |
|||
|
|||
/** |
|||
* 结束导入 |
|||
* @param taskId 任务id |
|||
* @param processStatus 处理状态 |
|||
* @param resultDescFile 结果描述文件 |
|||
* @param resultDesc 结果描述文本 |
|||
*/ |
|||
Boolean finish(String taskId, String processStatus, String operatorId, String resultDescFile, String resultDesc); |
|||
} |
|||
@ -0,0 +1,57 @@ |
|||
package com.epmet.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.epmet.constant.ImportTaskConstants; |
|||
import com.epmet.dao.ImportTaskDao; |
|||
import com.epmet.entity.ImportTaskEntity; |
|||
import com.epmet.service.ImportTaskService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-02-15 |
|||
*/ |
|||
@Service |
|||
public class ImportTaskServiceImpl implements ImportTaskService { |
|||
|
|||
@Autowired |
|||
private ImportTaskDao importRecordDao; |
|||
|
|||
/** |
|||
* 该用户,该业务类型,是否有正在处理的导入任务 |
|||
* @param operatorId 操作者ID |
|||
* @param bizType 业务类型。resi:居民 |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public boolean existsProcessingTask(String operatorId, String bizType) { |
|||
LambdaQueryWrapper<ImportTaskEntity> query = new LambdaQueryWrapper<>(); |
|||
query.eq(ImportTaskEntity::getOperatorId, operatorId); |
|||
query.eq(ImportTaskEntity::getBizType, bizType); |
|||
query.eq(ImportTaskEntity::getProcessStatus, ImportTaskConstants.PROCESS_STATUS_PROCESSING); |
|||
|
|||
return importRecordDao.selectCount(query) > 0; |
|||
} |
|||
|
|||
@Override |
|||
public String createProcessTask(String operatorId, String bizType) { |
|||
ImportTaskEntity importRecord = new ImportTaskEntity(); |
|||
importRecord.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_PROCESSING); |
|||
importRecord.setOperatorId(operatorId); |
|||
importRecord.setBizType(bizType); |
|||
importRecord.setStartTime(new Date()); |
|||
|
|||
importRecordDao.insert(importRecord); |
|||
return importRecord.getId(); |
|||
} |
|||
|
|||
@Override |
|||
public Boolean finish(String taskId, String processStatus, String operatorId, String resultDescFile, String resultDesc) { |
|||
return importRecordDao.finish(taskId, processStatus, operatorId, resultDesc, resultDescFile) > 0; |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
<?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.dao.ImportTaskDao"> |
|||
|
|||
<resultMap type="com.epmet.entity.ImportTaskEntity" id="importRecordMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="bizType" column="BIZ_TYPE"/> |
|||
<result property="processStatus" column="PROCESS_STATUS"/> |
|||
<result property="operatorId" column="OPERATOR_ID"/> |
|||
<result property="startTime" column="START_TIME"/> |
|||
<result property="resultDescFile" column="RESULT_DESC_FILE"/> |
|||
<result property="resultDesc" column="RESULT_DESC"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
</resultMap> |
|||
|
|||
<!--完成导入--> |
|||
<update id="finish"> |
|||
update import_task |
|||
set PROCESS_STATUS = #{process_status}, |
|||
RESULT_DESC = #{resultDesc}, |
|||
RESULT_DESC_FILE = #{resultDescFile}, |
|||
UPDATED_BY=#{operatorId}, |
|||
UPDATED_TIME=NOW() |
|||
where ID=#{taskId} |
|||
and PROCESS_STATUS = 'processing' |
|||
</update> |
|||
</mapper> |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue