Browse Source

Merge remote-tracking branch 'origin/dev' into dev

dev_shibei_match
sunyuchao 4 years ago
parent
commit
dd001f8e5d
  1. 37
      epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/form/CorsConfigFormDTO.java
  2. 27
      epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/result/CorsConfigResultDTO.java
  3. 24
      epmet-admin/epmet-admin-client/src/main/java/com/epmet/feign/EpmetAdminOpenFeignClient.java
  4. 18
      epmet-admin/epmet-admin-client/src/main/java/com/epmet/feign/fallback/EpmetAdminOpenFeignClientFallback.java
  5. 70
      epmet-admin/epmet-admin-server/src/main/java/com/epmet/controller/CorsConfigController.java
  6. 33
      epmet-admin/epmet-admin-server/src/main/java/com/epmet/dao/CorsConfigDao.java
  7. 56
      epmet-admin/epmet-admin-server/src/main/java/com/epmet/entity/CorsConfigEntity.java
  8. 20
      epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/CorsConfigService.java
  9. 110
      epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/CorsConfigServiceImpl.java
  10. 13
      epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.5__cors_config_tbl.sql
  11. 20
      epmet-admin/epmet-admin-server/src/main/resources/mapper/CorsConfigDao.xml
  12. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  13. 10
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  14. 5
      epmet-gateway/pom.xml
  15. 21
      epmet-gateway/src/main/java/com/epmet/bean/CorsConfigCache.java
  16. 141
      epmet-gateway/src/main/java/com/epmet/config/CorsConfig.java
  17. 4
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java
  18. 4
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenIndexDataMonthlyDao.java
  19. 2
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenIndexDataYearlyDao.java
  20. 8
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/IndexServiceImpl.java
  21. 9
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml
  22. 3
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataYearlyDao.xml
  23. 4
      epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/InitPointRuleResultDTO.java
  24. 2
      epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/feign/EpmetPointOpenFeignClient.java
  25. 5
      epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/feign/fallback/EpmetPointOpenFeignClientFallback.java
  26. 13
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/BackDoorController.java
  27. 4
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/PointRuleService.java
  28. 29
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointRuleServiceImpl.java
  29. 6
      epmet-module/gov-project/gov-project-server/src/main/resources/db/migration/V0.0.14__alter_project_location.sql
  30. 2
      epmet-module/gov-project/gov-project-server/src/main/resources/db/migration/V0.0.15__update_project.sql
  31. 2
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java

37
epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/form/CorsConfigFormDTO.java

@ -0,0 +1,37 @@
package com.epmet.dto.form;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CorsConfigFormDTO {
public interface Add {}
public interface Update {}
@NotBlank(message = "ID不能为空", groups = { Update.class })
private String id;
/**
* 首部type
*/
@NotBlank(message = "首部类型不能为空", groups = { Add.class, Update.class })
private String headerType;
/**
* 首部value
*/
@NotBlank(message = "首部值不能为空", groups = { Add.class, Update.class })
private String headerValue;
/**
* 备注
*/
private String comment;
}

27
epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/result/CorsConfigResultDTO.java

@ -0,0 +1,27 @@
package com.epmet.dto.result;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CorsConfigResultDTO {
private String id;
/**
* 首部类型
*/
private String headerType;
/**
* 首部值
*/
private String headerValue;
/**
* 首部备注
*/
private String comment;
}

24
epmet-admin/epmet-admin-client/src/main/java/com/epmet/feign/EpmetAdminOpenFeignClient.java

@ -0,0 +1,24 @@
package com.epmet.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.result.CorsConfigResultDTO;
import com.epmet.feign.fallback.EpmetAdminOpenFeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import java.util.List;
@FeignClient(name = ServiceConstant.EPMET_ADMIN_SERVER, fallback = EpmetAdminOpenFeignClientFallback.class)
//@FeignClient(name = ServiceConstant.EPMET_ADMIN_SERVER, fallback = EpmetAdminOpenFeignClientFallback.class, url = "localhost:8082")
public interface EpmetAdminOpenFeignClient {
/**
* @Description 查询跨域配置列表
* @return
* @author wxz
* @date 2021.06.25 10:00
*/
@PostMapping("/sys/cors-config/list")
Result<List<CorsConfigResultDTO>> list();
}

