Browse Source

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

dev_shibei_match
zxc 4 years ago
parent
commit
6b973e647e
  1. 6
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/project/dto/form/ProjectCategoryFormDTO.java
  2. 9
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/ScreenProjectController.java
  3. 6
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/ScreenProjectServiceImpl.java
  4. 102
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/ScreenProjectCategoryDTO.java
  5. 76
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/GridAndOrgCategoryCountResultDTO.java
  6. 6
      epmet-module/data-statistical/data-statistical-server/pom.xml
  7. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/constant/ProjectConstant.java
  8. 33
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java
  9. 12
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java
  10. 36
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectCategoryDao.java
  11. 43
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectDataDao.java
  12. 68
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenProjectCategoryEntity.java
  13. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java
  14. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java
  15. 34
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectCategoryGridAndOrgDailyService.java
  16. 105
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectCategoryService.java
  17. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectDataService.java
  18. 13
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java
  19. 203
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryGridAndOrgDailyServiceImpl.java
  20. 119
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryServiceImpl.java
  21. 90
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java
  22. 36
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml
  23. 30
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectCategoryDao.xml
  24. 122
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectDataDao.xml

6
epmet-module/data-report/data-report-client/src/main/java/com/epmet/project/dto/form/ProjectCategoryFormDTO.java

@ -35,4 +35,10 @@ public class ProjectCategoryFormDTO implements Serializable {
* 开始时间 * 开始时间
*/ */
private String startTime; private String startTime;
/**
* 组织名称
*/
@NotBlank(message = "组织名称不能为空",groups = CategoryProjectExportForm.class)
private String orgName;
} }

9
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/ScreenProjectController.java

@ -8,8 +8,6 @@ import com.alibaba.excel.write.metadata.WriteSheet;
import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.ExcelUtils;
@ -215,10 +213,9 @@ public class ScreenProjectController {
e.setIndex(1); e.setIndex(1);
resultDTOList.addAll(ConvertUtils.sourceToTarget(e.getChildren(),ProjectCategoryResultDTO.class)); resultDTOList.addAll(ConvertUtils.sourceToTarget(e.getChildren(),ProjectCategoryResultDTO.class));
}); });
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId());
Map<String,Object> mapData = new HashMap<>(); Map<String,Object> mapData = new HashMap<>();
mapData.put("list",resultDTOList); mapData.put("list",resultDTOList);
mapData.put("orgName",staffInfo.getAgencyName()); mapData.put("orgName", formDTO.getOrgName());
mapData.put("exportDate",getExportDateStr(formDTO.getStartTime(),formDTO.getEndTime())); mapData.put("exportDate",getExportDateStr(formDTO.getStartTime(),formDTO.getEndTime()));
Workbook workbook = ExcelExportUtil.exportExcel(new TemplateExportParams(templatePath), mapData); Workbook workbook = ExcelExportUtil.exportExcel(new TemplateExportParams(templatePath), mapData);
response.setHeader("content-Type", "application/vnd.ms-excel"); response.setHeader("content-Type", "application/vnd.ms-excel");
@ -257,9 +254,8 @@ public class ScreenProjectController {
formDTO.setIsPage(false); formDTO.setIsPage(false);
ValidatorUtils.validateEntity(formDTO, ProjectCategoryFormDTO.CategoryProjectExportForm.class); ValidatorUtils.validateEntity(formDTO, ProjectCategoryFormDTO.CategoryProjectExportForm.class);
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId());
Map<String, Object> mapData = new HashMap<>(); Map<String, Object> mapData = new HashMap<>();
mapData.put("orgName", staffInfo == null ? StrConstant.EPMETY_STR : staffInfo.getAgencyName()); mapData.put("orgName", formDTO.getOrgName());
mapData.put("exportDate", getExportDateStr(formDTO.getStartTime(), formDTO.getEndTime())); mapData.put("exportDate", getExportDateStr(formDTO.getStartTime(), formDTO.getEndTime()));
mapData.put("categoryName", formDTO.getCategoryName()); mapData.put("categoryName", formDTO.getCategoryName());
if (StringUtils.isNotBlank(formDTO.getParentCategoryName())) { if (StringUtils.isNotBlank(formDTO.getParentCategoryName())) {
@ -284,6 +280,7 @@ public class ScreenProjectController {
} }
formDTO.setPageNo(formDTO.getPageNo() + 1); formDTO.setPageNo(formDTO.getPageNo() + 1);
excelWriter.fill(data.getList(), writeSheet); excelWriter.fill(data.getList(), writeSheet);
data.getList().clear();
} while (data.getList().size() == formDTO.getPageSize()); } while (data.getList().size() == formDTO.getPageSize());
// String templatePath = "excel/project_temp.xlsx"; // String templatePath = "excel/project_temp.xlsx";

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

