Browse Source

Merge remote-tracking branch 'remotes/origin/dev_screen_data_2.0' into dev

master
jianjun 5 years ago
parent
commit
2f3d97ea20
  1. 2
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/CommonOperateTypeEnum.java
  2. 23
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java
  3. 2
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/constant/ScreenConstant.java
  4. 37
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/SubSingleIndexRankFormDTO.java
  5. 22
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/TreeByTypeFormDTO.java
  6. 3
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/PeerComparisonResultDTO.java
  7. 5
      epmet-module/data-report/data-report-server/pom.xml
  8. 2
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/constant/FactConstant.java
  9. 24
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/backdoor/BackDoorController.java
  10. 14
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/AgencyController.java
  11. 18
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/IndexController.java
  12. 4
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java
  13. 9
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenIndexDataMonthlyDao.java
  14. 13
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/backdoor/BackDoorService.java
  15. 51
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/backdoor/impl/BackDoorServiceImpl.java
  16. 4
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/AgencyService.java
  17. 12
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/IndexService.java
  18. 72
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java
  19. 20
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/IndexServiceImpl.java
  20. 37
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml
  21. 47
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml
  22. 26
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcollect/form/CustomerBizOrgFormDTO.java
  23. 5
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/form/CustomerIdAndDateIdFormDTO.java
  24. 1
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java
  25. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ShiBeiScreenCollController.java
  26. 7
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java
  27. 40
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerBizOrgDao.java
  28. 15
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerAgencyEntity.java
  29. 52
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerBizOrgEntity.java
  30. 233
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java
  31. 13
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java
  32. 13
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ShiBeiScreenCollService.java
  33. 13
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java
  34. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java
  35. 82
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ShiBeiScreenCollServiceImpl.java
  36. 65
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerPartymemberServiceImpl.java
  37. 1
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml
  38. 39
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerBizOrgDao.xml
  39. 13
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/GetJwtAccessTokenFormDTO.java
  40. 32
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/AppIdInfoResultDTO.java
  41. 16
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/GetJwtAccessTokenResultDTO.java
  42. 18
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java
  43. 12
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java
  44. 27
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalAppController.java
  45. 9
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalAppDao.java
  46. 6
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalAppService.java
  47. 28
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppServiceImpl.java
  48. 36
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/externalapp/ExtAppJwtTokenUtils.java
  49. 14
      epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppDao.xml
  50. 16
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/DimPartyMemberServiceImpl.java

2
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/CommonOperateTypeEnum.java

@ -11,6 +11,8 @@ public enum CommonOperateTypeEnum {
ADD("add", "添加"),
EDIT("edit", "编辑"),
DEL("del", "删除"),
DESC("DESC", "降序"),
ASC("ASC", "升序"),
;
private String code;

23
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java

@ -159,6 +159,29 @@ public class HttpClientManager {
}
public Result<String> sendPostByJSONAndHeader(String url, String jsonStrParam,Map<String,String> headerMap) {
try {
HttpPost httppost = new HttpPost(url);
httppost.setConfig(requestConfig);
httppost.addHeader("Content-Type", "application/json; charset=utf-8");
if (null != headerMap){
headerMap.forEach((k,v) -> {
httppost.addHeader(k,v);
});
}
if (StringUtils.isNotEmpty(jsonStrParam)) {
StringEntity se = new StringEntity(jsonStrParam, "utf-8");
httppost.setEntity(se);
}
return execute(httppost, false);
} catch (Exception e) {
log.error("send exception", e);
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg());
}
}
/**
* 上传临时素材
* @author zhaoqifeng

2
epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/constant/ScreenConstant.java

@ -16,6 +16,8 @@ public interface ScreenConstant {
String COMMA = ",";
String COLON = ":";
String MONTH_ID = "month";
String YEAR_ID = "year";

37
epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/SubSingleIndexRankFormDTO.java

@ -0,0 +1,37 @@
package com.epmet.evaluationindex.screen.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* desc:下级组织单项排行分数 form
*
* @DateTime 2020/8/20 9:54 上午
*/
@Data
public class SubSingleIndexRankFormDTO implements Serializable {
private static final long serialVersionUID = -2920561669035794486L;
@NotBlank(message = "客户ID不能为空")
private String customerId;
/**
* 机关ID
*/
@NotBlank(message = "机关ID不能为空")
private String agencyId;
@NotBlank(message = "指标code不能为空")
private String indexCode;
/**
* 默认查询前几名
*/
private Integer topNum;
private String monthId;
private String orgType;
private String sort;
}

22
epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/TreeByTypeFormDTO.java

@ -0,0 +1,22 @@
package com.epmet.evaluationindex.screen.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/10/22 10:52 上午
*/
@Data
public class TreeByTypeFormDTO implements Serializable {
private static final long serialVersionUID = -1438758394814978472L;
public interface TreeByType extends CustomerClientShowGroup{}
@NotBlank(message = "bizType不能为空",groups = TreeByType.class)
private String bizType;
}

3
epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/PeerComparisonResultDTO.java

@ -5,7 +5,8 @@ import lombok.Data;
import java.io.Serializable;
/**
* 同级对比各项数据查询--接口返参
* 同级对比(下级单项指数排行)各项数据查询--接口返参
*
* @Author sun
*/
@Data

5
epmet-module/data-report/data-report-server/pom.xml

@ -29,6 +29,11 @@
<artifactId>epmet-user-client</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>common-service-client</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>

2
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/constant/FactConstant.java

@ -61,4 +61,6 @@ public interface FactConstant {
* 评价指标类型-百分比
*/
String PERCENT = "percent";
String URL = "https://epmet-dev.elinkservice.cn/api/";
}

24
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/backdoor/BackDoorController.java

@ -0,0 +1,24 @@
package com.epmet.datareport.controller.backdoor;
import com.epmet.commons.tools.utils.Result;
import com.epmet.datareport.service.backdoor.BackDoorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @Author zxc
* @DateTime 2020/10/21 5:17 下午
*/
@RestController
@RequestMapping("backdoor")
public class BackDoorController {
@Autowired
private BackDoorService backDoorService;
@PostMapping("backdoor")
public Object backDoor(@RequestHeader("Data-Type")String dataType, @RequestHeader("AppId")String appId, @RequestHeader("target")String target, @RequestBody(required = false) Object o){
return backDoorService.backDoor(dataType,appId,target,o);
}
}

14
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/AgencyController.java

@ -4,6 +4,7 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.datareport.service.evaluationindex.screen.AgencyService;
import com.epmet.evaluationindex.screen.dto.form.CompartmentFormDTO;
import com.epmet.evaluationindex.screen.dto.form.TreeByTypeFormDTO;
import com.epmet.evaluationindex.screen.dto.result.CompartmentResultDTO;
import com.epmet.evaluationindex.screen.dto.result.TreeResultDTO;
import org.springframework.beans.factory.annotation.Autowired;
@ -33,6 +34,19 @@ public class AgencyController {
return new Result<TreeResultDTO>().ok(agencyService.tree(customerId));
}
/**
* @Description 智慧社区的tree
* @Param customerId
* @Param bizType
* @author zxc
* @date 2020/10/21 2:49 下午
*/
@PostMapping("treebytype")
public Result<TreeResultDTO> treeByType(@RequestHeader("CustomerId") String customerId,@RequestBody TreeByTypeFormDTO bizType){
ValidatorUtils.validateEntity(bizType, TreeByTypeFormDTO.TreeByType.class);
return new Result<TreeResultDTO>().ok(agencyService.treeByType(customerId,bizType));
}
/**
* @Description 2组织区域查询
* @param compartmentFormDTO

18
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/IndexController.java

@ -1,7 +1,5 @@
package com.epmet.datareport.controller.screen;
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.datareport.eum.OrgTypeEnum;
@ -88,6 +86,22 @@ public class IndexController {
return new Result<List<AnNingSubAgencyIndexRankResultDTO>>().ok(indexService.getSubAgencyIndexRank(formDTO));
}
/**
* desc: 下级组织单项指数得分排行
*
* @param customerId
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<java.util.List < com.epmet.evaluationindex.screen.dto.result.PeerComparisonResultDTO>>
* @author LiuJanJun
* @date 2020/10/22 1:49 下午
*/
@PostMapping("subsingleindexrank")
public Result<List<PeerComparisonResultDTO>> getSubSingleIndexRank(@RequestHeader("CustomerId") String customerId, @RequestBody SubSingleIndexRankFormDTO formDTO) {
formDTO.setCustomerId(customerId);
ValidatorUtils.validateEntity(formDTO);
return new Result<List<PeerComparisonResultDTO>>().ok(indexService.getSubSingleIndexRank(formDTO));
}
/**
* @param formDTO
* @Description 4获取该客户下所有网格指标排行

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

@ -40,6 +40,8 @@ public interface ScreenCustomerAgencyDao {
*/
TreeResultDTO selectRootAgencyId(@Param("customerId")String customerId);
TreeResultDTO selectRootAgencyIdByBizType(@Param("customerId")String customerId,@Param("bizType")String bizType);
/**
* @Description 查询下级机关的 名称和id
* @param subAgencyPids
@ -48,6 +50,8 @@ public interface ScreenCustomerAgencyDao {
*/
List<TreeResultDTO> selectSubAgencyList(@Param("subAgencyPids") String subAgencyPids);
List<TreeResultDTO> selectSubAgencyListByBizType(@Param("subAgencyPids") String subAgencyPids);
/**
* @Description 查询当前机关的区域信息
* @param agencyId

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

@ -91,8 +91,15 @@ public interface ScreenIndexDataMonthlyDao{
/**
* @param formDTO
* @Description 先进排行-先进支部排行
* @Description 先进排行-先进支部排行
* @author sun
*/
List<IndexAdvanceBranchRankResultDTO> selectRankList(AdvancedBranchRankFormDTO formDTO);
/**
* @param formDTO
* @Description 下级单项指标得分排行
* @author sun
*/
List<PeerComparisonResultDTO> getSingleIndexRank(SubSingleIndexRankFormDTO formDTO);
}