18
epmet-admin/epmet-admin-client/src/main/java/com/epmet/feign/fallback/EpmetAdminOpenFeignClientFallback.java

@ -0,0 +1,18 @@
package com.epmet.feign.fallback;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.result.CorsConfigResultDTO;
import com.epmet.feign.EpmetAdminOpenFeignClient;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class EpmetAdminOpenFeignClientFallback implements EpmetAdminOpenFeignClient {
@Override
public Result<List<CorsConfigResultDTO>> list() {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "list", null);
}
}

70
epmet-admin/epmet-admin-server/src/main/java/com/epmet/controller/CorsConfigController.java

@ -0,0 +1,70 @@
package com.epmet.controller;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.CorsConfigFormDTO;
import com.epmet.dto.result.CorsConfigResultDTO;
import com.epmet.service.CorsConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("cors-config")
public class CorsConfigController {
@Autowired
private CorsConfigService corsConfigService;
/**
* @Description 查询跨域配置列表
* @return
* @author wxz
* @date 2021.06.25 10:00
*/
@PostMapping("/list")
public Result<List<CorsConfigResultDTO>> list() {
List<CorsConfigResultDTO> list = corsConfigService.list();
return new Result<List<CorsConfigResultDTO>>().ok(list);
}
/**
* @Description 添加跨域配置
* @return
* @author wxz
* @date 2021.06.25 13:51
*/
@PostMapping("/add")
public Result<CorsConfigResultDTO> addConfig(@RequestBody CorsConfigFormDTO input) {
ValidatorUtils.validateEntity(input, CorsConfigFormDTO.Add.class);
CorsConfigResultDTO data = corsConfigService.addConfig(input.getHeaderType(), input.getHeaderValue(), input.getComment());
return new Result<CorsConfigResultDTO>().ok(data);
}
/**
* @Description 通过id删除配置
* @return
* @author wxz
* @date 2021.06.25 14:18
*/
@PostMapping("/delete/{id}")
public Result deleteConfigById(@PathVariable("id") String configId) {
corsConfigService.deleteById(configId);
return new Result<>();
}
/**
* @Description 根据id更新
* @return
* @author wxz
* @date 2021.06.25 14:23
*/
@PostMapping("/update")
public Result updateById(@RequestBody CorsConfigFormDTO input) {
ValidatorUtils.validateEntity(input, CorsConfigFormDTO.Update.class);
corsConfigService.updateById(input.getId(), input.getHeaderType(), input.getHeaderValue(), input.getComment());
return new Result<>();
}
}

33
epmet-admin/epmet-admin-server/src/main/java/com/epmet/dao/CorsConfigDao.java

@ -0,0 +1,33 @@
/**
* 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.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.CorsConfigEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 跨域配置表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-06-25
*/
@Mapper
public interface CorsConfigDao extends BaseDao<CorsConfigEntity> {
}

56
epmet-admin/epmet-admin-server/src/main/java/com/epmet/entity/CorsConfigEntity.java

@ -0,0 +1,56 @@
/**
* 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.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 跨域配置表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-06-25
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("cors_config")
public class CorsConfigEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 首部类型
*/
private String headerType;
/**
* 首部值
*/
private String headerValue;
/**
* 说明
*/
private String comment;
}

20
epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/CorsConfigService.java

@ -0,0 +1,20 @@
package com.epmet.service;
import com.epmet.dto.result.CorsConfigResultDTO;
import java.util.List;
/**
* @Description 跨域配置service接口
* @author wxz
* @date 2021-06-44 09:52:44
*/
public interface CorsConfigService {
List<CorsConfigResultDTO> list();
CorsConfigResultDTO addConfig(String headerType, String headerValue, String comment);
void deleteById(String configId);
void updateById(String configId, String headerType, String headerValue, String comment);
}

110
epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/CorsConfigServiceImpl.java

