Browse Source

事件赋值得分

master
zhaoqifeng 3 years ago
parent
commit
5a4e0d94cb
  1. 1
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/constant/DataSourceConstant.java
  2. 69
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/EventCategoryResultDTO.java
  3. 47
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/form/EventCategoryFormDTO.java
  4. 18
      epmet-module/data-aggregator/data-aggregator-server/pom.xml
  5. 45
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/PingYinEventController.java
  6. 70
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/evaluationindex/PingYinEventDao.java
  7. 24
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/PingYinEventService.java
  8. 98
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/PingYinEventServiceImpl.java
  9. 5
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/bootstrap.yml
  10. 139
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/PingYinEventDao.xml
  11. 4
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/basereport/form/EventInfoFormDTO.java
  12. 179
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/EventreportPingyinDTO.java
  13. 87
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/GridstaffWorkInfoPingyinDTO.java
  14. 30
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/SavePyEventDataFormDTO.java
  15. 4
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java
  16. 6
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java
  17. 19
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DataReportingController.java
  18. 16
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenPyEventDataDao.java
  19. 64
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenPyEventDataEntity.java
  20. 24
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenPyEventDataService.java
  21. 76
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenPyEventDataServiceImpl.java
  22. 7
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenPyEventDataDao.xml
  23. 13
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/EventreportPingyinController.java
  24. 34
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/GridstaffWorkInfoPingyinController.java
  25. 9
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/EventreportPingyinService.java
  26. 10
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/GridstaffWorkInfoPingyinService.java
  27. 38
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/EventreportPingyinServiceImpl.java
  28. 74
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/GridstaffWorkInfoPingyinServiceImpl.java

1
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/constant/DataSourceConstant.java

@ -30,6 +30,7 @@ public interface DataSourceConstant {
String DATA_STATISTICAL="datastatistical";
String EVALUATION_INDEX = "evaluationIndex";
String EVALUATION_INDEX_READ = "evaluationIndexRead";
String OPERCUSTOMIZE="opercustomize";

69
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/EventCategoryResultDTO.java

@ -0,0 +1,69 @@
package com.epmet.dataaggre.dto.evaluationindex;
import com.epmet.commons.tools.constant.NumConstant;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* @Author zxc
* @DateTime 2021/11/4 3:13 下午
* @DESC
*/
@Data
public class EventCategoryResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 类型project事件 work例行工作
*/
private String eventType;
/**
* 分类CODE
*/
private String categoryCode;
/**
* 分类code父级
*/
private String parentCategoryCode;
/**
* 分类名字
*/
private String categoryName;
/**
* 分类名字父级
*/
private String parentCategoryName;
/**
* 项目数
*/
private Integer eventTotal;
/**
* 分值
*/
private Integer score;
private Integer totalScore;
private List<EventCategoryResultDTO> children;
@JsonIgnore
private Integer index;
public EventCategoryResultDTO() {
this.categoryCode = "";
this.categoryName = "";
this.eventTotal = NumConstant.ZERO;
this.totalScore = NumConstant.ZERO;
this.children = new ArrayList<>();
}
}

47
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/form/EventCategoryFormDTO.java

@ -0,0 +1,47 @@
package com.epmet.dataaggre.dto.evaluationindex.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @author Administrator
*/
@Data
public class EventCategoryFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
public interface EventCategoryForm{}
public interface CategoryEventExportForm {}
/**
* 组织ID
*/
private String customerId;
/**
* 组织ID
*/
private String orgId;
/**
* 组织类型 组织agency网格grid
*/
private String orgType;
@NotBlank(message = "结束时间不能为空",groups = {EventCategoryForm.class,CategoryEventExportForm.class})
private String endTime;
/**
* 开始时间
*/
private String startTime;
/**
* 组织名称
*/
@NotBlank(message = "组织名称不能为空",groups = CategoryEventExportForm.class)
private String orgName;
}

18
epmet-module/data-aggregator/data-aggregator-server/pom.xml

