From 29294ac9ad6d9eedff7113e57744b61b980e5944 Mon Sep 17 00:00:00 2001 From: fuliqi <fuliqi@qq.com> Date: 星期五, 29 十一月 2024 10:27:02 +0800 Subject: [PATCH] 首页统计接口+跳转 --- business/src/main/resources/mapper/ProjectInfoMapper.xml | 7 ++ business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java | 119 +++++++++++++++++++++++++++++++-------- common/src/main/java/com/ycl/common/enums/business/ImportanceTypeEnum.java | 31 ++++++++++ business/src/main/java/com/ycl/mapper/ProjectInfoMapper.java | 5 + 4 files changed, 137 insertions(+), 25 deletions(-) diff --git a/business/src/main/java/com/ycl/mapper/ProjectInfoMapper.java b/business/src/main/java/com/ycl/mapper/ProjectInfoMapper.java index fa9dd84..161a304 100644 --- a/business/src/main/java/com/ycl/mapper/ProjectInfoMapper.java +++ b/business/src/main/java/com/ycl/mapper/ProjectInfoMapper.java @@ -5,8 +5,11 @@ import com.ycl.domain.entity.ProjectInfo; import com.ycl.domain.query.ProjectInfoQuery; import com.ycl.domain.vo.ProjectInfoVO; +import com.ycl.domain.vo.ProjectVO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 椤圭洰绠$悊鍩虹淇℃伅琛� Mapper 鎺ュ彛 @@ -29,4 +32,6 @@ */ IPage getPage(IPage page, @Param("query") ProjectInfoQuery query); + List<ProjectVO> homeCount(); + } diff --git a/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java b/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java index 49caeed..060e8cf 100644 --- a/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java +++ b/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java @@ -1,15 +1,16 @@ package com.ycl.service.impl; -import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ycl.common.base.Result; import com.ycl.common.enums.business.FileTypeEnum; +import com.ycl.common.enums.business.ImportanceTypeEnum; import com.ycl.common.enums.business.ProjectCategoryEnum; import com.ycl.common.utils.CopyUtils; import com.ycl.common.utils.DateUtils; import com.ycl.common.utils.SecurityUtils; +import com.ycl.common.utils.StringUtils; import com.ycl.domain.entity.*; import com.ycl.domain.form.DocumentInfoForm; import com.ycl.domain.form.ProjectInfoForm; @@ -20,11 +21,12 @@ import com.ycl.service.FileService; import com.ycl.service.ProjectInfoService; import lombok.RequiredArgsConstructor; -import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.*; import java.util.stream.Collectors; @@ -125,16 +127,16 @@ @Override @Transactional(rollbackFor = Exception.class) public Result removeById(Long id) { - investmentFundingMapper.delete(new QueryWrapper<ProjectInvestmentFunding>().eq("project_id",id)); - investmentInfoMapper.delete(new QueryWrapper<ProjectInvestmentInfo>().eq("project_id",id)); - policyMapper.delete(new QueryWrapper<ProjectInvestmentPolicyCompliance>().eq("project_id",id)); - unitRegistrationInfoMapper.delete(new QueryWrapper<ProjectUnitRegistrationInfo>().eq("project_id",id)); + investmentFundingMapper.delete(new QueryWrapper<ProjectInvestmentFunding>().eq("project_id", id)); + investmentInfoMapper.delete(new QueryWrapper<ProjectInvestmentInfo>().eq("project_id", id)); + policyMapper.delete(new QueryWrapper<ProjectInvestmentPolicyCompliance>().eq("project_id", id)); + unitRegistrationInfoMapper.delete(new QueryWrapper<ProjectUnitRegistrationInfo>().eq("project_id", id)); List<String> types = new ArrayList<>(); types.add(FileTypeEnum.PROJECT_INFO.getType()); types.add(FileTypeEnum.INVEST_POLICY.getType()); types.add(FileTypeEnum.DOCUMENT_INFO.getType()); - fileMapper.delete(new QueryWrapper<File>().eq("bus_id",id).in("type",types)); + fileMapper.delete(new QueryWrapper<File>().eq("bus_id", id).in("type", types)); baseMapper.deleteById(id); return Result.ok("鍒犻櫎鎴愬姛"); } @@ -176,10 +178,10 @@ List<ProjectInfoVO> records = page.getRecords(); List<ProjectVO> list = new ArrayList<>(); records.forEach(vo -> { - ProjectInfoVO.transform(vo); - vo.setProjectColorCode("green"); + ProjectInfoVO.transform(vo); + vo.setProjectColorCode("green"); ProjectVO projectVO = new ProjectVO(); - copyToProjectVO(vo,projectVO); + copyToProjectVO(vo, projectVO); //缈昏瘧椤圭洰闃舵 String phase = ProjectCategoryEnum.getPhaseByProjectStatus(projectVO.getProjectStatus(), projectVO.getProcessId() != null); projectVO.setProjectPhase(phase); @@ -188,13 +190,17 @@ return Result.ok().data(list).total(page.getTotal()); } - private void copyToProjectVO(ProjectInfoVO vo,ProjectVO projectVO) { + private void copyToProjectVO(ProjectInfoVO vo, ProjectVO projectVO) { //蹇界暐null鍊肩殑澶嶅埗 CopyUtils.copyNoNullProperties(vo, projectVO); - if(vo.getProjectInvestmentFunding()!=null) CopyUtils.copyNoNullProperties(vo.getProjectInvestmentFunding(),projectVO); - if(vo.getProjectInvestmentInfo()!=null) CopyUtils.copyNoNullProperties(vo.getProjectInvestmentInfo(),projectVO); - if(vo.getProjectUnitRegistrationInfo()!=null) CopyUtils.copyNoNullProperties(vo.getProjectUnitRegistrationInfo(),projectVO); - if(vo.getProjectInvestmentPolicyCompliance()!=null) CopyUtils.copyNoNullProperties(vo.getProjectInvestmentPolicyCompliance(),projectVO); + if (vo.getProjectInvestmentInfo() != null) + CopyUtils.copyNoNullProperties(vo.getProjectInvestmentInfo(), projectVO); + if (vo.getProjectUnitRegistrationInfo() != null) + CopyUtils.copyNoNullProperties(vo.getProjectUnitRegistrationInfo(), projectVO); + if (vo.getProjectInvestmentPolicyCompliance() != null) + CopyUtils.copyNoNullProperties(vo.getProjectInvestmentPolicyCompliance(), projectVO); + if (vo.getProjectInvestmentFunding() != null) + CopyUtils.copyNoNullProperties(vo.getProjectInvestmentFunding(), projectVO); } /** @@ -240,18 +246,81 @@ // {"type":"鐪侀噸鐐归」鐩�","count":0,"amount":"0.00","text":"鐪�"}]}} IndexCountVO indexCountVO = new IndexCountVO(); List<IndexProPhaseCountVO> proPhaseCountVO = new ArrayList<>(); - proPhaseCountVO.add(new IndexProPhaseCountVO("鍌ㄥ瑙勫垝闃舵", 0, "0.00", "鍌�")); - proPhaseCountVO.add(new IndexProPhaseCountVO("椤圭洰鍓嶆湡闃舵", 0, "0.00", "鏂�")); - proPhaseCountVO.add(new IndexProPhaseCountVO("瀹炴柦闃舵", 0, "0.00", "寤�")); - proPhaseCountVO.add(new IndexProPhaseCountVO("绔e伐鎶曠敤闃舵", 0, "0.00", "绔�")); - List<IndexImpTypeCountVO> impTypeCountVO = new ArrayList<>(); - impTypeCountVO.add(new IndexImpTypeCountVO("涓�鑸」鐩�", 0, "0.00", "鏅�")); - impTypeCountVO.add(new IndexImpTypeCountVO("鍘块噸鐐归」鐩�", 0, "0.00", "鍘�")); - impTypeCountVO.add(new IndexImpTypeCountVO("甯傞噸鐐归」鐩�", 0, "0.00", "甯�")); - impTypeCountVO.add(new IndexImpTypeCountVO("鐪侀噸鐐归」鐩�", 0, "0.00", "鐪�")); - indexCountVO.setImpTypeCountVO(impTypeCountVO); + List<ProjectVO> projectVOS = baseMapper.homeCount(); + List<ProjectVO> reserve = new ArrayList<>(); + List<ProjectVO> previous = new ArrayList<>(); + List<ProjectVO> implement = new ArrayList<>(); + List<ProjectVO> finish = new ArrayList<>(); + List<ProjectVO> normal = new ArrayList<>(); + List<ProjectVO> province = new ArrayList<>(); + List<ProjectVO> city = new ArrayList<>(); + List<ProjectVO> county = new ArrayList<>(); + projectVOS.forEach(item -> { + if (ProjectCategoryEnum.RESERVE.getDesc().equals(ProjectCategoryEnum.getPhaseByProjectStatus(item.getProjectStatus(), item.getProcessId() != null))) { + reserve.add(item); + } else if (ProjectCategoryEnum.PREVIOUS.getDesc().equals(ProjectCategoryEnum.getPhaseByProjectStatus(item.getProjectStatus(), item.getProcessId() != null))) { + previous.add(item); + } else if (ProjectCategoryEnum.IMPLEMENT.getDesc().equals(ProjectCategoryEnum.getPhaseByProjectStatus(item.getProjectStatus(), item.getProcessId() != null))) { + implement.add(item); + } else if (ProjectCategoryEnum.FINISH.getDesc().equals(ProjectCategoryEnum.getPhaseByProjectStatus(item.getProjectStatus(), item.getProcessId() != null))) { + finish.add(item); + } + + if (ImportanceTypeEnum.PROVINCIAL_KEY.getType().equals(item.getImportanceType())) { + province.add(item); + } else if (ImportanceTypeEnum.SUINING_KEY.getType().equals(item.getImportanceType())) { + city.add(item); + } else if (ImportanceTypeEnum.SHEHONG_KEY.getType().equals(item.getImportanceType())) { + county.add(item); + } else if (ImportanceTypeEnum.NORMAL.getType().equals(item.getImportanceType())) { + normal.add(item); + } + }); + //鍗曚綅鍏堥粯璁や负鍏� + proPhaseCountVO.add(new IndexProPhaseCountVO("鍌ㄥ瑙勫垝闃舵", reserve.size(), reserve.stream(). + filter(item -> !StringUtils.isEmpty(item.getTotalInvestment())) + .map(item -> new BigDecimal(item.getTotalInvestment()).setScale(2, RoundingMode.HALF_UP)) + .reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal("100000000"), 2, RoundingMode.HALF_UP).toString(), "鍌�")); + + proPhaseCountVO.add(new IndexProPhaseCountVO("椤圭洰鍓嶆湡闃舵", previous.size(), previous.stream(). + filter(item -> !StringUtils.isEmpty(item.getTotalInvestment())) + .map(item -> new BigDecimal(item.getTotalInvestment()).setScale(2, RoundingMode.HALF_UP)) + .reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal("100000000"), 2, RoundingMode.HALF_UP).toString(), "鏂�")); + + proPhaseCountVO.add(new IndexProPhaseCountVO("瀹炴柦闃舵", implement.size(), implement.stream(). + filter(item -> !StringUtils.isEmpty(item.getTotalInvestment())) + .map(item -> new BigDecimal(item.getTotalInvestment()).setScale(2, RoundingMode.HALF_UP)) + .reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal("100000000"), 2, RoundingMode.HALF_UP).toString(), "寤�")); + + proPhaseCountVO.add(new IndexProPhaseCountVO("绔e伐鎶曠敤闃舵", finish.size(), finish.stream(). + filter(item -> !StringUtils.isEmpty(item.getTotalInvestment())) + .map(item -> new BigDecimal(item.getTotalInvestment()).setScale(2, RoundingMode.HALF_UP)) + .reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal("100000000"), 2, RoundingMode.HALF_UP).toString(), "绔�")); + indexCountVO.setProPhaseCountVO(proPhaseCountVO); + List<IndexImpTypeCountVO> impTypeCountVO = new ArrayList<>(); + impTypeCountVO.add(new IndexImpTypeCountVO("涓�鑸」鐩�", province.size(), province.stream(). + filter(item -> !StringUtils.isEmpty(item.getTotalInvestment())) + .map(item -> new BigDecimal(item.getTotalInvestment()).setScale(2, RoundingMode.HALF_UP)) + .reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal("100000000"), 2, RoundingMode.HALF_UP).toString(), "鏅�")); + + impTypeCountVO.add(new IndexImpTypeCountVO("鍘块噸鐐归」鐩�", city.size(), city.stream(). + filter(item -> !StringUtils.isEmpty(item.getTotalInvestment())) + .map(item -> new BigDecimal(item.getTotalInvestment()).setScale(2, RoundingMode.HALF_UP)) + .reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal("100000000"), 2, RoundingMode.HALF_UP).toString(), "鍘�")); + + impTypeCountVO.add(new IndexImpTypeCountVO("甯傞噸鐐归」鐩�", county.size(), county.stream(). + filter(item -> !StringUtils.isEmpty(item.getTotalInvestment())) + .map(item -> new BigDecimal(item.getTotalInvestment()).setScale(2, RoundingMode.HALF_UP)) + .reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal("100000000"), 2, RoundingMode.HALF_UP).toString(), "甯�")); + + impTypeCountVO.add(new IndexImpTypeCountVO("鐪侀噸鐐归」鐩�", normal.size(), normal.stream(). + filter(item -> !StringUtils.isEmpty(item.getTotalInvestment())) + .map(item -> new BigDecimal(item.getTotalInvestment()).setScale(2, RoundingMode.HALF_UP)) + .reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal("100000000"), 2, RoundingMode.HALF_UP).toString(), "鐪�")); + indexCountVO.setImpTypeCountVO(impTypeCountVO); + return indexCountVO; } diff --git a/business/src/main/resources/mapper/ProjectInfoMapper.xml b/business/src/main/resources/mapper/ProjectInfoMapper.xml index 0da2550..5fbff88 100644 --- a/business/src/main/resources/mapper/ProjectInfoMapper.xml +++ b/business/src/main/resources/mapper/ProjectInfoMapper.xml @@ -153,4 +153,11 @@ order by TPI.gmt_create </select> + <select id="homeCount" resultType="com.ycl.domain.vo.ProjectVO"> + SELECT TPI.*,TPIF.total_investment,TPP.process_instance_id as processId + FROM t_project_info TPI + LEFT JOIN t_project_investment_funding TPIF ON TPI.id = TPIF.project_id and TPIF.deleted = 0 + LEFT JOIN t_project_process TPP ON TPI.id = TPP.project_id and TPP.deleted = 0 + WHERE TPI.deleted = 0 +</select> </mapper> diff --git a/common/src/main/java/com/ycl/common/enums/business/ImportanceTypeEnum.java b/common/src/main/java/com/ycl/common/enums/business/ImportanceTypeEnum.java new file mode 100644 index 0000000..056a218 --- /dev/null +++ b/common/src/main/java/com/ycl/common/enums/business/ImportanceTypeEnum.java @@ -0,0 +1,31 @@ +package com.ycl.common.enums.business; + +import com.baomidou.mybatisplus.annotation.EnumValue; +import com.fasterxml.jackson.annotation.JsonValue; +import lombok.Getter; + +/** + * 閲嶇偣绫诲瀷鏋氫妇 + * + * @author锛歠lq + * @date锛�2024/11/27 18:21 + */ +@Getter +public enum ImportanceTypeEnum { + PROVINCIAL_KEY("provincial_key", "鐪侀噸鐐�"), + SUINING_KEY("suining_key","閬傚畞甯傞噸鐐�"), + //鍘块噸鐐� + SHEHONG_KEY("shehong_key","灏勬椽甯傞噸鐐�"), + NORMAL("normal", "涓�鑸�"); + + @EnumValue // 鏍囨槑璇ュ瓧娈靛瓨鍏ユ暟鎹簱 + private final String type; + + @JsonValue // 鏍囨槑鍦ㄨ浆JSON鏃朵娇鐢ㄨ瀛楁 + private final String desc; + + ImportanceTypeEnum(String type, String desc) { + this.type = type; + this.desc = desc; + } +} -- Gitblit v1.8.0