From b04805b471232baa52b1263f6404abd729a1e56d Mon Sep 17 00:00:00 2001 From: zhangyuan Date: Tue, 31 May 2022 10:08:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FactUserHouseController.java | 24 ++++++++++++ .../com/epmet/excel/FactUserHouseExcel.java | 37 ++----------------- .../FactAgencyUserHouseDailyService.java | 11 ++++++ .../stats/FactGridUserHouseDailyService.java | 10 +++++ .../FactAgencyUserHouseDailyServiceImpl.java | 6 +++ .../FactGridUserHouseDailyServiceImpl.java | 6 +++ .../stats/impl/FactUserHouseServiceImpl.java | 10 ++++- 7 files changed, 68 insertions(+), 36 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactUserHouseController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactUserHouseController.java index 2723d62725..c1cce92e9d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactUserHouseController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactUserHouseController.java @@ -34,6 +34,14 @@ public class FactUserHouseController { return new Result>().ok(page); } + /** + * 合计 + * + * @param params + * @return com.epmet.commons.tools.utils.Result + * @author zhy + * @date 2022/5/31 9:48 + */ @RequestMapping("total") public Result total(@RequestParam Map params) { FactUserHouseResultDTO dto = factUserHouseService.total(params); @@ -46,12 +54,28 @@ public class FactUserHouseController { ExcelUtils.exportExcelToTarget(response, null, list, FactUserHouseExcel.class); } + /** + * 统计网格纬度 + * + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @author zhy + * @date 2022/5/31 9:48 + */ @PostMapping("userHouseStatGrid") public Result userHouseStatGrid(@RequestBody FactUserHouseFormDTO formDTO) { factUserHouseService.statGrid(formDTO); return new Result(); } + /** + * 统计组织纬度 + * + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @author zhy + * @date 2022/5/31 9:48 + */ @PostMapping("userHouseStatAgency") public Result userHouseStatAgency(@RequestBody FactUserHouseFormDTO formDTO) { factUserHouseService.statAgency(formDTO); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/excel/FactUserHouseExcel.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/excel/FactUserHouseExcel.java index c5de0d2dd9..96c5860cfb 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/excel/FactUserHouseExcel.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/excel/FactUserHouseExcel.java @@ -14,23 +14,11 @@ import java.util.Date; @Data public class FactUserHouseExcel { - @Excel(name = "主键,customer_id+AGENCY_ID+date_id只有一条记录") - private String id; - - @Excel(name = "客户id") - private String customerId; - - @Excel(name = "数据更新至:yyyyMMdd; ") + @Excel(name = "日期") private String dateId; - @Excel(name = "组织id") - private String agencyId; - - @Excel(name = "组织i所属的组织id") - private String pid; - - @Excel(name = "组织i所有上级id") - private String pids; + @Excel(name = "组织名称") + private String agencyName; @Excel(name = "小区总数") private Integer neighbourhoodsCount; @@ -68,23 +56,4 @@ public class FactUserHouseExcel { @Excel(name = "当日修改居民数") private Integer userModify; - @Excel(name = "删除标识 0未删除、1已删除") - private String delFlag; - - @Excel(name = "乐观锁") - private Integer revision; - - @Excel(name = "创建人") - private String createdBy; - - @Excel(name = "创建时间:第一次提交审核的时间,注意和历史表的第一条记录时间一致") - private Date createdTime; - - @Excel(name = "更新人") - private String updatedBy; - - @Excel(name = "更新时间") - private Date updatedTime; - - } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactAgencyUserHouseDailyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactAgencyUserHouseDailyService.java index 8328cba509..9a31152d55 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactAgencyUserHouseDailyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactAgencyUserHouseDailyService.java @@ -3,6 +3,7 @@ package com.epmet.service.stats; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.stats.FactAgencyUserHouseDailyDTO; +import com.epmet.dto.stats.FactGridUserHouseDailyDTO; import com.epmet.dto.stats.form.FactUserHouseFormDTO; import com.epmet.dto.stats.result.FactUserHouseResultDTO; import com.epmet.entity.stats.FactAgencyUserHouseDailyEntity; @@ -48,6 +49,16 @@ public interface FactAgencyUserHouseDailyService extends BaseService list(Map params); + /** + * 查询导出数据 + * + * @param params + * @return java.util.List + * @author generator + * @date 2022-05-27 + */ + List listExport(Map params); + /** * 单条查询 * diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGridUserHouseDailyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGridUserHouseDailyService.java index fa5a3ec2bb..36dd9046a5 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGridUserHouseDailyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGridUserHouseDailyService.java @@ -48,6 +48,16 @@ public interface FactGridUserHouseDailyService extends BaseService list(Map params); + /** + * 查询导出数据 + * + * @param params + * @return java.util.List + * @author generator + * @date 2022-05-27 + */ + List listExport(Map params); + /** * 单条查询 * diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactAgencyUserHouseDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactAgencyUserHouseDailyServiceImpl.java index 2f9a3bd605..8fbf82b671 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactAgencyUserHouseDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactAgencyUserHouseDailyServiceImpl.java @@ -48,6 +48,7 @@ public class FactAgencyUserHouseDailyServiceImpl extends BaseServiceImpl list = baseDao.getTotal(params); + // 只有当日数据直接展示,否则需要统计时间段内两天差值进行Incr和Modify数据计算 if (list.size() == NumConstant.ZERO) { return null; } else if (list.size() == NumConstant.ONE) { @@ -71,6 +72,11 @@ public class FactAgencyUserHouseDailyServiceImpl extends BaseServiceImpl listExport(Map params) { + return baseDao.listPage(params); + } + private QueryWrapper getWrapper(Map params) { String id = (String) params.get(FieldConstant.ID_HUMP); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGridUserHouseDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGridUserHouseDailyServiceImpl.java index d81f892096..0aaa1f0c2e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGridUserHouseDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGridUserHouseDailyServiceImpl.java @@ -48,6 +48,7 @@ public class FactGridUserHouseDailyServiceImpl extends BaseServiceImpl list = baseDao.getTotal(params); + // 只有当日数据直接展示,否则需要统计时间段内两天差值进行Incr和Modify数据计算 if (list.size() == NumConstant.ZERO) { return null; } else if (list.size() == NumConstant.ONE) { @@ -71,6 +72,11 @@ public class FactGridUserHouseDailyServiceImpl extends BaseServiceImpl listExport(Map params) { + return baseDao.listPage(params); + } + private QueryWrapper getWrapper(Map params) { String id = (String) params.get(FieldConstant.ID_HUMP); String dateId = (String) params.get("dateId"); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactUserHouseServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactUserHouseServiceImpl.java index dfe659b250..4d8a39348d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactUserHouseServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactUserHouseServiceImpl.java @@ -71,6 +71,7 @@ public class FactUserHouseServiceImpl implements FactUserHouseService { @Override public FactUserHouseResultDTO total(Map params) { FactUserHouseResultDTO dto = null; + // 不查询时间段默认查询当天 if (params.containsKey("startTime") && params.containsKey("endTime")) { if (StringUtils.isNotBlank(params.get("startTime").toString()) && StringUtils.isNotBlank(params.get("endTime").toString())) { params.put("dateId", StringUtils.EMPTY); @@ -80,6 +81,7 @@ public class FactUserHouseServiceImpl implements FactUserHouseService { } else { params.put("dateId", DateUtils.getBeforeNDay(NumConstant.ONE)); } + // 网格纬度查询网格统计表,其余纬度查询组织统计表 if (params.containsKey("level")) { if (OrgLevelEnum.GRID.getCode().equals(params.get("level").toString())) { dto = factGridUserHouseDailyService.getTotal(params); @@ -95,9 +97,9 @@ public class FactUserHouseServiceImpl implements FactUserHouseService { List list = new ArrayList<>(); if (params.containsKey("level")) { if (OrgLevelEnum.GRID.getCode().equals(params.get("level").toString()) || OrgLevelEnum.COMMUNITY.getCode().equals(params.get("level").toString())) { - list = ConvertUtils.sourceToTarget(factGridUserHouseDailyService.list(params), FactUserHouseResultDTO.class); + list = factGridUserHouseDailyService.listExport(params); } else { - list = ConvertUtils.sourceToTarget(factAgencyUserHouseDailyService.list(params), FactUserHouseResultDTO.class); + list = factAgencyUserHouseDailyService.listExport(params); } } return list; @@ -111,8 +113,10 @@ public class FactUserHouseServiceImpl implements FactUserHouseService { String dateId = formDTO.getDateId(); String customerId = formDTO.getCustomerId(); + // 先删除历史 factGridUserHouseDailyService.deleteByDateId(formDTO); + // 保证小区是全部网格后,其余数据进行循环匹配 List neiList = houseService.neighborhoodStat(formDTO); List houseList = houseService.houseStat(formDTO); List userList = icResiUserService.userStat(formDTO); @@ -173,8 +177,10 @@ public class FactUserHouseServiceImpl implements FactUserHouseService { return; } + // 先删除历史 factAgencyUserHouseDailyService.deleteByDateId(formDTO); + // 使用机构表左关联,对不同纬度的机构进行分组统计 formDTO.setLevel("community"); List commList = factGridUserHouseDailyService.statAgency(formDTO); if (!commList.isEmpty()) {