Browse Source

结算单上传接口。

xiaochan 4 years ago
parent
commit
4593f59673

+ 10 - 6
src/main/java/thyyxxk/webserver/controller/medicalinsurance/SiManageController.java

@@ -1,12 +1,12 @@
 package thyyxxk.webserver.controller.medicalinsurance;
 
-import com.alibaba.fastjson.JSONObject;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 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.service.medicalinsurance.SiManageService;
 
@@ -59,12 +59,16 @@ public class SiManageController {
         return service.selectSetlinfos(prm);
     }
 
+    @PostMapping("/upldSetlList")
     @PassToken
-    @GetMapping("/upldSetlList")
-    public ResultVo<JSONObject> upldSetlList(@RequestParam("patNo") String patNo,
-                                               @RequestParam("times") Integer times,
-                                               @RequestParam("ledgerSn") Integer ledgerSn) throws Exception {
-        return service.upldSetlList(patNo, times, ledgerSn);
+    public ResultVo<String> upldSetlList(@RequestBody List<SiPatInfo> siPatInfos) {
+        return service.upldSetlListBatch(siPatInfos);
     }
 
+    @GetMapping("/upldSetlListTimes")
+    @PassToken
+    public ResultVo<String> upldSetlListTimes(@RequestParam("startTime") String startTime,
+                                              @RequestParam("endTime") String endTime) {
+        return service.upldSetlListTimes(startTime, endTime);
+    }
 }

+ 2 - 2
src/main/java/thyyxxk/webserver/dao/his/PublicDao.java

@@ -126,10 +126,10 @@ public interface PublicDao {
                                          @Param("ledgerSn") Integer ledgerSn);
 
     @Update("<script>" +
-            "update zy_detail_charge set ori_detail_sn = -1 where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} " +
+            "update zy_detail_charge set ori_detail_sn = -1 where inpatient_no = '${inpatientNo}' and admiss_times = ${admissTimes} and ledger_sn = ${ledgerSn} " +
             "and charge_amount &gt; 0 and detail_sn in " +
             "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
-            "#{item}" +
+            "${item}" +
             "</foreach>" +
             "</script>")
     void genXingFuShuDuiYingZhenLiuShui(@Param("inpatientNo") String inpatientNo,

+ 12 - 0
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/UpIdCollectionDao.java

@@ -3,7 +3,9 @@ package thyyxxk.webserver.dao.his.medicalinsurance;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
 import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
+import thyyxxk.webserver.entity.medicalinsurance.query.SiPatInfo;
 import thyyxxk.webserver.entity.medicalinsurance.setllistupload.*;
 
 import java.util.Date;
@@ -192,4 +194,14 @@ public interface UpIdCollectionDao {
                               @Param("times") Integer times);
 
 
+    // 保存返回信息
+    @Update("update t_si_setlinfo set setl_list_id  = #{setlListId} where setl_id = #{setlId} ")
+    void fanHuiLiuShuiHao(@Param("setlListId") String setlListId,
+                          @Param("setlId") String setlId);
+
+    @Select("select a.pat_no,a.times,a.ledger_sn from t_si_setlinfo a,t_si_pat_info b where a.pat_no = b.pat_no and a.times = b.times and a.ledger_sn = b.ledger_sn " +
+            "and revoked = 0 and setl_type = 21 and b.insuplc_admdvs like '4301%' and b.insuplc_admdvs <> '430182' and setl_list_id is null " +
+            "and a.setl_time >= #{startTime} and and a.setl_time <= #{endTime}")
+    List<SiPatInfo> getHuanZheXinXi(@Param("startTime") String startTime,
+                                    @Param("endTime") String endTime);
 }

+ 12 - 14
src/main/java/thyyxxk/webserver/service/PublicServer.java

