diff --git a/epmet-cloud-generator/src/main/java/io/renren/GeneratorApplication.java b/epmet-cloud-generator/src/main/java/io/renren/GeneratorApplication.java
index caad8b0869..14d4210afa 100644
--- a/epmet-cloud-generator/src/main/java/io/renren/GeneratorApplication.java
+++ b/epmet-cloud-generator/src/main/java/io/renren/GeneratorApplication.java
@@ -2,7 +2,6 @@ package io.renren;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-
@SpringBootApplication
public class GeneratorApplication {
diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/form/StaffPatrolStatsFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/form/StaffPatrolStatsFormDTO.java
index 252162a682..a3386e6e37 100644
--- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/form/StaffPatrolStatsFormDTO.java
+++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/form/StaffPatrolStatsFormDTO.java
@@ -18,5 +18,8 @@ public class StaffPatrolStatsFormDTO implements Serializable {
private String dateId;
private String staffId;
private String gridId;
- private String roleType;
+ /**
+ * 角色key
+ */
+ private String roleKey;
}
diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/CustomerGridStaffDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/CustomerGridStaffDTO.java
new file mode 100644
index 0000000000..defbb16696
--- /dev/null
+++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/CustomerGridStaffDTO.java
@@ -0,0 +1,61 @@
+/**
+ * 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.dto.user.result;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+
+/**
+ * 政府工作人员表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-04-18
+ */
+@Data
+public class CustomerGridStaffDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 客户id
+ */
+ private String customerId;
+
+ /**
+ * 网格id
+ */
+ private String gridId;
+
+ /**
+ * 网格所属组织id
+ */
+ private String agencyId;
+
+ /**
+ * 网格所属的所有组织id
+ */
+ private String gridPids;
+
+ /**
+ * 关联User表的主键Id
+ */
+ private String userId;
+
+}
diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/StaffPatrolRecordResult.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/StaffPatrolRecordResult.java
new file mode 100644
index 0000000000..7239e34792
--- /dev/null
+++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/StaffPatrolRecordResult.java
@@ -0,0 +1,122 @@
+/**
+ * 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.dto.user.result;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+
+/**
+ * 工作人员巡查主记录
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2021-06-07
+ */
+@Data
+public class StaffPatrolRecordResult implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键
+ */
+ private String id;
+
+ /**
+ * 客户Id
+ */
+ private String customerId;
+
+ /**
+ * 网格id
+ */
+ private String grid;
+
+ /**
+ * 网格所有上级id
+ */
+ private String gridPids;
+
+ /**
+ * 工作人员用户id
+ */
+ private String staffId;
+
+ /**
+ * 工作人员所属组织id=网格所属的组织id
+ */
+ private String agencyId;
+
+ /**
+ * 巡查开始时间
+ */
+ private Date patrolStartTime;
+
+ /**
+ * 巡查结束时间,前端传入
+ */
+ private Date patrolEndTime;
+
+ /**
+ * 实际结束时间=操作结束巡查的时间
+ */
+ private Date actrualEndTime;
+
+ /**
+ * 本次巡查总耗时,单位秒;结束巡查时写入
+ */
+ private Integer totalTime;
+
+ /**
+ * 正在巡查中:patrolling;结束:end
+ */
+ private String status;
+
+ /**
+ * 删除标识 0.未删除 1.已删除
+ */
+ private Integer delFlag;
+
+ /**
+ * 乐观锁
+ */
+ private Integer revision;
+
+ /**
+ * 创建人
+ */
+ private String createdBy;
+
+ /**
+ * 创建时间
+ */
+ private Date createdTime;
+
+ /**
+ * 更新人
+ */
+ private String updatedBy;
+
+ /**
+ * 更新时间
+ */
+ private Date updatedTime;
+
+}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/BizDataStatsController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/BizDataStatsController.java
index 94e30fb994..5910f13386 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/BizDataStatsController.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/BizDataStatsController.java
@@ -29,7 +29,7 @@ public class BizDataStatsController {
**/
@RequestMapping("patrol")
public Result execute(@RequestBody StaffPatrolStatsFormDTO formDTO) {
- bizDataStatsService.initStaffPatrolStats(formDTO);
+ bizDataStatsService.executeStaffPatrolStats(formDTO);
return new Result();
}
}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerStaffGridDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerStaffGridDao.java
index 171f45db3c..20e3c6310a 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerStaffGridDao.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerStaffGridDao.java
@@ -19,7 +19,7 @@ package com.epmet.dao.org;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.extract.form.StaffPatrolStatsFormDTO;
-import com.epmet.dto.user.result.StatsStaffPatrolRecordDailyDTO;
+import com.epmet.dto.user.result.CustomerGridStaffDTO;
import com.epmet.entity.org.CustomerStaffGridEntity;
import org.apache.ibatis.annotations.Mapper;
@@ -34,5 +34,5 @@ import java.util.List;
@Mapper
public interface CustomerStaffGridDao extends BaseDao {
- List selectGridStaffList(StaffPatrolStatsFormDTO formDTO);
+ List selectGridStaffList(StaffPatrolStatsFormDTO formDTO);
}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/project/ProjectDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/project/ProjectDao.java
index 44e47f6f92..c4047cb0b3 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/project/ProjectDao.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/project/ProjectDao.java
@@ -18,16 +18,12 @@
package com.epmet.dao.project;
import com.epmet.commons.mybatis.dao.BaseDao;
-import com.epmet.dto.CustomerProjectParameterDTO;
import com.epmet.dto.ProjectDTO;
-import com.epmet.dto.ProjectSatisfactionStatisticsDTO;
import com.epmet.dto.project.ProjectAgencyDTO;
import com.epmet.dto.project.ProjectCategoryDTO;
import com.epmet.dto.project.ProjectGridDTO;
import com.epmet.dto.project.ProjectPointDTO;
import com.epmet.dto.project.result.ProjectExceedParamsResultDTO;
-import com.epmet.dto.screen.ScreenProjectProcessAttachmentDTO;
-import com.epmet.entity.evaluationindex.extract.FactOriginProjectMainDailyEntity;
import com.epmet.entity.project.ProjectEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -52,110 +48,119 @@ public interface ProjectDao extends BaseDao {
/**
* 已结案项目统计
- * @author zhaoqifeng
- * @date 2020/6/18 17:01
+ *
* @param customerId
* @param date
* @return java.util.List
+ * @author zhaoqifeng
+ * @date 2020/6/18 17:01
*/
List selectAgencyClosedProjectTotal(@Param("customerId") String customerId, @Param("date") String date);
/**
* 已结案项目增量
- * @author zhaoqifeng
- * @date 2020/6/18 17:01
+ *
* @param customerId
* @param date
* @return java.util.List
+ * @author zhaoqifeng
+ * @date 2020/6/18 17:01
*/
List selectAgencyClosedProjectInc(@Param("customerId") String customerId, @Param("date") String date);
/**
* 已结案项目统计
- * @author zhaoqifeng
- * @date 2020/6/18 17:01
+ *
* @param customerId
* @param date
* @return java.util.List
+ * @author zhaoqifeng
+ * @date 2020/6/18 17:01
*/
List selectGridClosedProjectTotal(@Param("customerId") String customerId, @Param("date") String date);
/**
* 已结案项目增量
- * @author zhaoqifeng
- * @date 2020/6/18 17:01
+ *
* @param customerId
* @param date
* @return java.util.List
+ * @author zhaoqifeng
+ * @date 2020/6/18 17:01
*/
List selectGridClosedProjectInc(@Param("customerId") String customerId, @Param("date") String date);
/**
* 获取项目信息
- * @author zhaoqifeng
- * @date 2020/9/15 16:13
+ *
* @param customerId
* @param date
* @return java.util.List
+ * @author zhaoqifeng
+ * @date 2020/9/15 16:13
*/
List selectProjectInfo(@Param("customerId") String customerId, @Param("date") String date);
/**
* 获取用户可滞留天数
- * @author zhaoqifeng
- * @date 2020/9/28 10:16
+ *
* @param customerId
* @return java.lang.String
+ * @author zhaoqifeng
+ * @date 2020/9/28 10:16
*/
String selectParameterValueByKey(@Param("customerId") String customerId);
/**
- * @Description 查找客户项目超期参数
- *
* @param customerId
* @return java.util.List
+ * @Description 查找客户项目超期参数
* @author wangc
* @date 2021.03.05 17:52
- */
+ */
List selectProjectExceedParams(@Param("customerId") String customerId);
/**
- * @Description 批量查询项目信息
* @param ids
* @return java.util.List
+ * @Description 批量查询项目信息
* @author wangc
* @date 2021.03.08 10:32
- */
- List batchSelectProjectInfo(@Param("ids")List ids);
+ */
+ List batchSelectProjectInfo(@Param("ids") List ids);
/**
- * @Description 查询项目的分类信息
* @param list
* @return java.util.List
+ * @Description 查询项目的分类信息
* @author wangc
* @date 2021.03.08 23:44
- */
- List selectProjectCategory(@Param("list")List list);
+ */
+ List selectProjectCategory(@Param("list") List list);
List getProjectCategoryData(@Param("customerId") String customerId, @Param("dateId") String dateId);
/**
* 获取项目满意度
- * @author zhaoqifeng
- * @date 2021/5/21 10:06
+ *
* @param customerId
* @return java.util.List
+ * @author zhaoqifeng
+ * @date 2021/5/21 10:06
*/
List selectProjectSatisfaction(@Param("customerId") String customerId);
/**
* 根据key查找value
- * @author zhaoqifeng
- * @date 2021/5/21 10:58
+ *
* @param customerId
* @param parameterKey
* @return java.lang.String
+ * @author zhaoqifeng
+ * @date 2021/5/21 10:58
*/
String selectValueByKey(@Param("customerId") String customerId, @Param("parameterKey") String parameterKey);
+
+ List selectProjectListByDateId(@Param("customerId") String customerId, @Param("dateId") String dateId, @Param("projectOrigin") String projectOrigin);
}
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 60176314f3..1a25f9cfdf 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
@@ -18,6 +18,7 @@
package com.epmet.dao.user;
import com.epmet.commons.mybatis.dao.BaseDao;
+import com.epmet.dto.extract.form.StaffPatrolStatsFormDTO;
import com.epmet.dto.user.result.StatsStaffPatrolRecordDailyDTO;
import com.epmet.entity.user.StatsStaffPatrolRecordDailyEntity;
import org.apache.ibatis.annotations.Mapper;
@@ -35,4 +36,6 @@ import java.util.List;
public interface StatsStaffPatrolRecordDailyDao extends BaseDao {
Integer insertBatch(@Param("list") List insertList);
+
+ int delete(StaffPatrolStatsFormDTO formDTO);
}
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 608fe55e3f..3c278bc523 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
@@ -6,6 +6,7 @@ import com.epmet.dto.extract.result.UserPartyResultDTO;
import com.epmet.dto.screen.ScreenProjectDataDTO;
import com.epmet.dto.user.result.CommonTotalAndIncCountResultDTO;
import com.epmet.dto.user.result.CustomerStaffDTO;
+import com.epmet.dto.user.result.StaffPatrolRecordResult;
import com.epmet.dto.user.result.StatsStaffPatrolRecordDailyDTO;
import com.epmet.entity.evaluationindex.screen.ScreenPartyUserRankDataEntity;
import org.apache.ibatis.annotations.Mapper;
@@ -174,5 +175,7 @@ public interface UserDao {
List selectUserByRoleKey(StaffPatrolStatsFormDTO formDTO);
List selectLastStaffPatrolList(StaffPatrolStatsFormDTO formDTO);
+
+ List selectStaffPatrolListByDateId(@Param("customerId") String customerId, @Param("dateId") String dateId);
}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/biz/BizDataStatsService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/biz/BizDataStatsService.java
index c644f2393e..8bff5118b7 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/biz/BizDataStatsService.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/biz/BizDataStatsService.java
@@ -27,5 +27,6 @@ import com.epmet.dto.extract.form.StaffPatrolStatsFormDTO;
*/
public interface BizDataStatsService {
- void initStaffPatrolStats(StaffPatrolStatsFormDTO formDTO);
+ void executeStaffPatrolStats(StaffPatrolStatsFormDTO formDTO);
+
}
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 151b376e4e..8ff799cd87 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
@@ -1,15 +1,26 @@
package com.epmet.service.evaluationindex.extract.biz.impl;
+import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.constant.NumConstant;
+import com.epmet.commons.tools.utils.ConvertUtils;
+import com.epmet.commons.tools.utils.DateUtils;
+import com.epmet.constant.ProjectConstant;
+import com.epmet.dto.ProjectDTO;
import com.epmet.dto.extract.form.StaffPatrolStatsFormDTO;
+import com.epmet.dto.user.result.CustomerGridStaffDTO;
import com.epmet.dto.user.result.CustomerStaffDTO;
+import com.epmet.dto.user.result.StaffPatrolRecordResult;
import com.epmet.dto.user.result.StatsStaffPatrolRecordDailyDTO;
+import com.epmet.entity.user.StatsStaffPatrolRecordDailyEntity;
import com.epmet.service.evaluationindex.extract.biz.BizDataStatsService;
import com.epmet.service.org.CustomerStaffService;
+import com.epmet.service.project.ProjectService;
import com.epmet.service.user.StatsStaffPatrolService;
import com.epmet.service.user.UserService;
import com.epmet.util.DimIdGenerator;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
+import org.jetbrains.annotations.Nullable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -34,55 +45,168 @@ public class BizDataStatsServiceImpl implements BizDataStatsService {
@Autowired
private UserService userService;
@Autowired
+ private ProjectService projectService;
+ @Autowired
private StatsStaffPatrolService statsStaffPatrolService;
@Override
- public void initStaffPatrolStats(StaffPatrolStatsFormDTO formDTO) {
- //获取所有的网格员
- //1.获取所有网格用户
- List allStaffList = customerStaffService.selectStaffGridList(formDTO);
- /* if (CollectionUtils.isEmpty(allStaffList)){
- log.warn("reloadStaffPatrolStats customerId:{} have any staff,param:{}",formDTO.getCustomerId(), JSON.toJSONString(formDTO));
- return
- }*/
- //获取所有含有网格员角色的用户
- List gridMemberList = userService.selectUserListByRoleKey(formDTO);
- /*if (CollectionUtils.isEmpty(gridMemberList)){
- log.warn("reloadStaffPatrolStats customerId:{} have any gridMembers,param:{}",formDTO.getCustomerId(), JSON.toJSONString(formDTO));
- return
- }*/
+ public void executeStaffPatrolStats(StaffPatrolStatsFormDTO formDTO) {
+ //校正数据
+ //获取所有网格员
+ List allGridMembers = getAllGridMembers(formDTO);
+ reloadStaffPatrolStatsData(formDTO, allGridMembers);
+
+ //初始化今天的数据
+ initStaffPatrolTodayData(formDTO, allGridMembers);
+
+ }
+
+ private void reloadStaffPatrolStatsData(StaffPatrolStatsFormDTO formDTO, List allGridMembers) {
+ //获取昨日的巡查统计记录
+ String yesterdayStr = getYesterdayString(formDTO);
+ List yesterdayStatsList = statsStaffPatrolService.selectData(formDTO.getCustomerId(), yesterdayStr);
+ if (CollectionUtils.isEmpty(yesterdayStatsList)) {
+ log.warn("reloadStaffPatrolStatsData have any yesterdayStats data,dateId:{}", yesterdayStr);
+ return;
+ }
+ Map yesterdayStatsMap = yesterdayStatsList.stream().collect(Collectors.toMap(o -> o.getGridId() + o.getStaffId(), o -> o, (o1, o2) -> o1));
+ //获取昨日的巡查记录
+ List yesterdayPatrolList = userService.selectStaffPatrolListByDateId(formDTO.getCustomerId(), yesterdayStr);
+
+ //获取昨日的立项项目数
+ List yesterdayProjectList = projectService.selectProjectListByDateId(formDTO.getCustomerId(), yesterdayStr, ProjectConstant.PROJECT_ORIGIN_AGENCY);
+
+ //遍历网格员 设置其 巡查次数 巡查时常 上报项目数
+ Map gridMemberMap = allGridMembers.stream().collect(Collectors.toMap(o -> o.getGridId() + o.getUserId(), o -> o, (o1, o2) -> o1));
+ List updateList = new ArrayList<>();
+ yesterdayPatrolList.forEach(patrolRecord -> {
+ String key = patrolRecord.getGrid().concat(patrolRecord.getStaffId());
+ StatsStaffPatrolRecordDailyDTO patrolRecordDailyDTO = yesterdayStatsMap.get(key);
+ if (patrolRecordDailyDTO != null) {
+ long total = (patrolRecord.getActrualEndTime().getTime() - patrolRecord.getPatrolStartTime().getTime()) / 1000;
+ if (patrolRecordDailyDTO.getTotalTime() == null) {
+ patrolRecordDailyDTO.setTotalTime(NumConstant.ZERO);
+ }
+ patrolRecordDailyDTO.setTotalTime(patrolRecordDailyDTO.getTotalTime() + (int) total);
+ if (patrolRecordDailyDTO.getPatrolTotal() == null) {
+ patrolRecordDailyDTO.setPatrolTotal(NumConstant.ZERO);
+ }
+ patrolRecordDailyDTO.setPatrolTotal(patrolRecordDailyDTO.getPatrolTotal() + NumConstant.ONE);
+ //如果巡查记录时间小于统计里的最新的时间 则更新
+ if (patrolRecordDailyDTO.getLatestPatrolTime() == null || patrolRecordDailyDTO.getLatestPatrolTime().getTime() < patrolRecord.getPatrolStartTime().getTime()) {
+ patrolRecordDailyDTO.setLatestPatrolTime(patrolRecord.getPatrolStartTime());
+ patrolRecordDailyDTO.setLatestPatrolStatus(patrolRecord.getStatus());
+ }
+ }
+ });
+ //填充项目数
+ yesterdayProjectList.forEach(projectDTO -> {
+ String key = projectDTO.getCreatedBy();
+
+ yesterdayPatrolList.forEach(patrol -> {
+ //项目立项时间 在巡查期间时 总数加1
+ long projectCreateTime = projectDTO.getCreatedTime().getTime();
+ if (patrol.getPatrolStartTime().getTime() >= projectCreateTime && patrol.getPatrolStartTime().getTime() >= projectCreateTime) {
+ 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());
+ return;
+ }
+ recordDailyDTO.setReportProjectCount(recordDailyDTO.getReportProjectCount() + 1);
+ }
+ });
+ });
+ StaffPatrolStatsFormDTO yesterdayParam = ConvertUtils.sourceToTarget(formDTO, StaffPatrolStatsFormDTO.class);
+ yesterdayParam.setDateId(yesterdayStr);
+ Integer effectRow = statsStaffPatrolService.delAndInsertBatch(yesterdayParam, yesterdayStatsList);
+ log.debug("initStaffPatrolStats insert rows:{}", effectRow);
+ }
+
+ /**
+ * desc: 获取key
+ *
+ * @param gridId
+ * @param staffId
+ * @return java.lang.String
+ * @author LiuJanJun
+ * @date 2021/7/2 8:32 上午
+ */
+ private String getUnqPatrolKey(String gridId, String staffId) {
+ return gridId.concat(staffId);
+ }
+
+
+ @Nullable
+ private String getYesterdayString(StaffPatrolStatsFormDTO formDTO) {
+ Date dateParam = DateUtils.parse(formDTO.getDateId(), DateUtils.DATE_PATTERN_YYYYMMDD);
+ Date yesterdayDate = DateUtils.addDateDays(dateParam, -1);
+ return DateUtils.format(yesterdayDate, DateUtils.DATE_PATTERN_YYYYMMDD);
+ }
+
+ private void initStaffPatrolTodayData(StaffPatrolStatsFormDTO formDTO, List allGridMembers) {
+
List lastStaffPatrolList = userService.selectLastStaffPatrolList(formDTO);
Map lastPatrolMap = lastStaffPatrolList.stream().collect(Collectors.toMap(o -> o.getGridId() + o.getStaffId(), o -> o, (o1, o2) -> o1));
//构建数据 插入
List insertList = new ArrayList<>();
- DimIdGenerator.DimIdBean dimIdBean = DimIdGenerator.getDimIdBean(new Date());
- allStaffList.forEach(gridStaff -> {
- gridStaff.setDateId(dimIdBean.getDateId());
- gridStaff.setWeekId(dimIdBean.getWeekId());
- gridStaff.setQuarterId(dimIdBean.getQuarterId());
- gridStaff.setYearId(dimIdBean.getYearId());
- gridStaff.setMonthId(dimIdBean.getMonthId());
- StatsStaffPatrolRecordDailyDTO recordDailyDTO = lastPatrolMap.get(gridStaff.getGridId().concat(gridStaff.getStaffId()));
-
- gridStaff.setTotalTime(NumConstant.ZERO);
- gridStaff.setPatrolTotal(NumConstant.ZERO);
- gridStaff.setLatestPatrolStatus("end");
- gridStaff.setReportProjectCount(NumConstant.ZERO);
+ Date date = DateUtils.parse(formDTO.getDateId(), DateUtils.DATE_PATTERN_YYYYMMDD);
+ DimIdGenerator.DimIdBean dimIdBean = DimIdGenerator.getDimIdBean(date);
+ allGridMembers.forEach(gridMember -> {
+ StatsStaffPatrolRecordDailyDTO record = new StatsStaffPatrolRecordDailyDTO();
+ record.setCustomerId(gridMember.getCustomerId());
+ record.setGridId(gridMember.getGridId());
+ record.setAgencyId(gridMember.getAgencyId());
+ record.setGridPids(gridMember.getGridPids());
+ record.setStaffId(gridMember.getUserId());
+ record.setDateId(dimIdBean.getDateId());
+ record.setWeekId(dimIdBean.getWeekId());
+ record.setQuarterId(dimIdBean.getQuarterId());
+ record.setYearId(dimIdBean.getYearId());
+ record.setMonthId(dimIdBean.getMonthId());
+ StatsStaffPatrolRecordDailyDTO recordDailyDTO = lastPatrolMap.get(gridMember.getGridId().concat(gridMember.getUserId()));
+
+ record.setTotalTime(NumConstant.ZERO);
+ record.setPatrolTotal(NumConstant.ZERO);
+ record.setLatestPatrolStatus("end");
+ record.setReportProjectCount(NumConstant.ZERO);
//最后巡查时间
- gridStaff.setLatestPatrolTime(null);
+ record.setLatestPatrolTime(null);
if (recordDailyDTO != null) {
- gridStaff.setLatestPatrolStatus(recordDailyDTO.getLatestPatrolStatus());
- gridStaff.setLatestPatrolTime(recordDailyDTO.getLatestPatrolTime());
+ record.setLatestPatrolStatus(recordDailyDTO.getLatestPatrolStatus());
+ record.setLatestPatrolTime(recordDailyDTO.getLatestPatrolTime());
}
- gridMemberList.forEach(gridMember -> {
- if (gridStaff.getStaffId().equals(gridMember.getUserId())) {
- insertList.add(gridStaff);
- }
- });
+ insertList.add(record);
+
});
- Integer effectRow = statsStaffPatrolService.insertBatch(insertList);
+ Integer effectRow = statsStaffPatrolService.delAndInsertBatch(formDTO, insertList);
log.debug("initStaffPatrolStats insert rows:{}", effectRow);
}
+
+ private List getAllGridMembers(StaffPatrolStatsFormDTO formDTO) {
+ //获取所有的网格员
+ //1.获取所有网格用户
+ List allStaffList = customerStaffService.selectStaffGridList(formDTO);
+ if (CollectionUtils.isEmpty(allStaffList)) {
+ log.warn("reloadStaffPatrolStats customerId:{} have any staff,param:{}", formDTO.getCustomerId(), JSON.toJSONString(formDTO));
+ return allStaffList;
+ }
+ //获取所有含有网格员角色的用户
+ List gridMemberList = userService.selectUserListByRoleKey(formDTO);
+ if (CollectionUtils.isEmpty(gridMemberList)) {
+ log.warn("reloadStaffPatrolStats customerId:{} have any gridMembers,param:{}", formDTO.getCustomerId(), JSON.toJSONString(formDTO));
+ return allStaffList;
+ }
+ List insertList = new ArrayList<>();
+
+ allStaffList.forEach(gridStaff -> gridMemberList.forEach(gridMember -> {
+ if (gridStaff.getUserId().equals(gridMember.getUserId())) {
+ insertList.add(gridStaff);
+ }
+ }));
+ log.debug("getAllGridMembers result:{},param:{}", JSON.toJSONString(insertList), JSON.toJSONString(formDTO));
+ return insertList;
+ }
}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerStaffService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerStaffService.java
index f498bbfe9c..6f03097838 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerStaffService.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerStaffService.java
@@ -1,7 +1,7 @@
package com.epmet.service.org;
import com.epmet.dto.extract.form.StaffPatrolStatsFormDTO;
-import com.epmet.dto.user.result.StatsStaffPatrolRecordDailyDTO;
+import com.epmet.dto.user.result.CustomerGridStaffDTO;
import java.util.List;
@@ -18,5 +18,5 @@ public interface CustomerStaffService {
* @author LiuJanJun
* @date 2021/6/29 3:13 下午
*/
- List selectStaffGridList(StaffPatrolStatsFormDTO formDTO);
+ List selectStaffGridList(StaffPatrolStatsFormDTO formDTO);
}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerStaffServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerStaffServiceImpl.java
index fc11765d10..fba61dd8bf 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerStaffServiceImpl.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerStaffServiceImpl.java
@@ -4,7 +4,7 @@ import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.constant.DataSourceConstant;
import com.epmet.dao.org.CustomerStaffGridDao;
import com.epmet.dto.extract.form.StaffPatrolStatsFormDTO;
-import com.epmet.dto.user.result.StatsStaffPatrolRecordDailyDTO;
+import com.epmet.dto.user.result.CustomerGridStaffDTO;
import com.epmet.service.org.CustomerStaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -33,7 +33,7 @@ public class CustomerStaffServiceImpl implements CustomerStaffService {
* @date 2021/6/29 3:13 下午
*/
@Override
- public List selectStaffGridList(StaffPatrolStatsFormDTO formDTO) {
+ public List selectStaffGridList(StaffPatrolStatsFormDTO formDTO) {
return customerStaffGridDao.selectGridStaffList(formDTO);
}
}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/ProjectService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/ProjectService.java
index 36c3ebd05b..db9a4add14 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/ProjectService.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/ProjectService.java
@@ -162,4 +162,5 @@ public interface ProjectService extends BaseService {
*/
List getProjectSatisfaction(String customerId);
+ List selectProjectListByDateId(String customerId, String yesterdayStr, String projectOriginAgency);
}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/impl/ProjectServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/impl/ProjectServiceImpl.java
index 3581f920b1..f7aa9d8754 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/impl/ProjectServiceImpl.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/impl/ProjectServiceImpl.java
@@ -196,5 +196,10 @@ public class ProjectServiceImpl extends BaseServiceImpl selectProjectListByDateId(String customerId, String dateId, String projectOrigin) {
+ return baseDao.selectProjectListByDateId(customerId,dateId,projectOrigin);
+ }
+
}
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 430a46defd..1f1f9cefff 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
@@ -1,5 +1,6 @@
package com.epmet.service.user;
+import com.epmet.dto.extract.form.StaffPatrolStatsFormDTO;
import com.epmet.dto.user.result.StatsStaffPatrolRecordDailyDTO;
import java.util.List;
@@ -9,5 +10,7 @@ import java.util.List;
*/
public interface StatsStaffPatrolService {
- Integer insertBatch(List insertList);
+ Integer delAndInsertBatch(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/UserService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java
index aecbe35158..55e3b5f4fb 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
@@ -7,6 +7,7 @@ import com.epmet.dto.org.result.OrgStaffDTO;
import com.epmet.dto.screen.ScreenProjectDataDTO;
import com.epmet.dto.stats.user.result.UserStatisticalData;
import com.epmet.dto.user.result.CustomerStaffDTO;
+import com.epmet.dto.user.result.StaffPatrolRecordResult;
import com.epmet.dto.user.result.StatsStaffPatrolRecordDailyDTO;
import com.epmet.entity.evaluationindex.screen.ScreenPartyUserRankDataEntity;
import com.epmet.util.DimIdGenerator;
@@ -109,4 +110,6 @@ public interface UserService {
List selectUserListByRoleKey(StaffPatrolStatsFormDTO formDTO);
List selectLastStaffPatrolList(StaffPatrolStatsFormDTO formDTO);
+
+ List selectStaffPatrolListByDateId(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 0a08ff7908..ca6e9b5988 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,11 +1,17 @@
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;
import com.epmet.constant.DataSourceConstant;
import com.epmet.dao.user.StatsStaffPatrolRecordDailyDao;
+import com.epmet.dto.extract.form.StaffPatrolStatsFormDTO;
import com.epmet.dto.user.result.StatsStaffPatrolRecordDailyDTO;
+import com.epmet.entity.user.StatsStaffPatrolRecordDailyEntity;
import com.epmet.service.user.StatsStaffPatrolService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -18,6 +24,7 @@ import java.util.List;
* @date: 2021/6/30 8:33 上午
* @version: 1.0
*/
+@Slf4j
@DataSource(DataSourceConstant.EPMET_USER)
@Service
public class StatsStaffPatrolServiceImpl implements StatsStaffPatrolService {
@@ -25,7 +32,28 @@ public class StatsStaffPatrolServiceImpl implements StatsStaffPatrolService {
private StatsStaffPatrolRecordDailyDao statsStaffPatrolRecordDailyDao;
@Override
- public Integer insertBatch(List insertList) {
+ public Integer delAndInsertBatch(StaffPatrolStatsFormDTO formDTO, List insertList) {
+ LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>();
+ queryWrapper.eq(StatsStaffPatrolRecordDailyEntity::getCustomerId, formDTO.getCustomerId())
+ .eq(StatsStaffPatrolRecordDailyEntity::getDateId, formDTO.getDateId());
+ if (StringUtils.isNotBlank(formDTO.getGridId())) {
+ queryWrapper.eq(StatsStaffPatrolRecordDailyEntity::getGridId, formDTO.getGridId());
+ }
+ if (StringUtils.isNotBlank(formDTO.getStaffId())) {
+ queryWrapper.eq(StatsStaffPatrolRecordDailyEntity::getStaffId, formDTO.getStaffId());
+ }
+
+ int delete = statsStaffPatrolRecordDailyDao.delete(formDTO);
+ log.debug("delAndInsertBatch delete:{},param:{}", delete, JSON.toJSONString(formDTO));
return statsStaffPatrolRecordDailyDao.insertBatch(insertList);
}
+
+ @Override
+ public List selectData(String customerId, String yesterdayStr) {
+ LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>();
+ queryWrapper.eq(StatsStaffPatrolRecordDailyEntity::getCustomerId, customerId)
+ .eq(StatsStaffPatrolRecordDailyEntity::getDateId, yesterdayStr);
+ List list = statsStaffPatrolRecordDailyDao.selectList(queryWrapper);
+ return ConvertUtils.sourceToTarget(list, StatsStaffPatrolRecordDailyDTO.class);
+ }
}
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 27ee9b6eb8..725c11d8f4 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
@@ -18,6 +18,7 @@ import com.epmet.dto.stats.user.*;
import com.epmet.dto.stats.user.result.UserStatisticalData;
import com.epmet.dto.user.result.CommonTotalAndIncCountResultDTO;
import com.epmet.dto.user.result.CustomerStaffDTO;
+import com.epmet.dto.user.result.StaffPatrolRecordResult;
import com.epmet.dto.user.result.StatsStaffPatrolRecordDailyDTO;
import com.epmet.entity.evaluationindex.screen.ScreenPartyUserRankDataEntity;
import com.epmet.service.user.UserService;
@@ -803,7 +804,7 @@ public class UserServiceImpl implements UserService {
@Override
public List selectUserListByRoleKey(StaffPatrolStatsFormDTO formDTO) {
- formDTO.setRoleType(RoleKeyConstants.ROLE_KEY_GRID_MEMBER);
+ formDTO.setRoleKey(RoleKeyConstants.ROLE_KEY_GRID_MEMBER);
return userDao.selectUserByRoleKey(formDTO);
}
@@ -812,4 +813,9 @@ public class UserServiceImpl implements UserService {
return userDao.selectLastStaffPatrolList(formDTO);
}
+ @Override
+ public List selectStaffPatrolListByDateId(String customerId, String yesterdayStr) {
+ return userDao.selectStaffPatrolListByDateId(customerId,yesterdayStr);
+ }
+
}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerStaffGridDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerStaffGridDao.xml
index 5e41b9e84d..75b9aa5b40 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerStaffGridDao.xml
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerStaffGridDao.xml
@@ -5,25 +5,27 @@
+
+
+ SELECT * FROM (
+ SELECT
+ sg.customer_id,
+ sg.grid_id,
+ sg.user_id,
+ grid.PID agencyId,
+ grid.PIDS gridPids
+ FROM
+ customer_staff_grid sg
+ LEFT JOIN customer_grid grid ON grid.id = sg.grid_id
+ WHERE
+ sg.del_flag = '0'
-
- SELECT
- sg.customer_id,
- sg.user_id AS staffId,
- sg.grid_id,
- grid.grid_name,
- grid.PID agencyId,
- grid.PIDS gridPids
- FROM
- customer_staff_grid sg
- LEFT JOIN customer_grid grid ON grid.id = sg.grid_id
- WHERE
- sg.del_flag = '0'
-
- AND sg.customer_id = #{customerId}
-
-
- AND sg.GRID_ID = #{gridId}
-
+
+ AND sg.customer_id = #{customerId}
+
+
+ AND sg.GRID_ID = #{gridId}
+
+ ) t WHERE t.agencyId IS NOT NULL
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/project/ProjectDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/project/ProjectDao.xml
index 3c5ebd884f..18ba4d2a0f 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/project/ProjectDao.xml
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/project/ProjectDao.xml
@@ -162,4 +162,11 @@
and CUSTOMER_ID = #{customerId}
and PARAMETER_KEY = #{parameterKey}
+
+ SELECT * FROM project
+ WHERE customer_id = #{customerId}
+ AND ORIGIN = #{projectOrigin}
+ AND del_flag = '0'
+ AND DATE_FORMAT( CREATED_TIME, '%Y%m%d' ) = #{dateId}
+
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 cba48614f3..d3ea3d3f9a 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
@@ -55,4 +55,15 @@
)
+
+ DELETE FROM stats_staff_patrol_record_daily
+ WHERE CUSTOMER_ID = #{customerId}
+ AND DATE_ID = #{dateId}
+
+ AND GRID_ID = #{gridId}
+
+
+ AND STAFF_ID = #{staffId}
+
+
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 3babf9e21e..c21c5c9c40 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
@@ -582,7 +582,7 @@
LEFT JOIN gov_staff_role gsr ON gsr.ID = sr.ROLE_ID
WHERE
s.del_flag = '0'
- AND gsr.ROLE_KEY = 'grid_member'
+ AND gsr.ROLE_KEY = #{roleKey}
SELECT
@@ -600,4 +600,13 @@
AND a.CUSTOMER_ID = #{customerId}
+
+ SELECT
+ r.*
+ FROM
+ staff_patrol_record r
+ WHERE
+ r.del_flag = '0' and r.customer_id = #{customerId}
+ AND DATE_FORMAT( r.ACTRUAL_END_TIME, '%Y%m%d' ) = #{dateId}
+