diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java index 1281b269f4..9ba8e7a96a 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java @@ -64,6 +64,8 @@ public interface NumConstant { long THREE_L = 3L; long FOUR_L = 4L; long MINUS_ONE_L = -1L; + long TEN_L = 10L; + long SIX_HUNDRED_L = 600L; String ZERO_STR = "0"; String ONE_STR = "1"; diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/distributedlock/LockConstants.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/distributedlock/LockConstants.java index 3174a43a8e..a823816952 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/distributedlock/LockConstants.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/distributedlock/LockConstants.java @@ -9,4 +9,6 @@ public interface LockConstants { String TEST_LOCK_NAME = "testLock"; String STATS_LOCK_NAME = "stats"; + + String SCREEN_DAILY = "screenDaily"; } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index a24aa8ee82..fce9a8cf85 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java @@ -12,6 +12,7 @@ import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.utils.DateUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.formula.functions.T; /** * @author Mark sunlightcs@gmail.com @@ -621,4 +622,13 @@ public class RedisKeys { public static String getResiTempChangedKey(String customerId) { return rootPrefix.concat("resi:").concat("export").concat(":template:changed").concat(customerId); } + + /** + * desc:获取执行完毕的 业务 参数结果key + * @param bizMethod + * @return + */ + public static String getBackDoorbizExcuteResult(String bizMethod) { + return rootPrefix.concat("backdoor:").concat(bizMethod); + } } diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/project/dto/form/ProjectCategoryFormDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/project/dto/form/ProjectCategoryFormDTO.java index 8cd3a4f083..c7a585ec6c 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/project/dto/form/ProjectCategoryFormDTO.java +++ b/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; + + /** + * 组织名称 + */ + @NotBlank(message = "组织名称不能为空",groups = CategoryProjectExportForm.class) + private String orgName; } diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/ScreenProjectController.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/ScreenProjectController.java index 66d088dd27..98cda05a2b 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/ScreenProjectController.java +++ b/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.constant.NumConstant; 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.utils.ConvertUtils; import com.epmet.commons.tools.utils.ExcelUtils; @@ -215,10 +213,9 @@ public class ScreenProjectController { e.setIndex(1); resultDTOList.addAll(ConvertUtils.sourceToTarget(e.getChildren(),ProjectCategoryResultDTO.class)); }); - CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId()); Map mapData = new HashMap<>(); mapData.put("list",resultDTOList); - mapData.put("orgName",staffInfo.getAgencyName()); + mapData.put("orgName", formDTO.getOrgName()); mapData.put("exportDate",getExportDateStr(formDTO.getStartTime(),formDTO.getEndTime())); Workbook workbook = ExcelExportUtil.exportExcel(new TemplateExportParams(templatePath), mapData); response.setHeader("content-Type", "application/vnd.ms-excel"); @@ -257,9 +254,8 @@ public class ScreenProjectController { formDTO.setIsPage(false); ValidatorUtils.validateEntity(formDTO, ProjectCategoryFormDTO.CategoryProjectExportForm.class); - CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId()); Map 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("categoryName", formDTO.getCategoryName()); if (StringUtils.isNotBlank(formDTO.getParentCategoryName())) { @@ -284,6 +280,7 @@ public class ScreenProjectController { } formDTO.setPageNo(formDTO.getPageNo() + 1); excelWriter.fill(data.getList(), writeSheet); + data.getList().clear(); } while (data.getList().size() == formDTO.getPageSize()); // String templatePath = "excel/project_temp.xlsx"; diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenProjectDataDao.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenProjectDataDao.java index 11c019e4d9..d20a3f1183 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenProjectDataDao.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenProjectDataDao.java @@ -54,7 +54,8 @@ public interface ScreenProjectDataDao { * @author zxc * @date 2021/11/5 1:40 下午 */ - List selectCategoryProjectList(@Param("customerId") String customerId,@Param("orgId") String orgId, - @Param("categoryCode")String categoryCode,@Param("status")String status); + List selectCategoryProjectList(@Param("orgId") String orgId, + @Param("categoryCode")String categoryCode,@Param("status")String status, + @Param("startTime")String startTime,@Param("endTime")String endTime); } diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/ScreenProjectServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/ScreenProjectServiceImpl.java index 041b6ba725..a40da16683 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/ScreenProjectServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/ScreenProjectServiceImpl.java @@ -11,6 +11,7 @@ import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.security.dto.TokenDto; 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.DataSourceConstant; import com.epmet.datareport.constant.FactConstant; @@ -245,6 +246,7 @@ public class ScreenProjectServiceImpl implements ScreenProjectService { /** * @Description 【项目分类】查询项目分类 + * 二级分类总数占比改为 二级分类总数/一级分类总数 * @param formDTO * @param tokenDto * @author zxc @@ -252,6 +254,9 @@ public class ScreenProjectServiceImpl implements ScreenProjectService { */ @Override public List selectProjectCategory(ProjectCategoryFormDTO formDTO, TokenDto tokenDto) { + if (StringUtils.isNotBlank(formDTO.getStartTime())){ + formDTO.setStartTime(DateUtils.getBeforeNDay(formDTO.getStartTime(),NumConstant.ONE)); + } if (StringUtils.isBlank(formDTO.getOrgId())){ CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId()); if (null == staffInfo){ @@ -325,6 +330,11 @@ public class ScreenProjectServiceImpl implements ScreenProjectService { collect.forEach(c -> { 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; } @@ -376,7 +386,7 @@ public class ScreenProjectServiceImpl implements ScreenProjectService { PageCategoryProjectListResultDTO result = new PageCategoryProjectListResultDTO(); List list; PageInfo objectPageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()) - .doSelectPageInfo(() -> screenProjectDataDao.selectCategoryProjectList(tokenDto.getCustomerId(), formDTO.getOrgId(), formDTO.getCategoryCode(), formDTO.getStatus())); + .doSelectPageInfo(() -> screenProjectDataDao.selectCategoryProjectList(formDTO.getOrgId(), formDTO.getCategoryCode(), formDTO.getStatus(),formDTO.getStartTime(),formDTO.getEndTime())); list = objectPageInfo.getList(); result.setTotal(Integer.valueOf(String.valueOf(objectPageInfo.getTotal()))); diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenProjectDataDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenProjectDataDao.xml index 05753a7b3a..28b422ab4d 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenProjectDataDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenProjectDataDao.xml @@ -162,24 +162,28 @@ diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/ScreenProjectCategoryDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/ScreenProjectCategoryDTO.java new file mode 100644 index 0000000000..f9fedd5560 --- /dev/null +++ b/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 + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.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; + + /** + * 分类等级:1、2....;产品目前只有2级分类 + */ + private Integer level; + + /** + * 删除标识 0未删除;1已删除 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/GridAndOrgCategoryCountResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/GridAndOrgCategoryCountResultDTO.java new file mode 100644 index 0000000000..7f3f9aa96d --- /dev/null +++ b/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; + } +} diff --git a/epmet-module/data-statistical/data-statistical-server/pom.xml b/epmet-module/data-statistical/data-statistical-server/pom.xml index 7a0ae49569..0fc10e94cb 100644 --- a/epmet-module/data-statistical/data-statistical-server/pom.xml +++ b/epmet-module/data-statistical/data-statistical-server/pom.xml @@ -142,6 +142,12 @@ 2.0.0 compile + + com.epmet + oper-crm-client + 2.0.0 + compile + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/constant/ProjectConstant.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/constant/ProjectConstant.java index 6b9966b154..ec417c1c60 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/constant/ProjectConstant.java +++ b/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_STATUS_CLOSED = "closed"; + String PROJECT_STATUS_ALL = "all"; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java index e70d9541b7..bc7d990f6e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java @@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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.redis.RedisKeys; +import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; @@ -60,6 +62,7 @@ import org.springframework.web.bind.annotation.*; import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; +import java.util.*; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -73,7 +76,8 @@ import java.util.concurrent.Future; public class DemoController { @Autowired private StatsDemoService demoService; - + @Autowired + private RedisUtils redisUtils; @Autowired private ExecutorService executorService; @@ -135,6 +139,8 @@ public class DemoController { private FactGridMemberStatisticsDailyService factGridMemberStatisticsDailyService; @Autowired private DimCustomerService dimCustomerService; + @Autowired + private ScreenProjectDataService screenProjectDataService; @GetMapping("testAlarm") public void testAlarm() { @@ -1068,4 +1074,39 @@ public class DemoController { customerAgencyService.sysAgencyInfo(formDTO.getFromCustomerId(), formDTO.getToCustomerId()); 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 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(); + Set result = new LinkedHashSet<>(); + if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)){ + List daysBetween = DateUtils.getDaysBetween(startDate, endDate); + daysBetween.forEach(d -> { + screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId,d); + screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId,d); + result.add(d); + redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("gridandorgdailynew"),customerId,result,3*24*60*60L); + }); + }else { + screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId,dateId); + screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId,dateId); + redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("gridandorgdailynew"),customerId,result,3*24*60*60L); + } + long end = System.currentTimeMillis(); + long l = (end - start) / 1000; + return new Result().ok("gridAndOrgDaily耗时" + l+ "s"); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java index e6155e982e..619e9f2e67 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java +++ b/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.indexcollect.form.CustomerBizOrgFormDTO; import com.epmet.dto.screen.ScreenProjectOrgDailyDTO; +import com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO; import com.epmet.dto.screen.result.TreeResultDTO; import com.epmet.dto.screencoll.form.CustomerAgencyFormDTO; import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity; @@ -244,4 +245,15 @@ public interface ScreenCustomerAgencyDao extends BaseDao selectByCustomerId(@Param("customerId") String customerId); + /** + * @Description 查询父子客户的组织【平阴】 + * @param customerIds 平阴,榆山,锦水的客户ID + * @param customerId 孔村的客户ID🤬 + * @author zxc + * @date 2021/11/10 2:52 下午 + */ + List selectParentSonAgency(@Param("customerIds") List customerIds ,@Param("customerId") String customerId); + + + String getParentAgencyId(@Param("agencyId") String agencyId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectCategoryDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectCategoryDao.java new file mode 100644 index 0000000000..08d28b6c86 --- /dev/null +++ b/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 + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.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 { + void deleteByProjectIds(@Param("customerId") String customerId, @Param("projectIds") List projectIds); +} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectDataDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectDataDao.java index 97c85d1bc0..26aa8892d9 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectDataDao.java +++ b/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.dto.screen.ScreenProjectDataDTO; +import com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO; import com.epmet.entity.evaluationindex.screen.ScreenProjectDataEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -68,4 +69,46 @@ public interface ScreenProjectDataDao extends BaseDao { int updateProjectSatisfactionScore(@Param("projectId")String projectId, @Param("score")BigDecimal score); List 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 selectGridCategoryProjectCount(@Param("dateId") String dateId,@Param("parentCustomerId") String parentCustomerId, + @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 selectOrgCategoryProjectCount(@Param("dateId") String dateId, @Param("status")String status, + @Param("customerId") String customerId, @Param("subCount")Integer subCount, + @Param("allAgencies") List allAgencies); + + /** + * @Description 查询组织下的1级项目分类 + * @param dateId + * @param status + * @param customerId + * @param subCount + * @param allAgencies + * @author zxc + * @date 2021/11/11 11:14 上午 + */ + List selectOrgCategoryOneLevelProjectCount(@Param("dateId") String dateId, @Param("status")String status, + @Param("customerId") String customerId, @Param("subCount")Integer subCount, + @Param("allAgencies") List allAgencies); + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenProjectCategoryEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenProjectCategoryEntity.java new file mode 100644 index 0000000000..4e1ea78bfe --- /dev/null +++ b/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 + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.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; + + /** + * 分类等级:1、2....;产品目前只有2级分类 + */ + private Integer level; + +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java index 600786782c..3b03d3768d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java @@ -2,6 +2,8 @@ package com.epmet.service.evaluationindex.extract.toscreen.impl; import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.distributedlock.DistributedLock; +import com.epmet.commons.tools.distributedlock.LockConstants; import com.epmet.commons.tools.enums.EnvEnum; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.HttpClientManager; @@ -20,6 +22,7 @@ import com.epmet.service.stats.DimCustomerService; import com.google.common.util.concurrent.ThreadFactoryBuilder; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.redisson.api.RLock; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -84,6 +87,10 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { private FactAgencyGovernDailyService factAgencyGovernDailyService; @Autowired private FactGridMemberStatisticsDailyService factGridMemberStatisticsDailyService; + @Autowired + private ScreenProjectCategoryGridAndOrgDailyService screenProjectCategoryGridAndOrgDailyService; + @Autowired + private DistributedLock distributedLock; /** * @param extractOriginFormDTO @@ -161,155 +168,165 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { * @date 2020/9/24 10:16 上午 */ public void extractDaily(String customerId, String dateId, boolean isLast) { - //等待3个线程执行完毕后再 继续执行下一个客户的 避免死锁 - final CountDownLatch latch = new CountDownLatch(NumConstant.FOUR); - threadPool.submit(() -> { - //党员基本情况screen_cpc_base_data - try { - partyBaseInfoService.statsPartyMemberBaseInfoToScreen(customerId, dateId); - } catch (Exception e) { - log.error("党员基本情况抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e); - } - //先锋模范screen_pioneer_data - if (isLast) { + RLock lock = null; + try { + // 锁持有10分钟,等待10s + lock = distributedLock.getLock(LockConstants.SCREEN_DAILY, NumConstant.SIX_HUNDRED_L, NumConstant.TEN_L, TimeUnit.SECONDS); + //等待3个线程执行完毕后再 继续执行下一个客户的 避免死锁 + final CountDownLatch latch = new CountDownLatch(NumConstant.FOUR); + threadPool.submit(() -> { + //党员基本情况screen_cpc_base_data try { - pioneerDataExtractService.extractGridPioneerData(customerId, dateId); + partyBaseInfoService.statsPartyMemberBaseInfoToScreen(customerId, dateId); } catch (Exception e) { - log.error("先锋模范【网格】抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e); + log.error("党员基本情况抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e); } + //先锋模范screen_pioneer_data + if (isLast) { + try { + pioneerDataExtractService.extractGridPioneerData(customerId, dateId); + } catch (Exception e) { + log.error("先锋模范【网格】抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e); + } + try { + pioneerDataExtractService.extractCommunityPioneerData(customerId, dateId); + } catch (Exception e) { + log.error("先锋模范【社区】抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e); + } + try { + pioneerDataExtractService.extractExceptCommunityPioneerData(customerId, dateId); + } catch (Exception e) { + log.error("先锋模范【extractExceptCommunityPioneerData】抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e); + } + } + + latch.countDown(); + log.info("extractDaily 1 thread run end ========= dateId:{},customerId:{}", dateId, customerId); + }); + threadPool.submit(() -> { + //公众参与排行(注册人数、参与人数、话题数、议题数、项目数)screen_public_party_total_data try { - pioneerDataExtractService.extractCommunityPioneerData(customerId, dateId); + publicPartiTotalDataExtractService.extractPublicPartiTotalData(customerId, dateId); } catch (Exception e) { - log.error("先锋模范【社区】抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e); + log.error("公众参与排行抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e); } + if (isLast) { + //基层治理- 难点赌点 screen_difficulty_data | screen_difficulty_img_data + try { + ScreenCentralZoneDataFormDTO param2 = new ScreenCentralZoneDataFormDTO(); + param2.setCustomerId(customerId); + param2.setDateId(null); + log.info("【难点赌点数据上报开始------】 当前客户Id{}", param2.getCustomerId()); + //screenGrassrootsGovernDataAbsorptionService.difficultyDataHub(param); + + screenGrassrootsGovernDataAbsorptionService.difficultyDataExtract(param2); + log.info("【难点赌点数据上报结束------】 当前客户Id{}", param2.getCustomerId()); + } catch (Exception e) { + log.error("基层治理-难点赌点抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e); + } + } + latch.countDown(); + log.info("extractDaily 2 thread run end ========= dateId:{},customerId:{}", dateId, customerId); + }); + threadPool.submit(() -> { + ScreenCentralZoneDataFormDTO param = new ScreenCentralZoneDataFormDTO(); + param.setCustomerId(customerId); + param.setDateId(dateId); + //中央区 screen_user_total_data try { - pioneerDataExtractService.extractExceptCommunityPioneerData(customerId, dateId); + screenCentralZoneDataAbsorptionService.centralZoneDataHub(param); } catch (Exception e) { - log.error("先锋模范【extractExceptCommunityPioneerData】抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e); + log.error("中央区抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e); } - } - latch.countDown(); - log.info("extractDaily 1 thread run end ========= dateId:{},customerId:{}", dateId, customerId); - }); - threadPool.submit(() -> { - //公众参与排行(注册人数、参与人数、话题数、议题数、项目数)screen_public_party_total_data - try { - publicPartiTotalDataExtractService.extractPublicPartiTotalData(customerId, dateId); - } catch (Exception e) { - log.error("公众参与排行抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e); - } - if (isLast) { - //基层治理- 难点赌点 screen_difficulty_data | screen_difficulty_img_data try { - ScreenCentralZoneDataFormDTO param2 = new ScreenCentralZoneDataFormDTO(); - param2.setCustomerId(customerId); - param2.setDateId(null); - log.info("【难点赌点数据上报开始------】 当前客户Id{}", param2.getCustomerId()); - //screenGrassrootsGovernDataAbsorptionService.difficultyDataHub(param); - - screenGrassrootsGovernDataAbsorptionService.difficultyDataExtract(param2); - log.info("【难点赌点数据上报结束------】 当前客户Id{}", param2.getCustomerId()); + // 项目(事件)分析按网格_按天统计 + screenProjectGridDailyService.extractionProjectGridDaily(customerId, dateId); } catch (Exception e) { - log.error("基层治理-难点赌点抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e); + log.error("项目(事件)分析按网格_按天统计失败,customerId为:" + customerId + "dateId为:" + dateId, e); + } + try { + // 项目(事件)分析按组织_按天统计 + screenProjectOrgDailyService.extractionProjectOrgDaily(customerId, dateId); + } catch (Exception e) { + log.error("项目(事件)分析按组织_按天统计失败,customerId为:" + customerId + "dateId为:" + dateId, e); } - } - latch.countDown(); - log.info("extractDaily 2 thread run end ========= dateId:{},customerId:{}", dateId, customerId); - }); - threadPool.submit(() -> { - ScreenCentralZoneDataFormDTO param = new ScreenCentralZoneDataFormDTO(); - param.setCustomerId(customerId); - param.setDateId(dateId); - //中央区 screen_user_total_data - try { - screenCentralZoneDataAbsorptionService.centralZoneDataHub(param); - } catch (Exception e) { - log.error("中央区抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e); - } - - try { - // 项目(事件)分析按网格_按天统计 - screenProjectGridDailyService.extractionProjectGridDaily(customerId, dateId); - } catch (Exception e) { - log.error("项目(事件)分析按网格_按天统计失败,customerId为:" + customerId + "dateId为:" + dateId, e); - } - try { - // 项目(事件)分析按组织_按天统计 - screenProjectOrgDailyService.extractionProjectOrgDaily(customerId, dateId); - } catch (Exception e) { - log.error("项目(事件)分析按组织_按天统计失败,customerId为:" + customerId + "dateId为:" + dateId, e); - } - //按天统计:网格内各个分类下的项目总数 - try { - projectCategoryGridDailyService.extractProjectCategoryData(customerId, dateId); - } catch (Exception e) { - log.error("按天统计:网格内各个分类下的项目总数,customerId为:" + customerId + "dateId为:" + dateId, e); - } + //按天统计:网格内各个分类下的项目总数 + try { + screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId, dateId); + } catch (Exception e) { + log.error("按天统计:网格内各个分类下的项目总数,customerId为:" + customerId + "dateId为:" + dateId, e); + } - // 按天统计:组织内各个分类下的项目总数 - try { - projectCategoryOrgDailyService.extractProjectCategoryOrgData(customerId, dateId); - } catch (Exception e) { - log.error("按天统计:组织内各个分类下的项目总数,customerId为:" + customerId + "dateId为:" + dateId, e); - } - latch.countDown(); - log.info("extractDaily 3 thread run end ========= dateId:{},customerId:{}", dateId, customerId); - }); - threadPool.submit(() -> { - //治理能力排行screen_govern_rank_data - try { - governRankDataExtractService.extractGridDataDaily(customerId, dateId); - } catch (Exception e) { - log.error("治理能力排行【网格】抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e); - } - try { - governRankDataExtractService.extractCommunityDataDaily(customerId, dateId); - } catch (Exception e) { - log.error("治理能力排行【社区】抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e); - } - try { - governRankDataExtractService.extractStreetDataDaily(customerId, dateId); - } catch (Exception e) { - log.error("治理能力排行【街道】抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e); - } - try { - governRankDataExtractService.extractDistrictDataDaily(customerId, dateId); - } catch (Exception e) { - log.error("治理能力排行【全区】抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e); - } + // 按天统计:组织内各个分类下的项目总数 + try { + screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId, dateId); + } catch (Exception e) { + log.error("按天统计:组织内各个分类下的项目总数,customerId为:" + customerId + "dateId为:" + dateId, e); + } + latch.countDown(); + log.info("extractDaily 3 thread run end ========= dateId:{},customerId:{}", dateId, customerId); + }); + threadPool.submit(() -> { + //治理能力排行screen_govern_rank_data + try { + governRankDataExtractService.extractGridDataDaily(customerId, dateId); + } catch (Exception e) { + log.error("治理能力排行【网格】抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e); + } + try { + governRankDataExtractService.extractCommunityDataDaily(customerId, dateId); + } catch (Exception e) { + log.error("治理能力排行【社区】抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e); + } + try { + governRankDataExtractService.extractStreetDataDaily(customerId, dateId); + } catch (Exception e) { + log.error("治理能力排行【街道】抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e); + } + try { + governRankDataExtractService.extractDistrictDataDaily(customerId, dateId); + } catch (Exception e) { + log.error("治理能力排行【全区】抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e); + } - try { - ExtractFactGridGovernDailyFromDTO extractFactGridGovernDailyFromDTO = new ExtractFactGridGovernDailyFromDTO(); - extractFactGridGovernDailyFromDTO.setCustomerId(customerId); - extractFactGridGovernDailyFromDTO.setDateId(dateId); - factGridGovernDailyService.extractFactGridGovernDaily(extractFactGridGovernDailyFromDTO); - } catch (Exception e) { - log.error("治理指数-网格fact_grid_govern_daily抽取失败,customerId为:" + customerId + "dateId为:" + dateId, e); - } + try { + ExtractFactGridGovernDailyFromDTO extractFactGridGovernDailyFromDTO = new ExtractFactGridGovernDailyFromDTO(); + extractFactGridGovernDailyFromDTO.setCustomerId(customerId); + extractFactGridGovernDailyFromDTO.setDateId(dateId); + factGridGovernDailyService.extractFactGridGovernDaily(extractFactGridGovernDailyFromDTO); + } catch (Exception e) { + log.error("治理指数-网格fact_grid_govern_daily抽取失败,customerId为:" + customerId + "dateId为:" + dateId, e); + } - try { - factAgencyGovernDailyService.extractFactAgencyGovernDaily(customerId, dateId); - } catch (Exception e) { - log.error("治理指数-组织fact_agency_govern_daily抽取失败,customerId为:" + customerId + "dateId为:" + dateId, e); - } + try { + factAgencyGovernDailyService.extractFactAgencyGovernDaily(customerId, dateId); + } catch (Exception e) { + log.error("治理指数-组织fact_agency_govern_daily抽取失败,customerId为:" + customerId + "dateId为:" + dateId, e); + } + try { + factGridMemberStatisticsDailyService.extractGridMemberStatisticsDaily(customerId, dateId); + } catch (Exception e) { + log.error("网格员数据统计fact_grid_member_statistics_daily抽取失败,customerId为:" + customerId + "dateId为:" + dateId, e); + } + extractPartData(customerId, dateId); + latch.countDown(); + log.info("extractDaily 4 thread run end ========= dateId:{},customerId:{}", dateId, customerId); + }); try { - factGridMemberStatisticsDailyService.extractGridMemberStatisticsDaily(customerId, dateId); - } catch (Exception e) { - log.error("网格员数据统计fact_grid_member_statistics_daily抽取失败,customerId为:" + customerId + "dateId为:" + dateId, e); + latch.await(); + } catch (InterruptedException e) { + log.error("extractDaily run exception", e); } - extractPartData(customerId, dateId); - latch.countDown(); - log.info("extractDaily 4 thread run end ========= dateId:{},customerId:{}", dateId, customerId); - }); - try { - latch.await(); - } catch (InterruptedException e) { - log.error("extractDaily run exception", e); + log.info("===== extractDaily method end customerId:{}======",customerId); + } catch (Exception e) { + log.error("extractDaily exception msg:{}", e); + } finally { + distributedLock.unLock(lock); } - log.info("===== extractDaily method end customerId:{}======",customerId); + } @Override diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java index fcb81fc243..9a46990c1d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java +++ b/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 getAgencyList(String customerId); + /** + * @Description 获取父级组织ID(外部客户) + * @Param agencyId + * @Return {@link String} + * @Author zhaoqifeng + * @Date 2021/11/10 17:00 + */ + String getParentAgencyId(String agencyId); + } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectCategoryGridAndOrgDailyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectCategoryGridAndOrgDailyService.java new file mode 100644 index 0000000000..9cdc9f3522 --- /dev/null +++ b/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); +} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectCategoryService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectCategoryService.java new file mode 100644 index 0000000000..7cea3ea62c --- /dev/null +++ b/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 + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.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 { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2021-11-10 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2021-11-10 + */ + List list(Map 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 projectIds); +} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectDataService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectDataService.java index a29640a75b..845a2fc844 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectDataService.java +++ b/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 relationInfo = relationService.selectSubCustomer(customerId); + List customerIds = new ArrayList<>(); + customerIds.add(customerId); + List allList = new ArrayList<>(); + List closedList = new ArrayList<>(); + if (CollectionUtils.isEmpty(relationInfo)){ + // 单客户 + allList = screenProjectDataDao.selectGridCategoryProjectCount(dateId, customerId, ProjectConstant.PROJECT_STATUS_ALL,customerId, NumConstant.FOUR); + closedList = screenProjectDataDao.selectGridCategoryProjectCount(dateId, customerId, ProjectConstant.PROJECT_STATUS_CLOSED,customerId, NumConstant.FOUR); + }else { + // 多客户 + List subCustomerIds = relationInfo.stream().map(CustomerRelationEntity::getCustomerId).collect(Collectors.toList()); + customerIds.addAll(subCustomerIds); + List finalAllList = allList; + List finalClosedList1 = closedList; + customerIds.forEach(c -> { + List all = screenProjectDataDao.selectGridCategoryProjectCount(dateId, customerId, ProjectConstant.PROJECT_STATUS_ALL, c, NumConstant.TWO); + finalAllList.addAll(all); + List closed = screenProjectDataDao.selectGridCategoryProjectCount(dateId, customerId, ProjectConstant.PROJECT_STATUS_CLOSED, c, NumConstant.TWO); + finalClosedList1.addAll(closed); + }); + } + List 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); + log.info("网格-所有项目分类即将插入的集合{}",JSON.toJSONString(allList)); + gridInsert(allList); + long end = System.currentTimeMillis(); + log.info("网格项目分类统计结束,耗时:"+ (end-start)/1000 + "s"); + } + + /** + * @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 needInsert){ + List> 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) { + log.info("开始执行组织项目分类统计"); + long start = System.currentTimeMillis(); + List relationInfo = relationService.selectSubCustomer(customerId); + List customerIds = new ArrayList<>(); + customerIds.add(customerId); + List result = new ArrayList<>(); + if (CollectionUtils.isEmpty(relationInfo)){ + // one customer + List agencies = screenCustomerAgencyDao.selectAgencyByCustomer(customerId); + if (CollectionUtils.isEmpty(agencies)){ + return; + } + List allAgencies = ConvertUtils.sourceToTarget(agencies, GridAndOrgCategoryCountResultDTO.class); + + result = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.FOUR, allAgencies); + List 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()))); + + + List oneLevelList = screenProjectDataDao.selectOrgCategoryOneLevelProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.FOUR, allAgencies); + List 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); + }else { + // more customers + // 去除孔村的客户ID,孔村镇的单独查😡 + List 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; + } + } + subCustomerIds.add(customerId); + List allAgencies = screenCustomerAgencyDao.selectParentSonAgency(subCustomerIds, PingYinConstant.KONG_CUN_CUSTOMER_ID); + List> partition = ListUtils.partition(allAgencies, NumConstant.FIFTY); + List allOrgCategoryList = result; + partition.forEach(p -> { + List allOrgList = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.TWO, p); + List 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()))); + + List oneLevelList = screenProjectDataDao.selectOrgCategoryOneLevelProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.TWO, p); + List oneLevelClosedList = screenProjectDataDao.selectOrgCategoryOneLevelProjectCount(dateId, ProjectConstant.PROJECT_STATUS_CLOSED, customerId, NumConstant.TWO, p); + 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); + allOrgCategoryList.addAll(allOrgList); + }); + } + orgDel(customerId,dateId); + log.info("组织-即将插入的项目分类{}",JSON.toJSONString(result)); + orgInsert(result); + long end = System.currentTimeMillis(); + log.info("组织项目分类统计结束,耗时:"+ (end-start)/1000 + "s"); + } + + /** + * @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 needInsert){ + List> partition = ListUtils.partition(needInsert, NumConstant.ONE_HUNDRED); + partition.forEach(p -> { + orgDailyService.insertBatch(ConvertUtils.sourceToTarget(p, ScreenProjectCategoryOrgDailyEntity.class)); + log.info("插入的组织项目分类为" + JSON.toJSONString(p)); + }); + } +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryServiceImpl.java new file mode 100644 index 0000000000..b696efeeb3 --- /dev/null +++ b/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 + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.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 implements ScreenProjectCategoryService { + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, ScreenProjectCategoryDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, ScreenProjectCategoryDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper 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 projectIds) { + if (CollectionUtils.isEmpty(projectIds)) { + return; + } + baseDao.deleteByProjectIds(customerId, projectIds); + } + +} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java index f04234049e..fcdcf05349 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java +++ b/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; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.dynamic.datasource.annotation.DataSource; @@ -24,20 +25,29 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.rocketmq.messages.DisputeProcessMQMsg; import com.epmet.commons.tools.constant.FieldConstant; 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.utils.ConvertUtils; +import com.epmet.commons.tools.utils.Result; import com.epmet.constant.DataSourceConstant; import com.epmet.dao.evaluationindex.screen.ScreenProjectDataDao; import com.epmet.dao.evaluationindex.screen.ScreenProjectImgDataDao; import com.epmet.dto.screen.ScreenProjectDataDTO; +import com.epmet.dto.screen.ScreenProjectImgDataDTO; import com.epmet.dto.screen.form.ScreenProjectDataInfoFormDTO; 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.ScreenProjectImgDataEntity; +import com.epmet.entity.stats.CustomerProjectCategoryDictEntity; import com.epmet.feign.EpmetMessageOpenFeignClient; +import com.epmet.feign.OperCrmOpenFeignClient; 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.stats.CustomerProjectCategoryDictService; import com.github.pagehelper.PageHelper; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; @@ -47,11 +57,8 @@ import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.math.BigDecimal; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.stream.Collectors; /** * 中央区-项目数据 @@ -59,6 +66,7 @@ import java.util.Map; * @author qu qu@elink-cn.com * @since v1.0.0 2021-02-23 */ +@Slf4j @Service @DataSource(value = DataSourceConstant.EVALUATION_INDEX) public class ScreenProjectDataServiceImpl extends BaseServiceImpl implements ScreenProjectDataService { @@ -67,6 +75,14 @@ public class ScreenProjectDataServiceImpl extends BaseServiceImpl page(Map params) { @@ -121,95 +137,84 @@ public class ScreenProjectDataServiceImpl extends BaseServiceImpl param) { - /*if (param.getIsFirst()) { - int affectedRows = baseDao.deleteByDateIdAndCustomerId(param.getCustomerId(), param.getDateId()); - while (affectedRows > 0) { - affectedRows = baseDao.deleteByDateIdAndCustomerId(param.getCustomerId(), param.getDateId()); - } - }*/ - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - Date today = new Date(); param.getDataList().forEach(item -> { String projectStatusCode = item.getProjectStatusCode(); //2021.3.8 epmet中,调用方传level,这边不再计算 - if(item.getProjectLevel() == null){ - //todo 动态获取超时时间 - //如果结案 结案时间立项时间; - if ("closed_case".equals(projectStatusCode)) { - Date createTime = item.getProjectCreateTime(); - Date closeCaseTime = item.getCloseCaseTime(); - - if (closeCaseTime.getTime() - createTime.getTime() <= 1000 * 60 * 60 * 24 * 4) { - //如果结案时间-立项时间小于等于4天 未超期 level3 - item.setProjectLevel(3); - } else if (closeCaseTime.getTime() - createTime.getTime() <= 1000 * 60 * 60 * 24 * 5) { - //如果结案时间-立项时间大于4天小于5天 即将超期 level2 - item.setProjectLevel(2); - } else { - //大于5天 已超期 level1 - item.setProjectLevel(1); - } - } else if ("pending".equals(projectStatusCode)) { - //如果处理中 当前时间-立项时间; - Date createTime = item.getProjectCreateTime(); - - if (today.getTime() - createTime.getTime() <= 1000 * 60 * 60 * 24 * 4) { - //如果当前时间-立项时间小于等于4天 未超期 level3 - item.setProjectLevel(3); - } else if (today.getTime() - createTime.getTime() <= 1000 * 60 * 60 * 24 * 5) { - //如果当前时间-立项时间大于4天小于5天 即将超期 level2 - item.setProjectLevel(2); - } else { - //大于5天 已超期 level1 - item.setProjectLevel(1); - } - } - } - //先删除该projectId对应的旧数据 - baseDao.deleteByProjectId(param.getCustomerId(), item.getProjectId()); - screenProjectImgDataDao.deleteByProjectId(param.getCustomerId(), item.getProjectId()); - - //如果orgType未知,获取一下 -// if ("unknown".equals(item.getOrgType())){ -// ScreenCustomerAgencyEntity screenCustomerAgencyEntity = agencyDao.selectById(item.getOrgId()); -// if (screenCustomerAgencyEntity != null){ -// item.setOrgType("agency"); -// }else { -// ScreenCustomerDeptEntity screenCustomerDeptEntity = deptDao.selectById(item.getOrgId()); -// if (screenCustomerDeptEntity!=null){ -// item.setOrgType("department"); -// }else { -// ScreenCustomerGridEntity screenCustomerGridEntity = gridDao.selectById(item.getOrgId()); -// if (screenCustomerGridEntity != null){ -// item.setOrgType("grid"); -// } -// } -// } -// } + setLevelByCreateTime(item, projectStatusCode); //插入项目表 ScreenProjectDataEntity screenProjectDataEntity = ConvertUtils.sourceToTarget(item, ScreenProjectDataEntity.class); screenProjectDataEntity.setCustomerId(param.getCustomerId()); screenProjectDataEntity.setDataEndTime(param.getDateId()); - baseDao.insert(screenProjectDataEntity); - //插入图片表 - String[] projectImgUrl = item.getProjectImgUrl(); - if (ArrayUtils.isNotEmpty(projectImgUrl)) { - for (int i = 0; i < projectImgUrl.length; i++) { - ScreenProjectImgDataEntity screenProjectImgDataEntity = new ScreenProjectImgDataEntity(); - screenProjectImgDataEntity.setCustomerId(param.getCustomerId()); - screenProjectImgDataEntity.setProjectId(item.getProjectId()); - screenProjectImgDataEntity.setProjectImgUrl(projectImgUrl[i]); - screenProjectImgDataEntity.setSort(i); - screenProjectImgDataDao.insert(screenProjectImgDataEntity); - } + String agencyId = screenCustomerAgencyService.getParentAgencyId(screenProjectDataEntity.getAllParentIds().split(StrConstant.COMMA)[0]); + if(StringUtils.isNotBlank(agencyId)) { + screenProjectDataEntity.setAllParentIds(agencyId.concat(StrConstant.COMMA).concat(screenProjectDataEntity.getAllParentIds())); } + //删除 并插入新的项目数据 + delAndInsertProjectData(param, item, screenProjectDataEntity); }); } + @Transactional(rollbackFor = Exception.class) + public void delAndInsertProjectData(ScreenCollFormDTO param, ScreenProjectDataInfoFormDTO item, ScreenProjectDataEntity screenProjectDataEntity) { + //先删除该projectId对应的旧数据 + baseDao.deleteByProjectId(param.getCustomerId(), item.getProjectId()); + screenProjectImgDataDao.deleteByProjectId(param.getCustomerId(), item.getProjectId()); + baseDao.insert(screenProjectDataEntity); + saveCategory(param.getCustomerId(), Collections.singletonList(screenProjectDataEntity)); + //插入该项目图片表 + String[] projectImgUrl = item.getProjectImgUrl(); + if (ArrayUtils.isNotEmpty(projectImgUrl)) { + List imgList = new ArrayList<>(); + for (int i = 0; i < projectImgUrl.length; i++) { + ScreenProjectImgDataDTO screenProjectImgDataEntity = new ScreenProjectImgDataDTO(); + screenProjectImgDataEntity.setCustomerId(param.getCustomerId()); + screenProjectImgDataEntity.setProjectId(item.getProjectId()); + screenProjectImgDataEntity.setProjectImgUrl(projectImgUrl[i]); + screenProjectImgDataEntity.setSort(i); + imgList.add(screenProjectImgDataEntity); + } + screenProjectImgDataDao.insertBatch(imgList); + } + } + + private void setLevelByCreateTime(ScreenProjectDataInfoFormDTO item, String projectStatusCode) { + if(item.getProjectLevel() == null){ + //todo 动态获取超时时间 + //如果结案 结案时间立项时间; + if ("closed_case".equals(projectStatusCode)) { + Date createTime = item.getProjectCreateTime(); + Date closeCaseTime = item.getCloseCaseTime(); + + if (closeCaseTime.getTime() - createTime.getTime() <= 1000 * 60 * 60 * 24 * 4L) { + //如果结案时间-立项时间小于等于4天 未超期 level3 + item.setProjectLevel(3); + } else if (closeCaseTime.getTime() - createTime.getTime() <= 1000 * 60 * 60 * 24 * 5L) { + //如果结案时间-立项时间大于4天小于5天 即将超期 level2 + item.setProjectLevel(2); + } else { + //大于5天 已超期 level1 + item.setProjectLevel(1); + } + } else if ("pending".equals(projectStatusCode)) { + //如果处理中 当前时间-立项时间; + Date createTime = item.getProjectCreateTime(); + Date today = new Date(); + if (today.getTime() - createTime.getTime() <= 1000 * 60 * 60 * 24 * 4L) { + //如果当前时间-立项时间小于等于4天 未超期 level3 + item.setProjectLevel(3); + } else if (today.getTime() - createTime.getTime() <= 1000 * 60 * 60 * 24 * 5L) { + //如果当前时间-立项时间大于4天小于5天 即将超期 level2 + item.setProjectLevel(2); + } else { + //大于5天 已超期 level1 + item.setProjectLevel(1); + } + } + } + } /** @@ -255,20 +260,24 @@ public class ScreenProjectDataServiceImpl extends BaseServiceImpl 0) { + while (affectedRows > NumConstant.ZERO) { affectedRows = baseDao.deleteByProjectTimeAndCustomerId(customerId, dateId); } List> partition = ListUtils.partition(meta, NumConstant.ONE_HUNDRED); partition.forEach(part -> { List list = ConvertUtils.sourceToTarget(part, ScreenProjectDataEntity.class); insertBatch(list); + saveCategory(customerId, list); }); } if(!CollectionUtils.isEmpty(orient)){ List> 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 +315,73 @@ public class ScreenProjectDataServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(customerId), ScreenProjectDataEntity::getCustomerId, customerId); + List projectList = baseDao.selectList(wrapper); + saveCategory(customerId, projectList); + } + + private void saveCategory(String customerId, List projectList) { + + Result parentCustomer = operCrmOpenFeignClient.getExternalAndParentCustomerId(customerId); + //删除旧分类 + List projectIds = projectList.stream().map(ScreenProjectDataEntity::getProjectId).collect(Collectors.toList()); + screenProjectCategoryService.deleteByProjectId(customerId, projectIds); + //提取分类信息 + List projectCategoryList = new ArrayList<>(); + projectList.forEach(project -> { + //分类为空不作处理 + if (StringUtils.isBlank(project.getCategoryCode())) { + return; + } + + List 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) { + log.error("customerId:{} categoryCode:{} is not exist in ProjectCategoryDict", customerId, category); + return; + } + if ("external".equals(categoryEntity.getCustomerType())) { + entity.setCategoryCode(categoryEntity.getEpmetCategoryCode()); + CustomerProjectCategoryDictEntity parent = customerProjectCategoryDictService.getByCategoryCode(parentCustomer.getData(), categoryEntity.getEpmetCategoryCode()); + if (null != parent) { + entity.setParentCategoryCode(parent.getParentCategoryCode()); + entity.setLevel(parent.getLevel()); + } else { + log.error("未找到对应分类"); + } + } else { + entity.setCategoryCode(categoryEntity.getCategoryCode()); + entity.setParentCategoryCode(categoryEntity.getParentCategoryCode()); + entity.setLevel(categoryEntity.getLevel()); + } + projectCategoryList.add(entity); + //如果分类数据已经超过100了 就插入一批 + if (projectCategoryList.size() > NumConstant.ONE_HUNDRED){ + screenProjectCategoryService.insertBatch(projectCategoryList); + projectCategoryList.clear(); + } + }); + }); + //如果不为空 则插入剩余的那一部分 + if (projectCategoryList.size() > NumConstant.ZERO){ + screenProjectCategoryService.insertBatch(projectCategoryList); + } + } + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/BaseReportServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/BaseReportServiceImpl.java index b00c8cace6..c6d884c32e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/BaseReportServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/BaseReportServiceImpl.java @@ -1,7 +1,6 @@ package com.epmet.service.impl; import com.epmet.commons.tools.constant.NumConstant; -import com.epmet.constant.BaseReportConstant; import com.epmet.dao.stats.BaseReportDao; import com.epmet.dto.basereport.form.*; import com.epmet.service.BaseReportService; @@ -60,7 +59,8 @@ public class BaseReportServiceImpl implements BaseReportService { } while (deleteNum > NumConstant.ZERO); } if (!CollectionUtils.isEmpty(formDTO.getDataList())) { - baseReportDao.insertBatchAgencyRegUser(formDTO.getDataList()); + ListUtils.partition(formDTO.getDataList(),NumConstant.ONE_HUNDRED) + .forEach(part->baseReportDao.insertBatchAgencyRegUser(part); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml index 12ccf09ab0..75ec0bb250 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml @@ -504,5 +504,41 @@ del_flag = 0 AND customer_id = #{customerId} + + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectCategoryDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectCategoryDao.xml new file mode 100644 index 0000000000..afe80a6416 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectCategoryDao.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + delete from screen_project_category + where CUSTOMER_ID = #{customerId} + + PROJECT_ID = #{projectId} + + + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectDataDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectDataDao.xml index 5930ae87c9..a15debd1c6 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectDataDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectDataDao.xml @@ -269,4 +269,120 @@ ORDER BY a.CREATED_TIME ASC + + + + + + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml index e906015ad2..5b39b9e9a1 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml @@ -88,6 +88,7 @@ WHERE CG.CUSTOMER_ID =#{customerId} and cg.del_flag='0' + AND cg.SYNC_FLAG = '1'