代码审查1

  public void insertbloodbyOrgId(String orgId) {
        String a = "1";
        String b = "2";
        if (StringUtils.isEmpty(orgId)) {
            return;
        }
        ArrayList<ProScopeConfig> proScopeConfigs = scopeMapper.selectList1(2);
        CountItems count65AndExaminationCount = sampleInfoMapper.getCount65AndExaminationCount1(orgId);
        CountItems count = bloodCellCheckoutMapper.getCount1(orgId);
        //计算65阳性 2 65岁
        List<BloodCellCheckoutStatisicParam> itemsModelParams65 = bloodCellCheckoutMapper.StatisticRate1(orgId, b);
        //计算全部阳性 1全部
        List<BloodCellCheckoutStatisicParam> itemsModelParamsall = bloodCellCheckoutMapper.StatisticRate1(orgId, a);
//        if (count.getExaminationDate() == null) {
//            return;
//        }
        //添加主表
        SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd");
        String format = sdf.format(count.getExaminationDate());
        PositiveRatioStatistic positiveRatioStatistic = new PositiveRatioStatistic();
        positiveRatioStatistic.setOrgId(orgId);
        positiveRatioStatistic.setCheckoutDate(format);
        positiveRatioStatistic.setCheckoutCount(count.getCheckoutCount());
        //2表示血球
        positiveRatioStatistic.setPositiveRatioType("2");
        positiveRatioStatistic.setId(UUIDGenerator.getUUID());
        positiveRatioStatistic.setOrgName(count.getName());

        if (count65AndExaminationCount != null) {
            positiveRatioStatistic.setCheckoutNum(count65AndExaminationCount.getExaminationCount());
            positiveRatioStatistic.setLnrCount(count65AndExaminationCount.getCount65());

        }
        //主表是否存在
        List<PositiveRatioStatistic> positiveRatioStatistics = positiveRatioStatisticMapper.selectList(new QueryWrapper<PositiveRatioStatistic>().lambda().eq(PositiveRatioStatistic::getCheckoutDate, format).eq(PositiveRatioStatistic::getOrgId, orgId).eq(PositiveRatioStatistic::getPositiveRatioType, 2));
        if (!positiveRatioStatistics.isEmpty()) {
            PositiveRatioStatistic positiveRatioStatistic1 = positiveRatioStatistics.get(0);
            String id = positiveRatioStatistic1.getId();
            positiveRatioStatistic.setId(id);
            positiveRatioStatisticMapper.updateById(positiveRatioStatistic);

            List<PositiveRatioStatisticLine> positiveRatioStatisticLines = positiveRatioStatisticLineMapper.selectList(new QueryWrapper<PositiveRatioStatisticLine>().lambda().eq(PositiveRatioStatisticLine::getPositiveRatioId, positiveRatioStatistic.getId()).eq(PositiveRatioStatisticLine::getPositiveType, "2"));
            if (positiveRatioStatisticLines.isEmpty()) {
                insertpositivelist(itemsModelParams65, proScopeConfigs, id, b);
            } else {
                updatebloodlist(itemsModelParams65, proScopeConfigs, id, b);
            }
            updatebloodlist(itemsModelParamsall, proScopeConfigs, id, a);
        } else {
            positiveRatioStatisticMapper.insert(positiveRatioStatistic);
            String id = positiveRatioStatistic.getId();
            //添加65岁可能没有
            insertpositivelist(itemsModelParams65, proScopeConfigs, id, a);
            insertpositivelist(itemsModelParamsall, proScopeConfigs, id, b);
        }

    }

    public void insertpositivelist(List<BloodCellCheckoutStatisicParam> itemsModelParams, List<ProScopeConfig> proScopeConfigs, String positiveRatioStatisticId, String positiveType) {
        if (!itemsModelParams.isEmpty()) {
            for (BloodCellCheckoutStatisicParam d :
                    itemsModelParams) {
                ProScopeConfig conferenceScope = ScopeUtils.getConferenceScope(proScopeConfigs, d.getProjectCode());
                insertchildren(d, positiveRatioStatisticId, conferenceScope, "偏高比", "", positiveType);
                insertchildren(d, positiveRatioStatisticId, conferenceScope, "偏低比", "", positiveType);
                insertchildren(d, positiveRatioStatisticId, conferenceScope, "", "H-", positiveType);
                insertchildren(d, positiveRatioStatisticId, conferenceScope, "", "L-", positiveType);
            }
        }
    }

    public void insertchildren(BloodCellCheckoutStatisicParam d, String positiveRatioStatistic, ProScopeConfig conferenceScope, String codeafterflag, String codebeforeflag, String positivetype) {

        String lowOrhighFlag = "1";//阳性率范围给前端返回格式要用到
        PositiveRatioStatisticLine positiveRatioStatisticLine = new PositiveRatioStatisticLine();
        positiveRatioStatisticLine.setPositiveRatioId(positiveRatioStatistic);
        positiveRatioStatisticLine.setPositiveName(codebeforeflag + d.getProjectCode() + codeafterflag);
        if (!codeafterflag.isEmpty()) {
            if (codeafterflag.equals("偏高比")) {
                positiveRatioStatisticLine.setPositiveRatio(d.getHighRate() + "");
                if (conferenceScope != null && !codeafterflag.isEmpty()) {
                    positiveRatioStatisticLine.setPositiveRange(ScopeUtils.getScopeFormat(conferenceScope, lowOrhighFlag));
                    positiveRatioStatisticLine.setPositiveLevel(ColorStatisticUtils.JudgeColorHigh(conferenceScope, d.getHighRate()));
                }
            } else {
                lowOrhighFlag = "2";//阳性率范围给前端返回格式要用到
                positiveRatioStatisticLine.setPositiveRatio(d.getLowRate() + "");
                if (conferenceScope != null && !codeafterflag.isEmpty()) {
                    positiveRatioStatisticLine.setPositiveRange(ScopeUtils.getScopeFormat(conferenceScope, lowOrhighFlag));
                    positiveRatioStatisticLine.setPositiveLevel(ColorStatisticUtils.JudgeColorLow(conferenceScope, d.getLowRate()));
                }
            }

        }
        if (!codebeforeflag.isEmpty()) {
            if (codebeforeflag.equals("H-")) {
                positiveRatioStatisticLine.setPositiveRatio(d.getMValue());
            } else {
                positiveRatioStatisticLine.setPositiveRatio(d.getNValue());
            }

        }
        positiveRatioStatisticLine.setPositiveType(positivetype);
        positiveRatioStatisticLineMapper.insert(positiveRatioStatisticLine);
    }

    public void updatebloodlist(List<BloodCellCheckoutStatisicParam> itemsModelParams, List<ProScopeConfig> proScopeConfigs, String id, String positiveType) {
        List<PositiveRatioStatisticLine> positiveRatioStatisticLinesall = positiveRatioStatisticLineMapper.selectList(new QueryWrapper<PositiveRatioStatisticLine>().lambda().eq(PositiveRatioStatisticLine::getPositiveRatioId, id).eq(PositiveRatioStatisticLine::getPositiveType, positiveType));
        Map<String, PositiveRatioStatisticLine> maps = positiveRatioStatisticLinesall.stream().collect(Collectors.toMap(PositiveRatioStatisticLine::getPositiveName, Function.identity()));
        if (!itemsModelParams.isEmpty()) {
            for (BloodCellCheckoutStatisicParam d :
                    itemsModelParams) {
                ProScopeConfig conferenceScope = ScopeUtils.getConferenceScope(proScopeConfigs, d.getProjectCode());
                updatechildren(d, conferenceScope, maps, "", "偏高比");
                updatechildren(d, conferenceScope, maps, "", "偏低比");
                updatechildren(d, conferenceScope, maps, "H-", "");
                updatechildren(d, conferenceScope, maps, "L-", "");
            }
        }
    }


    public void updatechildren(BloodCellCheckoutStatisicParam d, ProScopeConfig conferenceScope, Map<String, PositiveRatioStatisticLine> maps, String codebeforeflag, String codeafterflag) {
        String hName = codebeforeflag + d.getProjectCode() + codeafterflag;
        PositiveRatioStatisticLine positiveRatioStatisticLine2 = maps.get(hName);
        if (positiveRatioStatisticLine2 != null) {
            if (!codeafterflag.isEmpty()) {
                if (codeafterflag.equals("偏高比")) {
                    positiveRatioStatisticLine2.setPositiveRatio(d.getHighRate() + "");
                    if (conferenceScope != null && !codeafterflag.isEmpty()) {
                        positiveRatioStatisticLine2.setPositiveLevel(ColorStatisticUtils.JudgeColorHigh(conferenceScope, d.getHighRate()));
                    }

                } else {
                    positiveRatioStatisticLine2.setPositiveRatio(d.getLowRate() + "");
                    if (conferenceScope != null && !codeafterflag.isEmpty()) {
                        positiveRatioStatisticLine2.setPositiveLevel(ColorStatisticUtils.JudgeColorLow(conferenceScope, d.getLowRate()));
                    }
                }

            }
            if (!codebeforeflag.isEmpty()) {
                if (codeafterflag.equals("H-")) {
                    positiveRatioStatisticLine2.setPositiveRatio(d.getMValue());
                } else {
                    positiveRatioStatisticLine2.setPositiveRatio(d.getNValue());

                }
            }
            positiveRatioStatisticLineMapper.updateById(positiveRatioStatisticLine2);
        }

    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值