@@ -184,26 +184,25 @@ public class PublicServer {
         // 这里是重置 正流水号
         List<Integer> huoQuTuiFeiYuanLiuShui = dao.huoQuTuiFeiYuanLiuShui(inpatientNo, admissTimes, ledger);
         if (ListUtil.notBlank(huoQuTuiFeiYuanLiuShui)) {
-            List<List<Integer>> fenGeFuLiuShui = ListUtils.partition(huoQuTuiFeiYuanLiuShui, 100);
+            List<List<Integer>> fenGeFuLiuShui = ListUtils.partition(huoQuTuiFeiYuanLiuShui, 50);
             for (List<Integer> integers : fenGeFuLiuShui) {
                 dao.genXingFuShuDuiYingZhenLiuShui(inpatientNo, admissTimes, ledger, integers);
             }
         }
-        // 这里是判断正数的是否没有了
+        // 这里是判断正数的是否没有了,如果正数的没有了 那么负数的就要更新为空
         List<Integer> xuYaoQingKongDeFuLiuShui = new ArrayList<>();
-
-        Map<Integer, Integer> zhenShuLiuShuiMap = dao.zhenShuLiuShui(inpatientNo, admissTimes, ledger).stream().collect(Collectors.toMap(
-                item -> item, a -> a, (k1, k2) -> k1
-        ));
+        List<Integer> zhenShuLiuShuiMap = dao.zhenShuLiuShui(inpatientNo, admissTimes, ledger);
         List<Integer> fuShuLiuShui = dao.fuShuLiuShui(inpatientNo, admissTimes, ledger);
-
         for (Integer integer : fuShuLiuShui) {
-            if (!zhenShuLiuShuiMap.containsKey(integer)) {
+            if (!zhenShuLiuShuiMap.contains(integer) && !xuYaoQingKongDeFuLiuShui.contains(integer)) {
                 xuYaoQingKongDeFuLiuShui.add(integer);
             }
         }
         if (ListUtil.notBlank(xuYaoQingKongDeFuLiuShui)) {
-            dao.chongZhiFuShuYuanLiuShui(inpatientNo, admissTimes, ledger, xuYaoQingKongDeFuLiuShui);
+            List<List<Integer>> list = ListUtils.partition(xuYaoQingKongDeFuLiuShui, 50);
+            for (List<Integer> integers : list) {
+                dao.chongZhiFuShuYuanLiuShui(inpatientNo, admissTimes, ledger, integers);
+            }
         }
         // 这里判断是否重复退费,退多了
         Map<Integer, ZyDetailCharge> chongFuYuanLiuShuiMap = dao.chongFuTuiFeiLiuShui(inpatientNo, admissTimes, ledger).stream().collect(
@@ -224,11 +223,10 @@ public class PublicServer {
             if (ListUtil.notBlank(xuYaoChongZhiLiuShui)) {
                 dao.chongFuTuiFeiChongZhi(inpatientNo, admissTimes, ledger, xuYaoChongZhiLiuShui);
             }
-            // 这个是判断 trans_flag_yb = 2 费用相加 不为 0 的 就重置一下
-            if (!BigUtils.dengYu(dao.zhenFuXingDiFeiYong(inpatientNo, admissTimes, ledger), 0)) {
-                dao.chongXingZhengFuXiangDi(inpatientNo, admissTimes, ledger);
-            }
-
+        }
+        // 这个是判断 trans_flag_yb = 2 费用相加 不为 0 的 就重置一下
+        if (!BigUtils.dengYu(dao.zhenFuXingDiFeiYong(inpatientNo, admissTimes, ledger), 0)) {
+            dao.chongXingZhengFuXiangDi(inpatientNo, admissTimes, ledger);
         }
     }
 

+ 67 - 7
src/main/java/thyyxxk/webserver/service/medicalinsurance/SiManageService.java

@@ -1,5 +1,6 @@
 package thyyxxk.webserver.service.medicalinsurance;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -19,6 +20,7 @@ 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.setlinfo.SiSetlinfo;
 import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SlctSetlPrm;
 import thyyxxk.webserver.entity.medicalinsurance.setllistupload.IcuinfoUpld;
@@ -26,6 +28,7 @@ import thyyxxk.webserver.entity.medicalinsurance.setllistupload.IteminfoUpld;
 import thyyxxk.webserver.entity.medicalinsurance.setllistupload.SetlinfoUpld;
 import thyyxxk.webserver.service.PublicServer;
 import thyyxxk.webserver.utils.*;
+import thyyxxk.webserver.websocket.WebSocketServer;
 
 import java.io.IOException;
 import java.nio.file.Files;
@@ -308,13 +311,12 @@ public class SiManageService {
     }
 
     public ResultVo<JSONObject> upldSetlList(String patNo, Integer times, Integer ledgerSn) throws Exception {
-        log.info("入参 住院/门诊:{},次数:{}", patNo, times);
         SetlinfoUpld setlinfoUpld = upIdCollectionDao.setlinfo1(patNo, times);
         if (StringUtil.isBlank(setlinfoUpld.getSetlId())) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "结算id为空");
         }
         if (!setlinfoUpld.getInsuplc().startsWith("4301") || setlinfoUpld.getInsuplc().equals("430182")) {
-            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "该患者参保地不属于长沙市,无法上传结算清单。");
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该患者参保地不属于长沙市,无法上传结算清单。");
         }
         setlinfoUpld.setFixmedinsName(SiUtil.INSTITUTION_NAME);
         // 特级护理
