|
|
@ -2,53 +2,68 @@ package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
import com.alibaba.excel.ExcelWriter; |
|
|
|
import com.alibaba.excel.converters.Converter; |
|
|
|
import com.alibaba.excel.converters.ReadConverterContext; |
|
|
|
import com.alibaba.excel.enums.CellDataTypeEnum; |
|
|
|
import com.alibaba.excel.read.metadata.ReadSheet; |
|
|
|
import com.alibaba.excel.write.builder.ExcelWriterBuilder; |
|
|
|
import com.alibaba.excel.write.metadata.WriteSheet; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
|
|
|
import com.epmet.commons.tools.constant.ServiceConstant; |
|
|
|
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|
|
|
import com.epmet.commons.tools.dto.result.OptionResultDTO; |
|
|
|
import com.epmet.commons.tools.enums.BizTypeEnum; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
import com.epmet.commons.tools.exception.ExceptionUtils; |
|
|
|
import com.epmet.commons.tools.exception.ValidateException; |
|
|
|
import com.epmet.commons.tools.feign.ResultDataResolver; |
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
|
import com.epmet.commons.tools.utils.EpmetRequestHolder; |
|
|
|
import com.epmet.commons.tools.utils.ExcelUtils; |
|
|
|
import com.epmet.commons.tools.utils.FileUtils; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerResiUserRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; |
|
|
|
import com.epmet.commons.tools.redis.common.bean.GridInfoCache; |
|
|
|
import com.epmet.commons.tools.redis.common.bean.IcResiUserInfoCache; |
|
|
|
import com.epmet.commons.tools.utils.*; |
|
|
|
import com.epmet.constants.ImportTaskConstants; |
|
|
|
import com.epmet.dao.*; |
|
|
|
import com.epmet.dto.IcBuildingDTO; |
|
|
|
import com.epmet.dto.IcBuildingUnitDTO; |
|
|
|
import com.epmet.dto.IcNeighborHoodDTO; |
|
|
|
import com.epmet.dto.IcResiUserDTO; |
|
|
|
import com.epmet.dto.result.HouseAgencyInfoResultDTO; |
|
|
|
import com.epmet.dto.result.ImportTaskCommonResultDTO; |
|
|
|
import com.epmet.dto.result.LingShanSpecialCrowdListResultDTO; |
|
|
|
import com.epmet.dto.result.UploadImgResultDTO; |
|
|
|
import com.epmet.entity.*; |
|
|
|
import com.epmet.enums.LingShanSpecialCrowdTypeEnums; |
|
|
|
import com.epmet.excel.data.*; |
|
|
|
import com.epmet.excel.handler.*; |
|
|
|
import com.epmet.exceptions.ReadExcelHeaderOnlyException; |
|
|
|
import com.epmet.feign.EpmetAdminOpenFeignClient; |
|
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
|
import com.epmet.feign.OssFeignClient; |
|
|
|
import com.epmet.service.LingShanSpecialCrowdService; |
|
|
|
import com.epmet.utils.ImportTaskUtils; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.collections4.ListUtils; |
|
|
|
import org.apache.commons.fileupload.FileItem; |
|
|
|
import org.apache.commons.fileupload.disk.DiskFileItemFactory; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.http.entity.ContentType; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.web.multipart.commons.CommonsMultipartFile; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.io.OutputStream; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Optional; |
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
import java.util.concurrent.ExecutorService; |
|
|
|
import java.util.concurrent.atomic.AtomicReference; |
|
|
|
|
|
|
|
/** |
|
|
|
* 灵山特殊人群service |
|
|
@ -87,6 +102,11 @@ public class LingShanSpecialCrowdServiceImpl implements LingShanSpecialCrowdServ |
|
|
|
@Autowired |
|
|
|
private OssFeignClient ossFeignClient; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private EpmetAdminOpenFeignClient adminOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
|
|
|
|
|
|
|
@Override |
|
|
|
public String importSpecialCrowd(String crowdCategory, String fileSavePath, String originFilename) { |
|
|
|
Class<? extends LingShanSpecialCrowdDetailBaseExcelData> excelDataClass; |
|
|
@ -229,7 +249,7 @@ public class LingShanSpecialCrowdServiceImpl implements LingShanSpecialCrowdServ |
|
|
|
return "居民信息不存在,请先维护居民基础信息。"; |
|
|
|
} |
|
|
|
if (!resiEntity.getName().equals(name)) { |
|
|
|
return String.format("姓名信息与居民基础信息不一致。(在居民哭华总根据身份证号找到的居民姓名为:{})", name); |
|
|
|
return String.format("姓名信息与居民基础信息不一致。(在居民库中根据身份证号找到的居民姓名为:%s)", name); |
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
@ -287,4 +307,196 @@ public class LingShanSpecialCrowdServiceImpl implements LingShanSpecialCrowdServ |
|
|
|
specialCrowdDetailXfryDao.saveBatchManually(l); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void createSpecialCrowd(LingShanSpecialCrowdDetailBaseExcelData specialData, String specialType) { |
|
|
|
String customerId = EpmetRequestHolder.getLoginUserCustomerId(); |
|
|
|
String staffId = EpmetRequestHolder.getLoginUserId(); |
|
|
|
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(customerId, staffId); |
|
|
|
String orgIdPath = PidUtils.convertPid2OrgIdPath(staffInfo.getAgencyId(), staffInfo.getAgencyPIds()); |
|
|
|
|
|
|
|
Date now = new Date(); |
|
|
|
|
|
|
|
// 检查
|
|
|
|
String validateRst = validate(specialData); |
|
|
|
if (StringUtils.isNotBlank(validateRst)) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, validateRst); |
|
|
|
} |
|
|
|
|
|
|
|
// 保存人员和类型信息
|
|
|
|
LingshanSpecialCrowdPersonEntity person = new LingshanSpecialCrowdPersonEntity(IdWorker.getIdStr(), customerId, orgIdPath, specialData.getName(), specialData.getIdCard(), |
|
|
|
"0", 0, now, staffId, now, staffId); |
|
|
|
//
|
|
|
|
LingshanSpecialCrowdPersonTypeEntity personType = new LingshanSpecialCrowdPersonTypeEntity(IdWorker.getIdStr(), customerId, orgIdPath, specialData.getIdCard(), specialType, |
|
|
|
"0", 0, now, staffId, now, staffId); |
|
|
|
|
|
|
|
savePersonAndTypes(Arrays.asList(person), Arrays.asList(personType)); |
|
|
|
|
|
|
|
// Class clazz;
|
|
|
|
|
|
|
|
switch (specialType) { |
|
|
|
case "anzhibangjiao": |
|
|
|
LingshanSpecialCrowdDetailAzbjEntity e1 = ConvertUtils.sourceToTarget(specialData, LingshanSpecialCrowdDetailAzbjEntity.class); |
|
|
|
setCommonFields(e1, customerId, orgIdPath, now, staffId); |
|
|
|
saveBatch(Arrays.asList(e1), e1); |
|
|
|
break; |
|
|
|
case "xinfangrenyuan": |
|
|
|
LingshanSpecialCrowdDetailAzbjEntity e2 = ConvertUtils.sourceToTarget(specialData, LingshanSpecialCrowdDetailAzbjEntity.class); |
|
|
|
setCommonFields(e2, customerId, orgIdPath, now, staffId); |
|
|
|
saveBatch(Arrays.asList(e2), e2); |
|
|
|
break; |
|
|
|
case "xidurenyuan": |
|
|
|
LingshanSpecialCrowdDetailAzbjEntity e3 = ConvertUtils.sourceToTarget(specialData, LingshanSpecialCrowdDetailAzbjEntity.class); |
|
|
|
setCommonFields(e3, customerId, orgIdPath, now, staffId); |
|
|
|
saveBatch(Arrays.asList(e3), e3); |
|
|
|
break; |
|
|
|
case "shequjiaozheng": |
|
|
|
LingshanSpecialCrowdDetailAzbjEntity e4 = ConvertUtils.sourceToTarget(specialData, LingshanSpecialCrowdDetailAzbjEntity.class); |
|
|
|
setCommonFields(e4, customerId, orgIdPath, now, staffId); |
|
|
|
saveBatch(Arrays.asList(e4), e4); |
|
|
|
break; |
|
|
|
case "jingzhanghuanzhe": |
|
|
|
LingshanSpecialCrowdDetailAzbjEntity e5 = ConvertUtils.sourceToTarget(specialData, LingshanSpecialCrowdDetailAzbjEntity.class); |
|
|
|
setCommonFields(e5, customerId, orgIdPath, now, staffId); |
|
|
|
saveBatch(Arrays.asList(e5), e5); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void setCommonFields(LingshanSpecialCrowdDetailBaseEntity e, String customerId, String orgIdPath, Date now, String staffId) { |
|
|
|
e.setCustomerId(customerId); |
|
|
|
e.setOrgIdPath(orgIdPath); |
|
|
|
e.setId(IdWorker.getIdStr()); |
|
|
|
e.setRevision(0); |
|
|
|
e.setCreatedTime(now); |
|
|
|
e.setUpdatedTime(now); |
|
|
|
e.setCreatedBy(staffId); |
|
|
|
e.setUpdatedBy(staffId); |
|
|
|
e.setDelFlag("0"); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public LingShanSpecialCrowdDetailBaseExcelData getPersonSpecialTypeDetail(String idCard, String specialType, String specialDetailId) { |
|
|
|
// 查询人员基础信息
|
|
|
|
LambdaQueryWrapper<LingshanSpecialCrowdPersonEntity> personQ = new LambdaQueryWrapper<>(); |
|
|
|
personQ.eq(LingshanSpecialCrowdPersonEntity::getIdCard, idCard); |
|
|
|
LingshanSpecialCrowdPersonEntity person = specialCrowdPersonDao.selectOne(personQ); |
|
|
|
|
|
|
|
if (person == null) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, "未找到该人员信息"); |
|
|
|
} |
|
|
|
|
|
|
|
// 查询人员类别详情
|
|
|
|
LingShanSpecialCrowdDetailBaseExcelData d; |
|
|
|
switch (specialType) { |
|
|
|
case "anzhibangjiao": |
|
|
|
LingshanSpecialCrowdDetailAzbjEntity e1 = specialCrowdDetailAzbjDao.selectById(specialDetailId); |
|
|
|
d = ConvertUtils.sourceToTarget(e1, LingShanSpecialCrowdDetailAzbjExcelData.class); |
|
|
|
break; |
|
|
|
case "xinfangrenyuan": |
|
|
|
LingshanSpecialCrowdDetailXfryEntity e2 = specialCrowdDetailXfryDao.selectById(specialDetailId); |
|
|
|
d = ConvertUtils.sourceToTarget(e2, LingshanSpecialCrowdDetailXfryExcelData.class); |
|
|
|
break; |
|
|
|
case "xidurenyuan": |
|
|
|
LingshanSpecialCrowdDetailJdryEntity e3 = specialCrowdDetailJdryDao.selectById(specialDetailId); |
|
|
|
d = ConvertUtils.sourceToTarget(e3, LingshanSpecialCrowdDetailJdryExcelData.class); |
|
|
|
break; |
|
|
|
case "shequjiaozheng": |
|
|
|
LingshanSpecialCrowdDetailSqjzEntity e4 = specialCrowdDetailSqjzDao.selectById(specialDetailId); |
|
|
|
d = ConvertUtils.sourceToTarget(e4, LingshanSpecialCrowdDetailSqjzExcelData.class); |
|
|
|
break; |
|
|
|
case "jingzhanghuanzhe": |
|
|
|
LingshanSpecialCrowdDetailJzhzEntity e5 = specialCrowdDetailJzhzDao.selectById(specialDetailId); |
|
|
|
d = ConvertUtils.sourceToTarget(e5, LingshanSpecialCrowdDetailJzhzExcelData.class); |
|
|
|
break; |
|
|
|
default: |
|
|
|
d = new LingShanSpecialCrowdDetailBaseExcelData(); |
|
|
|
} |
|
|
|
|
|
|
|
if (d == null) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, "未找到该人员的类别详细信息"); |
|
|
|
} |
|
|
|
|
|
|
|
d.setName(person.getName()); |
|
|
|
|
|
|
|
// 查询居民信息
|
|
|
|
IcResiUserEntity resiBaseEntity = icResiUserDao.selectResiUserEntityByIdCard(idCard, EpmetRequestHolder.getLoginUserCustomerId()); |
|
|
|
if (resiBaseEntity == null) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, "未找到该人员信息"); |
|
|
|
} |
|
|
|
|
|
|
|
// 户籍地
|
|
|
|
d.setDomicilePlace(resiBaseEntity.getHjszd()); |
|
|
|
|
|
|
|
// 住址
|
|
|
|
d.setAddress(getAddressOfResi(resiBaseEntity.getGridId(), resiBaseEntity.getHomeId())); |
|
|
|
|
|
|
|
// 生日
|
|
|
|
d.setBirthday(resiBaseEntity.getBirthday()); |
|
|
|
|
|
|
|
// 性别
|
|
|
|
String gender = resiBaseEntity.getGender(); |
|
|
|
String genderStr; |
|
|
|
if (gender == null) { |
|
|
|
genderStr = "保密"; |
|
|
|
} else if (gender.equals("0")) { |
|
|
|
genderStr = "男"; |
|
|
|
} else if (gender.equals("1")) { |
|
|
|
genderStr = "女"; |
|
|
|
} else { |
|
|
|
genderStr = "未知"; |
|
|
|
} |
|
|
|
d.setGender(resiBaseEntity.getGender()); |
|
|
|
d.setGenderZh(genderStr); |
|
|
|
d.setMobile(resiBaseEntity.getMobile()); |
|
|
|
|
|
|
|
// 民族
|
|
|
|
AtomicReference<String> nationZh = new AtomicReference(); |
|
|
|
List<OptionResultDTO> nationDict = getResultDataOrReturnNull(adminOpenFeignClient.getNationOption(), ServiceConstant.EPMET_ADMIN_SERVER); |
|
|
|
if (CollectionUtils.isNotEmpty(nationDict)) { |
|
|
|
nationDict.stream().forEach(n -> { |
|
|
|
if (n.getValue().equals(resiBaseEntity.getMz())) { |
|
|
|
nationZh.set(n.getLabel()); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
d.setNation(nationZh.get()); |
|
|
|
return d; |
|
|
|
} |
|
|
|
|
|
|
|
private String getAddressOfResi(String gridId, String homeId) { |
|
|
|
|
|
|
|
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(gridId); |
|
|
|
String allParentName = gridInfo.getAllParentName(); |
|
|
|
String gridNamePath = gridInfo.getGridNamePath(); |
|
|
|
|
|
|
|
// IcNeighborHoodDTO nei = getResultDataOrReturnNull(govOrgOpenFeignClient.getIcNeighbordhoodById(villageId), ServiceConstant.GOV_ORG_SERVER);
|
|
|
|
// IcBuildingDTO buildingDTO = getResultDataOrReturnNull(govOrgOpenFeignClient.getBuildingById(buildId), ServiceConstant.GOV_ORG_SERVER);
|
|
|
|
// IcBuildingUnitDTO unit = getResultDataOrReturnNull(govOrgOpenFeignClient.getUnitById(unitId), ServiceConstant.GOV_ORG_SERVER);
|
|
|
|
HouseAgencyInfoResultDTO houseInfo = getResultDataOrReturnNull(govOrgOpenFeignClient.getHouseAgencyInfo(homeId), ServiceConstant.GOV_ORG_SERVER); |
|
|
|
return String.format("%s-%s-%s", allParentName, gridNamePath, houseInfo.getFullName()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<LingShanSpecialCrowdListResultDTO> listSpecialCrowds(String orgId, String orgType, String specialType, String name, String mobile, |
|
|
|
String idCard, Integer pageNo, Integer pageSize) { |
|
|
|
String customerId = EpmetRequestHolder.getLoginUserCustomerId(); |
|
|
|
|
|
|
|
String orgIdPath = null; |
|
|
|
if (StringUtils.isNotBlank(orgId)) { |
|
|
|
orgIdPath = CustomerOrgRedis.getOrgIdPath(orgId, orgType); |
|
|
|
} |
|
|
|
PageHelper.startPage(pageNo, pageSize); |
|
|
|
List<LingShanSpecialCrowdListResultDTO> l = specialCrowdPersonTypeDao.listSpecialCrowds(orgIdPath, orgType, specialType, name, mobile, idCard); |
|
|
|
l.forEach(i -> { |
|
|
|
IcResiUserDTO resi = icResiUserDao.getResiUserByIdCard(i.getIdCard(), customerId); |
|
|
|
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(resi.getGridId()); |
|
|
|
i.setOrgNamePath(gridInfo.getAgencyName().concat("-").concat(gridInfo.getGridName())); |
|
|
|
i.setAddress(getAddressOfResi(resi.getGridId(), resi.getHomeId())); |
|
|
|
i.setSpecialTypeDisplay(LingShanSpecialCrowdTypeEnums.getByType(i.getSpecialType()).getName()); |
|
|
|
}); |
|
|
|
return new PageData<>(l, new PageInfo<>(l).getTotal()); |
|
|
|
} |
|
|
|
} |
|
|
|