diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/controller/ProjectDetailsStatisticsCollectManifestController.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/controller/ProjectDetailsStatisticsCollectManifestController.java new file mode 100644 index 000000000..6ba8d18ae --- /dev/null +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/controller/ProjectDetailsStatisticsCollectManifestController.java @@ -0,0 +1,50 @@ +package com.jero.modules.cert.collect.controller; + +import com.jero.common.api.vo.Result; +import com.jero.common.aspect.annotation.AutoLog; +import com.jero.modules.cert.collect.service.IParamsManifestEOService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.Map; + +@Api(tags="项目详情-参数收集统计接口") +@RestController +@RequestMapping("/project/projectLibraryBase") +@Slf4j +public class ProjectDetailsStatisticsCollectManifestController { + @Autowired + private IParamsManifestEOService paramsManifestEOService; + + /** + * 项目详情-参数收集统计接口-清单下拉选项 + * @return + */ + @AutoLog(value = "项目详情-参数收集统计接口-清单下拉选项") + @ApiOperation(value="项目详情-参数收集统计接口-清单下拉选项", notes="项目详情-参数收集统计接口-清单下拉选项") + @GetMapping(value = "/getProjectDetailsStatisticsCollectManifestLabel") + public Result getProjectDetailsStatisticsCollectManifestLabel(@RequestParam(name="id",required=true) String id) { + List> labelList = paramsManifestEOService.labelListForProjectDetails(id); + return Result.OK(labelList); + } + + /** + * 项目详情-参数收集统计接口-统计结果 + * @return + */ + @AutoLog(value = "项目详情-参数收集统计接口-统计结果") + @ApiOperation(value="项目详情-参数收集统计接口-统计结果", notes="项目详情-参数收集统计接口-统计结果") + @GetMapping(value = "/getProjectDetailsStatisticsCollectManifestData") + public Result getProjectDetailsStatisticsCollectManifestData(@RequestParam(name="paramsManifestId",required=true) String paramsManifestId, + @RequestParam(name="cut",required=true) String cut) { + List> data = paramsManifestEOService.getStatisticsForProjectDetails(paramsManifestId, cut); + return Result.OK(data); + } +} diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/enums/CollectManifestStatisticsStateEnum.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/enums/CollectManifestStatisticsStateEnum.java new file mode 100644 index 000000000..9db2c1c9c --- /dev/null +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/enums/CollectManifestStatisticsStateEnum.java @@ -0,0 +1,61 @@ +package com.jero.modules.cert.collect.enums; + +import com.jero.common.constant.enums.CutEnum; + +import java.util.HashMap; +import java.util.Map; + +public enum CollectManifestStatisticsStateEnum { + NOT_START("未开始","Not start","not start"), + COLLECTING("收集中","Collecting","collecting"), + SUBMIT("已提交","Submit","submit"), + SYNC_REPORT("已同步至上报库","Sync Report","sync report"); + + String name; + String enName; + String value; + + CollectManifestStatisticsStateEnum(String name, String enName, String value) { + this.name = name; + this.enName = enName; + this.value = value; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getEnName() { + return enName; + } + + public void setEnName(String enName) { + this.enName = enName; + } + + public static Map toMap(String cut){ + Map map = new HashMap<>(); + if (CutEnum.CN.getValue().equals(cut)) { + for (CollectManifestStatisticsStateEnum collectManifestStatisticsStateEnum : CollectManifestStatisticsStateEnum.values()) { + map.put(collectManifestStatisticsStateEnum.getValue(), collectManifestStatisticsStateEnum.getName()); + } + } else if (CutEnum.EN.getValue().equals(cut)) { + for (CollectManifestStatisticsStateEnum collectManifestStatisticsStateEnum : CollectManifestStatisticsStateEnum.values()) { + map.put(collectManifestStatisticsStateEnum.getValue(), collectManifestStatisticsStateEnum.getEnName()); + } + } + return map; + } +} diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/mapper/ParamsManifestEOMapper.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/mapper/ParamsManifestEOMapper.java index a64cf9c60..97a6d0c9b 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/mapper/ParamsManifestEOMapper.java +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/mapper/ParamsManifestEOMapper.java @@ -7,6 +7,7 @@ import com.jero.modules.cert.collect.vo.ParamsManifestVO; import org.apache.ibatis.annotations.Param; import java.util.List; +import java.util.Map; /** * @Description: 参数清单 @@ -25,4 +26,5 @@ public interface ParamsManifestEOMapper extends BaseMapper { ParamsManifestVO getProjectById(@Param("projectId") String projectId); + List> labelListForProjectDetails(@Param("projectId") String projectId); } diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/mapper/xml/ParamsManifestEOMapper.xml b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/mapper/xml/ParamsManifestEOMapper.xml index 77c21dc38..0eddd3337 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/mapper/xml/ParamsManifestEOMapper.xml +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/mapper/xml/ParamsManifestEOMapper.xml @@ -124,4 +124,13 @@ ) tmp_tb where project_id = #{projectId} + + \ No newline at end of file diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/IParamsManifestEOService.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/IParamsManifestEOService.java index 624f50336..905f65650 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/IParamsManifestEOService.java +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/IParamsManifestEOService.java @@ -9,6 +9,7 @@ import com.jero.modules.cert.collect.vo.ParamsManifestVO; import com.jero.modules.cert.template.entity.ParamsTemplateEO; import java.util.List; +import java.util.Map; /** * @Description: 参数清单 @@ -82,4 +83,8 @@ public interface IParamsManifestEOService extends IService { ParamsManifestEO copy(ParamsManifestEO paramsManifestEO, String sourceManifestId); ParamsManifestVO getProjectById(String projectId); + + List> labelListForProjectDetails(String projectId); + + List> getStatisticsForProjectDetails(String paramsManifestId, String cut); } diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/impl/ParamsManifestEOServiceImpl.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/impl/ParamsManifestEOServiceImpl.java index 4225a1e7a..3a58e3598 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/impl/ParamsManifestEOServiceImpl.java +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/impl/ParamsManifestEOServiceImpl.java @@ -8,12 +8,14 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.jero.common.constant.enums.CutEnum; import com.jero.common.exception.JeroBootException; +import com.jero.common.system.vo.DictModel; import com.jero.modules.cert.collect.entity.ParamsCollectManifestEO; import com.jero.modules.cert.collect.entity.ParamsConfigDataEO; import com.jero.modules.cert.collect.entity.ParamsConfigEO; import com.jero.modules.cert.collect.entity.ParamsManifestEO; import com.jero.modules.cert.collect.enums.CollectManifestChangeFlagEnum; import com.jero.modules.cert.collect.enums.CollectManifestStateEnum; +import com.jero.modules.cert.collect.enums.CollectManifestStatisticsStateEnum; import com.jero.modules.cert.collect.enums.ManifestStateEnum; import com.jero.modules.cert.collect.mapper.ParamsCollectManifestEOMapper; import com.jero.modules.cert.collect.mapper.ParamsConfigEOMapper; @@ -30,6 +32,7 @@ import com.jero.modules.cert.template.service.IParamsTemplateEOService; import com.jero.modules.project.entity.ProjectRelatedPersonnel; import com.jero.modules.project.service.IProjectRelatedPersonnelService; import com.jero.modules.system.entity.SysUser; +import com.jero.modules.system.mapper.SysDictMapper; import com.jero.modules.system.service.ISysUserService; import org.apache.commons.lang.StringUtils; import org.springframework.beans.BeanUtils; @@ -38,6 +41,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; +import java.text.NumberFormat; import java.util.*; import java.util.stream.Collectors; @@ -87,6 +91,8 @@ public class ParamsManifestEOServiceImpl extends ServiceImpl> labelListForProjectDetails(String projectId) { + return paramsManifestEOMapper.labelListForProjectDetails(projectId); + } + + @Override + public List> getStatisticsForProjectDetails(String paramsManifestId, String cut) { + // 查询所有责任领域 + List dutyTerritoryDictList = sysDictMapper.queryDictItemsByCode("duty_territory"); + + // 统计清单参数 + ParamsCollectManifestEO paramsCollectManifestEO = new ParamsCollectManifestEO(); + paramsCollectManifestEO.setParamsManifestId(paramsManifestId); + List> listAll = paramsCollectManifestEOMapper.listInfoForExport(paramsCollectManifestEO); + + double total = listAll.size(); + + if (total > 0) { + List> result = new LinkedList<>(); + dutyTerritoryDictList.forEach(item->{ + // 计算数量 + double notStartNumber = listAll.stream().filter(e -> (CollectManifestStateEnum.WAIT_COLLECT.getValue().equals(e.get("state")) + || CollectManifestStateEnum.SDT_BACK.getValue().equals(e.get("state")) + || CollectManifestStateEnum.CHANGE.getValue().equals(e.get("state"))) && item.getValue().equals(e.get("duty_territory"))) + .count(); // 未开始的参数项 数量 + + double collectingNumber = listAll.stream().filter(e -> (CollectManifestStateEnum.WAIT_SDT.getValue().equals(e.get("state")) + || CollectManifestStateEnum.WAIT_FILL.getValue().equals(e.get("state")) + || CollectManifestStateEnum.DRE_BACK.getValue().equals(e.get("state")) + || CollectManifestStateEnum.CERT_BACK.getValue().equals(e.get("state"))) && item.getValue().equals(e.get("duty_territory"))) + .count(); // 收集中的参数项 数量 + + double submitNumber = listAll.stream().filter(e -> CollectManifestStateEnum.SUBMIT.getValue().equals(e.get("state")) && item.getValue().equals(e.get("duty_territory"))) + .count(); // 已提交的参数项 数量 + + double syncReportNumber = listAll.stream().filter(e -> CollectManifestStateEnum.SYNC_REPORT.getValue().equals(e.get("state")) && item.getValue().equals(e.get("duty_territory"))) + .count(); // 已同步上报库的参数项 数量 + + // 计算百分比 + String notStartPercent = getRatio(notStartNumber, total); // 未开始的参数项 百分比 + String collectingPercent = getRatio(collectingNumber, total); // 收集中的参数项 百分比 + String submitPercent = getRatio(submitNumber, total); // 已提交的参数项 百分比 + String syncReportPercent = getRatio(syncReportNumber, total); // 已同步上报库的参数项 百分比 + + + Map map = new HashMap<>(); + // 组装数据 返回前端 + List> data = new LinkedList<>(); + getData(data, cut, notStartNumber, notStartPercent); + getData(data, cut, collectingNumber, collectingPercent); + getData(data, cut, submitNumber, submitPercent); + getData(data, cut, syncReportNumber, syncReportPercent); + + if (CutEnum.EN.getValue().equals(cut)) { + map.put(item.getTextEn(), data); + } else { + map.put(item.getText(), data); + } + + result.add(map); + }); + return result; + } + + return null; + } + + private void getData(List> data, String cut, double quantity, String percentage) { + + Map notStartMap = new HashMap<>(); + if (CutEnum.EN.getValue().equals(cut)) { + notStartMap.put("name", CollectManifestStatisticsStateEnum.NOT_START.getEnName()); + } else { + notStartMap.put("name", CollectManifestStatisticsStateEnum.NOT_START.getName()); + } + notStartMap.put("type", CollectManifestStatisticsStateEnum.NOT_START.getValue()); + notStartMap.put("quantity", quantity); + notStartMap.put("percentage", percentage); + data.add(notStartMap); + } + + private String getRatio(Double d1, Double d2) { + if (d1 == null || d2 == null || d2 <= 0) { + return "0%"; + } + NumberFormat percent = NumberFormat.getPercentInstance(); + percent.setMaximumFractionDigits(2); + percent.setMinimumFractionDigits(2); + return percent.format(d1/d2); + } + }