diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/IpUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/IpUtils.java index 33846da5c2..8aabf5f5d9 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/IpUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/IpUtils.java @@ -62,8 +62,6 @@ public class IpUtils { if (StringUtils.isEmpty(ip) || IP_UNKNOWN.equalsIgnoreCase(ip)) { ip = request.getRemoteAddr(); } - - logger.info("getIpAddr origin ip:{}",ip); //对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割 if (ip != null) { //"***.***.***.***".length() = 15 if (ip.indexOf(StrConstant.COMMA) > 0) { @@ -74,6 +72,7 @@ public class IpUtils { } catch (Exception e) { logger.error("IpUtils getIpAddr ERROR ", e); } + return ip; } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/basereport/result/EventInfoResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/basereport/result/EventInfoResultDTO.java index cce7f1bb65..4396b6cb07 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/basereport/result/EventInfoResultDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/basereport/result/EventInfoResultDTO.java @@ -47,7 +47,7 @@ public class EventInfoResultDTO implements Serializable { * 事件类别 */ private String eventCategory; - + private String parentEventCategory; /** * 上报时间 YYYY-MM-DD HH:MM:SS */ @@ -78,6 +78,8 @@ public class EventInfoResultDTO implements Serializable { */ private String successfulOrNo; + private String status; + /** * 办结层级 01省、自治区、直辖市 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/DataReportingServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/DataReportingServiceImpl.java index 5c386342e9..bda9076789 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/DataReportingServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/DataReportingServiceImpl.java @@ -2,6 +2,7 @@ package com.epmet.service.impl; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.Result; import com.epmet.constant.OrgTypeConstant; import com.epmet.constant.ProjectConstant; import com.epmet.dto.basereport.form.EventInfoFormDTO; @@ -19,6 +20,7 @@ import com.epmet.dto.user.result.MidPatrolDetailResult; import com.epmet.dto.user.result.MidPatrolRecordResult; import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity; import com.epmet.entity.stats.CustomerProjectCategoryDictEntity; +import com.epmet.feign.OperCrmOpenFeignClient; import com.epmet.service.DataReportingService; import com.epmet.service.evaluationindex.screen.ScreenCustomerAgencyService; import com.epmet.service.evaluationindex.screen.ScreenCustomerGridService; @@ -61,6 +63,8 @@ public class DataReportingServiceImpl implements DataReportingService { private StatsStaffPatrolService statsStaffPatrolService; @Resource private CustomerProjectCategoryDictService customerProjectCategoryDictService; + @Resource + private OperCrmOpenFeignClient operCrmOpenFeignClient; /** * @Author sun @@ -153,10 +157,16 @@ public class DataReportingServiceImpl implements DataReportingService { if(CollectionUtils.isEmpty(projectList)) { return Collections.emptyList(); } + Map epmetCodeMap = new HashMap<>(); + Result parentCustomer = operCrmOpenFeignClient.getExternalAndParentCustomerId(formDTO.getCustomerId()); + if (StringUtils.isNotBlank(parentCustomer.getData())) { + customerProjectCategoryDictService.getByCategoryCodeMap(parentCustomer.getData()); + } + Map codeMap = customerProjectCategoryDictService.getByCategoryCodeMap(formDTO.getCustomerId());; //项目ID不为空时,因为只有一条,可以直接处理 if (StringUtils.isNotEmpty(formDTO.getProjectId())) { list = projectList.stream().map(project -> { - EventInfoResultDTO dto = getEventInfoResultDTO(project); + EventInfoResultDTO dto = getEventInfoResultDTO(project, epmetCodeMap, codeMap); if (OrgTypeConstant.AGENCY.equals(project.getOrgType())) { ScreenCustomerAgencyEntity agency = screenCustomerAgencyService.getAgencyById(project.getOrgId()); dto.setOrgCode(agency.getCode()); @@ -173,7 +183,7 @@ public class DataReportingServiceImpl implements DataReportingService { Map agencyMap = screenCustomerAgencyService.getAgencyList(formDTO.getCustomerId()); Map gridMap = screenCustomerGridService.getGridList(formDTO.getCustomerId()); list = projectList.stream().map(project -> { - EventInfoResultDTO dto = getEventInfoResultDTO(project); + EventInfoResultDTO dto = getEventInfoResultDTO(project, epmetCodeMap, codeMap); if (OrgTypeConstant.AGENCY.equals(project.getOrgType())) { ScreenCustomerAgencyEntity agency = agencyMap.get(project.getOrgId()); dto.setOrgCode(agency.getCode()); @@ -189,25 +199,29 @@ public class DataReportingServiceImpl implements DataReportingService { return list.stream().filter(item -> StringUtils.isNotBlank(item.getEventCategory())).collect(Collectors.toList()); } - private EventInfoResultDTO getEventInfoResultDTO(ScreenProjectDataDTO project) { + private EventInfoResultDTO getEventInfoResultDTO(ScreenProjectDataDTO project, Map epmetCodeMap, Map codeMap) { EventInfoResultDTO dto = new EventInfoResultDTO(); dto.setId(project.getProjectId()); dto.setCustomerId(project.getCustomerId()); dto.setEventName(project.getProjectTitle()); dto.setReporterId(project.getProjectCreator()); String categoryCode = project.getCategoryCode().split(StrConstant.COMMA)[0]; + String parentCode = null == codeMap.get(categoryCode)?null:codeMap.get(categoryCode).getParentCategoryCode(); //如果是孔村、榆山、锦水的项目需要关联分类字典表 if("2fe0065f70ca0e23ce4c26fca5f1d933".equals(project.getCustomerId()) || "44876154d10d7cb7affd92000f84f833".equals(project.getCustomerId()) || "46c55cb862d6d5e6d05d2ab61a1cc07e".equals(project.getCustomerId())) { - CustomerProjectCategoryDictEntity categoryEntity = customerProjectCategoryDictService.getByCategoryCode(project.getCustomerId(), categoryCode); + CustomerProjectCategoryDictEntity categoryEntity = codeMap.get(categoryCode); if (null != categoryEntity) { categoryCode = categoryEntity.getEpmetCategoryCode(); + parentCode = epmetCodeMap.get(categoryEntity.getEpmetCategoryCode()).getParentCategoryCode(); } else { categoryCode = null; + parentCode = null; } } dto.setEventCategory(categoryCode); + dto.setParentEventCategory(parentCode); dto.setReportTime(project.getProjectCreateTime()); dto.setHappenDate(DateUtils.parseDate(DateUtils.format(project.getProjectCreateTime()), DateUtils.DATE_PATTERN)); dto.setHappenPlace(project.getProjectAddress()); @@ -244,7 +258,7 @@ public class DataReportingServiceImpl implements DataReportingService { dto.setCompleteLevel("07"); } } - + dto.setStatus(getProjectStatus(project.getProjectStatusCode())); dto.setCompleteTime(project.getCloseCaseTime()); dto.setLat(project.getLatitude()); dto.setLng(project.getLongitude()); @@ -268,6 +282,19 @@ public class DataReportingServiceImpl implements DataReportingService { } } + private String getProjectStatus(String status) { + switch (status) { + case ProjectConstant.PENDING: + return "01"; + case ProjectConstant.CLOSED: + return "02"; + case ProjectConstant.CLOSED_CASE: + return "03"; + default: + return null; + } + } + @Override public List getPatrolRecordList(MidPatrolFormDTO formDTO) { return userService.getPatrolRecordList(formDTO); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/CustomerProjectCategoryDictService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/CustomerProjectCategoryDictService.java index cc8633b08f..02a859423a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/CustomerProjectCategoryDictService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/CustomerProjectCategoryDictService.java @@ -24,6 +24,7 @@ import com.epmet.entity.issue.IssueProjectCategoryDictEntity; import com.epmet.entity.stats.CustomerProjectCategoryDictEntity; import java.util.List; +import java.util.Map; /** * 客户项目分类字典表 @@ -65,4 +66,6 @@ public interface CustomerProjectCategoryDictService extends BaseService getByCategoryCodeMap(String customerId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/CustomerProjectCategoryDictServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/CustomerProjectCategoryDictServiceImpl.java index d7c81c93ad..592e2a33b6 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/CustomerProjectCategoryDictServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/CustomerProjectCategoryDictServiceImpl.java @@ -34,7 +34,11 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.Collections; import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; /** * 客户项目分类字典表 @@ -135,4 +139,15 @@ public class CustomerProjectCategoryDictServiceImpl extends BaseServiceImpl getByCategoryCodeMap(String customerId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(CustomerProjectCategoryDictEntity::getCustomerId, customerId); + List list = baseDao.selectList(wrapper); + if (CollectionUtils.isEmpty(list)) { + return Collections.emptyMap(); + } + return list.stream().collect(Collectors.toMap(CustomerProjectCategoryDictEntity::getCategoryCode, Function.identity())); + } } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java index 267ef87956..cde9814019 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java @@ -337,7 +337,7 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl list = testExcelImportResult.getList(); if (CollectionUtils.isNotEmpty(list)){ String customerId = tokenDto.getCustomerId(); - List existsNames = baseDao.selectOrgByOrgName(list.stream().map(m -> m.getOrganizationName()).collect(Collectors.toList()), customerId); + List existsNames = baseDao.selectOrgByOrgName(list.stream().map(ImportCommunitySelfOrganization::getOrganizationName).collect(Collectors.toList()), customerId); Map> groupByName = list.stream().collect(Collectors.groupingBy(ImportCommunitySelfOrganization::getOrganizationName)); groupByName.forEach((k,v) -> { if (v.size() > NumConstant.ONE){ @@ -399,4 +399,4 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl { + Map getUserMap(); } \ No newline at end of file diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseDisputeProcessServiceImpl.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseDisputeProcessServiceImpl.java index 2a9e99acbf..e20b533616 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseDisputeProcessServiceImpl.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseDisputeProcessServiceImpl.java @@ -20,22 +20,26 @@ package com.epmet.opendata.service.impl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.RenException; -import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.SystemMessageType; import com.epmet.dto.basereport.form.EventInfoFormDTO; import com.epmet.dto.basereport.result.EventInfoResultDTO; import com.epmet.feign.DataStatisticalOpenFeignClient; import com.epmet.opendata.dao.BaseDisputeProcessDao; +import com.epmet.opendata.entity.BaseConflictsResolveEntity; import com.epmet.opendata.entity.BaseDisputeProcessEntity; +import com.epmet.opendata.service.BaseConflictsResolveService; import com.epmet.opendata.service.BaseDisputeProcessService; import com.epmet.opendata.service.ExDeptService; +import com.epmet.opendata.service.ExUserService; import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.Date; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * 事件信息表 @@ -49,6 +53,10 @@ public class BaseDisputeProcessServiceImpl extends BaseServiceImpl deptMap = exDeptService.getDeptMap(); + Map userMap = exUserService.getUserMap(); List list = result.getData(); - if (CollectionUtils.isNotEmpty(list)) { - List entityList = ConvertUtils.sourceToTarget(list, BaseDisputeProcessEntity.class); - entityList.forEach(item -> { - item.setDetpId(deptMap.get(item.getOrgCode())); - }); - if(SystemMessageType.PROJECT_ADD.equals(formDTO.getType())){ - insertBatch(entityList); - }else { - updateBatchById(entityList); - } - } + saveEvent(formDTO, deptMap, userMap, list); //分批次循环 while (CollectionUtils.isNotEmpty(list)) { formDTO.setPageNo(formDTO.getPageNo() + NumConstant.ONE); result = dataStatisticalOpenFeignClient.getEventInfo(formDTO); list = result.getData(); - if (CollectionUtils.isNotEmpty(list)) { - List entityList = ConvertUtils.sourceToTarget(list, BaseDisputeProcessEntity.class); - entityList.forEach(item -> { - item.setDetpId(deptMap.get(item.getOrgCode())); - }); - if("add".equals(formDTO.getType())){ - insertBatch(entityList); - }else { - updateBatchById(entityList); - } - } + saveEvent(formDTO, deptMap, userMap, list); } } + private void saveEvent(EventInfoFormDTO formDTO, Map deptMap, Map userMap, List list) { + if (CollectionUtils.isNotEmpty(list)) { + + List resolveList = list.stream().map(item -> { + BaseConflictsResolveEntity entity = new BaseConflictsResolveEntity(); + entity.setId(item.getId()); + entity.setGridId(deptMap.get(item.getOrgCode())); + entity.setGridName(item.getOrgName()); + entity.setEventName(item.getEventName()); + entity.setHappenDate(item.getHappenDate()); + entity.setHappenPlace(item.getHappenPlace()); + entity.setEventDescription(item.getEventDescription()); + entity.setLng(item.getLng().toString()); + entity.setLat(item.getLat().toString()); + entity.setCreateBy(String.valueOf(userMap.get(item.getReporterId()))); + entity.setCreateDate(item.getReportTime()); + entity.setUpdateDate(new Date()); + entity.setStatus(item.getStatus()); + entity.setFirstEventCategory(item.getParentEventCategory()); + entity.setSecondEventCategory(item.getEventCategory()); + entity.setResolveWay(item.getWaysOfResolving()); + entity.setResolveGridLevel(item.getCompleteLevel()); + entity.setResolveTime(item.getCompleteTime()); + if(SystemMessageType.PROJECT_ADD.equals(formDTO.getType())) { + entity.setFlag(NumConstant.ZERO_STR); + } + return entity; + }).collect(Collectors.toList()); + + if(SystemMessageType.PROJECT_ADD.equals(formDTO.getType())){ + baseConflictsResolveService.insertBatch(resolveList); + }else { + baseConflictsResolveService.updateBatchById(resolveList); + } + } + } + } \ No newline at end of file diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/ExUserServiceImpl.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/ExUserServiceImpl.java index 4badca6794..d692687303 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/ExUserServiceImpl.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/ExUserServiceImpl.java @@ -17,23 +17,18 @@ package com.epmet.opendata.service.impl; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; -import com.epmet.commons.tools.constant.FieldConstant; -import com.epmet.commons.tools.page.PageData; -import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.opendata.dao.ExUserDao; -import com.epmet.opendata.dto.ExUserDTO; import com.epmet.opendata.entity.ExUserEntity; import com.epmet.opendata.service.ExUserService; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * 系统用户中间表 @@ -45,4 +40,13 @@ import java.util.Map; public class ExUserServiceImpl extends BaseServiceImpl implements ExUserService { + @Override + public Map getUserMap() { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + List list = baseDao.selectList(wrapper); + if (CollectionUtils.isEmpty(list)) { + return Collections.emptyMap(); + } + return list.stream().collect(Collectors.toMap(ExUserEntity::getQxUserId, ExUserEntity::getUserId, (key1, key2) -> key2)); + } } \ No newline at end of file