@ -384,6 +384,12 @@
<datasource.druid.evaluationIndex.username>epmet_evaluation_index_user</datasource.druid.evaluationIndex.username>
<datasource.druid.evaluationIndex.password>EpmEt-db-UsEr</datasource.druid.evaluationIndex.password>
<datasource.druid.evaluationIndex1.url>
<![CDATA[jdbc:mysql://192.168.1.140:3306/epmet_evaluation_index?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</datasource.druid.evaluationIndex1.url>
<datasource.druid.evaluationIndex1.username>root</datasource.druid.evaluationIndex1.username>
<datasource.druid.evaluationIndex1.password>root</datasource.druid.evaluationIndex1.password>
<datasource.druid.opercustomize.url>
<![CDATA[jdbc:mysql://192.168.1.140:3306/epmet_oper_customize?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</datasource.druid.opercustomize.url>
@ -522,6 +528,12 @@
<datasource.druid.evaluationIndex.username>epmet</datasource.druid.evaluationIndex.username>
<datasource.druid.evaluationIndex.password>elink@833066</datasource.druid.evaluationIndex.password>
<datasource.druid.evaluationIndex1.url>
<![CDATA[jdbc:mysql://rm-m5ef9t617j6o5eup7.mysql.rds.aliyuncs.com:3306/epmet_evaluation_index?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</datasource.druid.evaluationIndex1.url>
<datasource.druid.evaluationIndex1.username>epmet</datasource.druid.evaluationIndex1.username>
<datasource.druid.evaluationIndex1.password>elink@833066</datasource.druid.evaluationIndex1.password>
<datasource.druid.opercustomize.url>
<![CDATA[jdbc:mysql://rm-m5ef9t617j6o5eup7.mysql.rds.aliyuncs.com:3306/epmet_oper_customize?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</datasource.druid.opercustomize.url>
@ -661,6 +673,12 @@
<datasource.druid.evaluationIndex.username>epmet_evaluation_index_user</datasource.druid.evaluationIndex.username>
<datasource.druid.evaluationIndex.password>EpmEt-db-UsEr</datasource.druid.evaluationIndex.password>
<datasource.druid.evaluationIndex1.url>
<![CDATA[jdbc:mysql://rm-m5e3vzs2637224wj9.mysql.rds.aliyuncs.com:3306/epmet_evaluation_index?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</datasource.druid.evaluationIndex1.url>
<datasource.druid.evaluationIndex1.username>epmet_cloud_viewer</datasource.druid.evaluationIndex1.username>
<datasource.druid.evaluationIndex1.password>EpmEtclOUdvIEwEr@w</datasource.druid.evaluationIndex1.password>
<datasource.druid.opercustomize.url>
<![CDATA[jdbc:mysql://rm-m5e3vzs2637224wj9.mysql.rds.aliyuncs.com:3306/epmet_oper_customize?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</datasource.druid.opercustomize.url>

45
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/PingYinEventController.java

@ -0,0 +1,45 @@
package com.epmet.dataaggre.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.dataaggre.dto.evaluationindex.EventCategoryResultDTO;
import com.epmet.dataaggre.dto.evaluationindex.form.EventCategoryFormDTO;
import com.epmet.dataaggre.service.evaluationindex.PingYinEventService;
import lombok.extern.slf4j.Slf4j;
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 javax.annotation.Resource;
import java.util.List;
/**
* @author Administrator
*/
@RestController
@RequestMapping("pyevent")
@Slf4j
public class PingYinEventController {
@Resource
private PingYinEventService pingYinEventService;
/**
* 事件赋值得分
*
* @Param tokenDto
* @Return {@link Result<List<EventCategoryResultDTO>>}
* @Author zhaoqifeng
* @Date 2022/12/9 9:42
*/
@PostMapping("getEventCategorySore")
public Result<List<EventCategoryResultDTO>> getEventCategorySore(@LoginUser TokenDto tokenDto, @RequestBody EventCategoryFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, EventCategoryFormDTO.EventCategoryForm.class);
return new Result<List<EventCategoryResultDTO>>().ok(pingYinEventService.getEventCategorySore(tokenDto, formDTO));
}
}

70
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/evaluationindex/PingYinEventDao.java

@ -0,0 +1,70 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dataaggre.dao.evaluationindex;
import com.epmet.dataaggre.dto.evaluationindex.EventCategoryResultDTO;
import com.epmet.dataaggre.dto.evaluationindex.form.EventCategoryFormDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @Author sun
* @Description 指标统计服务
*/
@Mapper
public interface PingYinEventDao {
/**
* 获取项目分类
*
* @Param customerId
* @Return {@link List< EventCategoryResultDTO>}
* @Author zhaoqifeng
* @Date 2022/12/9 13:40
*/
List<EventCategoryResultDTO> selectProjectCategory(@Param("customerId")String customerId);
/**
* 获取例行工作分类
*
* @Param
* @Return {@link List< EventCategoryResultDTO>}
* @Author zhaoqifeng
* @Date 2022/12/9 13:41
*/
List<EventCategoryResultDTO> selectWorkCategory();
/**
* 项目赋值得分
* @Param formDTO
* @Return {@link List< EventCategoryResultDTO>}
* @Author zhaoqifeng
* @Date 2022/12/9 11:00
*/
List<EventCategoryResultDTO> selectProjectCategoryScoreList(EventCategoryFormDTO formDTO);
/**
* 例行工作赋值得分
* @Param formDTO
* @Return {@link List< EventCategoryResultDTO>}
* @Author zhaoqifeng
* @Date 2022/12/9 11:00
*/
List<EventCategoryResultDTO> selectWorkCategoryScoreList(EventCategoryFormDTO formDTO);
}

24
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/PingYinEventService.java

@ -0,0 +1,24 @@
package com.epmet.dataaggre.service.evaluationindex;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.dataaggre.dto.evaluationindex.EventCategoryResultDTO;
import com.epmet.dataaggre.dto.evaluationindex.form.EventCategoryFormDTO;
import java.util.List;
/**
* @author Administrator
*/
public interface PingYinEventService {
/**
* 事件赋值得分
*
* @Param tokenDto
* @Param formDTO
* @Return {@link List<EventCategoryResultDTO>}
* @Author zhaoqifeng
* @Date 2022/12/9 9:55
*/
List<EventCategoryResultDTO> getEventCategorySore (TokenDto tokenDto, EventCategoryFormDTO formDTO);
}

98
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/PingYinEventServiceImpl.java

@ -0,0 +1,98 @@
package com.epmet.dataaggre.service.evaluationindex.impl;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.dataaggre.constant.DataSourceConstant;
import com.epmet.dataaggre.dao.evaluationindex.PingYinEventDao;
import com.epmet.dataaggre.dto.evaluationindex.EventCategoryResultDTO;
import com.epmet.dataaggre.dto.evaluationindex.form.EventCategoryFormDTO;
import com.epmet.dataaggre.service.evaluationindex.PingYinEventService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
* @Author sun
* @Description 指标统计服务
*/
@Service
@DataSource(DataSourceConstant.EVALUATION_INDEX_READ)
@Slf4j
public class PingYinEventServiceImpl implements PingYinEventService {
@Resource
private PingYinEventDao pingYinEventDao;
/**
* 事件赋值得分
*
* @param tokenDto
* @param formDTO
* @Param tokenDto
* @Param formDTO
* @Return {@link List < EventCategoryResultDTO >}
* @Author zhaoqifeng
* @Date 2022/12/9 9:55
*/
@Override
public List<EventCategoryResultDTO> getEventCategorySore(TokenDto tokenDto, EventCategoryFormDTO formDTO) {
List<EventCategoryResultDTO> result = new ArrayList<>();
if (StringUtils.isNotBlank(formDTO.getStartTime())){
formDTO.setStartTime(DateUtils.getBeforeNDay(formDTO.getStartTime(), NumConstant.ONE));
}
if (StringUtils.isBlank(formDTO.getOrgId())){
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId());
if (null == staffInfo){
throw new EpmetException("未查询到此工作人员的所属组织信息...");
}
formDTO.setOrgId(staffInfo.getAgencyId());
formDTO.setOrgType("agency");
}
formDTO.setCustomerId(tokenDto.getCustomerId());
//获取项目分类
List<EventCategoryResultDTO> projectCategoryList = pingYinEventDao.selectProjectCategory(formDTO.getCustomerId());
//获取项目赋值得分统计
List<EventCategoryResultDTO> projectScoreList = pingYinEventDao.selectProjectCategoryScoreList(formDTO);
if (CollectionUtils.isNotEmpty(projectScoreList)) {
projectCategoryList.forEach(item -> {
projectScoreList.stream().filter(e -> item.getCategoryCode().equals(e.getParentCategoryCode())).forEach(e -> {
item.setEventTotal(item.getEventTotal() + e.getEventTotal());
item.setTotalScore(item.getTotalScore() + e.getTotalScore());
});
item.getChildren().forEach(son -> projectScoreList.stream().filter(e -> son.getCategoryCode().equals(e.getCategoryCode())).forEach(e -> {
son.setEventTotal(e.getEventTotal());
son.setTotalScore(e.getTotalScore());
}));
});
}
result.addAll(projectCategoryList);
//获取例行工作分类
List<EventCategoryResultDTO> workCategoryList = pingYinEventDao.selectWorkCategory();
//获取例行工作赋值得分统计
List<EventCategoryResultDTO> workScoreList = pingYinEventDao.selectWorkCategoryScoreList(formDTO);
if (CollectionUtils.isNotEmpty(workScoreList)) {
workCategoryList.forEach(item -> {
workScoreList.stream().filter(e -> item.getCategoryCode().equals(e.getParentCategoryCode())).forEach(e -> {
item.setEventTotal(item.getEventTotal() + e.getEventTotal());
item.setTotalScore(item.getTotalScore() + e.getTotalScore());
});
item.getChildren().forEach(son -> workScoreList.stream().filter(e -> son.getCategoryCode().equals(e.getCategoryCode())).forEach(e -> {
son.setEventTotal(e.getEventTotal());
son.setTotalScore(e.getTotalScore());
}));
});
}
result.addAll(workCategoryList);
return result;
}
}

5
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/bootstrap.yml

@ -166,6 +166,11 @@ dynamic:
url: @datasource.druid.partymember.url@
username: @datasource.druid.partymember.username@
password: @datasource.druid.partymember.password@
evaluationIndexRead:
driver-class-name: com.mysql.cj.jdbc.Driver
url: @datasource.druid.evaluationIndex1.url@
username: @datasource.druid.evaluationIndex1.username@
password: @datasource.druid.evaluationIndex1.password@
feign:
hystrix:
enabled: true

139
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/PingYinEventDao.xml

@ -0,0 +1,139 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dataaggre.dao.evaluationindex.PingYinEventDao">
<!-- 查询客户下所有分类 -->
<resultMap id="selectCategoryByCustomerIdMap" type="com.epmet.dataaggre.dto.evaluationindex.EventCategoryResultDTO">
<result column="e" property="eventType"/>
<result column="c" property="categoryCode"/>
<result column="n" property="categoryName"/>
<result column="pc1" property="parentCategoryCode"/>
<result column="score1" property="score"/>
<collection property="children" ofType="com.epmet.dataaggre.dto.evaluationindex.EventCategoryResultDTO">
<result column="e" property="eventType"/>
<result column="c2" property="categoryCode"/>
<result column="n2" property="categoryName"/>
<result column="pc2" property="parentCategoryCode"/>
<result column="score2" property="score"/>
<result column="n" property="parentCategoryName"/>
</collection>
</resultMap>
<select id="selectProjectCategory" resultMap="selectCategoryByCustomerIdMap">
SELECT
'事件' AS e,
'事件' AS e2,
p1.CATEGORY_CODE AS c,
p2.CATEGORY_CODE AS c2,
p1.CATEGORY_NAME AS n,
p2.CATEGORY_NAME AS n2,
p1.PARENT_CATEGORY_CODE AS pc1,
p2.PARENT_CATEGORY_CODE AS pc2,
p1.SCORE AS score1,
p2.SCORE AS score2
FROM customer_project_category_dict p1,customer_project_category_dict p2
WHERE p1.DEL_FLAG = '0'
AND p2.DEL_FLAG = '0'
AND p1.CUSTOMER_ID = #{customerId}
AND p2.CUSTOMER_ID = #{customerId}
AND p1.CATEGORY_CODE = p2.PARENT_CATEGORY_CODE
AND p1.CUSTOMER_TYPE = 'internal'
AND p2.CUSTOMER_TYPE = 'internal'
AND p1.IS_DISABLE = 'enable'
AND p2.IS_DISABLE = 'enable'
ORDER BY p1.SORT, p2.SORT
</select>
<select id="selectWorkCategory" resultMap="selectCategoryByCustomerIdMap">
SELECT
'例行工作' AS e,
'例行工作' AS e2,
p1.CATEGORY_CODE AS c,
p2.CATEGORY_CODE AS c2,
p1.CATEGORY_NAME AS n,
p2.CATEGORY_NAME AS n2,
p1.PARENT_CATEGORY_CODE AS pc1,
p2.PARENT_CATEGORY_CODE AS pc2,
p1.SCORE AS score1,
p2.SCORE AS score2
FROM customer_patrol_work_type_dict p1,customer_patrol_work_type_dict p2
WHERE p1.DEL_FLAG = '0'
AND p2.DEL_FLAG = '0'
AND p1.CATEGORY_CODE = p2.PARENT_CATEGORY_CODE
AND p1.IS_DISABLE = 'enable'
AND p2.IS_DISABLE = 'enable'
ORDER BY p1.SORT, p2.SORT
</select>
<select id="selectProjectCategoryScoreList" resultType="com.epmet.dataaggre.dto.evaluationindex.EventCategoryResultDTO">
SELECT
*
FROM
(SELECT
a.CATEGORY_CODE,
c.PARENT_CATEGORY_CODE,
COUNT( a.EVENT_ID ) AS eventTotal,
c.SCORE,
SUM( c.SCORE ) AS totalScore
FROM
screen_py_event_data a
INNER JOIN screen_project_data b ON a.EVENT_ID = b.PROJECT_ID
AND b.DEL_FLAG = '0'
INNER JOIN customer_project_category_dict c ON a.CATEGORY_CODE = c.CATEGORY_CODE
AND c.DEL_FLAG = '0'
AND c.CUSTOMER_ID = #{customerId}
AND c.IS_DISABLE = 'enable'
WHERE
a.DEL_FLAG = '0'
AND a.EVENT_TYPE = 'project'
<if test="startTime != null and startTime != ''">
AND DATE_FORMAT( a.EVENT_CREATE_TIME, '%Y-%m-%d' ) &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND DATE_FORMAT( a.EVENT_CREATE_TIME, '%Y-%m-%d' ) &lt;= #{endTime}
</if>
<if test="orgType == 'grid'">
AND b.ORG_ID = #{orgId}
</if>
<if test="orgType == 'agency'">
AND b.ALL_PARENT_IDS LIKE CONCAT('%', #{orgId}, '%')
</if>
) a
WHERE CATEGORY_CODE IS NOT NULL
</select>
<select id="selectWorkCategoryScoreList" resultType="com.epmet.dataaggre.dto.evaluationindex.EventCategoryResultDTO">
SELECT
*
FROM
(SELECT
a.CATEGORY_CODE,
c.PARENT_CATEGORY_CODE,
COUNT( a.EVENT_ID ) AS eventTotal,
c.SCORE,
SUM( c.SCORE ) AS totalScore
FROM
screen_py_event_data a
INNER JOIN epmet_user.patrol_routine_work b ON a.EVENT_ID = b.ID
AND b.DEL_FLAG = '0'
INNER JOIN customer_patrol_work_type_dict c ON a.CATEGORY_CODE = c.CATEGORY_CODE
AND c.IS_DISABLE = 'enable'
WHERE
a.DEL_FLAG = '0'
AND a.EVENT_TYPE = 'work'
<if test="startTime != null and startTime != ''">
AND DATE_FORMAT( a.EVENT_CREATE_TIME, '%Y-%m-%d' ) &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND DATE_FORMAT( a.EVENT_CREATE_TIME, '%Y-%m-%d' ) &lt;= #{endTime}
</if>
<if test="orgType == 'grid'">
AND b.GRID_ID = #{orgId}
</if>
<if test="orgType == 'agency'">
AND b.PIDS LIKE CONCAT('%', #{orgId}, '%')
</if>
) a
WHERE CATEGORY_CODE IS NOT NULL
</select>
</mapper>

4
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/basereport/form/EventInfoFormDTO.java

@ -4,6 +4,7 @@ import com.epmet.commons.tools.dto.form.PageFormDTO;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
@ -27,4 +28,7 @@ public class EventInfoFormDTO extends PageFormDTO implements Serializable {
* 2在完全初始化之后由于eventreport_pingyin表没有客户ID初始化其他客户的数据时候可以设2直接新增
*/
private String initFlag = "0";
private Date startTime;
private Date endTime;
}

179
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/EventreportPingyinDTO.java

@ -0,0 +1,179 @@
package com.epmet.dto.screen;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* 平阴区事件上报中间表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-07-22
*/
@Data
public class EventreportPingyinDTO {
private static final long serialVersionUID = 1L;
/**
* 上报区县代码参照6位行政区划代码
*/
private String qxBm;
/**
* 上报区县名称
*/
private String qxMc;
/**
* 网格编码,参照山东省社会治理网格化智能工作平台数据标准
*/
private String gridCode;
/**
* 网格名称
*/
private String gridName;
/**
* 事件编号可以使用区县系统中的事件唯一识别码
*/
private String eventCode;
/**
* 事件名称
*/
private String eventName;
/**
* 事件类别,参照山东省社会治理网格化智能工作平台数据标准10.19
*/
private String eventCategory;
/**
* 上报网格员姓名
*/
private String gridUserName;
/**
* 上报网格员的身份证号码
*/
private String gridUserCardid;
/**
* 事件上报时间
*/
private Date reportTime;
/**
* 事件发生时间
*/
private Date happenTime;
/**
* 事件发生地点描述
*/
private String happenPlace;
/**
* 事件简述详细一些文字数量不少于10字
*/
private String eventDescription;
/**
* 事件办结方式符合标准10.20
*/
private String waysOfResolving;
/**
* 必填 是否化解填写YNY N
*/
private String successfulOrNo;
/**
* 必填 是否办结填写YNY N
*/
private String successfulDefuse;
/**
* 办结层级符合标准10.21
*/
private String completeLevel;
/**
* 办结时间办结后填写
*/
private Date completeTime;
/**
* 事件发生位置经度wgs84坐标系请勿用火星坐标系不得跑出辖区
*/
private BigDecimal lng;
/**
* 事件发生位置纬度wgs84坐标系请勿用火星坐标系不得跑出辖区
*/
private BigDecimal lat;
/**
* 事件主要当事人姓名
*/
private String name;
/**
* 事件涉及人数
*/
private Integer numberInvolved;
/**
* 事件涉及单位名称
*/
private String relatedUnites;
/**
* 重点场所类别符合标准10.25
*/
private String keyAreaType;
/**
* 宗教活动规模符合标准10.26
*/
private String religionScale;
/**
* 宗教类别符合标准10.27
*/
private String religionType;
/**
* 重点场所是否变动填写YNY N
*/
private String isKeyareaState;
/**
* 重点人员是否在当地填写YNY N
*/
private String isKeypeopleLocate;
/**
* 重点人员现状描述
*/
private String keypeopleStatus;
/**
* 例行工作编辑插入更新时间,县市区填写
*/
private Date updateTime;
/**
* 事件是否删除YN
*/
private String isDel;
/**
* 入库时间自动生成请勿设置
*/
private Date recoredInsertTime;
}

87
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/GridstaffWorkInfoPingyinDTO.java

@ -0,0 +1,87 @@
package com.epmet.dto.screen;
import lombok.Data;
import java.util.Date;
/**
* 平阴区网格员例行工作信息
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-07-22
*/
@Data
public class GridstaffWorkInfoPingyinDTO {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
private String id;
/**
* 上报区县代码参照6位行政区划代码
*/
private String qxBm;
/**
* 上报区县名称
*/
private String qxMc;
/**
* 网格编码
*/
private String gridCode;
/**
* 网格名称
*/
private String gridName;
private String gridId;
/**
* 例行工作类型,应符合10.27中的例行工作类型
*/
private String workType;
/**
* 发生日期,格式为YYYY-MM-DD
*/
private Date happenTime;
/**
* 基础信息主键,出租房巡查重点场所巡查刑满释放人员社区矫正吸毒人员信访人员重点青少年和精神障碍者必填
*/
private Integer baseInfoId;
/**
* 有无变动异常,YN
*/
private String workResult;
/**
* 说明
*/
private String workContent;
/**
* 例行工作编辑插入更新时间,县市区填写
*/
private Date updateTime;
/**
* 例行工作是否删除YN
*/
private String isDel;
/**
* 入库时间自动生成请勿设置
*/
private Date recoredInsertTime;
private String happenTimeString;
}

30
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/SavePyEventDataFormDTO.java

@ -0,0 +1,30 @@
package com.epmet.dto.screen.form;/**
* @author ZhaoQiFeng
* @date 2022/12/8
* @apiNote
*/
import com.epmet.dto.screen.EventreportPingyinDTO;
import com.epmet.dto.screen.GridstaffWorkInfoPingyinDTO;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Description
* @Author zhaoqifeng
* @Date 2022/12/8 13:47
*/
@Data
public class SavePyEventDataFormDTO implements Serializable {
private static final long serialVersionUID = 526763788231934112L;
/**
* 项目列表
*/
private List<EventreportPingyinDTO> projectList;
/**
* 例行工作列表
*/
private List<GridstaffWorkInfoPingyinDTO> workList;
}

4
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java

@ -12,6 +12,7 @@ import com.epmet.dto.org.form.GridBaseInfoFormDTO;
import com.epmet.dto.org.result.CustomerAgencyDTO;
import com.epmet.dto.org.result.CustomerGridDTO;
import com.epmet.dto.screen.form.InitCustomerIndexForm;
import com.epmet.dto.screen.form.SavePyEventDataFormDTO;
import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO;
import com.epmet.dto.stats.form.FactUserHouseFormDTO;
import com.epmet.dto.user.form.StaffBaseInfoFormDTO;
@ -379,4 +380,7 @@ public interface DataStatisticalOpenFeignClient {
@PostMapping("/data/stats/factAgencyUserHouseDaily/userHouseStatNeighborhood")
Result userHouseStatNeighborhood(@RequestBody FactUserHouseFormDTO formDTO);
@PostMapping("/data/stats/datareporting/saveData")
Result saveData(@RequestBody SavePyEventDataFormDTO formDTO);
}

6
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java

@ -13,6 +13,7 @@ import com.epmet.dto.org.form.GridBaseInfoFormDTO;
import com.epmet.dto.org.result.CustomerAgencyDTO;
import com.epmet.dto.org.result.CustomerGridDTO;
import com.epmet.dto.screen.form.InitCustomerIndexForm;
import com.epmet.dto.screen.form.SavePyEventDataFormDTO;
import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO;
import com.epmet.dto.stats.form.FactUserHouseFormDTO;
import com.epmet.dto.user.form.StaffBaseInfoFormDTO;
@ -372,4 +373,9 @@ public class DataStatisticalOpenFeignClientFallBack implements DataStatisticalOp
public Result userHouseStatNeighborhood(FactUserHouseFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "userHouseStatNeighborhood", formDTO);
}
@Override
public Result saveData(SavePyEventDataFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "SavePyEventDataFormDTO", formDTO);
}
}

19
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DataReportingController.java

@ -7,6 +7,7 @@ import com.epmet.dto.basereport.result.EventInfoResultDTO;
import com.epmet.dto.org.form.GridBaseInfoFormDTO;
import com.epmet.dto.org.result.CustomerAgencyDTO;
import com.epmet.dto.org.result.CustomerGridDTO;
import com.epmet.dto.screen.form.SavePyEventDataFormDTO;
import com.epmet.dto.user.form.StaffBaseInfoFormDTO;
import com.epmet.dto.user.param.MidPatrolFormDTO;
import com.epmet.dto.user.result.GridUserInfoDTO;
@ -14,12 +15,14 @@ import com.epmet.dto.user.result.MidPatrolDetailResult;
import com.epmet.dto.user.result.MidPatrolRecordResult;
import com.epmet.opendata.dto.BaseDisputeProcessDTO;
import com.epmet.service.DataReportingService;
import com.epmet.service.evaluationindex.screen.ScreenPyEventDataService;
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 javax.annotation.Resource;
import java.util.List;
/**
@ -31,6 +34,8 @@ import java.util.List;
public class DataReportingController {
@Autowired
private DataReportingService dataReportingService;
@Resource
private ScreenPyEventDataService screenPyEventDataService;
/**
* @Author sun
@ -106,4 +111,18 @@ public class DataReportingController {
public Result<List<EventInfoResultDTO>> getEventInfoV2(@RequestBody(required = false) EventInfoFormDTO formDTO) {
return new Result<List<EventInfoResultDTO>>().ok(dataReportingService.getEventInfoV2(formDTO));
}
/**
* 保存同步到中间库的数据
*
* @Param formDTO
* @Return {@link Result}
* @Author zhaoqifeng
* @Date 2022/12/8 16:03
*/
@PostMapping("saveData")
public Result getEventInfoV2(@RequestBody(required = false) SavePyEventDataFormDTO formDTO) {
screenPyEventDataService.saveData(formDTO);
return new Result();
}
}

16
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenPyEventDataDao.java

@ -0,0 +1,16 @@
package com.epmet.dao.evaluationindex.screen;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.evaluationindex.screen.ScreenPyEventDataEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 上报到市平台中间库的事件
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-12-08
*/
@Mapper
public interface ScreenPyEventDataDao extends BaseDao<ScreenPyEventDataEntity> {
}

64
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenPyEventDataEntity.java

@ -0,0 +1,64 @@
package com.epmet.entity.evaluationindex.screen;
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-12-08
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("screen_py_event_data")
public class ScreenPyEventDataEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
///**
// * 客户Id
// */
//private String customerId;
//
///**
// * 上级组织Id
// */
//private String parentId;
//
///**
// * 所有上级ID,用英文逗号分开
// */
//private String allParentIds;
/**
* 事件Id
*/
private String eventId;
/**
* 事件类别 上报事件project例行工作work
*/
private String eventType;
/**
* 事件时间
*/
private Date eventCreateTime;
/**
* 事件分类编码
*/
private String categoryCode;
///**
// * 父类事件分类编码
// */
//private String parentCategoryCode;
}

24
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenPyEventDataService.java

@ -0,0 +1,24 @@
package com.epmet.service.evaluationindex.screen;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.dto.screen.form.SavePyEventDataFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenPyEventDataEntity;
/**
* 上报到市平台中间库的事件
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-12-08
*/
public interface ScreenPyEventDataService extends BaseService<ScreenPyEventDataEntity> {
/**
* 保存同步到中间库的数据
*
* @Param formDTO
* @Return
* @Author zhaoqifeng
* @Date 2022/12/8 11:14
*/
void saveData(SavePyEventDataFormDTO formDTO);
}

76
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenPyEventDataServiceImpl.java

@ -0,0 +1,76 @@
package com.epmet.service.evaluationindex.screen.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.constant.DataSourceConstant;
import com.epmet.dao.evaluationindex.screen.ScreenPyEventDataDao;
import com.epmet.dto.screen.form.SavePyEventDataFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenPyEventDataEntity;
import com.epmet.service.evaluationindex.screen.ScreenPyEventDataService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
/**
* 上报到市平台中间库的事件
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-12-08
*/
@Slf4j
@Service
@DataSource(DataSourceConstant.EVALUATION_INDEX)
public class ScreenPyEventDataServiceImpl extends BaseServiceImpl<ScreenPyEventDataDao, ScreenPyEventDataEntity> implements ScreenPyEventDataService {
/**
* 保存同步到中间库的数据
*
* @param formDTO
* @Param formDTO
* @Return
* @Author zhaoqifeng
* @Date 2022/12/8 11:14
*/
@Override
public void saveData(SavePyEventDataFormDTO formDTO) {
if (CollectionUtils.isNotEmpty(formDTO.getProjectList())) {
formDTO.getProjectList().forEach(item -> {
ScreenPyEventDataEntity entity = new ScreenPyEventDataEntity();
entity.setEventId(item.getEventCode().replace("py_", ""));
entity.setEventType("project");
entity.setEventCreateTime(item.getReportTime());
entity.setCategoryCode(item.getEventCategory());
LambdaQueryWrapper<ScreenPyEventDataEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ScreenPyEventDataEntity::getEventId, entity.getEventId());
wrapper.eq(ScreenPyEventDataEntity::getEventType, entity.getEventType());
ScreenPyEventDataEntity event = baseDao.selectOne(wrapper);
if (null == event) {
baseDao.insert(entity);
} else {
entity.setId(event.getId());
baseDao.updateById(entity);
}
});
}
if (CollectionUtils.isNotEmpty(formDTO.getWorkList())) {
formDTO.getWorkList().forEach(item -> {
ScreenPyEventDataEntity entity = new ScreenPyEventDataEntity();
entity.setEventId(item.getId());
entity.setEventType("work");
entity.setEventCreateTime(item.getHappenTime());
entity.setCategoryCode(item.getWorkType());
LambdaQueryWrapper<ScreenPyEventDataEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ScreenPyEventDataEntity::getEventId, entity.getEventId());
wrapper.eq(ScreenPyEventDataEntity::getEventType, entity.getEventType());
ScreenPyEventDataEntity event = baseDao.selectOne(wrapper);
if (null == event) {
baseDao.insert(entity);
} else {
entity.setId(event.getId());
baseDao.updateById(entity);
}
});
}
}
}

7
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenPyEventDataDao.xml

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.evaluationindex.screen.ScreenPyEventDataDao">
</mapper>

13
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/EventreportPingyinController.java

@ -36,4 +36,17 @@ public class EventreportPingyinController {
return new Result();
}
/**
* 将数据同步到平阴库
* @Param formDTO
* @Return {@link Result}
* @Author zhaoqifeng
* @Date 2022/12/9 14:15
*/
@PostMapping("saveData")
public Result saveData(@RequestBody(required = false) EventInfoFormDTO formDTO) {
eventreportPingyinService.saveData(formDTO);
return new Result();
}
}

34
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/GridstaffWorkInfoPingyinController.java

@ -1,20 +1,14 @@
package com.epmet.opendata.controller;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.epmet.dto.basereport.form.EventInfoFormDTO;
import com.epmet.opendata.service.GridstaffWorkInfoPingyinService;
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 javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
/**
@ -27,6 +21,20 @@ import java.util.Map;
@RequestMapping("gridstaffWorkInfoPingyin")
public class GridstaffWorkInfoPingyinController {
@Resource
private GridstaffWorkInfoPingyinService gridstaffWorkInfoPingyinService;
/**
* 将数据同步到平阴库
* @Param formDTO
* @Return {@link Result}
* @Author zhaoqifeng
* @Date 2022/12/9 14:15
*/
@PostMapping("saveData")
public Result saveData(@RequestBody(required = false) EventInfoFormDTO formDTO) {
gridstaffWorkInfoPingyinService.saveData(formDTO);
return new Result();
}
}

9
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/EventreportPingyinService.java

@ -20,4 +20,13 @@ public interface EventreportPingyinService extends BaseService<EventreportPingyi
* @Date 2021/10/15 16:59
*/
void getEventInfo(EventInfoFormDTO formDTO);
/**
* 将数据同步到平阴库
* @Param formDTO
* @Return
* @Author zhaoqifeng
* @Date 2022/12/9 14:16
*/
void saveData(EventInfoFormDTO formDTO);
}

10
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/GridstaffWorkInfoPingyinService.java

@ -1,6 +1,7 @@
package com.epmet.opendata.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.dto.basereport.form.EventInfoFormDTO;
import com.epmet.opendata.dto.form.UpsertPatrolRecordForm;
import com.epmet.opendata.entity.GridstaffWorkInfoPingyinEntity;
@ -19,4 +20,13 @@ public interface GridstaffWorkInfoPingyinService extends BaseService<GridstaffWo
*/
Boolean insertBaseGridWorkRecordV2(UpsertPatrolRecordForm formDTO);
/**
* 将数据同步到平阴库
* @Param formDTO
* @Return
* @Author zhaoqifeng
* @Date 2022/12/9 14:16
*/
void saveData(EventInfoFormDTO formDTO);
}

38
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/EventreportPingyinServiceImpl.java

@ -4,10 +4,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.utils.StrUtil;
import com.epmet.dto.basereport.form.EventInfoFormDTO;
import com.epmet.dto.basereport.result.EventInfoResultDTO;
import com.epmet.dto.screen.EventreportPingyinDTO;
import com.epmet.dto.screen.form.SavePyEventDataFormDTO;
import com.epmet.feign.DataStatisticalOpenFeignClient;
import com.epmet.opendata.dao.EventreportPingyinDao;
import com.epmet.opendata.dao.GridstaffInfoPingyinDao;
@ -16,6 +19,7 @@ import com.epmet.opendata.entity.GridstaffInfoPingyinEntity;
import com.epmet.opendata.service.EventreportPingyinService;
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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -63,13 +67,47 @@ public class EventreportPingyinServiceImpl extends BaseServiceImpl<EventreportPi
}
List<EventInfoResultDTO> list = result.getData();
saveEvent(list, formDTO.getInitFlag());
//将同步的数据保存
SavePyEventDataFormDTO savePyEventData = new SavePyEventDataFormDTO();
savePyEventData.setProjectList(ConvertUtils.sourceToTarget(list, EventreportPingyinDTO.class));
dataStatisticalOpenFeignClient.saveData(savePyEventData);
//分批次循环
while (CollectionUtils.isNotEmpty(list) && list.size() == formDTO.getPageSize()) {
formDTO.setPageNo(formDTO.getPageNo() + NumConstant.ONE);
result = dataStatisticalOpenFeignClient.getEventInfoV2(formDTO);
list = result.getData();
saveEvent(list, formDTO.getInitFlag());
//将同步的数据保存
savePyEventData = new SavePyEventDataFormDTO();
savePyEventData.setProjectList(ConvertUtils.sourceToTarget(list, EventreportPingyinDTO.class));
dataStatisticalOpenFeignClient.saveData(savePyEventData);
}
}
/**
* 将数据同步到平阴库
*
* @param formDTO
* @Param formDTO
* @Return
* @Author zhaoqifeng
* @Date 2022/12/9 14:16
*/
@Override
public void saveData(EventInfoFormDTO formDTO) {
LambdaQueryWrapper<EventreportPingyinEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.ge(EventreportPingyinEntity::getReportTime, formDTO.getStartTime());
wrapper.le(EventreportPingyinEntity::getReportTime, formDTO.getEndTime());
List<EventreportPingyinEntity> list = baseDao.selectList(wrapper);
List<List<EventreportPingyinEntity>> partition = ListUtils.partition(list, NumConstant.ONE_THOUSAND);
partition.forEach(part -> {
//将同步的数据保存
SavePyEventDataFormDTO savePyEventData = new SavePyEventDataFormDTO();
savePyEventData.setProjectList(ConvertUtils.sourceToTarget(part, EventreportPingyinDTO.class));
dataStatisticalOpenFeignClient.saveData(savePyEventData);
});
}
private void saveEvent(List<EventInfoResultDTO> list, String initFlag) {

74
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/GridstaffWorkInfoPingyinServiceImpl.java

@ -13,24 +13,30 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.utils.StrUtil;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.dto.basereport.form.EventInfoFormDTO;
import com.epmet.dto.form.patrol.PatrolQueryFormDTO;
import com.epmet.dto.result.PatrolRoutineWorkResult;
import com.epmet.dto.screen.GridstaffWorkInfoPingyinDTO;
import com.epmet.dto.screen.form.SavePyEventDataFormDTO;
import com.epmet.feign.DataStatisticalOpenFeignClient;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.opendata.dao.GridstaffWorkInfoPingyinDao;
import com.epmet.opendata.dto.form.UpsertPatrolRecordForm;
import com.epmet.opendata.entity.GridstaffWorkInfoPingyinEntity;
import com.epmet.opendata.service.GridstaffWorkInfoPingyinService;
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.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* 平阴区网格员例行工作信息
@ -44,6 +50,8 @@ public class GridstaffWorkInfoPingyinServiceImpl extends BaseServiceImpl<Gridsta
@Autowired
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
@Resource
private DataStatisticalOpenFeignClient dataStatisticalOpenFeignClient;
@Override
public Boolean insertBaseGridWorkRecordV2(UpsertPatrolRecordForm patrolRecordForm) {
@ -93,6 +101,60 @@ public class GridstaffWorkInfoPingyinServiceImpl extends BaseServiceImpl<Gridsta
return true;
}
/**
* 将数据同步到平阴库
*
* @param formDTO
* @Param formDTO
* @Return
* @Author zhaoqifeng
* @Date 2022/12/9 14:16
*/
@Override
public void saveData(EventInfoFormDTO formDTO) {
PatrolQueryFormDTO midPatrolFormDTO = new PatrolQueryFormDTO();
midPatrolFormDTO.setCustomerId(formDTO.getCustomerId());
midPatrolFormDTO.setPageNo(NumConstant.ONE);
midPatrolFormDTO.setPageSize(NumConstant.ONE_THOUSAND);
List<PatrolRoutineWorkResult> data;
do {
Result<List<PatrolRoutineWorkResult>> record = epmetUserOpenFeignClient.getPatrolRoutineWorkListV2(midPatrolFormDTO);
if (record == null || !record.success()) {
log.warn("获取例行工作记录V2失败,param:{}", JSON.toJSONString(midPatrolFormDTO));
throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode());
}
data = record.getData();
if (CollectionUtils.isNotEmpty(record.getData())) {
List<PatrolRoutineWorkResult> newList = new ArrayList<>();
data.forEach(item -> {
if (StringUtils.isBlank(item.getGridId())){
return;
}
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(item.getGridId());
if (null == gridInfo) {
return;
}
item.setGridCode(gridInfo.getCode());
if (StringUtils.isNotBlank(item.getGridCode())) {
newList.add(item);
}
});
List<GridstaffWorkInfoPingyinDTO> list = newList.stream().map(item -> {
GridstaffWorkInfoPingyinDTO dto = new GridstaffWorkInfoPingyinDTO();
dto.setId(item.getId());
dto.setHappenTime(DateUtils.parseDate(item.getHappenTime().concat(" 00:00:00"), DateUtils.DATE_PATTERN));
dto.setWorkType(item.getWorkTypeSecondCode());
return dto;
}).collect(Collectors.toList());
//将同步的数据保存
SavePyEventDataFormDTO savePyEventData = new SavePyEventDataFormDTO();
savePyEventData.setWorkList(list);
dataStatisticalOpenFeignClient.saveData(savePyEventData);
}
midPatrolFormDTO.setPageNo(midPatrolFormDTO.getPageNo() + 1);
} while (data.size() == NumConstant.ONE_THOUSAND);
}
/**
* Desc: 数据存入
*
@ -112,11 +174,17 @@ public class GridstaffWorkInfoPingyinServiceImpl extends BaseServiceImpl<Gridsta
private Boolean insertNewRecordBatch(List<PatrolRoutineWorkResult> list) {
List<GridstaffWorkInfoPingyinEntity> insertList = new ArrayList<>();
List<GridstaffWorkInfoPingyinDTO> newList = new ArrayList<>();
list.forEach(o -> {
if (StringUtils.isBlank(o.getGridCode())) {
return;
}
insertList.add(buildNewEntity(o));
GridstaffWorkInfoPingyinDTO dto = new GridstaffWorkInfoPingyinDTO();
dto.setId(o.getId());
dto.setHappenTime(DateUtils.parseDate(o.getHappenTime().concat(" 00:00:00"), DateUtils.DATE_PATTERN));
dto.setWorkType(o.getWorkTypeSecondCode());
newList.add(dto);
});
//insert
if (CollectionUtils.isEmpty(insertList)) {
@ -124,6 +192,10 @@ public class GridstaffWorkInfoPingyinServiceImpl extends BaseServiceImpl<Gridsta
return false;
}
insertGridStaffWorkInfoPY(insertList);
//将同步的数据保存
SavePyEventDataFormDTO savePyEventData = new SavePyEventDataFormDTO();
savePyEventData.setWorkList(newList);
dataStatisticalOpenFeignClient.saveData(savePyEventData);
return true;
}

Loading…
Cancel
Save