zoukankan      html  css  js  c++  java
  • try catch throw在编程里面的应用

    我们可以在try里面写代码,在一些异常情况下我们throw new Exception("不存在此挂号预约");

    这样在catch (Exception e)里面我们就可以获取异常信息并作相应的返回信号

    public Map<String, Object> PUTGHYSQX(Map<String, Object> reqMap) {
            Map<String, Object> resultMap = new HashMap<String, Object>();
            try {
                resultMap.put("code", "0");
                resultMap.put("msg", "SUCCESS");
                String shxh = CommUtil.getStringVal(reqMap, "shxh");
                if (CommUtil.checkNull(shxh)) {
                    throw new Exception("锁号序号shxh不能为空!");
                }
                String patid = CommUtil.getStringValNull(reqMap, "patid");
                if (CommUtil.checkNull(patid)) {
                    throw new Exception("门诊patid不能为空!");
                }
                List<Map> ghyy = queryGHYY(new HashMap() {
                    {
                        put("ORDERID", shxh);
                    }
                });
                if (ghyy.size() == 0) {
                    throw new Exception("不存在此挂号预约");
                }    
                if (CommUtil.getIntVal(ghyy.get(0), "F_ZFZT") == 1) {
                    throw new Exception("此挂号预约已支付,不能取消");
                }
                if (CommUtil.getIntVal(ghyy.get(0), "F_HasGH") == 1) {
                    throw new Exception("此挂号预约已挂号,不能取消");
                }
                if (CommUtil.getIntVal(ghyy.get(0), "F_ISTY") == 1) {
                    throw new Exception("此挂号预约已退约");
                }
                updateTable(Constants.MZ_GHYY, new HashMap(){
                    {
                        put("ORDERID", shxh);
                    }
                }, new HashMap(){
                    {
                        put("F_ISTY", 1);
                    }
                });
                subYSSYHYHZ(ghyy.get(0).get("KSBM").toString(),
                        ghyy.get(0).get("YS").toString(),
                        Integer.parseInt(ghyy.get(0).get("RQ").toString()),
                        Integer.parseInt(ghyy.get(0).get("APM").toString()));
                subYSSYHYMX(ghyy.get(0).get("KSBM").toString(),
                        ghyy.get(0).get("YS").toString(),
                        Integer.parseInt(ghyy.get(0).get("RQ").toString()),
                        Integer.parseInt(ghyy.get(0).get("APM").toString()),
                        ghyy.get(0).get("SJD").toString());
            } catch (Exception e) {
                resultMap.put("code", "-1");
                resultMap.put("msg", "FAIL");
                resultMap.put("result", e.getMessage());
                getLogger().error(e.getMessage());
            }
            return resultMap;
        }
  • 相关阅读:
    主数据管理(MDM)的成熟度
    Tensorflow实战Google深度学习框架—郑泽宇书籍整理
    《Flink基础教程》王绍学习资料
    《重新定义计算(ApacheFlink实践)》_蒋晓伟资料整理
    js实现页面的自定义翻译
    谈谈px,em,rem(采自菜鸟)
    js和css分别实现元素曲线运动
    echarts鼠标事件以及自定义数据获取
    js数组的多条件排序
    H5-meta标签使用大全
  • 原文地址:https://www.cnblogs.com/luzhanshi/p/13167710.html
Copyright © 2011-2022 走看看