@ -245,6 +245,7 @@ public class ScreenProjectServiceImpl implements ScreenProjectService {
/** /**
* @Description 项目分类查询项目分类 * @Description 项目分类查询项目分类
* 二级分类总数占比改为 二级分类总数/一级分类总数
* @param formDTO * @param formDTO
* @param tokenDto * @param tokenDto
* @author zxc * @author zxc
@ -325,6 +326,11 @@ public class ScreenProjectServiceImpl implements ScreenProjectService {
collect.forEach(c -> { collect.forEach(c -> {
c.setChildren(c.getChildren().stream().sorted(Comparator.comparing(ProjectCategoryResultDTO::getProjectTotal).reversed()).collect(Collectors.toList())); c.setChildren(c.getChildren().stream().sorted(Comparator.comparing(ProjectCategoryResultDTO::getProjectTotal).reversed()).collect(Collectors.toList()));
}); });
collect.forEach(p -> {
p.getChildren().forEach(c -> {
c.setTotalRatio(ratio(c.getProjectTotal(), p.getProjectTotal()));
});
});
return collect; return collect;
} }

102
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/ScreenProjectCategoryDTO.java

@ -0,0 +1,102 @@
/**
* 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.dto.screen;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 项目所属分类表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-11-10
*/
@Data
public class ScreenProjectCategoryDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
private String id;
/**
* 客户id
*/
private String customerId;
/**
* 项目id
*/
private String projectId;
/**
* 分类编码
*/
private String categoryCode;
/**
* 所属父类分类编码
*/
private String parentCategoryCode;
/**
* 原始分类编码
*/
private String originCategoryCode;
/**
* 分类等级12....产品目前只有2级分类
*/
private Integer level;
/**
* 删除标识 0未删除1已删除
*/
private String delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

76
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/GridAndOrgCategoryCountResultDTO.java

@ -0,0 +1,76 @@
package com.epmet.dto.screen.result;
import com.epmet.commons.tools.constant.NumConstant;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2021/11/10 10:36 上午
* @DESC
*/
@Data
public class GridAndOrgCategoryCountResultDTO implements Serializable {
private static final long serialVersionUID = -5167964547464983118L;
/**
* 组织ID
*/
private String orgId;
/**
* 组织类型
*/
private String orgType;
/**
* 网格ID
*/
private String gridId;
/**
* 上级组织ID
*/
private String pid;
/**
* 所有上级组织ID
*/
private String pids;
private String dateId;
private String customerId;
private String categoryOriginCustomerId;
/**
* 分类CODE
*/
private String categoryCode;
/**
* 分类CODE级别
*/
private Integer level;
/**
* 项目总数
*/
private Integer projectTotal;
/**
* 关闭结案项目总数
*/
private Integer closedProjectTotal;
public GridAndOrgCategoryCountResultDTO() {
this.orgId = "";
this.categoryCode = "";
this.level = NumConstant.ZERO;
this.projectTotal = NumConstant.ZERO;
this.closedProjectTotal = NumConstant.ZERO;
}
}

6
epmet-module/data-statistical/data-statistical-server/pom.xml

@ -128,6 +128,12 @@
<version>2.0.0</version> <version>2.0.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>oper-crm-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

3
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/constant/ProjectConstant.java

@ -90,4 +90,7 @@ public interface ProjectConstant {
* 上报 * 上报
*/ */
String PROJECT_REPORT="02"; String PROJECT_REPORT="02";
String PROJECT_STATUS_CLOSED = "closed";
String PROJECT_STATUS_ALL = "all";
} }

33
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java

@ -62,7 +62,6 @@ import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
@ -136,6 +135,8 @@ public class DemoController {
private FactGridMemberStatisticsDailyService factGridMemberStatisticsDailyService; private FactGridMemberStatisticsDailyService factGridMemberStatisticsDailyService;
@Autowired @Autowired
private DimCustomerService dimCustomerService; private DimCustomerService dimCustomerService;
@Autowired
private ScreenProjectDataService screenProjectDataService;
@GetMapping("testAlarm") @GetMapping("testAlarm")
public void testAlarm() { public void testAlarm() {
@ -1068,4 +1069,34 @@ public class DemoController {
customerAgencyService.sysAgencyInfo(formDTO.getFromCustomerId(), formDTO.getToCustomerId()); customerAgencyService.sysAgencyInfo(formDTO.getFromCustomerId(), formDTO.getToCustomerId());
return new Result(); return new Result();
} }
@PostMapping("extractCategory")
public Result extractCategory(@RequestBody StatsFormDTO formDTO) {
screenProjectDataService.extractCategory(formDTO.getCustomerId());
return new Result();
}
@Autowired
private ScreenProjectCategoryGridAndOrgDailyService screenProjectCategoryGridAndOrgDailyService;
@PostMapping("gridandorgdailynew")
public Result<String> gridAndDaily(@RequestParam("customerId")String customerId,@RequestParam("dateId")String dateId,
@RequestParam(name = "startDate",required = false)String startDate,
@RequestParam(name = "endDate",required = false)String endDate
){
long start = System.currentTimeMillis();
if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)){
List<String> daysBetween = DateUtils.getDaysBetween(startDate, endDate);
daysBetween.forEach(d -> {
screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId,d);
screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId,d);
});
}else {
screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId,dateId);
screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId,dateId);
}
long end = System.currentTimeMillis();
long l = (end - start) / 1000;
return new Result<String>().ok("gridAndOrgDaily耗时" + l+ "s");
}
} }

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

@ -28,6 +28,7 @@ import com.epmet.dto.extract.result.OrgNameResultDTO;
import com.epmet.dto.indexcal.AgencyAndParentResultDTO; import com.epmet.dto.indexcal.AgencyAndParentResultDTO;
import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO; import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO;
import com.epmet.dto.screen.ScreenProjectOrgDailyDTO; import com.epmet.dto.screen.ScreenProjectOrgDailyDTO;
import com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO;
import com.epmet.dto.screen.result.TreeResultDTO; import com.epmet.dto.screen.result.TreeResultDTO;
import com.epmet.dto.screencoll.form.CustomerAgencyFormDTO; import com.epmet.dto.screencoll.form.CustomerAgencyFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity; import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity;
@ -244,4 +245,15 @@ public interface ScreenCustomerAgencyDao extends BaseDao<ScreenCustomerAgencyEnt
*/ */
List<CustomerAgencyDTO> selectByCustomerId(@Param("customerId") String customerId); List<CustomerAgencyDTO> selectByCustomerId(@Param("customerId") String customerId);
/**
* @Description 查询父子客户的组织平阴
* @param customerIds 平阴榆山锦水的客户ID
* @param customerId 孔村的客户ID🤬
* @author zxc
* @date 2021/11/10 2:52 下午
*/
List<GridAndOrgCategoryCountResultDTO> selectParentSonAgency(@Param("customerIds") List<String> customerIds ,@Param("customerId") String customerId);
String getParentAgencyId(@Param("agencyId") String agencyId);
} }

36
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectCategoryDao.java

@ -0,0 +1,36 @@
/**
* 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.entity.evaluationindex.screen.ScreenProjectCategoryEntity;
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 2021-11-10
*/
@Mapper
public interface ScreenProjectCategoryDao extends BaseDao<ScreenProjectCategoryEntity> {
void deleteByProjectIds(@Param("customerId") String customerId, @Param("projectIds") List<String> projectIds);
}

43
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectDataDao.java