13
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/backdoor/BackDoorService.java

@ -0,0 +1,13 @@
package com.epmet.datareport.service.backdoor;
import com.epmet.commons.tools.utils.Result;
/**
* @Author zxc
* @DateTime 2020/10/21 5:17 下午
*/
public interface BackDoorService {
Object backDoor(String dataType, String appId, String target, Object o);
}

51
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/backdoor/impl/BackDoorServiceImpl.java

@ -0,0 +1,51 @@
package com.epmet.datareport.service.backdoor.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result;
import com.epmet.datareport.constant.*;
import com.epmet.datareport.service.backdoor.BackDoorService;
import com.epmet.dto.result.AppIdInfoResultDTO;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
* @Author zxc
* @DateTime 2020/10/21 5:17 下午
*/
@Service
@Slf4j
public class BackDoorServiceImpl implements BackDoorService {
@Autowired
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient;
@Override
public Object backDoor(String dataType, String appId, String target, Object o) {
Result<AppIdInfoResultDTO> appIdInfoResultDTOResult = commonServiceOpenFeignClient.appIdInfo(appId);
if (!appIdInfoResultDTOResult.success()){
throw new RenException("获取accessToken失败......");
}
AppIdInfoResultDTO data = appIdInfoResultDTOResult.getData();
String url = FactConstant.URL.concat(target);
Map<String,String> headerMap = new HashMap<>(16);
headerMap.put("AccessToken",data.getAccessToken());
headerMap.put("AppId",data.getAppId());
headerMap.put("AuthType","jwt");
headerMap.put("Data-Type",dataType);
Result<String> stringResult = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(o),headerMap);
log.info(JSON.toJSONString(stringResult));
if (!stringResult.success()){
throw new RenException("请求【"+url+"】失败......"+stringResult.error());
}
JSONObject jsonObject = JSON.parseObject(stringResult.getData());
return jsonObject;
}
}

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

@ -1,6 +1,7 @@
package com.epmet.datareport.service.evaluationindex.screen;
import com.epmet.evaluationindex.screen.dto.form.CompartmentFormDTO;
import com.epmet.evaluationindex.screen.dto.form.TreeByTypeFormDTO;
import com.epmet.evaluationindex.screen.dto.result.CompartmentResultDTO;
import com.epmet.evaluationindex.screen.dto.result.TreeResultDTO;
@ -20,6 +21,9 @@ public interface AgencyService {
*/
TreeResultDTO tree(String customerId);
TreeResultDTO treeByType(String customerId, TreeByTypeFormDTO bizType);
/**
* @Description 2组织区域查询
* @param compartmentFormDTO

12
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/IndexService.java

@ -72,8 +72,18 @@ public interface IndexService {
/**
* @param formDTO
* @Description 先进排行-先进支部排行
* @Description 先进排行-先进支部排行
* @author sun
*/
List<IndexAdvanceBranchRankResultDTO> advancedBranchRank(AdvancedBranchRankFormDTO formDTO);
/**
* desc:下级单项指数排行
*
* @param formDTO
* @return java.util.List<com.epmet.evaluationindex.screen.dto.result.PeerComparisonResultDTO>
* @author LiuJanJun
* @date 2020/10/22 10:58 上午
*/
List<PeerComparisonResultDTO> getSubSingleIndexRank(SubSingleIndexRankFormDTO formDTO);
}

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