@ -0,0 +1,110 @@
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.dao.CorsConfigDao;
import com.epmet.dto.result.CorsConfigResultDTO;
import com.epmet.entity.CorsConfigEntity;
import com.epmet.service.CorsConfigService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Description 跨域配置
* @author wxz
* @date 2021.06.25 09:53:57
*/
@Service
public class CorsConfigServiceImpl implements CorsConfigService {
@Autowired
private CorsConfigDao corsConfigDao;
@Autowired
private RedisTemplate redisTemplate;
private Logger logger = LoggerFactory.getLogger(getClass());
/**
* @Description 查询配置列表
* @return
* @author wxz
* @date 2021.06.25 09:58
*/
@Override
public List<CorsConfigResultDTO> list() {
LambdaQueryWrapper<CorsConfigEntity> conditions = new LambdaQueryWrapper<>();
return ConvertUtils.sourceToTarget(corsConfigDao.selectList(conditions), CorsConfigResultDTO.class);
}
@Override
public CorsConfigResultDTO addConfig(String headerType, String headerValue, String comment) {
LambdaQueryWrapper<CorsConfigEntity> w = new LambdaQueryWrapper<>();
w.eq(CorsConfigEntity::getHeaderType, headerType.trim());
w.eq(CorsConfigEntity::getHeaderValue, headerValue.trim());
if (corsConfigDao.selectCount(w) > 0) {
throw new RenException(EpmetErrorCode.OPER_CORS_CONFIG_ERROR.getCode(), "已存在该跨域配置,请勿重复添加");
}
CorsConfigEntity insert = new CorsConfigEntity();
insert.setHeaderType(headerType);
insert.setHeaderValue(headerValue);
insert.setComment(comment);
if (corsConfigDao.insert(insert) == 0) {
throw new RenException(EpmetErrorCode.OPER_CORS_CONFIG_ERROR.getCode(), "插入跨域配置出错");
}
deleteFromRedis();
return new CorsConfigResultDTO(insert.getId(), headerType, headerValue, comment);
}
@Override
public void deleteById(String configId) {
if (corsConfigDao.deleteById(configId) == 0) {
String msg = "删除出错,不存在该项数据";
throw new RenException(EpmetErrorCode.OPER_CORS_CONFIG_ERROR.getCode(), msg, msg, RenException.MessageMode.CODE_INTERNAL_EXTERNAL);
}
deleteFromRedis();
}
@Override
public void updateById(String configId, String headerType, String headerValue, String comment) {
CorsConfigEntity exists = corsConfigDao.selectById(configId);
if (exists == null) {
String msg = "该项数据不存在";
throw new RenException(EpmetErrorCode.OPER_CORS_CONFIG_ERROR.getCode(), msg, msg, RenException.MessageMode.CODE_INTERNAL_EXTERNAL);
}
exists.setHeaderType(headerType);
exists.setHeaderValue(headerValue);
exists.setComment(comment);
if (corsConfigDao.updateById(exists) == 0) {
throw new RenException(EpmetErrorCode.OPER_CORS_CONFIG_ERROR.getCode(), "更新出错,影响条数为0");
}
deleteFromRedis();
}
/**
* @Description 从缓存中删除
* @return
* @author wxz
* @date 2021.06.25 14:26
*/
private void deleteFromRedis() {
try {
redisTemplate.delete(RedisKeys.getCorsConfigKey());
} catch (Exception e) {
String errorMsg = ExceptionUtils.getErrorStackTrace(e);
logger.error(String.format("从Redis中删除Cors跨域信息失败,程序继续执行。错误信息:%s", errorMsg));
}
}
}

13
epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.5__cors_config_tbl.sql