@ -19,6 +19,7 @@ package com.epmet.dao.evaluationindex.screen;
import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.screen.ScreenProjectDataDTO; import com.epmet.dto.screen.ScreenProjectDataDTO;
import com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO;
import com.epmet.entity.evaluationindex.screen.ScreenProjectDataEntity; import com.epmet.entity.evaluationindex.screen.ScreenProjectDataEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -68,4 +69,46 @@ public interface ScreenProjectDataDao extends BaseDao<ScreenProjectDataEntity> {
int updateProjectSatisfactionScore(@Param("projectId")String projectId, @Param("score")BigDecimal score); int updateProjectSatisfactionScore(@Param("projectId")String projectId, @Param("score")BigDecimal score);
List<ScreenProjectDataDTO> selectProjectList(@Param("customerId") String customerId, @Param("projectId") String projectId); List<ScreenProjectDataDTO> selectProjectList(@Param("customerId") String customerId, @Param("projectId") String projectId);
/**
* @Description 查询网格下的项目分类
* @param customerIds 父子客户的customerId
* @param dateId 日期ID
* @param status 所有项目all已结案项目closed
* @param customerId 父级客户ID
* @param subCount 分类截取位数
* @author zxc
* @date 2021/11/10 3:12 下午
*/
List<GridAndOrgCategoryCountResultDTO> selectGridCategoryProjectCount(@Param("customerIds") List<String> customerIds,@Param("dateId") String dateId,
@Param("status")String status,@Param("customerId") String customerId,
@Param("subCount")Integer subCount);
/**
* @Description 查询组织下的项目分类
* @param dateId 日期ID
* @param status 所有项目all已结案项目closed
* @param customerId 父级客户ID
* @param subCount 分类截取位数
* @author zxc
* @date 2021/11/10 3:14 下午
*/
List<GridAndOrgCategoryCountResultDTO> selectOrgCategoryProjectCount(@Param("dateId") String dateId, @Param("status")String status,
@Param("customerId") String customerId, @Param("subCount")Integer subCount,
@Param("allAgencies") List<GridAndOrgCategoryCountResultDTO> allAgencies);
/**
* @Description 查询组织下的1级项目分类
* @param dateId
* @param status
* @param customerId
* @param subCount
* @param allAgencies
* @author zxc
* @date 2021/11/11 11:14 上午
*/
List<GridAndOrgCategoryCountResultDTO> selectOrgCategoryOneLevelProjectCount(@Param("dateId") String dateId, @Param("status")String status,
@Param("customerId") String customerId, @Param("subCount")Integer subCount,
@Param("allAgencies") List<GridAndOrgCategoryCountResultDTO> allAgencies);
} }

68
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenProjectCategoryEntity.java

@ -0,0 +1,68 @@
/**
* 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 2021-11-10
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("screen_project_category")
public class ScreenProjectCategoryEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户id
*/
private String customerId;
/**
* 项目id
*/
private String projectId;
/**
* 分类编码
*/
private String categoryCode;
/**
* 所属父类分类编码
*/
private String parentCategoryCode;
/**
* 原始分类编码
*/
private String originCategoryCode;
/**
* 分类等级12....产品目前只有2级分类
*/
private Integer level;
}

6
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java

@ -84,6 +84,8 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
private FactAgencyGovernDailyService factAgencyGovernDailyService; private FactAgencyGovernDailyService factAgencyGovernDailyService;
@Autowired @Autowired
private FactGridMemberStatisticsDailyService factGridMemberStatisticsDailyService; private FactGridMemberStatisticsDailyService factGridMemberStatisticsDailyService;
@Autowired
private ScreenProjectCategoryGridAndOrgDailyService screenProjectCategoryGridAndOrgDailyService;
/** /**
* @param extractOriginFormDTO * @param extractOriginFormDTO
@ -243,14 +245,14 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
//按天统计:网格内各个分类下的项目总数 //按天统计:网格内各个分类下的项目总数
try { try {
projectCategoryGridDailyService.extractProjectCategoryData(customerId, dateId); screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId, dateId);
} catch (Exception e) { } catch (Exception e) {
log.error("按天统计:网格内各个分类下的项目总数,customerId为:" + customerId + "dateId为:" + dateId, e); log.error("按天统计:网格内各个分类下的项目总数,customerId为:" + customerId + "dateId为:" + dateId, e);
} }
// 按天统计:组织内各个分类下的项目总数 // 按天统计:组织内各个分类下的项目总数
try { try {
projectCategoryOrgDailyService.extractProjectCategoryOrgData(customerId, dateId); screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId, dateId);
} catch (Exception e) { } catch (Exception e) {
log.error("按天统计:组织内各个分类下的项目总数,customerId为:" + customerId + "dateId为:" + dateId, e); log.error("按天统计:组织内各个分类下的项目总数,customerId为:" + customerId + "dateId为:" + dateId, e);
} }

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

@ -155,4 +155,13 @@ public interface ScreenCustomerAgencyService extends BaseService<ScreenCustomerA
*/ */
Map<String, ScreenCustomerAgencyEntity> getAgencyList(String customerId); Map<String, ScreenCustomerAgencyEntity> getAgencyList(String customerId);
/**
* @Description 获取父级组织ID外部客户
* @Param agencyId
* @Return {@link String}
* @Author zhaoqifeng
* @Date 2021/11/10 17:00
*/
String getParentAgencyId(String agencyId);
} }

34
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectCategoryGridAndOrgDailyService.java

@ -0,0 +1,34 @@
package com.epmet.service.evaluationindex.screen;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.screen.ScreenProjectCategoryOrgDailyDTO;
import com.epmet.dto.screencoll.ScreenCollFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryOrgDailyEntity;
import java.util.List;
import java.util.Map;
/**
* 项目(事件)分类按 网格组织按天统计
*/
public interface ScreenProjectCategoryGridAndOrgDailyService {
/**
* @Description 分类下的项目数grid
* @param customerId
* @param dateId
* @author zxc
* @date 2021/11/10 10:23 上午
*/
void extractCategoryProjectGridData(String customerId, String dateId);
/**
* @Description 分类下的项目数org
* @param customerId
* @param dateId
* @author zxc
* @date 2021/11/10 10:23 上午
*/
void extractCategoryProjectOrgData(String customerId, String dateId);
}

105
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectCategoryService.java

