Browse Source

增加动态柱状图

hsh 3 years ago
parent
commit
60faab0c50

+ 6 - 0
src/main/java/thyyxxk/webserver/controller/ybkf/YbStatController.java

@@ -58,4 +58,10 @@ public class YbStatController {
         return service.selectYbStatDetail(dto);
     }
 
+
+    @PostMapping("/selectBarChangeData")
+    public ResultVo<List<Map<String, Object>>> selectBarChangeData(@RequestBody @Validated YbStatDto dto){
+        return service.selectBarChangeData(dto);
+    }
+
 }

+ 20 - 0
src/main/java/thyyxxk/webserver/dao/his/ybkf/YbStatDao.java

@@ -7,6 +7,7 @@ import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SiSetlinfo;
 import thyyxxk.webserver.entity.ybkf.YbStatResult;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  *@Author hsh
@@ -202,4 +203,23 @@ public interface YbStatDao {
             "</script>")
     List<SiSetlinfo> selectSiSetlInfoListInProvinceOtherCitiesSingleDisease(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType);
 
+    @Select("<script>" +
+            "select yf=convert(varchar(7), a.setl_time, 120), a.medins_type, " +
+            "psnCount=count(distinct a.setl_id), " +
+            "inDays=sum(datediff(day, zy.admiss_date, zy.dis_date)), " +
+            "totalFee=cast(round(sum(a.medfee_sumamt),2) as decimal(10,2)), " +
+            "fundPooling=cast(round(sum(a.hifp_pay),2) as decimal(10,2)), " +
+            "bigIllFundPooling=cast(round(sum(a.hifmi_pay),2) as decimal(10,2)), " +
+            "civilServiceFund=cast(round(sum(a.cvlserv_pay),2) as decimal(10,2)), " +
+            "otherFunds=cast(round(sum(isnull(a.fund_pay_sumamt,0)-isnull(a.hifp_pay,0)-isnull(a.cvlserv_pay,0)-isnull(a.hifmi_pay,0)),2) as decimal(10,2)), " +
+            "allFunds=cast(round(sum(a.fund_pay_sumamt),2) as decimal(10,2)), " +
+            "drugFee=cast(round(sum(isnull(a.charge_western_medicine,0) + isnull(a.charge_patent_medicine,0) + isnull(a.charge_herbal,0)),2) as decimal(10,2)), " +
+            "matFee=cast(round(isnull(sum(a.charge_sanitary_material),0),2) as decimal(10,2)) " +
+            "from t_si_setlinfo a " +
+            "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
+            "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
+            "group by convert(varchar(7), a.setl_time, 120), a.medins_type order by convert(varchar(7), a.setl_time, 120) " +
+            "</script>")
+    List<Map<String, Object>> selectBarChangeData(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType);
+
 }

+ 95 - 0
src/main/java/thyyxxk/webserver/service/ybkf/YbStatService.java

@@ -18,10 +18,12 @@ import thyyxxk.webserver.utils.FilterUtil;
 import thyyxxk.webserver.utils.ResultVoUtil;
 
 import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @ClassName YbStatService
@@ -1281,4 +1283,97 @@ public class YbStatService {
         return ResultVoUtil.success(siSetlInfoList);
     }
 