@ -0,0 +1,13 @@
CREATE TABLE `cors_config` (
`ID` varchar(64) NOT NULL,
`HEADER_TYPE` varchar(32) NOT NULL COMMENT '首部类型',
`HEADER_VALUE` varchar(128) NOT NULL COMMENT '首部值',
`COMMENT` varchar(512) DEFAULT NULL COMMENT '说明',
`DEL_FLAG` int(11) NOT NULL DEFAULT '0' COMMENT '删除标识 0.未删除 1.已删除',
`REVISION` int(11) NOT NULL COMMENT '乐观锁',
`CREATED_BY` varchar(32) NOT NULL COMMENT '创建人',
`CREATED_TIME` datetime NOT NULL COMMENT '创建时间',
`UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人',
`UPDATED_TIME` datetime NOT NULL COMMENT '更新时间',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='跨域配置表'

20
epmet-admin/epmet-admin-server/src/main/resources/mapper/CorsConfigDao.xml

@ -0,0 +1,20 @@
<?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.CorsConfigDao">
<resultMap type="com.epmet.entity.CorsConfigEntity" id="corsConfigMap">
<result property="id" column="ID"/>
<result property="headerType" column="HEADER_TYPE"/>
<result property="headerValue" column="HEADER_VALUE"/>
<result property="comment" column="COMMENT"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
</mapper>

1
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java

@ -128,6 +128,7 @@ public enum EpmetErrorCode {
USER_LIST_ROLES_BY_KEY_FAIL(8715, "根据角色key查询角色列表失败"),
OPER_UPLOAD_IMG_TYPE_ERROR(8716, "请上传PNG格式的图片"),
OPER_UPLOAD_IMG_SIZE_ERROR(8717, "请上传200*200的图片"),
OPER_CORS_CONFIG_ERROR(8718, "跨域配置错误"),
// 党建声音 前端提示 88段
DRAFT_CONTENT_IS_NULL(8801, "至少需要添加一个段落"),

10
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java

@ -459,4 +459,14 @@ public class RedisKeys {
String currentMonth= DateUtils.getBeforeNMonth(NumConstant.ZERO);
return "groupread:user:".concat(currentMonth).concat(":").concat(source).concat(":").concat(groupId).concat(":").concat(sourceId);
}
/**
* @Description 跨域配置key
* @return
* @author wxz
* @date 2021.06.25 10:31
*/
public static String getCorsConfigKey() {
return rootPrefix.concat("sys:cors");
}
}

5
epmet-gateway/pom.xml

@ -81,6 +81,11 @@
<artifactId>epmet-commons-openapi</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-admin-client</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
<build>

21
epmet-gateway/src/main/java/com/epmet/bean/CorsConfigCache.java

@ -0,0 +1,21 @@
package com.epmet.bean;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @Description 跨域配置缓存
* @author wxz
* @date 2021.06.25 10:59:44
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CorsConfigCache {
private List<String> accessControlAllowOrigins;
}

141
epmet-gateway/src/main/java/com/epmet/config/CorsConfig.java

@ -1,15 +1,29 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* <p>
* https://www.renren.io
*
* <p>
* 版权所有侵权必究
*/
package com.epmet.config;
import com.epmet.bean.CorsConfigCache;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.feign.ResultDataResolver;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.dto.result.CorsConfigResultDTO;
import com.epmet.feign.EpmetAdminOpenFeignClient;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
@ -21,6 +35,11 @@ import org.springframework.web.server.WebFilter;
import org.springframework.web.server.WebFilterChain;
import reactor.core.publisher.Mono;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Cors跨域
*
@ -29,33 +48,105 @@ import reactor.core.publisher.Mono;
*/
@Configuration
public class CorsConfig {
private static final String MAX_AGE = "18000L";
@Bean
public WebFilter corsFilter() {
return (ServerWebExchange ctx, WebFilterChain chain) -> {
ServerHttpRequest request = ctx.getRequest();
if (!CorsUtils.isCorsRequest(request)) {
return chain.filter(ctx);
}
HttpHeaders requestHeaders = request.getHeaders();
ServerHttpResponse response = ctx.getResponse();
HttpMethod requestMethod = requestHeaders.getAccessControlRequestMethod();
HttpHeaders headers = response.getHeaders();
return new EpmetWebFilter();
}
}
/**
* @Description 用于CORS等操作的判断
* @return
* @author wxz
* @date 2021.06.25 10:42
*/
class EpmetWebFilter implements WebFilter, ResultDataResolver {
private static final String MAX_AGE = "18000L";
@Autowired
private EpmetAdminOpenFeignClient adminOpenFeignClient;
@Resource
private RedisTemplate<String, CorsConfigCache> redisTemplate;
private Logger logger = LoggerFactory.getLogger(getClass());
@Override
public Mono<Void> filter(ServerWebExchange ctx, WebFilterChain chain) {
ServerHttpRequest request = ctx.getRequest();
if (!CorsUtils.isCorsRequest(request)) {
return chain.filter(ctx);
}
HttpHeaders requestHeaders = request.getHeaders();
ServerHttpResponse response = ctx.getResponse();
HttpMethod requestMethod = requestHeaders.getAccessControlRequestMethod();
HttpHeaders headers = response.getHeaders();
if (isAllowed(requestHeaders.getOrigin())) {
headers.add(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, requestHeaders.getOrigin());
headers.addAll(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS, requestHeaders.getAccessControlRequestHeaders());
if (requestMethod != null) {
headers.add(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS, requestMethod.name());
}
headers.addAll(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS, requestHeaders.getAccessControlRequestHeaders());
if (requestMethod != null) {
headers.add(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS, requestMethod.name());
}
headers.add(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true");
headers.add(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, "*");
headers.add(HttpHeaders.ACCESS_CONTROL_MAX_AGE, MAX_AGE);
if (request.getMethod() == HttpMethod.OPTIONS) {
response.setStatusCode(HttpStatus.OK);
return Mono.empty();
}
return chain.filter(ctx);
}
/**
* @Description 是否允许跨域
* @return
* @author wxz
* @date 2021.06.25 10:43
*/
private Boolean isAllowed(String origin) {
HashOperations<String, String, List<String>> ope = redisTemplate.opsForHash();
Map<String, List<String>> configMap = ope.entries(RedisKeys.getCorsConfigKey());
if (configMap == null || configMap.size() == 0) {
List<CorsConfigResultDTO> data = null;
try {
data = getResultDataOrThrowsException(
adminOpenFeignClient.list(),
ServiceConstant.EPMET_ADMIN_SERVER,
EpmetErrorCode.SERVER_ERROR.getCode(),
"调用Admin服务查询Cors配置失败");
} catch (Exception e) {
logger.error("调用Admin服务查询Cors配置失败");
}
headers.add(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true");
headers.add(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, "*");
headers.add(HttpHeaders.ACCESS_CONTROL_MAX_AGE, MAX_AGE);
if (request.getMethod() == HttpMethod.OPTIONS) {
response.setStatusCode(HttpStatus.OK);
return Mono.empty();
// 将origin集合
List<String> origins = data.stream()
.filter((c) -> HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN.equals(c.getHeaderType()))
.map((c) -> c.getHeaderValue())
.collect(Collectors.toList());
try {
configMap.put(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, origins);
ope.putAll(RedisKeys.getCorsConfigKey(), configMap);
} catch (Exception e) {
logger.error(String.format("gateway缓存跨域配置出错:%s", ExceptionUtils.getErrorStackTrace(e)));
}
return chain.filter(ctx);
};
}
}
}
List<String> accessControlAllowOrigins = configMap.get(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN);
logger.info("accessControlAllowOrigins:" + accessControlAllowOrigins);
logger.info("origin:" + origin);
if (CollectionUtils.isEmpty(accessControlAllowOrigins)) {
return false;
}
if (accessControlAllowOrigins.contains("*")) {
return true;
}
return accessControlAllowOrigins.contains(origin);
}
}

4
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java

@ -7,7 +7,6 @@ import com.epmet.dataaggre.constant.DataSourceConstant;
import com.epmet.dataaggre.dao.epmetuser.StaffPatrolRecordDao;
import com.epmet.dataaggre.dao.epmetuser.StaffRoleDao;
import com.epmet.dataaggre.dao.epmetuser.UserBaseInfoDao;
import com.epmet.dataaggre.dto.datastats.result.SubAgencyUserResultDTO;
import com.epmet.dataaggre.dto.epmetuser.StaffPatrolDetailDTO;
import com.epmet.dataaggre.dto.epmetuser.StaffPatrolRecordDTO;
import com.epmet.dataaggre.dto.epmetuser.form.PatrolDateListFormDTO;
@ -21,9 +20,7 @@ import com.epmet.dataaggre.service.epmetuser.StaffPatrolDetailService;
import com.epmet.dataaggre.service.epmetuser.StaffPatrolRecordService;
import com.epmet.dataaggre.service.govorg.GovOrgService;
import lombok.extern.slf4j.Slf4j;
import oracle.sql.NUMBER;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -78,6 +75,7 @@ public class EpmetUserServiceImpl implements EpmetUserService {
/**
* @Param formDTO
* @Description 001各人员巡查记录列表查询
* @remark 因为是yi以人为单位的数据 所以要内存分页
* @author sun
*/
@Override

4
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenIndexDataMonthlyDao.java

@ -47,7 +47,9 @@ public interface ScreenIndexDataMonthlyDao{
* @author zxc
* @date 2020/8/20 9:02 上午
*/
List<MonthBarchartResult> selectMonthBarchart(@Param("agencyId")String agencyId,@Param("monthId") String monthId);
List<MonthBarchartResult> selectMonthBarchart(@Param("agencyId")String agencyId,
@Param("monthId") String monthId,
@Param("customerId")String customerId);
/**
* @param subAgencyIndexRankFormDTO

2
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenIndexDataYearlyDao.java

@ -40,7 +40,7 @@ public interface ScreenIndexDataYearlyDao{
* @author zxc
* @date 2020/8/19 3:43 下午
*/
YearAverageIndexResultDTO selectYearAverageIndex(@Param("agencyId")String agencyId);
YearAverageIndexResultDTO selectYearAverageIndex(@Param("agencyId")String agencyId,@Param("customerId")String customerId);
/**
* 5下级部门指数排行安宁数据段用 -

8
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/IndexServiceImpl.java

@ -53,7 +53,7 @@ public class IndexServiceImpl implements IndexService {
@DataSource(value = DataSourceConstant.EVALUATION_INDEX,datasourceNameFromArg = true)
@Override
public YearAverageIndexResultDTO yearAverageIndex(YearAverageIndexFormDTO yearAverageIndexFormDTO) {
YearAverageIndexResultDTO yearAverageIndexResultDTO = screenIndexDataYearlyDao.selectYearAverageIndex(yearAverageIndexFormDTO.getAgencyId());
YearAverageIndexResultDTO yearAverageIndexResultDTO = screenIndexDataYearlyDao.selectYearAverageIndex(yearAverageIndexFormDTO.getAgencyId(),yearAverageIndexFormDTO.getCustomerId());
if (null == yearAverageIndexResultDTO){
return new YearAverageIndexResultDTO();
}
@ -119,7 +119,9 @@ public class IndexServiceImpl implements IndexService {
result.setXAxis(partyMemberLeadServiceImpl.getXPro());
}
// 2. 查询近一年的指数值【包括本月】
List<MonthBarchartResult> monthBarchartResults = screenIndexDataMonthlyDao.selectMonthBarchart(monthBarchartFormDTO.getAgencyId(),monthBarchartFormDTO.getMonthId());
List<MonthBarchartResult> monthBarchartResults = screenIndexDataMonthlyDao.selectMonthBarchart(monthBarchartFormDTO.getAgencyId(),
monthBarchartFormDTO.getMonthId(),
monthBarchartFormDTO.getCustomerId());
if (monthBarchartResults.size() == NumConstant.ZERO){
for (int i = NumConstant.ZERO; i <= NumConstant.TWELVE; i++) {
serviceAbilityData.add(NumConstant.ZERO_DOT_ZERO);
@ -233,8 +235,10 @@ public class IndexServiceImpl implements IndexService {
subAgencyIndexRankFormDTO.setYearId(String.valueOf(yearId));
List<SubAgencyIndexRankResultDTO> subAgencyIndexRankResultDTOS = new ArrayList<>();
if (StringUtils.isNotEmpty(subAgencyIndexRankFormDTO.getAreaCode())){
//area_code不为空,多客户
subAgencyIndexRankResultDTOS = screenIndexDataMonthlyDao.selectSubAgencyIndexRankNew(subAgencyIndexRankFormDTO);
}else {
//单客户
subAgencyIndexRankResultDTOS = screenIndexDataMonthlyDao.selectSubAgencyIndexRank(subAgencyIndexRankFormDTO);
}
if (CollectionUtils.isEmpty(subAgencyIndexRankResultDTOS)){

9
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml

@ -43,6 +43,9 @@
WHERE
del_flag = '0'
AND org_id = #{agencyId}
<if test="customerId != null and customerId != ''">
and customer_id = #{customerId}
</if>
<if test="monthId != null and monthId.trim() != ''">
AND MONTH_ID &lt;= #{monthId}
</if>
@ -64,6 +67,9 @@
AND parent_id = #{agencyId}
AND year_id = #{yearId}
AND ORG_TYPE != 'department'
<if test="customerId != null and customerId != ''">
and customer_id = #{customerId}
</if>
ORDER BY index_total DESC
LIMIT #{topNum}
</select>
@ -327,6 +333,9 @@
AND ca.AREA_CODE LIKE CONCAT(#{areaCode},'%')
AND y.year_id = #{yearId}
AND y.ORG_TYPE != 'department'
<if test="customerId != null and customerId != ''">
and y.customer_id = #{customerId}
</if>
ORDER BY y.index_total DESC
LIMIT #{topNum}
</select>

3
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataYearlyDao.xml

@ -15,6 +15,9 @@
WHERE
del_flag = '0'
AND org_id = #{agencyId}
<if test="customerId != null and customerId != ''">
and customer_id=#{customerId}
</if>
order by year_id desc
limit 1
</select>

4
epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/InitPointRuleResultDTO.java

@ -42,4 +42,6 @@ public class InitPointRuleResultDTO implements Serializable {
* 已经初始化总数
*/
private Integer initedTotal;
}
private String InitedDetail;
}

2
epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/feign/EpmetPointOpenFeignClient.java

@ -36,7 +36,7 @@ public interface EpmetPointOpenFeignClient {
* @author sun
**/
@PostMapping("/point/opback/initpointrule")
Result<InitPointRuleResultDTO> initPointRule();
Result<InitPointRuleResultDTO> initPointRule(String customerId);
/**
* 获取小组积分

5
epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/feign/fallback/EpmetPointOpenFeignClientFallback.java

@ -10,6 +10,7 @@ import com.epmet.dto.form.GroupPointFormDTO;
import com.epmet.dto.result.ResiPointDetailResultDTO;
import com.epmet.feign.EpmetPointOpenFeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestParam;
/**
* @Description
@ -25,8 +26,8 @@ public class EpmetPointOpenFeignClientFallback implements EpmetPointOpenFeignCli
}
@Override
public Result<InitPointRuleResultDTO> initPointRule() {
return ModuleUtils.feignConError(ServiceConstant.EPMET_POINT_SERVER, "initPointRule");
public Result<InitPointRuleResultDTO> initPointRule(@RequestParam String customerId) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_POINT_SERVER, "initPointRule",customerId);
}
/**

13
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/BackDoorController.java

@ -9,10 +9,7 @@ import com.epmet.dto.InitPointRuleResultDTO;
import com.epmet.dto.form.PointRuleFormDTO;
import com.epmet.service.PointRuleService;
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 org.springframework.web.bind.annotation.*;
import java.util.List;
@ -44,12 +41,12 @@ public class BackDoorController {
/**
* desc:批量添加规则
*
* @param list
* @param customerId
* @return
*/
@PostMapping(value = "initpointrule")
public Result<InitPointRuleResultDTO> initPointRule() {
InitPointRuleResultDTO resultDTO = pointRuleService.initPointRule();
@GetMapping(value = "initpointrule")
public Result<InitPointRuleResultDTO> initPointRule(@RequestParam(required = false) String customerId) {
InitPointRuleResultDTO resultDTO = pointRuleService.initPointRule(customerId);
return new Result<InitPointRuleResultDTO>().ok(resultDTO);
}

4
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/PointRuleService.java

@ -69,7 +69,7 @@ public interface PointRuleService extends BaseService<PointRuleEntity> {
**/
PointRuleEntity getByEventCodeAndCustomerId(String customerId,String eventCode);
InitPointRuleResultDTO initPointRule();
InitPointRuleResultDTO initPointRule(String customerId);
/**
* 获取小组积分规则
@ -79,4 +79,4 @@ public interface PointRuleService extends BaseService<PointRuleEntity> {
* @return com.epmet.dto.result.GroupPointRuleResultDTO
*/
GroupPointRuleResultDTO getGroupRule(String customerId);
}
}

29
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointRuleServiceImpl.java

@ -16,7 +16,6 @@
*/
package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.epmet.common.enu.PointUnitEnum;
@ -196,14 +195,23 @@ public class PointRuleServiceImpl extends BaseServiceImpl<PointRuleDao, PointRul
@Override
@Transactional(rollbackFor = Exception.class)
public InitPointRuleResultDTO initPointRule() {
public InitPointRuleResultDTO initPointRule(String customerId) {
//得到所有客户Id
Result<List<CustomerDTO>> customerListResult = operCrmOpenFeignClient.getAllCustomerList();
log.info("initPointRule operCrmOpenFeignClient.getAllCustomerList result:{}",JSON.toJSONString(customerListResult));
if (!customerListResult.success() || CollectionUtils.isEmpty(customerListResult.getData())) {
throw new RenException("获取所有客户列表失败");
List<CustomerDTO> customerDTOList = null;
if (StringUtils.isBlank(customerId)){
Result<List<CustomerDTO>> customerListResult = operCrmOpenFeignClient.getAllCustomerList();
log.info("initPointRule operCrmOpenFeignClient.getAllCustomerList result:{}",JSON.toJSONString(customerListResult));
if (!customerListResult.success() || CollectionUtils.isEmpty(customerListResult.getData())) {
throw new RenException("获取所有客户列表失败");
}
customerDTOList = customerListResult.getData();
}else{
customerDTOList = new ArrayList<>();
CustomerDTO customerDTO = new CustomerDTO();
customerDTO.setId(customerId);
customerDTOList.add(customerDTO);
}
List<CustomerDTO> customerDTOList = customerListResult.getData();
//获取默认规则列表
List<PointRuleDefaultEntity> ruleDefaultEntities = pointRuleDefaultDao.selectList(null);
if (CollectionUtils.isEmpty(ruleDefaultEntities)) {
@ -221,7 +229,7 @@ public class PointRuleServiceImpl extends BaseServiceImpl<PointRuleDao, PointRul
//key :: customerId || value :: 客户规则集合
Map<String,List<PointRuleEntity>> customerRuleMap =
customerRule.stream().collect(Collectors.groupingBy(PointRuleEntity :: getCustomerId));
customerRuleMap.forEach((customerId,ruleList) -> {
customerRuleMap.forEach((cId,ruleList) -> {
if(null != ruleList){
List<String> event = new LinkedList<>(defaultEventCodeList);
//取差集,event只剩下当前客户没有的积分规则
@ -234,7 +242,7 @@ public class PointRuleServiceImpl extends BaseServiceImpl<PointRuleDao, PointRul
entity.setCreatedTime(new Date());
entity.setUpdatedBy("");
entity.setUpdatedTime(new Date());
entity.setCustomerId(customerId);
entity.setCustomerId(cId);
insertList.add(entity);
return entity;
}).collect(Collectors.toList());
@ -281,6 +289,7 @@ public class PointRuleServiceImpl extends BaseServiceImpl<PointRuleDao, PointRul
InitPointRuleResultDTO result = new InitPointRuleResultDTO();
result.setCustomerTotal(customerDTOList.size());
result.setInitedTotal(insertList.size());
result.setInitedDetail(JSON.toJSONString(insertList));
return result;
}
@ -337,4 +346,4 @@ public class PointRuleServiceImpl extends BaseServiceImpl<PointRuleDao, PointRul
}
return resultStaff.getData();
}
}
}

6
epmet-module/gov-project/gov-project-server/src/main/resources/db/migration/V0.0.14__alter_project_location.sql

@ -1,6 +0,0 @@
ALTER TABLE `project`
ADD COLUMN `LOCATE_ADDRESS` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '定位地址[立项项目指的项目发生位置,议题转的项目指的话题发生位置]' AFTER `ORG_ID_PATH`,
ADD COLUMN `LOCATE_LONGITUDE` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '定位经度' AFTER `LOCATE_ADDRESS`,
ADD COLUMN `LOCATE_DIMENSION` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '定位维度' AFTER `LOCATE_LONGITUDE`;

2
epmet-module/gov-project/gov-project-server/src/main/resources/db/migration/V0.0.15__update_project.sql

@ -1,2 +0,0 @@
update project set locate_address = NULL,locate_longitude = NULL,locate_dimension = NULL;

2
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java

@ -560,7 +560,7 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerDao, CustomerEn
//2021.1.25 sun 新增初始化客户积分规则和评价指标权重 start
//8.客户初始化已有的积分规则
Result<InitPointRuleResultDTO> resultPoint = epmetPointOpenFeignClient.initPointRule();
Result<InitPointRuleResultDTO> resultPoint = epmetPointOpenFeignClient.initPointRule(formDTO.getCustomerId());
if (!resultPoint.success()) {
throw new RenException(resultPoint.getCode(), resultPoint.getInternalMsg());
}

Loading…
Cancel
Save