@ -0,0 +1,105 @@
/**
* 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.service.evaluationindex.screen;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.screen.ScreenProjectCategoryDTO;
import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryEntity;
import java.util.List;
import java.util.Map;
/**
* 项目所属分类表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-11-10
*/
public interface ScreenProjectCategoryService extends BaseService<ScreenProjectCategoryEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<ScreenProjectCategoryDTO>
* @author generator
* @date 2021-11-10
*/
PageData<ScreenProjectCategoryDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<ScreenProjectCategoryDTO>
* @author generator
* @date 2021-11-10
*/
List<ScreenProjectCategoryDTO> list(Map<String, Object> params);
/**
* 单条查询
*
* @param id
* @return ScreenProjectCategoryDTO
* @author generator
* @date 2021-11-10
*/
ScreenProjectCategoryDTO get(String id);
/**
* 默认保存
*
* @param dto
* @return void
* @author generator
* @date 2021-11-10
*/
void save(ScreenProjectCategoryDTO dto);
/**
* 默认更新
*
* @param dto
* @return void
* @author generator
* @date 2021-11-10
*/
void update(ScreenProjectCategoryDTO dto);
/**
* 批量删除
*
* @param ids
* @return void
* @author generator
* @date 2021-11-10
*/
void delete(String[] ids);
/**
* 删除项目分类
* @Param customerId
* @Param projectIds
* @Return
* @Author zhaoqifeng
* @Date 2021/11/10 11:06
*/
void deleteByProjectId(String customerId, List<String> projectIds);
}

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

@ -148,4 +148,13 @@ public interface ScreenProjectDataService extends BaseService<ScreenProjectDataE
*/ */
void sendProjectChangeMq(DisputeProcessMQMsg msg); void sendProjectChangeMq(DisputeProcessMQMsg msg);
/**
* @Description 提取项目分类
* @Param customerId
* @Return
* @Author zhaoqifeng
* @Date 2021/11/10 10:24
*/
void extractCategory(String customerId);
} }

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

@ -335,4 +335,17 @@ public class ScreenCustomerAgencyServiceImpl extends BaseServiceImpl<ScreenCusto
return list.stream().collect(Collectors.toMap(ScreenCustomerAgencyEntity::getAgencyId, Function.identity())); return list.stream().collect(Collectors.toMap(ScreenCustomerAgencyEntity::getAgencyId, Function.identity()));
} }
/**
* @param agencyId
* @Description 获取父级组织ID外部客户
* @Param agencyId
* @Return {@link String}
* @Author zhaoqifeng
* @Date 2021/11/10 17:00
*/
@Override
public String getParentAgencyId(String agencyId) {
return baseDao.getParentAgencyId(agencyId);
}
} }

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

