Browse Source

联建单位和活动数据导入

dev_shibei_match
zhaoqifeng 4 years ago
parent
commit
0955e36811
  1. 2
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  2. 31
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyActivityServiceImpl.java
  3. 69
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyUnitServiceImpl.java

2
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java

@ -145,6 +145,8 @@ public enum EpmetErrorCode {
PATROL_REPEATED_SUBMIT_ERROR(8521, "巡查已结束,请勿重复提交"),
PATROL_END_TIME_ERROR(8522, "巡查结束时间不能小于巡查开始时间"),
TIME_FORMAT_ERROR(8523, "时间格式错误"),
//社区党建
PARTY_UNIT_NAME_EXITED(8531, "单位名称已存在"),
// 社区自组织
COMMUNITY_SELF_ORGANIZATION_REPART_ERROR(8524, "社区自组织名称已存在"),

31
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyActivityServiceImpl.java

@ -217,13 +217,38 @@ public class IcPartyActivityServiceImpl extends BaseServiceImpl<IcPartyActivityD
Iterator<IcPartyActivityImportExcel> iterator = result.iterator();
while (iterator.hasNext()) {
IcPartyActivityImportExcel obj = iterator.next();
//单位名称不能为空,不可重复
if (StringUtils.isBlank(obj.getUnitName().trim())) {
//单位名称校验
if (StringUtils.isBlank(obj.getUnitName())) {
numList.add(obj.getRowNum());
log.warn(String.format("单位名称为空,行号->%s", obj.getRowNum()));
iterator.remove();
} else if (null == option.get(obj.getUnitName())){
numList.add(obj.getRowNum());
log.warn(String.format("单位名称不存在,行号->%s", obj.getRowNum()));
iterator.remove();
}
//服务事项校验
if (StringUtils.isBlank(obj.getServiceMatter())) {
numList.add(obj.getRowNum());
log.warn(String.format("服务事项为空,行号->%s", obj.getRowNum()));
iterator.remove();
} else if (null == categoryMap.get(obj.getServiceMatter())){
numList.add(obj.getRowNum());
log.warn(String.format("服务事项不存在,行号->%s", obj.getRowNum()));
iterator.remove();
}
//活动标题 活动目标 活动内容 活动时间 活动地址 活动地址经度 活动地址纬度 活动结果
if(StringUtils.isBlank(obj.getTitle()) || StringUtils.isBlank(obj.getTarget()) ||
StringUtils.isBlank(obj.getContent()) ||
StringUtils.isBlank(obj.getActivityTime()) ||
StringUtils.isBlank(obj.getAddress()) ||
StringUtils.isBlank(obj.getLatitude()) ||
StringUtils.isBlank(obj.getLongitude()) ||
StringUtils.isBlank(obj.getResult())) {
numList.add(obj.getRowNum());
log.warn(String.format("活动标题、活动目标、活动内容、活动时间、活动地址、活动地址经度、活动地址纬度、活动结果为空,行号->%s", obj.getRowNum()));
iterator.remove();
}
}
if (CollectionUtils.isEmpty(result)) {
Collections.sort(numList);

69
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyUnitServiceImpl.java

@ -27,6 +27,7 @@ import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.enums.DictTypeEnum;
import com.epmet.commons.tools.enums.PartyUnitTypeEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
@ -36,7 +37,6 @@ import com.epmet.commons.tools.utils.ExcelPoiUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.IcPartyUnitDao;
import com.epmet.dto.IcPartyUnitDTO;
import com.epmet.dto.form.GridOptionFormDTO;
import com.epmet.dto.form.PartyUnitFormDTO;
import com.epmet.dto.form.demand.ServiceQueryFormDTO;
import com.epmet.dto.form.demand.SubCodeFormDTO;
@ -169,9 +169,19 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl<IcPartyUnitDao, IcPa
if (CollectionUtils.isNotEmpty(dto.getServiceMatterList())) {
entity.setServiceMatter(StringUtils.join(dto.getServiceMatterList(), StrConstant.COMMA));
}
LambdaQueryWrapper<IcPartyUnitEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(IcPartyUnitEntity::getAgencyId, entity.getAgencyId());
wrapper.eq(IcPartyUnitEntity::getUnitName, entity.getUnitName());
List<IcPartyUnitEntity> list = baseDao.selectList(wrapper);
if(StringUtils.isBlank(entity.getId())) {
if (CollectionUtils.isNotEmpty(list)) {
throw new EpmetException(EpmetErrorCode.PARTY_UNIT_NAME_EXITED.getCode(), EpmetErrorCode.PARTY_UNIT_NAME_EXITED.getMsg(), EpmetErrorCode.PARTY_UNIT_NAME_EXITED.getMsg());
}
insert(entity);
} else {
if (CollectionUtils.isNotEmpty(list) && list.get(0).getId().equals(entity.getId())) {
throw new EpmetException(EpmetErrorCode.PARTY_UNIT_NAME_EXITED.getCode(), EpmetErrorCode.PARTY_UNIT_NAME_EXITED.getMsg(), EpmetErrorCode.PARTY_UNIT_NAME_EXITED.getMsg());
}
updateById(entity);
}
}
@ -266,19 +276,59 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl<IcPartyUnitDao, IcPa
List<IcPartyUnitImportExcel> result = importResult.getList();
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId());
//获取组织下网格信息
GridOptionFormDTO formDTO = new GridOptionFormDTO();
formDTO.setAgencyId(staffInfoCache.getAgencyId());
//1.数据校验 只允许导入当前组织下的网格的数据
//网格名称不一样的数据舍弃
if (null == staffInfoCache) {
throw new EpmetException(8000, "获取用户缓存失败");
}
SubCodeFormDTO codeFormDTO = new SubCodeFormDTO();
codeFormDTO.setCustomerId(tokenDto.getCustomerId());
codeFormDTO.setParentCategoryCode("1010");
Map<String, String> categoryMap = icResiDemandDictService.querySubCodeList(codeFormDTO).stream().collect(Collectors.toMap(OptionDTO::getLabel, OptionDTO::getValue));
//1.数据校验
Iterator<IcPartyUnitImportExcel> iterator = result.iterator();
while (iterator.hasNext()) {
IcPartyUnitImportExcel obj = iterator.next();
//单位名称不能为空,不可重复
if (StringUtils.isBlank(obj.getUnitName().trim())) {
if (StringUtils.isBlank(obj.getUnitName())) {
numList.add(obj.getRowNum());
log.warn(String.format("单位名称为空,行号->%s", obj.getRowNum()));
iterator.remove();
} else {
LambdaQueryWrapper<IcPartyUnitEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(IcPartyUnitEntity::getAgencyId, staffInfoCache.getAgencyId());
wrapper.eq(IcPartyUnitEntity::getUnitName, obj.getUnitName());
List<IcPartyUnitEntity> list = baseDao.selectList(wrapper);
if (CollectionUtils.isNotEmpty(list)) {
numList.add(obj.getRowNum());
log.warn(String.format("单位名称已存在,行号->%s", obj.getRowNum()));
iterator.remove();
}
}
//分类校验
if (StringUtils.isBlank(obj.getType()) || null == PartyUnitTypeEnum.getCode(obj.getType())) {
numList.add(obj.getRowNum());
log.warn(String.format("分类名不存在,行号->%s", obj.getRowNum()));
iterator.remove();
}
//服务事项校验
if (StringUtils.isNotBlank(obj.getServiceMatter())) {
List<String> matters = Arrays.asList(obj.getServiceMatter().split(StrConstant.COLON));
matters.forEach(item -> {
if (null == categoryMap.get(item)) {
numList.add(obj.getRowNum());
log.warn(String.format("服务事项不存在,行号->%s", obj.getRowNum()));
iterator.remove();
}
});
}
//联系人 联系电话 在职党员 地址 中心位置经度 中心位置纬度 校验
if (StringUtils.isBlank(obj.getContact()) || StringUtils.isBlank(obj.getContactMobile()) ||
StringUtils.isBlank(obj.getContact()) ||
null == obj.getMemberCount() ||
StringUtils.isBlank(obj.getLatitude()) ||
StringUtils.isBlank(obj.getLongitude())) {
numList.add(obj.getRowNum());
log.warn(String.format("联系人、联系电话、在职党员、地址、中心位置经度、中心位置纬度为空,行号->%s", obj.getRowNum()));
iterator.remove();
}
}
@ -287,10 +337,7 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl<IcPartyUnitDao, IcPa
String subList = numList.stream().map(String::valueOf).collect(Collectors.joining("、"));
return new Result().error(9999, "第" + subList + "行未成功!");
}
SubCodeFormDTO codeFormDTO = new SubCodeFormDTO();
codeFormDTO.setCustomerId(tokenDto.getCustomerId());
codeFormDTO.setParentCategoryCode("1010");
Map<String, String> categoryMap = icResiDemandDictService.querySubCodeList(codeFormDTO).stream().collect(Collectors.toMap(OptionDTO::getLabel, OptionDTO::getValue));
List<IcPartyUnitEntity> list = result.stream().map(item -> {
IcPartyUnitEntity entity = new IcPartyUnitEntity();
entity.setCustomerId(tokenDto.getCustomerId());

Loading…
Cancel
Save