@@ -419,19 +421,77 @@ public class SiManageService {
 
         JSONObject jsonObject = exec.makeTradeHeaderWithInsureArea(SiFunction.UPLOAD_SI_SETTLE_INFO, setlinfoUpld.getInsuplc());
         jsonObject.replace("input", input);
-//        log.info("查询结算单上传信息:{}", input);
-//        return ResultVoUtil.success(input);
         JSONObject result = exec.executeTrade(jsonObject, SiFunction.UPLOAD_SI_SETTLE_INFO);
         log.info("医保结算信息上传:\n参数:{} \n结果:{}", jsonObject, result);
         if (null == result) {
             return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
         }
         if (null == result.getInteger(RESULT_CODE)) {
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("医保中心报错:【%s】 ", result.getString("message")));
         }
         if (result.getIntValue(RESULT_CODE) == 0) {
-            return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "上传成功");
+            upIdCollectionDao.fanHuiLiuShuiHao(result.getJSONObject(OUTPUT).getString("setl_list_id"), setlinfoUpld.getSetlId());
+            return ResultVoUtil.success(ExceptionEnum.SUCCESS, "上传成功");
+        }
+        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("医保中心报错:【%s】 ", result.getString("err_msg")));
+    }
+
+    /**
+     * 多个患者上传
+     *
+     * @param param 患者信息
+     * @return 返回
+     */
+    public ResultVo<String> upldSetlListBatch(List<SiPatInfo> param) {
+        if (ListUtil.isBlank(param)) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "请选择需要上传的患者。");
+        }
+        for (SiPatInfo siPatInfo : param) {
+            try {
+                ResultVo<JSONObject> resultVo = upldSetlList(siPatInfo.getPatNo(), siPatInfo.getTimes(), siPatInfo.getLedgerSn());
+                if (resultVo.getCode() != ExceptionEnum.SUCCESS.getCode()) {
+                    upldSetlErrorMessage(siPatInfo.getPatNo(), siPatInfo.getTimes(), siPatInfo.getLedgerSn(), resultVo.getMessage());
+                }
+            } catch (Exception e) {
+                log.info("批量上传结算单错误:{}", JSON.toJSONString(e));
+                upldSetlErrorMessage(siPatInfo.getPatNo(), siPatInfo.getTimes(), siPatInfo.getLedgerSn(), e.getMessage());
+            }
         }
-        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString("err_msg"));
+        return ResultVoUtil.success();
     }