@ -0,0 +1,203 @@
package com.epmet.service.evaluationindex.screen.impl;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.constant.DataSourceConstant;
import com.epmet.constant.PingYinConstant;
import com.epmet.constant.ProjectConstant;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerAgencyDao;
import com.epmet.dao.evaluationindex.screen.ScreenProjectCategoryGridDailyDao;
import com.epmet.dao.evaluationindex.screen.ScreenProjectCategoryOrgDailyDao;
import com.epmet.dao.evaluationindex.screen.ScreenProjectDataDao;
import com.epmet.dto.screen.ScreenProjectOrgDailyDTO;
import com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO;
import com.epmet.entity.crm.CustomerRelationEntity;
import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryGridDailyEntity;
import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryOrgDailyEntity;
import com.epmet.service.crm.CustomerRelationService;
import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryGridAndOrgDailyService;
import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryGridDailyService;
import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryOrgDailyService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author zxc
* @DateTime 2021/11/10 10:25 上午
* @DESC
*/
@Service
@DataSource(DataSourceConstant.EVALUATION_INDEX)
@Slf4j
public class ScreenProjectCategoryGridAndOrgDailyServiceImpl implements ScreenProjectCategoryGridAndOrgDailyService{
@Autowired
private ScreenProjectDataDao screenProjectDataDao;
@Autowired
private CustomerRelationService relationService;
@Autowired
private ScreenProjectCategoryGridDailyDao gridDailyDao;
@Autowired
private ScreenProjectCategoryGridDailyService gridDailyService;
@Autowired
private ScreenProjectCategoryOrgDailyService orgDailyService;
@Autowired
private ScreenProjectCategoryOrgDailyDao orgDailyDao;
@Autowired
private ScreenCustomerAgencyDao screenCustomerAgencyDao;
/**
* @Description 分类下的项目数grid
* @param customerId
* @param dateId
* @author zxc
* @date 2021/11/10 10:23 上午
*/
@Override
public void extractCategoryProjectGridData(String customerId, String dateId) {
List<CustomerRelationEntity> relationInfo = relationService.selectSubCustomer(customerId);
List<String> customerIds = new ArrayList<>();
customerIds.add(customerId);
List<GridAndOrgCategoryCountResultDTO> allList = new ArrayList<>();
List<GridAndOrgCategoryCountResultDTO> closedList = new ArrayList<>();
if (CollectionUtils.isEmpty(relationInfo)){
// 单客户
allList = screenProjectDataDao.selectGridCategoryProjectCount(customerIds, dateId, ProjectConstant.PROJECT_STATUS_ALL,customerId, NumConstant.FOUR);
closedList = screenProjectDataDao.selectGridCategoryProjectCount(customerIds, dateId, ProjectConstant.PROJECT_STATUS_CLOSED,customerId, NumConstant.FOUR);
}else {
// 多客户
List<String> subCustomerIds = relationInfo.stream().map(CustomerRelationEntity::getCustomerId).collect(Collectors.toList());
customerIds.addAll(subCustomerIds);
allList = screenProjectDataDao.selectGridCategoryProjectCount(customerIds, dateId, ProjectConstant.PROJECT_STATUS_ALL,customerId, NumConstant.TWO);
closedList = screenProjectDataDao.selectGridCategoryProjectCount(customerIds, dateId, ProjectConstant.PROJECT_STATUS_CLOSED,customerId, NumConstant.TWO);
}
List<GridAndOrgCategoryCountResultDTO> finalClosedList = closedList;
allList.forEach(a -> finalClosedList.stream().filter(c -> c.getGridId().equals(a.getGridId()) && c.getCategoryCode().equals(a.getCategoryCode())).forEach(c -> a.setClosedProjectTotal(c.getClosedProjectTotal())));
gridDel(customerId,dateId);
gridInsert(allList);
}
/**
* @Description 项目分类网格删除
* @param customerId
* @param dateId
* @author zxc
* @date 2021/11/10 1:55 下午
*/
@Transactional(rollbackFor = Exception.class)
public void gridDel(String customerId,String dateId){
Integer num = NumConstant.ZERO;
do {
num = gridDailyDao.deleteByDateIdAndCustomerId(customerId, dateId);
}while (num > NumConstant.ZERO && num == NumConstant.ONE_THOUSAND);
}
/**
* @Description 项目分类网格添加
* @param needInsert
* @author zxc
* @date 2021/11/10 1:55 下午
*/
@Transactional(rollbackFor = Exception.class)
public void gridInsert(List<GridAndOrgCategoryCountResultDTO> needInsert){
List<List<GridAndOrgCategoryCountResultDTO>> partition = ListUtils.partition(needInsert, NumConstant.ONE_HUNDRED);
partition.forEach(p -> {
gridDailyService.insertBatch(ConvertUtils.sourceToTarget(p,ScreenProjectCategoryGridDailyEntity.class));
log.info("插入的网格项目分类为" + JSON.toJSONString(p));
});
}
/**
* @Description 分类下的项目数org
* 项目分类来源
* 本级直接立项 + 下级 + 直属网格
* @param customerId
* @param dateId
* @author zxc
* @date 2021/11/10 10:23 上午
*/
@Override
public void extractCategoryProjectOrgData(String customerId, String dateId) {
List<CustomerRelationEntity> relationInfo = relationService.selectSubCustomer(customerId);
List<String> customerIds = new ArrayList<>();
customerIds.add(customerId);
List<GridAndOrgCategoryCountResultDTO> result = new ArrayList<>();
if (CollectionUtils.isEmpty(relationInfo)){
// one customer
List<ScreenProjectOrgDailyDTO> agencies = screenCustomerAgencyDao.selectAgencyByCustomer(customerId);
List<GridAndOrgCategoryCountResultDTO> allAgencies = ConvertUtils.sourceToTarget(agencies, GridAndOrgCategoryCountResultDTO.class);
result = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.FOUR, allAgencies);
List<GridAndOrgCategoryCountResultDTO> oneLevelList = screenProjectDataDao.selectOrgCategoryOneLevelProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.FOUR, allAgencies);
List<GridAndOrgCategoryCountResultDTO> oneLevelClosedList = screenProjectDataDao.selectOrgCategoryOneLevelProjectCount(dateId, ProjectConstant.PROJECT_STATUS_CLOSED, customerId, NumConstant.FOUR, allAgencies);
oneLevelList.forEach(a -> oneLevelClosedList.stream().filter(c -> a.getOrgId().equals(c.getOrgId()) && a.getCategoryCode().equals(c.getCategoryCode())).forEach(c -> a.setClosedProjectTotal(c.getClosedProjectTotal())));
result.addAll(oneLevelList);
List<GridAndOrgCategoryCountResultDTO> closedList = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_CLOSED, customerId, NumConstant.FOUR, allAgencies);
result.forEach(r -> closedList.stream().filter(c -> r.getOrgId().equals(c.getOrgId()) && r.getCategoryCode().equals(c.getCategoryCode())).forEach(c -> r.setClosedProjectTotal(c.getClosedProjectTotal())));
}else {
// more customers
// 去除孔村的客户ID,孔村镇的单独查😡
List<String> subCustomerIds = relationInfo.stream().map(CustomerRelationEntity::getCustomerId).collect(Collectors.toList());
for (int i = NumConstant.ZERO; i < subCustomerIds.size(); i++) {
if (subCustomerIds.get(i).equals(PingYinConstant.KONG_CUN_CUSTOMER_ID)){
customerIds.remove(i);
continue;
}
}
List<GridAndOrgCategoryCountResultDTO> allAgencies = screenCustomerAgencyDao.selectParentSonAgency(subCustomerIds, PingYinConstant.KONG_CUN_CUSTOMER_ID);
List<List<GridAndOrgCategoryCountResultDTO>> partition = ListUtils.partition(allAgencies, NumConstant.FIFTY);
List<GridAndOrgCategoryCountResultDTO> allOrgCategoryList = result;
partition.forEach(p -> {
List<GridAndOrgCategoryCountResultDTO> allOrgList = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.TWO, p);
List<GridAndOrgCategoryCountResultDTO> oneLevelList = screenProjectDataDao.selectOrgCategoryOneLevelProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.FOUR, allAgencies);
List<GridAndOrgCategoryCountResultDTO> oneLevelClosedList = screenProjectDataDao.selectOrgCategoryOneLevelProjectCount(dateId, ProjectConstant.PROJECT_STATUS_CLOSED, customerId, NumConstant.FOUR, allAgencies);
oneLevelList.forEach(a -> oneLevelClosedList.stream().filter(c -> a.getOrgId().equals(c.getOrgId()) && a.getCategoryCode().equals(c.getCategoryCode())).forEach(c -> a.setClosedProjectTotal(c.getClosedProjectTotal())));
allOrgList.addAll(oneLevelList);
List<GridAndOrgCategoryCountResultDTO> closedOrgList = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_CLOSED, customerId, NumConstant.TWO, p);
allOrgList.forEach(a -> closedOrgList.stream().filter(c -> a.getOrgId().equals(c.getOrgId()) && a.getCategoryCode().equals(c.getCategoryCode())).forEach(c -> a.setClosedProjectTotal(c.getClosedProjectTotal())));
allOrgCategoryList.addAll(allOrgList);
});
}
orgDel(customerId,dateId);
orgInsert(result);
}
/**
* @Description 项目分类组织删除
* @param customerId
* @param dateId
* @author zxc
* @date 2021/11/10 4:58 下午
*/
@Transactional(rollbackFor = Exception.class)
public void orgDel(String customerId,String dateId){
Integer num = NumConstant.ZERO;
do {
num = orgDailyDao.deleteByDateIdAndCustomerId(customerId, dateId);
}while (num > NumConstant.ZERO && num == NumConstant.ONE_THOUSAND);
}
/**
* @Description 项目分类组织插入
* @param needInsert
* @author zxc
* @date 2021/11/10 5:03 下午
*/
@Transactional(rollbackFor = Exception.class)
public void orgInsert(List<GridAndOrgCategoryCountResultDTO> needInsert){
List<List<GridAndOrgCategoryCountResultDTO>> partition = ListUtils.partition(needInsert, NumConstant.ONE_HUNDRED);
partition.forEach(p -> {
orgDailyService.insertBatch(ConvertUtils.sourceToTarget(p, ScreenProjectCategoryOrgDailyEntity.class));
log.info("插入的组织项目分类为" + JSON.toJSONString(p));
});
}
}

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

