Browse Source

优化 以及添加 查询条件。

xiaochan 3 years ago
parent
commit
d22ccec095

+ 12 - 7
src/main/java/thyyxxk/webserver/controller/medicalinsurance/SiManageController.java

@@ -7,13 +7,13 @@ import org.springframework.web.bind.annotation.*;
 import thyyxxk.webserver.config.auth.PassToken;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.medicalinsurance.manage.*;
-import thyyxxk.webserver.entity.medicalinsurance.query.SiPatInfo;
 import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SlctSetlPrm;
 import thyyxxk.webserver.entity.medicalinsurance.setllistupload.UpldCollection;
 import thyyxxk.webserver.entity.querydata.JieSuanDanChaXun;
 import thyyxxk.webserver.entity.querydata.TSiSetlinfo;
 import thyyxxk.webserver.service.medicalinsurance.SiManageService;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 import java.util.Map;
 
@@ -65,15 +65,13 @@ public class SiManageController {
 
     @PostMapping("/upldSetlList")
     @PassToken
-    public ResultVo<String> upldSetlList(@RequestBody List<SiPatInfo> siPatInfos) {
+    public ResultVo<String> upldSetlList(@RequestBody List<TSiSetlinfo> siPatInfos) {
         return service.upldSetlListBatch(siPatInfos);
     }
 
-    @GetMapping("/upldSetlListTimes")
-    public ResultVo<String> upldSetlListTimes(@RequestParam("startTime") String startTime,
-                                              @RequestParam("endTime") String endTime,
-                                              @RequestParam("insutype") String insutype) {
-        return service.upldSetlListTimes(startTime, endTime, insutype);
+    @PostMapping("/upldSetlListTimes")
+    public ResultVo<String> upldSetlListTimes(@RequestBody JieSuanDanChaXun param) {
+        return service.upldSetlListTimes(param);
     }
 
     @GetMapping("/getMedType")
@@ -92,4 +90,11 @@ public class SiManageController {
                                                   @RequestParam("ledgerSn") Integer ledgerSn) throws Exception {
         return service.getUploadInfo(patNo, times, ledgerSn);
     }
+
+    @PostMapping("/exportExcel")
+    public void exportExcel(HttpServletResponse response,
+                            @RequestBody @Validated JieSuanDanChaXun param) {
+        service.exportExcel(response, param);
+    }
+
 }

+ 55 - 25
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/UpIdCollectionDao.java

@@ -231,7 +231,7 @@ public interface UpIdCollectionDao {
             "row_number() over (order by setl_time) as rowNumber," +
             "pat_no,times,ledger_sn,psn_name,gend,brdy,insutype,psn_type,mdtrt_id,setl_id,setl_time, " +
             "       a.med_type,medfee_sumamt,fund_pay_sumamt, " +
-            "       acct_pay,psn_cash_pay,clr_optins, " +
+            "       acct_pay,psn_cash_pay,clr_optins,clr_optins_name = (select name from t_region where code=clr_optins), " +
             "       outDeptName=(select rtrim(name) from zd_unit_code where code=small_dept), " +
             "       setl_list_id " +
             "from t_si_setlinfo a left join  zy_inactpatient b on (a.pat_no = b.inpatient_no and a.times = b.admiss_times) " +
@@ -243,43 +243,58 @@ public interface UpIdCollectionDao {
             "<if test=\"patNo !=null and patNo != '' \">" +
             "  and pat_no = #{patNo} " +
             "</if>" +
-            "<if test=\"insutype.size > 0 \">" +
+            "<if test=\"insutypes.size > 0 \">" +
             "  and insutype in " +
-            "<foreach collection='insutype' item='item' index='index' open='(' close=')' separator=','>" +
+            "<foreach collection='insutypes' item='item' index='index' open='(' close=')' separator=','>" +
             "#{item}" +
             "</foreach>" +
             "</if>" +
-            "<if test=\"outDept.size > 0 \">" +
+            "<if test=\"outDepts.size > 0 \">" +
             "and small_dept in " +
-            "<foreach collection='outDept' item='item' index='index' open='(' close=')' separator=','>" +
+            "<foreach collection='outDepts' item='item' index='index' open='(' close=')' separator=','>" +
             "#{item} " +
             "</foreach>" +
             "</if>" +
-            "<if test=\"medType.size > 0 \">" +
+            "<if test=\"medTypes.size > 0 \">" +
             "  and a.med_type in " +
-            "<foreach collection='outDept' item='item' index='index' open='(' close=')' separator=','>" +
+            "<foreach collection='medTypes' item='item' index='index' open='(' close=')' separator=','>" +
             "#{item}" +
             "</foreach>" +
             "</if>" +
-            "<if test=\"psnType.size > 0 \">" +
+            "<if test=\"psnTypes.size > 0 \">" +
             "  and psn_type in " +
-            "<foreach collection='psnType' item='item' index='index' open='(' close=')' separator=','>" +
+            "<foreach collection='psnTypes' item='item' index='index' open='(' close=')' separator=','>" +
             "#{item}" +
             "</foreach>" +
             "</if>" +
+            "<if test=\"clrOptins.size > 0 \">" +
+            "  and clr_optins in " +
+            "<foreach collection='clrOptins' item='item' index='index' open='(' close=')' separator=','>" +
+            "#{item}" +
+            "</foreach>" +
+            "</if>" +
+            "<if test=\"flag == false \">" +
+            " and a.setl_list_id is null " +
+            "</if>" +
+            "<if test=\"flag == true \">" +
+            " and a.setl_list_id is not null " +
+            "</if>" +
             " ) temp where rowNumber > ${pageSize} * (${currentPage} - 1)" +
             "</script>")
     List<TSiSetlinfo> huoQuJieSuanRenYuan(@Param("startTime") String startTime,
                                           @Param("endTime") String endTime,
                                           @Param("setlType") String setlTyle,
                                           @Param("patNo") String patNo,
-                                          @Param("insutype") List<String> insutypes,
-                                          @Param("outDept") List<String> outDepts,
-                                          @Param("medType") List<String> medTypes,
-                                          @Param("psnType") List<String> psnTypes,
+                                          @Param("insutypes") List<String> insutypes,
+                                          @Param("outDepts") List<String> outDepts,
+                                          @Param("medTypes") List<String> medTypes,
+                                          @Param("psnTypes") List<String> psnTypes,
+                                          @Param("clrOptins") List<String> clrOptins,
+                                          @Param("flag") boolean flag,
                                           @Param("currentPage") long currentPage,
                                           @Param("pageSize") long pageSize);
 
+
     @Select("<script>" +
             "select count(*) " +
             "from t_si_setlinfo a left join  zy_inactpatient b on (a.pat_no = b.inpatient_no and a.times = b.admiss_times) " +
@@ -291,37 +306,52 @@ public interface UpIdCollectionDao {
             "<if test=\"patNo !=null and patNo != '' \">" +
             "  and pat_no = #{patNo} " +
             "</if>" +
-            "<if test=\"insutype.size > 0 \">" +
+            "<if test=\"insutypes.size > 0 \">" +
             "  and insutype in " +
-            "<foreach collection='insutype' item='item' index='index' open='(' close=')' separator=','>" +
+            "<foreach collection='insutypes' item='item' index='index' open='(' close=')' separator=','>" +
             "#{item}" +
             "</foreach>" +
             "</if>" +
-            "<if test=\"outDept.size > 0 \">" +
+            "<if test=\"outDepts.size > 0 \">" +
             "and small_dept in " +
-            "<foreach collection='outDept' item='item' index='index' open='(' close=')' separator=','>" +
+            "<foreach collection='outDepts' item='item' index='index' open='(' close=')' separator=','>" +
             "#{item} " +
             "</foreach>" +
             "</if>" +
-            "<if test=\"medType.size > 0 \">" +
+            "<if test=\"medTypes.size > 0 \">" +
             "  and a.med_type in " +
-            "<foreach collection='outDept' item='item' index='index' open='(' close=')' separator=','>" +
+            "<foreach collection='medTypes' item='item' index='index' open='(' close=')' separator=','>" +
             "#{item}" +
             "</foreach>" +
             "</if>" +
-            "<if test=\"psnType.size > 0 \">" +
+            "<if test=\"psnTypes.size > 0 \">" +
             "  and psn_type in " +
-            "<foreach collection='psnType' item='item' index='index' open='(' close=')' separator=','>" +
+            "<foreach collection='psnTypes' item='item' index='index' open='(' close=')' separator=','>" +
             "#{item}" +
             "</foreach>" +
             "</if>" +
+            "<if test=\"clrOptins.size > 0 \">" +
+            "  and clr_optins in " +
+            "<foreach collection='clrOptins' item='item' index='index' open='(' close=')' separator=','>" +
+            "#{item}" +
+            "</foreach>" +
+            "</if>" +
+            "<if test=\"flag == false \">" +
+            " and a.setl_list_id is null " +
+            "</if>" +
+            "<if test=\"flag == true \">" +
+            " and a.setl_list_id is not null " +
+            "</if>" +
             "</script>")
     long huoQuJieSuanRenYuanTotal(@Param("startTime") String startTime,
                                   @Param("endTime") String endTime,
                                   @Param("setlType") String setlTyle,
                                   @Param("patNo") String patNo,
-                                  @Param("insutype") List<String> insutypes,
-                                  @Param("outDept") List<String> outDepts,
-                                  @Param("medType") List<String> medTypes,
-                                  @Param("psnType") List<String> psnTypes);
+                                  @Param("insutypes") List<String> insutypes,
+                                  @Param("outDepts") List<String> outDepts,
+                                  @Param("medTypes") List<String> medTypes,
+                                  @Param("psnTypes") List<String> psnTypes,
+                                  @Param("clrOptins") List<String> clrOptins,
+                                  @Param("flag") boolean flag);
+
 }

+ 11 - 0
src/main/java/thyyxxk/webserver/entity/querydata/JieSuanDanChaXun.java

@@ -41,6 +41,17 @@ public class JieSuanDanChaXun {
      */
     private List<String> psnType;
 
+    /**
+     * 结算机构
+     */
+    private List<String> clrOptins;
+
+    /**
+     * false 未传
+     * true 已传
+     */
+    private Boolean flag;
+
 
     private long currentPage;
     private long pageSize;

+ 5 - 0
src/main/java/thyyxxk/webserver/entity/querydata/TSiSetlinfo.java

@@ -1,6 +1,8 @@
 package thyyxxk.webserver.entity.querydata;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
 
 import java.io.Serializable;
 import java.util.Date;
@@ -73,6 +75,8 @@ public class TSiSetlinfo implements Serializable {
     /**
      * 出生日期
      */
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd")
     private Date brdy;
 
     /**
@@ -278,4 +282,5 @@ public class TSiSetlinfo implements Serializable {
 
     private String outDeptName;
 
+
 }

+ 50 - 17
src/main/java/thyyxxk/webserver/service/medicalinsurance/SiManageService.java

@@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.constants.Capacity;
+import thyyxxk.webserver.constants.GetDateFormat;
 import thyyxxk.webserver.constants.YesOrNo;
 import thyyxxk.webserver.constants.sidicts.*;
 import thyyxxk.webserver.dao.his.medicalinsurance.SiManageDao;
@@ -23,7 +24,6 @@ import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
 import thyyxxk.webserver.entity.dictionary.PureCodeName;
 import thyyxxk.webserver.entity.medicalinsurance.manage.*;
-import thyyxxk.webserver.entity.medicalinsurance.query.SiPatInfo;
 import thyyxxk.webserver.entity.medicalinsurance.query.SiSetlFeeDetl;
 import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SiSetlinfo;
 import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SlctSetlPrm;
@@ -34,6 +34,7 @@ import thyyxxk.webserver.service.PublicServer;
 import thyyxxk.webserver.utils.*;
 import thyyxxk.webserver.websocket.WebSocketServer;
 
+import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
@@ -504,13 +505,12 @@ public class SiManageService {
      * @param param 患者信息
      * @return 返回
      */
-    public ResultVo<String> upldSetlListBatch(List<SiPatInfo> param) {
+    public ResultVo<String> upldSetlListBatch(List<TSiSetlinfo> param) {
         if (ListUtil.isBlank(param)) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "请选择需要上传的患者。");
         }
-
         for (int i = 0; i < param.size(); i++) {
-            SiPatInfo siPatInfo = param.get(i);
+            TSiSetlinfo siPatInfo = param.get(i);
             int percentage = makePercentage(i + 1, param.size());
             try {
                 ResultVo<String> resultVo = upldSetlList(siPatInfo.getPatNo(), siPatInfo.getTimes(), siPatInfo.getLedgerSn());
@@ -527,15 +527,18 @@ public class SiManageService {
     }
 
     /**
-     * 根据时间上传
+     * 全部上传
      *
-     * @param startTime 开始时间
-     * @param endTime   结算时间
      * @return 返回信息
      */
-    public ResultVo<String> upldSetlListTimes(String startTime, String endTime, String insutype) {
+    public ResultVo<String> upldSetlListTimes(JieSuanDanChaXun param) {
         try {
-            upldSetlListBatch(upIdCollectionDao.getHuanZheXinXi(startTime, endTime, insutype));
+            param.setPageSize(param.getTotal());
+            List<TSiSetlinfo> list = huoQuJieSuanRenYuan(param).getData().getRecords();
+            if (ListUtil.isBlank(list)) {
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有要上传的信息。");
+            }
+            upldSetlListBatch(list);
         } catch (Exception e) {
             log.info("时间范围上传结算单错误:{}", JSON.toJSONString(e));
         }
@@ -624,17 +627,15 @@ public class SiManageService {
         log.info("参数:{}", JSONObject.toJSONString(param));
         IPage<TSiSetlinfo> page = new Page<>();
         page.setRecords(upIdCollectionDao.huoQuJieSuanRenYuan(param.getStartTime(), param.getEndTime(), param.getClrType(), param.getPatNo(),
-                param.getInsutype(), param.getOutDept(), param.getMedType(), param.getPsnType(), param.getCurrentPage(), param.getPageSize()));
+                param.getInsutype(), param.getOutDept(), param.getMedType(), param.getPsnType(), param.getClrOptins(), param.getFlag(), param.getCurrentPage(),
+                param.getPageSize()));
         if (ListUtil.isBlank(page.getRecords())) {
             return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
         }
         for (TSiSetlinfo item : page.getRecords()) {
             item.setGendName(item.getGend().equals("1") ? "男" : "女");
-            Admdvs admdvs = Admdvs.get(item.getClrOptins());
-            if (null == admdvs) {
-                item.setClrOptinsName(dao.selectRegion(item.getClrOptins()));
-            } else {
-                item.setClrOptinsName(admdvs.getName());
+            if (item.getClrOptinsName() == null) {
+                item.setClrOptinsName(Objects.requireNonNull(Admdvs.get(item.getClrOptins())).getName());
             }
             Insutype insutype = Insutype.get(item.getInsutype());
             if (null != insutype) {
@@ -651,12 +652,11 @@ public class SiManageService {
         }
         if (param.getTotal() == 0) {
             page.setTotal(upIdCollectionDao.huoQuJieSuanRenYuanTotal(param.getStartTime(), param.getEndTime(), param.getClrType(), param.getPatNo(),
-                    param.getInsutype(), param.getOutDept(), param.getMedType(), param.getPsnType()));
+                    param.getInsutype(), param.getOutDept(), param.getMedType(), param.getPsnType(), param.getClrOptins(), param.getFlag()));
         }
         return ResultVoUtil.success(page);
     }
 
-
     public ResultVo<List<Object>> getMedType() {
         JSONArray jsonArray = new JSONArray();
         for (MedType e : MedType.values()) {
@@ -668,4 +668,37 @@ public class SiManageService {
         return ResultVoUtil.success(jsonArray);
     }
 
+    public void exportExcel(HttpServletResponse response, JieSuanDanChaXun param) {
+        param.setPageSize(param.getTotal());
+        log.info("医保结算单: {}", JSON.toJSONStringWithDateFormat(param, GetDateFormat.DATE));
+        List<TSiSetlinfo> list = huoQuJieSuanRenYuan(param).getData().getRecords();
+        String[] title = {"姓名", "住院号/门诊号", "次数", "性别", "出生日期", "险种类型", "人员类别", "就诊ID", "结算ID", "结算时间", "医疗类别", "总费用", "报销金额", "个人账户支出", "个人现金支出",
+                "清算机构", "出院科室"};
+        String[][] content = new String[list.size()][];
+        for (int i = 0; i < list.size(); i++) {
+            content[i] = new String[title.length];
+            TSiSetlinfo pojo = list.get(i);
+            content[i][0] = pojo.getPsnName();
+            content[i][1] = pojo.getPatNo();
+            content[i][2] = pojo.getTimes().toString();
+            content[i][3] = pojo.getGendName();
+            content[i][4] = DateUtil.formatDatetime(pojo.getBrdy(), GetDateFormat.DATE);
+            content[i][5] = pojo.getInsutypeName();
+            content[i][6] = pojo.getPsnTypeName();
+            content[i][7] = pojo.getMdtrtId();
+            content[i][8] = pojo.getSetlId();
+            content[i][9] = DateUtil.formatDatetime(pojo.getSetlTime(), GetDateFormat.DATE_TIME);
+            content[i][10] = pojo.getMedTypeName();
+            content[i][11] = pojo.getMedfeeSumamt();
+            content[i][12] = pojo.getFundPaySumamt();
+            content[i][13] = pojo.getAcctPay();
+            content[i][14] = pojo.getPsnCashPay();
+            content[i][15] = pojo.getClrOptinsName();
+            content[i][16] = pojo.getOutDeptName();
+        }
+        //传三个参数 一个是 固定的 response ,excel的头部信息,excel的内容
+        ExcelUtil.exportExcel(response, title, content);
+    }
+
+
 }