| | |
| | | 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; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.bean.DtoConversionUtils; |
| | | import com.ruoyi.project.domain.*; |
| | | import com.ruoyi.project.domain.vo.*; |
| | | import com.ruoyi.project.mapper.*; |
| | | import com.ruoyi.project.service.*; |
| | | import com.ruoyi.system.mapper.SysDictDataMapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | /** |
| | | * 捐献器官管理Service业务层处理 |
| | |
| | | * @author ruoyi |
| | | * @date 2021-11-10 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class ServiceDonateorganServiceImpl extends ServiceImpl<ServiceDonateorganMapper, ServiceDonateorgan> implements IServiceDonateorganService { |
| | | |
| | |
| | | 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; |
| | | IServiceOrganallocationService serviceOrganallocationService; |
| | | |
| | | |
| | | /** |
| | |
| | | if (serviceDonateorgan.getTransplanttime() != null) { |
| | | wrappers.eq(ServiceDonateorgan::getTransplanttime, serviceDonateorgan.getTransplanttime()); |
| | | } |
| | | if (serviceDonateorgan.getEstimatedtime() != null) { |
| | | wrappers.eq(ServiceDonateorgan::getEstimatedtime, serviceDonateorgan.getEstimatedtime()); |
| | | } |
| | | return this.list(wrappers); |
| | | } |
| | | |
| | |
| | | map_accept.put(org_accept.getCity(), map_accept.getOrDefault(org_accept.getCity(), 0) + 1); |
| | | } |
| | | } |
| | | // List<BasePrcaddressDict> city = basePrcaddressDictMapper.getAllCityOfZJ(); |
| | | // for(BasePrcaddressDict c : city){ |
| | | // NumberOfOrgans numberOfOrgans = new NumberOfOrgans(); |
| | | // numberOfOrgans.setDistrict(c.getAreaname()); |
| | | // numberOfOrgans.setNumberOfHospitals(baseOrganizationMapper.getOrganizationByCity(c.getAreanumber())); |
| | | // numberOfOrgans.setDonateNumber(map_donate.getOrDefault(c.getAreaname(),0)); |
| | | // numberOfOrgans.setAcceptNumber(map_accept.getOrDefault(c.getAreaname(),0)); |
| | | // list.add(numberOfOrgans); |
| | | // } |
| | | |
| | | List<String> regions = new ArrayList<String>(); |
| | | regions.add("0"); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public organQuality getOrganQuality(TimeVO timeVO) { |
| | | organQuality og = new organQuality(); |
| | | public OrganQuality getOrganQuality(TimeVO timeVO) { |
| | | OrganQuality og = new OrganQuality(); |
| | | |
| | | //本年度获取捐献者数量 |
| | | int transferNumber = serviceDonationwitnessMapper.countThisYearByTime(timeVO); |
| | |
| | | og.setDonateTransferRate(transferRate); |
| | | } |
| | | |
| | | //本年度移植器官数量 |
| | | //本年度移植器官数量(含弃用) |
| | | int organTransplantNumber = serviceDonateorganMapper.getAllFinishedOrgansThisYear(timeVO); |
| | | //本年度DBD来源器官捐献者 |
| | | int DBDDonaterNumber = serviceDonationwitnessMapper.getDBDDonaterNumberThisYear(timeVO); |
| | |
| | | int DCDDonaterNumber = serviceDonationwitnessMapper.getDCDDonaterNumberThisYear(timeVO); |
| | | //本年度DBCD来源器官捐献者 |
| | | int DBCDDonaterNumber = serviceDonationwitnessMapper.getDBCDDonaterNumberThisYear(timeVO); |
| | | //查出来的transferNumber有问题,先不用了,用下面相加的transferNumber |
| | | transferNumber = DBDDonaterNumber + DCDDonaterNumber + DBCDDonaterNumber; |
| | | log.info("transferNumber的值为:{}, DBDDonaterNumber的值为:{}, DCDDonaterNumber的值为:{}, DBCDDonaterNumber的值为:{}", transferNumber, DBDDonaterNumber, DCDDonaterNumber, DBCDDonaterNumber); |
| | | if (transferNumber == 0) { |
| | | og.setOrganProductionRate(0.0); |
| | | og.setDBDDonateRate(0.0); |
| | |
| | | og.setMarginOrganRate(0.0); |
| | | og.setGermPositiveRate(0.0); |
| | | } else { |
| | | double organUsedRate = (double) organTransplantNumber / (double) getOrganNumber; |
| | | log.info("timeVO的值为 : {}", timeVO); |
| | | TimeVO timeVO1 = DtoConversionUtils.sourceToTarget(timeVO, TimeVO.class); |
| | | timeVO1.setTransplantstate(1); |
| | | //获取本年度已经移植器官数量 |
| | | int organTransplantNumber2 = serviceDonateorganMapper.getAllFinishedOrgansThisYear(timeVO1); |
| | | log.info("timeVO1的值为 : {}", timeVO1); |
| | | log.info("organTransplantNumber2的值为 : {}", organTransplantNumber2); |
| | | log.info("organTransplantNumber的值为 : {}", organTransplantNumber); |
| | | double organUsedRate = (double) organTransplantNumber2 / (double) organTransplantNumber; |
| | | og.setOrganUsedRate(organUsedRate); |
| | | |
| | | double biopsyBeforeRate = (double) biopsyBeforeNumber / (double) getOrganNumber; |
| | |
| | | donateNumber.setNumberOfDonate(serviceDonatebaseinfoMapper.countNumber(timeVO)); |
| | | donateNumber.setNumberOfMedicalEvaluation(serviceMedicalevaluationMapper.countNumber(timeVO)); |
| | | donateNumber.setNumberOfRelativeConfirmation(serviceRelativesconfirmationMapper.countNumber(timeVO)); |
| | | donateNumber.setNumberOfDonatePeople(serviceOrganallocationMapper.countNumber(timeVO)); |
| | | // donateNumber.setNumberOfDonatePeople(serviceOrganallocationMapper.countNumber(timeVO)); |
| | | donateNumber.setNumberOfDonatePeople(serviceDonateorganMapper.countNumber(timeVO)); |
| | | donateNumber.setNumberOfOrgans(serviceDonateorganMapper.countNumber(timeVO)); |
| | | donateNumber.setNumberOfWitness(serviceDonationwitnessMapper.countNumber(timeVO)); |
| | | donateNumber.setNumberOfEthicalReview(serviceEthicalreviewopinionsMapper.countNumber(timeVO)); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<organInfoVO> getOrganCount(TimeVO timeVO) { |
| | | List<organInfoVO> l = new ArrayList<>(); |
| | | |
| | | //List<ServiceDonateorgan> serviceDonateorgans = serviceDonateorganMapper.selectAll(timeVO); |
| | | Map<String, Integer> map_organs = new HashMap<String, Integer>(); |
| | | //List<String> organNo = new ArrayList<>(); |
| | | public Map<String, Object> getOrganCount(TimeVO timeVO) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<OrganInfoVO> organInfoVOList = new ArrayList<>(); |
| | | Integer countSum = 0; |
| | | Integer abandonCountSum = 0; |
| | | |
| | | List<SysDictData> data = dictDataMapper.selectDictDataByType("sys_Organ"); |
| | | if (StringUtils.isNull(data)) { |
| | | data = new ArrayList<SysDictData>(); |
| | | } |
| | | |
| | | |
| | | for (SysDictData sysDictData : data) { |
| | | 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); |
| | | DistinctOrgansCount distinctOrgansCount = serviceDonateorganMapper.getDistinctOrgansCount(sysDictData.getDictValue(), timeVO.getStarttime(), timeVO.getEndtime(), timeVO.getCity(), timeVO.getReporterno()); |
| | | OrganInfoVO organ = new OrganInfoVO(); |
| | | organ.setOrganNo(sysDictData.getDictValue()); |
| | | organ.setCount(distinctOrgansCount.getGainsum()); |
| | | organ.setAbandonCount(distinctOrgansCount.getAbandonCount()); |
| | | countSum = countSum + distinctOrgansCount.getGainsum(); |
| | | abandonCountSum = abandonCountSum + distinctOrgansCount.getAbandonCount(); |
| | | organInfoVOList.add(organ); |
| | | } |
| | | } |
| | | for (Map.Entry<String, Integer> entry : map_organs.entrySet()) { |
| | | organInfoVO organ = new organInfoVO(); |
| | | organ.setOrganNo(entry.getKey()); |
| | | //organ.setOrganName(serviceDonateorganMapper.getOrganNameByNo(entry.getKey())); |
| | | organ.setCount(entry.getValue()); |
| | | l.add(organ); |
| | | } |
| | | |
| | | 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); |
| | | |
| | | map.put("countSum", countSum); |
| | | map.put("abandonCountSum", abandonCountSum); |
| | | map.put("organInfoVOList", organInfoVOList); |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public List<ServiceDonateorgan> saveData(List<ServiceDonateorgan> serviceDonateorgans) { |
| | | for (ServiceDonateorgan serviceDonateorgan : serviceDonateorgans) { |
| | | if (serviceDonateorgan.getInfoid() == null) { |
| | | throw new BaseException("未关联捐献基础信息,infoid为空了" + serviceDonateorgan); |
| | | } |
| | | |
| | | // @Override |
| | | // public List<DonateByRegionVO> OrgansOfHospitalByMonth() { |
| | | // List<BaseOrganization> baseOrganizations = baseOrganizationMapper.getHospitalList(); |
| | | // List<DonateByRegionVO> l = new ArrayList<>(); |
| | | // List<ServiceDonatebaseinfo> serviceDonatebaseinfos = serviceDonatebaseinfoMapper.getAllDonateBaseInfo(); |
| | | // |
| | | // for(BaseOrganization b : baseOrganizations){ |
| | | // HashMap<String, Integer> map_baseinfo_count = new HashMap<String, Integer>(); |
| | | // HashMap<String, Integer> map_completion_count = new HashMap<String, Integer>(); |
| | | // //List<ServiceDonatebaseinfo> serviceDonatebaseinfos = serviceDonatebaseinfoMapper.getBaseInfoByHospital(b.getOrganizationid()); |
| | | // List<ServiceDonatebaseinfo> serviceDonatebaseinfoOfThisHospital = new ArrayList<>(); |
| | | // for(ServiceDonatebaseinfo sd : serviceDonatebaseinfos){ |
| | | // if(b.getOrganizationid().equals(sd.getTreatmenthospitalno())){ |
| | | // serviceDonatebaseinfoOfThisHospital.add(sd); |
| | | // } |
| | | // } |
| | | // for(ServiceDonatebaseinfo s : serviceDonatebaseinfoOfThisHospital){ |
| | | // Date dt = s.getReporttime(); |
| | | // SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | // String date = formatter.format(dt); |
| | | // String month = date.substring(0, 7); |
| | | // map_baseinfo_count.put(month, map_baseinfo_count.getOrDefault(month,0) + 1); |
| | | // ServiceDonatecompletioninfo sc = serviceDonatecompletioninfoMapper.getByInfoId(s.getId()); |
| | | // if(sc != null){ |
| | | // map_completion_count.put(month, map_completion_count.getOrDefault(month,0) + 1); |
| | | // } |
| | | // else{ |
| | | // map_completion_count.put(month, map_completion_count.getOrDefault(month,0)); |
| | | // } |
| | | // |
| | | // } |
| | | // |
| | | // for(Map.Entry<String, Integer> entry: map_baseinfo_count.entrySet()) { |
| | | // DonateByRegionVO d = new DonateByRegionVO(); |
| | | // d.setHospitalNumber(b.getOrganizationid()); |
| | | // d.setHospitalName(b.getOrganizationname()); |
| | | // d.setRegionLevel(b.getRegionallevel()); |
| | | // d.setMonth(entry.getKey()); |
| | | // d.setBaseInfoCount(entry.getValue()); |
| | | // d.setCompletionCount(map_completion_count.get(entry.getKey())); |
| | | // l.add(d); |
| | | // } |
| | | // } |
| | | // return l; |
| | | // } |
| | | String organNumber = serviceDonateorgan.getDonorno() + "." + serviceDonateorgan.getOrganno(); |
| | | if (StringUtils.isEmpty(serviceDonateorgan.getDonorno()) || StringUtils.isEmpty(serviceDonateorgan.getOrganno())) { |
| | | throw new BaseException("新增时生成的编号为空,创建失败(请检查捐献者编号和器官类别)! :" + serviceDonateorgan.toString()); |
| | | } else { |
| | | ServiceDonateorgan serviceDonateorgan1 = new ServiceDonateorgan(); |
| | | serviceDonateorgan1.setOrgannumber(organNumber); |
| | | List<ServiceDonateorgan> listrecord = this.queryList(serviceDonateorgan); |
| | | if (listrecord.size() > 0) { |
| | | continue; |
| | | } |
| | | } |
| | | serviceDonateorgan.setOrgannumber(organNumber); |
| | | log.info("serviceDonateorgan的数据为: {}", serviceDonateorgan); |
| | | boolean save = this.save(serviceDonateorgan); |
| | | |
| | | } |
| | | return serviceDonateorgans; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean editArrayData(List<ServiceDonateorgan> serviceDonateorgans) { |
| | | for (ServiceDonateorgan serviceDonateorgan : serviceDonateorgans) { |
| | | if (serviceDonateorgan.getId() == null) { |
| | | throw new BaseException("id为空了 :" + serviceDonateorgan); |
| | | } |
| | | this.updateById(serviceDonateorgan); |
| | | } |
| | | //将带ID的数据返回 |
| | | return true; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<DonateNumberByMonth> getDonatePeopleByMonth(TimeVO timeVO) { |
| | |
| | | return l; |
| | | } |
| | | |
| | | @Override |
| | | public List<ServiceDonateorgan> countList(ServiceDonateorgan serviceDonateorgan) { |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | List<SysRole> l = user.getRoles(); |
| | | Boolean b = false; |
| | | for (SysRole r : l) { |
| | | if (r.getRoleId().longValue() == 3) { |
| | | b = true; |
| | | } |
| | | } |
| | | if (b) { |
| | | serviceDonateorgan.setCreateBy(user.getUserName()); |
| | | } |
| | | return serviceDonateorganMapper.countList(serviceDonateorgan); |
| | | } |
| | | |
| | | } |