@ -0,0 +1,119 @@
/**
* 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.service.evaluationindex.screen.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.dao.evaluationindex.screen.ScreenProjectCategoryDao;
import com.epmet.dto.screen.ScreenProjectCategoryDTO;
import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryEntity;
import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 项目所属分类表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-11-10
*/
@Service
public class ScreenProjectCategoryServiceImpl extends BaseServiceImpl<ScreenProjectCategoryDao, ScreenProjectCategoryEntity> implements ScreenProjectCategoryService {
@Override
public PageData<ScreenProjectCategoryDTO> page(Map<String, Object> params) {
IPage<ScreenProjectCategoryEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, ScreenProjectCategoryDTO.class);
}
@Override
public List<ScreenProjectCategoryDTO> list(Map<String, Object> params) {
List<ScreenProjectCategoryEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, ScreenProjectCategoryDTO.class);
}
private QueryWrapper<ScreenProjectCategoryEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<ScreenProjectCategoryEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
return wrapper;
}
@Override
public ScreenProjectCategoryDTO get(String id) {
ScreenProjectCategoryEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, ScreenProjectCategoryDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(ScreenProjectCategoryDTO dto) {
ScreenProjectCategoryEntity entity = ConvertUtils.sourceToTarget(dto, ScreenProjectCategoryEntity.class);
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(ScreenProjectCategoryDTO dto) {
ScreenProjectCategoryEntity entity = ConvertUtils.sourceToTarget(dto, ScreenProjectCategoryEntity.class);
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
}
/**
* 删除项目分类
*
* @param customerId
* @param projectIds
* @Param customerId
* @Param projectIds
* @Return
* @Author zhaoqifeng
* @Date 2021/11/10 11:06
*/
@Override
public void deleteByProjectId(String customerId, List<String> projectIds) {
if (CollectionUtils.isEmpty(projectIds)) {
return;
}
baseDao.deleteByProjectIds(customerId, projectIds);
}
}

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

@ -17,6 +17,7 @@
package com.epmet.service.evaluationindex.screen.impl; package com.epmet.service.evaluationindex.screen.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.dynamic.datasource.annotation.DataSource;
@ -24,19 +25,27 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.rocketmq.messages.DisputeProcessMQMsg; import com.epmet.commons.rocketmq.messages.DisputeProcessMQMsg;
import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.DataSourceConstant; import com.epmet.constant.DataSourceConstant;
import com.epmet.dao.evaluationindex.screen.ScreenProjectDataDao; import com.epmet.dao.evaluationindex.screen.ScreenProjectDataDao;
import com.epmet.dao.evaluationindex.screen.ScreenProjectImgDataDao; import com.epmet.dao.evaluationindex.screen.ScreenProjectImgDataDao;
import com.epmet.dto.screen.ScreenProjectDataDTO; import com.epmet.dto.screen.ScreenProjectDataDTO;
import com.epmet.dto.screen.form.ScreenProjectDataInfoFormDTO; import com.epmet.dto.screen.form.ScreenProjectDataInfoFormDTO;
import com.epmet.dto.screencoll.ScreenCollFormDTO; import com.epmet.dto.screencoll.ScreenCollFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryEntity;
import com.epmet.entity.evaluationindex.screen.ScreenProjectDataEntity; import com.epmet.entity.evaluationindex.screen.ScreenProjectDataEntity;
import com.epmet.entity.evaluationindex.screen.ScreenProjectImgDataEntity; import com.epmet.entity.evaluationindex.screen.ScreenProjectImgDataEntity;
import com.epmet.entity.stats.CustomerProjectCategoryDictEntity;
import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.feign.EpmetMessageOpenFeignClient;
import com.epmet.feign.OperCrmOpenFeignClient;
import com.epmet.send.SendMqMsgUtil; import com.epmet.send.SendMqMsgUtil;
import com.epmet.service.evaluationindex.screen.ScreenCustomerAgencyService;
import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryService;
import com.epmet.service.evaluationindex.screen.ScreenProjectDataService; import com.epmet.service.evaluationindex.screen.ScreenProjectDataService;
import com.epmet.service.stats.CustomerProjectCategoryDictService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
@ -48,10 +57,8 @@ import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Arrays; import java.util.*;
import java.util.Date; import java.util.stream.Collectors;
import java.util.List;
import java.util.Map;
/** /**
* 中央区-项目数据 * 中央区-项目数据
@ -67,6 +74,14 @@ public class ScreenProjectDataServiceImpl extends BaseServiceImpl<ScreenProjectD
private ScreenProjectImgDataDao screenProjectImgDataDao; private ScreenProjectImgDataDao screenProjectImgDataDao;
@Resource @Resource
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient;
@Resource
private ScreenProjectCategoryService screenProjectCategoryService;
@Resource
private CustomerProjectCategoryDictService customerProjectCategoryDictService;
@Resource
private OperCrmOpenFeignClient operCrmOpenFeignClient;
@Resource
private ScreenCustomerAgencyService screenCustomerAgencyService;
@Override @Override
public PageData<ScreenProjectDataDTO> page(Map<String, Object> params) { public PageData<ScreenProjectDataDTO> page(Map<String, Object> params) {
@ -132,6 +147,7 @@ public class ScreenProjectDataServiceImpl extends BaseServiceImpl<ScreenProjectD
}*/ }*/
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date today = new Date(); Date today = new Date();
List<ScreenProjectDataEntity> projectList = new ArrayList<>();
param.getDataList().forEach(item -> { param.getDataList().forEach(item -> {
String projectStatusCode = item.getProjectStatusCode(); String projectStatusCode = item.getProjectStatusCode();
@ -195,7 +211,12 @@ public class ScreenProjectDataServiceImpl extends BaseServiceImpl<ScreenProjectD
ScreenProjectDataEntity screenProjectDataEntity = ConvertUtils.sourceToTarget(item, ScreenProjectDataEntity.class); ScreenProjectDataEntity screenProjectDataEntity = ConvertUtils.sourceToTarget(item, ScreenProjectDataEntity.class);
screenProjectDataEntity.setCustomerId(param.getCustomerId()); screenProjectDataEntity.setCustomerId(param.getCustomerId());
screenProjectDataEntity.setDataEndTime(param.getDateId()); screenProjectDataEntity.setDataEndTime(param.getDateId());
String agencyId = screenCustomerAgencyService.getParentAgencyId(screenProjectDataEntity.getAllParentIds().split(StrConstant.COMMA)[0]);
if(StringUtils.isNotBlank(agencyId)) {
screenProjectDataEntity.setAllParentIds(agencyId.concat(StrConstant.COMMA).concat(screenProjectDataEntity.getAllParentIds()));
}
baseDao.insert(screenProjectDataEntity); baseDao.insert(screenProjectDataEntity);
projectList.add(screenProjectDataEntity);
//插入图片表 //插入图片表
String[] projectImgUrl = item.getProjectImgUrl(); String[] projectImgUrl = item.getProjectImgUrl();
if (ArrayUtils.isNotEmpty(projectImgUrl)) { if (ArrayUtils.isNotEmpty(projectImgUrl)) {
@ -209,6 +230,8 @@ public class ScreenProjectDataServiceImpl extends BaseServiceImpl<ScreenProjectD
} }
} }
}); });
saveCategory(param.getCustomerId(), projectList);
} }
@ -262,13 +285,17 @@ public class ScreenProjectDataServiceImpl extends BaseServiceImpl<ScreenProjectD
partition.forEach(part -> { partition.forEach(part -> {
List<ScreenProjectDataEntity> list = ConvertUtils.sourceToTarget(part, ScreenProjectDataEntity.class); List<ScreenProjectDataEntity> list = ConvertUtils.sourceToTarget(part, ScreenProjectDataEntity.class);
insertBatch(list); insertBatch(list);
saveCategory(customerId, list);
}); });
} }
if(!CollectionUtils.isEmpty(orient)){ if(!CollectionUtils.isEmpty(orient)){
List<List<ScreenProjectDataDTO>> partition = ListUtils.partition(orient, NumConstant.ONE_HUNDRED); List<List<ScreenProjectDataDTO>> partition = ListUtils.partition(orient, NumConstant.ONE_HUNDRED);
partition.forEach(part -> baseDao.updateBatch(part,dateId)); partition.forEach(part -> {
baseDao.updateBatch(part,dateId);
saveCategory(customerId, ConvertUtils.sourceToTarget(part, ScreenProjectDataEntity.class));
});
} }
} }
@ -306,4 +333,57 @@ public class ScreenProjectDataServiceImpl extends BaseServiceImpl<ScreenProjectD
SendMqMsgUtil.build().openFeignClient(epmetMessageOpenFeignClient).sendProjectMqMsg(msg); SendMqMsgUtil.build().openFeignClient(epmetMessageOpenFeignClient).sendProjectMqMsg(msg);
} }
/**
* @param customerId
* @Description 提取项目分类
* @Param customerId
* @Return
* @Author zhaoqifeng
* @Date 2021/11/10 10:24
*/
@Override
public void extractCategory(String customerId) {
LambdaQueryWrapper<ScreenProjectDataEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(customerId), ScreenProjectDataEntity::getCustomerId, customerId);
List<ScreenProjectDataEntity> projectList = baseDao.selectList(wrapper);
saveCategory(customerId, projectList);
}
private void saveCategory(String customerId, List<ScreenProjectDataEntity> projectList) {
Result<String> parentCustomer = operCrmOpenFeignClient.getExternalAndParentCustomerId(customerId);
//删除旧分类
List<String> projectIds = projectList.stream().map(ScreenProjectDataEntity::getProjectId).collect(Collectors.toList());
screenProjectCategoryService.deleteByProjectId(customerId, projectIds);
//提取分类信息
List<ScreenProjectCategoryEntity> projectCategoryList = new ArrayList<>();
projectList.forEach(project -> {
//分类为空不作处理
if (StringUtils.isNotBlank(project.getCategoryCode())) {
List<String> categoryList = Arrays.asList(project.getCategoryCode().split(StrConstant.COMMA));
categoryList.forEach(category -> {
ScreenProjectCategoryEntity entity = new ScreenProjectCategoryEntity();
entity.setCustomerId(customerId);
entity.setProjectId(project.getProjectId());
entity.setOriginCategoryCode(category);
CustomerProjectCategoryDictEntity categoryEntity = customerProjectCategoryDictService.getByCategoryCode(customerId, category);
if (null != categoryEntity) {
//
if ("external".equals(categoryEntity.getCustomerType())) {
entity.setCategoryCode(categoryEntity.getEpmetCategoryCode());
CustomerProjectCategoryDictEntity parent = customerProjectCategoryDictService.getByCategoryCode(parentCustomer.getData(), categoryEntity.getEpmetCategoryCode());
entity.setParentCategoryCode(parent.getParentCategoryCode());
} else {
entity.setCategoryCode(categoryEntity.getCategoryCode());
entity.setParentCategoryCode(categoryEntity.getParentCategoryCode());
}
entity.setLevel(categoryEntity.getLevel());
}
projectCategoryList.add(entity);
});
}
});
screenProjectCategoryService.insertBatch(projectCategoryList);
}
} }

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

