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);
}
}
代码审查1
于 2023-02-24 15:42:04 首次发布