+
+    /**
+     * 根据时间上传
+     *
+     * @param startTime 开始时间
+     * @param endTime   结算时间
+     * @return 返回信息
+     */
+    public ResultVo<String> upldSetlListTimes(String startTime, String endTime) {
+        try {
+            upldSetlListBatch(upIdCollectionDao.getHuanZheXinXi(startTime, endTime));
+        } catch (Exception e) {
+            log.info("时间范围上传结算单错误:{}", JSON.toJSONString(e));
+        }
+        return ResultVoUtil.success();
+    }
+
+    /**
+     * 发送医保上传的错误信息
+     *
+     * @param meg 错误消息
+     */
+    public void upldSetlErrorMessage(String patNo, Integer times, Integer ledgerSn, String meg) {
+        JSONObject obj = new JSONObject();
+        obj.put("name", "upldSetlListMessage");
+        obj.put("message", meg);
+        obj.put("patNo", patNo);
+        obj.put("times", times);
+        obj.put("ledgerSn", ledgerSn);
+        String message = obj.toJSONString();
+        //  先写死成我的 02896
+        WebSocketServer.sendMessageByUserCode(TokenUtil.getTokenUserId(), message);
+        log.info("发送错误通知:{}", message);
+    }
+
 }

+ 30 - 0
src/main/resources/banner.txt

@@ -0,0 +1,30 @@
+${AnsiColor.BRIGHT_GREEN}$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
+      ██     ██     ██      ██     ██             ████   ████   ████
+     ░██    ████   ░██     ░██    ████           █░░░ █ █░░░ █ █░░░ █
+     ░██   ██░░██  ░██     ░██   ██░░██         ░█   ░ ░█   ░ ░█   ░
+     ░██  ██  ░░██ ░░██    ██   ██  ░░██        ░█████ ░█████ ░█████
+     ░██ ██████████ ░░██  ██   ██████████       ░█░░░ █░█░░░ █░█░░░ █
+ ██  ░██░██░░░░░░██  ░░████   ░██░░░░░░██       ░█   ░█░█   ░█░█   ░█
+░░█████ ░██     ░██   ░░██    ░██     ░██       ░ ████ ░ ████ ░ ████
+ ░░░░░  ░░      ░░     ░░     ░░      ░░         ░░░░   ░░░░   ░░░░
+${AnsiColor.BRIGHT_YELLOW}$$                                _.ooOoo._                               $$
+${AnsiColor.BRIGHT_RED}$$                               o888888888o                              $$
+${AnsiColor.BRIGHT_CYAN}$$                               88"  .  "88                              $$
+${AnsiColor.BRIGHT_MAGENTA}$$                               (|  ^_^  |)                              $$
+${AnsiColor.BRIGHT_GREEN}$$                               O\   =   /O                              $$
+${AnsiColor.BRIGHT_RED}$$                            ____/`-----'\____                           $$
+${AnsiColor.BRIGHT_CYAN}$$                          .'  \\|       |$$  `.                         $$
+${AnsiColor.BRIGHT_MAGENTA}$$                         /  \\|||   :   |||$$  \                        $$
+${AnsiColor.BRIGHT_GREEN}$$                        /  _|||||  -:-  |||||-  \                       $$
+${AnsiColor.BRIGHT_YELLOW}$$                        |   | \\\   -   $$/ |   |                       $$
+${AnsiColor.BRIGHT_GREEN}$$                        | \_|  ''\-----/''  |   |                       $$
+${AnsiColor.BRIGHT_YELLOW}$$                        \  .-\___  `-`  ____/-. /                       $$
+${AnsiColor.BRIGHT_CYAN}$$                      ___`. .'   /--.--\   `. . ___                     $$
+${AnsiColor.BRIGHT_RED}$$                    ."" '<  `.____\_<|>_/____.'  >'"".                  $$
+${AnsiColor.BRIGHT_GREEN}$$                  | | :  `- \`.;`.\ _ /``;.`/ - ` : | |                 $$
+${AnsiColor.BRIGHT_YELLOW}$$                  \  \ `-.   \_ ___\ /___ _/   .-` /  /                 $$
+${AnsiColor.BRIGHT_CYAN}$$            ========`-.____`-.____\_____/____.-`____.-'========         $$
+${AnsiColor.BRIGHT_MAGENTA}$$                                  `=---='                               $$
+${AnsiColor.BRIGHT_YELLOW}$$            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^        $$
+${AnsiColor.BRIGHT_GREEN}$$                     佛祖保佑          永无BUG         永不修改            $$
+${AnsiColor.BRIGHT_YELLOW}$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$