liusheng
2023-10-26 dcd3eb3bbbc25b01155493f20f5680fc6d4aee11
ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceDonateorganServiceImpl.java
@@ -1,6 +1,7 @@
package com.ruoyi.project.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.entity.SysDictData;
@@ -8,13 +9,15 @@
import com.ruoyi.project.domain.*;
import com.ruoyi.project.domain.vo.*;
import com.ruoyi.project.mapper.*;
import com.ruoyi.project.service.IServiceDonateorganService;
import com.ruoyi.project.service.*;
import com.ruoyi.system.mapper.SysDictDataMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
 * 捐献器官管理Service业务层处理
@@ -23,8 +26,7 @@
 * @date 2021-11-10
 */
@Service
public class ServiceDonateorganServiceImpl extends ServiceImpl<ServiceDonateorganMapper, ServiceDonateorgan> implements IServiceDonateorganService
{
public class ServiceDonateorganServiceImpl extends ServiceImpl<ServiceDonateorganMapper, ServiceDonateorgan> implements IServiceDonateorganService {
    @Autowired
    ServiceDonateorganMapper serviceDonateorganMapper;
@@ -56,10 +58,26 @@
    @Autowired
    ServiceDonatecompletioninfoMapper serviceDonatecompletioninfoMapper;
    @Autowired
    private SysDictDataMapper dictDataMapper;
    @Autowired
    private IServiceMedicalevaluationService serviceMedicalevaluationService;
    @Autowired
    private IServiceRelativesconfirmationService serviceRelativesconfirmationService;
    @Autowired
    private IServiceEthicalreviewopinionsService serviceEthicalreviewopinionsService;
    @Autowired
    private IServiceOrganallocationService serviceOrganallocationService;
    @Autowired
    private IServiceDonationwitnessService serviceDonationwitnessService;
    @Autowired
    private IServiceDonatecompletioninfoService serviceDonatecompletioninfoService;
    /**
@@ -239,8 +257,7 @@
        int donateNumber = serviceDonatebaseinfoMapper.getDonateBaseCountThisYear(timeVO);
        if(donateNumber == 0){
            og.setDonateTransferRate(0.0);
        }
        else {
        } else {
            double transferRate = (double) transferNumber / (double) donateNumber;
            og.setDonateTransferRate(transferRate);
        }
@@ -258,8 +275,7 @@
            og.setDBDDonateRate(0.0);
            og.setDCDDonateRate(0.0);
            og.setDBCDDonateRate(0.0);
        }
        else{
        } else {
            double productionRate = (double) organTransplantNumber / (double) transferNumber;
            og.setOrganProductionRate(productionRate);
@@ -291,8 +307,7 @@
            og.setOrganAfterGetCheckRate(0.0);
            og.setMarginOrganRate(0.0);
            og.setGermPositiveRate(0.0);
        }
        else{
        } else {
            double organUsedRate = (double) organTransplantNumber / (double) getOrganNumber;
            og.setOrganUsedRate(organUsedRate);
@@ -313,8 +328,7 @@
        int PNFNumber = serviceDonateorganMapper.getPNFNumberThisYear(timeVO);
        if(organTransplantNumber == 0){
            og.setTotalPNFRate(0.0);
        }
        else{
        } else {
            double PNFRate = (double) PNFNumber / (double) organTransplantNumber;
            og.setTotalPNFRate(PNFRate);
        }
@@ -369,12 +383,10 @@
        if(organTransplantNumber == 0){
            og.setTotalDGFRate(0.0);
        }
        else{
        } else {
            double DGFRate = (double) DGFNumber / (double) organTransplantNumber;
            og.setTotalDGFRate(DGFRate);
        }
        //本年度DBD来源器官DGF数量
@@ -400,8 +412,7 @@
        if(countDBD == 0){
            og.setDBDPNFRate(0.0);
            og.setDBDDGFRate(0.0);
        }
        else{
        } else {
            double DBDPNFRate = (double) countDBDPNF / (double) countDBD;
            og.setDBDPNFRate(DBDPNFRate);
@@ -412,8 +423,7 @@
        if(countDCD == 0){
            og.setDCDPNFRate(0.0);
            og.setDCDDGFRate(0.0);
        }
        else{
        } else {
            double DCDPNFRate = (double) countDCDPNF / (double) countDCD;
            og.setDCDPNFRate(DCDPNFRate);
@@ -424,8 +434,7 @@
        if(countDBCD == 0){
            og.setDBCDPNFRate(0.0);
            og.setDBCDDGFRate(0.0);
        }
        else{
        } else {
            double DBCDPNFRate = (double) countDBCDPNF / (double) countDBCD;
            og.setDBCDPNFRate(DBCDPNFRate);
@@ -508,8 +517,7 @@
                ServiceDonatecompletioninfo sc = serviceDonatecompletioninfoMapper.getByInfoId(s.getId());
                if(sc != null){
                    map_completion_count.put(month, map_completion_count.getOrDefault(month,0) + 1);
                }
                else{
                } else {
                    map_completion_count.put(month, map_completion_count.getOrDefault(month,0));
                }
@@ -555,19 +563,16 @@
                }
            }
            if(map_baseinfo_count.size()==0)
            {
            if (map_baseinfo_count.size() == 0) {
                map_baseinfo_count.put(Organizationid, map_baseinfo_count.getOrDefault(Organizationid,0));
            }
            if(map_completion_count.size()==0)
            {
            if (map_completion_count.size() == 0) {
                map_completion_count.put(Organizationid, map_completion_count.getOrDefault(Organizationid,0));
            }
            // for(Map.Entry<String, Integer> entry: map_baseinfo_count.entrySet()) {
            if(map_baseinfo_count.get(b.getOrganizationid())>0 || map_completion_count.get(b.getOrganizationid())>0)
            {
            if (map_baseinfo_count.get(b.getOrganizationid()) > 0 || map_completion_count.get(b.getOrganizationid()) > 0) {
                DonateByRegionVO d = new DonateByRegionVO();
                d.setHospitalNumber(b.getOrganizationid());
                d.setHospitalName(b.getOrganizationname());
@@ -726,15 +731,13 @@
        //List<String> organNo = new ArrayList<>();
        List<SysDictData>  data = dictDataMapper.selectDictDataByType("sys_Organ");
        if (StringUtils.isNull(data))
        {
        if (StringUtils.isNull(data)) {
            data = new ArrayList<SysDictData>();
        }
        for(SysDictData sysDictData : data){
            if(!sysDictData.getDictValue().equals("C00"))
            {
            if (!sysDictData.getDictValue().equals("C00")) {
                int count = serviceDonateorganMapper.getDistinctOrgansCount(sysDictData.getDictValue(),timeVO.getStarttime(),timeVO.getEndtime(),timeVO.getCity(),timeVO.getReporterno());
                map_organs.put(sysDictData.getDictValue(), count);
            }
@@ -748,6 +751,98 @@
        }
        return l;
    }
    @Override
    public Map<String, Object> getWorkFlow(Long id) {
        //用于返回
        Map<String, Object> map = new ConcurrentHashMap<>();
        ServiceDonateorgan serviceDonateorgan = getById(id);
        if (ObjectUtils.isEmpty(serviceDonateorgan)) {
            return null;
        }
        //封装serviceDonateorgan潜在捐献数据
        Map<String, String> donateorgan = new HashMap<>();
        donateorgan.put("createtime", serviceDonateorgan.getCreateTime().toString());
        donateorgan.put("updatetime", serviceDonateorgan.getUpdateTime().toString());
        donateorgan.put("process", "");
        //封装医学评估
        Map<String, String> medicalevaluation = new HashMap<>();
        ServiceMedicalevaluation serviceMedicalevaluation = new ServiceMedicalevaluation();
        serviceMedicalevaluation.setInfoid(id);
        List<ServiceMedicalevaluation> serviceMedicalevaluations = serviceMedicalevaluationService.queryList(serviceMedicalevaluation);
        if (!CollectionUtils.isEmpty(serviceMedicalevaluations)) {
            medicalevaluation.put("createtime", serviceMedicalevaluations.get(0).getCreateTime().toString());
            medicalevaluation.put("updatetime", serviceMedicalevaluations.get(0).getUpdateTime().toString());
            medicalevaluation.put("process", "");
        }
        //封装捐献确认
        Map<String, String> relativesconfirmation = new HashMap<>();
        ServiceRelativesconfirmation serviceRelativesconfirmation = new ServiceRelativesconfirmation();
        serviceRelativesconfirmation.setInfoid(id);
        List<ServiceRelativesconfirmation> serviceRelativesconfirmations = serviceRelativesconfirmationService.queryList(serviceRelativesconfirmation);
        if (!CollectionUtils.isEmpty(serviceRelativesconfirmations)) {
            relativesconfirmation.put("createtime", serviceRelativesconfirmations.get(0).getCreateTime().toString());
            relativesconfirmation.put("updatetime", serviceRelativesconfirmations.get(0).getUpdateTime().toString());
            relativesconfirmation.put("process", "");
        }
        //封装伦理审查
        Map<String, String> ethicalreviewopinions = new HashMap<>();
        ServiceEthicalreviewopinions serviceEthicalreviewopinions = new ServiceEthicalreviewopinions();
        serviceEthicalreviewopinions.setInfoid(id);
        List<ServiceEthicalreviewopinions> serviceEthicalreviewopinionsList = serviceEthicalreviewopinionsService.queryList(serviceEthicalreviewopinions);
        if (!CollectionUtils.isEmpty(serviceEthicalreviewopinionsList)) {
            ethicalreviewopinions.put("createtime", serviceEthicalreviewopinionsList.get(0).getCreateTime().toString());
            ethicalreviewopinions.put("updatetime", serviceEthicalreviewopinionsList.get(0).getUpdateTime().toString());
            ethicalreviewopinions.put("process", "");
        }
        //封装器官分配
        Map<String, String> organallocationService = new HashMap<>();
        ServiceOrganallocation serviceOrganallocation = new ServiceOrganallocation();
        serviceOrganallocation.setOrganid(id);
        List<ServiceOrganallocation> serviceOrganallocations = serviceOrganallocationService.selectServiceOrganallocationList(serviceOrganallocation);
        if (!CollectionUtils.isEmpty(serviceOrganallocations)) {
            organallocationService.put("createtime", serviceOrganallocations.get(0).getCreateTime().toString());
            organallocationService.put("updatetime", serviceOrganallocations.get(0).getUpdateTime().toString());
            organallocationService.put("process", "");
        }
        //封装获取见证
        Map<String, String> donationwitness = new HashMap<>();
        ServiceDonationwitness serviceDonationwitness = serviceDonationwitnessService.getByInfoId(id);
        if (!ObjectUtils.isEmpty(serviceDonationwitness)) {
            donationwitness.put("createtime", serviceDonationwitness.getCreateTime().toString());
            donationwitness.put("updatetime", serviceDonationwitness.getUpdateTime().toString());
            donationwitness.put("process", "");
        }
        //封装完成登记
        Map<String, String> donatecompletioninfo = new HashMap<>();
        ServiceDonatecompletioninfo serviceDonatecompletioninfo = new ServiceDonatecompletioninfo();
        serviceDonatecompletioninfo.setInfoid(id);
        List<ServiceDonatecompletioninfo> serviceDonatecompletioninfos = serviceDonatecompletioninfoService.queryList(serviceDonatecompletioninfo);
        if (!CollectionUtils.isEmpty(serviceDonatecompletioninfos)) {
            donatecompletioninfo.put("createtime", serviceDonatecompletioninfos.get(0).getCreateTime().toString());
            donatecompletioninfo.put("updatetime", serviceDonatecompletioninfos.get(0).getUpdateTime().toString());
            donatecompletioninfo.put("process", "");
        }
        //将数据封闭,并返回
        map.put("donateorgan", donateorgan);
        map.put("medicalevaluation", medicalevaluation);
        map.put("relativesconfirmation", relativesconfirmation);
        map.put("ethicalreviewopinions", ethicalreviewopinions);
        map.put("organallocationService", organallocationService);
        map.put("donationwitness", donationwitness);
        map.put("donatecompletioninfo", donatecompletioninfo);
        return map;
    }
@@ -929,7 +1024,6 @@
        return l;
    }
}