@ -9,6 +9,7 @@ import com.epmet.datareport.dao.evaluationindex.screen.ScreenCustomerGridDao;
import com.epmet.datareport.service.evaluationindex.screen.AgencyService;
import com.epmet.evaluationindex.screen.constant.ScreenConstant;
import com.epmet.evaluationindex.screen.dto.form.CompartmentFormDTO;
import com.epmet.evaluationindex.screen.dto.form.TreeByTypeFormDTO;
import com.epmet.evaluationindex.screen.dto.result.AgencyDistributionResultDTO;
import com.epmet.evaluationindex.screen.dto.result.CompartmentResultDTO;
import com.epmet.evaluationindex.screen.dto.result.TreeResultDTO;
@ -66,6 +67,37 @@ public class AgencyServiceImpl implements AgencyService {
return rootAgency;
}
/**
* @Description 智慧社区的tree
* @Param customerId
* @Param bizType
* @author zxc
* @date 2020/10/21 2:49 下午
*/
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
public TreeResultDTO treeByType(String customerId, TreeByTypeFormDTO bizType) {
TreeResultDTO rootAgency = null;
try {
rootAgency = screenCustomerAgencyDao.selectRootAgencyIdByBizType(customerId,bizType.getBizType());
if (null == rootAgency) {
return new TreeResultDTO();
}
} catch (TooManyResultsException e) {
throw new RenException("根组织结构数据有误");
}
List<Double> centerMark = this.getCenterMark(rootAgency.getCenterMarkA());
rootAgency.setCenterMark(centerMark.size() == NumConstant.ZERO ? new ArrayList<>() : centerMark);
if (rootAgency.getLevel().equals(ScreenConstant.COMMUNITY)) {
List<TreeResultDTO> treeResultDTOS = screenCustomerGridDao.selectGridInfo(rootAgency.getValue());
rootAgency.setChildren(treeResultDTOS);
} else {
List<TreeResultDTO> departmentList = this.getDepartmentListByBiz(("".equals(rootAgency.getPids()) || rootAgency.getPids().equals(NumConstant.ZERO_STR)) ? rootAgency.getValue() : rootAgency.getPids().concat(",").concat(rootAgency.getValue()));
rootAgency.setChildren(departmentList);
}
return rootAgency;
}
/**
* @Description 处理centerMark
* @param centerMark
@ -105,7 +137,45 @@ public class AgencyServiceImpl implements AgencyService {
});
sub.setChildren(treeResultDTOS);
}else {
List<TreeResultDTO> subAgency = getDepartmentList(sub.getPids() + "," + sub.getValue());
List<TreeResultDTO> subAgency = new ArrayList<>();
if (sub.getPids().contains(ScreenConstant.COMMA)){
subAgency = getDepartmentList(sub.getPids() + ScreenConstant.COMMA + sub.getValue());
}else {
subAgency = getDepartmentList(sub.getPids() + ScreenConstant.COLON + sub.getValue());
}
sub.setChildren(subAgency);
}
});
}
return subAgencyList;
}
/**
* @Description 智慧社区的tree
* @Param subAgencyPids
* @author zxc
* @date 2020/10/21 2:49 下午
*/
public List<TreeResultDTO> getDepartmentListByBiz(String subAgencyPids) {
List<TreeResultDTO> subAgencyList = screenCustomerAgencyDao.selectSubAgencyListByBizType(subAgencyPids);
if (subAgencyList.size() > NumConstant.ZERO) {
subAgencyList.forEach(sub -> {
List<Double> centerMark = this.getCenterMark(sub.getCenterMarkA());
sub.setCenterMark(centerMark.size() == NumConstant.ZERO ? new ArrayList<>() : centerMark);
if (sub.getLevel().equals(ScreenConstant.COMMUNITY)){
List<TreeResultDTO> treeResultDTOS = screenCustomerGridDao.selectGridInfo(sub.getValue());
treeResultDTOS.forEach(tree -> {
List<Double> centerMarkTree = this.getCenterMark(tree.getCenterMarkA());
tree.setCenterMark(centerMarkTree.size() == NumConstant.ZERO ? new ArrayList<>() : centerMarkTree);
});
sub.setChildren(treeResultDTOS);
}else {
List<TreeResultDTO> subAgency = new ArrayList<>();
if (sub.getPids().contains(ScreenConstant.COMMA)){
subAgency = getDepartmentListByBiz(sub.getPids() + ScreenConstant.COMMA + sub.getValue());
}else {
subAgency = getDepartmentListByBiz(sub.getPids() + ScreenConstant.COLON + sub.getValue());
}
sub.setChildren(subAgency);
}
});

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

@ -2,6 +2,7 @@ package com.epmet.datareport.service.evaluationindex.screen.impl;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.enums.CommonOperateTypeEnum;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.constant.DataSourceConstant;
import com.epmet.datareport.dao.evaluationindex.screen.ScreenIndexDataMonthlyDao;
@ -11,18 +12,15 @@ import com.epmet.evaluationindex.screen.constant.ScreenConstant;
import com.epmet.evaluationindex.screen.dto.form.*;
import com.epmet.evaluationindex.screen.dto.result.*;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.helper.DataUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.unit.DataUnit;
import java.math.BigDecimal;
import java.text.NumberFormat;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@ -328,4 +326,20 @@ public class IndexServiceImpl implements IndexService {
return list;
}
@Override
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
public List<PeerComparisonResultDTO> getSubSingleIndexRank(SubSingleIndexRankFormDTO formDTO) {
if (StringUtils.isBlank(formDTO.getMonthId())) {
formDTO.setMonthId(DateUtils.getBeforeNMonth(1));
}
if (StringUtils.isBlank(formDTO.getSort())) {
formDTO.setSort(CommonOperateTypeEnum.DESC.getCode());
}
if (formDTO.getTopNum() == null) {
formDTO.setTopNum(NumConstant.FIVE);
}
List<PeerComparisonResultDTO> list = screenIndexDataMonthlyDao.getSingleIndexRank(formDTO);
return list;
}
}

37
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml

@ -114,4 +114,41 @@
AND agency_id = #{agencyId}
</select>
<select id="selectRootAgencyIdByBizType" resultType="com.epmet.evaluationindex.screen.dto.result.TreeResultDTO">
SELECT
ca.agency_name AS label,
cbo.ORG_ID AS value,
ca.pids AS pids,
IFNULL(ca.center_mark,'') AS centerMarkA,
ca.level AS level
FROM
screen_customer_agency ca
LEFT JOIN screen_customer_biz_org cbo ON cbo.ORG_ID = ca.AGENCY_ID
WHERE
ca.del_flag = 0
AND cbo.DEL_FLAG = 0
AND ca.pid = '0'
AND cbo.customer_id = #{customerId}
AND cbo.BIZ_TYPE = #{bizType}
</select>
<select id="selectSubAgencyListByBizType" resultType="com.epmet.evaluationindex.screen.dto.result.TreeResultDTO">
SELECT
cbo.ORG_ID AS value,
ca.agency_name AS label,
ca.pids AS pids,
IFNULL(ca.center_mark,'') AS centerMarkA,
ca.level AS level
FROM
screen_customer_biz_org cbo
LEFT JOIN screen_customer_agency ca ON ca.AGENCY_ID = cbo.ORG_ID
WHERE
ca.del_flag = '0'
AND cbo.DEL_FLAG = 0
AND cbo.biz_type = "community"
AND ca.pids = #{subAgencyPids}
ORDER BY
ca.created_time DESC
</select>
</mapper>

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

@ -205,4 +205,51 @@
LIMIT #{topNum}
</select>
<select id="getSingleIndexRank" resultType="com.epmet.evaluationindex.screen.dto.result.PeerComparisonResultDTO">
SELECT
ORG_ID,
ORG_NAME,
<choose>
<when test="indexCode == 'dangjiannengli'">
round(party_dev_ablity,1) as score
</when>
<when test="indexCode == 'zhilinengli'">
round(govern_ablity,1) as score
</when>
<when test="indexCode == 'fuwunengli'">
round(service_ablity,1) as score
</when>
</choose>
FROM
screen_index_data_monthly
WHERE
del_flag = '0'
<if test="customerId != null and customerId != ''">
AND CUSTOMER_ID = #{customerId,jdbcType=VARCHAR}
</if>
AND PARENT_ID = #{agencyId,jdbcType=VARCHAR}
AND MONTH_ID = #{monthId,jdbcType=VARCHAR}
<choose>
<when test="orgType != null and orgType != ''">
AND ORG_TYPE = #{orgType,jdbcType=VARCHAR}
</when>
<otherwise>
AND ORG_TYPE != 'department'
</otherwise>
</choose>
ORDER BY
<choose>
<when test="indexCode == 'dangjiannengli'">
party_dev_ablity
</when>
<when test="indexCode == 'zhilinengli'">
govern_ablity
</when>
<when test="indexCode == 'fuwunengli'">
service_ablity
</when>
</choose>
${sort}
LIMIT #{topNum}
</select>
</mapper>

26
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcollect/form/CustomerBizOrgFormDTO.java

@ -0,0 +1,26 @@
package com.epmet.dto.indexcollect.form;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable;
/**
* 客户业务组织关系 入参
*/
@Data
public class CustomerBizOrgFormDTO implements Serializable {
/**
* 当为true时后台将删除本月数据
*/
@NotEmpty(message = "客户Id不能为空")
private String customerId;
/**
* 业务类型智慧社区 community
*/
@NotEmpty(message = "业务类型不能为空")
private String bizType;
}

5
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/form/CustomerIdAndDateIdFormDTO.java

@ -19,6 +19,9 @@ public class CustomerIdAndDateIdFormDTO implements Serializable {
private String customerId;
@NotBlank(message = "日期Id不能为空",groups = CustomerIdAndDateId.class)
private String dateId;
private String startDate;
private String endDate;
}

1
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java

@ -263,7 +263,6 @@ public class DimController {
*/
@PostMapping("statsparty")
public Result getPartyInfo(@RequestBody CustomerIdAndDateIdFormDTO customerIdAndDateIdFormDTO) {
ValidatorUtils.validateEntity(customerIdAndDateIdFormDTO, CustomerIdAndDateIdFormDTO.CustomerIdAndDateId.class);
return new Result().ok(partyMemberService.statsPartyMember(customerIdAndDateIdFormDTO));
}

9
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ShiBeiScreenCollController.java

@ -1,6 +1,7 @@
package com.epmet.controller;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO;
import com.epmet.dto.screencoll.form.*;
import com.epmet.service.evaluationindex.screen.ShiBeiScreenCollService;
import org.springframework.beans.factory.annotation.Autowired;
@ -261,4 +262,12 @@ public class ShiBeiScreenCollController {
shiBeiScreenCollService.insertPublicPartiTotalData(formDTO, customerId);
return new Result();
}
/**
* 初始化客户业务组织类型
**/
@PostMapping("initbizorg")
public Result initBizOrg(@RequestBody CustomerBizOrgFormDTO formDTO) {
return new Result().ok(shiBeiScreenCollService.initBizOrg(formDTO));
}
}

7
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java

@ -23,6 +23,7 @@ import com.epmet.dto.extract.form.ScreenPartyBranchDataFormDTO;
import com.epmet.dto.extract.form.ScreenPartyLinkMassesDataFormDTO;
import com.epmet.dto.extract.result.CustomerAgencyInfoResultDTO;
import com.epmet.dto.extract.result.OrgNameResultDTO;
import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO;
import com.epmet.dto.screen.result.TreeResultDTO;
import com.epmet.dto.screencoll.form.CustomerAgencyFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity;
@ -165,13 +166,15 @@ public interface ScreenCustomerAgencyDao extends BaseDao<ScreenCustomerAgencyEnt
*/
List<ScreenPartyLinkMassesDataFormDTO> selectAllAgencyIdToPartyLinkMessage(@Param("customerId") String customerId,@Param("monthId") String monthId);
List<ScreenPartyBranchDataFormDTO> selectAllAgencyIdToOrganize(@Param("customerId") String customerId,@Param("monthId") String monthId);
List<ScreenPartyBranchDataFormDTO> selectAllAgencyIdToOrganize(@Param("customerId") String customerId, @Param("monthId") String monthId);
/**
* @Description 查询org名称机关
* @param agencyIds
* @Description 查询org名称机关
* @author zxc
* @date 2020/9/24 1:27 下午
*/
List<OrgNameResultDTO> selectOrgNameAgency(@Param("agencyIds") List<String> agencyIds);
Boolean initBizOrg(CustomerBizOrgFormDTO formDTO);
}

40
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerBizOrgDao.java

@ -0,0 +1,40 @@
/**
* 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.evaluationindex.screen;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerBizOrgEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 组织机构信息
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-18
*/
@Mapper
public interface ScreenCustomerBizOrgDao extends BaseDao<ScreenCustomerBizOrgEntity> {
int deleteByBizType(CustomerBizOrgFormDTO formDTO);
int batchInsert(@Param("list") List<ScreenCustomerBizOrgEntity> list);
}

15
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerAgencyEntity.java

@ -89,15 +89,20 @@ public class ScreenCustomerAgencyEntity extends BaseEpmetEntity {
private String level;
/**
* 行政地区编码
*/
* 行政地区编码
*/
private String areaCode;
private String sourceType;
/**
* 数据更新至: yyyy|yyyyMM|yyyyMMdd(08-21新增)
*/
/**
* 数据更新至: yyyy|yyyyMM|yyyyMMdd(08-21新增)
*/
private String dataEndTime;
/**
* desc: 是否显示 1显示 0不显示
*/
private String isDisplay;
}

52
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerBizOrgEntity.java

@ -0,0 +1,52 @@
/**
* 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.evaluationindex.screen;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 组织机构信息
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-21
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("screen_customer_biz_org")
public class ScreenCustomerBizOrgEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户id
*/
private String customerId;
/**
* 组织id
*/
private String orgId;
/**
* 业务类型 community:智慧社区
*/
private String bizType;
}

233
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java