@ -504,5 +504,41 @@
del_flag = 0 del_flag = 0
AND customer_id = #{customerId} AND customer_id = #{customerId}
</select> </select>
<select id="getParentAgencyId" resultType="java.lang.String">
SELECT
a.AGENCY_ID
FROM
screen_customer_agency a
INNER JOIN screen_customer_agency b ON a.AREA_CODE = b.PARENT_AREA_CODE
AND b.DEL_FLAG = '0'
AND b.AGENCY_ID = #{agencyId}
WHERE
a.DEL_FLAG = '0'
</select>
<!-- 查询父子客户的组织【平阴】 -->
<select id="selectParentSonAgency" resultType="com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO">
SELECT
AGENCY_ID AS orgId,
PID,
REPLACE(PIDS,',',':') AS pids,
`LEVEL` AS orgType
FROM screen_customer_agency
WHERE DEL_FLAG = '0'
AND CUSTOMER_ID IN
<foreach collection="customerIds" item="c" separator="," open="(" close=")">
#{c}
</foreach>
UNION ALL
SELECT
AGENCY_ID AS orgId,
PID,
REPLACE(PIDS,',',':') AS pids,
CASE WHEN `LEVEL` = 'district' THEN 'street' ELSE `LEVEL` END AS orgType
FROM screen_customer_agency
WHERE DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND `LEVEL` != 'street'
</select>
</mapper> </mapper>

30
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectCategoryDao.xml