+    public ResultVo<List<Map<String, Object>>> selectBarChangeData(YbStatDto dto){
+        String beginTime = dto.getStartTime();
+        String endTime = DateUtil.getMonthEndtime(dto.getEndTime());
+        // 不限制查询险种类型
+        String setlType = dto.getSetlType();
+
+        List<Map<String, Object>> list = dao.selectBarChangeData(beginTime, endTime, setlType);
+
+        if (null == list || list.isEmpty()) {
+            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
+        }
+
+        Map<String, List<Map<String, Object>>> map1 = list.stream().collect(Collectors.groupingBy(f -> String.valueOf(f.get("yf")), Collectors.toList()));
+        List<Map<String, Object>> result = new ArrayList<>();
+        List<Map<String, Object>> list1 = new ArrayList<>();
+        for(Map.Entry<String, List<Map<String, Object>>> entry : map1.entrySet()){
+            List<Map<String, Object>> list2 = entry.getValue();
+            if(list2 == null && list2.size() < 1){
+                continue;
+            }
+
+            if(result != null && result.size()< 1){
+                list1.addAll(list2);
+                result.addAll(list2);
+            } else {
+                List<Map<String, Object>> sl = new ArrayList<>();
+                for(Map<String, Object> m1 : list1){
+                    Map<String, Object> m = new HashMap<>();
+                    String medinsType1 = m1.get("medins_type") + "";
+                    boolean flag = true;
+                    for(Map<String, Object> m2 : list2){
+                        String medinsType2 = m2.get("medins_type") + "";
+                        if(medinsType1.equals(medinsType2)){
+                            flag = false;
+                            m.put("yf", entry.getKey());
+                            m.put("medins_type", medinsType1);
+                            m.put("psnCount", DecimalUtil.add(new BigDecimal(String.valueOf(m2.get("psnCount"))), new BigDecimal(String.valueOf(m1.get("psnCount")))));
+                            m.put("inDays", DecimalUtil.add(new BigDecimal(String.valueOf(m2.get("inDays"))), new BigDecimal(String.valueOf(m1.get("inDays")))));
+                            m.put("totalFee", DecimalUtil.add(new BigDecimal(String.valueOf(m2.get("totalFee"))), new BigDecimal(String.valueOf(m1.get("totalFee")))));
+                            m.put("fundPooling", DecimalUtil.add(new BigDecimal(String.valueOf(m2.get("fundPooling"))), new BigDecimal(String.valueOf(m1.get("fundPooling")))));
+                            m.put("bigIllFundPooling", DecimalUtil.add(new BigDecimal(String.valueOf(m2.get("bigIllFundPooling"))), new BigDecimal(String.valueOf(m1.get("bigIllFundPooling")))));
+                            m.put("civilServiceFund", DecimalUtil.add(new BigDecimal(String.valueOf(m2.get("civilServiceFund"))), new BigDecimal(String.valueOf(m1.get("civilServiceFund")))));
+                            m.put("otherFunds", DecimalUtil.add(new BigDecimal(String.valueOf(m2.get("otherFunds"))), new BigDecimal(String.valueOf(m1.get("otherFunds")))));
+                            m.put("allFunds", DecimalUtil.add(new BigDecimal(String.valueOf(m2.get("allFunds"))), new BigDecimal(String.valueOf(m1.get("allFunds")))));
+                            m.put("drugFee", DecimalUtil.add(new BigDecimal(String.valueOf(m2.get("drugFee"))), new BigDecimal(String.valueOf(m1.get("drugFee")))));
+                            m.put("matFee", DecimalUtil.add(new BigDecimal(String.valueOf(m2.get("matFee"))), new BigDecimal(String.valueOf(m1.get("matFee")))));
+                            m.put("otherFunds", DecimalUtil.add(new BigDecimal(String.valueOf(m2.get("otherFunds"))), new BigDecimal(String.valueOf(m1.get("otherFunds")))));
+                            break;
+                        }
+                    }
+
+                    if(flag){
+                        m.put("yf", entry.getKey());
+                        m.put("medins_type", medinsType1);
+                        m.put("psnCount", m1.get("psnCount"));
+                        m.put("inDays", m1.get("inDays"));
+                        m.put("totalFee", m1.get("totalFee"));
+                        m.put("fundPooling", m1.get("fundPooling"));
+                        m.put("bigIllFundPooling", m1.get("bigIllFundPooling"));
+                        m.put("civilServiceFund", m1.get("civilServiceFund"));
+                        m.put("otherFunds", m1.get("otherFunds"));
+                        m.put("allFunds", m1.get("allFunds"));
+                        m.put("drugFee", m1.get("drugFee"));
+                        m.put("matFee", m1.get("matFee"));
+                        m.put("otherFunds", m1.get("otherFunds"));
+                    }
+                    sl.add(m);
+                }
+
+                // 下个月没有上个月的险种的数据,也需要添加到下个月展示
+                for(Map<String, Object> m2 : list2){
+                    String medinsType2 = m2.get("medins_type") + "";
+                    boolean flag = true;
+                    for(Map<String, Object> m1 : sl){
+                        String medinsType1 = m1.get("medins_type") + "";
+                        if(medinsType2.equals(medinsType1)){
+                            flag = false;
+                            break;
+                        }
+                    }
+                    if(flag){
+                        sl.add(m2);
+                    }
+                }
+                result.addAll(sl);
+                list1.clear();
+                list1.addAll(sl);
+            }
+        }
+
+        return ResultVoUtil.success(result);
+    }
+
 }