From ad9592dd863d7ef854d9e2023db194345606d406 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Wed, 7 Jul 2021 15:41:30 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=91=E6=A0=BC=E5=91=98=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=B8=8A=E6=8A=A5=E6=8E=A5=E5=8F=A3=E5=87=BA=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/stats/form/GmUploadDataFormDTO.java | 7 +- .../dto/stats/form/GmUploadEventFormDTO.java | 10 +- .../epmet/controller/StatsUserController.java | 4 +- .../screen/ScreenCustomerAgencyDao.java | 8 ++ .../com/epmet/dao/stats/DataStatsDao.java | 45 +++++++ .../main/java/com/epmet/dao/user/UserDao.java | 13 +++ .../com/epmet/service/StatsUserService.java | 2 +- .../screen/ScreenCustomerAgencyService.java | 7 ++ .../impl/ScreenCustomerAgencyServiceImpl.java | 9 ++ .../service/impl/StatsUserServiceImpl.java | 110 ++++++++++++++++-- .../com/epmet/service/user/UserService.java | 13 +++ .../service/user/impl/UserServiceImpl.java | 19 +++ .../screen/ScreenCustomerAgencyDao.xml | 18 +++ .../resources/mapper/stats/DatsStatsDao.xml | 101 ++++++++++++++++ .../main/resources/mapper/user/UserDao.xml | 71 +++++++++++ 15 files changed, 417 insertions(+), 20 deletions(-) create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DataStatsDao.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DatsStatsDao.xml diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/form/GmUploadDataFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/form/GmUploadDataFormDTO.java index 7f6671dd83..34d9366054 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/form/GmUploadDataFormDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/form/GmUploadDataFormDTO.java @@ -3,6 +3,7 @@ package com.epmet.dto.stats.form; import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; import lombok.Data; +import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotEmpty; import java.io.Serializable; import java.math.BigDecimal; @@ -21,13 +22,15 @@ public class GmUploadDataFormDTO implements Serializable { */ private Boolean isFirst; //客户Id + @NotBlank(message = "客户Id不能为空", groups = {UploadData.class}) private String customerId; //日维度Id + @NotBlank(message = "dateId不能为空", groups = {UploadData.class}) private String dateId; //数据集合对象 - @NotEmpty(message = "数据集合对象不能为空",groups = AgencyProjectForm.class) + @NotEmpty(message = "数据集合对象不能为空",groups = UploadData.class) private List dataList; - public interface AgencyProjectForm extends CustomerClientShowGroup {} + public interface UploadData extends CustomerClientShowGroup {} @Data public static class DataList{ diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/form/GmUploadEventFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/form/GmUploadEventFormDTO.java index 56eb2c059c..13d689fc6a 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/form/GmUploadEventFormDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/form/GmUploadEventFormDTO.java @@ -3,9 +3,9 @@ package com.epmet.dto.stats.form; import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; import lombok.Data; +import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotEmpty; import java.io.Serializable; -import java.math.BigDecimal; import java.util.Date; import java.util.List; @@ -19,13 +19,15 @@ public class GmUploadEventFormDTO implements Serializable { //为true时需要删除历史数据 private Boolean isFirst; //客户Id + @NotBlank(message = "客户Id不能为空", groups = {UploadEvent.class}) private String customerId; //日维度Id + @NotBlank(message = "dateId不能为空", groups = {UploadEvent.class}) private String dateId; //数据集合对象 - @NotEmpty(message = "数据集合对象不能为空",groups = AgencyProjectForm.class) + @NotEmpty(message = "数据集合对象不能为空",groups = UploadEvent.class) private List dataList; - public interface AgencyProjectForm extends CustomerClientShowGroup {} + public interface UploadEvent extends CustomerClientShowGroup {} @Data public static class DataList{ @@ -56,7 +58,7 @@ public class GmUploadEventFormDTO implements Serializable { //事件数【立项项目数】 private Integer reportProjectCount = 0; //最新的巡查开始时间 - private String latestPatrolTime; + private Date latestPatrolTime; //最新的巡查状态 正在巡查中:patrolling;结束:end private String latestPatrolStatus = "end"; diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsUserController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsUserController.java index c46c98f64c..c42929f386 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsUserController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsUserController.java @@ -44,17 +44,19 @@ public class StatsUserController { */ @PostMapping("gm-uploadevent") public Result gmUploadEvent(@RequestBody GmUploadEventFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, GmUploadEventFormDTO.UploadEvent.class); statsUserService.gmUploadEvent(formDTO); return new Result(); } /** * @Param formDTO - * @Description 数据上报--网格员事件总数上报 + * @Description 数据上报--网格员数据分析上报 * @author sun */ @PostMapping("gm-uploaddata") public Result gmUploadData(@RequestBody GmUploadDataFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, GmUploadDataFormDTO.UploadData.class); statsUserService.gmUploadData(formDTO); return new Result(); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java index ebe3ff3783..e6155e982e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java @@ -18,6 +18,7 @@ package com.epmet.dao.evaluationindex.screen; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.extract.form.PartyBaseInfoFormDTO; import com.epmet.dto.extract.form.ScreenPartyBranchDataFormDTO; import com.epmet.dto.extract.form.ScreenPartyLinkMassesDataFormDTO; @@ -236,4 +237,11 @@ public interface ScreenCustomerAgencyDao extends BaseDao selectByPid(@Param("customerId") String customerId, @Param("parentAgencyId")String parentAgencyId); List selectKcCommunity(String customerId); + + /** + * @Description 查询客户index库组织信息供数据封装使用 + * @author sun + */ + List selectByCustomerId(@Param("customerId") String customerId); + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DataStatsDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DataStatsDao.java new file mode 100644 index 0000000000..8572bf2616 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DataStatsDao.java @@ -0,0 +1,45 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao.stats; + +import com.epmet.dto.stats.form.GmUploadDataFormDTO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @Author sun + * @Description 数据统计服务 + */ +@Mapper +public interface DataStatsDao { + + /** + * @Description 数据上报--网格员数据分析上报--按客户Id和dateId删除历史数据 + * @author sun + */ + int delGmUploadData(String customerId, String dateId); + + /** + * @Description 数据上报--网格员数据分析上报--批量新增或修改数据 + * @author sun + */ + int saveOrUpGmUploadData(@Param("list") List list); + +} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java index dabacfd7da..88f3483641 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java @@ -3,6 +3,7 @@ package com.epmet.dao.user; import com.epmet.dto.extract.form.GridHeartedFormDTO; import com.epmet.dto.extract.result.UserPartyResultDTO; import com.epmet.dto.screen.ScreenProjectDataDTO; +import com.epmet.dto.stats.form.GmUploadEventFormDTO; import com.epmet.dto.user.result.CommonTotalAndIncCountResultDTO; import com.epmet.entity.evaluationindex.screen.ScreenPartyUserRankDataEntity; import org.apache.ibatis.annotations.Mapper; @@ -159,5 +160,17 @@ public interface UserDao { * @date 2021/6/8 5:21 下午 */ List selectStaffInfo(@Param("list") List staffUserIdList); + + /** + * @Description 数据上报--网格员事件总数上报--按客户Id和dateId删除历史数据 + * @author sun + */ + int delGmUploadEvent(@Param("customerId") String customerId, @Param("dateId") String dateId); + + /** + * @Description 数据上报--网格员事件总数上报--批量新增或修改数据 + * @author sun + */ + int saveOrUpGmUploadEvent(@Param("list") List list); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsUserService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsUserService.java index 0e71cbd62f..f09cf007a0 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsUserService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsUserService.java @@ -29,7 +29,7 @@ public interface StatsUserService { /** * @Param formDTO - * @Description 数据上报--网格员事件总数上报 + * @Description 数据上报--网格员数据分析上报 * @author sun */ void gmUploadData(GmUploadDataFormDTO formDTO); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java index 5c303466aa..5ded177ae0 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java @@ -17,6 +17,7 @@ package com.epmet.service.evaluationindex.screen; +import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.extract.form.PartyBaseInfoFormDTO; import com.epmet.dto.extract.form.ScreenPartyBranchDataFormDTO; import com.epmet.dto.extract.form.ScreenPartyLinkMassesDataFormDTO; @@ -131,4 +132,10 @@ public interface ScreenCustomerAgencyService{ */ List selectKcCommunity(String customerId); + /** + * @Description 查询客户index库组织信息供数据封装使用 + * @author sun + */ + List getByCustomerId(String customerId); + } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java index 17b22866c6..16ba642e62 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java @@ -25,6 +25,7 @@ import com.epmet.constant.OrgSourceTypeConstant; import com.epmet.constant.ScreenConstant; import com.epmet.dao.evaluationindex.screen.ScreenCustomerAgencyDao; import com.epmet.dao.evaluationindex.screen.ScreenCustomerGridDao; +import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.extract.form.PartyBaseInfoFormDTO; import com.epmet.dto.extract.form.ScreenPartyBranchDataFormDTO; import com.epmet.dto.extract.form.ScreenPartyLinkMassesDataFormDTO; @@ -294,5 +295,13 @@ public class ScreenCustomerAgencyServiceImpl implements ScreenCustomerAgencyServ return screenCustomerAgencyDao.selectKcCommunity(customerId); } + /** + * @Description 查询客户index库组织信息供数据封装使用 + * @author sun + */ + @Override + public List getByCustomerId(String customerId) { + return screenCustomerAgencyDao.selectByCustomerId(customerId); + } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsUserServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsUserServiceImpl.java index e9155fcaad..ee68d5dbe7 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsUserServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsUserServiceImpl.java @@ -5,18 +5,22 @@ import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.constant.ProjectConstant; +import com.epmet.dao.stats.DataStatsDao; import com.epmet.dto.AgencySubTreeDto; +import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.StatsFormDTO; import com.epmet.dto.stats.form.GmUploadDataFormDTO; import com.epmet.dto.stats.form.GmUploadEventFormDTO; import com.epmet.dto.stats.user.result.UserStatisticalData; import com.epmet.service.StatsUserService; +import com.epmet.service.evaluationindex.screen.ScreenCustomerAgencyService; import com.epmet.service.stats.DimAgencyService; import com.epmet.service.stats.DimCustomerService; import com.epmet.service.stats.user.UserStatisticalService; import com.epmet.service.user.UserService; import com.epmet.util.DimIdGenerator; import com.epmet.util.ModuleConstant; +import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -27,6 +31,7 @@ import org.springframework.util.CollectionUtils; import java.util.Calendar; import java.util.Date; import java.util.List; +import java.util.concurrent.atomic.AtomicReference; /** @@ -51,6 +56,11 @@ public class StatsUserServiceImpl implements StatsUserService { @Autowired private UserStatisticalService userStatisticalService; + @Autowired + private ScreenCustomerAgencyService screenCustomerAgencyService; + @Autowired + private DataStatsDao dataStatsDao; + /** * @param formDTO 如果目标日期为空,则自动计算为T-1天 @@ -61,9 +71,9 @@ public class StatsUserServiceImpl implements StatsUserService { **/ @Override public void partition(StatsFormDTO formDTO) { - if(StringUtils.isBlank(formDTO.getDate())){ + if (StringUtils.isBlank(formDTO.getDate())) { //如果定时任务没有指定参数,默认数据更新至t-1,包含t-1这一天内的数据 - formDTO.setDate(DateUtils.getBeforeNDay(1,DateUtils.DATE_PATTERN)); + formDTO.setDate(DateUtils.getBeforeNDay(1, DateUtils.DATE_PATTERN)); } int pageNo = NumConstant.ONE; @@ -93,15 +103,15 @@ public class StatsUserServiceImpl implements StatsUserService { } /** - * @Description 生成用户统计数据 * @param customerId 客户Id - * @param date 目标日期 + * @param date 目标日期 * @return + * @Description 生成用户统计数据 * @author wangc * @date 2020.06.28 14:40 - **/ - void generate(String customerId,Date date){ - log.info("customerId:"+customerId+";date:"+DateUtils.format(date,DateUtils.DATE_TIME_PATTERN)); + **/ + void generate(String customerId, Date date) { + log.info("customerId:" + customerId + ";date:" + DateUtils.format(date, DateUtils.DATE_TIME_PATTERN)); //1.初始化时间参数 Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); @@ -113,14 +123,14 @@ public class StatsUserServiceImpl implements StatsUserService { //2.初始化时间维度{"dateId":"20210325","monthId":"202103","quarterId":"2021Q1","weekId":"2021W13","yearId":"2021"} DimIdGenerator.DimIdBean timeDimension = DimIdGenerator.getDimIdBean(null == date ? calendar.getTime() : date); - log.info("timeDimension:"+ JSON.toJSONString(timeDimension)); + log.info("timeDimension:" + JSON.toJSONString(timeDimension)); //3.初始化机关维度 - List agencies = dimAgencyService.getAllAgency(customerId); + List agencies = dimAgencyService.getAllAgency(customerId); //4.计算机关统计数据、生成唯一性统计数据 try { UserStatisticalData agencyData = userService.traverseAgencyUser(agencies, date, timeDimension); userStatisticalService.insertUniquely(agencyData); - }catch(Exception e){ + } catch (Exception e) { log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, ModuleConstant.EXCEPTION_DING_INTERCEPTOR_PREFIX_AGENCY_USER_STATISTICAL, customerId, new Date().toString(), e.getMessage())); } @@ -128,7 +138,7 @@ public class StatsUserServiceImpl implements StatsUserService { try { UserStatisticalData gridData = userService.traverseGridUser(agencies, date, timeDimension); userStatisticalService.insertUniquely(gridData); - }catch(Exception e){ + } catch (Exception e) { log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, ModuleConstant.EXCEPTION_DING_INTERCEPTOR_PREFIX_GRID_USER_STATISTICAL, customerId, new Date().toString(), e.getMessage())); } } @@ -140,16 +150,92 @@ public class StatsUserServiceImpl implements StatsUserService { */ @Override public void gmUploadEvent(GmUploadEventFormDTO formDTO) { + //1.判断是否批量删除历史数据 + if (formDTO.getIsFirst()) { + int deleteNum; + do { + deleteNum = userService.delGmUploadEvent(formDTO.getCustomerId(), formDTO.getDateId()); + } while (deleteNum > NumConstant.ZERO); + } + + //2.查询当前客户index库组织信息供数据封装使用 + List agencyList = screenCustomerAgencyService.getByCustomerId(formDTO.getCustomerId()); + + //3.分批处理上传数据 + List> partition = ListUtils.partition(formDTO.getDataList(), NumConstant.ONE_HUNDRED); + partition.forEach(p -> { + //4.封装数据并执行 + p.forEach(m -> { + AtomicReference bl = new AtomicReference<>(false); + StringBuffer gridPids = new StringBuffer(""); + agencyList.forEach(ag -> { + if (m.getAgencyId().equals(ag.getId())) { + bl.set(true); + gridPids.append((StringUtils.isEmpty(ag.getPids()) || "0".equals(ag.getPids()) ? ag.getId() : ag.getPids().replaceAll(",", ":") + ":" + ag.getId())); + } + }); + if (bl.get()) { + m.setGridPids(gridPids.toString()); + m.setPatrolTotal(NumConstant.ZERO); + m.setTotalTime(NumConstant.ZERO); + m.setLatestPatrolStatus("end"); + } else { + log.warn(String.format("网格员事件总数上报,数据错误,根据agencyId未查询到组织信息,客户Id->%s,组织Id->%s", m.getCustomerId(), m.getAgencyId())); + } + }); + //批量新增或修改数据 + if (!CollectionUtils.isEmpty(p)) { + userService.saveOrUpGmUploadEvent(p); + } + }); } /** * @Param formDTO - * @Description 数据上报--网格员事件总数上报 + * @Description 数据上报--网格员数据分析上报 * @author sun */ @Override public void gmUploadData(GmUploadDataFormDTO formDTO) { + //1.判断是否批量删除历史数据 + if (formDTO.getIsFirst()) { + int deleteNum; + do { + deleteNum = dataStatsDao.delGmUploadData(formDTO.getCustomerId(), formDTO.getDateId()); + } while (deleteNum > NumConstant.ZERO); + } + + //2.查询当前客户index库组织信息供数据封装使用 + List agencyList = screenCustomerAgencyService.getByCustomerId(formDTO.getCustomerId()); + + //3.分批处理上传数据 + List> partition = ListUtils.partition(formDTO.getDataList(), NumConstant.ONE_HUNDRED); + partition.forEach(p -> { + //4.封装数据并执行 + p.forEach(m -> { + AtomicReference bl = new AtomicReference<>(false); + StringBuffer pid = new StringBuffer(""); + StringBuffer pids = new StringBuffer(""); + agencyList.forEach(ag -> { + if (m.getAgencyId().equals(ag.getId())) { + bl.set(true); + pid.append(ag.getPid()); + pids.append((StringUtils.isEmpty(ag.getPids()) || "0".equals(ag.getPids()) ? ag.getId() : ag.getPids().replaceAll(",", ":") + ":" + ag.getId())); + } + }); + if (bl.get()) { + m.setPid(pid.toString()); + m.setPids(pids.toString()); + } else { + log.warn(String.format("网格员数据分析上报,数据错误,根据agencyId未查询到组织信息,客户Id->%s,组织Id->%s", m.getCustomerId(), m.getAgencyId())); + } + }); + //批量新增或修改数据 + if (!CollectionUtils.isEmpty(p)) { + dataStatsDao.saveOrUpGmUploadData(p); + } + }); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java index ebc01ebdb3..f69bcb5165 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java @@ -4,6 +4,7 @@ import com.epmet.dto.AgencySubTreeDto; import com.epmet.dto.extract.form.GridHeartedFormDTO; import com.epmet.dto.org.result.OrgStaffDTO; import com.epmet.dto.screen.ScreenProjectDataDTO; +import com.epmet.dto.stats.form.GmUploadEventFormDTO; import com.epmet.dto.stats.user.result.UserStatisticalData; import com.epmet.entity.evaluationindex.screen.ScreenPartyUserRankDataEntity; import com.epmet.util.DimIdGenerator; @@ -94,4 +95,16 @@ public interface UserService { * @return com.epmet.dto.user.OrgGridManagerTotalDTO */ Map queryOrgGridManager(String customerId,List orgStaffDTOList); + + /** + * @Description 数据上报--网格员事件总数上报--按客户Id和dateId删除历史数据 + * @author sun + */ + int delGmUploadEvent(String customerId, String dateId); + + /** + * @Description 数据上报--网格员事件总数上报--批量新增或修改数据 + * @author sun + */ + void saveOrUpGmUploadEvent(List list); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java index 59897628e3..46a3bb2258 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java @@ -12,6 +12,7 @@ import com.epmet.dto.extract.form.GridHeartedFormDTO; import com.epmet.dto.extract.result.UserPartyResultDTO; import com.epmet.dto.org.result.OrgStaffDTO; import com.epmet.dto.screen.ScreenProjectDataDTO; +import com.epmet.dto.stats.form.GmUploadEventFormDTO; import com.epmet.dto.stats.user.*; import com.epmet.dto.stats.user.result.UserStatisticalData; import com.epmet.dto.user.result.CommonTotalAndIncCountResultDTO; @@ -797,4 +798,22 @@ public class UserServiceImpl implements UserService { return resultMap; } + /** + * @Description 数据上报--网格员事件总数上报--按客户Id和dateId删除历史数据 + * @author sun + */ + @Override + public int delGmUploadEvent(String customerId, String dateId) { + return userDao.delGmUploadEvent(customerId, dateId); + } + + /** + * @Description 数据上报--网格员事件总数上报--批量新增或修改数据 + * @author sun + */ + @Override + public void saveOrUpGmUploadEvent(List list) { + userDao.saveOrUpGmUploadEvent(list); + } + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml index 4640aeebe6..e313a60faf 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml @@ -485,4 +485,22 @@ AND CUSTOMER_ID = #{customerId} and level='community' + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DatsStatsDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DatsStatsDao.xml new file mode 100644 index 0000000000..65ea939f02 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DatsStatsDao.xml @@ -0,0 +1,101 @@ + + + + + + + DELETE + FROM + fact_grid_member_statistics_daily + WHERE + customer_id = #{customerId} + AND date_id = #{dateId} + LIMIT 1000 + + + + INSERT INTO fact_grid_member_statistics_daily + ( + id, + date_id, + month_id, + year_id, + customer_id, + agency_id, + grid_id, + pid, + pids, + staff_id, + staff_name, + project_count, + issue_to_project_count, + closed_issue_count, + project_response_count, + project_transfer_count, + project_closed_count, + project_incr, + issue_to_project_incr, + closed_issue_incr, + project_response_incr, + project_transfer_incr, + project_closed_incr, + del_flag, + revision, + created_by, + created_time, + updated_by, + updated_time + ) + VALUES + + ( + REPLACE(UUID(), '-', ''), + #{i.dateId}, + #{i.monthId}, + #{i.yearId}, + #{i.customerId}, + #{i.agencyId}, + #{i.gridId}, + #{i.pid}, + #{i.pids}, + #{i.staffId}, + #{i.staffName}, + #{i.projectCount}, + #{i.issueToProjectCount}, + #{i.closedIssueCount}, + #{i.projectResponseCount}, + #{i.projectTransferCount}, + #{i.projectClosedCount}, + #{i.projectIncr}, + #{i.issueToProjectIncr}, + #{i.closedIssueIncr}, + #{i.projectResponseIncr}, + #{i.projectTransferIncr}, + #{i.projectClosedIncr}, + 0, + 0, + 'BASE_REPORT', + NOW(), + 'BASE_REPORT', + NOW() + ) + + ON DUPLICATE KEY + UPDATE + project_count = values(project_count), + issue_to_project_count = values(issue_to_project_count), + closed_issue_count = values(closed_issue_count), + project_response_count = values(project_response_count), + project_transfer_count = values(project_transfer_count), + project_closed_count = values(project_closed_count), + project_incr = values(project_incr), + issue_to_project_incr = values(issue_to_project_incr), + closed_issue_incr = values(closed_issue_incr), + project_response_incr = values(project_response_incr), + project_transfer_incr = values(project_transfer_incr), + project_closed_incr = values(project_closed_incr), + updated_by = 'BASE_REPORT', + updated_time = NOW() + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml index acb6c9feb3..c235e69647 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml @@ -570,4 +570,75 @@ user_id = #{userId} + + + DELETE + FROM + stats_staff_patrol_record_daily + WHERE + customer_id = #{customerId} + AND date_id = #{dateId} + LIMIT 1000 + + + + INSERT INTO stats_staff_patrol_record_daily + ( + id, + customer_id, + date_id, + week_id, + month_id, + quarter_id, + year_id, + grid_id, + agency_id, + grid_pids, + staff_id, + patrol_total, + total_time, + report_project_count, + latest_patrol_time, + latest_patrol_status, + del_flag, + revision, + created_by, + created_time, + updated_by, + updated_time + ) + VALUES + + ( + REPLACE(UUID(), '-', ''), + #{i.customerId}, + #{i.dateId}, + #{i.weekId}, + #{i.monthId}, + #{i.quarterId}, + #{i.yearId}, + #{i.gridId}, + #{i.agencyId}, + #{i.gridPids}, + #{i.staffId}, + #{i.patrolTotal}, + #{i.totalTime}, + #{i.reportProjectCount}, + #{i.latestPatrolTime}, + #{i.latestPatrolStatus}, + 0, + 0, + 'BASE_REPORT', + NOW(), + 'BASE_REPORT', + NOW() + ) + + ON DUPLICATE KEY + UPDATE + report_project_count = values(report_project_count), + updated_by = 'BASE_REPORT', + updated_time = NOW() + +