diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java
index 055d174c2e..3321091b4f 100644
--- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java
@@ -10,6 +10,7 @@ import org.aspectj.lang.ProceedingJoinPoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DuplicateKeyException;
+import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
@@ -286,6 +287,7 @@ public abstract class BaseRequestLogAspect {
if (object != null
&& !(object instanceof ServletRequest)
&& !(object instanceof ServletResponse)
+ && !(object instanceof MultipartFile)
) {
try {
// 尝试作为json解析
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/ThreadDispatcherConfig.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/ThreadDispatcherConfig.java
new file mode 100644
index 0000000000..1b2d32c2cc
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/ThreadDispatcherConfig.java
@@ -0,0 +1,39 @@
+/**
+ * Copyright (c) 2018 人人开源 All rights reserved.
+ *
+ * https://www.renren.io
+ *
+ * 版权所有,侵权必究!
+ */
+
+package com.epmet.commons.tools.config;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.filter.RequestContextFilter;
+import org.springframework.web.servlet.DispatcherServlet;
+
+import javax.annotation.PostConstruct;
+
+
+/**
+ * DESC:设置线程继承属性为true,便于子线程获取到父线程的request,两个都设置为了保险
+ *
+ * @author Mark sunlightcs@gmail.com
+ * @since 1.0.0
+ */
+@Configuration
+public class ThreadDispatcherConfig {
+
+ @Autowired
+ RequestContextFilter requestContextFilter;
+ @Autowired
+ DispatcherServlet dispatcherServlet;
+
+ @PostConstruct
+ public void init() {
+ // 设置线程继承属性为true,便于子线程获取到父线程的request,两个都设置为了保险。
+ requestContextFilter.setThreadContextInheritable(true);
+ dispatcherServlet.setThreadContextInheritable(true);
+ }
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java
index 400e3893e4..77875d5415 100644
--- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java
@@ -171,4 +171,7 @@ public interface Constant {
* 被禁用标识
* */
String DISABLE = "disable";
+
+ String OPITON_SOURCE_REMOTE = "remote";
+ String OPITON_SOURCE_LOCAL = "local";
}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/SpecialCustomerOrgConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/SpecialCustomerOrgConstant.java
new file mode 100644
index 0000000000..05058b1211
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/SpecialCustomerOrgConstant.java
@@ -0,0 +1,31 @@
+package com.epmet.commons.tools.constant;
+
+
+/**
+ * 需要特殊处理的客户id
+ *
+ * @author Mark sunlightcs@gmail.com
+ * @since 1.0.0
+ */
+public interface SpecialCustomerOrgConstant {
+ /**
+ * 榆山街道组织id
+ */
+ String YUSHAN_AGENCY_ID_PROD="1258587398679126017";
+
+ /**
+ * 南宁社区-开发测试用的
+ */
+ String test="6e511da6816e53af4cda952365a26eb9";
+
+ // /**
+ // * 榆山生产客户id
+ // */
+ // String YUSHAN_PROD_CUSTOMER_ID = "46c55cb862d6d5e6d05d2ab61a1cc07e";
+ //
+ // /**
+ // * 榆山测试客户id
+ // */
+ // String YUSHAN_TEST_CUSTOMER_ID = "a4bbf298d8e427844038cee466f022ef";
+
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java
index 67f467f63c..62d9fef763 100644
--- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java
@@ -107,4 +107,7 @@ public interface StrConstant {
* 积分规则修改的头
*/
String POINT_CHANGE_HEAD = "修改了%s规则,";
+
+ String YES = "是";
+ String NO = "否";
}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/UpdateUserPointsFormDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/UpdateUserPointsFormDTO.java
new file mode 100644
index 0000000000..1eb3092d07
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/UpdateUserPointsFormDTO.java
@@ -0,0 +1,29 @@
+package com.epmet.commons.tools.dto.form;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class UpdateUserPointsFormDTO implements Serializable {
+
+ /**
+ * 行为类型:
+ * 双十信息更新-double_info_update
+ * 网格巡查-grid_patrol
+ * 网格上报事件-grid_report_event
+ * 网格工作上传-grid_work_upload
+ */
+ private String behaviorType;
+
+ /**
+ * 手机号
+ */
+ private String mobile;
+
+ /**
+ * 工作端用户id
+ */
+ private String staffId;
+ private String customerId;
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/BehaviorTypeYuShanEnum.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/BehaviorTypeYuShanEnum.java
new file mode 100644
index 0000000000..8c5b1caf5b
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/BehaviorTypeYuShanEnum.java
@@ -0,0 +1,43 @@
+package com.epmet.commons.tools.enums;
+
+
+/**
+ * 更新用户积分(双实信息更新 网格巡查)
+ * 行为类型枚举类
+ */
+public enum BehaviorTypeYuShanEnum {
+
+ DOUBLE_INFO_UPDATE("double_info_update", "双十信息更新"),
+ GRID_PATROL("grid_patrol", "网格巡查"),
+ GRID_REPORT_EVENT("grid_report_event", "网格上报事件"),
+ GRID_WORK_UPLOAD("grid_work_upload", "网格工作上传"),
+ ;
+
+ private String code;
+ private String name;
+
+
+ BehaviorTypeYuShanEnum(String code, String name) {
+ this.code = code;
+ this.name = name;
+ }
+
+ public static BehaviorTypeYuShanEnum getEnum(String code) {
+ BehaviorTypeYuShanEnum[] values = BehaviorTypeYuShanEnum.values();
+ for (BehaviorTypeYuShanEnum value : values) {
+ if (value.getCode().equals(code)) {
+ return value;
+ }
+ }
+ return null;
+ }
+
+
+ public String getCode() {
+ return code;
+ }
+
+ public String getName() {
+ return name;
+ }
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ExternalApiEnum.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ExternalApiEnum.java
new file mode 100644
index 0000000000..ed916dd6df
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ExternalApiEnum.java
@@ -0,0 +1,35 @@
+package com.epmet.commons.tools.enums;
+
+/**
+ * 外部api
+ */
+public enum ExternalApiEnum {
+
+ /**
+ * 榆山-测试服务器地址
+ */
+ UPDATE_USER_POINTS("/api/points/behavior/updateUserPoints","更新用户积分(双实信息更新 网格巡查)","http://yapi.elinkservice.cn/project/57/interface/api/7466");
+
+ private String apiPath;
+ private String desc;
+ private String descUrl;
+
+
+ ExternalApiEnum(String apiPath, String desc,String descUrl) {
+ this.apiPath = apiPath;
+ this.desc = desc;
+ this.descUrl=descUrl;
+ }
+
+ public String getApiPath() {
+ return apiPath;
+ }
+
+ public String getDesc() {
+ return desc;
+ }
+
+ public String getDescUrl() {
+ return descUrl;
+ }
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ExternalServerEnum.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ExternalServerEnum.java
new file mode 100644
index 0000000000..119a222e27
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ExternalServerEnum.java
@@ -0,0 +1,55 @@
+package com.epmet.commons.tools.enums;
+
+import com.epmet.commons.tools.constant.StrConstant;
+
+
+/**
+ * 外部客户的服务器地址
+ */
+public enum ExternalServerEnum {
+ DEV_TEST("45687aa479955f9d06204d415238f7cc", "https://epdc-api-test.elinkservice.cn/epdc-api"),
+ /**
+ * 榆山-测试服务器地址
+ */
+ YUSHAN_TEST("a4bbf298d8e427844038cee466f022ef", "https://epdc-api-test.elinkservice.cn/epdc-api"),
+ /**
+ * 榆山-生产服务器地址
+ */
+ YUSHAN_PROD("46c55cb862d6d5e6d05d2ab61a1cc07e", "https://epdc-yushan.elinkservice.cn/epdc-api");
+
+
+ private String customerId;
+ private String url;
+
+
+ ExternalServerEnum(String customerId, String url) {
+ this.customerId = customerId;
+ this.url = url;
+ }
+
+ public static String getUrl(String customerId) {
+ ExternalServerEnum[] array = values();
+ for (ExternalServerEnum enumValue : array) {
+ if (enumValue.getCustomerId().equals(customerId)) {
+ return enumValue.getUrl();
+ }
+ }
+ return StrConstant.EPMETY_STR;
+ }
+
+ public String getCustomerId() {
+ return customerId;
+ }
+
+ public void setCustomerId(String customerId) {
+ this.customerId = customerId;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
index eb73373717..91c63770dd 100644
--- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
@@ -651,4 +651,97 @@ public class RedisKeys {
public static String getHouseInfoCacheKey(String houseId,String customerId){
return rootPrefix.concat("house:").concat(customerId).concat(":").concat(houseId);
}
+
+ /**
+ * 居民导入-缓存目录key
+ * @param importTag
+ * @return
+ */
+ public static String icResiImportBaseKey(String importTag) {
+ return rootPrefix.concat("resi:").concat("import:").concat(importTag);
+ }
+
+ /**
+ * 居民导入-数据分类的key
+ * add:新增居民
+ * category:类别变更
+ * transfer:调动
+ * @param importTag
+ * @param type
+ * @return
+ */
+ public static String icResiImportTypeKey(String importTag, String type) {
+ return icResiImportBaseKey(importTag).concat(":").concat(type);
+ }
+
+ /**
+ * 居民导入-详细信息key
+ * @param importTag
+ * @param type
+ * @param resiId
+ * @return
+ */
+ public static String icResiImportResiCategoryKey(String importTag, String type, String resiId) {
+ return icResiImportTypeKey(importTag, type).concat(":").concat(resiId);
+ }
+
+ /**
+ * @Description 临时房屋缓存key
+ * @param customerId
+ * @param userId
+ * @author zxc
+ * @date 2022/2/14 9:38 上午
+ */
+ public static String getTemporaryHouseInfoCacheKey(String customerId,String userId){
+ return rootPrefix.concat("temporary:").concat("temporaryHouse:").concat(customerId).concat(":").concat(userId);
+ }
+
+ /**
+ * @Description 临时网格缓存key
+ * @param customerId
+ * @param userId
+ * @author zxc
+ * @date 2022/2/14 9:38 上午
+ */
+ public static String getTemporaryGridInfoCacheKey(String customerId,String userId){
+ return rootPrefix.concat("temporary:").concat("temporaryGrid:").concat(customerId).concat(":").concat(userId);
+ }
+
+ /**
+ * @Description 临时小区缓存key
+ * @param customerId
+ * @param userId
+ * @author zxc
+ * @date 2022/2/14 9:39 上午
+ */
+ public static String getTemporaryNeighborHoodInfoCacheKey(String customerId,String userId){
+ return rootPrefix.concat("temporary:").concat("temporaryNeighborHood:").concat(customerId).concat(":").concat(userId);
+ }
+
+ /**
+ * @Description 临时楼栋缓存key
+ * @param customerId
+ * @param userId
+ * @author zxc
+ * @date 2022/2/14 9:39 上午
+ */
+ public static String getTemporaryBuildingInfoCacheKey(String customerId,String userId){
+ return rootPrefix.concat("temporary:").concat("temporaryBuilding:").concat(customerId).concat(":").concat(userId);
+ }
+
+ /**
+ * @Description 临时楼栋单元缓存key
+ * @param customerId
+ * @param userId
+ * @author zxc
+ * @date 2022/2/14 1:54 下午
+ */
+ public static String getTemporaryBuildingUnitInfoCacheKey(String customerId,String userId){
+ return rootPrefix.concat("temporary:").concat("temporaryBuildingUnit:").concat(customerId).concat(":").concat(userId);
+ }
+
+ public static String getTemporaryImportResultCacheKey(String customerId,String userId){
+ return rootPrefix.concat("temporary:").concat("temporaryResult:").concat(customerId).concat(":").concat(userId);
+ }
+
}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YuShanSysApiService.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YuShanSysApiService.java
new file mode 100644
index 0000000000..9779c6d990
--- /dev/null
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YuShanSysApiService.java
@@ -0,0 +1,72 @@
+package com.epmet.commons.tools.utils;
+
+
+import com.alibaba.fastjson.JSON;
+import com.epmet.commons.tools.constant.SpecialCustomerOrgConstant;
+import com.epmet.commons.tools.dto.form.UpdateUserPointsFormDTO;
+import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
+import com.epmet.commons.tools.enums.ExternalApiEnum;
+import com.epmet.commons.tools.enums.ExternalServerEnum;
+import com.epmet.commons.tools.exception.EpmetErrorCode;
+import com.epmet.commons.tools.exception.RenException;
+import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.util.List;
+
+/**
+ * e事通调用榆山api
+ *
+ * @author yinzuomei
+ * @date 2022-02-16
+ **/
+@Service
+@Slf4j
+public class YuShanSysApiService {
+
+
+ /**
+ * 更新用户积分(双实信息更新 网格巡查)
+ *
+ * @return
+ */
+ @Async
+ public void updateUserPoints(String customerId, List paramList) {
+ if (StringUtils.isBlank(customerId) || CollectionUtils.isEmpty(paramList)) {
+ throw new RenException("参数错误");
+ }
+ String serverUrl = ExternalServerEnum.getUrl(customerId);
+ if (StringUtils.isBlank(serverUrl)) {
+ log.warn(String.format("当前客户:%s,未配置服务器地址", customerId));
+ return;
+ }
+ String apiPath = serverUrl.concat(ExternalApiEnum.UPDATE_USER_POINTS.getApiPath());
+ log.info(String.format("updateUserPoints 接口路径:%s", apiPath));
+ for (UpdateUserPointsFormDTO formDTO : paramList) {
+ try {
+ CustomerStaffInfoCacheResult staff = CustomerStaffRedis.getStaffInfo(customerId, formDTO.getStaffId());
+ //只有榆山街道的工作人员才调用
+ if (null != staff && (staff.getAgencyId().equals(SpecialCustomerOrgConstant.YUSHAN_AGENCY_ID_PROD) || staff.getAgencyPIds().contains(SpecialCustomerOrgConstant.YUSHAN_AGENCY_ID_PROD))) {
+ formDTO.setMobile(staff.getMobile());
+ //测试用手机号
+ // formDTO.setMobile("13205302682");
+ Result res = HttpClientManager.getInstance().sendPostByJSON(apiPath, JSON.toJSONString(formDTO));
+ Result result = JSON.parseObject(res.getData(), Result.class);
+ log.info(String.format("updateUserPoints 入参:%s;返参:%s", JSON.toJSONString(formDTO),JSON.toJSONString(result)));
+ if (!result.success()) {
+ log.warn("updateUserPoints failed:{}", JSON.toJSONString(result));
+ }
+ }
+ } catch (Exception e) {
+ log.warn("updateUserPoints exception 入参:{}", JSON.toJSONString(formDTO));
+ throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), e.getMessage());
+ }
+ }
+ }
+
+
+}
diff --git a/epmet-gateway/src/main/java/com/epmet/GatewayApplication.java b/epmet-gateway/src/main/java/com/epmet/GatewayApplication.java
index a1630c821e..064b59610e 100644
--- a/epmet-gateway/src/main/java/com/epmet/GatewayApplication.java
+++ b/epmet-gateway/src/main/java/com/epmet/GatewayApplication.java
@@ -10,6 +10,7 @@ package com.epmet;
import com.epmet.commons.tools.aspect.ServletExceptionHandler;
import com.epmet.commons.tools.config.RedissonConfig;
+import com.epmet.commons.tools.config.ThreadDispatcherConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@@ -27,7 +28,7 @@ import org.springframework.context.annotation.FilterType;
@EnableDiscoveryClient
@EnableFeignClients
//@ServletComponentScan
-@ComponentScan(basePackages = {"com.epmet.*"}, excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {RedissonConfig.class, ServletExceptionHandler.class}))
+@ComponentScan(basePackages = {"com.epmet.*"}, excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {RedissonConfig.class, ThreadDispatcherConfig.class, ServletExceptionHandler.class}))
public class GatewayApplication {
public static void main(String[] args) {
diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/result/CustomerDataManageResultDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/result/CustomerDataManageResultDTO.java
index e736309945..f293af93d0 100644
--- a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/result/CustomerDataManageResultDTO.java
+++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/result/CustomerDataManageResultDTO.java
@@ -44,6 +44,10 @@ public class CustomerDataManageResultDTO {
private Integer patrolCount = 0;
//巡查时长
private String patrolDuration;
+ /**
+ * 例行工作次数
+ */
+ private Integer patrolRoutineWorkTimes = 0;
//未转换前的巡查时长
private Integer patrolDurationInteger = 0;
//数据对应dateId
diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/StatsStaffPatrolRecordDailyDao.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/StatsStaffPatrolRecordDailyDao.java
index 49c101c018..e1fe7554ec 100644
--- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/StatsStaffPatrolRecordDailyDao.java
+++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/StatsStaffPatrolRecordDailyDao.java
@@ -40,6 +40,7 @@ public interface StatsStaffPatrolRecordDailyDao extends BaseDao userIds,
@Param("startDateId") String startDateID,
@Param("endDateID") String endDateID);
+
+ /**
+ * desc: 获取例行工作次数
+ * @param patrolForm
+ * @return
+ */
+ List getRoutineWorkCount(CustomerDataManageFormDTO patrolForm);
}
diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/CustomerDataManageExcel.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/CustomerDataManageExcel.java
index 821a11426f..65f55557fe 100644
--- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/CustomerDataManageExcel.java
+++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/CustomerDataManageExcel.java
@@ -47,6 +47,9 @@ public class CustomerDataManageExcel {
@Excel(name = "巡查时长")
private String patrolDuration;
+ @Excel(name = "例行工作次数")
+ private Integer patrolRoutineWorkTimes;
+
/**
* 未转换前的巡查时长
*/
diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java
index 84dec4c630..527b6a484b 100644
--- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java
+++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java
@@ -1,60 +1,61 @@
package com.epmet.dataaggre.service.datastats.impl;
import com.alibaba.fastjson.JSON;
-import com.epmet.commons.dynamic.datasource.annotation.DataSource;
-import com.epmet.commons.tools.constant.NumConstant;
-import com.epmet.commons.tools.enums.OrgLevelEnum;
-import com.epmet.commons.tools.exception.RenException;
-import com.epmet.commons.tools.feign.ResultDataResolver;
-import com.epmet.commons.tools.utils.ConvertUtils;
-import com.epmet.commons.tools.utils.DateUtils;
-import com.epmet.commons.tools.utils.ExcelUtils;
-import com.epmet.dataaggre.constant.DataSourceConstant;
-import com.epmet.dataaggre.constant.OrgConstant;
-import com.epmet.dataaggre.dao.datastats.DataStatsDao;
-import com.epmet.dataaggre.dao.datastats.FactGridMemberStatisticsDailyDao;
-import com.epmet.dataaggre.dto.datastats.FactGroupActDailyDTO;
-import com.epmet.dataaggre.dto.datastats.form.*;
-import com.epmet.dataaggre.dto.datastats.result.*;
+ import com.epmet.commons.dynamic.datasource.annotation.DataSource;
+ import com.epmet.commons.tools.constant.NumConstant;
+ import com.epmet.commons.tools.enums.OrgLevelEnum;
+ import com.epmet.commons.tools.enums.OrgTypeEnum;
+ import com.epmet.commons.tools.exception.RenException;
+ import com.epmet.commons.tools.feign.ResultDataResolver;
+ import com.epmet.commons.tools.utils.ConvertUtils;
+ import com.epmet.commons.tools.utils.DateUtils;
+ import com.epmet.commons.tools.utils.ExcelUtils;
+ import com.epmet.dataaggre.constant.DataSourceConstant;
+ import com.epmet.dataaggre.constant.OrgConstant;
+ import com.epmet.dataaggre.dao.datastats.DataStatsDao;
+ import com.epmet.dataaggre.dao.datastats.FactGridMemberStatisticsDailyDao;
+ import com.epmet.dataaggre.dto.datastats.FactGroupActDailyDTO;
+ import com.epmet.dataaggre.dto.datastats.form.*;
+ import com.epmet.dataaggre.dto.datastats.result.*;
import com.epmet.dataaggre.dto.epmetuser.FactIcuserCategoryAnalysisDailyDTO;
import com.epmet.dataaggre.dto.epmetuser.form.GridMemberPatrolListFormDTO;
-import com.epmet.dataaggre.dto.epmetuser.result.GridMemberPatrolListResultDTO;
-import com.epmet.dataaggre.dto.epmetuser.result.PatrolDailySumResult;
-import com.epmet.dataaggre.dto.evaluationindex.ScreenAgencyOrGridListDTO;
-import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO;
-import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerGridDTO;
-import com.epmet.dataaggre.dto.evaluationindex.ScreenGovernRankDataDailyDTO;
+ import com.epmet.dataaggre.dto.epmetuser.result.GridMemberPatrolListResultDTO;
+ import com.epmet.dataaggre.dto.epmetuser.result.PatrolDailySumResult;
+ import com.epmet.dataaggre.dto.evaluationindex.ScreenAgencyOrGridListDTO;
+ import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO;
+ import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerGridDTO;
+ import com.epmet.dataaggre.dto.evaluationindex.ScreenGovernRankDataDailyDTO;
import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO;
import com.epmet.dataaggre.dto.govorg.result.GridDateIdResultDTO;
import com.epmet.dataaggre.dto.govorg.result.GridMemberDataAnalysisResultDTO;
-import com.epmet.dataaggre.dto.govproject.form.ProjectTotalFormDTO;
-import com.epmet.dataaggre.dto.resigroup.ActCategoryDictDTO;
-import com.epmet.dataaggre.dto.resigroup.result.GroupActRankDetailDTO;
-import com.epmet.dataaggre.entity.datastats.DimAgencyEntity;
-import com.epmet.dataaggre.entity.datastats.FactAgencyGovernDailyEntity;
-import com.epmet.dataaggre.excel.CustomerDataManageExcel;
-import com.epmet.dataaggre.service.datastats.DataStatsService;
-import com.epmet.dataaggre.service.epmetuser.StatsStaffPatrolRecordDailyService;
-import com.epmet.dataaggre.service.evaluationindex.EvaluationIndexService;
-import com.epmet.dataaggre.service.govorg.GovOrgService;
-import com.epmet.dataaggre.service.opercrm.CustomerRelation;
-import com.github.pagehelper.PageHelper;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletResponse;
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.text.NumberFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.*;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.stream.Collectors;
+ import com.epmet.dataaggre.dto.govproject.form.ProjectTotalFormDTO;
+ import com.epmet.dataaggre.dto.resigroup.ActCategoryDictDTO;
+ import com.epmet.dataaggre.dto.resigroup.result.GroupActRankDetailDTO;
+ import com.epmet.dataaggre.entity.datastats.DimAgencyEntity;
+ import com.epmet.dataaggre.entity.datastats.FactAgencyGovernDailyEntity;
+ import com.epmet.dataaggre.excel.CustomerDataManageExcel;
+ import com.epmet.dataaggre.service.datastats.DataStatsService;
+ import com.epmet.dataaggre.service.epmetuser.StatsStaffPatrolRecordDailyService;
+ import com.epmet.dataaggre.service.evaluationindex.EvaluationIndexService;
+ import com.epmet.dataaggre.service.govorg.GovOrgService;
+ import com.epmet.dataaggre.service.opercrm.CustomerRelation;
+ import com.github.pagehelper.PageHelper;
+ import lombok.extern.slf4j.Slf4j;
+ import org.apache.commons.collections4.CollectionUtils;
+ import org.apache.commons.lang3.StringUtils;
+ import org.springframework.beans.factory.annotation.Autowired;
+ import org.springframework.stereotype.Service;
+
+ import javax.servlet.http.HttpServletResponse;
+ import java.math.BigDecimal;
+ import java.math.RoundingMode;
+ import java.text.NumberFormat;
+ import java.text.ParseException;
+ import java.text.SimpleDateFormat;
+ import java.util.*;
+ import java.util.concurrent.atomic.AtomicInteger;
+ import java.util.concurrent.atomic.AtomicReference;
+ import java.util.stream.Collectors;
/**
* @Author sun
@@ -98,15 +99,15 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
formDTO.setDateId(format.format(yesterday));
}
- //0.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表
+ //NumConstant.ZERO.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表
agencyList = indexService.getAgencyIdsByAgencyId(formDTO.getAgencyId());
agencyList.add(formDTO.getAgencyId());
//1.查询组织下注册用户最新日统计数据【只查询注册用户的统计数据,不涉及参与用户的】
List userList = dataStatsDao.getAgnecyRegUser(agencyList, formDTO.getDateId());
- int userTotal = 0;
- int resiTotal = 0;
- int partyMemberTotal = 0;
+ int userTotal = NumConstant.ZERO;
+ int resiTotal = NumConstant.ZERO;
+ int partyMemberTotal = NumConstant.ZERO;
for (AgencyBasicDataResultDTO u : userList){
userTotal+=u.getUserTotal();
resiTotal+=u.getResiTotal();
@@ -114,15 +115,15 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
}
resultDTO.setUserTotal(userTotal);
resultDTO.setResiTotal(resiTotal);
- resultDTO.setResiRatio(resultDTO.getResiTotal() == 0 || resultDTO.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getResiTotal() / (float) resultDTO.getUserTotal())));
+ resultDTO.setResiRatio(resultDTO.getResiTotal() == NumConstant.ZERO || resultDTO.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getResiTotal() / (float) resultDTO.getUserTotal())));
resultDTO.setPartyMemberTotal(partyMemberTotal);
- resultDTO.setPartyMemberRatio(resultDTO.getPartyMemberTotal() == 0 || resultDTO.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPartyMemberTotal() / (float) resultDTO.getUserTotal())));
+ resultDTO.setPartyMemberRatio(resultDTO.getPartyMemberTotal() == NumConstant.ZERO || resultDTO.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPartyMemberTotal() / (float) resultDTO.getUserTotal())));
//2.查询组织下最新群组日统计数据
List groupList = dataStatsDao.getAgnecyGroup(agencyList, formDTO.getDateId());
- int groupTotal = 0;
- int ordinaryTotal = 0;
- int branchTotal = 0;
+ int groupTotal = NumConstant.ZERO;
+ int ordinaryTotal = NumConstant.ZERO;
+ int branchTotal = NumConstant.ZERO;
for (AgencyBasicDataResultDTO g : groupList){
groupTotal+=g.getGroupTotal();
ordinaryTotal+=g.getOrdinaryTotal();
@@ -130,9 +131,9 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
}
resultDTO.setGroupTotal(groupTotal);
resultDTO.setOrdinaryTotal(ordinaryTotal);
- resultDTO.setOrdinaryRatio(resultDTO.getOrdinaryTotal() == 0 || resultDTO.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getOrdinaryTotal() / (float) resultDTO.getGroupTotal())));
+ resultDTO.setOrdinaryRatio(resultDTO.getOrdinaryTotal() == NumConstant.ZERO || resultDTO.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getOrdinaryTotal() / (float) resultDTO.getGroupTotal())));
resultDTO.setBranchTotal(branchTotal);
- resultDTO.setBranchRatio(resultDTO.getBranchTotal() == 0 || resultDTO.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getBranchTotal() / (float) resultDTO.getGroupTotal())));
+ resultDTO.setBranchRatio(resultDTO.getBranchTotal() == NumConstant.ZERO || resultDTO.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getBranchTotal() / (float) resultDTO.getGroupTotal())));
//3.查询组织下最新话题日统计数据
//状态话题-机关日统计数据表最新日期三种状态数据
@@ -148,21 +149,21 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
//转议题
int shiftIssueTotal = topicSHiftIssue.stream().mapToInt(AgencyBasicDataResultDTO.Topic::getShiftedIssueTotal).sum();
resultDTO.setShiftIssueTotal(shiftIssueTotal);
- resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal())));
+ resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal())));
//热议中
int discussingTotal = hotdiscuss.stream().mapToInt(AgencyBasicDataResultDTO.Topic::getTopicCount).sum();
resultDTO.setDiscussingTotal(discussingTotal);
- resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal())));
+ resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal())));
//已处理
resultDTO.setClosedTopicTotal(closedTotal);
- resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal())));
+ resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal())));
- //4.查询组织下最新议题日统计数据
+ //NumConstant.FOUR.查询组织下最新议题日统计数据
List issueList = dataStatsDao.getAgencyIssue(agencyList, formDTO.getDateId());
- int issueTotal = 0;
- int votingTotal = 0;
- int closedIssueTotal = 0;
- int shiftProjectTotal = 0;
+ int issueTotal = NumConstant.ZERO;
+ int votingTotal = NumConstant.ZERO;
+ int closedIssueTotal = NumConstant.ZERO;
+ int shiftProjectTotal = NumConstant.ZERO;
for (AgencyBasicDataResultDTO i : issueList){
issueTotal+=i.getIssueTotal();
votingTotal+=i.getVotingTotal();
@@ -171,17 +172,17 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
}
resultDTO.setIssueTotal(issueTotal);
resultDTO.setVotingTotal(votingTotal);
- resultDTO.setVotingRatio(resultDTO.getVotingTotal() == 0 || resultDTO.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getVotingTotal() / (float) resultDTO.getIssueTotal())));
+ resultDTO.setVotingRatio(resultDTO.getVotingTotal() == NumConstant.ZERO || resultDTO.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getVotingTotal() / (float) resultDTO.getIssueTotal())));
resultDTO.setClosedIssueTotal(closedIssueTotal);
- resultDTO.setClosedIssueRatio(resultDTO.getClosedIssueTotal() == 0 || resultDTO.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedIssueTotal() / (float) resultDTO.getIssueTotal())));
+ resultDTO.setClosedIssueRatio(resultDTO.getClosedIssueTotal() == NumConstant.ZERO || resultDTO.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedIssueTotal() / (float) resultDTO.getIssueTotal())));
resultDTO.setShiftProjectTotal(shiftProjectTotal);
- resultDTO.setShiftProjectRatio(resultDTO.getShiftProjectTotal() == 0 || resultDTO.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftProjectTotal() / (float) resultDTO.getIssueTotal())));
+ resultDTO.setShiftProjectRatio(resultDTO.getShiftProjectTotal() == NumConstant.ZERO || resultDTO.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftProjectTotal() / (float) resultDTO.getIssueTotal())));
//5.查询组织下最新项目日统计数据
List projectList = dataStatsDao.getAgencyProject(agencyList, formDTO.getDateId());
- int projectTotal = 0;
- int pendingTotal = 0;
- int closedProjectTotal = 0;
+ int projectTotal = NumConstant.ZERO;
+ int pendingTotal = NumConstant.ZERO;
+ int closedProjectTotal = NumConstant.ZERO;
for (AgencyBasicDataResultDTO p : projectList){
projectTotal+=p.getProjectTotal();
pendingTotal+=p.getPendingTotal();
@@ -189,9 +190,9 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
}
resultDTO.setProjectTotal(projectTotal);
resultDTO.setPendingTotal(pendingTotal);
- resultDTO.setPendingRatio(resultDTO.getPendingTotal() == 0 || resultDTO.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPendingTotal() / (float) resultDTO.getProjectTotal())));
+ resultDTO.setPendingRatio(resultDTO.getPendingTotal() == NumConstant.ZERO || resultDTO.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPendingTotal() / (float) resultDTO.getProjectTotal())));
resultDTO.setClosedProjectTotal(closedProjectTotal);
- resultDTO.setClosedProjectRatio(resultDTO.getClosedProjectTotal() == 0 || resultDTO.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedProjectTotal() / (float) resultDTO.getProjectTotal())));
+ resultDTO.setClosedProjectRatio(resultDTO.getClosedProjectTotal() == NumConstant.ZERO || resultDTO.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedProjectTotal() / (float) resultDTO.getProjectTotal())));
return resultDTO;
}
@@ -220,21 +221,21 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
gridIds.add(formDTO.getGridId());
List userList = dataStatsDao.getSubGridUser(gridIds, formDTO.getDateId());
if (userList.size() > NumConstant.ZERO) {
- resultDTO.setUserTotal(userList.get(0).getUserTotal());
- resultDTO.setResiTotal(userList.get(0).getResiTotal());
- resultDTO.setResiRatio(resultDTO.getResiTotal() == 0 || resultDTO.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getResiTotal() / (float) resultDTO.getUserTotal())));
- resultDTO.setPartyMemberTotal(userList.get(0).getPartyMemberTotal());
- resultDTO.setPartyMemberRatio(resultDTO.getPartyMemberTotal() == 0 || resultDTO.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPartyMemberTotal() / (float) resultDTO.getUserTotal())));
+ resultDTO.setUserTotal(userList.get(NumConstant.ZERO).getUserTotal());
+ resultDTO.setResiTotal(userList.get(NumConstant.ZERO).getResiTotal());
+ resultDTO.setResiRatio(resultDTO.getResiTotal() == NumConstant.ZERO || resultDTO.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getResiTotal() / (float) resultDTO.getUserTotal())));
+ resultDTO.setPartyMemberTotal(userList.get(NumConstant.ZERO).getPartyMemberTotal());
+ resultDTO.setPartyMemberRatio(resultDTO.getPartyMemberTotal() == NumConstant.ZERO || resultDTO.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPartyMemberTotal() / (float) resultDTO.getUserTotal())));
}
//2.查询网格下最新群组日统计数据
List groupList = dataStatsDao.getSubGridGroup(gridIds, formDTO.getDateId());
if (groupList.size() > NumConstant.ZERO) {
- resultDTO.setGroupTotal(groupList.get(0).getGroupTotal());
- resultDTO.setOrdinaryTotal(groupList.get(0).getOrdinaryTotal());
- resultDTO.setOrdinaryRatio(resultDTO.getOrdinaryTotal() == 0 || resultDTO.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getOrdinaryTotal() / (float) resultDTO.getGroupTotal())));
- resultDTO.setBranchTotal(groupList.get(0).getBranchTotal());
- resultDTO.setBranchRatio(resultDTO.getBranchTotal() == 0 || resultDTO.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getBranchTotal() / (float) resultDTO.getGroupTotal())));
+ resultDTO.setGroupTotal(groupList.get(NumConstant.ZERO).getGroupTotal());
+ resultDTO.setOrdinaryTotal(groupList.get(NumConstant.ZERO).getOrdinaryTotal());
+ resultDTO.setOrdinaryRatio(resultDTO.getOrdinaryTotal() == NumConstant.ZERO || resultDTO.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getOrdinaryTotal() / (float) resultDTO.getGroupTotal())));
+ resultDTO.setBranchTotal(groupList.get(NumConstant.ZERO).getBranchTotal());
+ resultDTO.setBranchRatio(resultDTO.getBranchTotal() == NumConstant.ZERO || resultDTO.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getBranchTotal() / (float) resultDTO.getGroupTotal())));
}
//3.查询网格下最新话题日统计数据
@@ -245,7 +246,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
List topicShiftIssueList = dataStatsDao.getSubGridTopicShiftIssue(gridIds, formDTO.getDateId());
//热议中话题-网格日统计数据
List hotdiscussList = dataStatsDao.getSubGridTopicHotDiscuss(gridIds, formDTO.getDateId());
- AtomicReference closedTotal = new AtomicReference<>(0);
+ AtomicReference closedTotal = new AtomicReference<>(NumConstant.ZERO);
if (topicList.size() > NumConstant.ZERO) {
resultDTO.setTopicTotal(topicList.stream().collect(Collectors.summingInt(SubGridFormDTO.Topic::getTopicCount)));
topicList.forEach(t -> {
@@ -256,38 +257,38 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
}
//转议题
if (topicShiftIssueList.size() > NumConstant.ZERO) {
- resultDTO.setShiftIssueTotal(topicShiftIssueList.get(0).getShiftedIssueTotal());
- resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal())));
+ resultDTO.setShiftIssueTotal(topicShiftIssueList.get(NumConstant.ZERO).getShiftedIssueTotal());
+ resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal())));
}
//热议中
if (hotdiscussList.size() > NumConstant.ZERO) {
- resultDTO.setDiscussingTotal(hotdiscussList.get(0).getTopicCount());
- resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal())));
+ resultDTO.setDiscussingTotal(hotdiscussList.get(NumConstant.ZERO).getTopicCount());
+ resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal())));
}
//已处理
resultDTO.setClosedTopicTotal(closedTotal.get());
- resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal())));
+ resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal())));
- //4.查询网格下最新议题日统计数据
+ //NumConstant.FOUR.查询网格下最新议题日统计数据
List issueList = dataStatsDao.getSubGridIssue(gridIds, formDTO.getDateId());
if (issueList.size() > NumConstant.ZERO) {
- resultDTO.setIssueTotal(issueList.get(0).getIssueTotal());
- resultDTO.setVotingTotal(issueList.get(0).getVotingTotal());
- resultDTO.setVotingRatio(resultDTO.getVotingTotal() == 0 || resultDTO.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getVotingTotal() / (float) resultDTO.getIssueTotal())));
- resultDTO.setClosedIssueTotal(issueList.get(0).getClosedIssueTotal());
- resultDTO.setClosedIssueRatio(resultDTO.getClosedIssueTotal() == 0 || resultDTO.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedIssueTotal() / (float) resultDTO.getIssueTotal())));
- resultDTO.setShiftProjectTotal(issueList.get(0).getShiftProjectTotal());
- resultDTO.setShiftProjectRatio(resultDTO.getShiftProjectTotal() == 0 || resultDTO.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftProjectTotal() / (float) resultDTO.getIssueTotal())));
+ resultDTO.setIssueTotal(issueList.get(NumConstant.ZERO).getIssueTotal());
+ resultDTO.setVotingTotal(issueList.get(NumConstant.ZERO).getVotingTotal());
+ resultDTO.setVotingRatio(resultDTO.getVotingTotal() == NumConstant.ZERO || resultDTO.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getVotingTotal() / (float) resultDTO.getIssueTotal())));
+ resultDTO.setClosedIssueTotal(issueList.get(NumConstant.ZERO).getClosedIssueTotal());
+ resultDTO.setClosedIssueRatio(resultDTO.getClosedIssueTotal() == NumConstant.ZERO || resultDTO.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedIssueTotal() / (float) resultDTO.getIssueTotal())));
+ resultDTO.setShiftProjectTotal(issueList.get(NumConstant.ZERO).getShiftProjectTotal());
+ resultDTO.setShiftProjectRatio(resultDTO.getShiftProjectTotal() == NumConstant.ZERO || resultDTO.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftProjectTotal() / (float) resultDTO.getIssueTotal())));
}
//5.查询网格下最新项目日统计数据
List projectList = dataStatsDao.getSubGridProject(gridIds, formDTO.getDateId());
if (projectList.size() > NumConstant.ZERO) {
- resultDTO.setProjectTotal(projectList.get(0).getProjectTotal());
- resultDTO.setPendingTotal(projectList.get(0).getPendingTotal());
- resultDTO.setPendingRatio(resultDTO.getPendingTotal() == 0 || resultDTO.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPendingTotal() / (float) resultDTO.getProjectTotal())));
- resultDTO.setClosedProjectTotal(projectList.get(0).getClosedProjectTotal());
- resultDTO.setClosedProjectRatio(resultDTO.getClosedProjectTotal() == 0 || resultDTO.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedProjectTotal() / (float) resultDTO.getProjectTotal())));
+ resultDTO.setProjectTotal(projectList.get(NumConstant.ZERO).getProjectTotal());
+ resultDTO.setPendingTotal(projectList.get(NumConstant.ZERO).getPendingTotal());
+ resultDTO.setPendingRatio(resultDTO.getPendingTotal() == NumConstant.ZERO || resultDTO.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPendingTotal() / (float) resultDTO.getProjectTotal())));
+ resultDTO.setClosedProjectTotal(projectList.get(NumConstant.ZERO).getClosedProjectTotal());
+ resultDTO.setClosedProjectRatio(resultDTO.getClosedProjectTotal() == NumConstant.ZERO || resultDTO.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedProjectTotal() / (float) resultDTO.getProjectTotal())));
}
return resultDTO;
@@ -339,12 +340,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dto.setResiTotal(u.getResiTotal());
}
}
- dto.setPartyMemberRatio(dto.getPartyMemberTotal() == 0 || dto.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPartyMemberTotal() / (float) dto.getUserTotal())));
- dto.setResiRatio(dto.getResiTotal() == 0 || dto.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getResiTotal() / (float) dto.getUserTotal())));
+ dto.setPartyMemberRatio(dto.getPartyMemberTotal() == NumConstant.ZERO || dto.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPartyMemberTotal() / (float) dto.getUserTotal())));
+ dto.setResiRatio(dto.getResiTotal() == NumConstant.ZERO || dto.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getResiTotal() / (float) dto.getUserTotal())));
resultList.add(dto);
}
- //4.按要求排序并返回
+ //NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator() {
@Override
public int compare(SubAgencyUserResultDTO o1, SubAgencyUserResultDTO o2) {
@@ -408,12 +409,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dto.setResiTotal(re.getResiTotal());
}
}
- dto.setPartyMemberRatio(dto.getPartyMemberTotal() == 0 || dto.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPartyMemberTotal() / (float) dto.getUserTotal())));
- dto.setResiRatio(dto.getResiTotal() == 0 || dto.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getResiTotal() / (float) dto.getUserTotal())));
+ dto.setPartyMemberRatio(dto.getPartyMemberTotal() == NumConstant.ZERO || dto.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPartyMemberTotal() / (float) dto.getUserTotal())));
+ dto.setResiRatio(dto.getResiTotal() == NumConstant.ZERO || dto.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getResiTotal() / (float) dto.getUserTotal())));
resultList.add(dto);
}
- //4.按要求排序并返回
+ //NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator() {
@Override
public int compare(SubGridUserResultDTO o1, SubGridUserResultDTO o2) {
@@ -477,12 +478,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dto.setBranchTotal(u.getBranchTotal());
}
}
- dto.setOrdinaryRatio(dto.getOrdinaryTotal() == 0 || dto.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getOrdinaryTotal() / (float) dto.getGroupTotal())));
- dto.setBranchRatio(dto.getBranchTotal() == 0 || dto.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getBranchTotal() / (float) dto.getGroupTotal())));
+ dto.setOrdinaryRatio(dto.getOrdinaryTotal() == NumConstant.ZERO || dto.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getOrdinaryTotal() / (float) dto.getGroupTotal())));
+ dto.setBranchRatio(dto.getBranchTotal() == NumConstant.ZERO || dto.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getBranchTotal() / (float) dto.getGroupTotal())));
resultList.add(dto);
}
- //4.按要求排序并返回
+ //NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator() {
@Override
public int compare(SubAgencyGroupResultDTO o1, SubAgencyGroupResultDTO o2) {
@@ -543,12 +544,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dto.setBranchTotal(re.getBranchTotal());
}
}
- dto.setOrdinaryRatio(dto.getOrdinaryTotal() == 0 || dto.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getOrdinaryTotal() / (float) dto.getGroupTotal())));
- dto.setBranchRatio(dto.getBranchTotal() == 0 || dto.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getBranchTotal() / (float) dto.getGroupTotal())));
+ dto.setOrdinaryRatio(dto.getOrdinaryTotal() == NumConstant.ZERO || dto.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getOrdinaryTotal() / (float) dto.getGroupTotal())));
+ dto.setBranchRatio(dto.getBranchTotal() == NumConstant.ZERO || dto.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getBranchTotal() / (float) dto.getGroupTotal())));
resultList.add(dto);
}
- //4.按要求排序并返回
+ //NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator() {
@Override
public int compare(SubGridGroupResultDTO o1, SubGridGroupResultDTO o2) {
@@ -604,10 +605,10 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
List hotdiscuss = dataStatsDao.getSubAgencyTopicHotDiscuss(agencyIds, formDTO.getDateId());
subAgencyList.forEach(sub -> {
SubAgencyTopicResultDTO resultDTO = new SubAgencyTopicResultDTO();
- AtomicInteger topicTotal = new AtomicInteger(0);
- AtomicInteger closedTotal = new AtomicInteger(0);
- AtomicInteger shiftIssueTotal = new AtomicInteger(0);
- AtomicInteger hotdiscussTotal = new AtomicInteger(0);
+ AtomicInteger topicTotal = new AtomicInteger(NumConstant.ZERO);
+ AtomicInteger closedTotal = new AtomicInteger(NumConstant.ZERO);
+ AtomicInteger shiftIssueTotal = new AtomicInteger(NumConstant.ZERO);
+ AtomicInteger hotdiscussTotal = new AtomicInteger(NumConstant.ZERO);
topic.forEach(t -> {
if (t.getAgencyId().equals(sub.getAgencyId())) {
topicTotal.addAndGet(t.getTopicCount());
@@ -633,28 +634,25 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
resultDTO.setAreaCode(null == sub.getAreaCode() ? "" : sub.getAreaCode());
resultDTO.setTopicTotal(topicTotal.get());
resultDTO.setDiscussingTotal(hotdiscussTotal.get());
- resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal())));
+ resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal())));
resultDTO.setClosedTopicTotal(closedTotal.get());
- resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal())));
+ resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal())));
resultDTO.setShiftIssueTotal(shiftIssueTotal.get());
- resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal())));
+ resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal())));
resultList.add(resultDTO);
});
//3.按要求排序并返回
- Collections.sort(resultList, new Comparator() {
- @Override
- public int compare(SubAgencyTopicResultDTO o1, SubAgencyTopicResultDTO o2) {
- if ("discussing".equals(formDTO.getType())) {
- return o2.getDiscussingTotal().compareTo(o1.getDiscussingTotal());
- } else if ("closed".equals(formDTO.getType())) {
- return o2.getClosedTopicTotal().compareTo(o1.getClosedTopicTotal());
- } else if ("shiftIssue".equals(formDTO.getType())) {
- return o2.getShiftIssueTotal().compareTo(o1.getShiftIssueTotal());
- } else {
- return o2.getTopicTotal().compareTo(o1.getTopicTotal());
- }
+ resultList.sort((o1, o2) -> {
+ if ("discussing".equals(formDTO.getType())) {
+ return o2.getDiscussingTotal().compareTo(o1.getDiscussingTotal());
+ } else if ("closed".equals(formDTO.getType())) {
+ return o2.getClosedTopicTotal().compareTo(o1.getClosedTopicTotal());
+ } else if ("shiftIssue".equals(formDTO.getType())) {
+ return o2.getShiftIssueTotal().compareTo(o1.getShiftIssueTotal());
+ } else {
+ return o2.getTopicTotal().compareTo(o1.getTopicTotal());
}
});
@@ -700,10 +698,10 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
List hotdiscuss = dataStatsDao.getSubGridTopicHotDiscuss(gridIds, formDTO.getDateId());
gridList.forEach(gr -> {
SubGridTopicResultDTO resultDTO = new SubGridTopicResultDTO();
- AtomicInteger topicTotal = new AtomicInteger(0);
- AtomicInteger closedTotal = new AtomicInteger(0);
- AtomicInteger shiftIssueTotal = new AtomicInteger(0);
- AtomicInteger hotdiscussTotal = new AtomicInteger(0);
+ AtomicInteger topicTotal = new AtomicInteger(NumConstant.ZERO);
+ AtomicInteger closedTotal = new AtomicInteger(NumConstant.ZERO);
+ AtomicInteger shiftIssueTotal = new AtomicInteger(NumConstant.ZERO);
+ AtomicInteger hotdiscussTotal = new AtomicInteger(NumConstant.ZERO);
topic.forEach(t -> {
if (t.getGridId().equals(gr.getGridId())) {
topicTotal.addAndGet(t.getTopicCount());
@@ -727,11 +725,11 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
resultDTO.setGridName(gr.getGridName());
resultDTO.setTopicTotal(topicTotal.get());
resultDTO.setDiscussingTotal(hotdiscussTotal.get());
- resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal())));
+ resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal())));
resultDTO.setClosedTopicTotal(closedTotal.get());
- resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal())));
+ resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal())));
resultDTO.setShiftIssueTotal(shiftIssueTotal.get());
- resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal())));
+ resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal())));
resultList.add(resultDTO);
});
@@ -802,13 +800,13 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dto.setShiftProjectTotal(u.getShiftProjectTotal());
}
}
- dto.setVotingRatio(dto.getVotingTotal() == 0 || dto.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getVotingTotal() / (float) dto.getIssueTotal())));
- dto.setClosedIssueRatio(dto.getClosedIssueTotal() == 0 || dto.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedIssueTotal() / (float) dto.getIssueTotal())));
- dto.setShiftProjectRatio(dto.getShiftProjectTotal() == 0 || dto.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getShiftProjectTotal() / (float) dto.getIssueTotal())));
+ dto.setVotingRatio(dto.getVotingTotal() == NumConstant.ZERO || dto.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getVotingTotal() / (float) dto.getIssueTotal())));
+ dto.setClosedIssueRatio(dto.getClosedIssueTotal() == NumConstant.ZERO || dto.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedIssueTotal() / (float) dto.getIssueTotal())));
+ dto.setShiftProjectRatio(dto.getShiftProjectTotal() == NumConstant.ZERO || dto.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getShiftProjectTotal() / (float) dto.getIssueTotal())));
resultList.add(dto);
}
- //4.按要求排序并返回
+ //NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator() {
@Override
public int compare(SubAgencyIssueResultDTO o1, SubAgencyIssueResultDTO o2) {
@@ -872,13 +870,13 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dto.setShiftProjectTotal(re.getShiftProjectTotal());
}
}
- dto.setVotingRatio(dto.getVotingTotal() == 0 || dto.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getVotingTotal() / (float) dto.getIssueTotal())));
- dto.setClosedIssueRatio(dto.getClosedIssueTotal() == 0 || dto.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedIssueTotal() / (float) dto.getIssueTotal())));
- dto.setShiftProjectRatio(dto.getShiftProjectTotal() == 0 || dto.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getShiftProjectTotal() / (float) dto.getIssueTotal())));
+ dto.setVotingRatio(dto.getVotingTotal() == NumConstant.ZERO || dto.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getVotingTotal() / (float) dto.getIssueTotal())));
+ dto.setClosedIssueRatio(dto.getClosedIssueTotal() == NumConstant.ZERO || dto.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedIssueTotal() / (float) dto.getIssueTotal())));
+ dto.setShiftProjectRatio(dto.getShiftProjectTotal() == NumConstant.ZERO || dto.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getShiftProjectTotal() / (float) dto.getIssueTotal())));
resultList.add(dto);
}
- //4.按要求排序并返回
+ //NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator() {
@Override
public int compare(SubGridIssueResultDTO o1, SubGridIssueResultDTO o2) {
@@ -943,12 +941,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dto.setClosedProjectTotal(u.getClosedProjectTotal());
}
}
- dto.setPendingRatio(dto.getPendingTotal() == 0 || dto.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPendingTotal() / (float) dto.getProjectTotal())));
- dto.setClosedProjectRatio(dto.getClosedProjectTotal() == 0 || dto.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedProjectTotal() / (float) dto.getProjectTotal())));
+ dto.setPendingRatio(dto.getPendingTotal() == NumConstant.ZERO || dto.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPendingTotal() / (float) dto.getProjectTotal())));
+ dto.setClosedProjectRatio(dto.getClosedProjectTotal() == NumConstant.ZERO || dto.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedProjectTotal() / (float) dto.getProjectTotal())));
resultList.add(dto);
}
- //4.按要求排序并返回
+ //NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator() {
@Override
public int compare(SubAgencyProjectResultDTO o1, SubAgencyProjectResultDTO o2) {
@@ -1009,12 +1007,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dto.setClosedProjectTotal(re.getClosedProjectTotal());
}
}
- dto.setPendingRatio(dto.getPendingTotal() == 0 || dto.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPendingTotal() / (float) dto.getProjectTotal())));
- dto.setClosedProjectRatio(dto.getClosedProjectTotal() == 0 || dto.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedProjectTotal() / (float) dto.getProjectTotal())));
+ dto.setPendingRatio(dto.getPendingTotal() == NumConstant.ZERO || dto.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPendingTotal() / (float) dto.getProjectTotal())));
+ dto.setClosedProjectRatio(dto.getClosedProjectTotal() == NumConstant.ZERO || dto.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedProjectTotal() / (float) dto.getProjectTotal())));
resultList.add(dto);
}
- //4.按要求排序并返回
+ //NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator() {
@Override
public int compare(SubGridProjectResultDTO o1, SubGridProjectResultDTO o2) {
@@ -1278,7 +1276,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
resultList.add(dto);
}
- //4.按要求排序并返回
+ //NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator() {
@Override
public int compare(AgencyGovrnResultDTO o1, AgencyGovrnResultDTO o2) {
@@ -1380,7 +1378,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
resultList.add(dto);
}
- //4.按要求排序并返回
+ //NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator() {
@Override
public int compare(GridGovrnResultDTO o1, GridGovrnResultDTO o2) {
@@ -1388,7 +1386,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
return o2.getGroupSelfGovernRatio().compareTo(o1.getGroupSelfGovernRatio());
} else if ("grid".equals(formDTO.getType())) {
return o2.getGridSelfGovernRatio().compareTo(o1.getGridSelfGovernRatio());
- } else if ("community".equals(formDTO.getType())) {
+ } else if (OrgLevelEnum.COMMUNITY.getCode().equals(formDTO.getType())) {
return o2.getCommunityResolvedRatio().compareTo(o1.getCommunityResolvedRatio());
} else if ("department".equals(formDTO.getType())) {
return o2.getDistrictDeptResolvedRatio().compareTo(o1.getDistrictDeptResolvedRatio());
@@ -1471,18 +1469,18 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
formDTO.setDateId(format.format(yesterday));
}
BaseStatsDataResultDTO result = new BaseStatsDataResultDTO();
- result.setTopicTotal(0);
- result.setTopicIncr(0);
+ result.setTopicTotal(NumConstant.ZERO);
+ result.setTopicIncr(NumConstant.ZERO);
- result.setIssueTotal(0);
- result.setIssueIncr(0);
- result.setProjectTotal(0);
- result.setProjectIncr(0);
- result.setClosedProjectTotal(0);
- result.setClosedProjectIncr(0);
+ result.setIssueTotal(NumConstant.ZERO);
+ result.setIssueIncr(NumConstant.ZERO);
+ result.setProjectTotal(NumConstant.ZERO);
+ result.setProjectIncr(NumConstant.ZERO);
+ result.setClosedProjectTotal(NumConstant.ZERO);
+ result.setClosedProjectIncr(NumConstant.ZERO);
- //0.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表
+ //NumConstant.ZERO.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表
List agencyList = indexService.getAgencyIdsByAgencyId(formDTO.getAgencyId());
agencyList.add(formDTO.getAgencyId());
TotalAndIncrResultDTO sum = dataStatsDao.getAgencySumTopic(agencyList, formDTO.getDateId());
@@ -1546,7 +1544,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
List result = new ArrayList<>();
//如果是社区 则下级是网格 查询网格的数据
if (OrgLevelEnum.COMMUNITY.getCode().equals(formDTO.getAgencyLevel())){
- //0.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表
+ //NumConstant.ZERO.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表
List subAgencyList = indexService.getSubGridList(formDTO.getAgencyId());
if (subAgencyList.size() < NumConstant.ONE) {
return null;
@@ -1585,7 +1583,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
result.add(resultDTO);
});
}else {
- //0.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表
+ //NumConstant.ZERO.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表
List subAgencyList = indexService.getSubAgencyListByAgency(formDTO.getAgencyId());
if (subAgencyList.size() < NumConstant.ONE) {
return null;
@@ -1636,9 +1634,9 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
resultDTO.setRoutineWorkCount(patrolRecordDTO.getRoutineWorkCount());
resultDTO.setPatrolTotal(patrolRecordDTO.getPatrolTotal());
Integer totalTime = patrolRecordDTO.getTotalTime();
- if (totalTime != null || totalTime > 0){
+ if (totalTime != null || totalTime > NumConstant.ZERO){
int minutes = totalTime / 60;
- if (minutes >0){
+ if (minutes >NumConstant.ZERO){
String totalTimeDesc = minutes / 60 + "小时"+ minutes % 60 + "分";
resultDTO.setPatrolTotalTime(totalTimeDesc);
}
@@ -1649,12 +1647,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
private Integer getTotal(Map startMap, Map endMap,String agencyId){
Integer total1 = startMap.getOrDefault(agencyId,NumConstant.ZERO);
Integer total2 = endMap.getOrDefault(agencyId,NumConstant.ZERO);
- return Math.max(total2-total1,0);
+ return Math.max(total2-total1,NumConstant.ZERO);
}
private String getPercentage(Integer countInt, Integer totalInt) {
if (NumConstant.ZERO == totalInt) {
- return "0%";
+ return "NumConstant.ZERO%";
}
BigDecimal count = new BigDecimal(countInt);
BigDecimal total = new BigDecimal(totalInt);
@@ -1681,7 +1679,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
//根据组织级别判断查询直属下级组织或网格数据
//2.直属网格
- if ("community".equals(formDTO.getAgencyLevel())) {
+ if (OrgLevelEnum.COMMUNITY.getCode().equals(formDTO.getAgencyLevel())) {
//2-1.查询组织直属网格列表【网格维度】
List gridList = indexService.getSubGridList(formDTO.getAgencyId());
if (gridList.size() < NumConstant.ONE) {
@@ -1729,8 +1727,8 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
});
}
- //4.按用户数降序排序并返回
- Collections.sort(resultList, (o1, o2) -> {
+ //NumConstant.FOUR.按用户数降序排序并返回
+ resultList.sort((o1, o2) -> {
//降序
return o2.getUserTotal().compareTo(o1.getUserTotal());
});
@@ -1757,7 +1755,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
//根据组织级别判断查询直属下级组织或网格数据
//2.直属网格
- if ("community".equals(formDTO.getAgencyLevel())) {
+ if (OrgLevelEnum.COMMUNITY.getCode().equals(formDTO.getAgencyLevel())) {
//2-1.查询组织直属网格列表【网格维度】
List gridList = indexService.getSubGridList(formDTO.getAgencyId());
if (gridList.size() < NumConstant.ONE) {
@@ -1798,7 +1796,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
List hotdiscuss = dataStatsDao.getSubAgencyTopicHotDiscuss(agencyIds, formDTO.getDateId());
//3-3.查询直属下级组织小组日统计数据
List list = dataStatsDao.getSubAgencyGroup(agencyIds, formDTO.getDateId());
- //3-4.封装数据
+ //3-NumConstant.FOUR.封装数据
subAgencyList.forEach(sub -> {
SubTopicAndGroupResultDTO resultDTO = new SubTopicAndGroupResultDTO();
resultDTO.setOrgId(sub.getAgencyId());
@@ -1817,12 +1815,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
});
}
- //4.按用户数降序排序并返回
- Collections.sort(resultList, (o1, o2) -> {
+ //NumConstant.FOUR.按用户数降序排序并返回
+ resultList.sort((o1, o2) -> {
//降序
return o2.getTopicTotal().compareTo(o1.getTopicTotal());
});
- AtomicInteger i = new AtomicInteger(1);
+ AtomicInteger i = new AtomicInteger(NumConstant.ONE);
resultList.forEach(e->e.setSort(i.getAndIncrement()));
return resultList;
}
@@ -1876,24 +1874,27 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
*/
@Override
public void CustomerDataManage(CustomerDataManageFormDTO formDTO, HttpServletResponse response) throws Exception {
+ String openTime = formDTO.getStartTime();
List result = operateExport(formDTO).getList();
if (!CollectionUtils.isEmpty(result)){
CustomerDataManageResultDTO.CustomerDataManage c = new CustomerDataManageResultDTO.CustomerDataManage();
c.setOrgName("合计");
- c.setUserCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getUserCount)));
- c.setResidentCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getResidentCount)));
- c.setPartyMemberCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getPartyMemberCount)));
- c.setGroupCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getGroupCount)));
- c.setTopicCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getTopicCount)));
- c.setIssueCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getIssueCount)));
- c.setProjectCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getProjectCount)));
- c.setClosedProjectCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getClosedProjectCount)));
- c.setPatrolPeopleCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolPeopleCount)));
- c.setPatrolCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolCount)));
- c.setPatrolDurationInteger(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolDurationInteger)));
+ c.setUserCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getUserCount).sum());
+ c.setResidentCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getResidentCount).sum());
+ c.setPartyMemberCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getPartyMemberCount).sum());
+ c.setGroupCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getGroupCount).sum());
+ c.setTopicCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getTopicCount).sum());
+ c.setIssueCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getIssueCount).sum());
+ c.setProjectCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getProjectCount).sum());
+ c.setClosedProjectCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getClosedProjectCount).sum());
+ c.setPatrolPeopleCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolPeopleCount).sum());
+ c.setPatrolRoutineWorkTimes(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolRoutineWorkTimes).sum());
+ c.setPatrolCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolCount).sum());
+ c.setPatrolDurationInteger(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolDurationInteger).sum());
c.setPatrolDuration(getHm(c.getPatrolDurationInteger()));
result.add(c);
}
+ formDTO.setStartTime(openTime);
String fileName = excelName(formDTO);
ExcelUtils.exportExcelToTargetDisposeAll(response,fileName,result, CustomerDataManageExcel.class);
}
@@ -1908,7 +1909,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
String result = "0分钟";
if (seconds >= NumConstant.SIXTY) {
Integer hours = seconds / 3600;
- Integer minutes = seconds % 3600 / 60;
+ Integer minutes = seconds % 3600 / NumConstant.SIXTY;
result = (hours < NumConstant.ONE ? "" : hours + "小时") + (minutes < NumConstant.ONE ? "" : minutes + "分钟");
}else if (seconds < NumConstant.SIXTY && seconds > NumConstant.ZERO){
result = "1分钟";
@@ -1928,20 +1929,20 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
s.append(agencyName);
if (StringUtils.isNotBlank(formDTO.getStartTime())){
String startTime = formDTO.getStartTime();
- String sYear = startTime.substring(0, 4);
- String sMonth = startTime.substring(4, 6);
- String sDay = startTime.substring(6, 8);
+ String sYear = startTime.substring(NumConstant.ZERO, NumConstant.FOUR);
+ String sMonth = startTime.substring(NumConstant.FOUR, NumConstant.SIX);
+ String sDay = startTime.substring(NumConstant.SIX, NumConstant.EIGHT);
String endTime = formDTO.getEndTime();
- String eYear = endTime.substring(0, 4);
- String eMonth = endTime.substring(4, 6);
- String eDay = endTime.substring(6, 8);
+ String eYear = endTime.substring(NumConstant.ZERO, NumConstant.FOUR);
+ String eMonth = endTime.substring(NumConstant.FOUR, NumConstant.SIX);
+ String eDay = endTime.substring(NumConstant.SIX, NumConstant.EIGHT);
s.append(sYear).append("年").append(sMonth).append("月").append(sDay).append("日-")
.append(eYear).append("年").append(eMonth).append("月").append(eDay).append("日区间新增值");
}else {
String endTime = formDTO.getEndTime();
- String eYear = endTime.substring(0, 4);
- String eMonth = endTime.substring(4, 6);
- String eDay = endTime.substring(6, 8);
+ String eYear = endTime.substring(NumConstant.ZERO, NumConstant.FOUR);
+ String eMonth = endTime.substring(NumConstant.FOUR, NumConstant.SIX);
+ String eDay = endTime.substring(NumConstant.SIX, NumConstant.EIGHT);
s.append(eYear).append("年").append(eMonth).append("月").append(eDay).append("日截止累计值");
}
return s.toString();
@@ -1976,7 +1977,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
}
//组织或网格Id集合
List idList = agencyGrid.getAgencyGridList().stream().map(ScreenAgencyOrGridListDTO.AgencyGrid::getOrgId).collect(Collectors.toList());
- formDTO.setDataType(!"community".equals(agencyGrid.getLevel()) ? "agency" : "grid");
+ formDTO.setDataType(!OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) ? OrgTypeEnum.AGENCY.getCode() : OrgTypeEnum.GRID.getCode());
formDTO.setIdList(idList);
resultDTO.setTotal(idList.size());
@@ -1984,25 +1985,27 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
formDTO.setSourceType("end");
List userEnd = dataStatsDao.regUserList(formDTO);
HashMap uEndMap = new HashMap<>();
- userEnd.stream().forEach(u->uEndMap.put(u.getOrgId(),u));
+ userEnd.forEach(u->uEndMap.put(u.getOrgId(),u));
List groupEnd = dataStatsDao.groupList(formDTO);
HashMap gEndMap = new HashMap<>();
- groupEnd.stream().forEach(u->gEndMap.put(u.getOrgId(),u));
+ groupEnd.forEach(u->gEndMap.put(u.getOrgId(),u));
List topicEnd = dataStatsDao.topicList(formDTO);
HashMap tEndMap = new HashMap<>();
- topicEnd.stream().forEach(u->tEndMap.put(u.getOrgId(),u));
+ topicEnd.forEach(u->tEndMap.put(u.getOrgId(),u));
List issueEnd = dataStatsDao.issueList(formDTO);
HashMap iEndMap = new HashMap<>();
- issueEnd.stream().forEach(u->iEndMap.put(u.getOrgId(),u));
+ issueEnd.forEach(u->iEndMap.put(u.getOrgId(),u));
List projectEnd = dataStatsDao.projectList(formDTO);
HashMap pEndMap = new HashMap<>();
- projectEnd.stream().forEach(u->pEndMap.put(u.getOrgId(),u));
+ projectEnd.forEach(u->pEndMap.put(u.getOrgId(),u));
//巡查数据不区分区间差值,只计算累计值,人员做去重处理且是有巡查记录的人员 ==
CustomerDataManageFormDTO patrolForm = ConvertUtils.sourceToTarget(formDTO,CustomerDataManageFormDTO.class);
patrolForm.setStartTime(startTimeForm);
List patrolEnd = statsStaffPatrolRecordDailyService.patrolList(patrolForm);
- //4.判断是否需要查询起始日期用户、群组、话题、议题、项目、巡查数据
+ //获取例行工作次数
+ List workCountList = statsStaffPatrolRecordDailyService.getPatrolRecordCount(patrolForm);
+ //NumConstant.FOUR.判断是否需要查询起始日期用户、群组、话题、议题、项目、巡查数据
HashMap uStartMap = new HashMap<>();
HashMap gStartMap = new HashMap<>();
HashMap tStartMap = new HashMap<>();
@@ -2011,87 +2014,101 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
if ("Interval".equals(formDTO.getType())) {
formDTO.setSourceType("start");
List userStart = dataStatsDao.regUserList(formDTO);
- userStart.stream().forEach(u->uStartMap.put(u.getOrgId(),u));
+ userStart.forEach(u->uStartMap.put(u.getOrgId(),u));
List groupStart = dataStatsDao.groupList(formDTO);
- groupStart.stream().forEach(u->gStartMap.put(u.getOrgId(),u));
+ groupStart.forEach(u->gStartMap.put(u.getOrgId(),u));
List topicStart = dataStatsDao.topicList(formDTO);
- topicStart.stream().forEach(u->tStartMap.put(u.getOrgId(),u));
+ topicStart.forEach(u->tStartMap.put(u.getOrgId(),u));
List issueStart = dataStatsDao.issueList(formDTO);
- issueStart.stream().forEach(u->iStartMap.put(u.getOrgId(),u));
+ issueStart.forEach(u->iStartMap.put(u.getOrgId(),u));
List projectStart = dataStatsDao.projectList(formDTO);
- projectStart.stream().forEach(u->pStartMap.put(u.getOrgId(),u));
+ projectStart.forEach(u->pStartMap.put(u.getOrgId(),u));
}
//5.封装数据
- agencyGrid.getAgencyGridList().forEach(org -> {
+ for (ScreenAgencyOrGridListDTO.AgencyGrid org : agencyGrid.getAgencyGridList()) {
CustomerDataManageResultDTO.CustomerDataManage dto = new CustomerDataManageResultDTO.CustomerDataManage();
dto.setOrgId(org.getOrgId());
dto.setOrgName(org.getOrgName());
- int user = 0;
- int resi = 0;
- int part = 0;
- if(uEndMap.containsKey(org.getOrgId())){
+ int user = NumConstant.ZERO;
+ int resi = NumConstant.ZERO;
+ int part = NumConstant.ZERO;
+ if (uEndMap.containsKey(org.getOrgId())) {
user = uEndMap.get(org.getOrgId()).getUserCount();
resi = uEndMap.get(org.getOrgId()).getResidentCount();
part = uEndMap.get(org.getOrgId()).getPartyMemberCount();
- if ("Interval".equals(formDTO.getType())&&uStartMap.containsKey(org.getOrgId())) {
+ if ("Interval".equals(formDTO.getType()) && uStartMap.containsKey(org.getOrgId())) {
user = user - uStartMap.get(org.getOrgId()).getUserCount();
resi = resi - uStartMap.get(org.getOrgId()).getResidentCount();
part = part - uStartMap.get(org.getOrgId()).getPartyMemberCount();
}
}
- int group = 0;
- if(gEndMap.containsKey(org.getOrgId())){
+ int group = NumConstant.ZERO;
+ if (gEndMap.containsKey(org.getOrgId())) {
group = gEndMap.get(org.getOrgId()).getGroupCount();
- if ("Interval".equals(formDTO.getType())&&gStartMap.containsKey(org.getOrgId())) {
+ if ("Interval".equals(formDTO.getType()) && gStartMap.containsKey(org.getOrgId())) {
group = group - gStartMap.get(org.getOrgId()).getGroupCount();
}
}
- int topic = 0;
- if(tEndMap.containsKey(org.getOrgId())){
+ int topic = NumConstant.ZERO;
+ if (tEndMap.containsKey(org.getOrgId())) {
topic = tEndMap.get(org.getOrgId()).getTopicCount();
- if ("Interval".equals(formDTO.getType())&&tStartMap.containsKey(org.getOrgId())) {
+ if ("Interval".equals(formDTO.getType()) && tStartMap.containsKey(org.getOrgId())) {
topic = topic - tStartMap.get(org.getOrgId()).getTopicCount();
}
}
- int issue = 0;
- if(iEndMap.containsKey(org.getOrgId())){
+ int issue = NumConstant.ZERO;
+ if (iEndMap.containsKey(org.getOrgId())) {
issue = iEndMap.get(org.getOrgId()).getIssueCount();
- if ("Interval".equals(formDTO.getType())&&iStartMap.containsKey(org.getOrgId())) {
+ if ("Interval".equals(formDTO.getType()) && iStartMap.containsKey(org.getOrgId())) {
issue = issue - iStartMap.get(org.getOrgId()).getIssueCount();
}
}
- int project = 0;
- int closed = 0;
- if(pEndMap.containsKey(org.getOrgId())){
+ int project = NumConstant.ZERO;
+ int closed = NumConstant.ZERO;
+ if (pEndMap.containsKey(org.getOrgId())) {
project = pEndMap.get(org.getOrgId()).getProjectCount();
closed = pEndMap.get(org.getOrgId()).getClosedProjectCount();
- if ("Interval".equals(formDTO.getType())&&pStartMap.containsKey(org.getOrgId())) {
+ if ("Interval".equals(formDTO.getType()) && pStartMap.containsKey(org.getOrgId())) {
project = project - pStartMap.get(org.getOrgId()).getProjectCount();
closed = closed - pStartMap.get(org.getOrgId()).getClosedProjectCount();
}
}
- int patro = 0;
- int patroCount = 0;
+ int patro = NumConstant.ZERO;
+ int patroCount = NumConstant.ZERO;
String patrolDuration = "";
- int patrolDurationInteger = 0;
+ int patrolDurationInteger = NumConstant.ZERO;
HashSet set = new HashSet();
for (CustomerDataManageResultDTO.CustomerDataManage u : patrolEnd) {
- if ("community".equals(agencyGrid.getLevel()) && org.getOrgId().equals(u.getOrgId())) {
+ if (OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) && org.getOrgId().equals(u.getOrgId())) {
patroCount += u.getPatrolCount();
patrolDurationInteger += u.getPatrolDurationInteger();
set.add(u.getStaffId());
}
- if (!"community".equals(agencyGrid.getLevel()) && u.getOrgId().contains(org.getOrgId())) {
+ if (!OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) && u.getOrgId().contains(org.getOrgId())) {
patroCount += u.getPatrolCount();
patrolDurationInteger += u.getPatrolDurationInteger();
set.add(u.getStaffId());
}
}
+ //例行工作次数累加
+ int patrolRoutineWorkTimes = NumConstant.ZERO;
+ if (CollectionUtils.isNotEmpty(workCountList) && workCountList.get(NumConstant.ZERO) != null) {
+ for (CustomerDataManageResultDTO.CustomerDataManage work : workCountList) {
+ if (OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) && org.getOrgId().equals(work.getOrgId())) {
+ patrolRoutineWorkTimes += work.getPatrolRoutineWorkTimes();
+ set.add(work.getStaffId());
+ } else if (!OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) && work.getOrgId().contains(org.getOrgId())) {
+ patrolRoutineWorkTimes += work.getPatrolRoutineWorkTimes();
+ set.add(work.getStaffId());
+ }
+ }
+ }
+
patro = set.size();
Integer minutes = patrolDurationInteger / 60;
- patrolDuration = (minutes / 60 > 0 ? minutes / 60 + "小时" : "") + (minutes % 60 > 0 ? minutes % 60 + "分钟" : "0分钟");
+ patrolDuration = (minutes / 60 > NumConstant.ZERO ? minutes / 60 + "小时" : "") + (minutes % 60 > NumConstant.ZERO ? minutes % 60 + "分钟" : "0分钟");
dto.setUserCount(user);
dto.setResidentCount(resi);
@@ -2106,10 +2123,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dto.setPatrolDuration(patrolDuration);
dto.setPatrolDurationInteger(patrolDurationInteger);
+ dto.setPatrolRoutineWorkTimes(patrolRoutineWorkTimes);
+
dataManageList.add(dto);
- });
+ }
- //6.默认按用户总数降序
+ //NumConstant.SIX.默认按用户总数降序
Collections.sort(dataManageList, new Comparator() {
@Override
public int compare(CustomerDataManageResultDTO.CustomerDataManage o1, CustomerDataManageResultDTO.CustomerDataManage o2) {
diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StatsStaffPatrolRecordDailyService.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StatsStaffPatrolRecordDailyService.java
index 4bd0b91d93..6b20674c30 100644
--- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StatsStaffPatrolRecordDailyService.java
+++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StatsStaffPatrolRecordDailyService.java
@@ -35,12 +35,13 @@ import java.util.List;
public interface StatsStaffPatrolRecordDailyService extends BaseService {
/**
- * desc:获取组织或网格的 时间段内的总次数等
+ * desc:获取组织或网格的 时间段内的总次数等
+ *
* @param orgIdList
- * @param startDateId
- * @param endDateId
- * @return
- */
+ * @param startDateId
+ * @param endDateId
+ * @return
+ */
List getPatrolSumList(List orgIdList, String startDateId, String endDateId);
/**
@@ -51,11 +52,20 @@ public interface StatsStaffPatrolRecordDailyService extends BaseService listStaffPatrolRecordDailyAnalysis(String gridPids, String gridId, List userIds, String startDateID, String endDateID);
+
+ /**
+ * desc:获取巡查日统计的相关次数
+ *
+ * @param patrolForm
+ * @return
+ */
+ List getPatrolRecordCount(CustomerDataManageFormDTO patrolForm);
}
diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StatsStaffPatrolRecordDailyServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StatsStaffPatrolRecordDailyServiceImpl.java
index 610bdcd81c..d885b50130 100644
--- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StatsStaffPatrolRecordDailyServiceImpl.java
+++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StatsStaffPatrolRecordDailyServiceImpl.java
@@ -52,4 +52,9 @@ public class StatsStaffPatrolRecordDailyServiceImpl extends BaseServiceImpl listStaffPatrolRecordDailyAnalysis(String gridPids, String gridId, List userIds, String startDateID, String endDateID) {
return baseDao.listStaffPatrolRecordDailyAnalysis(gridPids, gridId, userIds, startDateID, endDateID);
}
+
+ @Override
+ public List getPatrolRecordCount(CustomerDataManageFormDTO patrolForm) {
+ return baseDao.getRoutineWorkCount(patrolForm);
+ }
}
diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StatsStaffPatrolRecordDailyDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StatsStaffPatrolRecordDailyDao.xml
index 86aae4d681..273b7e215b 100644
--- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StatsStaffPatrolRecordDailyDao.xml
+++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StatsStaffPatrolRecordDailyDao.xml
@@ -86,5 +86,42 @@
sprd.STAFF_ID,
sprd.GRID_ID
+
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java
index 97453a2f06..e7ba9b027f 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java
@@ -54,6 +54,7 @@ import com.epmet.service.stats.DimAgencyService;
import com.epmet.service.stats.DimCustomerPartymemberService;
import com.epmet.service.stats.DimCustomerService;
import com.epmet.util.DimIdGenerator;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@@ -64,9 +65,7 @@ import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
+import java.util.concurrent.*;
@RequestMapping("demo")
@RestController
@@ -1099,6 +1098,12 @@ public class DemoController {
return new Result();
}
+ ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
+ .setNameFormat("ScreenExtractServiceImpl-pool-%d").build();
+ ExecutorService threadPool = new ThreadPoolExecutor(3, 6,
+ 10L, TimeUnit.MINUTES,
+ new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy());
+
@Autowired
private ScreenProjectCategoryGridAndOrgDailyService screenProjectCategoryGridAndOrgDailyService;
@@ -1113,14 +1118,22 @@ public class DemoController {
if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)){
List daysBetween = DateUtils.getDaysBetween(startDate, endDate);
daysBetween.forEach(d -> {
- screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId,d);
- screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId,d);
+ threadPool.submit(() -> {
+ screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId,d);
+ });
+ threadPool.submit(() -> {
+ screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId,d);
+ });
result.add(d);
redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("gridandorgdailynew"),customerId,result,3*24*60*60L);
});
}else {
- screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId,dateId);
- screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId,dateId);
+ threadPool.submit(() -> {
+ screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId,dateId);
+ });
+ threadPool.submit(() -> {
+ screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId,dateId);
+ });
result.add(dateId);
redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("gridandorgdailynew"),customerId,result,3*24*60*60L);
}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/StatsStaffPatrolRecordDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/StatsStaffPatrolRecordDailyDao.java
index 42233f31d6..7c37db8f28 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/StatsStaffPatrolRecordDailyDao.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/StatsStaffPatrolRecordDailyDao.java
@@ -43,7 +43,7 @@ public interface StatsStaffPatrolRecordDailyDao extends BaseDao insertList);
+ Integer insertBatchOrUpdate(@Param("list") List insertList);
/**
* desc: 删除内部数据
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/mq/ProjectChangedCustomListener.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/mq/ProjectChangedCustomListener.java
index a09e63861c..c4c0138ad0 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/mq/ProjectChangedCustomListener.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/mq/ProjectChangedCustomListener.java
@@ -10,6 +10,7 @@ import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.SpringContextUtils;
+import com.epmet.constant.PingYinConstant;
import com.epmet.constant.SystemMessageType;
import com.epmet.dto.extract.form.ExtractOriginFormDTO;
import com.epmet.service.evaluationindex.extract.todata.FactOriginExtractService;
@@ -66,7 +67,7 @@ public class ProjectChangedCustomListener implements MessageListenerConcurrently
} catch (Exception e) {
//失败不重发
logger.error("consumeMessage fail,msg:{}",e.getMessage());
- return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
+ return ConsumeConcurrentlyStatus.RECONSUME_LATER;
}
log.info("consumeMessage success, cost:{} ms",System.currentTimeMillis() - start);
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
@@ -94,7 +95,7 @@ public class ProjectChangedCustomListener implements MessageListenerConcurrently
}
log.info("消费了项目变动消息,customer id:{}", msgObj.getCustomerId());
- if (org.apache.commons.lang.StringUtils.isNotBlank(pendingMsgLabel)) {
+ if (StringUtils.isNotBlank(pendingMsgLabel)) {
try {
removePendingMqMsgCache(pendingMsgLabel);
} catch (Exception e) {
@@ -109,19 +110,14 @@ public class ProjectChangedCustomListener implements MessageListenerConcurrently
try {
String customerId = msgObj.getCustomerId();
distributedLock = SpringContextUtils.getBean(DistributedLock.class);
- lock = distributedLock.getLock(String.format("lock:project_changed:%s", customerId)
+ lock = distributedLock.getLock(String.format("lock:project_changed:%s:%s", customerId, msgObj.getProjectId())
,30L, 30L, TimeUnit.SECONDS);
if (StringUtils.isBlank(customerId)){
logger.error("consumer project_changed fail,msg:{}",customerId);
return;
}
- //消息被消费太快 业务数据还没有完成 歇一会先
- try {
- Thread.sleep(60L);
- } catch (InterruptedException e) {
- logger.error("consumeMessage sleep exception",e);
- }
+
ExtractOriginFormDTO extractOriginFormDTO = new ExtractOriginFormDTO();
extractOriginFormDTO.setCustomerId(customerId);
@@ -146,21 +142,8 @@ public class ProjectChangedCustomListener implements MessageListenerConcurrently
}
logger.info("consumer projectChanged msg success,{}",aBoolean);
- //发送项目数据上报的mq消息
- if ("6f203e30de1a65aab7e69c058826cd80".equals(customerId)) {
- if ("issue_shift_project".equals(msgObj.getOperation()) || "created".equals(msgObj.getOperation()) || "close".equals(msgObj.getOperation())) {
- String type;
- if ("issue_shift_project".equals(msgObj.getOperation()) || "created".equals(msgObj.getOperation())) {
- type = SystemMessageType.PROJECT_ADD;
- } else {
- type = SystemMessageType.PROJECT_EDIT;
- }
- List projectList = new ArrayList<>();
- projectList.add(msgObj.getProjectId());
- DisputeProcessMQMsg msg = new DisputeProcessMQMsg(customerId, projectList, type);
- SpringContextUtils.getBean(ScreenProjectDataService.class).sendProjectChangeMq(msg);
- }
- }
+ sendProject2OpenData(msgObj, customerId);
+
} catch (RenException e) {
// 如果是我们手动抛出的异常,说明在业务可控范围内。目前不需要MQ重试
logger.error("【RocketMQ】消费项目变动消息失败:",e);
@@ -175,6 +158,29 @@ public class ProjectChangedCustomListener implements MessageListenerConcurrently
}
}
+ /**
+ * desc:发型项目数据到 opendata
+ * @param msgObj
+ * @param customerId
+ */
+ private void sendProject2OpenData(ProjectChangedMQMsg msgObj, String customerId) {
+ //发送项目数据上报的mq消息
+ if (PingYinConstant.PROD_PING_YIN_CUSTOMER_ID.equals(customerId)) {
+ if ("issue_shift_project".equals(msgObj.getOperation()) || "created".equals(msgObj.getOperation()) || "close".equals(msgObj.getOperation())) {
+ String type;
+ if ("issue_shift_project".equals(msgObj.getOperation()) || "created".equals(msgObj.getOperation())) {
+ type = SystemMessageType.PROJECT_ADD;
+ } else {
+ type = SystemMessageType.PROJECT_EDIT;
+ }
+ List projectList = new ArrayList<>();
+ projectList.add(msgObj.getProjectId());
+ DisputeProcessMQMsg msg = new DisputeProcessMQMsg(customerId, projectList, type);
+ SpringContextUtils.getBean(ScreenProjectDataService.class).sendProjectChangeMq(msg);
+ }
+ }
+ }
+
@PreDestroy
public void saveCalStatus() {
//todo
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/biz/impl/BizDataStatsServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/biz/impl/BizDataStatsServiceImpl.java
index 15d3ba8b06..0b0d0d5f1c 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/biz/impl/BizDataStatsServiceImpl.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/biz/impl/BizDataStatsServiceImpl.java
@@ -130,6 +130,7 @@ public class BizDataStatsServiceImpl implements BizDataStatsService {
List insertList = buildInitPatrolStatsData(formDTO, allGridMembers);
Map yesterdayStatsMap = insertList.stream().collect(Collectors.toMap(o -> o.getGridId() + o.getStaffId(), o -> o, (o1, o2) -> o1));
+ log.debug("reloadStaffPatrolStatsData 所有网格员数据{}",JSON.toJSONString(yesterdayStatsMap));
//获取昨日的巡查记录
List yesterdayPatrolList = userService.selectStaffPatrolListByDateId(formDTO.getCustomerId(), formDTO.getDateId());
@@ -138,7 +139,7 @@ public class BizDataStatsServiceImpl implements BizDataStatsService {
//获取昨日的例行工作数据
List yesterdayWorkList = userService.selectRoutineWorkListByDateId(formDTO.getCustomerId(), formDTO.getDateId());
-
+ log.debug("reloadStaffPatrolStatsData 例行工作数据数据{}",JSON.toJSONString(yesterdayWorkList));
//遍历网格员 设置其 巡查次数 巡查时常 上报项目数
yesterdayPatrolList.forEach(patrolRecord -> {
String key = patrolRecord.getGrid().concat(patrolRecord.getStaffId());
@@ -172,7 +173,7 @@ public class BizDataStatsServiceImpl implements BizDataStatsService {
String unqPatrolKey = getUnqPatrolKey(patrol.getGrid(), patrol.getStaffId());
StatsStaffPatrolRecordDailyDTO recordDailyDTO = yesterdayStatsMap.get(unqPatrolKey);
if (recordDailyDTO == null) {
- log.error("have project data but have any patrolRecordDaily,gridId:{},staffId:{}", patrol.getGrid(), patrol.getStaffId());
+ log.error("reloadStaffPatrolStatsData have project data but have any patrolRecordDaily,gridId:{},staffId:{}", patrol.getGrid(), patrol.getStaffId());
return;
}
@@ -181,17 +182,17 @@ public class BizDataStatsServiceImpl implements BizDataStatsService {
});
});
yesterdayWorkList.forEach(work->{
- String key = work.getGridId().concat(work.getUserId());
+ String key = getUnqPatrolKey(work.getGridId(),work.getUserId());
StatsStaffPatrolRecordDailyDTO patrolRecordDailyDTO = yesterdayStatsMap.get(key);
if (patrolRecordDailyDTO == null){
+ log.warn("reloadStaffPatrolStatsData getRoutineWorkCount key{} not exist in gridMembers",key);
return;
}
patrolRecordDailyDTO.setRoutineWorkCount(patrolRecordDailyDTO.getRoutineWorkCount() + NumConstant.ONE);
-
});
- Integer effectRow = statsStaffPatrolService.delAndInsertBatch(formDTO, insertList);
- log.debug("initStaffPatrolStats insert rows:{}", effectRow);
+ Integer effectRow = statsStaffPatrolService.insertBatchOrUpdate(formDTO, insertList);
+ log.info("initStaffPatrolStats insert rows:{}", effectRow);
}
/**
@@ -218,7 +219,7 @@ public class BizDataStatsServiceImpl implements BizDataStatsService {
private void initStaffPatrolTodayData(StaffPatrolStatsFormDTO formDTO, List allGridMembers) {
log.info("initStaffPatrolTodayData param:{}", JSON.toJSONString(formDTO));
List insertList = buildInitPatrolStatsData(formDTO, allGridMembers);
- Integer effectRow = statsStaffPatrolService.delAndInsertBatch(formDTO, insertList);
+ Integer effectRow = statsStaffPatrolService.insertBatchOrUpdate(formDTO, insertList);
log.debug("initStaffPatrolStats insert rows:{}", effectRow);
}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java
index 6d4e5c029f..76764c1322 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java
@@ -278,20 +278,6 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
} catch (Exception e) {
log.error("项目(事件)分析按组织_按天统计失败,customerId为:" + customerId + "dateId为:" + dateId, e);
}
-
- //按天统计:网格内各个分类下的项目总数
- try {
- screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId, dateId);
- } catch (Exception e) {
- log.error("按天统计:网格内各个分类下的项目总数,customerId为:" + customerId + "dateId为:" + dateId, e);
- }
-
- // 按天统计:组织内各个分类下的项目总数
- try {
- screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId, dateId);
- } catch (Exception e) {
- log.error("按天统计:组织内各个分类下的项目总数,customerId为:" + customerId + "dateId为:" + dateId, e);
- }
} finally {
latch.countDown();
log.info("extractDaily 3 thread run end ========= dateId:{},customerId:{}", dateId, customerId);
@@ -342,6 +328,20 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
log.error("网格员数据统计fact_grid_member_statistics_daily抽取失败,customerId为:" + customerId + "dateId为:" + dateId, e);
}
extractPartData(customerId, dateId, null);
+ // 挪到这的原因是因为,要等 screen_project_data表跑完,下面两个方法抽取数据来源于screen_project_data和screen_project_category
+ //按天统计:网格内各个分类下的项目总数
+ try {
+ screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId, dateId);
+ } catch (Exception e) {
+ log.error("按天统计:网格内各个分类下的项目总数,customerId为:" + customerId + "dateId为:" + dateId, e);
+ }
+
+ // 按天统计:组织内各个分类下的项目总数
+ try {
+ screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId, dateId);
+ } catch (Exception e) {
+ log.error("按天统计:组织内各个分类下的项目总数,customerId为:" + customerId + "dateId为:" + dateId, e);
+ }
} finally {
latch.countDown();
log.info("extractDaily 4 thread run end ========= dateId:{},customerId:{}", dateId, customerId);
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/StatsStaffPatrolService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/StatsStaffPatrolService.java
index 1f1f9cefff..7a50ff5546 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/StatsStaffPatrolService.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/StatsStaffPatrolService.java
@@ -10,7 +10,7 @@ import java.util.List;
*/
public interface StatsStaffPatrolService {
- Integer delAndInsertBatch(StaffPatrolStatsFormDTO formDTO, List insertList);
+ Integer insertBatchOrUpdate(StaffPatrolStatsFormDTO formDTO, List insertList);
List selectData(String customerId, String yesterdayStr);
}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/StatsStaffPatrolServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/StatsStaffPatrolServiceImpl.java
index 97bc67ed86..32145d5c76 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/StatsStaffPatrolServiceImpl.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/StatsStaffPatrolServiceImpl.java
@@ -1,6 +1,5 @@
package com.epmet.service.user.impl;
-import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.utils.ConvertUtils;
@@ -33,10 +32,8 @@ public class StatsStaffPatrolServiceImpl implements StatsStaffPatrolService {
@Transactional(rollbackFor = Exception.class)
@Override
- public Integer delAndInsertBatch(StaffPatrolStatsFormDTO formDTO, List insertList) {
- int delete = statsStaffPatrolRecordDailyDao.deleteInternal(formDTO);
- log.debug("delAndInsertBatch delete:{},param:{}", delete, JSON.toJSONString(formDTO));
- return statsStaffPatrolRecordDailyDao.insertBatch(insertList);
+ public Integer insertBatchOrUpdate(StaffPatrolStatsFormDTO formDTO, List insertList) {
+ return statsStaffPatrolRecordDailyDao.insertBatchOrUpdate(insertList);
}
@Override
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/StatsStaffPatrolRecordDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/StatsStaffPatrolRecordDailyDao.xml
index 7e00ed10c8..ebf1914935 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/StatsStaffPatrolRecordDailyDao.xml
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/StatsStaffPatrolRecordDailyDao.xml
@@ -2,7 +2,7 @@
-
+
insert into stats_staff_patrol_record_daily
(
ID,
@@ -63,6 +63,11 @@
ON DUPLICATE KEY UPDATE
PATROL_TOTAL = values(PATROL_TOTAL),
TOTAL_TIME = values(TOTAL_TIME),
+ LATEST_PATROL_STATUS = values(LATEST_PATROL_STATUS),
+ LATEST_PATROL_TIME = values(LATEST_PATROL_TIME),
+ REPORT_PROJECT_COUNT = values(REPORT_PROJECT_COUNT),
+ ROUTINE_WORK_COUNT = values(ROUTINE_WORK_COUNT),
+ UPDATED_TIME = now(),
UPDATED_BY = VALUES(UPDATED_BY)
diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcSocietyOrgController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcSocietyOrgController.java
index 786fc77928..2b07959e33 100644
--- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcSocietyOrgController.java
+++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcSocietyOrgController.java
@@ -20,6 +20,7 @@ package com.epmet.controller;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.constant.NumConstant;
+import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ExcelPoiUtils;
import com.epmet.commons.tools.utils.ExcelUtils;
@@ -27,10 +28,8 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.AddSocietyOrgFormDTO;
import com.epmet.dto.form.EditSocietyOrgFormDTO;
-import com.epmet.dto.form.GetListPlaceOrgFormDTO;
import com.epmet.dto.form.GetListSocietyOrgFormDTO;
import com.epmet.dto.form.demand.ServiceQueryFormDTO;
-import com.epmet.dto.result.GetListPlaceOrgResultDTO;
import com.epmet.dto.result.GetListSocietyOrgResultDTO;
import com.epmet.dto.result.demand.OptionDTO;
import com.epmet.excel.IcSocietyOrgExcel;
@@ -164,9 +163,9 @@ public class IcSocietyOrgController {
Collections.sort(resultList);
String subList = resultList.stream().map(String::valueOf).collect(Collectors.joining("、"));
log.warn(str + "第" + subList + "行未成功!");
- return new Result().error(9999, str + "第" + subList + "行未成功!");
+ return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), str + "第" + subList + "行未成功!");
}
return new Result().ok(str);
}
-}
\ No newline at end of file
+}
diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyActivityServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyActivityServiceImpl.java
index cdfa84d5e2..4cea3f9136 100644
--- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyActivityServiceImpl.java
+++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyActivityServiceImpl.java
@@ -24,6 +24,7 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
+import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.security.dto.TokenDto;
@@ -267,7 +268,7 @@ public class IcPartyActivityServiceImpl extends BaseServiceImpl list = result.stream().map(item -> {
@@ -296,7 +297,7 @@ public class IcPartyActivityServiceImpl extends BaseServiceImpl list = result.stream().map(item -> {
@@ -405,7 +405,7 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl nums;
+
+ /**
+ * 总条数
+ */
+ private Integer num;
+}
diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/InfoByNamesResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/InfoByNamesResultDTO.java
new file mode 100644
index 0000000000..00e92b3ece
--- /dev/null
+++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/InfoByNamesResultDTO.java
@@ -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;
+
+}
diff --git a/epmet-module/gov-org/gov-org-server/pom.xml b/epmet-module/gov-org/gov-org-server/pom.xml
index 58e2e0cf03..fecf57eb7d 100644
--- a/epmet-module/gov-org/gov-org-server/pom.xml
+++ b/epmet-module/gov-org/gov-org-server/pom.xml
@@ -125,6 +125,12 @@
2.0.0
compile
+
+ com.alibaba
+ easyexcel
+ 3.0.3
+ compile
+
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerGridConstant.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerGridConstant.java
index 4374038f6f..bfe1fbe93c 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerGridConstant.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerGridConstant.java
@@ -16,4 +16,7 @@ public interface CustomerGridConstant {
String DEPT = "dept";
String GRID = "grid";
+
+ String NEIGHBORHOOD = "neighborHood";
+ String BUILDING = "building";
}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java
index adaa3ed3f1..2ac1605193 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java
@@ -24,6 +24,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.constant.NumConstant;
+import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
@@ -31,6 +32,7 @@ import com.epmet.dao.IcBuildingUnitDao;
import com.epmet.dto.BuildingTreeLevelDTO;
import com.epmet.dto.form.IcBulidingFormDTO;
import com.epmet.dto.form.IcBulidingUnitFormDTO;
+import com.epmet.dto.form.ImportInfoFormDTO;
import com.epmet.dto.form.ListIcNeighborHoodFormDTO;
import com.epmet.dto.result.BuildingResultDTO;
import com.epmet.dto.result.BuildingResultPagedDTO;
@@ -194,11 +196,32 @@ public class BuildingController {
Collections.sort(resultList);
String subList = resultList.stream().map(String::valueOf).collect(Collectors.joining("、"));
log.warn(str + "第" + subList + "行未成功!");
- return new Result().error(9999, str+"第"+subList+"行未成功!");
+ return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), str+"第"+subList+"行未成功!");
}
return new Result().ok(str);
}
+ /**
+ * @Description 楼宇导入
+ * @param tokenDTO
+ * @param file
+ * @param orgId
+ * @param orgType
+ * @author zxc
+ * @date 2022/2/13 10:18 上午
+ */
+ @PostMapping("buildingimport")
+ public Result buildingImportExcel(@LoginUser TokenDto tokenDTO, @RequestParam("file") MultipartFile file,
+ @RequestParam("orgId")String orgId,
+ @RequestParam("orgType")String orgType) throws IOException{
+ ImportInfoFormDTO formDTO = new ImportInfoFormDTO();
+ formDTO.setCustomerId(tokenDTO.getCustomerId());
+ formDTO.setOrgType(orgType);
+ formDTO.setOrgId(orgId);
+ formDTO.setUserId(tokenDTO.getUserId());
+ return buildingService.buildingImportExcel(formDTO,file);
+ }
+
/**
* 查看楼宇单元列表
* @param tokenDTO
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java
index cd54f15e64..017da95fd9 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java
@@ -19,6 +19,9 @@ package com.epmet.controller;
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.ExcelReader;
+import com.alibaba.excel.read.metadata.ReadSheet;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.constant.NumConstant;
@@ -28,17 +31,21 @@ import com.epmet.commons.tools.feign.ResultDataResolver;
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.dto.form.IcHouseFormDTO;
-import com.epmet.dto.form.IcNeighborHoodFormDTO;
-import com.epmet.dto.form.ListIcNeighborHoodFormDTO;
-import com.epmet.dto.form.LoginUserDetailsFormDTO;
+import com.epmet.dao.IcBuildingDao;
+import com.epmet.dto.form.*;
import com.epmet.dto.result.HouseInfoDTO;
import com.epmet.dto.result.IcNeighborHoodResultDTO;
+import com.epmet.dto.result.ImportResultDTO;
import com.epmet.dto.result.LoginUserDetailsResultDTO;
import com.epmet.excel.IcHouseExcel;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
+import com.epmet.model.HouseInfoModel;
+import com.epmet.model.ImportHouseInfoListener;
+import com.epmet.redis.IcHouseRedis;
import com.epmet.service.HouseService;
+import com.epmet.service.IcHouseService;
+import com.epmet.service.IcNeighborHoodService;
import com.epmet.util.ExcelPoiUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@@ -49,6 +56,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
+import java.io.InputStream;
import java.util.*;
import java.util.stream.Collectors;
@@ -69,6 +77,14 @@ public class HouseController implements ResultDataResolver {
@Autowired
private EpmetUserOpenFeignClient userOpenFeignClient;
+ @Autowired
+ private IcBuildingDao icBuildingDao;
+ @Autowired
+ private IcHouseRedis icHouseRedis;
+ @Autowired
+ private IcNeighborHoodService neighborHoodService;
+ @Autowired
+ private IcHouseService icHouseService;
@PostMapping("houselist")
@@ -223,7 +239,7 @@ public class HouseController implements ResultDataResolver {
Collections.sort(resultList);
String subList = resultList.stream().map(String::valueOf).collect(Collectors.joining("、"));
log.warn(str + "第" + subList + "行未成功!");
- return new Result().error(9999, str+"第"+subList+"行未成功!");
+ return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), str+"第"+subList+"行未成功!");
}
return new Result().ok(str);
}
@@ -232,4 +248,48 @@ public class HouseController implements ResultDataResolver {
Result> queryListHouseInfo(@RequestBody Set houseIds, @RequestParam("customerId") String customerId){
return new Result>().ok(houseService.queryListHouseInfo(houseIds,customerId));
}
+
+ @PostMapping("houseimport")
+ public Result houseImport(@LoginUser TokenDto tokenDTO, @RequestParam("file") MultipartFile file,
+ @RequestParam("orgId")String orgId,
+ @RequestParam("orgType")String orgType){
+ ImportInfoFormDTO formDTO = new ImportInfoFormDTO();
+ formDTO.setCustomerId(tokenDTO.getCustomerId());
+ formDTO.setOrgType(orgType);
+ formDTO.setOrgId(orgId);
+ formDTO.setUserId(tokenDTO.getUserId());
+ ExcelReader excelReader = null;
+ try {
+ InputStream inputStream = null;
+ try {
+ inputStream = file.getInputStream();
+ } catch (IOException e) {
+ return new Result().error("读取文件失败");
+ }
+ excelReader = EasyExcel.read(inputStream).build();
+ // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener
+ ReadSheet readSheet = EasyExcel.readSheet(0).head(HouseInfoModel.class)
+ .registerReadListener(new ImportHouseInfoListener(formDTO,icBuildingDao,icHouseRedis,neighborHoodService,icHouseService))
+ .build();
+ excelReader.read(readSheet);
+ } finally {
+ if (excelReader != null) {
+ excelReader.finish();
+ }
+ }
+ ImportResultDTO dto = icHouseRedis.getImportResultDTO(formDTO.getCustomerId(), formDTO.getUserId());
+ if (null == dto){
+ return new Result<>();
+ }
+ List nums = dto.getNums();
+ Integer num = dto.getNum();
+ String s = "共%s条数据,导入成功%s条。";
+ if (nums.size() > NumConstant.ZERO){
+ Collections.sort(nums);
+ s = s + "第"+nums.stream().map(String::valueOf).collect(Collectors.joining("、"))+"条导入失败";
+ return new Result<>().error(9999,String.format(s,num,num - nums.size()));
+ }
+ return new Result<>().error(9999,String.format(s,num,num));
+ }
+
}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java
index fcd64c4658..a78ea28431 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java
@@ -28,10 +28,13 @@ import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.IcNeighborHoodDTO;
+import com.epmet.dto.form.ImportInfoFormDTO;
import com.epmet.service.IcNeighborHoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import java.io.IOException;
import java.util.List;
import java.util.Map;
@@ -85,6 +88,18 @@ public class IcNeighborHoodController {
return new Result();
}
+ /**
+ * @Description 通过ID查询小区信息
+ * @Param ids
+ * @Return {@link Result< List< IcNeighborHoodDTO>>}
+ * @Author zhaoqifeng
+ * @Date 2021/11/8 10:46
+ */
+ @PostMapping("getlistbyids")
+ public Result> getListByIds(@RequestBody List ids) {
+ return new Result>().ok(icNeighborHoodService.getListByIds(ids));
+ }
+
/**
* @Description 获取网格下小区列表
* @Param dto
@@ -98,15 +113,22 @@ public class IcNeighborHoodController {
}
/**
- * @Description 通过ID查询小区信息
- * @Param ids
- * @Return {@link Result< List< IcNeighborHoodDTO>>}
- * @Author zhaoqifeng
- * @Date 2021/11/8 10:46
+ * @Description 小区信息导入
+ * @param tokenDTO
+ * @param file
+ * @author zxc
+ * @date 2022/2/12 10:47 上午
*/
- @PostMapping("getlistbyids")
- public Result> getListByIds(@RequestBody List ids) {
- return new Result>().ok(icNeighborHoodService.getListByIds(ids));
+ @PostMapping("neighborhoodimport")
+ public Result neighborhoodImport(@LoginUser TokenDto tokenDTO, @RequestParam("file") MultipartFile file,
+ @RequestParam("orgId")String orgId,
+ @RequestParam("orgType")String orgType) throws IOException {
+ ImportInfoFormDTO formDTO = new ImportInfoFormDTO();
+ formDTO.setCustomerId(tokenDTO.getCustomerId());
+ formDTO.setOrgType(orgType);
+ formDTO.setOrgId(orgId);
+ formDTO.setUserId(tokenDTO.getUserId());
+ return icNeighborHoodService.neighborhoodImport(formDTO,file);
}
}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java
index 60c1651315..da7f783c1e 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java
@@ -23,6 +23,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.constant.NumConstant;
+import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
@@ -223,7 +224,7 @@ public class NeighborHoodController {
Collections.sort(resultList);
String subList = resultList.stream().map(String::valueOf).collect(Collectors.joining("、"));
log.warn(str + "第" + subList + "行未成功!");
- return new Result().error(9999, str + "第" + subList + "行未成功!");
+ return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), str + "第" + subList + "行未成功!");
}
return new Result().ok(str);
}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java
index 7eef403d38..3dcedd5c73 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java
@@ -365,4 +365,13 @@ public interface CustomerGridDao extends BaseDao {
@Param("operateUserId") String operateUserId);
List getStaffGridList(@Param("customerId") String customerId, @Param("orgId") String orgId, @Param("orgType") String orgType);
+
+ /**
+ * @Description 根据网格名字查询网格信息
+ * @param names
+ * @author zxc
+ * @date 2022/2/12 2:06 下午
+ */
+ List selectGridInfoByNames(@Param("names")List names,@Param("customerId")String customerId);
+
}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java
index 6d029cb291..cc052eed19 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java
@@ -19,6 +19,7 @@ package com.epmet.dao;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.dao.BaseDao;
+import com.epmet.dto.ImportGeneralDTO;
import com.epmet.dto.result.BaseInfoFamilyBuildingResultDTO;
import com.epmet.dto.result.BuildingResultDTO;
import com.epmet.entity.CustomerAgencyEntity;
@@ -73,4 +74,92 @@ public interface IcBuildingDao extends BaseDao {
List buildingListByIds(@Param("buildingIdList") List buildingIdList);
IPage buildingListByIds(IPage page,@Param("buildingIdList") List buildingIdList);
+ /**
+ * @Description 根据ID查询楼栋名
+ * @param orgId
+ * @author zxc
+ * @date 2022/2/13 2:32 下午
+ */
+ String selectBuildingNameById(@Param("orgId")String orgId);
+
+ /**
+ * @Description 根据ID查询小区名
+ * @param orgId
+ * @author zxc
+ * @date 2022/2/13 4:21 下午
+ */
+ String selectNeighborHoodNameById(@Param("orgId")String orgId);
+
+ /**
+ * @Description 根据ID查询网格名
+ * @param orgId
+ * @author zxc
+ * @date 2022/2/13 4:26 下午
+ */
+ String selectGridNameById(@Param("orgId")String orgId);
+
+ /**
+ * @Description 根据ID查询组织名
+ * @param orgId
+ * @author zxc
+ * @date 2022/2/13 4:29 下午
+ */
+ String selectAgencyNameById(@Param("orgId")String orgId);
+
+ /**
+ * @Description 查询组织下所有网格信息
+ * @param orgId
+ * @author zxc
+ * @date 2022/2/14 9:48 上午
+ */
+ List selectAllGridByOrgId(@Param("orgId")String orgId);
+
+ /**
+ * @Description 查询网格下所有的小区
+ * @param orgId
+ * @author zxc
+ * @date 2022/2/14 10:21 上午
+ */
+ List selectAllNeighborHoodByGridIds(@Param("orgIds")List orgId);
+
+ /**
+ * @Description 根据小区ID查询楼栋
+ * @param neighborHoodId
+ * @author zxc
+ * @date 2022/2/14 1:25 下午
+ */
+ List selectAllBuildingByNeighborHoodId(@Param("orgId")String orgId);
+
+ /**
+ * @Description 根据楼栋ID查询楼栋单元
+ * @param building
+ * @author zxc
+ * @date 2022/2/14 1:58 下午
+ */
+ List selectAllBuildingUnitByBuildingId(@Param("orgId")String orgId);
+
+ /**
+ * @Description 根据ID查询小区
+ * @param id
+ * @author zxc
+ * @date 2022/2/14 3:16 下午
+ */
+ ImportGeneralDTO selectNeighborHoodById(@Param("id")String id);
+
+ /**
+ * @Description 根据ID查询楼栋
+ * @param id
+ * @author zxc
+ * @date 2022/2/14 4:26 下午
+ */
+ ImportGeneralDTO selectBuildingById(@Param("id")String id);
+
+ /**
+ * @Description 查询已存在的房屋
+ * @param ids
+ * @author zxc
+ * @date 2022/2/14 5:32 下午
+ */
+ List selectExistHouse(@Param("ids")List ids);
+
}
\ No newline at end of file
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java
index 6e5d0487eb..3203e96854 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java
@@ -51,4 +51,14 @@ public interface IcNeighborHoodDao extends BaseDao {
Integer checkNameUq(@Param("customerId") String customerId,
@Param("neighborHoodName")String neighborHoodName,
@Param("neighborId")String neighborId);
+
+ /**
+ * @Description 根据小区名查询存在小区
+ * @param names
+ * @param customerId
+ * @author zxc
+ * @date 2022/2/12 2:59 下午
+ */
+ List selectNeighborhoodNameByNames(@Param("names")List names,@Param("customerId") String customerId);
+
}
\ No newline at end of file
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcPropertyManagementDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcPropertyManagementDao.java
index b79a5cc3e6..442f3d0514 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcPropertyManagementDao.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcPropertyManagementDao.java
@@ -20,6 +20,10 @@ package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.IcPropertyManagementEntity;
import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
/**
* 物业表
@@ -31,4 +35,20 @@ import org.apache.ibatis.annotations.Mapper;
public interface IcPropertyManagementDao extends BaseDao {
IcPropertyManagementEntity selectByName(String name);
+
+ /**
+ * @Description 根据物业名查询已存在的物业名
+ * @param names
+ * @author zxc
+ * @date 2022/2/13 9:21 上午
+ */
+ List selectExistNames(@Param("names")List names);
+
+ /**
+ * @Description 根据名字查ID
+ * @param names
+ * @author zxc
+ * @date 2022/2/13 9:59 上午
+ */
+ List selectIdByName(@Param("names")List names);
}
\ No newline at end of file
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/IcNeighborHoodEntity.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/IcNeighborHoodEntity.java
index 62489898d2..9fb05feb87 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/IcNeighborHoodEntity.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/IcNeighborHoodEntity.java
@@ -17,6 +17,7 @@
package com.epmet.entity;
+import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
@@ -98,4 +99,9 @@ public class IcNeighborHoodEntity extends BaseEpmetEntity {
*/
private String location;
+ @TableField(exist = false)
+ private String gridName;
+
+ @TableField(exist = false)
+ private String propertyName;
}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcNeighborHoodExcel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcNeighborHoodExcel.java
index 72c57047e0..b996da1bf2 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcNeighborHoodExcel.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcNeighborHoodExcel.java
@@ -21,6 +21,7 @@ import cn.afterturn.easypoi.excel.annotation.Excel;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.util.ExcelVerifyInfo;
+import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
@@ -121,4 +122,16 @@ public class IcNeighborHoodExcel extends ExcelVerifyInfo implements Serializable
@Length(max=500,message = "不能超过500个字")
private String remark;
+ @JsonIgnore
+ private Boolean status = false;
+
+ @JsonIgnore
+ private Boolean existNameStatus = false;
+
+ @JsonIgnore
+ private Boolean agencyNameStatus = false;
+
+ @JsonIgnore
+ private Boolean reStatus = false;
+
}
\ No newline at end of file
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingInfoModel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingInfoModel.java
new file mode 100644
index 0000000000..e76c391324
--- /dev/null
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingInfoModel.java
@@ -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;
+
+}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseInfoModel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseInfoModel.java
new file mode 100644
index 0000000000..9330a1a2d0
--- /dev/null
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseInfoModel.java
@@ -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;
+
+}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java
new file mode 100644
index 0000000000..808a69f810
--- /dev/null
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java
@@ -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 {
+
+ List nums = new ArrayList<>();
+ Integer num = NumConstant.ZERO;
+
+ List needDisposeList = new ArrayList<>();
+ List needInsertList = new ArrayList<>();
+
+ String gridName = null;
+ String agencyName = null;
+
+ Map gridInfos = null;
+ List gridInfoDTOs = null;
+ Map neighborHoodInfos = null;
+ List neighborHoodInfoDTOs = null;
+ ImportGeneralDTO neighborHoodGeneralDTO = null;
+ Map buildingInfos = null;
+ List 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 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> groupByStatus = needDisposeList.stream().collect(Collectors.groupingBy(ImportGeneralDTO::getExistStatus));
+ List importGeneralDTOS = groupByStatus.get(false);
+ if (!CollectionUtils.isEmpty(importGeneralDTOS)){
+ List importInfo = neighborHoodService.getImportInfo(formDTO, importGeneralDTOS);
+ Map> groupByBuildingExistStatus = importInfo.stream().collect(Collectors.groupingBy(ImportGeneralDTO::getBuildingExistStatus));
+ List 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 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 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 getNeighborHoodInfos(List 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 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));
+ }
+}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java
new file mode 100644
index 0000000000..e572980355
--- /dev/null
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java
@@ -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 {
+
+ List nums = new ArrayList<>();
+ Integer num = NumConstant.ZERO;
+
+ List needDisposeList = new ArrayList<>();
+ List needInsertList = new ArrayList<>();
+
+ String gridName = null;
+ String agencyName = null;
+
+ Map gridInfos = null;
+ List gridInfoDTOs = null;
+ Map neighborHoodInfos = null;
+ List neighborHoodInfoDTOs = null;
+ ImportGeneralDTO neighborHoodGeneralDTO = null;
+ Map buildingInfos = null;
+ List buildingInfoDTOs = null;
+ ImportGeneralDTO buildingGeneralDTO = null;
+ Map buildingUnitInfos = null;
+ List 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 importInfo = neighborHoodService.getImportInfo(formDTO, needDisposeList);
+ needInsertList.addAll(importInfo);
+ }
+ if (CollectionUtils.isEmpty(needInsertList)){
+ return;
+ }
+ Map 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 ids = needInsertList.stream().filter(n -> StringUtils.isNotBlank(n.getBuildingUnitId())).map(m -> m.getBuildingUnitId() + "_" + m.getDoorName()).distinct().collect(Collectors.toList());
+ List 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> groupByExistStatus = needInsertList.stream().collect(Collectors.groupingBy(ImportGeneralDTO::getExistStatus));
+ List 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 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 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 getNeighborHoodInfos(List 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 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 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 houses){
+ if (!CollectionUtils.isEmpty(houses)){
+ icHouseService.insertBatch(ConvertUtils.sourceToTarget(houses, IcHouseEntity.class));
+ }
+ }
+
+}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportNeighborHoodInfoListener.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportNeighborHoodInfoListener.java
new file mode 100644
index 0000000000..c31e83960b
--- /dev/null
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportNeighborHoodInfoListener.java
@@ -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 {
+
+ List nums = new ArrayList<>();
+ Integer num = NumConstant.ZERO;
+
+ List needDisposeList = new ArrayList<>();
+ List needInsertList = new ArrayList<>();
+
+ String gridName = null;
+ String agencyName = null;
+
+ Map gridInfos = null;
+ List gridInfoDTOs = null;
+ Map neighborHoodInfos = null;
+ List 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 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> groupByStatus = needDisposeList.stream().collect(Collectors.groupingBy(ImportGeneralDTO::getExistStatus));
+ List importGeneralDTOS = groupByStatus.get(false);
+ if (!CollectionUtils.isEmpty(importGeneralDTOS)){
+ List importInfo = neighborHoodService.getImportInfo(formDTO, importGeneralDTOS);
+ Map> groupByBuildingExistStatus = importInfo.stream().collect(Collectors.groupingBy(ImportGeneralDTO::getNeighborHoodExistStatus));
+ List existList = groupByBuildingExistStatus.get(true);
+ if (!CollectionUtils.isEmpty(existList)){
+ existList.forEach(e -> {
+ nums.add(e.getNum());
+ });
+ }
+ List notExistList = groupByBuildingExistStatus.get(false);
+ if (!CollectionUtils.isEmpty(notExistList)){
+ // 物业表插入
+ List propertyNames = notExistList.stream().filter(n -> StringUtils.isNotBlank(n.getPropertyName())).map(m -> m.getPropertyName()).distinct().collect(Collectors.toList());
+ List disposePropertyNames = notExistList.stream().filter(n -> StringUtils.isNotBlank(n.getPropertyName())).map(m -> m.getPropertyName()).distinct().collect(Collectors.toList());
+ if (!CollectionUtils.isEmpty(propertyNames)){
+ List existPropertyNames = propertyManagementDao.selectExistNames(propertyNames);
+ disposePropertyNames.removeAll(existPropertyNames);
+ List 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 neighborHoodAndManagementDTOS = ConvertUtils.sourceToTarget(notExistList, NeighborHoodAndManagementDTO.class);
+ List 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 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 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 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 getNeighborHoodInfos(List 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));
+ }
+}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodInfoModel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodInfoModel.java
new file mode 100644
index 0000000000..8dbdbafccd
--- /dev/null
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodInfoModel.java
@@ -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;
+
+}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java
index 4f3ece54a8..2329e467d6 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java
@@ -23,7 +23,9 @@ import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.dao.IcHouseDao;
import com.epmet.dto.result.HouseInfoDTO;
+import com.epmet.dto.result.ImportResultDTO;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
@@ -43,6 +45,9 @@ public class IcHouseRedis {
@Autowired
private IcHouseDao icHouseDao;
+ @Autowired
+ private RedisTemplate redisTemplate;
+
public void delete(Object[] ids) {
}
@@ -79,4 +84,221 @@ public class IcHouseRedis {
return houseInfo;
}
+ /**
+ * @Description 存放房屋临时缓存
+ * @param customerId
+ * @param map
+ * @param userId
+ * @author zxc
+ * @date 2022/2/14 9:04 上午
+ */
+ public void setTemporaryCacheHouse(String customerId, Map map,String userId){
+ String key = RedisKeys.getTemporaryHouseInfoCacheKey(customerId,userId);
+ redisUtils.hMSet(key,map);
+ }
+
+ /**
+ * @Description 获取房屋临时缓存
+ * @param customerId
+ * @param userId
+ * @author zxc
+ * @date 2022/2/14 9:28 上午
+ */
+ public Object getTemporaryCacheHouse(String customerId,String userId,String buildingIdAndUnitIdAndHouseName){
+ String key = RedisKeys.getTemporaryHouseInfoCacheKey(customerId,userId);
+ return redisUtils.hGet(key, buildingIdAndUnitIdAndHouseName);
+ }
+
+ /**
+ * @Description 删除房屋临时缓存
+ * @param customerId
+ * @param userId
+ * @author zxc
+ * @date 2022/2/14 9:29 上午
+ */
+ public void delTemporaryCacheHouses(String customerId,String userId){
+ String key = RedisKeys.getTemporaryHouseInfoCacheKey(customerId,userId);
+ redisUtils.delete(key);
+ }
+
+ /**
+ * @Description 保存网格临时缓存
+ * @param customerId
+ * @param map
+ * @param userId
+ * @author zxc
+ * @date 2022/2/14 1:49 下午
+ */
+ public void setTemporaryCacheGrid(String customerId, Map map,String userId) {
+ String key = RedisKeys.getTemporaryGridInfoCacheKey(customerId, userId);
+ redisUtils.hMSet(key, map);
+ }
+
+ /**
+ * @Description 获取网格临时缓存【单个】
+ * @param customerId
+ * @param userId
+ * @param gridName
+ * @author zxc
+ * @date 2022/2/14 1:49 下午
+ */
+ public Object getTemporaryCacheGrid(String customerId,String userId,String gridName){
+ String key = RedisKeys.getTemporaryGridInfoCacheKey(customerId,userId);
+ Object o = redisUtils.hGet(key, gridName);
+ return o;
+ }
+
+ /**
+ * @Description 获取网格临时缓存【多个】
+ * @param customerId
+ * @param userId
+ * @author zxc
+ * @date 2022/2/14 1:50 下午
+ */
+ public Map getTemporaryCacheGrids(String customerId,String userId){
+ String key = RedisKeys.getTemporaryGridInfoCacheKey(customerId,userId);
+ return redisUtils.hGetAll(key);
+ }
+
+ /**
+ * @Description 删除网格临时缓存
+ * @param customerId
+ * @param userId
+ * @author zxc
+ * @date 2022/2/14 1:50 下午
+ */
+ public void delTemporaryCacheGrids(String customerId,String userId){
+ String key = RedisKeys.getTemporaryGridInfoCacheKey(customerId,userId);
+ redisUtils.delete(key);
+ }
+
+ /**
+ * @Description 保存临时小区缓存
+ * @param customerId
+ * @param map
+ * @param userId
+ * @author zxc
+ * @date 2022/2/14 1:50 下午
+ */
+ public void setTemporaryCacheNeighBorHood(String customerId, Map map,String userId) {
+ String key = RedisKeys.getTemporaryNeighborHoodInfoCacheKey(customerId, userId);
+ redisUtils.hMSet(key, map);
+ }
+
+ /**
+ * @Description 获取临时小区缓存【单个】
+ * @param customerId
+ * @param userId
+ * @param gridIdAndNeighborHoodName
+ * @author zxc
+ * @date 2022/2/14 1:50 下午
+ */
+ public Object getTemporaryCacheNeighBorHood(String customerId,String userId,String gridIdAndNeighborHoodName){
+ String key = RedisKeys.getTemporaryNeighborHoodInfoCacheKey(customerId,userId);
+ return redisUtils.hGet(key, gridIdAndNeighborHoodName);
+ }
+
+ /**
+ * @Description 删除临时小区缓存
+ * @param customerId
+ * @param userId
+ * @author zxc
+ * @date 2022/2/14 1:51 下午
+ */
+ public void delTemporaryCacheNeighBorHood(String customerId,String userId){
+ String key = RedisKeys.getTemporaryNeighborHoodInfoCacheKey(customerId,userId);
+ redisUtils.delete(key);
+ }
+
+ /**
+ * @Description 保存临时楼栋缓存
+ * @param customerId
+ * @param map
+ * @param userId
+ * @author zxc
+ * @date 2022/2/14 1:51 下午
+ */
+ public void setTemporaryCacheBuilding(String customerId, Map map,String userId) {
+ String key = RedisKeys.getTemporaryBuildingInfoCacheKey(customerId, userId);
+ redisUtils.hMSet(key, map);
+ }
+
+ /**
+ * @Description 获取临时楼栋缓存【单个】
+ * @param customerId
+ * @param userId
+ * @param neighborHoodIdAndBuildingName
+ * @author zxc
+ * @date 2022/2/14 1:51 下午
+ */
+ public Object getTemporaryCacheBuilding(String customerId,String userId,String neighborHoodIdAndBuildingName){
+ String key = RedisKeys.getTemporaryBuildingInfoCacheKey(customerId,userId);
+ return redisUtils.hGet(key, neighborHoodIdAndBuildingName);
+ }
+
+ /**
+ * @Description 删除临时楼栋缓存
+ * @param customerId
+ * @param userId
+ * @author zxc
+ * @date 2022/2/14 1:51 下午
+ */
+ public void delTemporaryCacheBuilding(String customerId,String userId){
+ String key = RedisKeys.getTemporaryBuildingInfoCacheKey(customerId,userId);
+ redisUtils.delete(key);
+ }
+
+ /**
+ * @Description 保存临时楼栋单元缓存
+ * @param customerId
+ * @param map
+ * @param userId
+ * @author zxc
+ * @date 2022/2/14 1:51 下午
+ */
+ public void setTemporaryCacheBuildingUnit(String customerId, Map map,String userId) {
+ String key = RedisKeys.getTemporaryBuildingUnitInfoCacheKey(customerId, userId);
+ redisUtils.hMSet(key, map);
+ }
+
+ /**
+ * @Description 获取临时楼栋单元缓存【单个】
+ * @param customerId
+ * @param userId
+ * @param buildingIdAndUnitName
+ * @author zxc
+ * @date 2022/2/14 1:51 下午
+ */
+ public Object getTemporaryCacheBuildingUnit(String customerId,String userId,String buildingIdAndUnitName){
+ String key = RedisKeys.getTemporaryBuildingUnitInfoCacheKey(customerId,userId);
+ return redisUtils.hGet(key, buildingIdAndUnitName);
+ }
+
+ /**
+ * @Description 删除临时楼栋单元缓存
+ * @param customerId
+ * @param userId
+ * @author zxc
+ * @date 2022/2/14 1:51 下午
+ */
+ public void delTemporaryCacheBuildingUnit(String customerId,String userId){
+ String key = RedisKeys.getTemporaryBuildingUnitInfoCacheKey(customerId,userId);
+ redisUtils.delete(key);
+ }
+
+ public void setImportResultDTO(String customerId, String userId, ImportResultDTO dto){
+ String key = RedisKeys.getTemporaryImportResultCacheKey(customerId,userId);
+ Map result = BeanUtil.beanToMap(dto, false, true);
+ redisUtils.hMSet(key,result,RedisUtils.MINUTE_ONE_EXPIRE);
+ }
+
+ public ImportResultDTO getImportResultDTO(String customerId, String userId){
+ String key = RedisKeys.getTemporaryImportResultCacheKey(customerId,userId);
+ Map map = redisUtils.hGetAll(key);
+ if (CollectionUtils.isEmpty(map)){
+ return null;
+ }
+ return ConvertUtils.mapToEntity(map,ImportResultDTO.class);
+ }
+
}
\ No newline at end of file
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java
index 81b70a4bd2..240c24d454 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java
@@ -17,15 +17,19 @@
package com.epmet.service;
+import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.BuildingTreeLevelDTO;
import com.epmet.dto.form.IcBulidingFormDTO;
+import com.epmet.dto.form.ImportInfoFormDTO;
import com.epmet.dto.form.ListIcNeighborHoodFormDTO;
import com.epmet.dto.result.BuildingResultDTO;
import com.epmet.dto.result.BuildingResultPagedDTO;
import com.epmet.dto.result.IcNeighborHoodResultDTO;
import com.epmet.excel.IcBuildingExcel;
+import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
import java.util.List;
/**
@@ -62,4 +66,14 @@ public interface BuildingService {
List buildingListByIds(List buildingIdList);
BuildingResultPagedDTO buildinglistbyidsPage(List buildingIdList, Integer pageNo, Integer pageSize);
+
+ /**
+ * @Description 楼宇导入
+ * @param formDTO
+ * @param file
+ * @author zxc
+ * @date 2022/2/13 10:18 上午
+ */
+ Result buildingImportExcel(ImportInfoFormDTO formDTO, MultipartFile file) throws IOException;
+
}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcBuildingService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcBuildingService.java
index 5b5ff7d05d..b7279e59ad 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcBuildingService.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcBuildingService.java
@@ -102,4 +102,15 @@ public interface IcBuildingService extends BaseService {
* @Date 2021/10/26 14:43
*/
List getBuildingOptions(String neighborHoodId);
+
+ /**
+ * 根据楼栋名获取楼栋信息
+ *
+ * @Param neighborHoodId
+ * @Param buildingName
+ * @Return {@link IcBuildingDTO}
+ * @Author zhaoqifeng
+ * @Date 2022/2/14 15:19
+ */
+ IcBuildingDTO getBuildingInfo(String neighborHoodId, String buildingName);
}
\ No newline at end of file
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcBuildingUnitService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcBuildingUnitService.java
index 40045f2b75..0d315539e6 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcBuildingUnitService.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcBuildingUnitService.java
@@ -102,4 +102,14 @@ public interface IcBuildingUnitService extends BaseService
* @Date 2021/10/26 14:49
*/
List getUnitOptions(String buildingId);
+
+ /**
+ * 根据单元名获取单元信息
+ * @Param buildingId
+ * @Param unitName
+ * @Return {@link IcBuildingUnitDTO}
+ * @Author zhaoqifeng
+ * @Date 2022/2/14 15:42
+ */
+ IcBuildingUnitDTO getUnitInfo(String buildingId, String unitName);
}
\ No newline at end of file
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java
index 3592d82175..6a7ba74a55 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java
@@ -20,9 +20,16 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.dto.result.OptionResultDTO;
import com.epmet.commons.tools.page.PageData;
+import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.IcNeighborHoodDTO;
+import com.epmet.dto.ImportGeneralDTO;
+import com.epmet.dto.form.ImportInfoFormDTO;
import com.epmet.entity.IcNeighborHoodEntity;
+import com.epmet.entity.IcNeighborHoodPropertyEntity;
+import com.epmet.entity.IcPropertyManagementEntity;
+import org.springframework.web.multipart.MultipartFile;
+import java.io.IOException;
import java.util.List;
import java.util.Map;
@@ -112,4 +119,28 @@ public interface IcNeighborHoodService extends BaseService
* @Date 2021/11/8 10:45
*/
List getListByIds(List ids);
+
+ /**
+ * @Description 小区信息导入
+ * @param formDTO
+ * @param file
+ * @author zxc
+ * @date 2022/2/12 11:11 上午
+ */
+ Result neighborhoodImport(ImportInfoFormDTO formDTO, MultipartFile file) throws IOException;
+
+ /**
+ * 获取导入小区,楼栋,单元ID
+ *
+ * @Param formDTO
+ * @Param list
+ * @Return {@link List< ImportGeneralDTO >}
+ * @Author zhaoqifeng
+ * @Date 2022/2/14 9:40
+ */
+ List getImportInfo(ImportInfoFormDTO formDTO, List list);
+
+ void insertPropertyManagement(List propertyManagementEntities);
+
+ void neighborHoodPropertyInsert(List entities);
}
\ No newline at end of file
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java
index cdf6227a8e..15daabf246 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java
@@ -1,6 +1,9 @@
package com.epmet.service.impl;
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.ExcelReader;
+import com.alibaba.excel.read.metadata.ReadSheet;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -13,18 +16,26 @@ import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.utils.ConvertUtils;
+import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.*;
import com.epmet.dto.BuildingTreeLevelDTO;
import com.epmet.dto.CustomerStaffAgencyDTO;
import com.epmet.dto.IcBuildingDTO;
import com.epmet.dto.form.IcBulidingFormDTO;
+import com.epmet.dto.form.ImportInfoFormDTO;
import com.epmet.dto.form.ListIcNeighborHoodFormDTO;
import com.epmet.dto.result.BuildingResultDTO;
import com.epmet.dto.result.BuildingResultPagedDTO;
import com.epmet.dto.result.IcNeighborHoodResultDTO;
+import com.epmet.dto.result.ImportResultDTO;
import com.epmet.entity.*;
import com.epmet.enums.BuildingTypeEnums;
import com.epmet.excel.IcBuildingExcel;
+import com.epmet.model.BuildingInfoModel;
+import com.epmet.model.HouseInfoModel;
+import com.epmet.model.ImportBuildingInfoListener;
+import com.epmet.redis.IcHouseRedis;
+import com.epmet.service.*;
import com.epmet.service.BuildingService;
import com.epmet.service.IcBuildingService;
import com.epmet.service.IcBuildingUnitService;
@@ -36,9 +47,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
+import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -71,6 +85,10 @@ public class BuildingServiceImpl implements BuildingService {
private CustomerStaffAgencyDao customerStaffAgencyDao;
@Resource
private IcBuildingUnitDao icBuildingUnitDao;
+ @Autowired
+ private IcHouseRedis icHouseRedis;
+ @Autowired
+ private IcNeighborHoodService neighborHoodService;
@Override
@Transactional(rollbackFor = Exception.class)
@@ -174,7 +192,7 @@ public class BuildingServiceImpl implements BuildingService {
buildingTreeLevelDTO.setId(item.getId());
buildingTreeLevelDTO.setPId(item.getGridId());
buildingTreeLevelDTO.setLabel(item.getNeighborHoodName());
- buildingTreeLevelDTO.setLevel("neighbourHood");
+ buildingTreeLevelDTO.setLevel("neighborHood");
buildingTreeLevelDTO.setLongitude(item.getLongitude());
buildingTreeLevelDTO.setLatitude(item.getLatitude());
buildingTreeLevelDTO.setChildren(new ArrayList<>());
@@ -325,7 +343,7 @@ public class BuildingServiceImpl implements BuildingService {
icBuildingUnitService.insertBatch(icBuildingUnitEntityList);
/* if(!"".equals(str)){
- return new Result().error(9999, str.append("不存在").toString());
+ return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), str.append("不存在").toString());
}*/
return numList;
}
@@ -366,6 +384,54 @@ public class BuildingServiceImpl implements BuildingService {
return result;
}
+ /**
+ * @Description 楼宇导入
+ * 根据左侧树选中的层级,可导入对应数据:
+ * 1. 选中社区可导入该社区下所有小区信息、楼宇信息、房屋信息(没有匹配的小区、楼宇均新增,网格没有对应的不新增);
+ * 2. 选中网格可导入该网格下所有小区信息、楼宇信息、房屋信息(没有匹配的小区、楼宇均新增);
+ * 3. 选中小区可导入该小区下所有楼宇信息、房屋信息(没有匹配的楼宇均新增);
+ * 4. 选中楼宇可导入该楼宇下所有房屋信息。
+ * @param formDTO
+ * @param file
+ * @author zxc
+ * @date 2022/2/13 10:15 上午
+ */
+ @Override
+ public Result buildingImportExcel(ImportInfoFormDTO formDTO, MultipartFile file) throws IOException {
+ ExcelReader excelReader = null;
+ try {
+ InputStream inputStream = null;
+ try {
+ inputStream = file.getInputStream();
+ } catch (IOException e) {
+ return new Result().error("读取文件失败");
+ }
+ excelReader = EasyExcel.read(inputStream).build();
+ // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener
+ ReadSheet readSheet = EasyExcel.readSheet(0).head(BuildingInfoModel.class)
+ .registerReadListener(new ImportBuildingInfoListener(formDTO,icHouseRedis,icBuildingDao,neighborHoodService))
+ .build();
+ excelReader.read(readSheet);
+ } finally {
+ if (excelReader != null) {
+ excelReader.finish();
+ }
+ }
+ ImportResultDTO dto = icHouseRedis.getImportResultDTO(formDTO.getCustomerId(), formDTO.getUserId());
+ if (null == dto){
+ return new Result<>();
+ }
+ List nums = dto.getNums();
+ Integer num = dto.getNum();
+ String s = "共%s条数据,导入成功%s条。";
+ if (nums.size() > NumConstant.ZERO){
+ Collections.sort(nums);
+ s = s + "第"+nums.stream().map(String::valueOf).collect(Collectors.joining("、"))+"条导入失败";
+ return new Result<>().error(9999,String.format(s,num,num - nums.size()));
+ }
+ return new Result<>().error(9999,String.format(s,num,num));
+ }
+
private List searchAllBuilding(ListIcNeighborHoodFormDTO formDTO) {
// QueryWrapper neighborHoodEntityQueryWrapper = new QueryWrapper<>();
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffGridServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffGridServiceImpl.java
index 23582c1906..184a4b7acd 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffGridServiceImpl.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffGridServiceImpl.java
@@ -176,7 +176,8 @@ public class CustomerStaffGridServiceImpl extends BaseServiceImpl();
}
- return data;
+ gridStaff.stream().forEach(g -> data.stream().filter(d -> g.getStaffId().equals(d.getStaffId()) && g.getGridId().equals(d.getGridId())).forEach(d -> g.setMobile(d.getMobile())));
+ return gridStaff.stream().filter(g -> StringUtils.isNotBlank(g.getMobile())).collect(Collectors.toList());
}
/**
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcBuildingServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcBuildingServiceImpl.java
index ea85e2ce33..122e9755a0 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcBuildingServiceImpl.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcBuildingServiceImpl.java
@@ -133,4 +133,24 @@ public class IcBuildingServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>();
+ wrapper.eq(IcBuildingEntity::getNeighborHoodId, neighborHoodId);
+ wrapper.eq(IcBuildingEntity::getBuildingName, buildingName);
+ IcBuildingEntity entity = baseDao.selectOne(wrapper);
+ return ConvertUtils.sourceToTarget(entity, IcBuildingDTO.class);
+ }
+
}
\ No newline at end of file
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcBuildingUnitServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcBuildingUnitServiceImpl.java
index 4b8cb1f094..3b8409c0cd 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcBuildingUnitServiceImpl.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcBuildingUnitServiceImpl.java
@@ -133,4 +133,24 @@ public class IcBuildingUnitServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>();
+ wrapper.eq(IcBuildingUnitEntity::getBuildingId, buildingId);
+ wrapper.eq(IcBuildingUnitEntity::getUnitNum, unitName);
+ IcBuildingUnitEntity entity = baseDao.selectOne(wrapper);
+ return ConvertUtils.sourceToTarget(entity, IcBuildingUnitDTO.class);
+ }
+
}
\ No newline at end of file
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java
index 3d5b6fa96b..99db449d72 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java
@@ -17,30 +17,56 @@
package com.epmet.service.impl;
+import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.ExcelReader;
+import com.alibaba.excel.read.metadata.ReadSheet;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
+import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.dto.result.OptionResultDTO;
+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.CustomerOrgRedis;
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.utils.ConvertUtils;
+import com.epmet.commons.tools.utils.Result;
+import com.epmet.constant.CustomerGridConstant;
+import com.epmet.dao.CustomerGridDao;
+import com.epmet.dao.IcBuildingDao;
import com.epmet.dao.IcNeighborHoodDao;
-import com.epmet.dto.IcNeighborHoodDTO;
-import com.epmet.entity.IcNeighborHoodEntity;
-import com.epmet.service.IcNeighborHoodService;
+import com.epmet.dao.IcPropertyManagementDao;
+import com.epmet.dto.*;
+import com.epmet.dto.form.ImportInfoFormDTO;
+import com.epmet.dto.result.ImportResultDTO;
+import com.epmet.dto.result.InfoByNamesResultDTO;
+import com.epmet.entity.*;
+import com.epmet.excel.IcNeighborHoodExcel;
+import com.epmet.model.ImportNeighborHoodInfoListener;
+import com.epmet.model.NeighborHoodInfoModel;
+import com.epmet.redis.IcHouseRedis;
+import com.epmet.service.*;
+import com.epmet.util.ExcelPoiUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.ListUtils;
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.web.multipart.MultipartFile;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
+import javax.annotation.Resource;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.*;
import java.util.stream.Collectors;
/**
@@ -53,6 +79,22 @@ import java.util.stream.Collectors;
@Service
public class IcNeighborHoodServiceImpl extends BaseServiceImpl implements IcNeighborHoodService {
+ @Autowired
+ private CustomerGridDao customerGridDao;
+ @Autowired
+ private IcPropertyManagementDao propertyManagementDao;
+ @Autowired
+ private IcPropertyManagementService propertyManagementService;
+ @Autowired
+ private IcNeighborHoodPropertyService neighborHoodPropertyService;
+ @Resource
+ private IcBuildingService icBuildingService;
+ @Resource
+ private IcBuildingUnitService icBuildingUnitService;
+ @Autowired
+ private IcHouseRedis icHouseRedis;
+ @Autowired
+ private IcBuildingDao icBuildingDao;
@Override
public PageData page(Map params) {
@@ -160,4 +202,411 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcNeighborHoodExcel.class);
+ List failList = importResult.getFailList();
+ //存放错误数据行号
+ List numList = new ArrayList<>();
+ if(CollectionUtils.isNotEmpty(failList)){
+ for ( IcNeighborHoodExcel entity : failList) {
+ //打印失败的行 和失败的信息
+ log.error("第{}行,{}",entity.getRowNum(),entity.getErrorMsg());
+ numList.add(entity.getRowNum());
+ }
+ }
+ List result =importResult.getList();
+ return disposeImportNeighborhood(formDTO,result);*/
+ return importNeighbor(formDTO,file);
+ }
+
+ /**
+ * @Description 根据左侧树选中的层级,可导入对应数据:
+ * 1. 选中社区可导入该社区下所有小区信息、楼宇信息、房屋信息(没有匹配的小区、楼宇均新增,网格没有对应的不新增);
+ * 2. 选中网格可导入该网格下所有小区信息、楼宇信息、房屋信息(没有匹配的小区、楼宇均新增);
+ * 3. 选中小区可导入该小区下所有楼宇信息、房屋信息(没有匹配的楼宇均新增);
+ * 4. 选中楼宇可导入该楼宇下所有房屋信息。
+ * @param formDTO
+ * @param result
+ * @author zxc
+ * @date 2022/2/12 2:02 下午
+ */
+ public Result disposeImportNeighborhood(ImportInfoFormDTO formDTO, List result){
+ if (CollectionUtils.isEmpty(result)){
+ return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"excel表格内没有数据");
+ }
+ List nums = new ArrayList<>();
+ List gridNames = result.stream().map(IcNeighborHoodExcel::getGridName).distinct().collect(Collectors.toList());
+ // 1. 查询数据网格是否存在
+ List gridInfos = customerGridDao.selectGridInfoByNames(gridNames, formDTO.getCustomerId());
+ if (CollectionUtils.isEmpty(gridInfos)){
+ // 网格没有对应的不新增
+ for (int i = NumConstant.ONE; i <= result.size(); i++) {
+ nums.add(i);
+ }
+ String str = String.format("共%s条,成功导入%s条。",result.size(),0);
+ return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),str + "第"+nums.stream().map(String::valueOf).collect(Collectors.joining("、"))+"行未成功!");
+ }
+ result.forEach(r -> {
+ for (InfoByNamesResultDTO g : gridInfos) {
+ if (r.getGridName().equals(g.getGridName())){
+ // 能查询出网格,变为true
+ r.setStatus(true);
+ break;
+ }
+ }
+ });
+ Map> groupStatus = result.stream().collect(Collectors.groupingBy(IcNeighborHoodExcel::getStatus));
+ // 只获取能查询到的网格
+ List neighborHoods = groupStatus.get(true);
+ // 2. 查询组织选中组织下存在的小区
+ List existNames = baseDao.selectNeighborhoodNameByNames(neighborHoods.stream().map(IcNeighborHoodExcel::getNeighborHoodName).distinct().collect(Collectors.toList()), formDTO.getCustomerId());
+ // 为了显示多少行插入成功,未成功
+ result.forEach(r -> {
+ for (String s : existNames) {
+ if (r.getNeighborHoodName().equals(s)){
+ // 数据库已存在此小区名变为true
+ r.setExistNameStatus(true);
+ break;
+ }
+ }
+ });
+ Map> groupByExistName = neighborHoods.stream().collect(Collectors.groupingBy(IcNeighborHoodExcel::getExistNameStatus));
+ // 获取需要插入的数据
+ List needInsert = groupByExistName.get(false);
+ if (CollectionUtils.isEmpty(needInsert)){
+ for (int i = NumConstant.ONE; i <= result.size(); i++) {
+ nums.add(i);
+ }
+ String str = String.format("共%s条,成功导入%s条。",result.size(),0);
+ return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),str + "第"+nums.stream().map(String::valueOf).collect(Collectors.joining("、"))+"行未成功!");
+ }
+ if (formDTO.getOrgType().equals(CustomerGridConstant.AGENCY)){
+ AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(formDTO.getOrgId());
+ if (null == agencyInfo){
+ throw new EpmetException("未查询到组织信息...");
+ }
+ needInsert.forEach(n -> {
+ if (agencyInfo.getOrganizationName().equals(n.getAgencyName())){
+ // 所属组织名一样变为true
+ n.setAgencyNameStatus(true);
+ }
+ });
+ }else {
+ GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(formDTO.getOrgId());
+ if (null == gridInfo){
+ throw new EpmetException("未查询到网格信息...");
+ }
+ needInsert.forEach(n -> {
+ if (gridInfo.getGridName().equals(n.getGridName())){
+ //网格名一样变为true
+ n.setAgencyNameStatus(true);
+ }
+ });
+ }
+ Map> groupByAgencyNameStatus = needInsert.stream().collect(Collectors.groupingBy(IcNeighborHoodExcel::getAgencyNameStatus));
+ List finalNeedInsert = groupByAgencyNameStatus.get(true);
+ if (CollectionUtils.isEmpty(finalNeedInsert)){
+ for (int i = NumConstant.ONE; i <= result.size(); i++) {
+ nums.add(i);
+ }
+ String str = String.format("共%s条,成功导入%s条。",result.size(),0);
+ return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),str +"第"+nums.stream().map(String::valueOf).collect(Collectors.joining("、"))+"行未成功!");
+ }
+ Map collect = finalNeedInsert.stream().collect(Collectors.groupingBy(o -> o.getGridName() + "_" + o.getNeighborHoodName(), Collectors.counting()));
+ collect.forEach((k,v) -> {
+ if (Integer.valueOf(v.toString()).compareTo(1) > 0){
+ for (IcNeighborHoodExcel r : result) {
+ if (k.equals(r.getGridName()+"_"+r.getNeighborHoodName())){
+ r.setReStatus(true);
+ }
+ }
+ }
+ });
+ List realFinalResult = new ArrayList<>();
+ for (int i = NumConstant.ZERO; i < result.size(); i++) {
+ if (result.get(i).getStatus() == true && result.get(i).getExistNameStatus() == false &&
+ result.get(i).getAgencyNameStatus() == true && result.get(i).getReStatus() == false){
+ realFinalResult.add(result.get(i));
+ }
+ }
+ List