|
|
@ -18,8 +18,8 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
/** |
|
|
|
* @description: 统计查询 |
|
|
@ -150,11 +150,44 @@ public class StatisticalService implements IStatisticalService { |
|
|
|
List<Long> hospitalIds = getHospitalIds(param.getProjectId()); |
|
|
|
List<StatisticalVo.Item> items = firstAidRecordDao.countThrombosisRateDate(param.getCountType(), hospitalIds, param.getStartTime(), param.getEndTime()); |
|
|
|
StatisticalVo.Common common = new StatisticalVo.Common(); |
|
|
|
// TODO 补充items 计算求和
|
|
|
|
common.setTotal(0L); |
|
|
|
common.setList(items); |
|
|
|
common.setTotal(getTotal(items)); |
|
|
|
List<StatisticalVo.Item> newItems = fillItems(items, param.getStartTime(), param.getEndTime(), param.getCountType()); |
|
|
|
common.setList(newItems); |
|
|
|
return common; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private List<StatisticalVo.Item> fillItems(List<StatisticalVo.Item> items, Long startTime, Long endTime, Byte countType) { |
|
|
|
if (CollectionUtil.isEmpty(items)) { |
|
|
|
return items; |
|
|
|
} |
|
|
|
Map<String, StatisticalVo.Item> map = new HashMap<>(); |
|
|
|
List<StatisticalVo.Item> newItems = new ArrayList<>(); |
|
|
|
items.forEach(item -> map.put(item.getName(), item)); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
int unit = Calendar.HOUR_OF_DAY; |
|
|
|
if (countType == Constant.Param.COUNT_TYPE_HOUR) { |
|
|
|
sdf = new SimpleDateFormat("yyyy-MM-dd HH"); |
|
|
|
unit = Calendar.HOUR; |
|
|
|
} else if (countType == Constant.Param.COUNT_TYPE_MONTH) { |
|
|
|
sdf = new SimpleDateFormat("yyyy-MM"); |
|
|
|
unit = Calendar.MONTH; |
|
|
|
} |
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
calendar.setTimeInMillis(startTime); |
|
|
|
while (calendar.getTimeInMillis() <= endTime) { |
|
|
|
String format = sdf.format(calendar.getTime()); |
|
|
|
if (map.containsKey(format)) { |
|
|
|
newItems.add(map.get(format)); |
|
|
|
} else { |
|
|
|
newItems.add(new StatisticalVo.Item(format, null)); |
|
|
|
} |
|
|
|
calendar.add(unit, 1); |
|
|
|
} |
|
|
|
return items; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public StatisticalVo.Common timeWindowsPatient(StatisticalDto.TimeAndType param, Long userId) { |
|
|
|
List<Long> hospitalIds = getHospitalIds(param.getProjectId()); |
|
|
@ -170,12 +203,9 @@ public class StatisticalService implements IStatisticalService { |
|
|
|
} |
|
|
|
List<StatisticalVo.Item> items = firstAidRecordDao.countTimeWindowPatientFx(hospitalIds, param.getStartTime(), param.getEndTime(), type); |
|
|
|
StatisticalVo.Common common = new StatisticalVo.Common(); |
|
|
|
long total = 0L; |
|
|
|
for (StatisticalVo.Item item : items) { |
|
|
|
total += Integer.parseInt(item.getValue()); |
|
|
|
} |
|
|
|
common.setTotal(total); |
|
|
|
common.setList(items); |
|
|
|
common.setTotal(getTotal(items)); |
|
|
|
List<StatisticalVo.Item> newItems = fillItems(items, param.getStartTime(), param.getEndTime(), param.getCountType()); |
|
|
|
common.setList(newItems); |
|
|
|
return common; |
|
|
|
} |
|
|
|
|
|
|
@ -228,7 +258,7 @@ public class StatisticalService implements IStatisticalService { |
|
|
|
return common; |
|
|
|
} |
|
|
|
|
|
|
|
private long getTotal(List<StatisticalVo.Item> items, int countType) { |
|
|
|
private long getTotal(List<StatisticalVo.Item> items) { |
|
|
|
long total = 0L; |
|
|
|
if(CollectionUtil.isNotEmpty(items)){ |
|
|
|
for (StatisticalVo.Item item : items){ |
|
|
|