@ -5,6 +5,8 @@ import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.OrgTypeConstant;
import com.epmet.constant.ProjectConstant;
import com.epmet.dao.evaluationindex.extract.FactOriginProjectOrgPeriodDailyDao;
import com.epmet.dto.ProjectDTO;
import com.epmet.dto.extract.FactOriginProjectMainDailyDTO;
@ -32,10 +34,10 @@ import com.epmet.service.project.ProjectService;
import com.epmet.service.topic.TopicService;
import com.epmet.util.DimIdGenerator;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.apache.commons.collections4.CollectionUtils;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@ -86,9 +88,9 @@ public class ProjectExtractServiceImpl implements ProjectExtractService {
if (!CollectionUtils.isEmpty(closedList)) {
List<FactOriginProjectMainDailyEntity> closeProjects =
pendingList.stream().flatMap(pending -> closedList.stream().filter(closed -> pending.getId().equals(closed.getProjectId())).map(process -> {
FactOriginProjectMainDailyEntity entity = new FactOriginProjectMainDailyEntity();
entity.setId(process.getProjectId());
entity.setProjectStatus("closed");
FactOriginProjectMainDailyEntity entity = new FactOriginProjectMainDailyEntity();
entity.setId(process.getProjectId());
entity.setProjectStatus(ProjectConstant.CLOSED);
entity.setCreatedTime(DateUtils.stringToDate(pending.getDateId(), DateUtils.DATE_PATTERN_YYYYMMDD));
entity.setUpdatedTime(process.getUpdatedTime());
entity.setIsResolved(process.getIsResolved());
@ -194,10 +196,11 @@ public class ProjectExtractServiceImpl implements ProjectExtractService {
}
}
final List<FactOriginProjectMainDailyEntity> mainList = list;
List<FactOriginProjectLogDailyEntity> logList = new ArrayList<>();
//节点发起人 部门流转退回结案
List<ProcessInfoDTO> processList = projectProcessService.getProcessListByCustomer(customerId, dateString);
if (!CollectionUtils.isEmpty(processList)) {
List<FactOriginProjectLogDailyEntity> logList = processList.stream().map(process -> {
logList = processList.stream().map(process -> {
//获取日期相关维度
DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(process.getCreatedTime());
FactOriginProjectLogDailyEntity entity = new FactOriginProjectLogDailyEntity();
@ -213,11 +216,11 @@ public class ProjectExtractServiceImpl implements ProjectExtractService {
entity.setIsActive(NumConstant.ONE);
entity.setPids(process.getPids());
if (StringUtils.isNotBlank(process.getDepartmentId())) {
entity.setOrgType("department");
entity.setOrgType(OrgTypeConstant.DEPARTMENT);
entity.setOrgId(process.getDepartmentId());
entity.setPid(process.getAgencyId());
}else if (StringUtils.isNotBlank(process.getGridId())) {
entity.setOrgType("grid");
entity.setOrgType(OrgTypeConstant.GRID);
entity.setOrgId(process.getGridId());
entity.setPid(process.getAgencyId());
}else{
@ -243,67 +246,11 @@ public class ProjectExtractServiceImpl implements ProjectExtractService {
return entity;
}).collect(Collectors.toList());
//节点发起人 响应
List<ProcessInfoDTO> responseList = projectProcessService.getResponseProcessList(customerId, dateString);
if (!CollectionUtils.isEmpty(responseList)) {
logList.addAll(responseList.stream().map(process -> {
//获取日期相关维度
DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(process.getCreatedTime());
FactOriginProjectLogDailyEntity entity = new FactOriginProjectLogDailyEntity();
entity.setCustomerId(customerId);
entity.setAgencyId(process.getAgencyId());
entity.setYearId(dimId.getYearId());
entity.setQuarterId(dimId.getQuarterId());
entity.setMonthId(dimId.getMonthId());
entity.setDateId(dimId.getDateId());
entity.setProjectId(process.getProjectId());
entity.setOperationUserId(process.getStaffId());
entity.setActionCode(process.getOperation());
entity.setIsActive(NumConstant.ONE);
entity.setPids(process.getPids());
if (StringUtils.isNotBlank(process.getDepartmentId())) {
entity.setOrgType("department");
entity.setOrgId(process.getDepartmentId());
entity.setPid(process.getAgencyId());
} else if (StringUtils.isNotBlank(process.getGridId())) {
entity.setOrgType("grid");
entity.setOrgId(process.getGridId());
entity.setPid(process.getAgencyId());
} else {
if (!process.getPids().contains(StrConstant.COLON)) {
entity.setPids("");
entity.setPid(NumConstant.ZERO_STR);
} else {
String[] orgArray = process.getPids().split(StrConstant.COLON);
if (orgArray.length > NumConstant.ONE) {
entity.setPid(orgArray[orgArray.length - NumConstant.TWO]);
String path = process.getPids().replaceAll(process.getAgencyId(), "");
if (path.endsWith(StrConstant.COLON)) {
path = path.substring(NumConstant.ZERO, path.length() - NumConstant.ONE);
}
entity.setPids(path);
} else {
log.warn("【data-statistical】业务数据抽取模块,ProjectExtractServiceImpl.saveOriginProjectDaily:查询出的项目节点发起人所属的orgIdPath不正确,agencyId->{},orgIdPath->{}", process.getAgencyId(), process.getPids());
entity.setPid(NumConstant.ZERO_STR);
entity.setPids("");
}
}
}
return entity;
}).collect(Collectors.toList()));
}
//项目评论人
List<ProcessInfoDTO> satisfactionRecordList = projectProcessService.getSatisfactionRecord(customerId, dateString);
satisfactionRecordList.forEach(log -> mainList.stream().filter(project -> log.getProjectId().equals(project.getId())).forEach(main -> {
//进行满意度评价的居民的所属机关的父机机关信息
log.setPid(main.getPid());
log.setPids(main.getPids());
}));
logList.addAll(satisfactionRecordList.stream().map(process -> {
}
//节点发起人 响应
List<ProcessInfoDTO> responseList = projectProcessService.getResponseProcessList(customerId, dateString);
if (!CollectionUtils.isEmpty(responseList)) {
logList.addAll(responseList.stream().map(process -> {
//获取日期相关维度
DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(process.getCreatedTime());
FactOriginProjectLogDailyEntity entity = new FactOriginProjectLogDailyEntity();
@ -317,67 +264,123 @@ public class ProjectExtractServiceImpl implements ProjectExtractService {
entity.setOperationUserId(process.getStaffId());
entity.setActionCode(process.getOperation());
entity.setIsActive(NumConstant.ONE);
entity.setOrgId(process.getGridId());
entity.setOrgType("grid");
entity.setPids(process.getPids());
entity.setPid(process.getPid());
return entity;
}).collect(Collectors.toList()));
//节点接收人
List<ProcessInfoDTO> processStaffList = projectProcessService.getProcessStaffByCustomer(customerId, dateString);
logList.addAll(processStaffList.stream().map(process -> {
//获取日期相关维度
DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(process.getCreatedTime());
FactOriginProjectLogDailyEntity entity = new FactOriginProjectLogDailyEntity();
entity.setCustomerId(customerId);
entity.setAgencyId(process.getAgencyId());
entity.setYearId(dimId.getYearId());
entity.setQuarterId(dimId.getQuarterId());
entity.setMonthId(dimId.getMonthId());
entity.setDateId(dimId.getDateId());
entity.setProjectId(process.getProjectId());
entity.setOperationUserId(process.getStaffId());
entity.setActionCode(process.getOperation());
entity.setIsActive(NumConstant.ZERO);
entity.setPids(process.getPids());
if (StringUtils.isNotBlank(process.getDepartmentId())) {
entity.setOrgType("department");
entity.setOrgType(OrgTypeConstant.DEPARTMENT);
entity.setOrgId(process.getDepartmentId());
entity.setPid(process.getAgencyId());
}else if (StringUtils.isNotBlank(process.getGridId())) {
entity.setOrgType("grid");
} else if (StringUtils.isNotBlank(process.getGridId())) {
entity.setOrgType(OrgTypeConstant.GRID);
entity.setOrgId(process.getGridId());
entity.setPid(process.getAgencyId());
}else{
if(!process.getPids().contains(StrConstant.COLON)){
} else {
if (!process.getPids().contains(StrConstant.COLON)) {
entity.setPids("");
entity.setPid(NumConstant.ZERO_STR);
}else{
} else {
String[] orgArray = process.getPids().split(StrConstant.COLON);
if(orgArray.length > NumConstant.ONE){
if (orgArray.length > NumConstant.ONE) {
entity.setPid(orgArray[orgArray.length - NumConstant.TWO]);
String path = process.getPids().replaceAll(process.getAgencyId(),"");
if(path.endsWith(StrConstant.COLON)){
path =path.substring(NumConstant.ZERO,path.length() - NumConstant.ONE);
String path = process.getPids().replaceAll(process.getAgencyId(), "");
if (path.endsWith(StrConstant.COLON)) {
path = path.substring(NumConstant.ZERO, path.length() - NumConstant.ONE);
}
entity.setPids(path);
}else{
log.warn("【data-statistical】业务数据抽取模块,ProjectExtractServiceImpl.saveOriginProjectDaily:查询出的项目节点发起人所属的orgIdPath不正确,agencyId->{},orgIdPath->{}",process.getAgencyId(),process.getPids());
} else {
log.warn("【data-statistical】业务数据抽取模块,ProjectExtractServiceImpl.saveOriginProjectDaily:查询出的项目节点发起人所属的orgIdPath不正确,agencyId->{},orgIdPath->{}", process.getAgencyId(), process.getPids());
entity.setPid(NumConstant.ZERO_STR);
entity.setPids("");
}
}
}
return entity;
}).collect(Collectors.toList()));
}
if (!logList.isEmpty()) {
factOriginProjectLogDailyService.deleteByDate(customerId, dateString);
factOriginProjectLogDailyService.insertBatch(logList);
//项目评论人
List<ProcessInfoDTO> satisfactionRecordList = projectProcessService.getSatisfactionRecord(customerId, dateString);
satisfactionRecordList.forEach(log -> mainList.stream().filter(project -> log.getProjectId().equals(project.getId())).forEach(main -> {
//进行满意度评价的居民的所属机关的父机机关信息
log.setPid(main.getPid());
log.setPids(main.getPids());
}));
logList.addAll(satisfactionRecordList.stream().map(process -> {
//获取日期相关维度
DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(process.getCreatedTime());
FactOriginProjectLogDailyEntity entity = new FactOriginProjectLogDailyEntity();
entity.setCustomerId(customerId);
entity.setAgencyId(process.getAgencyId());
entity.setYearId(dimId.getYearId());
entity.setQuarterId(dimId.getQuarterId());
entity.setMonthId(dimId.getMonthId());
entity.setDateId(dimId.getDateId());
entity.setProjectId(process.getProjectId());
entity.setOperationUserId(process.getStaffId());
entity.setActionCode(process.getOperation());
entity.setIsActive(NumConstant.ONE);
entity.setOrgId(process.getGridId());
entity.setOrgType(OrgTypeConstant.GRID);
entity.setPids(process.getPids());
entity.setPid(process.getPid());
return entity;
}).collect(Collectors.toList()));
//节点接收人
List<ProcessInfoDTO> processStaffList = projectProcessService.getProcessStaffByCustomer(customerId, dateString);
logList.addAll(processStaffList.stream().map(process -> {
//获取日期相关维度
DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(process.getCreatedTime());
FactOriginProjectLogDailyEntity entity = new FactOriginProjectLogDailyEntity();
entity.setCustomerId(customerId);
entity.setAgencyId(process.getAgencyId());
entity.setYearId(dimId.getYearId());
entity.setQuarterId(dimId.getQuarterId());
entity.setMonthId(dimId.getMonthId());
entity.setDateId(dimId.getDateId());
entity.setProjectId(process.getProjectId());
entity.setOperationUserId(process.getStaffId());
entity.setActionCode(process.getOperation());
entity.setIsActive(NumConstant.ZERO);
entity.setPids(process.getPids());
if (StringUtils.isNotBlank(process.getDepartmentId())) {
entity.setOrgType(OrgTypeConstant.DEPARTMENT);
entity.setOrgId(process.getDepartmentId());
entity.setPid(process.getAgencyId());
}else if (StringUtils.isNotBlank(process.getGridId())) {
entity.setOrgType(OrgTypeConstant.GRID);
entity.setOrgId(process.getGridId());
entity.setPid(process.getAgencyId());
}else{
if(!process.getPids().contains(StrConstant.COLON)){
entity.setPids("");
entity.setPid(NumConstant.ZERO_STR);
}else{
String[] orgArray = process.getPids().split(StrConstant.COLON);
if(orgArray.length > NumConstant.ONE){
entity.setPid(orgArray[orgArray.length - NumConstant.TWO]);
String path = process.getPids().replaceAll(process.getAgencyId(),"");
if(path.endsWith(StrConstant.COLON)){
path =path.substring(NumConstant.ZERO,path.length() - NumConstant.ONE);
}
entity.setPids(path);
}else{
log.warn("【data-statistical】业务数据抽取模块,ProjectExtractServiceImpl.saveOriginProjectDaily:查询出的项目节点发起人所属的orgIdPath不正确,agencyId->{},orgIdPath->{}",process.getAgencyId(),process.getPids());
entity.setPid(NumConstant.ZERO_STR);
entity.setPids("");
}
}
}
return entity;
}).collect(Collectors.toList()));
if (!logList.isEmpty()) {
factOriginProjectLogDailyService.deleteByDate(customerId, dateString);
factOriginProjectLogDailyService.insertBatch(logList);
}
}
/**
@ -404,21 +407,21 @@ public class ProjectExtractServiceImpl implements ProjectExtractService {
dest.setOrgType("dept");
dest.setPid(original.getOrgId());
dest.setPids(original.getOrgIdPath());
}else if(StringUtils.isNotBlank(original.getGridId())){
dest.setOrgType("grid");
}else if(StringUtils.isNotBlank(original.getGridId())) {
dest.setOrgType(OrgTypeConstant.GRID);
dest.setPid(original.getOrgId());
dest.setPids(original.getOrgIdPath());
}else{
dest.setOrgType("agency");
}else {
dest.setOrgType(OrgTypeConstant.AGENCY);
dest.setPids("");
String[] array = original.getOrgIdPath().split(StrConstant.COLON);
if(array.length <= NumConstant.ZERO){
if (array.length <= NumConstant.ZERO) {
dest.setPid(NumConstant.ZERO_STR);
}
if(array[NumConstant.ZERO].equals(original.getOrgId()) && array.length == NumConstant.ONE){
if (array[NumConstant.ZERO].equals(original.getOrgId()) && array.length == NumConstant.ONE) {
dest.setPid(NumConstant.ZERO_STR);
}
if(array.length > NumConstant.ONE && original.getOrgId().equals(array[array.length - NumConstant.ONE])){
if (array.length > NumConstant.ONE && original.getOrgId().equals(array[array.length - NumConstant.ONE])) {
dest.setPid(array[array.length - NumConstant.TWO]);
dest.setPids(original.getOrgIdPath().replace(original.getOrgId(),""));
}
@ -456,7 +459,7 @@ public class ProjectExtractServiceImpl implements ProjectExtractService {
*/
private Integer getDetentionDays(String id, Date startDate, Date endDate) {
int result;
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
SimpleDateFormat format = new SimpleDateFormat(DateUtils.DATE_PATTERN_YYYYMMDD);
List<WorkDayFormDTO> list = new ArrayList<>();
WorkDayFormDTO workDayFormDTO = new WorkDayFormDTO();

13
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java

@ -21,6 +21,7 @@ package com.epmet.service.evaluationindex.screen;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.dto.extract.form.*;
import com.epmet.dto.extract.result.GridInfoResultDTO;
import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity;
import com.epmet.entity.org.CustomerGridEntity;
@ -75,10 +76,20 @@ public interface ScreenCustomerGridService extends BaseService<ScreenCustomerGri
List<PartyAbilityGridMonthlyFormDTO> selectAllGridInfoToParty(String customerId);
/**
* @Description 查询全部网格信息
* @param customerId
* @Description 查询全部网格信息
* @author zxc
* @date 2020/9/18 10:47 上午
*/
List<GovernAbilityGridMonthlyFormDTO> selectAllGridInfo(String customerId);
/**
* desc: 初始化客户的业务组织关系
*
* @param formDTO
* @return java.lang.Boolean
* @author LiuJanJun
* @date 2020/10/21 2:33 下午
*/
Boolean initBizOrg(CustomerBizOrgFormDTO formDTO);
}

13
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ShiBeiScreenCollService.java

@ -1,8 +1,7 @@
package com.epmet.service.evaluationindex.screen;
import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO;
import com.epmet.dto.screencoll.form.*;
import java.util.List;
/**
* 大屏数据采集api
*
@ -231,4 +230,14 @@ public interface ShiBeiScreenCollService {
* @Date 09:44 2020-08-25
**/
void insertPublicPartiTotalData(PublicPartiTotalDataListFormDTO formDTO, String customerId);
/**
* desc: 初始化客户业务组织关系表
*
* @param formDTO
* @return java.lang.Integer
* @author LiuJanJun
* @date 2020/10/21 2:38 下午
*/
Integer initBizOrg(CustomerBizOrgFormDTO formDTO);
}

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

@ -39,6 +39,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.*;
import java.util.stream.Collectors;
@ -131,6 +132,12 @@ public class ScreenCustomerAgencyServiceImpl implements ScreenCustomerAgencyServ
exists.setLevel(e.getLevel());
exists.setDataEndTime(dateEndTime);
exists.setAreaCode(e.getAreaCode());
//如果没有区划 则默认暂时不显示
if (StringUtils.isEmpty(e.getAreaCode())) {
exists.setIsDisplay(NumConstant.ZERO_STR);
} else {
exists.setIsDisplay(NumConstant.ONE_STR);
}
exists.setAllParentNames(e.getAllParentName());
updateAgency(exists);
}
@ -221,6 +228,12 @@ public class ScreenCustomerAgencyServiceImpl implements ScreenCustomerAgencyServ
cae.setAllParentNames(e.getAllParentName());
cae.setAreaCode(e.getAreaCode());
//cae.setAreaMarks(e);
//如果没有区划 则默认暂时不显示
if (StringUtils.isEmpty(e.getAreaCode())) {
cae.setIsDisplay(NumConstant.ZERO_STR);
} else {
cae.setIsDisplay(NumConstant.ONE_STR);
}
cae.setCustomerId(e.getCustomerId());
cae.setDataEndTime(dateEndTime);
cae.setLevel(e.getLevel());

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

@ -26,10 +26,10 @@ import com.epmet.constant.OrgSourceTypeConstant;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerGridDao;
import com.epmet.dto.extract.form.*;
import com.epmet.dto.extract.result.GridInfoResultDTO;
import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity;
import com.epmet.entity.org.CustomerGridEntity;
import com.epmet.service.evaluationindex.screen.ScreenCustomerGridService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -150,8 +150,8 @@ public class ScreenCustomerGridServiceImpl extends BaseServiceImpl<ScreenCustome
}
/**
* @Description 查询全部网格信息
* @param customerId
* @Description 查询全部网格信息
* @author zxc
* @date 2020/9/18 10:47 上午
*/
@ -159,4 +159,9 @@ public class ScreenCustomerGridServiceImpl extends BaseServiceImpl<ScreenCustome
public List<GovernAbilityGridMonthlyFormDTO> selectAllGridInfo(String customerId) {
return screenCustomerGridDao.selectAllGridInfo(customerId);
}
@Override
public Boolean initBizOrg(CustomerBizOrgFormDTO formDTO) {
return null;
}
}

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

@ -17,17 +17,20 @@
package com.epmet.service.evaluationindex.screen.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
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.validator.ValidatorUtils;
import com.epmet.constant.CompareConstant;
import com.epmet.constant.DataSourceConstant;
import com.epmet.constant.IndexCalConstant;
import com.epmet.dao.evaluationindex.screen.*;
import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO;
import com.epmet.dto.screencoll.form.*;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerBizOrgEntity;
import com.epmet.entity.evaluationindex.screen.ScreenEventImgDataEntity;
import com.epmet.entity.evaluationindex.screen.ScreenUserJoinEntity;
import com.epmet.service.evaluationindex.screen.ShiBeiScreenCollService;
@ -40,7 +43,6 @@ import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
@ -54,9 +56,9 @@ import java.util.stream.Collectors;
@DataSource(DataSourceConstant.EVALUATION_INDEX)
public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
@Autowired
private ScreenPartyUserRankDataDao screenPartyUserRankDataDao;
@Autowired
@Autowired
private ScreenPartyUserRankDataDao screenPartyUserRankDataDao;
@Autowired
private ScreenPartyLinkMassesDataDao screenPartyLinkMassesDataDao;
@Autowired
private ScreenPartyBranchDataDao screenPartyBranchDataDao;
@ -81,6 +83,8 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
@Autowired
private ScreenCustomerAgencyDao screenCustomerAgencyDao;
@Autowired
private ScreenCustomerBizOrgDao screenCustomerBizOrgDao;
@Autowired
private ScreenUserTotalDataDao screenUserTotalDataDao;
@Autowired
private ScreenUserJoinDao screenUserJoinDao;
@ -94,7 +98,7 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
@Transactional(rollbackFor = Exception.class)
public void insertPartyUserRankData(PartyUserRankDataListFormDTO formDTO,String customerId) {
public void insertPartyUserRankData(PartyUserRankDataListFormDTO formDTO, String customerId) {
if (formDTO.getIsFirst()) {
int deleteNum;
do {
@ -187,7 +191,7 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
if (null != formDTO.getDataList().get(i).getImgDataList() && formDTO.getDataList().get(i).getImgDataList().size() > NumConstant.ZERO) {
// 根据原始事件ID,物理删除 - 事件数据图片数据
events[i] = formDTO.getDataList().get(i).getEventId();
for (int j = NumConstant.ZERO; j < formDTO.getDataList().get(i).getImgDataList().size(); j++){
for (int j = NumConstant.ZERO; j < formDTO.getDataList().get(i).getImgDataList().size(); j++) {
// 新增 中央区-事件数据图片数据 表
ScreenEventImgDataEntity imgDataEntity = new ScreenEventImgDataEntity();
imgDataEntity.setEventId(formDTO.getDataList().get(i).getImgDataList().get(j).getEventId());
@ -198,7 +202,7 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
}
}
}
if (isImgUrl){
if (isImgUrl) {
screenEventImgDataDao.delEventImgDataByEvent(events);
screenEventImgDataDao.batchInsertEventImgData(eventImgDataList);
}
@ -210,11 +214,11 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
@Override
@Transactional(rollbackFor = Exception.class)
public void insertDifficultyData(DifficultyDataFormDTO formDTO, String customerId) {
if(formDTO.getIsFirst()){
if (formDTO.getIsFirst()) {
//直接删除当前客户下所有的数据
screenDifficultyDataDao.deleteDifficultyData(customerId);
}
if (null != formDTO && !CollectionUtils.isEmpty(formDTO.getDataList())){
if (null != formDTO && !CollectionUtils.isEmpty(formDTO.getDataList())) {
screenDifficultyDataDao.batchInsertDifficultyData(formDTO.getDataList(), customerId);
}
}
@ -309,9 +313,9 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
}
if (!CollectionUtils.isEmpty(formDTO.getDataList())) {
List<CustomerAgencyFormDTO> pidIsZeroList = formDTO.getDataList().stream().filter(d -> d.getPid().equals(NumConstant.ZERO_STR) || "".equals(d.getPid())).collect(Collectors.toList());
if (pidIsZeroList.size()>NumConstant.ONE){
if (pidIsZeroList.size() > NumConstant.ONE) {
Object o = JSONObject.toJSON(pidIsZeroList);
throw new RenException("多个pid为【0】的数据:"+o.toString());
throw new RenException("多个pid为【0】的数据:" + o.toString());
}
screenCustomerAgencyDao.batchInsertCustomerAgency(formDTO.getDataList(), customerId);
}
@ -343,9 +347,9 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
} while (deleteNum != NumConstant.ZERO);
}
if (!CollectionUtils.isEmpty(formDTO.getDataList())) {
if (formDTO.getDataList().size() > NumConstant.ZERO){
if (formDTO.getDataList().size() > NumConstant.ZERO) {
String[] orgIds = new String[formDTO.getDataList().size()];
for (int i = NumConstant.ZERO; i < formDTO.getDataList().size(); i++){
for (int i = NumConstant.ZERO; i < formDTO.getDataList().size(); i++) {
orgIds[i] = formDTO.getDataList().get(i).getOrgId();
}
@ -360,11 +364,11 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
// 定义本月待添加数据的集合
List<ScreenUserJoinEntity> curMonthJoinEntityList = new ArrayList<>();
// 增加率计算
if (null != lastMonthJoinList && lastMonthJoinList.size() > NumConstant.ZERO){
if (null != lastMonthJoinList && lastMonthJoinList.size() > NumConstant.ZERO) {
// 存在上个月的数据 (本月-上月)/上月 *100
for (int i = NumConstant.ZERO; i < formDTO.getDataList().size(); i++){
for (int j = NumConstant.ZERO; j < lastMonthJoinList.size(); j++){
if (formDTO.getDataList().get(i).getOrgId().equals(lastMonthJoinList.get(j).getOrgId())){
for (int i = NumConstant.ZERO; i < formDTO.getDataList().size(); i++) {
for (int j = NumConstant.ZERO; j < lastMonthJoinList.size(); j++) {
if (formDTO.getDataList().get(i).getOrgId().equals(lastMonthJoinList.get(j).getOrgId())) {
ScreenUserJoinEntity entity = ConvertUtils.sourceToTarget(formDTO.getDataList().get(i), ScreenUserJoinEntity.class);
entity.setJoinTotalUpRate(this.calculateGrowthRateNumber(lastMonthJoinList.get(i).getJoinTotal(), formDTO.getDataList().get(j).getJoinTotal()));
entity.setJoinTotalUpFlag(this.calculateGrowthRateFlag(lastMonthJoinList.get(i).getJoinTotal(), formDTO.getDataList().get(j).getJoinTotal()));
@ -380,8 +384,8 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
// 计算增长率后的 待新增数据
BigDecimal zero = new BigDecimal(NumConstant.ZERO);
// 不存在上个月的数据
for (int i = NumConstant.ZERO; i < formDTO.getDataList().size(); i++){
ScreenUserJoinEntity entity = ConvertUtils.sourceToTarget(formDTO.getDataList().get(i), ScreenUserJoinEntity.class);
for (int i = NumConstant.ZERO; i < formDTO.getDataList().size(); i++) {
ScreenUserJoinEntity entity = ConvertUtils.sourceToTarget(formDTO.getDataList().get(i), ScreenUserJoinEntity.class);
entity.setJoinTotalUpRate(zero);
entity.setJoinTotalUpFlag("");
entity.setAvgIssueUpRate(zero);
@ -396,14 +400,37 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
}
}
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
@Transactional(rollbackFor = Exception.class)
public Integer initBizOrg(CustomerBizOrgFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
List<ScreenCustomerAgencyEntity> entityList = screenCustomerAgencyDao.selectListAgencyInfo(formDTO.getCustomerId());
List<ScreenCustomerBizOrgEntity> list = new ArrayList<>();
if (CollectionUtils.isEmpty(entityList)) {
return 0;
}
entityList.forEach(o -> {
ScreenCustomerBizOrgEntity entity = new ScreenCustomerBizOrgEntity();
entity.setCustomerId(o.getCustomerId());
entity.setOrgId(o.getAgencyId());
entity.setBizType(formDTO.getBizType());
list.add(entity);
});
screenCustomerBizOrgDao.deleteByBizType(formDTO);
return screenCustomerBizOrgDao.batchInsert(list);
}
/**
* 获取当前日期的前一个月的日期
*
* @param
* @return java.lang.String[]
* @Author zhangyong
* @Date 15:33 2020-08-21
**/
private String[] lastMonthDate(){
private String[] lastMonthDate() {
String[] date = new String[NumConstant.TWO];
//Java获取当前日期的前一个月的日期
Calendar calendar = Calendar.getInstance();
@ -411,8 +438,9 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + NumConstant.ONE;
date[NumConstant.ZERO] = String.valueOf(year);
date[NumConstant.ONE] = String.valueOf(month);;
if (NumConstant.TEN >= month){
date[NumConstant.ONE] = String.valueOf(month);
;
if (NumConstant.TEN >= month) {
date[NumConstant.ONE] = NumConstant.ZERO_STR + month;
}
return date;
@ -421,8 +449,8 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
/**
* 计算 本月数值 相较于 上月数值的增长率
*
* @param old 上月数值
* @param now 本月数值
* @param old 上月数值
* @param now 本月数值
* @return java.math.BigDecimal
* @Author zhangyong
* @Date 15:38 2020-08-21
@ -459,8 +487,8 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
/**
* 计算 本月数值 相较于 上月数值的增长率 得出标识
*
* @param old 上月数值
* @param now 本月数值
* @param old 上月数值
* @param now 本月数值
* @return java.util.String
* @Author zhangyong
* @Date 15:38 2020-08-21

65
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerPartymemberServiceImpl.java

@ -41,6 +41,7 @@ import com.epmet.service.partymember.PartyMemberService;
import com.epmet.service.stats.DimCustomerPartymemberService;
import com.epmet.service.stats.DimCustomerService;
import com.epmet.service.stats.DimGridService;
import com.epmet.util.DimIdGenerator;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
@ -49,10 +50,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -134,32 +132,49 @@ public class DimCustomerPartymemberServiceImpl extends BaseServiceImpl<DimCustom
*/
@Override
public Boolean statsPartyMember(CustomerIdAndDateIdFormDTO customerIdAndDateIdFormDTO) {
List<String> allCustomerId = dimCustomerService.getAllCustomerId();
if (CollectionUtils.isEmpty(allCustomerId)){
String customerIdOne = customerIdAndDateIdFormDTO.getCustomerId();
List<String> customerIds = new ArrayList<>();
List<String> dateIds = new ArrayList<>();
if (StringUtils.isNotBlank(customerIdOne)){
customerIds.add(customerIdOne);
}else {
customerIds = dimCustomerService.getAllCustomerId();
}
if (CollectionUtils.isEmpty(customerIds)){
throw new RenException(StatsConstant.CUSTOMER_INFO_NULL);
}
allCustomerId.forEach(customerId -> {
String dateId = customerIdAndDateIdFormDTO.getDateId();
List<DimCustomerPartyMemberFormDTO> partyMemberList = partyMemberService.selectPartyMemberInfo(customerId, dateId);
if (CollectionUtils.isEmpty(partyMemberList)){
log.warn(String.format(StatsConstant.PARTY_INFO_LIST,customerId));
return;
if ((StringUtils.isBlank(customerIdAndDateIdFormDTO.getStartDate()) && StringUtils.isBlank(customerIdAndDateIdFormDTO.getEndDate()))){
if (StringUtils.isNotBlank(customerIdAndDateIdFormDTO.getDateId())){
dateIds.add(customerIdAndDateIdFormDTO.getDateId());
}else {
dateIds.add(DimIdGenerator.getDateDimId(DateUtils.addDateDays(new Date(), -1)));
}
List<String> gridIds = partyMemberList.stream().map(party -> party.getGridId()).distinct().collect(Collectors.toList());
List<GridBelongAgencyResultDTO> agencyInfos = dimGridService.selectGridBelongAgencyInfo(gridIds);
TimeListResultDTO timeList = DateUtils.getTimeList(dateId);
partyMemberList.forEach(party -> {
BeanUtils.copyProperties(timeList,party);
agencyInfos.forEach(agency -> {
if (party.getGridId().equals(agency.getGridId())){
party.setAgencyId(agency.getAgencyId());
party.setParentId(agency.getParentId());
party.setPids(agency.getPids());
}
}else {
dateIds = DateUtils.getDaysBetween(customerIdAndDateIdFormDTO.getStartDate(), customerIdAndDateIdFormDTO.getEndDate());
}
List<String> finalDateIds = dateIds;
customerIds.forEach(customerId -> {
finalDateIds.forEach(dateId -> {
List<DimCustomerPartyMemberFormDTO> partyMemberList = partyMemberService.selectPartyMemberInfo(customerId, dateId);
if (CollectionUtils.isEmpty(partyMemberList)){
log.warn(String.format(StatsConstant.PARTY_INFO_LIST,customerId));
return;
}
List<String> gridIds = partyMemberList.stream().map(party -> party.getGridId()).distinct().collect(Collectors.toList());
List<GridBelongAgencyResultDTO> agencyInfos = dimGridService.selectGridBelongAgencyInfo(gridIds);
TimeListResultDTO timeList = DateUtils.getTimeList(dateId);
partyMemberList.forEach(party -> {
BeanUtils.copyProperties(timeList,party);
agencyInfos.forEach(agency -> {
if (party.getGridId().equals(agency.getGridId())){
party.setAgencyId(agency.getAgencyId());
party.setParentId(agency.getParentId());
party.setPids(agency.getPids());
}
});
});
delAndInsertParty(partyMemberList,customerId,dateId);
});
delAndInsertParty(partyMemberList,customerId,dateId);
});
return true;
}

1
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml

@ -80,6 +80,7 @@
<select id="selectListAgencyInfo" parameterType="map" resultType="com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity">
SELECT
CUSTOMER_ID,
AGENCY_ID agencyId,
AGENCY_NAME agencyName,
PIDS pids

39
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerBizOrgDao.xml

@ -0,0 +1,39 @@
<?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.ScreenCustomerBizOrgDao">
<delete id="deleteByBizType">
delete from screen_customer_biz_org
where CUSTOMER_ID = #{customerId}
and BIZ_TYPE = #{bizType,jdbcType=VARCHAR}
</delete>
<insert id="batchInsert">
insert into screen_customer_biz_org
(
ID,
CUSTOMER_ID,
ORG_ID,
BIZ_TYPE,
DEL_FLAG,
REVISION,
CREATED_BY,
CREATED_TIME,
UPDATED_BY,
UPDATED_TIME
) values
<foreach collection="list" item="item" separator=",">
(
(SELECT REPLACE(UUID(), '-', '') AS id),
#{item.customerId},
#{item.orgId},
#{item.bizType},
0,
0,
'APP_USER',
now(),
'APP_USER',
now()
)
</foreach>
</insert>
</mapper>

13
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/GetJwtAccessTokenFormDTO.java

@ -0,0 +1,13 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class GetJwtAccessTokenFormDTO {
@NotBlank(message = "AppId不能为空")
private String appId;
}

32
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/AppIdInfoResultDTO.java

@ -0,0 +1,32 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/10/21 5:30 下午
*/
@Data
public class AppIdInfoResultDTO implements Serializable {
private static final long serialVersionUID = 4556971930323763712L;
/**
* 应用ID
*/
private String appId;
/**
* 客户ID
*/
private String customerId;
/**
* 密钥
*/
private String secret;
private String accessToken;
}

16
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/GetJwtAccessTokenResultDTO.java

@ -0,0 +1,16 @@
package com.epmet.dto.result;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class GetJwtAccessTokenResultDTO {
private String customerId;
private String token;
private Long ts;
}

18
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java

@ -3,7 +3,9 @@ package com.epmet.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.ExternalAppAuthFormDTO;
import com.epmet.dto.form.GetJwtAccessTokenFormDTO;
import com.epmet.dto.form.WorkDayFormDTO;
import com.epmet.dto.result.AppIdInfoResultDTO;
import com.epmet.dto.result.ExternalAppAuthResultDTO;
import com.epmet.dto.result.WorkDayResultDTO;
import com.epmet.feign.fallback.EpmetCommonServiceOpenFeignClientFallback;
@ -19,8 +21,8 @@ import java.util.List;
* @author yinzuomei@elink-cn.com
* @date 2020/6/4 10:28
*/
@FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallback = EpmetCommonServiceOpenFeignClientFallback.class)
//@FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallback = EpmetCommonServiceOpenFeignClientFallback.class, url = "http://localhost:8103")
//@FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallback = EpmetCommonServiceOpenFeignClientFallback.class)
@FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallback = EpmetCommonServiceOpenFeignClientFallback.class, url = "localhost:8103")
public interface EpmetCommonServiceOpenFeignClient {
/**
* @param formDTO
@ -53,4 +55,16 @@ public interface EpmetCommonServiceOpenFeignClient {
*/
@PostMapping("/commonservice/externalapp/get-secret")
Result getSecret(@RequestBody String appId);
/**
* @Description 获取AccessToken
* @return Result
* @author wxz
* @date 2020.10.22 10:19
*/
@PostMapping("/commonservice/externalapp/get-jwt-accesstoken")
Result getAccessToken(@RequestBody GetJwtAccessTokenFormDTO form);
@PostMapping("/commonservice/externalapp/appidinfo")
Result<AppIdInfoResultDTO> appIdInfo(@RequestBody String appId);
}

12
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java

@ -4,7 +4,9 @@ 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.form.ExternalAppAuthFormDTO;
import com.epmet.dto.form.GetJwtAccessTokenFormDTO;
import com.epmet.dto.form.WorkDayFormDTO;
import com.epmet.dto.result.AppIdInfoResultDTO;
import com.epmet.dto.result.ExternalAppAuthResultDTO;
import com.epmet.dto.result.WorkDayResultDTO;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
@ -39,4 +41,14 @@ public class EpmetCommonServiceOpenFeignClientFallback implements EpmetCommonSer
public Result getSecret(String appId) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "getSecret", appId);
}
@Override
public Result<AppIdInfoResultDTO> appIdInfo(String appId) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "appIdInfo", appId);
}
@Override
public Result getAccessToken(GetJwtAccessTokenFormDTO form) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "getAccessToken", form);
}
}

27
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalAppController.java

@ -8,8 +8,11 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.ExternalAppAuthFormDTO;
import com.epmet.dto.form.ExternalAppFormDTO;
import com.epmet.dto.form.GetJwtAccessTokenFormDTO;
import com.epmet.dto.result.AppIdInfoResultDTO;
import com.epmet.dto.result.ExternalAppAuthResultDTO;
import com.epmet.dto.result.ExternalAppResultDTO;
import com.epmet.dto.result.GetJwtAccessTokenResultDTO;
import com.epmet.service.ExternalAppAuthService;
import com.epmet.service.ExternalAppSecretService;
import com.epmet.service.ExternalAppService;
@ -17,10 +20,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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;
@ -146,4 +146,23 @@ public class ExternalAppController {
return new Result().ok(secret);
}
/**
* @Description 获取AccessToken
* @return Result
* @author wxz
* @date 2020.10.22 10:19
*/
@PostMapping("get-jwt-accesstoken")
public Result getAccessToken(@RequestBody GetJwtAccessTokenFormDTO form) {
ValidatorUtils.validateEntity(form);
String appId = form.getAppId();
GetJwtAccessTokenResultDTO jwtAccessToken = externalAppService.getJwtAccessToken(appId);
return new Result().ok(jwtAccessToken);
}
@PostMapping("appidinfo")
public Result<AppIdInfoResultDTO> appIdInfo(@RequestBody String appId){
return new Result<AppIdInfoResultDTO>().ok(externalAppService.appIdInfo(appId));
}
}

9
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalAppDao.java

@ -18,6 +18,7 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.result.AppIdInfoResultDTO;
import com.epmet.dto.result.ExternalAppResultDTO;
import com.epmet.entity.ExternalAppEntity;
import org.apache.ibatis.annotations.Mapper;
@ -41,4 +42,12 @@ public interface ExternalAppDao extends BaseDao<ExternalAppEntity> {
List<ExternalAppResultDTO> list(@Param("customerId") String customerId);
List<String> getCustomerIds();
/**
* @Description 根据appId查询客户ID和密钥
* @Param appId
* @author zxc
* @date 2020/10/21 5:50 下午
*/
AppIdInfoResultDTO appIdInfo(@Param("appId")String appId);
}

6
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalAppService.java

@ -18,7 +18,9 @@
package com.epmet.service;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.result.AppIdInfoResultDTO;
import com.epmet.dto.result.ExternalAppResultDTO;
import com.epmet.dto.result.GetJwtAccessTokenResultDTO;
import java.util.List;
@ -38,4 +40,8 @@ public interface ExternalAppService {
List<String> getCustomerIds();
String resetSecret(String appId);
GetJwtAccessTokenResultDTO getJwtAccessToken(String appId);
AppIdInfoResultDTO appIdInfo(String appId);
}

28
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppServiceImpl.java

@ -27,12 +27,15 @@ import com.epmet.dao.ExternalAppDao;
import com.epmet.dao.ExternalAppSecretDao;
import com.epmet.dao.ExternalCustomerDao;
import com.epmet.dto.CustomerDTO;
import com.epmet.dto.result.AppIdInfoResultDTO;
import com.epmet.dto.result.ExternalAppResultDTO;
import com.epmet.dto.result.GetJwtAccessTokenResultDTO;
import com.epmet.entity.ExternalAppEntity;
import com.epmet.entity.ExternalAppSecretEntity;
import com.epmet.enu.CustomerTypeEnum;
import com.epmet.feign.OperCrmOpenFeignClient;
import com.epmet.service.ExternalAppService;
import com.epmet.utils.externalapp.ExtAppJwtTokenUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
@ -41,6 +44,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
@ -70,6 +74,9 @@ public class ExternalAppServiceImpl implements ExternalAppService {
@Autowired
private RedisUtils redisUtils;
@Autowired
private ExtAppJwtTokenUtils tokenUtils;
@Transactional
@Override
public ExternalAppResultDTO add(String appName, String customerId, String customerType) {
@ -197,4 +204,25 @@ public class ExternalAppServiceImpl implements ExternalAppService {
return null;
}
@Override
public GetJwtAccessTokenResultDTO getJwtAccessToken(String appId) {
ExternalAppEntity externalAppEntity = externalAppDao.selectById(appId);
String customerId = externalAppEntity.getCustomerId();
String secret = externalAppSecretDao.getSecretByAppId(appId);
long ts = System.currentTimeMillis();
String token = tokenUtils.genToken(secret, appId, customerId, ts);
return new GetJwtAccessTokenResultDTO(customerId, token, ts);
}
@Override
public AppIdInfoResultDTO appIdInfo(String appId) {
AppIdInfoResultDTO appIdInfoResultDTO = externalAppDao.appIdInfo(appId);
if (null == appIdInfoResultDTO){
throw new RenException("没查到对应appId【"+appId+"】的信息");
}
String accessToken = tokenUtils.genToken(appIdInfoResultDTO.getSecret(), appId, appIdInfoResultDTO.getCustomerId(), System.currentTimeMillis());
appIdInfoResultDTO.setAccessToken(accessToken);
return appIdInfoResultDTO;
}
}

36
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/externalapp/ExtAppJwtTokenUtils.java

@ -49,7 +49,7 @@ public class ExtAppJwtTokenUtils {
}
}
public String createToken(Map<String, Object> map, String secret) {
private String createToken(Map<String, Object> map, String secret) {
return Jwts.builder()
.setHeaderParam("typ", "JWT")
.setClaims(map)
@ -59,21 +59,7 @@ public class ExtAppJwtTokenUtils {
.compact();
}
// /**
// * token是否过期
// *
// * @return true:过期
// */
// public boolean isTokenExpired(Date expiration) {
// return expiration.before(new Date());
// }
public static void main(String[] args) {
genToken();
// getClaim();
}
public static void genToken() {
public static void genTestToken() {
HashMap<String, Object> claim = new HashMap<>();
//市北
//String secret = "612d304095c50369c3ef06e490f05779eeb8f19ff16566c73aeafafc5fa01970";
@ -89,21 +75,19 @@ public class ExtAppJwtTokenUtils {
String appId = "f358d63a89f3670c197c62ca4c3a0366";
String customrId = "45687aa479955f9d06204d415238f7cc";
claim.put("customerId", customrId);
claim.put("appId", appId);
long ts = System.currentTimeMillis() + 1000 * 60 * 1;
System.out.println("时间戳:" + ts);
claim.put("ts", ts);
String abc = new ExtAppJwtTokenUtils().createToken(claim, secret);
System.out.println(abc);
String token = new ExtAppJwtTokenUtils().genToken(secret, appId, customrId, ts);
System.out.println(token);
}
public static void getClaim() {
String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJhcHBJZCI6IjEiLCJjdXN0b21lcklkIjoiYzEiLCJpYXQiOjE1OTc3NDI2NTB9.09Vop0Nobg3LENAJoAZaCUKtgAjADAK48BS11ky3YdAp6h-cXYtGeqUxbgvE_4F6239rc7UE2fjxtEvMuWEJuA";
public String genToken(String secret, String appId, String customrId, Long ts) {
HashMap<String, Object> claim = new HashMap<>();
claim.put("customerId", customrId);
claim.put("appId", appId);
claim.put("ts", ts);
Claims claimByToken = new ExtAppJwtTokenUtils().getClaimByToken(token, "4a762660254c57996343f8ee42fbc0a6");
System.out.println(claimByToken);
return createToken(claim, secret);
}
}

14
epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppDao.xml

@ -66,5 +66,19 @@
SELECT CUSTOMER_ID FROM external_app WHERE DEL_FLAG = 0
</select>
<!-- 根据appId查询客户ID和密钥 -->
<select id="appIdInfo" resultType="com.epmet.dto.result.AppIdInfoResultDTO">
SELECT
ea.ID AS appId,
ea.CUSTOMER_ID,
eas.SECRET
FROM external_app ea
LEFT JOIN external_app_secret eas ON eas.APP_ID = ea.id
WHERE
ea.DEL_FLAG = 0
AND eas.DEL_FLAG = 0
AND ea.ID = #{appId}
</select>
</mapper>

16
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/DimPartyMemberServiceImpl.java

@ -1,7 +1,6 @@
package com.epmet.service.impl;
import com.alibaba.druid.util.StringUtils;
import com.epmet.commons.tools.constant.NumConstant;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO;
import com.epmet.feign.DataStatisticalOpenFeignClient;
@ -23,15 +22,8 @@ public class DimPartyMemberServiceImpl implements DimPartyMemberService {
@Override
public Result getPartyInfo(String dateId) {
CustomerIdAndDateIdFormDTO c = new CustomerIdAndDateIdFormDTO();
if (!StringUtils.isEmpty(dateId)) {
c.setDateId(dateId);
}else {
String now = LocalDate.now().minusDays(NumConstant.ONE).toString();
String concat = now.substring(NumConstant.ZERO, NumConstant.FOUR).concat(now.substring(NumConstant.FIVE, NumConstant.SEVEN)).concat(now.substring(NumConstant.EIGHT, NumConstant.TEN));
c.setDateId(concat);
}
return statsFeignClient.getPartyInfo(c);
public Result getPartyInfo(String form) {
CustomerIdAndDateIdFormDTO customerIdAndDateIdFormDTO = JSON.parseObject(form, CustomerIdAndDateIdFormDTO.class);
return statsFeignClient.getPartyInfo(customerIdAndDateIdFormDTO);
}
}

Loading…
Cancel
Save