Java 代码优化:DrugBandQuantityPurchaseSticVO 对象处理
List
if (CollectionUtils.isNotEmpty(list)) { for(DrugBandQuantityPurchaseVO purchaseVO :list) { DrugBandQuantityPurchaseSticVO vo = new DrugBandQuantityPurchaseSticVO(); BeanUtils.copyProperties(vo,purchaseVO); String contractDate = ""; if(null != vo.getContractStartDate()) { contractDate = DateUtils.formatDate(vo.getContractStartDate(),'yyyy.MM.dd'); } if(null != vo.getContractStartDate()) { contractDate += '~'+ DateUtils.formatDate(vo.getContractEndDate(),'yyyy.MM.dd'); } vo.setContractDate(contractDate);
Double convertPrice = vo.getConvertPrice() == null ? 0 : vo.getConvertPrice();
vo.setConvertPrice(convertPrice);
DrugBandQuantityConsumptionStatisticsVO statisticsVO = statisticsVOMap.get(purchaseVO.getDrugTradeCode());
if (statisticsVO != null) {
vo.setCurrentPeriodQuantity(DoubleDigitalOperUtil.divide(statisticsVO.getConsumption(),purchaseVO.getAmountPerPackage().doubleValue(), 2));
double currentPeriodQuantity = vo.getCurrentPeriodQuantity() == null ? 0 : vo.getCurrentPeriodQuantity();
vo.setCurrentPeriodRetailAmount(currentPeriodQuantity*vo.getTradePrice());
vo.setCurrentRetrenchRetailAmount((convertPrice-vo.getTradePrice())*vo.getCurrentPeriodQuantity());
}
statisticsVO = statisticsVOListMap.get(purchaseVO.getDrugTradeCode());
if (statisticsVO != null) {
vo.setContractCumulativeQuantity(DoubleDigitalOperUtil.divide(statisticsVO.getConsumption(),purchaseVO.getAmountPerPackage().doubleValue(), 2));
double currentPeriodQuantity = vo.getCurrentPeriodQuantity() == null ? 0 : vo.getCurrentPeriodQuantity();
vo.setContractRetailAmount(currentPeriodQuantity*vo.getTradePrice());
vo.setCumulativeRetrenchRetailAmount((convertPrice-vo.getTradePrice())*vo.getContractCumulativeQuantity());
}
sticVOS.add(vo);
}
}
原文地址: https://www.cveoy.top/t/topic/o0KT 著作权归作者所有。请勿转载和采集!