From cf4a5deced71464d424ce5931774f6df0c4c6bb3 Mon Sep 17 00:00:00 2001
From: “djh” <“3298565835@qq.com”>
Date: 星期三, 26 十一月 2025 16:30:07 +0800
Subject: [PATCH] 修改新增
---
multi-system/src/main/java/com/gkhy/exam/system/service/impl/StatisticsServiceImpl.java | 216 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 216 insertions(+), 0 deletions(-)
diff --git a/multi-system/src/main/java/com/gkhy/exam/system/service/impl/StatisticsServiceImpl.java b/multi-system/src/main/java/com/gkhy/exam/system/service/impl/StatisticsServiceImpl.java
new file mode 100644
index 0000000..7819b36
--- /dev/null
+++ b/multi-system/src/main/java/com/gkhy/exam/system/service/impl/StatisticsServiceImpl.java
@@ -0,0 +1,216 @@
+package com.gkhy.exam.system.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.gkhy.exam.common.exception.ApiException;
+import com.gkhy.exam.system.domain.*;
+import com.gkhy.exam.system.domain.req.EmployeeRecordReq;
+import com.gkhy.exam.system.domain.vo.EmployeeRecordVO;
+import com.gkhy.exam.system.domain.vo.statistic.CompanyStatisticsVo;
+import com.gkhy.exam.system.mapper.*;
+import com.gkhy.exam.system.service.StatisticsService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Service
+public class StatisticsServiceImpl implements StatisticsService {
+
+ @Autowired
+ private CompanySummaryMapper companySummaryMapper;
+ @Autowired
+ private EmployeeRecordMapper employeeRecordMapper;
+
+ @Autowired
+ private StandingBookMapper standingBookMapper;
+
+ @Autowired
+ private AnnualVerificationPlanMapper annualVerificationPlanMapper;
+
+ @Autowired
+ private AnnualVerificationDeviceMapper annualVerificationDeviceMapper;
+ @Autowired
+ private CompanyQualityPolicyMapper companyQualityPolicyMapper;
+
+ @Autowired
+ private QualityMapper qualityMapper;
+ @Autowired
+ private QualityTargetMapper qualityTargetMapper;
+
+ @Autowired
+ private ContractLedgerMapper contractLedgerMapper;
+
+ @Autowired
+ private AnnualReportMapper annualReportMapper;
+
+ @Autowired
+ private InternalKnowledgeMapper internalKnowledgeMapper;
+
+ @Autowired
+ private TrainPlanMapper trainPlanMapper;
+
+ @Autowired
+ private InternalAuditCheckMapper internalAuditCheckMapper;
+
+ @Autowired
+ private ContinuousImproveMapper continuousImproveMapper;
+
+ @Autowired
+ private OutsourcedProductMapper outsourcedProductMapper;
+
+ @Override
+ public CompanyStatisticsVo getCompanyStatistics(Integer companyId, String year) {
+
+ String yearBegin = year + "-01-01 00:00:00";
+ String yearEnd = year + "-12-31 23:59:59";
+
+ CompanyStatisticsVo companyStatisticsVo = companySummaryMapper.selectCompanyStatistics(companyId);
+ if (companyStatisticsVo == null) {
+ return companyStatisticsVo;
+ }
+ companyStatisticsVo.setYear(year);
+ EmployeeRecordReq req = new EmployeeRecordReq();
+ req.setCompanyId(companyId.longValue());
+ List<EmployeeRecordVO> sysUsers = employeeRecordMapper.selectEmployeeRecordList(req);
+ int totalUser = sysUsers.size();
+ long countJS = sysUsers.stream()
+ .filter(user -> user.getPersonType() != null)
+ .filter(user -> user.getPersonType() == 1) // 技术类
+ .count();
+ companyStatisticsVo.setTotalEmployee(totalUser);
+ companyStatisticsVo.setProfessionalEmployee(
+ countJS > 0 ? (int) countJS : 0
+ );
+
+ //企业资源和能力情况
+
+ LambdaQueryWrapper<StandingBook> queryWrapper = new LambdaQueryWrapper<>();
+ queryWrapper.eq(StandingBook::getCompanyId, companyId);
+ queryWrapper.eq(StandingBook::getDelFlag, 0);
+ List<StandingBook> standingBooks = standingBookMapper.selectList(queryWrapper);
+ //计算计算机总数
+ long computerTotal = standingBooks.stream()
+ .filter(st -> st.getDeviceType() != null)
+ .filter(st -> st.getDeviceType() == 1)
+ .count();
+ //生成设备
+ long productionEquipment = standingBooks.stream()
+ .filter(st -> st.getDeviceType() != null)
+ .filter(st -> st.getDeviceType() == 5)
+ .count();
+ companyStatisticsVo.setComputerTotal(computerTotal > 0 ? (int) computerTotal : 0);
+ companyStatisticsVo.setProductionEquipment(productionEquipment > 0 ? (int) productionEquipment : 0);
+ companyStatisticsVo.setOtherOfficeEquipment(standingBooks.size() - (int) computerTotal - (int) productionEquipment);
+
+ LambdaQueryWrapper<AnnualVerificationPlan> queryWrapper1 = new LambdaQueryWrapper<>();
+ queryWrapper1.eq(AnnualVerificationPlan::getCompanyId, companyId).eq(AnnualVerificationPlan::getDelFlag, 0).eq(AnnualVerificationPlan::getYear, year);
+ List<AnnualVerificationPlan> annualVerificationPlans = annualVerificationPlanMapper.selectList(queryWrapper1);
+ if (!annualVerificationPlans.isEmpty()) {
+ AnnualVerificationPlan annualVerificationPlan = annualVerificationPlans.get(0);
+ LambdaQueryWrapper<AnnualVerificationDevice> queryWrapper2 = new LambdaQueryWrapper<>();
+ queryWrapper2.eq(AnnualVerificationDevice::getAnnualVerificationId, annualVerificationPlan.getId()).eq(AnnualVerificationDevice::getDelFlag, 0).eq(AnnualVerificationDevice::getPlanType, 2);
+ List<AnnualVerificationDevice> annualVerificationDevices = annualVerificationDeviceMapper.selectList(queryWrapper2);
+ companyStatisticsVo.setDetectionEquipment(annualVerificationDevices.size());
+ queryWrapper2.between(AnnualVerificationDevice::getCreateTime, yearBegin, yearEnd);
+ List<AnnualVerificationDevice> annualVerificationDevices1 = annualVerificationDeviceMapper.selectList(queryWrapper2);
+ companyStatisticsVo.setDetectionEquipmentAdd(annualVerificationDevices1.size());
+ } else {
+ companyStatisticsVo.setDetectionEquipment(0);
+ }
+
+ LambdaQueryWrapper<CompanyQualityPolicy> queryWrapper3 = new LambdaQueryWrapper<>();
+ queryWrapper3.eq(CompanyQualityPolicy::getCompanyId, companyId).eq(CompanyQualityPolicy::getDelFlag, 1);
+ List<CompanyQualityPolicy> qualities = companyQualityPolicyMapper.selectList(queryWrapper3);
+ if (!qualities.isEmpty()) {
+ companyStatisticsVo.setCompanyQualityPolicy(qualities.get(0).getPolicy());
+ }
+
+
+ LambdaQueryWrapper<Quality> queryWrapper4 = new LambdaQueryWrapper<>();
+ queryWrapper4.eq(Quality::getCompanyId, companyId).eq(Quality::getDelFlag, 1).eq(Quality::getYear, year);
+ List<Quality> qualities1 = qualityMapper.selectList(queryWrapper4);
+ if (!qualities1.isEmpty()) {
+ LambdaQueryWrapper<QualityTarget> queryWrapper5 = new LambdaQueryWrapper<>();
+ queryWrapper5.eq(QualityTarget::getQualityId, qualities1.get(0).getId()).eq(QualityTarget::getDelFlag, 1).orderByDesc(QualityTarget::getCreateTime);
+ List<QualityTarget> qualityTargets = qualityTargetMapper.selectList(queryWrapper5);
+ if (!qualityTargets.isEmpty()) {
+ List<String> collect = qualityTargets.stream().map(QualityTarget::getMessage).collect(Collectors.toList());
+ companyStatisticsVo.setCompanyQualityTarget(collect);
+ }
+ }
+ LambdaQueryWrapper<ContractLedger> queryWrapper6 = new LambdaQueryWrapper<>();
+ queryWrapper6.eq(ContractLedger::getCompanyId, companyId).eq(ContractLedger::getDelFlag, 1).between(ContractLedger::getSignDate, yearBegin, yearEnd);
+
+ List<ContractLedger> contractLedgers = contractLedgerMapper.selectList(queryWrapper6);
+ companyStatisticsVo.setContractLedger(contractLedgers.size());
+ if (!contractLedgers.isEmpty()) {
+ Long count = contractLedgers.stream().filter(contractLedger -> contractLedger.getDeliver() == 1).count();
+ companyStatisticsVo.setDeliveredContract(count.intValue());
+ } else {
+ companyStatisticsVo.setDeliveredContract(0);
+ }
+ //满意度
+ LambdaQueryWrapper<AnnualReport> queryWrapper7 = new LambdaQueryWrapper<>();
+ queryWrapper7.eq(AnnualReport::getCompanyId, companyId).eq(AnnualReport::getDelFlag, 1).eq(AnnualReport::getYear, year);
+ AnnualReport annualReport = annualReportMapper.selectOne(queryWrapper7);
+ if (annualReport != null) {
+ companyStatisticsVo.setSumSatisficing(annualReport.getSumSatisficing());
+ } else {
+ companyStatisticsVo.setSumSatisficing("0");
+ }
+ //只是产权数量
+ LambdaQueryWrapper<InternalKnowledge> queryWrapper8 = new LambdaQueryWrapper<>();
+ queryWrapper8.eq(InternalKnowledge::getCompanyId, companyId).eq(InternalKnowledge::getDelFlag, 0)
+ .between(InternalKnowledge::getCreateTime, yearBegin, yearEnd);
+ Long l = internalKnowledgeMapper.selectCount(queryWrapper8);
+ companyStatisticsVo.setPatent(l.intValue());
+ //培训计划名称
+ LambdaQueryWrapper<TrainPlan> queryWrapper9 = new LambdaQueryWrapper<>();
+ queryWrapper9.eq(TrainPlan::getCompanyId, companyId).eq(TrainPlan::getDelFlag, 1).between(TrainPlan::getTrainTime, yearBegin, yearEnd);
+ List<TrainPlan> trainPlans = trainPlanMapper.selectList(queryWrapper9);
+ if (!trainPlans.isEmpty()) {
+ String courseNames = trainPlans.stream()
+ .map(TrainPlan::getTrainName)
+ .collect(Collectors.joining(","));
+ companyStatisticsVo.setTrainPlanName(courseNames);
+ }
+ //内审检查不符合
+ int statisticData = internalAuditCheckMapper.getStatisticData(companyId, yearBegin, yearEnd);
+ companyStatisticsVo.setInternalAuditCheckResult(statisticData);
+ //改进项
+ int conStatistic = continuousImproveMapper.getConStatistic(companyId, year);
+ companyStatisticsVo.setConStatisticNum(conStatistic);
+ LambdaQueryWrapper<OutsourcedProduct> queryWrapper10 = new LambdaQueryWrapper<>();
+ queryWrapper10.eq(OutsourcedProduct::getCompanyId, companyId).eq(OutsourcedProduct::getDelFlag, 0)
+ .between(OutsourcedProduct::getCreateTime, yearBegin, yearEnd);
+ List<OutsourcedProduct> outsourcedProducts = outsourcedProductMapper.selectList(queryWrapper10);
+ if (!outsourcedProducts.isEmpty()){
+ String ps = outsourcedProducts.stream()
+ .map(OutsourcedProduct::getProductName)
+ .collect(Collectors.joining(","));
+ companyStatisticsVo.setOutsourcedProduct(ps);
+ }
+
+ req.setCompanyId(companyId.longValue());
+ req.setStartTime(yearBegin);
+ req.setEndTime(yearEnd);
+ List<EmployeeRecordVO> sysUsersAdd = employeeRecordMapper.selectEmployeeRecordList(req);
+ int totalUserAdd = sysUsersAdd.size();
+ long countJSAdd = sysUsersAdd.stream()
+ .filter(user -> user.getPersonType() != null)
+ .filter(user -> user.getPersonType() == 1) // 技术类
+ .count();
+ companyStatisticsVo.setTotalEmployeeAdd(totalUserAdd);
+ companyStatisticsVo.setProfessionalEmployeeAdd(
+ countJSAdd > 0 ? (int) countJSAdd : 0
+ );
+
+ queryWrapper9.eq(TrainPlan::getStatus, 0);
+ Long l1 = trainPlanMapper.selectCount(queryWrapper9);
+ companyStatisticsVo.setTrainPlanCompleted(l1.intValue());
+
+ return companyStatisticsVo;
+ }
+
+}
--
Gitblit v1.9.2