| | |
| | | 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.AjaxResult; |
| | | 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 org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.logging.Logger; |
| | | |
| | | /** |
| | | * 捐献器官管理Service业务层处理 |
| | |
| | | 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; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<organInfoVO> getOrganCount(TimeVO timeVO) { |
| | | List<organInfoVO> l = new ArrayList<>(); |
| | | 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>(); |
| | |
| | | |
| | | 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()); |
| | | // map_organs.put(sysDictData.getDictValue(), distinctOrgansCount.getGainsum()); |
| | | // map_organs.put("abandonCount", distinctOrgansCount.getAbandonCount()); |
| | | OrganInfoVO organ = new OrganInfoVO(); |
| | | organ.setOrganNo(sysDictData.getDictValue()); |
| | | organ.setCount(distinctOrgansCount.getGainsum()); |
| | | organ.setAbandonCount(distinctOrgansCount.getAbandonCount()); |
| | | l.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); |
| | | } |
| | | // 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()); |
| | | // organ.setAbandonCount(); |
| | | // l.add(organ); |
| | | // } |
| | | |
| | | return l; |
| | | } |
| | |
| | | log.info("serviceDonateorgan的数据为: {}", serviceDonateorgan); |
| | | boolean save = this.save(serviceDonateorgan); |
| | | |
| | | |
| | | // //保存service_organallocation |
| | | // ServiceOrganallocation serviceOrganallocation = new ServiceOrganallocation(); |
| | | // serviceOrganallocation.setAgeunit(serviceDonateorgan.getAgeunit()); |
| | | // serviceOrganallocation.setApplicanttime(serviceDonateorgan.getApplicanttime()); |
| | | // serviceOrganallocation.setIdcardno(serviceDonateorgan.getIdcardno()); |
| | | // serviceOrganallocation.setIdcardtype(Long.valueOf(serviceDonateorgan.getIdcardtype())); |
| | | // serviceOrganallocation.setOrganid(serviceDonateorgan.getId()); |
| | | // serviceOrganallocation.setOrgannumber(serviceDonateorgan.getOrgannumber()); |
| | | // log.info("serviceOrganallocation的数据为: {}", serviceOrganallocation); |
| | | // serviceOrganallocationService.save(serviceOrganallocation); |
| | | } |
| | | return serviceDonateorgans; |
| | | } |
| | |
| | | return true; |
| | | } |
| | | |
| | | |
| | | // @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; |
| | | // } |
| | | |
| | | @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); |
| | | } |
| | | |
| | | } |