@ -0,0 +1,30 @@
<?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.ScreenProjectCategoryDao">
<resultMap type="com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryEntity" id="screenProjectCategoryMap">
<result property="id" column="ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="projectId" column="PROJECT_ID"/>
<result property="categoryCode" column="CATEGORY_CODE"/>
<result property="parentCategoryCode" column="PARENT_CATEGORY_CODE"/>
<result property="originCategoryCode" column="ORIGIN_CATEGORY_CODE"/>
<result property="level" column="LEVEL"/>
<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>
<delete id="deleteByProjectIds">
delete from screen_project_category
where CUSTOMER_ID = #{customerId}
<foreach collection="projectIds" item="projectId" open="AND (" close=" )" separator=" OR ">
PROJECT_ID = #{projectId}
</foreach>
</delete>
</mapper>

122
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectDataDao.xml

@ -269,4 +269,126 @@
ORDER BY ORDER BY
a.CREATED_TIME ASC a.CREATED_TIME ASC
</select> </select>
<!-- 查询网格下的项目分类 -->
<select id="selectGridCategoryProjectCount" resultType="com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO">
SELECT
#{dateId} AS dateId,
#{customerId} AS customerId,
pc.CATEGORY_CODE,
pd.ORG_ID AS gridId,
pd.PARENT_ID AS pid,
pd.ALL_PARENT_IDS AS pids,
pc.`LEVEL`,
<if test=' status == "closed" '>
COUNT(DISTINCT pc.PROJECT_ID) AS closedProjectTotal
</if>
<if test=' status == "all" '>
COUNT(DISTINCT pc.PROJECT_ID) AS projectTotal
</if>
FROM screen_project_data pd
LEFT JOIN screen_project_category pc ON (pc.PROJECT_ID = pd.PROJECT_ID AND pc.DEL_FLAG = '0')
WHERE pd.DEL_FLAG = '0'
AND pd.CUSTOMER_ID IN
<foreach collection="customerIds" item="c" separator="," open="(" close=")">
#{c}
</foreach>
AND DATE_FORMAT(pd.PROJECT_CREATE_TIME,'%Y%m%d') <![CDATA[ <= ]]> #{dateId}
AND pd.ORG_TYPE = 'grid'
AND pc.level = 2
<if test=' status == "closed" '>
AND pd.PROJECT_STATUS_CODE IN ('closed','closed_case')
</if>
GROUP BY pd.ORG_ID,pc.CATEGORY_CODE
UNION ALL
SELECT
#{dateId} AS dateId,
#{customerId} AS customerId,
left(pc.CATEGORY_CODE, #{subCount}) AS categoryCode,
pd.ORG_ID AS gridId,
pd.PARENT_ID AS pid,
pd.ALL_PARENT_IDS AS pids,
1 AS level,
<if test=' status == "closed" '>
COUNT(DISTINCT pc.PROJECT_ID) AS closedProjectTotal
</if>
<if test=' status == "all" '>
COUNT(DISTINCT pc.PROJECT_ID) AS projectTotal
</if>
FROM screen_project_data pd
INNER JOIN screen_project_category pc ON (pc.PROJECT_ID = pd.PROJECT_ID AND pc.DEL_FLAG = '0')
WHERE pd.DEL_FLAG = '0'
AND pd.CUSTOMER_ID IN
<foreach collection="customerIds" item="c" separator="," open="(" close=")">
#{c}
</foreach>
AND DATE_FORMAT(pd.PROJECT_CREATE_TIME,'%Y%m%d') <![CDATA[ <= ]]> #{dateId}
AND pd.ORG_TYPE = 'grid'
<if test=' status == "closed" '>
AND pd.PROJECT_STATUS_CODE IN ('closed','closed_case')
</if>
GROUP BY pd.ORG_ID,categoryCode
</select>
<!-- 查询组织下的项目分类 -->
<select id="selectOrgCategoryProjectCount" resultType="com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO">
<foreach collection="allAgencies" item="a" separator=" UNION ALL ">
SELECT
#{dateId} AS dateId,
#{customerId} AS customerId,
pd.customer_id AS categoryOriginCustomerId,
pc.CATEGORY_CODE,
#{a.orgId} AS orgId,
#{a.pid} AS pid,
#{a.pids} AS pids,
#{a.orgType} AS orgType,
pc.`LEVEL`,
<if test=' status == "closed" '>
COUNT(DISTINCT pc.PROJECT_ID) AS closedProjectTotal
</if>
<if test=' status == "all" '>
COUNT(DISTINCT pc.PROJECT_ID) AS projectTotal
</if>
FROM screen_project_data pd
LEFT JOIN screen_project_category pc ON (pc.PROJECT_ID = pd.PROJECT_ID AND pc.DEL_FLAG = '0')
WHERE pd.DEL_FLAG = '0'
AND pc.level = 2
AND DATE_FORMAT(pd.PROJECT_CREATE_TIME,'%Y%m%d') <![CDATA[ <= ]]> #{dateId}
AND ALL_PARENT_IDS LIKE CONCAT('%',#{a.orgId},'%')
<if test=' status == "closed" '>
AND pd.PROJECT_STATUS_CODE IN ('closed','closed_case')
</if>
GROUP BY pc.CATEGORY_CODE
</foreach>
</select>
<select id="selectOrgCategoryOneLevelProjectCount" resultType="com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO">
<foreach collection="allAgencies" item="a" separator=" UNION ALL ">
SELECT
#{dateId} AS dateId,
#{customerId} AS customerId,
pd.customer_id AS categoryOriginCustomerId,
left(pc.CATEGORY_CODE, #{subCount}) AS categoryCode,
#{a.orgId} AS orgId,
#{a.pid} AS pid,
#{a.pids} AS pids,
#{a.orgType} AS orgType,
pc.`LEVEL`,
<if test=' status == "closed" '>
COUNT(DISTINCT pc.PROJECT_ID) AS closedProjectTotal
</if>
<if test=' status == "all" '>
COUNT(DISTINCT pc.PROJECT_ID) AS projectTotal
</if>
FROM screen_project_data pd
INNER JOIN screen_project_category pc ON (pc.PROJECT_ID = pd.PROJECT_ID AND pc.DEL_FLAG = '0')
WHERE pd.DEL_FLAG = '0'
AND DATE_FORMAT(pd.PROJECT_CREATE_TIME,'%Y%m%d') <![CDATA[ <= ]]> #{dateId}
AND ALL_PARENT_IDS LIKE CONCAT('%',#{a.orgId},'%')
<if test=' status == "closed" '>
AND pd.PROJECT_STATUS_CODE IN ('closed','closed_case')
</if>
GROUP BY categoryCode
</foreach>
</select>
</mapper> </mapper>

Loading…
Cancel
Save