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 entities = ConvertUtils.sourceToTarget(realFinalResult, IcNeighborHoodEntity.class); + entities.forEach(e -> { + for (InfoByNamesResultDTO g : gridInfos) { + if (e.getGridName().equals(g.getGridName())){ + e.setAgencyId(g.getAgencyId()); + e.setAgencyPids(g.getAgencyPids()); + e.setCustomerId(formDTO.getCustomerId()); + e.setGridId(g.getGridId()); + e.setParentAgencyId(g.getParentAgencyId()); + break; + } + } + }); + // 物业表插入 + List propertyNames = finalNeedInsert.stream().map(m -> m.getPropertyName()).distinct().collect(Collectors.toList()); + List disposePropertyNames = finalNeedInsert.stream().map(m -> m.getPropertyName()).distinct().collect(Collectors.toList()); + List existPropertyNames = propertyManagementDao.selectExistNames(propertyNames); + disposePropertyNames.removeAll(existPropertyNames); + List propertyManagementEntities = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(disposePropertyNames)){ + disposePropertyNames.forEach(name -> { + IcPropertyManagementEntity e = new IcPropertyManagementEntity(); + e.setName(name); + propertyManagementEntities.add(e); + }); + } + importInsert(entities,propertyManagementEntities); + // 小区物业关系表插入 + List neighborHoodAndManagementDTOS = ConvertUtils.sourceToTarget(entities, 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.getId()); + })); + List icNeighborHoodPropertyEntities = ConvertUtils.sourceToTarget(neighborHoodAndManagementDTOS, IcNeighborHoodPropertyEntity.class); + neighborHoodPropertyInsert(icNeighborHoodPropertyEntities); + + for (int i = NumConstant.ZERO; i < result.size(); i++) { + if (result.get(i).getStatus() == false || result.get(i).getExistNameStatus() == true || result.get(i).getAgencyNameStatus() == false || result.get(i).getReStatus() == true){ + nums.add(i + NumConstant.ONE); + } + } + String str = String.format("共%s条,成功导入%s条。",result.size(),entities.size()); + if (CollectionUtils.isNotEmpty(nums)){ + return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),str + "第"+nums.stream().map(String::valueOf).collect(Collectors.joining("、"))+"行未成功!"); + } + return new Result().ok(str); + } + + public Result importNeighbor(ImportInfoFormDTO formDTO, MultipartFile file){ + 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(NeighborHoodInfoModel.class) + .registerReadListener(new ImportNeighborHoodInfoListener(formDTO,icHouseRedis,icBuildingDao,this,propertyManagementDao)) + .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)); + } + + /** + * @Description 小区插入,物业插入 + * @param entities + * @param propertyManagementEntities + * @author zxc + * @date 2022/2/13 10:09 上午 + */ + @Transactional(rollbackFor = Exception.class) + public void importInsert(List entities,List propertyManagementEntities){ + List> partition = ListUtils.partition(entities, NumConstant.ONE_HUNDRED); + partition.forEach(p -> { + insertBatch(p); + }); + List> partition1 = ListUtils.partition(propertyManagementEntities, NumConstant.ONE_HUNDRED); + partition1.forEach(p -> { + propertyManagementService.insertBatch(p); + }); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void insertPropertyManagement(List propertyManagementEntities){ + if (CollectionUtils.isEmpty(propertyManagementEntities)){ + return; + } + List> partition1 = ListUtils.partition(propertyManagementEntities, NumConstant.ONE_HUNDRED); + partition1.forEach(p -> { + propertyManagementService.insertBatch(p); + }); + } + + /** + * @Description 小区物业关系表插入 + * @param entities + * @author zxc + * @date 2022/2/13 10:09 上午 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void neighborHoodPropertyInsert(List entities){ + List> partition = ListUtils.partition(entities, NumConstant.ONE_HUNDRED); + partition.forEach(p -> { + neighborHoodPropertyService.insertBatch(p); + }); + } + + /** + * 获取导入小区,楼栋,单元ID + * + * @param formDTO + * @param list + * @Param formDTO + * @Param list + * @Return {@link List< ImportGeneralDTO >} + * @Author zhaoqifeng + * @Date 2022/2/14 9:40 + */ + @Override + public List getImportInfo(ImportInfoFormDTO formDTO, List list) { + list.forEach(item -> { + if (StringUtils.isEmpty(item.getNeighborHoodId())) { + //1.获取小区ID,判断小区是否存在,不存在则添加小区,存在则直接获取小区ID + String neighborHoodId = getNeighborHoodId(formDTO.getCustomerId(), item); + item.setNeighborHoodId(neighborHoodId); + //2.获取楼栋ID,判断楼栋是否存在,不存在则添加楼栋,存在则直接获取楼栋ID + if (StringUtils.isEmpty(item.getBuildingId()) && StringUtils.isNotEmpty(item.getBuildingName())) { + String buildingId = getBuildingId(formDTO.getCustomerId(), item); + item.setBuildingId(buildingId); + } + //3.获取单元ID,判断单元是否存在,不存在则添加单元,存在则直接获取单元ID + if (null != item.getBuildingUnit()) { + String unitId = getUnitId(formDTO.getCustomerId(), item); + item.setBuildingUnitId(unitId); + } + } else if (StringUtils.isNotEmpty(item.getNeighborHoodId()) && StringUtils.isEmpty(item.getBuildingId())) { + //获取楼栋ID,判断楼栋是否存在,不存在则添加楼栋,存在则直接获取楼栋ID + String buildingId = getBuildingId(formDTO.getCustomerId(), item); + item.setBuildingId(buildingId); + //获取单元ID,判断单元是否存在,不存在则添加单元,存在则直接获取单元ID + if (null != item.getBuildingUnit()) { + String unitId = getUnitId(formDTO.getCustomerId(), item); + item.setBuildingUnitId(unitId); + } + } + }); + + return list; + } + + /** + * 根据小区名获取小区ID,如果没有,先新增小区 + * @Param gridId + * @Param name + * @Return {@link String} + * @Author zhaoqifeng + * @Date 2022/2/14 9:50 + */ + @Transactional(rollbackFor = Exception.class) + private String getNeighborHoodId(String customerId, ImportGeneralDTO info) { + //根据网格ID和小区名获取小区信息 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(IcNeighborHoodEntity::getGridId, info.getGridId()); + wrapper.eq(IcNeighborHoodEntity::getNeighborHoodName, info.getNeighborHoodName()); + IcNeighborHoodEntity entity = baseDao.selectOne(wrapper); + if (null != entity) { + info.setNeighborHoodExistStatus(true); + return entity.getId(); + } + entity = new IcNeighborHoodEntity(); + entity.setCustomerId(customerId); + entity.setAgencyId(info.getAgencyId()); + entity.setParentAgencyId(info.getPid()); + entity.setAgencyPids(info.getPids()); + entity.setGridId(info.getGridId()); + entity.setNeighborHoodName(info.getNeighborHoodName()); + entity.setAddress(info.getAddress()); + entity.setRemark(info.getRemark()); + baseDao.insert(entity); + return entity.getId(); + } + + /** + * 获取楼栋ID + * @Param customerId + * @Param info + * @Return {@link String} + * @Author zhaoqifeng + * @Date 2022/2/14 15:36 + */ + private String getBuildingId(String customerId, ImportGeneralDTO info) { + //根据小区ID和楼栋名获取楼栋信息 + IcBuildingDTO building = icBuildingService.getBuildingInfo(info.getNeighborHoodId(), info.getBuildingName()); + if (null != building) { + info.setBuildingExistStatus(true); + return building.getId(); + } + IcBuildingEntity buildingEntity = new IcBuildingEntity(); + buildingEntity.setCustomerId(customerId); + buildingEntity.setNeighborHoodId(info.getNeighborHoodId()); + buildingEntity.setBuildingName(info.getBuildingName()); + buildingEntity.setType(null == info.getType()?NumConstant.ONE_STR:info.getType()); + buildingEntity.setSort(NumConstant.ZERO); + buildingEntity.setTotalUnitNum(info.getTotalUnitNum()); + buildingEntity.setTotalFloorNum(info.getTotalFloorNum()); + buildingEntity.setTotalHouseNum(info.getTotalHouseNum()); + icBuildingService.insert(buildingEntity); + if (null != info.getTotalUnitNum() && info.getTotalUnitNum() > NumConstant.ZERO) { + //设置楼宇单元 + List unitList = new ArrayList<>(); + for (int i =0 ; i + + + diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml index d4f3847235..ee64e59aca 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml @@ -221,4 +221,112 @@ order by gridName,neighborHoodName,buildingName + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml index 32338f7927..08adc876d0 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml @@ -129,8 +129,9 @@ LEFT JOIN ic_neighbor_hood c on a.NEIGHBOR_HOOD_ID = c.ID and c.DEL_FLAG = '0' LEFT JOIN ic_building_unit d on a.BUILDING_UNIT_ID = d.ID and d.DEL_FLAG = '0' + a.del_flag = '0' - case c.AGENCY_PIDS + and case c.AGENCY_PIDS when '' then CONCAT(c.AGENCY_ID) like CONCAT(#{pids}, '%') else CONCAT(c.AGENCY_PIDS, ':', c.AGENCY_ID) like CONCAT(#{pids}, '%') end diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml index 73c23350d7..36daaf0d27 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml @@ -214,4 +214,18 @@ and a.id !=#{neighborId} + + + diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcPropertyManagementDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcPropertyManagementDao.xml index 725fdf969f..5a5cf172a3 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcPropertyManagementDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcPropertyManagementDao.xml @@ -23,4 +23,29 @@ m.DEL_FLAG = '0' AND m.`NAME` = #{name} + + + + + + + \ No newline at end of file diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/GovProjectApplication.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/GovProjectApplication.java index 37c767c4b3..47fa0b89ac 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/GovProjectApplication.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/GovProjectApplication.java @@ -5,6 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.scheduling.annotation.EnableAsync; /** * @@ -14,6 +15,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@EnableAsync @ServletComponentScan public class GovProjectApplication { public static void main(String[] args) { diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectTraceServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectTraceServiceImpl.java index 2a56eb3dfc..53e1bd4c6c 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectTraceServiceImpl.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectTraceServiceImpl.java @@ -9,7 +9,9 @@ import com.epmet.commons.rocketmq.messages.ProjectChangedMQMsg; import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.dto.form.UpdateUserPointsFormDTO; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; +import com.epmet.commons.tools.enums.BehaviorTypeYuShanEnum; import com.epmet.commons.tools.enums.OrgTypeEnum; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; @@ -107,6 +109,9 @@ public class ProjectTraceServiceImpl implements ProjectTraceS private ResiEventReportOrgDao resiEventReportOrgDao; @Autowired private BlockChainUploadService blockChainUploadService; + @Autowired + private YuShanSysApiService yuShanSysApiService; + @Override public List getPendProjectList(TokenDto tokenDto, ProjectListFromDTO fromDTO) { @@ -312,7 +317,10 @@ public class ProjectTraceServiceImpl implements ProjectTraceS List staffList = formDTO.getStaffList(); //1.文字内容安全校验 List list = new ArrayList<>(); - list.add(formDTO.getTitle());list.add(formDTO.getBackGround());list.add(formDTO.getPublicReply());list.add(formDTO.getInternalRemark()); + list.add(formDTO.getTitle()); + list.add(formDTO.getBackGround()); + list.add(formDTO.getPublicReply()); + list.add(formDTO.getInternalRemark()); safetyCheck(list); //2.数据准备,查询需要用到的数据 @@ -552,6 +560,12 @@ public class ProjectTraceServiceImpl implements ProjectTraceS String errorMsg = ExceptionUtils.getThrowableErrorStackTrace(e); log.error("【项目流转】上链失败,错误信息:{}", errorMsg); } + //项目立项如果是榆山街道的工作人员,需要调用【更新用户积分(双实信息更新 网格巡查)】/api/points/behavior/updateUserPoints + UpdateUserPointsFormDTO updateUserPointsFormDTO=new UpdateUserPointsFormDTO(); + updateUserPointsFormDTO.setCustomerId(projectEntity.getCustomerId()); + updateUserPointsFormDTO.setStaffId(projectEntity.getCreatedBy()); + updateUserPointsFormDTO.setBehaviorType(BehaviorTypeYuShanEnum.GRID_REPORT_EVENT.getCode()); + yuShanSysApiService.updateUserPoints(projectEntity.getCustomerId(),Arrays.asList(updateUserPointsFormDTO)); } /** diff --git a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/IcPartymemberStyleCategoryDictDTO.java b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/IcPartymemberStyleCategoryDictDTO.java new file mode 100644 index 0000000000..a93b2ec63b --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/IcPartymemberStyleCategoryDictDTO.java @@ -0,0 +1,99 @@ +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 党员风采分类字典表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-12 + */ +@Data +public class IcPartymemberStyleCategoryDictDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 楼栋主键 + */ + private String id; + + /** + * 客户id + */ + private String customerId; + + /** + * 上级分类ID 顶级此列存储0 + */ + private String pid; + + /** + * 所有上级分类ID英文顿号隔开,顶级此列存储0 + */ + private String pids; + + /** + * 分类编码,分类编码+customer_id唯一;从1000开始 + */ + private String categoryCode; + + /** + * 上级分类编码 + */ + private String parentCategoryCode; + + /** + * 分类名称 + */ + private String categoryName; + + /** + * 分类级别1,2,3,4.... 目前只有一级 + */ + private Integer level; + + /** + * 排序 + */ + private Integer sort; + + /** + * 0:可用;1:被禁用。默认0 + */ + private Boolean beDisabled; + + /** + * 删除标识 0未删除、1已删除 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/IcPartymemberStyleDTO.java b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/IcPartymemberStyleDTO.java index 1bfdc10d0b..a2cda91a24 100644 --- a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/IcPartymemberStyleDTO.java +++ b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/IcPartymemberStyleDTO.java @@ -55,6 +55,11 @@ public class IcPartymemberStyleDTO implements Serializable { */ private String gridId; + /** + * 网格的所有上级 + */ + private String gridPids; + private String gridName; /** @@ -98,5 +103,9 @@ public class IcPartymemberStyleDTO implements Serializable { private Date updatedTime; private List imageList; - + /** + * 分类名称 + */ + private String categoryName; + private String categoryId; } \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/AddStyleCategoryFormDTO.java b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/AddStyleCategoryFormDTO.java new file mode 100644 index 0000000000..729b9fb731 --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/AddStyleCategoryFormDTO.java @@ -0,0 +1,36 @@ +package com.epmet.resi.partymember.dto.partymember.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * 【党员风采分类】添加或修改分类 + */ +@Data +public class AddStyleCategoryFormDTO implements Serializable { + public interface AddUserInternalGroup { + } + + public interface AddUserShowGroup extends CustomerClientShowGroup { + } + + @NotBlank(message = "customerId不能为空", groups = AddUserInternalGroup.class) + private String customerId; + + /** + * 分类名称 + */ + @NotBlank(message = "分类名称不能为空", groups = AddUserShowGroup.class) + @Length(max = 10, groups = AddUserShowGroup.class) + private String categoryName; + + /** + * 主键 + */ + private String categoryId; + +} diff --git a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/PartyMemberStyleFormDTO.java b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/PartyMemberStyleFormDTO.java index 6cedb15c89..40edfb678a 100644 --- a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/PartyMemberStyleFormDTO.java +++ b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/PartyMemberStyleFormDTO.java @@ -22,4 +22,5 @@ public class PartyMemberStyleFormDTO implements Serializable { private String mainDeed; private Integer pageNo; private Integer pageSize; + private String categoryId; } diff --git a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/StyleCategoryCommonFormDTO.java b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/StyleCategoryCommonFormDTO.java new file mode 100644 index 0000000000..a575b8a6dc --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/StyleCategoryCommonFormDTO.java @@ -0,0 +1,15 @@ +package com.epmet.resi.partymember.dto.partymember.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +@Data +public class StyleCategoryCommonFormDTO implements Serializable { + private static final long serialVersionUID = -291713921309878763L; + public interface AddUserInternalGroup {} + @NotBlank(message = "customerId不能为空",groups = AddUserInternalGroup.class) + private String customerId; +} diff --git a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/StyleSelectListFormDTO.java b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/StyleSelectListFormDTO.java new file mode 100644 index 0000000000..ee39dcbf74 --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/StyleSelectListFormDTO.java @@ -0,0 +1,21 @@ +package com.epmet.resi.partymember.dto.partymember.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +@Data +public class StyleSelectListFormDTO implements Serializable { + + public interface AddUserInternalGroup {} + @NotBlank(message = "customerId不能为空",groups = AddUserInternalGroup.class) + private String customerId; + + /** + * query:查询条件用;新增或者编辑:addorupdate + */ + @NotBlank(message = "type不能为空",groups = AddUserInternalGroup.class) + private String type; +} diff --git a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/StyleShowListFormDTO.java b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/StyleShowListFormDTO.java new file mode 100644 index 0000000000..20b188919a --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/StyleShowListFormDTO.java @@ -0,0 +1,23 @@ +package com.epmet.resi.partymember.dto.partymember.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +@Data +public class StyleShowListFormDTO implements Serializable { + public interface AddUserInternalGroup { + } + + @NotBlank(message = "userId不能为空", groups = AddUserInternalGroup.class) + private String userId; + @NotBlank(message = "customerId不能为空", groups = AddUserInternalGroup.class) + private String customerId; + + @NotNull(message = "pageNo不能为空", groups = AddUserInternalGroup.class) + private Integer pageNo; + @NotNull(message = "pageSize不能为空", groups = AddUserInternalGroup.class) + private Integer pageSize; +} diff --git a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/UpdateStyleCategoryFormDTO.java b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/UpdateStyleCategoryFormDTO.java new file mode 100644 index 0000000000..0eae2aa4af --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/UpdateStyleCategoryFormDTO.java @@ -0,0 +1,30 @@ +package com.epmet.resi.partymember.dto.partymember.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + + +@Data +public class UpdateStyleCategoryFormDTO implements Serializable { + public interface DeleteInternalGroup { + } + public interface UpdateStatusInternalGroup { + } + /** + * 主键 + */ + @NotBlank(message = "categoryId不能为空", groups = {DeleteInternalGroup.class,UpdateStatusInternalGroup.class}) + private String categoryId; + + /** + * 0:可用;1:被禁用。默认0 + */ + @NotNull(message = "beDisabled不能为空", groups = {UpdateStatusInternalGroup.class}) + private Boolean beDisabled; + + + private String userId; +} diff --git a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/result/StyleCategoryDictResDTO.java b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/result/StyleCategoryDictResDTO.java new file mode 100644 index 0000000000..3c8767503d --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/result/StyleCategoryDictResDTO.java @@ -0,0 +1,27 @@ +package com.epmet.resi.partymember.dto.partymember.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 【党员风采分类】列表查询 + */ +@Data +public class StyleCategoryDictResDTO implements Serializable { + /** + * 主键 + */ + private String categoryId; + + /** + * 分类名称 + */ + private String categoryName; + + /** + * 0:可用;1:被禁用。默认0 + */ + private Boolean beDisabled; + +} diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleCategoryDictController.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleCategoryDictController.java new file mode 100644 index 0000000000..e1212d5e56 --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleCategoryDictController.java @@ -0,0 +1,101 @@ +package com.epmet.modules.partymember.controller; + +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.modules.partymember.service.IcPartymemberStyleCategoryDictService; +import com.epmet.resi.partymember.dto.partymember.form.AddStyleCategoryFormDTO; +import com.epmet.resi.partymember.dto.partymember.form.StyleCategoryCommonFormDTO; +import com.epmet.resi.partymember.dto.partymember.form.StyleSelectListFormDTO; +import com.epmet.resi.partymember.dto.partymember.form.UpdateStyleCategoryFormDTO; +import com.epmet.resi.partymember.dto.partymember.result.StyleCategoryDictResDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + + +/** + * 党员风采分类字典表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-12 + */ +@RestController +@RequestMapping("stylecategorydict") +public class IcPartymemberStyleCategoryDictController { + + @Autowired + private IcPartymemberStyleCategoryDictService icPartymemberStyleCategoryDictService; + + /** + * 【党员风采分类】列表查询 + * @param formDTO + * @return + */ + @PostMapping("list") + public Result> list(@RequestBody StyleCategoryCommonFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO,StyleCategoryCommonFormDTO.AddUserInternalGroup.class); + return new Result>().ok(icPartymemberStyleCategoryDictService.queryList(formDTO.getCustomerId())); + } + + /** + * 【党员风采分类】添加或修改分类 + * @param formDTO + * @return + */ + @PostMapping("addorupdate") + public Result addOrUpdate(@RequestBody AddStyleCategoryFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO, AddStyleCategoryFormDTO.AddUserInternalGroup.class,AddStyleCategoryFormDTO.AddUserShowGroup.class); + icPartymemberStyleCategoryDictService.addOrUpdate(formDTO); + return new Result(); + } + + /** + * 【党员风采分类】删除分类:删除的分类如果已经使用过,清空已经使用的记录,修改时需要重新选择, + * @param formDTO + * @return + */ + @PostMapping("delete") + public Result delete(@LoginUser TokenDto tokenDto, @RequestBody UpdateStyleCategoryFormDTO formDTO){ + formDTO.setUserId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(formDTO,UpdateStyleCategoryFormDTO.DeleteInternalGroup.class); + icPartymemberStyleCategoryDictService.delete(formDTO); + return new Result(); + } + + /** + * 【党员风采分类】启用或禁用 + * @param tokenDto + * @param formDTO + * @return + */ + @PostMapping("updatestatus") + public Result updateStatus(@LoginUser TokenDto tokenDto, @RequestBody UpdateStyleCategoryFormDTO formDTO){ + formDTO.setUserId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(formDTO,UpdateStyleCategoryFormDTO.UpdateStatusInternalGroup.class); + icPartymemberStyleCategoryDictService.updateStatus(formDTO); + return new Result(); + } + + /** + * 党员风采-分类下拉框 + * 查询条件中:展示所有未删除的 + * 新增活修改党员风采:展示可用的 + * + * @param formDTO + * @return + */ + @PostMapping("select-list") + public Result> list(@RequestBody StyleSelectListFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, StyleSelectListFormDTO.AddUserInternalGroup.class); + return new Result>().ok(icPartymemberStyleCategoryDictService.selectList(formDTO)); + } + + + +} \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleController.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleController.java index cadf703b2c..ee3a025d13 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleController.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleController.java @@ -31,6 +31,7 @@ import com.epmet.modules.partymember.excel.IcPartymemberStyleExcel; import com.epmet.modules.partymember.service.IcPartymemberStyleService; import com.epmet.resi.partymember.dto.partymember.IcPartymemberStyleDTO; import com.epmet.resi.partymember.dto.partymember.form.PartyMemberStyleFormDTO; +import com.epmet.resi.partymember.dto.partymember.form.StyleShowListFormDTO; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -100,6 +101,8 @@ public class IcPartymemberStyleController { excel.setGridName(item.getGridName()); excel.setName(item.getName()); excel.setMainDeed(item.getMainDeed()); + //导出时新增分类名称 + excel.setCategoryName(item.getCategoryName()); return excel; }).collect(Collectors.toList()); } @@ -117,4 +120,16 @@ public class IcPartymemberStyleController { return icPartymemberStyleService.importData(tokenDto, response, file); } + /** + * 数据分析-党员风采列表查询 + * @param tokenDto + * @return + */ + @PostMapping("showlist") + public Result> showList(@LoginUser TokenDto tokenDto, @RequestBody StyleShowListFormDTO formDTO){ + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setUserId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(formDTO,StyleShowListFormDTO.AddUserInternalGroup.class); + return new Result>().ok(icPartymemberStyleService.showList(formDTO)); + } } \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/dao/IcPartymemberStyleCategoryDictDao.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/dao/IcPartymemberStyleCategoryDictDao.java new file mode 100644 index 0000000000..cc768ad36c --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/dao/IcPartymemberStyleCategoryDictDao.java @@ -0,0 +1,20 @@ +package com.epmet.modules.partymember.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.modules.partymember.entity.IcPartymemberStyleCategoryDictEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 党员风采分类字典表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-12 + */ +@Mapper +public interface IcPartymemberStyleCategoryDictDao extends BaseDao { + + Integer getMaxCategoryCode(String customerId); + + int updateToDel(@Param("categoryId") String categoryId,@Param("userId") String userId); +} \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/dao/IcPartymemberStyleDao.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/dao/IcPartymemberStyleDao.java index de5966a068..cd78d48284 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/dao/IcPartymemberStyleDao.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/dao/IcPartymemberStyleDao.java @@ -19,7 +19,11 @@ package com.epmet.modules.partymember.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.modules.partymember.entity.IcPartymemberStyleEntity; +import com.epmet.resi.partymember.dto.partymember.IcPartymemberStyleDTO; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 党员风采 @@ -29,5 +33,8 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface IcPartymemberStyleDao extends BaseDao { - + + int clearCategry(@Param("categoryId") String categoryId, @Param("userId")String userId); + + List selectShowList(@Param("agencyId")String agencyId, @Param("customerId")String customerId); } \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/entity/IcPartymemberStyleCategoryDictEntity.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/entity/IcPartymemberStyleCategoryDictEntity.java new file mode 100644 index 0000000000..73c469dc82 --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/entity/IcPartymemberStyleCategoryDictEntity.java @@ -0,0 +1,66 @@ +package com.epmet.modules.partymember.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 党员风采分类字典表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-12 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("ic_partymember_style_category_dict") +public class IcPartymemberStyleCategoryDictEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户id + */ + private String customerId; + + /** + * 上级分类ID 顶级此列存储0 + */ + private String pid; + + /** + * 所有上级分类ID英文顿号隔开,顶级此列存储0 + */ + private String pids; + + /** + * 分类编码,分类编码+customer_id唯一;从1000开始 + */ + private String categoryCode; + + /** + * 上级分类编码 + */ + private String parentCategoryCode; + + /** + * 分类名称 + */ + private String categoryName; + + /** + * 分类级别1,2,3,4.... 目前只有一级 + */ + private Integer level; + + /** + * 排序 + */ + private Integer sort; + + /** + * 0:可用;1:被禁用。默认0 + */ + private Boolean beDisabled; + +} diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/entity/IcPartymemberStyleEntity.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/entity/IcPartymemberStyleEntity.java index ad3e4afe9e..fea632569a 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/entity/IcPartymemberStyleEntity.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/entity/IcPartymemberStyleEntity.java @@ -50,6 +50,11 @@ public class IcPartymemberStyleEntity extends BaseEpmetEntity { */ private String gridId; + /** + * 网格的所有上级 + */ + private String gridPids; + /** * 党员姓名 */ @@ -59,5 +64,6 @@ public class IcPartymemberStyleEntity extends BaseEpmetEntity { * 主要事迹 */ private String mainDeed; - + private String categoryId; + private String categoryCode; } diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/excel/IcPartymemberStyleExcel.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/excel/IcPartymemberStyleExcel.java index a64decdd9c..108a49b1cf 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/excel/IcPartymemberStyleExcel.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/excel/IcPartymemberStyleExcel.java @@ -40,4 +40,7 @@ public class IcPartymemberStyleExcel { @Excel(name = "主要事迹") private String mainDeed; + + @Excel(name="所属分类") + private String categoryName; } \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/excel/IcPartymemberStyleImportExcel.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/excel/IcPartymemberStyleImportExcel.java index fa48ae5b34..38da34f534 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/excel/IcPartymemberStyleImportExcel.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/excel/IcPartymemberStyleImportExcel.java @@ -21,8 +21,10 @@ import cn.afterturn.easypoi.excel.annotation.Excel; import com.epmet.commons.tools.utils.ExcelVerifyInfo; import lombok.Data; +import javax.validation.constraints.NotBlank; + /** - * 党员风采 + * 党员风采导入 * * @author generator generator@elink-cn.com * @since v1.0.0 2021-11-18 @@ -31,14 +33,18 @@ import lombok.Data; public class IcPartymemberStyleImportExcel extends ExcelVerifyInfo { @Excel(name = "所属网格") + @NotBlank(message = "此列不能为空") private String gridName; @Excel(name = "党员姓名") + @NotBlank(message = "此列不能为空") private String name; @Excel(name = "主要事迹") + @NotBlank(message = "此列不能为空") private String mainDeed; - @Excel(name = "照片") - private String imageUrl; + @Excel(name="所属分类") + @NotBlank(message = "此列不能为空") + private String categoryName; } \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleCategoryDictService.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleCategoryDictService.java new file mode 100644 index 0000000000..1cbad15a09 --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleCategoryDictService.java @@ -0,0 +1,57 @@ +package com.epmet.modules.partymember.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.modules.partymember.entity.IcPartymemberStyleCategoryDictEntity; +import com.epmet.resi.partymember.dto.partymember.form.AddStyleCategoryFormDTO; +import com.epmet.resi.partymember.dto.partymember.form.StyleSelectListFormDTO; +import com.epmet.resi.partymember.dto.partymember.form.UpdateStyleCategoryFormDTO; +import com.epmet.resi.partymember.dto.partymember.result.StyleCategoryDictResDTO; + +import java.util.List; +import java.util.Map; + +/** + * 党员风采分类字典表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-12 + */ +public interface IcPartymemberStyleCategoryDictService extends BaseService { + + /** + * 【党员风采分类】列表查询 + * @param customerId + * @return + */ + List queryList(String customerId); + + /** + * 党员风采分类】添加或修改分类 + * @param formDTO + */ + void addOrUpdate(AddStyleCategoryFormDTO formDTO); + + /** + * 删除的分类如果已经使用过,清空已经使用的记录,修改时需要重新选择, + * @param formDTO + */ + void delete(UpdateStyleCategoryFormDTO formDTO); + + /** + * 【党员风采分类】启用或禁用 + * 新增党员风采时不显示已经禁用的分类,已经使用了禁用的分类正常显示, + * @param formDTO + */ + void updateStatus(UpdateStyleCategoryFormDTO formDTO); + + /** + * 党员风采-分类下拉框 + * @param formDTO + * @return + */ + List selectList(StyleSelectListFormDTO formDTO); + + IcPartymemberStyleCategoryDictEntity get(String categoryId); + + Map getCategoryDictMap(String customerId); +} \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleService.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleService.java index fb4c6e1800..1baf248479 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleService.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleService.java @@ -24,6 +24,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.modules.partymember.entity.IcPartymemberStyleEntity; import com.epmet.resi.partymember.dto.partymember.IcPartymemberStyleDTO; import com.epmet.resi.partymember.dto.partymember.form.PartyMemberStyleFormDTO; +import com.epmet.resi.partymember.dto.partymember.form.StyleShowListFormDTO; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; @@ -109,4 +110,10 @@ public interface IcPartymemberStyleService extends BaseService showList(StyleShowListFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleCategoryDictServiceImpl.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleCategoryDictServiceImpl.java new file mode 100644 index 0000000000..39e34e4c61 --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleCategoryDictServiceImpl.java @@ -0,0 +1,183 @@ +package com.epmet.modules.partymember.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.modules.partymember.dao.IcPartymemberStyleCategoryDictDao; +import com.epmet.modules.partymember.dao.IcPartymemberStyleDao; +import com.epmet.modules.partymember.entity.IcPartymemberStyleCategoryDictEntity; +import com.epmet.modules.partymember.service.IcPartymemberStyleCategoryDictService; +import com.epmet.resi.partymember.dto.partymember.form.AddStyleCategoryFormDTO; +import com.epmet.resi.partymember.dto.partymember.form.StyleSelectListFormDTO; +import com.epmet.resi.partymember.dto.partymember.form.UpdateStyleCategoryFormDTO; +import com.epmet.resi.partymember.dto.partymember.result.StyleCategoryDictResDTO; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 党员风采分类字典表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-12 + */ +@Service +public class IcPartymemberStyleCategoryDictServiceImpl extends BaseServiceImpl implements IcPartymemberStyleCategoryDictService { + + @Autowired + private IcPartymemberStyleDao icPartymemberStyleDao; + + /** + * 【党员风采分类】列表查询 + * + * @param customerId + * @return + */ + @Override + public List queryList(String customerId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(IcPartymemberStyleCategoryDictEntity::getCustomerId, customerId); + queryWrapper.orderByDesc(IcPartymemberStyleCategoryDictEntity::getSort); + List list = baseDao.selectList(queryWrapper); + List resultList = new ArrayList<>(); + for (IcPartymemberStyleCategoryDictEntity entity : list) { + StyleCategoryDictResDTO resDTO = new StyleCategoryDictResDTO(); + resDTO.setCategoryId(entity.getId()); + resDTO.setCategoryName(entity.getCategoryName()); + resDTO.setBeDisabled(entity.getBeDisabled()); + resultList.add(resDTO); + } + return resultList; + } + + /** + * 党员风采分类】添加或修改分类 + * + * @param formDTO + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void addOrUpdate(AddStyleCategoryFormDTO formDTO) { + //校验分类名称是否唯一 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(IcPartymemberStyleCategoryDictEntity::getCustomerId, formDTO.getCustomerId()) + .eq(IcPartymemberStyleCategoryDictEntity::getCategoryName, formDTO.getCategoryName()) + .ne(StringUtils.isNotBlank(formDTO.getCategoryId()), IcPartymemberStyleCategoryDictEntity::getId, formDTO.getCategoryId()); + Integer cout = baseDao.selectCount(queryWrapper); + if (cout > NumConstant.ZERO) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "分类名称已存在", "分类名称已存在"); + } + if (StringUtils.isNotBlank(formDTO.getCategoryId())) { + //更新分类名称 + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.set(IcPartymemberStyleCategoryDictEntity::getCategoryName, formDTO.getCategoryName()); + updateWrapper.eq(IcPartymemberStyleCategoryDictEntity::getId, formDTO.getCategoryId()); + baseDao.update(null, updateWrapper); + return; + } + IcPartymemberStyleCategoryDictEntity insert = new IcPartymemberStyleCategoryDictEntity(); + insert.setCategoryName(formDTO.getCategoryName()); + insert.setCustomerId(formDTO.getCustomerId()); + insert.setPid(NumConstant.ZERO_STR); + insert.setPids(NumConstant.ZERO_STR); + // 查询 当前客户下最大的一级分类数。 + Integer maxCategoryCode = baseDao.getMaxCategoryCode(formDTO.getCustomerId()); + if (NumConstant.ZERO == maxCategoryCode) { + maxCategoryCode = 1001; + } else { + maxCategoryCode++; + } + insert.setCategoryCode(String.valueOf(maxCategoryCode)); + insert.setParentCategoryCode(NumConstant.ZERO_STR); + insert.setLevel(NumConstant.ONE); + + LambdaQueryWrapper maxSortWrapper = new LambdaQueryWrapper<>(); + maxSortWrapper.eq(IcPartymemberStyleCategoryDictEntity::getCustomerId, formDTO.getCustomerId()) + .orderByDesc(IcPartymemberStyleCategoryDictEntity::getSort).last("limit 1"); + IcPartymemberStyleCategoryDictEntity max = baseDao.selectOne(maxSortWrapper); + insert.setSort(null == max ? NumConstant.ONE : max.getSort() + NumConstant.ONE); + insert.setBeDisabled(false); + baseDao.insert(insert); + } + + /** + * 删除的分类如果已经使用过,清空已经使用的记录,修改时需要重新选择, + * + * @param formDTO + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void delete(UpdateStyleCategoryFormDTO formDTO) { + baseDao.updateToDel(formDTO.getCategoryId(),formDTO.getUserId()); + icPartymemberStyleDao.clearCategry(formDTO.getCategoryId(),formDTO.getUserId()); + } + + /** + * 【党员风采分类】启用或禁用 + * 新增党员风采时不显示已经禁用的分类,已经使用了禁用的分类正常显示, + * + * @param formDTO + */ + @Override + public void updateStatus(UpdateStyleCategoryFormDTO formDTO) { + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.set(IcPartymemberStyleCategoryDictEntity::getBeDisabled, formDTO.getBeDisabled()) + .set(IcPartymemberStyleCategoryDictEntity::getUpdatedBy, formDTO.getUserId()) + .set(IcPartymemberStyleCategoryDictEntity::getUpdatedTime, new Date()); + updateWrapper.eq(IcPartymemberStyleCategoryDictEntity::getId, formDTO.getCategoryId()); + baseDao.update(null, updateWrapper); + } + + /** + * 党员风采-分类下拉框 + * + * @param formDTO + * @return + */ + @Override + public List selectList(StyleSelectListFormDTO formDTO) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(IcPartymemberStyleCategoryDictEntity::getCustomerId, formDTO.getCustomerId()); + if("addorupdate".equals(formDTO.getType())){ + //查询可用的 + queryWrapper.eq(IcPartymemberStyleCategoryDictEntity::getBeDisabled,false); + } + queryWrapper.orderByAsc(IcPartymemberStyleCategoryDictEntity::getSort); + List list = baseDao.selectList(queryWrapper); + List resultList = new ArrayList<>(); + for (IcPartymemberStyleCategoryDictEntity entity : list) { + StyleCategoryDictResDTO resDTO = new StyleCategoryDictResDTO(); + resDTO.setCategoryId(entity.getId()); + resDTO.setCategoryName(entity.getCategoryName()); + resDTO.setBeDisabled(entity.getBeDisabled()); + resultList.add(resDTO); + } + return resultList; + } + + @Override + public IcPartymemberStyleCategoryDictEntity get(String categoryId) { + return baseDao.selectById(categoryId); + } + + @Override + public Map getCategoryDictMap(String customerId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(IcPartymemberStyleCategoryDictEntity::getCustomerId, customerId); + List list=baseDao.selectList(queryWrapper); + Map map=new HashMap<>(); + if(!CollectionUtils.isEmpty(list)){ + map=list.stream().collect(Collectors.toMap(IcPartymemberStyleCategoryDictEntity::getCategoryName, m -> m, (k1, k2) -> k1)); + } + return map; + } + +} \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleServiceImpl.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleServiceImpl.java index f02233a520..1c214acd60 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleServiceImpl.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleServiceImpl.java @@ -26,6 +26,7 @@ import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; +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; @@ -39,13 +40,16 @@ import com.epmet.dto.CustomerGridDTO; import com.epmet.dto.form.GridOptionFormDTO; import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.modules.partymember.dao.IcPartymemberStyleDao; +import com.epmet.modules.partymember.entity.IcPartymemberStyleCategoryDictEntity; import com.epmet.modules.partymember.entity.IcPartymemberStyleEntity; import com.epmet.modules.partymember.entity.IcPartymemberStyleImageEntity; import com.epmet.modules.partymember.excel.IcPartymemberStyleImportExcel; +import com.epmet.modules.partymember.service.IcPartymemberStyleCategoryDictService; import com.epmet.modules.partymember.service.IcPartymemberStyleImageService; import com.epmet.modules.partymember.service.IcPartymemberStyleService; import com.epmet.resi.partymember.dto.partymember.IcPartymemberStyleDTO; import com.epmet.resi.partymember.dto.partymember.form.PartyMemberStyleFormDTO; +import com.epmet.resi.partymember.dto.partymember.form.StyleShowListFormDTO; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; @@ -76,6 +80,8 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl page(Map params) { @@ -105,6 +111,9 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl list = baseDao.selectList(wrapper); PageInfo pageInfo = new PageInfo<>(list); List dtoList = ConvertUtils.sourceToTarget(list, IcPartymemberStyleDTO.class); @@ -200,6 +214,8 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl(dtoList, pageInfo.getTotal()); @@ -219,6 +235,7 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcPartymemberStyleImportExcel.class); + List failList = importResult.getFailList(); //存放错误数据行号 List numList = new ArrayList<>(); @@ -240,8 +257,10 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl gridMap = gridOptionResult.getData().stream().collect(Collectors.toMap(CustomerGridDTO::getGridName, CustomerGridDTO::getId)); + //获取党员风采所有分类:key:分类名称; + Map categoryDictMap=icPartymemberStyleCategoryDictService.getCategoryDictMap(tokenDto.getCustomerId()); //1.数据校验 只允许导入当前组织下的网格的数据 - //网格名称不一样的数据舍弃 + //网格名称不一样的数据舍弃或者分类名称不存在也舍弃 Iterator iterator = result.iterator(); while (iterator.hasNext()) { IcPartymemberStyleImportExcel obj = iterator.next(); @@ -249,12 +268,18 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl%s,行号->%s", obj.getGridName(), obj.getRowNum())); iterator.remove(); + continue; + } + if (null == categoryDictMap.get(obj.getCategoryName().trim())) { + numList.add(obj.getRowNum()); + log.warn(String.format("分类名称【%s】不存在,不可导入,行号->%s", obj.getCategoryName(), obj.getRowNum())); + iterator.remove(); } } if (CollectionUtils.isEmpty(result)) { Collections.sort(numList); String subList = numList.stream().map(String::valueOf).collect(Collectors.joining("、")); - return new Result().error(9999, "第" + subList + "行未成功!"); + return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "第" + subList + "行未成功!"); } List imageList = new ArrayList<>(); List list = result.stream().map(item -> { @@ -263,25 +288,16 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl { - IcPartymemberStyleImageEntity urlEntity = new IcPartymemberStyleImageEntity(); - urlEntity.setImageUrl(url); - urlEntity.setCustomerId(tokenDto.getCustomerId()); - urlEntity.setStyleId(entity.getId()); - urlEntity.setSort(i.getAndIncrement()); - urlEntity.setRevision(NumConstant.ZERO); - urlEntity.setDelFlag(NumConstant.ZERO_STR); - urlEntity.setCreatedBy(tokenDto.getUserId()); - urlEntity.setUpdatedBy(tokenDto.getUserId()); - urlEntity.setCreatedTime(new Date()); - urlEntity.setUpdatedTime(new Date()); - imageList.add(urlEntity); - }); - } return entity; }).collect(Collectors.toList()); @@ -293,9 +309,35 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl showList(StyleShowListFormDTO formDTO) { + CustomerStaffInfoCacheResult staff = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId()); + if (null == staff || StringUtils.isBlank(staff.getAgencyId())) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询当前工作人员缓存信息失败", "查询用户信息异常"); + } + PageInfo pageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.selectShowList(staff.getAgencyId(), formDTO.getCustomerId())); + if (CollectionUtils.isNotEmpty(pageInfo.getList())) { + //赋值网格名称 + for (IcPartymemberStyleDTO dto : pageInfo.getList()) { + dto.setImageList(icPartymemberStyleImageService.getByStyleId(dto.getId())); + GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(dto.getGridId()); + if (null != gridInfo) { + dto.setGridName(gridInfo.getGridName()); + } + } + } + return new PageData<>(pageInfo.getList(), pageInfo.getTotal()); + } + +} diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/db/migration/V0.0.2__style_dict.sql b/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/db/migration/V0.0.2__style_dict.sql new file mode 100644 index 0000000000..1881277a69 --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/db/migration/V0.0.2__style_dict.sql @@ -0,0 +1,23 @@ +CREATE TABLE `ic_partymember_style_category_dict` ( + `ID` varchar(64) NOT NULL COMMENT '楼栋主键', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户id', + `PID` varchar(64) CHARACTER SET utf8 NOT NULL COMMENT '上级分类ID 顶级此列存储0', + `PIDS` varchar(512) CHARACTER SET utf8 NOT NULL COMMENT '所有上级分类ID英文顿号隔开,顶级此列存储0', + `CATEGORY_CODE` varchar(64) CHARACTER SET utf8 NOT NULL COMMENT '分类编码,分类编码+customer_id唯一;从1000开始', + `PARENT_CATEGORY_CODE` varchar(64) CHARACTER SET utf8 NOT NULL COMMENT '上级分类编码', + `CATEGORY_NAME` varchar(128) CHARACTER SET utf8 NOT NULL COMMENT '分类名称', + `LEVEL` int(10) NOT NULL COMMENT '分类级别1,2,3,4.... 目前只有一级', + `SORT` int(10) unsigned NOT NULL COMMENT '排序', + `BE_DISABLED` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0:可用;1:被禁用。默认0', + `DEL_FLAG` varchar(1) NOT NULL DEFAULT '0' COMMENT '删除标识 0未删除、1已删除', + `REVISION` int(11) NOT NULL DEFAULT '0' COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='党员风采分类字典表'; + + +alter table ic_partymember_style add COLUMN CATEGORY_ID VARCHAR(64) comment '分类主键' AFTER MAIN_DEED; +alter table ic_partymember_style add COLUMN CATEGORY_CODE VARCHAR(64) comment '分类编码' after CATEGORY_ID; diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/db/migration/V0.0.3__style_gridpids.sql b/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/db/migration/V0.0.3__style_gridpids.sql new file mode 100644 index 0000000000..aa3c561c66 --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/db/migration/V0.0.3__style_gridpids.sql @@ -0,0 +1 @@ +alter table ic_partymember_style add COLUMN GRID_PIDS VARCHAR(255) comment '网格的所有上级' after GRID_ID; diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/IcPartymemberStyleCategoryDictDao.xml b/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/IcPartymemberStyleCategoryDictDao.xml new file mode 100644 index 0000000000..27d838e556 --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/IcPartymemberStyleCategoryDictDao.xml @@ -0,0 +1,18 @@ + + + + + + + + + update ic_partymember_style_category_dict set del_flag='1',UPDATED_BY=#{userId},UPDATED_TIME=now() + where id=#{categoryId} + + \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/IcPartymemberStyleDao.xml b/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/IcPartymemberStyleDao.xml index a8375fe173..e68586a288 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/IcPartymemberStyleDao.xml +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/IcPartymemberStyleDao.xml @@ -18,5 +18,29 @@ + + update ic_partymember_style + set CATEGORY_ID='',CATEGORY_CODE='',UPDATED_BY=#{userId},UPDATED_TIME=now() + where del_flag='0' + and CATEGORY_ID=#{categoryId} + + \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/ImportTaskConstants.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/ImportTaskConstants.java new file mode 100644 index 0000000000..685e80a39a --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/ImportTaskConstants.java @@ -0,0 +1,26 @@ +package com.epmet.constant; + +/** + * 导入任务的业务类型常量 + */ +public interface ImportTaskConstants { + /** + * 居民 + */ + String BIZ_TYPE_RESI = "resi"; + + /** + * 处理状态:处理中 + */ + String PROCESS_STATUS_PROCESSING = "processing"; + + /** + * 处理状态:成功 + */ + String PROCESS_STATUS_FINISHED_SUCCESS = "finished_success"; + + /** + * 处理状态:完成,但未完全成功 + */ + String PROCESS_STATUS_FINISHED_FAIL = "finished_fail"; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/patrol/GridMemberRoutineWorkFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/patrol/GridMemberRoutineWorkFormDTO.java new file mode 100644 index 0000000000..d1c26b624b --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/patrol/GridMemberRoutineWorkFormDTO.java @@ -0,0 +1,47 @@ +package com.epmet.dto.form.patrol; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 网格员例行工作 + * @Author sun + */ +@Data +public class GridMemberRoutineWorkFormDTO implements Serializable { + + private static final long serialVersionUID = -3522636529743412120L; + public interface RoutineWork extends CustomerClientShowGroup {} + public interface RoutineWorkDetail extends CustomerClientShowGroup {} + + /** + * 网格Id + */ + @NotBlank(message = "网格Id不能为空", groups = RoutineWork.class) + private String gridId; + + /** + * 例行工作Id + */ + @NotBlank(message = "例行工作Id不能为空", groups = RoutineWorkDetail.class) + private String routineWorkId; + + /** + * 当前页 + */ + private Integer pageNo = 1; + + /** + * 每页记录数 + */ + private Integer pageSize = 20; + + //token中客户Id + private String customerId; + //token中用户Id + private String staffId; + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/RoutineWorkDetailResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/RoutineWorkDetailResultDTO.java new file mode 100644 index 0000000000..94335fda2b --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/RoutineWorkDetailResultDTO.java @@ -0,0 +1,84 @@ +package com.epmet.dto.result; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * @Description 网格员例行工作详情 + * @Author sun + */ +@Data +public class RoutineWorkDetailResultDTO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 例行工作Id + */ + private String routineWorkId; + /** + * 网格Id + */ + private String gridId; + /** + * 网格名称 + */ + private String gridName; + /** + * 网格员Id + */ + private String staffId; + /** + * 网格员姓名 + */ + private String staffName; + /** + * 提交日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date submitTime; + /** + * 事项类型名称,一类-二类 + */ + private String workTypeName; + /** + * 重点人员是否在当地 + */ + private String isKeyPeopleLocateName; + /** + * 重点人员现状 + */ + private String keyPeopleStatus; + /** + * 事项名称 + */ + private String title; + /** + * 是否异常 + */ + private String isNormalName; + /** + * 发生日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date happenTime; + /** + * 发生地点 + */ + private String address; + /** + * 事项简述 + */ + private String workContent; + + //例行工作一类编码 + @JsonIgnore + private String allPCode; + //例行工作二类编码 + @JsonIgnore + private String workTypeCode; + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/RoutineWorkListResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/RoutineWorkListResultDTO.java new file mode 100644 index 0000000000..f37dedcfbb --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/RoutineWorkListResultDTO.java @@ -0,0 +1,63 @@ +package com.epmet.dto.result; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * @Description 网格员例行工作列表 + * @Author sun + */ +@Data +public class RoutineWorkListResultDTO implements Serializable { + private static final long serialVersionUID = 1L; + /** + * 总条数 + */ + private Integer total = 0; + + /** + * 集合对象 + */ + private List list; + + @Data + public static class RoutineWorkList { + /** + * 例行工作Id + */ + private String routineWorkId; + + /** + * 标题 + */ + private String title; + + /** + * 提交日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date submitTime; + + /** + * 工作类型[一类-二类名称] + */ + private String workTypeName; + + /** + * 是否异常 + */ + private String isNormalName; + //例行工作一类编码 + @JsonIgnore + private String allPCode; + //例行工作二类编码 + @JsonIgnore + private String workTypeCode; + } + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StatsdataResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StatsdataResultDTO.java new file mode 100644 index 0000000000..307309f01c --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StatsdataResultDTO.java @@ -0,0 +1,35 @@ +package com.epmet.dto.result; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * @Description 网格员例行工作数据统计 + * @Author sun + */ +@Data +public class StatsdataResultDTO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 巡查总次数 + */ + private Integer patrolTotal; + + /** + * 巡查时长(xx小时xx分钟) + */ + private String totalTime; + @JsonIgnore + private Integer totalNum; + + /** + * 例行工作总次数 + */ + private Integer routineWorkCount; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/UserApplication.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/UserApplication.java index 106c49d028..caf839f79a 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/UserApplication.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/UserApplication.java @@ -13,6 +13,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.scheduling.annotation.EnableAsync; /** * 管理后台 @@ -24,6 +25,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@EnableAsync @ServletComponentScan public class UserApplication { diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/bean/ResiExportBaseInfoData.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/bean/ResiExportBaseInfoData.java new file mode 100644 index 0000000000..5dc0d0b7c5 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/bean/ResiExportBaseInfoData.java @@ -0,0 +1,27 @@ +package com.epmet.bean; + +import lombok.Data; + +import java.io.Serializable; + +/** + * desc:导出居民信息 基础信息 给其他sheet使用 + */ +@Data +public class ResiExportBaseInfoData implements Serializable { + private static final long serialVersionUID = 1L; + + private String GRID_ID; + private String VILLAGE_ID; + private String BUILD_ID; + private String UNIT_ID; + private String HOME_ID; + private String IS_BDHJ; + private String NAME; + private String MOBILE; + private String GENDER; + private String ID_CARD; + private String BIRTHDAY; + private String CONTACTS; + private String CONTACTS_MOBILE; +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/bean/ResiImportCategoryData.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/bean/ResiImportCategoryData.java index 436be52b29..1526038d21 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/bean/ResiImportCategoryData.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/bean/ResiImportCategoryData.java @@ -14,6 +14,7 @@ import java.util.Map; @Data public class ResiImportCategoryData { + private String resiId; private String agencyId; private String gridId; private String villageId; @@ -30,7 +31,8 @@ public class ResiImportCategoryData { public ResiImportCategoryData() { } - public ResiImportCategoryData(String agencyId, String gridId, String villageId, String buildId, String unitId, String homeId, Map categories) { + public ResiImportCategoryData(String resiId, String agencyId, String gridId, String villageId, String buildId, String unitId, String homeId, Map categories) { + this.resiId = resiId; this.agencyId = agencyId; this.gridId = gridId; this.villageId = villageId; @@ -39,13 +41,4 @@ public class ResiImportCategoryData { this.homeId = homeId; this.categories = categories; } - - public ResiImportCategoryData(String agencyId, String gridId, String villageId, String buildId, String unitId, String homeId) { - this.agencyId = agencyId; - this.gridId = gridId; - this.villageId = villageId; - this.buildId = buildId; - this.unitId = unitId; - this.homeId = homeId; - } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/bean/ResiImportResiCategoryChangedCache.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/bean/ResiImportResiCategoryChangedCache.java index 6203c917a9..29470e875c 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/bean/ResiImportResiCategoryChangedCache.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/bean/ResiImportResiCategoryChangedCache.java @@ -11,11 +11,16 @@ import java.util.Map; @Data public class ResiImportResiCategoryChangedCache { + /** + * 导入的tag,用来标记唯一一次导入操作。 + */ + private String importTag; + /** * 新增居民 * Map> */ - private Map newResis = new HashMap<>(); +// private Map newResis = new HashMap<>(); /** * 调动的居民 diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java index 1350ce159f..67c1aabd7e 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java @@ -24,6 +24,7 @@ import com.alibaba.excel.write.metadata.fill.FillWrapper; import com.epmet.commons.rocketmq.messages.IcResiUserAddMQMsg; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.constant.Constant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; @@ -38,11 +39,13 @@ import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.HttpClientManager; import com.epmet.commons.tools.utils.IpUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.constant.ImportTaskConstants; import com.epmet.constant.SystemMessageType; import com.epmet.dto.IcResiUserDTO; import com.epmet.dto.form.*; @@ -54,6 +57,7 @@ import com.epmet.feign.OperCustomizeOpenFeignClient; import com.epmet.feign.OssFeignClient; import com.epmet.service.IcResiUserImportService; import com.epmet.service.IcResiUserService; +import com.epmet.service.ImportTaskService; import jodd.io.FileUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; @@ -118,6 +122,11 @@ public class IcResiUserController { private RedisUtils redisUtils; @Autowired private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; + @Autowired + private LoginUserUtil loginUserUtil; + @Autowired + private ImportTaskService importTaskService; + /** * 模板枚举 @@ -293,6 +302,7 @@ public class IcResiUserController { @RequestMapping(value = "/exportExcel") public void exportExcelByEasyExcel(@RequestHeader String customerId,@LoginUser TokenDto tokenDto, @RequestBody IcResiUserPageFormDTO pageFormDTO, HttpServletResponse response) throws Exception { //tokenDto.setUserId("9e37adcce6472152e6508a19d3683e02"); + long startM = System.currentTimeMillis(); CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(customerId, tokenDto.getUserId()); String staffOrgPath = null; if (StringUtils.isNotBlank(staffInfoCacheResult.getAgencyPIds()) && !NumConstant.ZERO_STR.equals(staffInfoCacheResult.getAgencyPIds())) { @@ -322,7 +332,7 @@ public class IcResiUserController { map.putIfAbsent(tableName,exportItem); String columnName = item.getColumnName().concat(item.getColumnNum() == NumConstant.ZERO ? StrConstant.EPMETY_STR : item.getColumnNum().toString()); exportItem.getItemMap().put(columnName,item); - if (item.getOptionSourceType().equals("remote")&&item.getOptionSourceValue().contains(StrConstant.QUESTION_MARK)){ + if (Constant.OPITON_SOURCE_REMOTE.equals(item.getOptionSourceType())&&item.getOptionSourceValue().contains(StrConstant.QUESTION_MARK)){ //多个参数 String[] paramArr = item.getOptionSourceValue().split(StrConstant.QUESTION_MARK_TRANSFER)[NumConstant.ONE].split(StrConstant.AND_MARK); Arrays.stream(paramArr).forEach(o->{ @@ -346,7 +356,7 @@ public class IcResiUserController { .collect(Collectors.toList()); List> resiResultList = null; - pageFormDTO.setPageSize(NumConstant.TEN_THOUSAND); + pageFormDTO.setPageSize(NumConstant.ONE_THOUSAND); for (IcResiUserTableEnum tableEnum : resiTableList) { String tableName = tableEnum.getTableName(); pageFormDTO.setPageNo(NumConstant.ONE); @@ -374,6 +384,7 @@ public class IcResiUserController { if (excelWriter != null){ excelWriter.finish(); } + log.info("exportExcelByEasyExcel resi info cost time:{}s",(System.currentTimeMillis()-startM)/NumConstant.ONE_THOUSAND); } } @@ -431,6 +442,18 @@ public class IcResiUserController { throw new RenException("文件类型不匹配"); } + String operatorId = loginUserUtil.getLoginUserId(); + String importTaskId; + + // 记录导入任务 + if (importTaskService.existsProcessingTask(operatorId, ImportTaskConstants.BIZ_TYPE_RESI)) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), + "已存在执行中的导入任务,请等待执行完成。", + "已存在执行中的导入任务,请等待执行完成。"); + } else { + importTaskId = importTaskService.createProcessTask(operatorId, ImportTaskConstants.BIZ_TYPE_RESI); + } + Path savePath = null; try { String fileName = UUID.randomUUID().toString().concat(".").concat(extension); @@ -438,10 +461,14 @@ public class IcResiUserController { IOUtils.copy(file.getInputStream(), new FileOutputStream(savePath.toString())); List formItemList = icResiUserService.listFormItems(customerId,IcFormCodeEnum.RESI_BASE_INFO.getCode()); - icResiUserImportService.importIcResiInfoFromExcel(formItemList, savePath.toString(), response); - } catch (IOException e) { - String errorMsg = ExceptionUtils.getErrorStackTrace(e); + + icResiUserImportService.importIcResiInfoFromExcel(importTaskId, formItemList, savePath.toString(), response); + } catch (Throwable e) { + String errorMsg = ExceptionUtils.getThrowableErrorStackTrace(e); log.error("【导入居民信息失败】导入失败:{}", errorMsg); + + // 要将导入任务状态设置为结束但不成功 + importTaskService.finish(importTaskId, ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL, operatorId, null, e.getMessage()); throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); } finally { try { diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/PatrolRoutineWorkController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/PatrolRoutineWorkController.java index 5297d84c2a..41f14362ee 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/PatrolRoutineWorkController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/PatrolRoutineWorkController.java @@ -1,21 +1,17 @@ package com.epmet.controller; -import com.alibaba.excel.EasyExcel; -import com.alibaba.excel.ExcelWriter; -import com.alibaba.excel.write.metadata.WriteSheet; +import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.aop.NoRepeatSubmit; -import com.epmet.commons.tools.utils.ExcelUtils; +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.PatrolRoutineWorkFormDTO; import com.epmet.dto.form.PcWorkListFormDTO; +import com.epmet.dto.form.patrol.GridMemberRoutineWorkFormDTO; import com.epmet.dto.form.patrol.PatrolQueryFormDTO; -import com.epmet.dto.result.PatrolRoutineWorkResult; -import com.epmet.dto.result.PcWorkListResultDTO; -import com.epmet.excel.PcWorkListExport; +import com.epmet.dto.result.*; import com.epmet.service.PatrolRoutineWorkService; import com.github.pagehelper.Page; -import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -25,8 +21,6 @@ import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletResponse; import java.util.List; -import static io.netty.handler.codec.smtp.SmtpRequests.data; - /** * 例行工作 * @@ -85,4 +79,38 @@ public class PatrolRoutineWorkController { gridUserWorkService.pcWorkListExport(formDTO,response); } + /** + * @Author sun + * @Description 【例行工作】网格员巡查例行工作统计数据 + **/ + @PostMapping("statsdata") + public Result statsData(@LoginUser TokenDto tokenDto, @RequestBody GridMemberRoutineWorkFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, GridMemberRoutineWorkFormDTO.RoutineWork.class); + formDTO.setStaffId(tokenDto.getUserId()); + return new Result().ok(gridUserWorkService.statsData(formDTO)); + } + + /** + * @Author sun + * @Description 【例行工作】网格员例行工作列表 + **/ + @PostMapping("list") + public Result list(@LoginUser TokenDto tokenDto, @RequestBody GridMemberRoutineWorkFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, GridMemberRoutineWorkFormDTO.RoutineWork.class); + formDTO.setStaffId(tokenDto.getUserId()); + return new Result().ok(gridUserWorkService.list(formDTO)); + } + + /** + * @Author sun + * @Description 【例行工作】例行工作详情 + **/ + @PostMapping("detail") + public Result detail(@LoginUser TokenDto tokenDto, @RequestBody GridMemberRoutineWorkFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, GridMemberRoutineWorkFormDTO.RoutineWorkDetail.class); + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setStaffId(tokenDto.getUserId()); + return new Result().ok(gridUserWorkService.detail(formDTO)); + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/ImportTaskDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/ImportTaskDao.java new file mode 100644 index 0000000000..1306b7e3cd --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/ImportTaskDao.java @@ -0,0 +1,31 @@ +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.ImportTaskEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-15 + */ +@Mapper +public interface ImportTaskDao extends BaseDao { + + /** + * 完成导入 + * @param taskId 任务id + * @param processStatus 处理状态 + * @param operatorId 操作者id + * @param resultDesc 结果文字描述 + * @param resultDescFile 结果描述文件 + * @return + */ + int finish(@Param("taskId") String taskId, + @Param("process_status") String processStatus, + @Param("operatorId") String operatorId, + @Param("resultDesc") String resultDesc, + @Param("resultDescFile") String resultDescFile); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/PatrolRoutineWorkDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/PatrolRoutineWorkDao.java index d728cc82e2..6f99cf404a 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/PatrolRoutineWorkDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/PatrolRoutineWorkDao.java @@ -22,8 +22,11 @@ import com.epmet.dto.form.PcWorkListFormDTO; import com.epmet.dto.form.patrol.PatrolQueryFormDTO; import com.epmet.dto.result.PatrolRoutineWorkResult; import com.epmet.dto.result.PcWorkListResultDTO; +import com.epmet.dto.result.RoutineWorkDetailResultDTO; +import com.epmet.dto.result.RoutineWorkListResultDTO; import com.epmet.entity.PatrolRoutineWorkEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -39,4 +42,17 @@ public interface PatrolRoutineWorkDao extends BaseDao { List selectList(PatrolQueryFormDTO formDTO); List pcWorkList(PcWorkListFormDTO formDTO); + + /** + * @Author sun + * @Description 【例行工作】网格员例行工作列表 + **/ + List staffRoutineWorkList(@Param("gridId") String gridId, @Param("staffId") String staffId); + + /** + * @Author sun + * @Description 【例行工作】例行工作详情 + **/ + RoutineWorkDetailResultDTO getDetail(@Param("routineWorkId") String routineWorkId); + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java index 3cfb231881..8f62aef830 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java @@ -138,6 +138,8 @@ public interface StaffRoleDao extends BaseDao { */ List staffGridRole(@Param("forms") List forms); + List staffGridRoleByIds(@Param("ids") List ids); + /** * @Description 查询角色 * @Param userIds diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StatsStaffPatrolRecordDailyDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StatsStaffPatrolRecordDailyDao.java index 15b4b8c02d..d8eba9d0b0 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StatsStaffPatrolRecordDailyDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StatsStaffPatrolRecordDailyDao.java @@ -20,6 +20,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.result.PatrolYuShanResultDTO; import com.epmet.dto.result.SelectPatrolCountResultDTO; +import com.epmet.dto.result.StatsdataResultDTO; import com.epmet.entity.StatsStaffPatrolRecordDailyEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -81,5 +82,11 @@ public interface StatsStaffPatrolRecordDailyDao extends BaseDao patrolInfo(@Param("agencyId")String agencyId); + + /** + * @Author sun + * @Description 【例行工作】网格员巡查例行工作统计数据 + **/ + StatsdataResultDTO getStatsData(@Param("gridId") String gridId, @Param("staffId") String staffId); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/ImportTaskEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/ImportTaskEntity.java new file mode 100644 index 0000000000..742c6cc93e --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/ImportTaskEntity.java @@ -0,0 +1,48 @@ +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-15 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("import_task") +public class ImportTaskEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 业务类型。resi:居民;楼栋:building;房屋:house。依次补充 + */ + private String bizType; + + /** + * 处理状态。processing:处理中;finished:完成; + */ + private String processStatus; + + /** + * 谁导入的 + */ + private String operatorId; + + /** + * 开始导入的时间 + */ + private Date startTime; + + private String resultDescFile; + + private String resultDesc; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/DynamicEasyExcelListener.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/DynamicEasyExcelListener.java deleted file mode 100644 index 4c12594a45..0000000000 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/DynamicEasyExcelListener.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.epmet.excel.handler; - -import com.alibaba.excel.context.AnalysisContext; -import com.alibaba.excel.event.AnalysisEventListener; -import com.alibaba.fastjson.JSON; -import lombok.extern.slf4j.Slf4j; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * 创建一个监听器 - */ -@Slf4j -public class DynamicEasyExcelListener extends AnalysisEventListener> { - - /** - * 表头数据(存储所有的表头数据) - */ - private List> headList = new ArrayList<>(); - - /** - * 数据体 - */ - private List> dataList = new ArrayList<>(); -// Map dataList = new HashMap<>(); - - /** - * 这里会一行行的返回头 - * - * @param headMap - * @param context - */ - @Override - public void invokeHeadMap(Map headMap, AnalysisContext context) { - //log.info("解析到一条头数据:{}", JSON.toJSONString(headMap)); - //存储全部表头数据 - headList.add(headMap); - } - - /** - * 这个每一条数据解析都会来调用 - * - * @param data - * one row value. Is is same as {@link AnalysisContext#readRowHolder()} - * @param context - */ - @Override - public void invoke(Map data, AnalysisContext context) { - //log.info("解析到一条数据:{}", JSON.toJSONString(data)); - dataList.add(data); - } - - /** - * 所有数据解析完成了 都会来调用 - * - * @param context - */ - @Override - public void doAfterAllAnalysed(AnalysisContext context) { - // 这里也要保存数据,确保最后遗留的数据也存储到数据库 - //log.info("所有数据解析完成!"); - } - - public List> getHeadList() { - return headList; - } - - public List> getDataList() { - return dataList; - } -} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcResiImportDynamicExcelListener.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcResiImportDynamicExcelListener.java new file mode 100644 index 0000000000..427e70f0a3 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcResiImportDynamicExcelListener.java @@ -0,0 +1,189 @@ +package com.epmet.excel.handler; + +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.event.AnalysisEventListener; +import com.epmet.dto.result.FormItemResult; +import com.epmet.service.impl.IcResiUserImportServiceImpl; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 创建一个监听器 + */ +@Slf4j +public class IcResiImportDynamicExcelListener extends AnalysisEventListener> { + + /** + * 一次性导入的条数 + */ + private static final Integer ONCE_BATCH_IMPORT_ITEMS_SIZE = 2000; + + /** + * 客户id + */ + private String customerId; + + /** + * 当前操作人的AgencyId + */ + private String currUserAgencyId; + + /** + * 当前用户ID + */ + private String currentUserId; + + /** + * 当前用户agencyId + */ + private String currUserAgencyPids; + + /** + * 数据库表名 + */ + private String tableName; + + private IcResiUserImportServiceImpl icResiUserImportService; + + /** + * item列表 + */ + private List formItemList; + + /** + * 是否是基础信息表 + */ + private Boolean isPrimary; + + /** + * 有几行是表头 + */ + private Integer headRowNumber; + + /** + * key:itemId + * value:ColumnWrapper 列封装信息,列基础信息和列值 + */ + private Map itemIdAndColumnWrapper; + + /** + * 被丢弃的header,原因:checkbox的情况下,选项在表格中是多列,但是在item中不存在 + */ + private Map abandonedHeaders; + + /** + * 表头数据(存储所有的表头数据) + */ + private List> headList = new ArrayList<>(); + + /** + * 数据体 + */ + private List> dataList = new ArrayList<>(); +// Map dataList = new HashMap<>(); + + + public IcResiImportDynamicExcelListener(IcResiUserImportServiceImpl icResiUserImportService, String customerId, + String currentUserId, String currUserAgencyId, + String currUserAgencyPids, Boolean isPrimary, String tableName, + List formItemList, Integer headRowNumber) { + + this.customerId = customerId; + this.icResiUserImportService = icResiUserImportService; + this.formItemList = formItemList; + this.isPrimary = isPrimary; + this.currentUserId = currentUserId; + this.currUserAgencyId = currUserAgencyId; + this.currUserAgencyPids = currUserAgencyPids; + this.tableName = tableName; + this.headRowNumber = headRowNumber; + } + + /** + * 这里会一行行的返回头 + * + * @param headMap + * @param context + */ + @Override + public void invokeHeadMap(Map headMap, AnalysisContext context) { + headList.add(headMap); + + if (headList.size() < headRowNumber) { + return; + } + + // 合并多级表头到一个list中,key为列序号 + Map> headers = icResiUserImportService.mergeMultiLevelHeadLabels(headList); + + // 清洗表头数据,通过items剔除,并且得到options + abandonedHeaders = icResiUserImportService.removeAndGetOptionsFromHeaders(headers, formItemList); + + // 交换表头信息,以label连起来的string作为key,列号的列表作为value + HashMap> combinedHeaders = icResiUserImportService.exchangeKeyAndValueOfHeaders(headers); + + // 得到客户配置item数据。<"兴趣爱好:兴趣特长", item对象> + Map customizedLabelCompbinedItemsMap = formItemList.stream().collect( + Collectors.toMap(formItem -> { + String groupLabel = formItem.getGroupLabel(); + String label = formItem.getLabel(); + if (StringUtils.isNotBlank(groupLabel)) { + return groupLabel.concat(":").concat(label); + } else { + return label; + } + }, formItem -> formItem) + ); + + itemIdAndColumnWrapper = icResiUserImportService.convertExcelHeaders2DBColumnWrappers(customizedLabelCompbinedItemsMap, combinedHeaders); + } + + /** + * 这个每一条数据解析都会来调用 + * + * @param data + * one row value. Is is same as {@link AnalysisContext#readRowHolder()} + * @param context + */ + @Override + public void invoke(Map data, AnalysisContext context) { + // 每2000条数据处理一次 + dataList.add(data); + + // 达到了批量导入的阈值,执行一次持久化 + if (dataList.size() >= ONCE_BATCH_IMPORT_ITEMS_SIZE) { + execPersistant(); + } + } + + /** + * 所有数据解析完成了会调用 + * 此处也要判断,然后执行持久化,因为最后一部分数据,达不到批量阈值,不能漏掉,在最后结束的时候给他执行进去 + * @param context + */ + @Override + public void doAfterAllAnalysed(AnalysisContext context) { + if (dataList.size() != 0) { + execPersistant(); + } + } + + /** + * 执行持久化 + */ + private void execPersistant() { + // 持久化 + if (isPrimary) { + icResiUserImportService.persistIcResiBaseInfo(itemIdAndColumnWrapper, dataList, currUserAgencyId, abandonedHeaders, currUserAgencyPids, currentUserId, tableName); + } else { + icResiUserImportService.persistIcResiExtraInfo(itemIdAndColumnWrapper, dataList, currUserAgencyId, abandonedHeaders, currentUserId, tableName, customerId); + } + dataList.clear(); + } +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java index 7f3d0bdca0..35748c9ddc 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java @@ -12,5 +12,5 @@ import java.util.List; */ public interface IcResiUserImportService { - void importIcResiInfoFromExcel(List formItemList, String excelPathName, HttpServletResponse response); + void importIcResiInfoFromExcel(String importTaskId, List formItemList, String excelPathName, HttpServletResponse response); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/ImportTaskService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/ImportTaskService.java new file mode 100644 index 0000000000..65245abd98 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/ImportTaskService.java @@ -0,0 +1,35 @@ +package com.epmet.service; + + +/** + * + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-15 + */ +public interface ImportTaskService { + + /** + * 检查指定类型该用户是否存在处理中的导入任务 + * @param operatorId 操作者ID + * @param bizType 业务类型。resi:居民 + * @return + */ + boolean existsProcessingTask(String operatorId, String bizType); + + /** + * 创建处理任务 + * @param operatorId + * @param bizType + */ + String createProcessTask(String operatorId, String bizType); + + /** + * 结束导入 + * @param taskId 任务id + * @param processStatus 处理状态 + * @param resultDescFile 结果描述文件 + * @param resultDesc 结果描述文本 + */ + Boolean finish(String taskId, String processStatus, String operatorId, String resultDescFile, String resultDesc); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/PatrolRoutineWorkService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/PatrolRoutineWorkService.java index 5af4a1300a..81653fea19 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/PatrolRoutineWorkService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/PatrolRoutineWorkService.java @@ -20,9 +20,9 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.dto.form.PatrolRoutineWorkFormDTO; import com.epmet.dto.form.PcWorkListFormDTO; +import com.epmet.dto.form.patrol.GridMemberRoutineWorkFormDTO; import com.epmet.dto.form.patrol.PatrolQueryFormDTO; -import com.epmet.dto.result.PatrolRoutineWorkResult; -import com.epmet.dto.result.PcWorkListResultDTO; +import com.epmet.dto.result.*; import com.epmet.entity.PatrolRoutineWorkEntity; import com.github.pagehelper.Page; @@ -58,4 +58,22 @@ public interface PatrolRoutineWorkService extends BaseService>> errorRows = new ThreadLocal<>(); - public static final ThreadLocal>> skipedRows = new ThreadLocal<>(); /** * 导入的居民中,新增或者变动的居民 @@ -82,10 +88,12 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res /** * key: itemId * value: - * key: option的中文 - * value: options的英文key,也可能是数据id + * key: 当前item的super itemId + * value: superItem的子item列表 + * key: option的中文 + * value: options的英文key,也可能是数据id */ - Cache> itemIdAndOptionsCache = CacheBuilder.newBuilder().maximumSize(500).build(); + Cache>> itemIdAndOptionsCache = CacheBuilder.newBuilder().maximumSize(500).build(); @Autowired @@ -118,6 +126,12 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res @Autowired private UserService userService; + @Autowired + private RedisUtils redisUtils; + + @Autowired + private ImportTaskService importTaskService; + /** * 字表中不需要的列 @@ -204,11 +218,13 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res /** * 导入居民信息 - * 导入主表和所有子表信息 - * @return + * @param importTaskId 导入任务id + * @param formItemList item列表 + * @param excelPathName excel缓存路径 + * @param response 响应对象 */ @Override - public void importIcResiInfoFromExcel(List formItemList, String excelPathName, HttpServletResponse response) { + public void importIcResiInfoFromExcel(String importTaskId, List formItemList, String excelPathName, HttpServletResponse response) { String loginUserId = loginUserUtil.getLoginUserId(); String loginUserApp = loginUserUtil.getLoginUserApp(); @@ -227,12 +243,14 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res CustomerAgencyDTO agencyInfo = getResultDataOrThrowsException(govOrgOpenFeignClient.getAgencyById(currUserAgencyId), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null, null); String customerId = agencyInfo.getCustomerId(); + boolean hasErrorRows = false; + try { initImportThreadLocal(customerId); // 上传主表信息 importIcResiBaseInfoFromExcel(formItemList,excelPathName, IcResiUserTableEnum.IC_RESI_USER.getSheetNo(), IcResiUserTableEnum.IC_RESI_USER.getHeadRowNo(), - currUserAgencyId, agencyInfo.getPids(), loginUserId, IcResiUserTableEnum.IC_RESI_USER.getTableName()); + currUserAgencyId, agencyInfo.getPids(), loginUserId, IcResiUserTableEnum.IC_RESI_USER.getTableName(), customerId); // 上传附表信息 for (IcResiUserTableEnum sheet : IcResiUserTableEnum.values()) { @@ -253,22 +271,50 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res } // 执行人员类别变更记录 - Map newResis = newlyOrChangedResi.get().getNewResis(); +// Map newResis = newlyOrChangedResi.get().getNewResis(); Map categoryChangedResis = newlyOrChangedResi.get().getCategoryChangedResis(); Map transferedResis = newlyOrChangedResi.get().getTransferedResis(); + log.info("类别变动居民数:{}", categoryChangedResis.size()); + log.info("调动居民数:{}", transferedResis.size()); + //保存调动或者变更记录 - saveNewResiCategoryRecord(newResis); + saveNewResiCategoryRecord(); saveResiCategoryChangedRecord(categoryChangedResis); saveTransferedResiRecord(transferedResis); + hasErrorRows = hasErrorRows(); + try { - downLoadResults(response); - } catch (IOException e) { + // todo 做了导入记录之后,这里就要判断,没有错误就不生成文件了 + downLoadResults(hasErrorRows, response); + } catch (Exception e) { log.error("【导入IC居民附加信息】下载导入结果信息失败:{}", ExceptionUtils.getErrorStackTrace(e)); } + + // 更新上传记录 + if (hasErrorRows) { + importTaskService.finish(importTaskId, ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL, loginUserId, + null, null); + } else { + importTaskService.finish(importTaskId, ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS, loginUserId, + null, null); + } + + } catch (Exception e) { + // 抛出,让外层捕获处理,记录 + throw e; } finally { - skipedRows.remove(); + // 清空rediskey + try { + String importTag = newlyOrChangedResi.get().getImportTag(); + redisUtils.deleteByPattern(RedisKeys.icResiImportBaseKey(importTag).concat("*")); + } catch (Exception e) { + String errorMsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【导入IC居民附加信息】清空redis 类别缓存出错:{}", errorMsg); + } + + // 清空线程变量 errorRows.remove(); newlyOrChangedResi.remove(); resiCategoryColumnNameAndLabel.remove(); @@ -276,16 +322,35 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res } } + /** + * 是否有错误行 + * @return + */ + private Boolean hasErrorRows() { + boolean hasError = false; + Map> tableAndErrorRows = errorRows.get(); + for (Map.Entry> entry:tableAndErrorRows.entrySet()) { + if (entry.getValue().size() != 0) { + hasError = true; + } + } + + return hasError; + } + /** * threadLocal初始化 */ private void initImportThreadLocal(String customerId) { + // 生成importTag,用于标记唯一一次导入操作,导入完成之后,用来删除redis里面临时的key + String operatorId = loginUserUtil.getLoginUserId(); + String importTag = operatorId + System.currentTimeMillis(); + // 跳过的,不导入的行 Map> skipedRowsMap = new LinkedHashMap<>(); for (IcResiUserTableEnum e : IcResiUserTableEnum.values()) { skipedRowsMap.put(e.getTableName(), new LinkedList<>()); } - skipedRows.set(skipedRowsMap); // 错误信息 Map> errorRowsMap = new LinkedHashMap<>(); @@ -296,6 +361,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res // 居民类别信息 ResiImportResiCategoryChangedCache c = new ResiImportResiCategoryChangedCache(); + c.setImportTag(importTag); newlyOrChangedResi.set(c); List resiCategoryItems = getResultDataOrThrowsException(operCustomizeOpenFeignClient.listResiCategoryItems(customerId), @@ -320,43 +386,12 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res * @param currentUserId * @return */ - private Object importIcResiBaseInfoFromExcel(List formItemList, String excelPathName, int sheetNo, int headRowNumber, String currUserAgencyId, String currUserAgencyPids, String currentUserId, - String tableName) { - DynamicEasyExcelListener readListener = new DynamicEasyExcelListener(); - //EasyExcelFactory.read(new File(excelPathName)).registerReadListener(readListener).headRowNumber(headRowNumber).sheet(sheetNo).doRead(); - EasyExcel.read(new File(excelPathName)).registerReadListener(readListener).headRowNumber(headRowNumber).sheet(sheetNo).doRead(); - - List> headList = readListener.getHeadList(); - List> dataList = readListener.getDataList(); - - // 合并多级表头到一个list中,key为列序号 - Map> headers = mergeMultiLevelHeadLabels(headList); - - // 清洗表头数据,通过items剔除,并且得到options - Map abandonedHeaders = removeAndGetOptionsFromHeaders(headers, formItemList); - - // 交换表头信息,以label连起来的string作为key,列号的列表作为value - HashMap> combinedHeaders = exchangeKeyAndValueOfHeaders(headers); + private void importIcResiBaseInfoFromExcel(List formItemList, String excelPathName, int sheetNo, int headRowNumber, String currUserAgencyId, String currUserAgencyPids, String currentUserId, + String tableName, String customerId) { - // 得到客户配置item数据。<"兴趣爱好:兴趣特长", item对象> - Map customizedLabelCompbinedItemsMap = formItemList.stream().collect( - Collectors.toMap(formItem -> { - String groupLabel = formItem.getGroupLabel(); - String label = formItem.getLabel(); - if (StringUtils.isNotBlank(groupLabel)) { - return groupLabel.concat(":").concat(label); - } else { - return label; - } - }, formItem -> formItem) - ); - - Map itemIdAndColumnWrapper = convertExcelHeaders2DBColumnWrappers(customizedLabelCompbinedItemsMap, combinedHeaders); - - // 持久化 - persistIcResiBaseInfo(itemIdAndColumnWrapper, dataList, currUserAgencyId, abandonedHeaders, currUserAgencyPids, currentUserId, tableName); - - return headers; + IcResiImportDynamicExcelListener readListener = new IcResiImportDynamicExcelListener(this, customerId, currentUserId, currUserAgencyId, currUserAgencyPids, + true, tableName, formItemList, headRowNumber); + EasyExcel.read(new File(excelPathName)).registerReadListener(readListener).headRowNumber(headRowNumber).sheet(sheetNo).doRead(); } /** @@ -371,34 +406,12 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res * @param targetTableName 要插入哪一个表 * @return */ - private Object importIcResiExtraInfoFromExcel(List formItemList, String excelPathName, int sheetNo, int headRowNumber, String currUserAgencyId, String currentUserId, + private void importIcResiExtraInfoFromExcel(List formItemList, String excelPathName, int sheetNo, int headRowNumber, String currUserAgencyId, String currentUserId, String targetTableName, String customerId) { - DynamicEasyExcelListener readListener = new DynamicEasyExcelListener(); - EasyExcelFactory.read(new File(excelPathName)).registerReadListener(readListener).headRowNumber(headRowNumber).sheet(sheetNo).doRead(); - - List> headList = readListener.getHeadList(); - List> dataList = readListener.getDataList(); - - Map> headers = mergeMultiLevelHeadLabels(headList); - - Map abandonedHeaders = removeAndGetOptionsFromHeaders(headers, formItemList); - - HashMap> combinedHeaders = exchangeKeyAndValueOfHeaders(headers); - Map formItemMap = formItemList.stream().collect( - Collectors.toMap(formItem -> { - String groupLabel = formItem.getGroupLabel(); - String label = formItem.getLabel(); - if (StringUtils.isNotBlank(groupLabel)) { - return groupLabel.concat(":").concat(label); - } else { - return label; - } - }, formItem -> formItem) - ); - Map headerColumnWrapper = convertExcelHeaders2DBColumnWrappers(formItemMap, combinedHeaders); - persistIcResiExtraInfo(headerColumnWrapper, dataList, currUserAgencyId, abandonedHeaders, currentUserId, targetTableName, customerId); - return headerColumnWrapper; + IcResiImportDynamicExcelListener readListener = new IcResiImportDynamicExcelListener(this, customerId, currentUserId, currUserAgencyId, null, + false, targetTableName, formItemList, headRowNumber); + EasyExcelFactory.read(new File(excelPathName)).registerReadListener(readListener).headRowNumber(headRowNumber).sheet(sheetNo).doRead(); } /** @@ -408,7 +421,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res * @param currUserAgencyId 当前用户的组织id * @param checkBoxOptionColumnIdxAndLabel 复选框的列号&label中文 */ - private void persistIcResiBaseInfo(Map itemIdAndColumnWrapper, List> dataRows, + public void persistIcResiBaseInfo(Map itemIdAndColumnWrapper, List> dataRows, String currUserAgencyId, Map checkBoxOptionColumnIdxAndLabel, String currUserAgencyPids, String currentUserId, String tableName) { @@ -468,8 +481,10 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res } } else { // 新增居民 + String resiId = IdWorker.getIdStr(); + columnAndValues.put("CREATED_BY", currentUserId); - columnAndValues.put("ID", UUID.randomUUID().toString().replace("-", "")); + columnAndValues.put("ID", resiId); icResiUserDao.add(tableName, columnAndValues); // 过滤出本居民含有哪些类别 @@ -478,19 +493,31 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res .filter((categoryColumnName) -> "1".equals(columnAndValues.get(categoryColumnName))) .collect(Collectors.toMap((k) -> k, (k) -> columnAndValues.get(k))); - newlyOrChangedResi.get().getNewResis().put(columnAndValues.get("ID"), - new ResiImportCategoryData(columnAndValues.get("AGENCY_ID"), - columnAndValues.get("GRID_ID"), - columnAndValues.get("VILLAGE_ID"), - columnAndValues.get("BUILD_ID"), - columnAndValues.get("UNIT_ID"), - columnAndValues.get("HOME_ID"), - resiCategories)); +// newlyOrChangedResi.get().getNewResis().put(resiId, +// new ResiImportCategoryData(columnAndValues.get("AGENCY_ID"), +// columnAndValues.get("GRID_ID"), +// columnAndValues.get("VILLAGE_ID"), +// columnAndValues.get("BUILD_ID"), +// columnAndValues.get("UNIT_ID"), +// columnAndValues.get("HOME_ID"), +// resiCategories)); + + ResiImportCategoryData categoryData = new ResiImportCategoryData(resiId, + columnAndValues.get("AGENCY_ID"), + columnAndValues.get("GRID_ID"), + columnAndValues.get("VILLAGE_ID"), + columnAndValues.get("BUILD_ID"), + columnAndValues.get("UNIT_ID"), + columnAndValues.get("HOME_ID"), + resiCategories); + + redisUtils.hMSet(RedisKeys.icResiImportResiCategoryKey(newlyOrChangedResi.get().getImportTag(), "add", resiId), BeanUtil.beanToMap(categoryData)); + categoryData = null; } } catch (Exception e) { String errorMsg; - if (e instanceof RenException) { + if (e instanceof RenException | e instanceof EpmetException) { errorMsg = e.getMessage(); } else { errorMsg = "未知系统错误"; @@ -517,7 +544,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res * @param checkBoxOptionColumnIdxAndLabel 复选框的列号&label中文 * @param targetTableName 要插入到哪一个表 */ - private void persistIcResiExtraInfo(Map headerColumnWrapper, List> dataRows, + public void persistIcResiExtraInfo(Map headerColumnWrapper, List> dataRows, String currUserAgencyId, Map checkBoxOptionColumnIdxAndLabel, String currentUserId, String targetTableName, String customerId) { @@ -637,7 +664,9 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res for (Map.Entry itemIdAndColumnWrapper : itemIdAndColumnWrappers.entrySet()) { + String itemId = itemIdAndColumnWrapper.getKey(); ColumnWrapper columnWrapper = itemIdAndColumnWrapper.getValue(); + if ("input".equals(columnWrapper.getItemType()) || "textarea".equals(columnWrapper.getItemType()) || "datepicker".equals(columnWrapper.getItemType()) @@ -663,13 +692,37 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res columnWrapper.setColValue(colValue); } else { // remote类型。优先从缓存取 - Map optionsOfItem = itemIdAndOptionsCache.getIfPresent(itemIdAndColumnWrapper.getKey()); - if (optionsOfItem == null || optionsOfItem.size() == 0) { - optionsOfItem = listRemoteOptions(itemIdAndColumnWrappers, columnWrapper.getOptionSourceValue(), currUserAgencyId, "saveorupdate"); - itemIdAndOptionsCache.put(itemIdAndColumnWrapper.getKey(), optionsOfItem); + String fullUri = columnWrapper.getOptionSourceValue(); + String[] uriParts = splitOptionSourceUrl(fullUri); + String pureUri = uriParts[0]; + String superItemId = uriParts[1]; + String superColumValue; + + if (StringUtils.isNotBlank(superItemId)) { + superColumValue = itemIdAndColumnWrappers.get(superItemId).getColValue(); + } else { + superColumValue = "-"; + } + + Map> superOptions = itemIdAndOptionsCache.getIfPresent(itemId); + if (superOptions != null && superOptions.size() > 0) { + Map options = superOptions.get(superColumValue); + if (options == null || options.size() == 0) { + options = listRemoteOptions(pureUri, superItemId, itemIdAndColumnWrappers, currUserAgencyId, "saveorupdate"); + superOptions.put(superColumValue, options); + } + + String colValue = options.get(cellContent); + columnWrapper.setColValue(colValue); + } else { + Map options = listRemoteOptions(pureUri, superItemId, itemIdAndColumnWrappers, currUserAgencyId, "saveorupdate"); + superOptions = new HashMap<>(); + superOptions.put(superColumValue, options); + itemIdAndOptionsCache.put(itemId, superOptions); + + String colValue = options.get(cellContent); + columnWrapper.setColValue(colValue); } - String colValue = optionsOfItem.get(cellContent); - columnWrapper.setColValue(colValue); } } else if ("checkbox".equals(columnWrapper.getItemType())) { String checkBoxColValue = getCheckBoxColValue(columnWrapper, row, checkBoxOptionColumnIdxAndLabel); @@ -709,7 +762,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res * @author wxz * @date 2021.10.28 21:27:18 */ - private HashMap> exchangeKeyAndValueOfHeaders(Map> headers) { + public HashMap> exchangeKeyAndValueOfHeaders(Map> headers) { HashMap> itemAndColIndexs = new LinkedHashMap<>(); headers.forEach((k, v) -> { @@ -734,7 +787,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res * @author wxz * @date 2021.10.28 21:07:12 */ - private Map removeAndGetOptionsFromHeaders(Map> headers, List items) { + public Map removeAndGetOptionsFromHeaders(Map> headers, List items) { List itemLabels = items.stream().map(i -> i.getLabel()).collect(Collectors.toList()); Map abandonedOptions = new HashMap<>(); for (Map.Entry> entry:headers.entrySet()) { @@ -765,7 +818,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res * value:列号组成的列表(例如[1,2,3]) * @return key:itemId;value:columnWrapper */ - private Map convertExcelHeaders2DBColumnWrappers(Map customizedLabelCompbinedItemsMap, Map> combinedHeaders) { + public Map convertExcelHeaders2DBColumnWrappers(Map customizedLabelCompbinedItemsMap, Map> combinedHeaders) { // HashMap> tables = new HashMap<>(); Map columns = new LinkedHashMap<>(combinedHeaders.size()); @@ -835,7 +888,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res * @author wxz * @date 2021.10.27 16:17:34 */ - private Map> mergeMultiLevelHeadLabels(List> headList) { + public Map> mergeMultiLevelHeadLabels(List> headList) { Map lastNotNullHeads = new LinkedHashMap<>(); @@ -875,28 +928,37 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res } /** - * 远程获取options + * 分割sourceUrl为纯url和父itemId * @param fullUri - * @return + * @return [ pureUri, cascadeItemId(父itemId) ] */ - public Map listRemoteOptions(Map columnWrappers, String fullUri, String currUserAgencyId, String purpose) { + public String[] splitOptionSourceUrl(String fullUri) { String pureUri = null; String cascadeItemId = null; - ColumnWrapper cascadeItemColumnWrapper = null; if (fullUri.indexOf(StrConstant.QUESTION_MARK) != -1) { String[] uriParts = fullUri.split(StrConstant.QUESTION_MARK_TRANSFER); pureUri = uriParts[0]; cascadeItemId = uriParts[1]; - - // 根据uri上的id,找到关联的itemid,从而找到关联的item的值 - if (columnWrappers != null){ - cascadeItemColumnWrapper = columnWrappers.get(cascadeItemId); - } } else { pureUri = fullUri; } + return new String[] { pureUri, cascadeItemId }; + } + + /** + * 远程获取options + * @return + */ + public Map listRemoteOptions(String pureUri, String cascadeItemId, Map columnWrappers, String currUserAgencyId, String purpose) { + ColumnWrapper cascadeItemColumnWrapper = null; + + // 根据uri上的id,找到关联的itemid,从而找到关联的item的值 + if (columnWrappers != null && StringUtils.isNotBlank(cascadeItemId)){ + cascadeItemColumnWrapper = columnWrappers.get(cascadeItemId); + } + List options = null; switch (pureUri) { @@ -1013,19 +1075,11 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res * @param response * @throws IOException */ - public void downLoadResults(HttpServletResponse response) throws IOException { + public void downLoadResults(Boolean hasErrorRows, HttpServletResponse response) throws IOException { String fileName; // 判断是否有错误信息,以确定文件名 - boolean hasError = false; - Map> tableAndErrorRows = errorRows.get(); - for (Map.Entry> entry:tableAndErrorRows.entrySet()) { - if (entry.getValue().size() != 0) { - hasError = true; - } - } - - if (hasError) { + if (hasErrorRows) { fileName = "导入失败条目清单.xls"; } else { fileName = "导入成功.xls"; @@ -1093,6 +1147,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res } ResiImportCategoryData oldOne = new ResiImportCategoryData( + existingResiMap.get("ID"), existingResiMap.get("AGENCY_ID"), existingResiMap.get("GRID_ID"), existingResiMap.get("VILLAGE_ID"), @@ -1102,7 +1157,8 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res existingResiCategories); ResiImportCategoryData newOne = new ResiImportCategoryData( - existingResiMap.get("AGENCY_ID"), + newResiMap.get("ID"), + newResiMap.get("AGENCY_ID"), newResiMap.get("GRID_ID"), newResiMap.get("VILLAGE_ID"), newResiMap.get("BUILD_ID"), @@ -1153,6 +1209,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res } ResiImportCategoryData oldOne = new ResiImportCategoryData( + existingResiMap.get("ID"), existingResiMap.get("AGENCY_ID"), existingResiMap.get("GRID_ID"), existingResiMap.get("VILLAGE_ID"), @@ -1161,7 +1218,9 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res existingResiMap.get("HOME_ID"), oldCategories); - ResiImportCategoryData newOne = new ResiImportCategoryData(existingResiMap.get("AGENCY_ID"), + ResiImportCategoryData newOne = new ResiImportCategoryData( + newResiMap.get("ID"), + newResiMap.get("AGENCY_ID"), newResiMap.get("GRID_ID"), newResiMap.get("VILLAGE_ID"), newResiMap.get("BUILD_ID"), @@ -1180,14 +1239,20 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res private void saveSubTableInfoToCategoryChangedResiCache(String icResiId, String columnName, Map resiInfoMap) { ResiImportResiCategoryChangedCache cc = newlyOrChangedResi.get(); - Map newResis = cc.getNewResis(); +// Map newResis = cc.getNewResis(); Map categoryChangedResis = cc.getCategoryChangedResis(); Map transferedResis = cc.getTransferedResis(); - ResiImportCategoryData newResi = newResis.get(icResiId); - if (newResi != null) { +// ResiImportCategoryData newResi = newResis.get(icResiId); + + String userCateRedisKey = RedisKeys.icResiImportResiCategoryKey(newlyOrChangedResi.get().getImportTag(), "add", icResiId); + Map < String, Object > addUserMap = redisUtils.hGetAll(userCateRedisKey); + if (addUserMap != null && addUserMap.size() > 0) { //说明是新增居民 - newResi.getCategories().put(columnName, "1"); + ResiImportCategoryData newResiCateData = ConvertUtils.mapToEntity(addUserMap, ResiImportCategoryData.class); + newResiCateData.getCategories().put(columnName, "1"); + redisUtils.hMSet(userCateRedisKey, BeanUtil.beanToMap(newResiCateData)); + newResiCateData = null; return; } @@ -1339,35 +1404,39 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res /** * 保存新增居民类别记录 - * @param newResis */ - public void saveNewResiCategoryRecord(Map newResis) { + public void saveNewResiCategoryRecord() { Date now = new Date(); + Set newResiKeys = redisUtils.keys(RedisKeys.icResiImportTypeKey(newlyOrChangedResi.get().getImportTag(), "add").concat("*")); + CustomerStaffInfoCacheResult operator = CustomerStaffRedis.getStaffInfo(loginUserUtil.getLoginUserCustomerId(), loginUserUtil.getLoginUserId()); - for (Map.Entry resi : newResis.entrySet()) { - String resiId = resi.getKey(); - ResiImportCategoryData data = resi.getValue(); + for (String resiKey : newResiKeys) { + Map newResiInfoMap = redisUtils.hGetAll(resiKey); + ResiImportCategoryData newResiInfoObj = ConvertUtils.mapToEntity(newResiInfoMap, ResiImportCategoryData.class); - IcResiUserEntity resiInfo = icResiUserDao.selectById(resiId); + IcResiUserEntity resiInfo = icResiUserDao.selectById(newResiInfoObj.getResiId()); // 插入changeRecord - IcUserChangeRecordEntity changeRecord = fillChangeRecord(loginUserUtil.getLoginUserCustomerId(), resiId, resiInfo.getName(), null, + IcUserChangeRecordEntity changeRecord = fillChangeRecord(loginUserUtil.getLoginUserCustomerId(), newResiInfoObj.getResiId(), resiInfo.getName(), null, loginUserUtil.getLoginUserId(), operator.getRealName(), "-", "-", "add", "新增", "", now); icUserChangeRecordDao.insert(changeRecord); // 插入changeDetail - for (Map.Entry column : data.getCategories().entrySet()) { - IcUserChangeDetailedEntity changedetail = fillChangeDetail(loginUserUtil.getLoginUserCustomerId(), resiId, changeRecord.getId(), data.getAgencyId(), - data.getGridId(), data.getVillageId(), data.getBuildId(), data.getUnitId(), - data.getHomeId(), "add", "新增", column.getKey(), 1, resiInfo.getPids()); + for (Map.Entry column : newResiInfoObj.getCategories().entrySet()) { + IcUserChangeDetailedEntity changedetail = fillChangeDetail(loginUserUtil.getLoginUserCustomerId(), newResiInfoObj.getResiId(), changeRecord.getId(), newResiInfoObj.getAgencyId(), + newResiInfoObj.getGridId(), newResiInfoObj.getVillageId(), newResiInfoObj.getBuildId(), newResiInfoObj.getUnitId(), + newResiInfoObj.getHomeId(), "add", "新增", column.getKey(), 1, resiInfo.getPids()); icUserChangeDetailedDao.insert(changedetail); + changedetail = null; } - } + changeRecord = null; + newResiInfoObj = null; + } } /** diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java index 5709333e9b..f912200041 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java @@ -20,11 +20,9 @@ package com.epmet.service.impl; import cn.hutool.core.bean.BeanUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.epmet.bean.ResiExportBaseInfoData; 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.constant.ServiceConstant; -import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.constant.*; import com.epmet.commons.tools.dto.form.DictListFormDTO; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.dto.result.DictListResultDTO; @@ -69,6 +67,7 @@ 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.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -77,6 +76,8 @@ import java.math.RoundingMode; import java.sql.Date; import java.sql.Timestamp; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; import java.util.function.Function; import java.util.stream.Collectors; @@ -114,6 +115,8 @@ public class IcResiUserServiceImpl extends BaseServiceImpl getWrapper(Map params){ String id = (String)params.get(FieldConstant.ID_HUMP); @@ -881,7 +884,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl> mapListPage = PageHelper.startPage(pageFormDTO.getPageNo(), pageFormDTO.getPageSize(), pageFormDTO.getPageFlag()).doSelectPage(() -> { this.dynamicQuery(pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), baseTableName, pageFormDTO.getConditions(), currentStaffAgencyId, staffOrgPath); }); - mapListPage.getResult().stream().filter(Objects::nonNull).forEach(resiUser -> { + mapListPage.getResult().parallelStream().filter(Objects::nonNull).forEach(resiUser -> { String resiId = null; //获取用户Id if (IcResiUserConstant.IC_RESI_USER.equals(baseTableName)) { @@ -905,28 +908,33 @@ public class IcResiUserServiceImpl extends BaseServiceImpl originalConditionMap = new HashMap<>(); - for (FormItemResult e : formItemMap.getItemMap().values()) { + Map originalConditionMap = new ConcurrentHashMap<>(); + formItemMap.getItemMap().values().parallelStream().forEach(e->{ String columnName = getColumnName(e); Object temp = resiUser.get(columnName); String vauleStr = temp == null ? StrConstant.EPMETY_STR : temp.toString(); originalConditionMap.putIfAbsent(columnName,vauleStr); - if ("remote".equals(e.getOptionSourceType()) && StringUtils.isNotBlank(vauleStr)) { + if (Constant.OPITON_SOURCE_REMOTE.equals(e.getOptionSourceType()) && StringUtils.isNotBlank(vauleStr)) { putRemoteValue(formItemMap.getRemoteItemConditionMap().get(e.getItemId()), currentStaffAgencyId, resiUser,originalConditionMap, e, columnName, vauleStr); } else { putOptionValue(resiUser, e, columnName, vauleStr); } + }); - } - if (!IcResiUserConstant.IC_RESI_USER.equals(baseTableName)) { - Map o = redisUtils.hGetAll(RedisKeys.getExportResiBaseInfoKey(resiId)); - if (o != null){ - resiUser.putAll(o); + if (IcResiUserConstant.IC_RESI_USER.equals(baseTableName)) { + //把人放入redis缓存 便于后面的sheet使用基础信息 + ResiExportBaseInfoData infoData = ConvertUtils.mapToEntity(resiUser, ResiExportBaseInfoData.class); + redisTemplate.opsForValue().set(RedisKeys.getExportResiBaseInfoKey(resiId), infoData,RedisUtils.MINUTE_THIRTY_EXPIRE, TimeUnit.SECONDS); + } else { + ResiExportBaseInfoData temp = (ResiExportBaseInfoData) redisTemplate.opsForValue().get(RedisKeys.getExportResiBaseInfoKey(resiId)); + if (temp != null){ + try { + resiUser.putAll(ConvertUtils.entityToMap(temp)); + } catch (Exception e) { + log.error("entityToMap exception,temp:{}",temp); + } } - return; } - //把人放入redis缓存 便于后面的sheet使用基础信息 - redisUtils.hMSet(RedisKeys.getExportResiBaseInfoKey(resiId),resiUser,RedisUtils.MINUTE_THIRTY_EXPIRE); }); remoteOptionCacheMap.clear(); return mapListPage.getResult(); @@ -962,9 +970,11 @@ public class IcResiUserServiceImpl extends BaseServiceImpl remoteOptions = icResiUserImportService.listRemoteOptions(columnWrappers, e.getOptionSourceValue(), currentStaffAgencyId, "query"); + String[] parts = icResiUserImportService.splitOptionSourceUrl(e.getOptionSourceValue()); + + Map remoteOptions = icResiUserImportService.listRemoteOptions(parts[0], parts[1], columnWrappers, currentStaffAgencyId, "query"); if (FormItemTypeEnum.CHECKBOX.getCode().equals(e.getItemType())) { - remoteOptions.forEach((label, value) -> map.put(value, vauleStr.contains(value) ? "是" : "否")); + remoteOptions.forEach((label, value) -> map.put(value, vauleStr.contains(value) ? StrConstant.YES : StrConstant.NO)); } else if (FormItemTypeEnum.SELECT.getCode().equals(e.getItemType())) { remoteOptions.forEach((label, value) -> { if (vauleStr.equals(value)) { @@ -984,7 +994,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl { - map.put(optionDTO.getValue(), vauleStr.contains(optionDTO.getValue()) ? "是" : "否"); + map.put(optionDTO.getValue(), vauleStr.contains(optionDTO.getValue()) ? StrConstant.YES : StrConstant.NO); }); break; case SELECT: diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java new file mode 100644 index 0000000000..d80ee5d9a6 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java @@ -0,0 +1,57 @@ +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.epmet.constant.ImportTaskConstants; +import com.epmet.dao.ImportTaskDao; +import com.epmet.entity.ImportTaskEntity; +import com.epmet.service.ImportTaskService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; + +/** + * + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-15 + */ +@Service +public class ImportTaskServiceImpl implements ImportTaskService { + + @Autowired + private ImportTaskDao importRecordDao; + + /** + * 该用户,该业务类型,是否有正在处理的导入任务 + * @param operatorId 操作者ID + * @param bizType 业务类型。resi:居民 + * @return + */ + @Override + public boolean existsProcessingTask(String operatorId, String bizType) { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(ImportTaskEntity::getOperatorId, operatorId); + query.eq(ImportTaskEntity::getBizType, bizType); + query.eq(ImportTaskEntity::getProcessStatus, ImportTaskConstants.PROCESS_STATUS_PROCESSING); + + return importRecordDao.selectCount(query) > 0; + } + + @Override + public String createProcessTask(String operatorId, String bizType) { + ImportTaskEntity importRecord = new ImportTaskEntity(); + importRecord.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_PROCESSING); + importRecord.setOperatorId(operatorId); + importRecord.setBizType(bizType); + importRecord.setStartTime(new Date()); + + importRecordDao.insert(importRecord); + return importRecord.getId(); + } + + @Override + public Boolean finish(String taskId, String processStatus, String operatorId, String resultDescFile, String resultDesc) { + return importRecordDao.finish(taskId, processStatus, operatorId, resultDesc, resultDescFile) > 0; + } +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/PatrolRoutineWorkServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/PatrolRoutineWorkServiceImpl.java index bc850e1d2c..df3d1c3418 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/PatrolRoutineWorkServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/PatrolRoutineWorkServiceImpl.java @@ -25,29 +25,33 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.rocketmq.messages.BaseMQMsgDTO; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.dto.form.UpdateUserPointsFormDTO; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.dto.result.DictTreeResultDTO; +import com.epmet.commons.tools.enums.BehaviorTypeYuShanEnum; import com.epmet.commons.tools.enums.DictTypeEnum; import com.epmet.commons.tools.enums.OrgTypeEnum; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; 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.security.user.LoginUserUtil; import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.YuShanSysApiService; import com.epmet.constant.SystemMessageType; import com.epmet.dao.PatrolRoutineWorkDao; +import com.epmet.dao.StatsStaffPatrolRecordDailyDao; import com.epmet.dto.CustomerGridDTO; import com.epmet.dto.form.CustomerGridFormDTO; import com.epmet.dto.form.PatrolRoutineWorkFormDTO; import com.epmet.dto.form.PcWorkListFormDTO; +import com.epmet.dto.form.patrol.GridMemberRoutineWorkFormDTO; import com.epmet.dto.form.patrol.PatrolQueryFormDTO; -import com.epmet.dto.result.AllGridsByUserIdResultDTO; -import com.epmet.dto.result.PatrolRoutineWorkResult; -import com.epmet.dto.result.PcWorkListResultDTO; +import com.epmet.dto.result.*; import com.epmet.entity.PatrolRoutineWorkEntity; import com.epmet.entity.PatrolRoutineWorkTypeEntity; import com.epmet.excel.PcWorkListExport; @@ -61,6 +65,7 @@ import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -68,13 +73,10 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import javax.servlet.http.HttpServletResponse; -import java.beans.Encoder; import java.net.URLEncoder; import java.util.*; import java.util.stream.Collectors; -import static com.epmet.commons.tools.utils.DateUtils.DATE_PATTERN; - /** * 巡查例行工作 * @@ -94,6 +96,10 @@ public class PatrolRoutineWorkServiceImpl extends BaseServiceImpl NumConstant.ZERO ? resultDTO.getTotalNum() / 60 : 0); + String patrolDuration = (minutes / 60 > 0 ? minutes / 60 + "小时" : "") + (minutes % 60 > 0 ? minutes % 60 + "分钟" : "0分钟"); + resultDTO.setTotalTime(patrolDuration); + + return resultDTO; + } + + /** + * @Author sun + * @Description 【例行工作】网格员例行工作列表 + **/ + @Override + public RoutineWorkListResultDTO list(GridMemberRoutineWorkFormDTO formDTO) { + RoutineWorkListResultDTO resultDTO = new RoutineWorkListResultDTO(); + //1.按条件查询网格员例行工作列表数据 + PageInfo result = + PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.staffRoutineWorkList(formDTO.getGridId(), formDTO.getStaffId())); + if (org.springframework.util.CollectionUtils.isEmpty(result.getList())) { + return resultDTO; + } + + //2.查询分类编码字典数据 + Result> unitTypeMap = adminOpenFeignClient.dictMap(DictTypeEnum.PATROL_WORK_TYPE.getCode()); + if (!unitTypeMap.success() || MapUtils.isEmpty(unitTypeMap.getData())) { + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "获取例行工作类型字典表数据失败!"); + } + Map map = unitTypeMap.getData(); + + //3.封装数据并返回 + result.getList().forEach(re -> { + re.setWorkTypeName(map.get(re.getWorkTypeCode()) + "-" + map.get(re.getWorkTypeCode())); + }); + resultDTO.setTotal((int) result.getTotal()); + resultDTO.setList(result.getList()); + return resultDTO; + } + + /** + * @Author sun + * @Description 【例行工作】例行工作详情 + **/ + @Override + public RoutineWorkDetailResultDTO detail(GridMemberRoutineWorkFormDTO formDTO) { + //1.查询例行工作详情数据 + RoutineWorkDetailResultDTO resultDTO = baseDao.getDetail(formDTO.getRoutineWorkId()); + if (null == resultDTO) { + return new RoutineWorkDetailResultDTO(); + } + //2.获取工作人员缓存信息 + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); + if (null == staffInfo) { + throw new EpmetException(String.format("查询工作人员%s缓存信息失败...", formDTO.getStaffId())); + } + //3.获取网格缓存信息 + GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(resultDTO.getGridId()); + if (null == gridInfo) { + throw new EpmetException(String.format("未查询到网格{%s}信息", resultDTO.getGridId())); + } + if (StringUtils.isEmpty(gridInfo.getAgencyName())) { + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(gridInfo.getPid()); + gridInfo.setAgencyName(agencyInfo.getOrganizationName()); + } + //4.获取例行工作类型字典表数据 + Result> unitTypeMap = adminOpenFeignClient.dictMap(DictTypeEnum.PATROL_WORK_TYPE.getCode()); + if (!unitTypeMap.success() || MapUtils.isEmpty(unitTypeMap.getData())) { + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "获取例行工作类型字典表数据失败!"); + } + //5.封装数据并返回 + resultDTO.setGridName(gridInfo.getAgencyName() + "-" + gridInfo.getGridName()); + resultDTO.setStaffName(staffInfo.getRealName()); + resultDTO.setWorkTypeName(unitTypeMap.getData().get(resultDTO.getAllPCode()) + "-" + unitTypeMap.getData().get(resultDTO.getWorkTypeCode())); + return resultDTO; + + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java index 9ddd74e7aa..770cf8f650 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java @@ -9,8 +9,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.rocketmq.messages.StaffPatrolMQMsg; import com.epmet.commons.tools.constant.NumConstant; -import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.dto.form.UpdateUserPointsFormDTO; +import com.epmet.commons.tools.enums.BehaviorTypeYuShanEnum; import com.epmet.commons.tools.enums.OrgTypeEnum; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; @@ -21,10 +22,7 @@ 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.security.dto.TokenDto; -import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.utils.DateUtils; -import com.epmet.commons.tools.utils.ExcelUtils; -import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.*; import com.epmet.constant.PatrolConstant; import com.epmet.constant.SystemMessageType; import com.epmet.dao.CustomerStaffDao; @@ -58,8 +56,6 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -92,7 +88,8 @@ public class StaffPatrolRecordServiceImpl extends BaseServiceImplsendPatrolMsg(e, SystemMessageType.USER_PATROL_STOP)); + list.forEach(e-> { + sendPatrolMsg(e, SystemMessageType.USER_PATROL_STOP); + //网格员结束巡查,如果是榆山街道的工作人员,需要调用【更新用户积分(双实信息更新 网格巡查)】/api/points/behavior/updateUserPoints + UpdateUserPointsFormDTO updateUserPointsFormDTO=new UpdateUserPointsFormDTO(); + updateUserPointsFormDTO.setCustomerId(e.getCustomerId()); + updateUserPointsFormDTO.setStaffId(e.getStaffId()); + updateUserPointsFormDTO.setBehaviorType(BehaviorTypeYuShanEnum.GRID_PATROL.getCode()); + yuShanSysApiService.updateUserPoints(e.getCustomerId(),Arrays.asList(updateUserPointsFormDTO)); + }); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java index fca7a68aed..c5f75b2222 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java @@ -32,6 +32,7 @@ import com.epmet.entity.StaffRoleEntity; import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.service.StaffRoleService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.ListUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -136,7 +137,9 @@ public class StaffRoleServiceImpl extends BaseServiceImpl(); } - List result = baseDao.staffGridRole(forms); + List userIds = forms.stream().map(m -> m.getStaffId()).distinct().collect(Collectors.toList()); + List result = baseDao.staffGridRoleByIds(userIds); + /*List result = baseDao.staffGridRole(forms);*/ if (CollectionUtils.isEmpty(result)){ return new ArrayList<>(); } diff --git a/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml b/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml index ac5d97de01..cce9a52831 100644 --- a/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml +++ b/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml @@ -79,6 +79,11 @@ spring: namespace: @nacos.config.namespace@ group: @nacos.config.group@ file-extension: yaml + servlet: + multipart: + max-file-size: 100MB + max-request-size: 100MB + management: endpoints: web: diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/ImportTaskDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/ImportTaskDao.xml new file mode 100644 index 0000000000..edc56fa5c7 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/ImportTaskDao.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + update import_task + set PROCESS_STATUS = #{process_status}, + RESULT_DESC = #{resultDesc}, + RESULT_DESC_FILE = #{resultDescFile}, + UPDATED_BY=#{operatorId}, + UPDATED_TIME=NOW() + where ID=#{taskId} + and PROCESS_STATUS = 'processing' + + \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/PatrolRoutineWorkDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/PatrolRoutineWorkDao.xml index 78cf718131..5d155dbe82 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/PatrolRoutineWorkDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/PatrolRoutineWorkDao.xml @@ -86,5 +86,47 @@ SELECT WORK_TYPE_CODE AS workTypeCode FROM patrol_routine_work_type WHERE DEL_FLAG = 0 AND ROUTINE_WORK_ID = #{wid} + + + + diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml index 777ef27ee8..6ce9736f4d 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml @@ -210,6 +210,23 @@ + + + + \ No newline at end of file