|
@@ -27,6 +27,7 @@ import com.diagbot.exception.CommonException;
|
|
|
import com.diagbot.util.ClassUtil;
|
|
|
import com.diagbot.util.EntityUtil;
|
|
|
import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.util.ObjectUtil;
|
|
|
import com.diagbot.util.StringUtil;
|
|
|
import com.diagbot.vo.EntryStatisticsVO;
|
|
|
import com.diagbot.vo.FilterOrderVO;
|
|
@@ -44,6 +45,8 @@ import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
@@ -994,6 +997,7 @@ public class ConsoleFacade {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ //表头生成
|
|
|
List<String> columnSet = Arrays.asList(hospitalSet.getValue().split(","));
|
|
|
List<ColumnDTO> columns = Lists.newLinkedList();
|
|
|
Integer orderNo = 1;
|
|
@@ -1069,7 +1073,7 @@ public class ConsoleFacade {
|
|
|
if (entry.getValue().containsKey(item.getId())) {
|
|
|
addValMap.put(item.getFieldName(), entry.getValue().get(item.getId()).getCasesEntryId());
|
|
|
} else {
|
|
|
- addValMap.put(item.getFieldName(), 0L);
|
|
|
+ addValMap.put(item.getFieldName(), null);
|
|
|
}
|
|
|
} else if (item.getFieldName().lastIndexOf("_name") > 0) {
|
|
|
addMap.put(item.getFieldName(), Class.forName("java.lang.String"));
|
|
@@ -1095,6 +1099,99 @@ public class ConsoleFacade {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
+ //排序
|
|
|
+ Collections.sort(retList, new Comparator<Object>() {
|
|
|
+ @Override
|
|
|
+ public int compare(Object o1, Object o2) {
|
|
|
+
|
|
|
+ if (StringUtil.isNotBlank(filterUnModifyMRVO.getAsc())) {
|
|
|
+ //升序
|
|
|
+ Object o1Val = ObjectUtil.getValueByKey(o1, filterUnModifyMRVO.getAsc());
|
|
|
+ Object o2Val = ObjectUtil.getValueByKey(o2, filterUnModifyMRVO.getAsc());
|
|
|
+ if (filterUnModifyMRVO.getAsc().lastIndexOf("_num") > 1) {
|
|
|
+ return ((Integer) o1Val).compareTo((Integer) o2Val);
|
|
|
+ }
|
|
|
+ if (filterUnModifyMRVO.getAsc().lastIndexOf("_id") > 1) {
|
|
|
+ return ((Long) o1Val).compareTo((Long) o2Val);
|
|
|
+ } else {
|
|
|
+ return ((String) o1Val).compareTo((String) o2Val);
|
|
|
+ }
|
|
|
+ } else if (StringUtil.isNotBlank(filterUnModifyMRVO.getDesc())) {
|
|
|
+ //降序
|
|
|
+ Object o1Val = ObjectUtil.getValueByKey(o1, filterUnModifyMRVO.getDesc());
|
|
|
+ Object o2Val = ObjectUtil.getValueByKey(o2, filterUnModifyMRVO.getDesc());
|
|
|
+ if (filterUnModifyMRVO.getDesc().lastIndexOf("_num") > 1) {
|
|
|
+ return ((Integer) o2Val).compareTo((Integer) o1Val);
|
|
|
+ }
|
|
|
+ if (filterUnModifyMRVO.getDesc().lastIndexOf("_id") > 1) {
|
|
|
+ return ((Long) o2Val).compareTo((Long) o1Val);
|
|
|
+ } else {
|
|
|
+ return ((String) o2Val).compareTo((String) o1Val);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //增加全院数据
|
|
|
+ if (StringUtil.isBlank(filterUnModifyMRVO.getName()) || filterUnModifyMRVO.getName().equals("全院")) {
|
|
|
+ try {
|
|
|
+
|
|
|
+ Object globleObj = new Object();
|
|
|
+ HashMap addMap = new HashMap();
|
|
|
+ HashMap addValMap = new HashMap();
|
|
|
+ addMap.put("deptId", Class.forName("java.lang.String"));
|
|
|
+ addValMap.put("deptId", "");
|
|
|
+ addMap.put("deptName", Class.forName("java.lang.String"));
|
|
|
+ addValMap.put("deptName", "全院");
|
|
|
+
|
|
|
+ for (ColumnDTO item : columns) {
|
|
|
+ if (item.getFieldName().lastIndexOf("_id") > 0) {
|
|
|
+ addMap.put(item.getFieldName(), Class.forName("java.lang.Long"));
|
|
|
+ List<Object> entryIds = retList
|
|
|
+ .stream()
|
|
|
+ .map(i -> ObjectUtil.getValueByKey(i, item.getFieldName()))
|
|
|
+ .filter(i -> i != null)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (ListUtil.isNotEmpty(entryIds)) {
|
|
|
+ addValMap.put(item.getFieldName(), entryIds.get(0));
|
|
|
+ } else {
|
|
|
+ addValMap.put(item.getFieldName(), null);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (item.getFieldName().lastIndexOf("_name") > 0) {
|
|
|
+ addMap.put(item.getFieldName(), Class.forName("java.lang.String"));
|
|
|
+ List<Object> entryNames = retList
|
|
|
+ .stream()
|
|
|
+ .map(i -> ObjectUtil.getValueByKey(i, item.getFieldName()))
|
|
|
+ .filter(i -> i != null)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (ListUtil.isNotEmpty(entryNames)) {
|
|
|
+ addValMap.put(item.getFieldName(), entryNames.get(0));
|
|
|
+ } else {
|
|
|
+ addValMap.put(item.getFieldName(), "");
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (item.getFieldName().lastIndexOf("_num") > 0) {
|
|
|
+ addMap.put(item.getFieldName(), Class.forName("java.lang.Integer"));
|
|
|
+ Integer entryNum = retList
|
|
|
+ .stream()
|
|
|
+ .map(i -> ObjectUtil.getValueByKey(i, item.getFieldName()))
|
|
|
+ .filter(i -> i != null)
|
|
|
+ .map(i -> (Integer) i)
|
|
|
+ .reduce(0, Integer::sum);
|
|
|
+ addValMap.put(item.getFieldName(), entryNum);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ globleObj = new ClassUtil().dynamicClass(globleObj, addMap, addValMap);
|
|
|
+ retList.add(0, globleObj);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
unModifyMRDTO.setColumns(columns);
|
|
|
unModifyMRDTO.setData(retList);
|
|
|
return unModifyMRDTO;
|