2013年11月2日星期六

In the pages strut problems occur when running

Great God I'm doing you javaweb development , encountered this problem such
I looked at the code I can not find the cause of the problem in any place , here is my code for this error page



------ Solution ------- -------------------------------------
check the value of your reception ggmc pass over no ?
------ Solution ---------------------------------------- ----
use ggmc before printing , there should be no value cause a null pointer
------ For reference only ------------------ ---------------------
upstairs two pages I put this code to paste all out to help me look at you , you just said that ggmc this field is " ad Name ", and it is this field there are two cases , when the background fill ad name when it will have value , if not filled when it is advertised name null value , I would like to ask , at what where the judgment together with nulls
package com.borui.actions.magazine;
import com.borui.actions.BaseAction;
import com.borui.report.Form;
import com.borui.report.Report;
import com.borui.utils.NetUtils;
import net.sf.json.JSONObject;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.List;
@Namespace("/magazine")
public class MeetingOrderAction extends BaseAction {
    private String SL;
    private String orderNo;
    private String ydl;
    private String meetingid;
    private SXMagazineAction meeting = new SXMagazineAction();
    private MeetingAction meetingAction = new MeetingAction();

    public String getYdl() {
        return ydl;
    }

    public void setYdl(String ydl) {
        this.ydl = ydl;
    }
    public String getSL() {
        return SL;
    }

    public void setSL(String SL) {
        this.SL = SL;
    }
    public String getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    public String getMeetingid() {
        return meetingid;
    }
    public void setMeetingid(String meetingid) {
        this.meetingid = meetingid;
    }

    //orderSuccess
    @Action(value = "meetingorder", results = {
            @Result(name = "alipay", location = "../alipay/alipayapi", params = {"meetingid", "${orderNo}"}, type = "redirect"),
            @Result(name = "orderSuccess", location = "../alipay/return_url.jsp", params = {"meetingid", "${orderNo}"})})
    public String meetingorder() {
        Report meet = getGys();
        Report meetInfo = getMeeting(meetingid);
        Report ggmc = getMeetadvent();
        String gys = getGysName();

        setAttribute("ggmc", ggmc);
        setAttribute("gysName", gys);
        setAttribute("meetInfo", meetInfo);
        setAttribute("provinces", getOrderProvinces());
        setAttribute("meetingid", meetingid);
        if (isPost()) {
            if (meetingAction.checkPay(meetingid) || checkAdOrderMoney(meetingid)) {
                orderNo = createOrder(meetingid);
                return "alipay";
            } else {
                orderNo = createOrder(meetingid);
                setAttribute("orderStatue", "报名成功");
                return "orderSuccess";
            }
        }
        return SUCCESS;
    }

    //获取会议广告名称
    public Report getMeetadvent() {
        Report ggmc = new Report();
        ggmc.setFormID("aae02a63418901440141aab3faf30432");
        ggmc.setReportID("r_63c6fa1445b947e890580a2714c3d486");
        ggmc.putParam("hyid", meetingid);
        ggmc.setPaging(false);
        try {
            ggmc.init();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ggmc;
    }

    //获取会议信息、供应商
    public Report getGys() {
        Report report = new Report("aae02a6340c71b520140f124a9490283", "r_0201f2c51efb459aa229132545a3c0f2");
        try {
            report.init();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return report;
    }

    //获取会议信息
    public Report getMeetingInfo(String hyid) {
        Report report = new Report("aae02a6340c71b520140f124a9490283", "r_a8d3c09d1bf54eed94841ad015c9811d");
        report.putParam("hyid", hyid);
        try {
            report.init();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return report;
    }

    //获取会议信息
    private Report getMeeting(String meetingid) {
        StringBuffer str = new StringBuffer(" 1=1 ");
        Report report = new Report();
        report.setCustomForm(true);
        report.setReportID("r_8f3987e7010945bf824b25795ae945c8");
        if (!"".equals(meetingid)) {
            str.append(" and GYSHY.HYID = '").append(meetingid).append("'");
        }
        report.putParam("hyid", str);
        try {
            report.init();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return report;
    }

    //给广告位加上数组方法
    private String[] moneys(String meetingid) {
        return new String[0];
    }

    //保存信息
    public String createOrder(String meetingid) {
        String money = money(meetingid);
        String[] moneys = moneys(meetingid);
        BigDecimal signal = new BigDecimal("0");
        BigDecimal pic_m = new BigDecimal("0");
        BigDecimal number = new BigDecimal("0");
        number = new BigDecimal(SL);
        signal = new BigDecimal(money);
        pic_m = signal.multiply(number);

        String orderNo = NetUtils.getOrderNumber();
        String chose = getParameter("choose");
        String dep = getParameter("LXRXM");
        String phono = getParameter("SJ");
        String name = getParameter("QPRXM");
        String zw = getParameter("BMZW");
        String idcar = getParameter("QPRSFZHM");
        String email = getParameter("YX");
        String dh = getParameter("GDHM");
        String sm = getParameter("SM");
        String chosenCity = getParameter("chosenCity");
        String tj = getParameter("tuijian");
        String fax = getParameter("FAX");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String ly_time = sdf.format(new java.util.Date());
        SimpleDateFormat time = new SimpleDateFormat("HH:mm:ss");
        String ltime = time.format(new java.util.Date());

        BigDecimal moneyAll = new BigDecimal("0");
        moneyAll = pic_m;
        if (getParameter("ydl") != null) {
            String[] mc = getRequest().getParameterValues("ggmc");
            String[] dgsl = getRequest().getParameterValues("ydl");
            int sum = 0;
            for (int i = 0; i < mc.length; ++i) {
                int num = Integer.parseInt(dgsl[i]);
                sum += num;
            }

            BigDecimal priceOne = new BigDecimal("0");
            BigDecimal priceAll = new BigDecimal("0");
            BigDecimal zje = new BigDecimal("0");
            String[] gid = getParameterValues("GGID");
            if (mc.length == dgsl.length) {
                for (int i = 0; i < mc.length; i++) {
                    Report piaojia = new Report();
                    piaojia.setCustomForm(true);
                    piaojia.setReportID("r_35ff7c87f5e1457dbd8c6135d23dad40");
                    String where = "1=1";
                    if (!"".equals(gid[i])) {
                        where = where + " and HYGG.GID= '" + NetUtils.decode(gid[i]) + "'";
                    }
                    piaojia.putParam("where", where);
                    piaojia.setPageNumber(1);
                    piaojia.setPageSize(1);
                    try {
                        piaojia.init();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    List dj = piaojia.getData();
                    String prices = (((JSONObject) dj.get(0)).getString("GGDJ")).equals("") ? "0" : ((JSONObject) dj.get(0)).getString("GGDJ");
                    priceOne = new BigDecimal(prices);
                    int pnumber = Integer.parseInt(dgsl[i]);
                    if (pnumber != 0) {
                        BigDecimal piaoNub = new BigDecimal(pnumber);
                        priceAll = priceOne.multiply(piaoNub);
                        Form quantity = new Form();
                        quantity.setFormID("aae02a6341b5f0da0141c12246e50528");
                        quantity.setAction(Form.ACTION_ADD);
                        if (checkAdOrderMoney(meetingid)) {
                            quantity.putParam("FKZT", "未付款");
                        } else {
                            quantity.putParam("FKZT", "免费");
                        }
                        quantity.putParam("DDBH", orderNo);
                        quantity.putParam("HYID", meetingid);
                        quantity.putParam("GGMC", mc[i]);
                        quantity.putParam("YDSL", pnumber);
                        quantity.putParam("ZJE", priceAll);
                        try {
                            quantity.save();
                            moneyAll = moneyAll.add(priceAll);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }

        Form form = new Form();
        form.setFormID("aae02a63410a4e2601414853f56503b1");
        form.setAction(Form.ACTION_ADD);
        if (meetingAction.checkPay(meetingid)) {
            form.putParam("FKZT", "未付款");
        } else {
            form.putParam("FKZT", "免费");
        }
        form.putParam("SL", SL);
        form.putParam("BMZT", "已报名");
        form.putParam("BMDW", dep);
        form.putParam("LXDH", phono);
        form.putParam("XM", name);
        form.putParam("ZW", zw);
        form.putParam("SFHM", idcar);
        form.putParam("YX", email);
        form.putParam("CZ", fax);
        form.putParam("SM", sm);
        form.putParam("DGRQ", ly_time);
        form.putParam("DGSJ", ltime);
        form.putParam("CITY", chosenCity);
        form.putParam("FL", chose);
        form.putParam("TJDW", tj);
        form.putParam("GYSID", getGysid(meetingid));
        form.putParam("GSMC", getGysName());
        form.putParam("DHHM", dh);
        form.putParam("DDBH", orderNo);
        form.putParam("FY", moneyAll);
        form.putParam("HYMC", getMeetingName());
        form.putParam("HYID", meetingid);
        try {
            form.save();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return orderNo;
    }

------ For reference only ----------------------------------- ----
   //获取供应商名称
    public String getGysName() {
        String gysid = "";
        String gysName = "";
        CooperationAction cooperation = new CooperationAction();
        Report report = getMeeting(meetingid);
        List list = report.getData();
        if (list != null && list.size() != 0) {
            if (((JSONObject) list.get(0)).getString("GYSID") != null) {
                gysid = ((JSONObject) list.get(0)).getString("GYSID");
            }
        }

        Report gysReport = cooperation.getGYSInfo(gysid);
        List gyslist = gysReport.getData();
        if (list != null && list.size() != 0) {
            if (((JSONObject) gyslist.get(0)).getString("GSMC") != null) {
                gysName = ((JSONObject) gyslist.get(0)).getString("GSMC");
            }
        }
        return gysName;
    }

    //获取供应商名称
    public String getGysName(String hyid) {
        String gysName = "";
        CooperationAction cooperation = new CooperationAction();
        Report gysReport = cooperation.getGYSInfo(getGysid(hyid));
        List gyslist = gysReport.getData();
        if (gyslist != null && gyslist.size() != 0) {
            if (((JSONObject) gyslist.get(0)).getString("GSMC") != null) {
                gysName = ((JSONObject) gyslist.get(0)).getString("GSMC");
            }
        }
        return gysName;
    }

    //获取供应商id
    public String getGysid(String hyid) {
        String gysid = "";
        Report report = new Report("aae02a6340c71b520140f124a9490283", "r_a8d3c09d1bf54eed94841ad015c9811d");
        report.putParam("hyid", hyid);
        try {
            report.init();
        } catch (Exception e) {
            e.printStackTrace();
        }
        List list = report.getData();
        if (list != null && list.size() != 0) {
            gysid = ((JSONObject) list.get(0)).getString("GYSID");
        }
        return gysid;
    }

    //获取会议id
    public String getMeetingID() {
        Report meetInfo = getMeeting(meetingid);
        List meetingList = meetInfo.getData();
        return ((JSONObject) meetingList.get(0)).getString("HYID");
    }

    //获取会议名称
    public String getMeetingName(String orderNo, String str) {
        String money = "";
        List meetingOrderList = getMeetingOrder(orderNo);
        if (meetingOrderList != null && meetingOrderList.size() != 0) {
            JSONObject object = (JSONObject) meetingOrderList.get(0);
            if (object.get(str) != null) {
                money = object.getString(str);
            }
        }
        return money;
    }

    //获取会议名称
    public String getMeetingName() {
        Report meetInfo = getMeeting(meetingid);
        List meetingList = meetInfo.getData();
        return ((JSONObject) meetingList.get(0)).getString("HYMC");
    }

    //会议费用
    public String money(String meetingid) {
        Report meeting = getMeeting(meetingid);
        String money = "0";
        List meetingList = meeting.getData();
        if (meetingList != null && meetingList.size() != 0) {
            money = ((JSONObject) meetingList.get(0)).getString("FY");
        }
        return money;
    }

    //保存订单付款状态
    public void saveMeetingOrder(String gid) {
        Form form = new Form();
        form.setFormID("aae02a63410a4e2601414853f56503b1");
        form.setGid(gid);
        form.setAction(Form.ACTION_EDIT);
        form.putParam("FKZT", "已付款");
        try {
            form.save();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //保存广告位订单状态
    public void savaAdventOrder(String gid) {
        Form from = new Form();
        from.setFormID("aae02a6341b5f0da0141c12246e50528");
        from.setGid(gid);
        from.setAction(Form.ACTION_ADD);
        from.putParam("FKZT", "已付款");
        try {
            from.save();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //获取会议价格
    public String getMoney(String orderNo) {
        String money = "";
        List meetingOrderList = getMeetingOrder(orderNo);
        if (meetingOrderList != null && meetingOrderList.size() != 0) {
            JSONObject object = (JSONObject) meetingOrderList.get(0);
            if (object.get("FY") != null && !"0".equals(object.getString("FY"))) {
                money = (object.getString("FY"));
            }
        }
        return money;
    }

    //获取会议订单
    public List getMeetingOrder(String number) {
        Report report = new Report("aae02a63410a4e2601414853f56503b1", "r_d61ff96782944a18b34efd99ec6b50b8");
        report.putParam("number", number);
        try {
            report.init();
        } catch (Exception e) {
            e.printStackTrace();
        }
        List list = report.getData();
        return list;
    }


    //检测广告位价格是否需呀付费
    public Boolean checkAdOrderMoney(String meetingid) {
        String money = getAdOrderMoney();
        try {
            String[] checkMoney = money.split("[.]");
            if (checkMoney.length > 1) {
                if ("0.00".equals(money) || "0.0".equals(money)) {
                    return false;
                } else if (checkMoney[1] == null) {
                    money = checkMoney[0];
                } else {
                    return true;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return SXMagazineAction.isNumeric(money) && !"0".equals(money);
    }

    //获取广告位价格
    public String getAdOrderMoney() {
        String[] mc = getRequest().getParameterValues("ggmc");
        String[] dgsl = getRequest().getParameterValues("ydl");
        int sum = 0;
        for (int i = 0; i < mc.length; ++i) {
            int num = Integer.parseInt(dgsl[i]);
            sum += num;
        }
        BigDecimal money = new BigDecimal("0");
        BigDecimal priceOne = new BigDecimal("0");
        BigDecimal priceAll = new BigDecimal("0");
        BigDecimal zje = new BigDecimal("0");
        String[] gid = getParameterValues("GGID");
        if (mc.length == dgsl.length) {
            for (int i = 0; i < mc.length; i++) {
                Report piaojia = new Report();
                piaojia.setCustomForm(true);
                piaojia.setReportID("r_35ff7c87f5e1457dbd8c6135d23dad40");
                String where = "1=1";
                if (!"".equals(gid[i])) {
                    where = where + " and HYGG.GID= '" + NetUtils.decode(gid[i]) + "'";
                }
                piaojia.putParam("where", where);
                piaojia.setPageNumber(1);
                piaojia.setPageSize(1);
                try {
                    piaojia.init();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                List dj = piaojia.getData();
                String prices = (((JSONObject) dj.get(0)).getString("GGDJ")).equals("") ? "0" : ((JSONObject) dj.get(0)).getString("GGDJ");
                priceOne = new BigDecimal(prices);
                int pnumber = Integer.parseInt(dgsl[i]);
                if (pnumber != 0) {
                    BigDecimal piaoNub = new BigDecimal(pnumber);
                    priceAll = priceOne.multiply(piaoNub);
                    money = money.add(priceAll);
                }
            }
        }

        return money.toString();
    }
}

two upstairs Great God help us to see
------ For reference only ------------------------- --------------
two muddy I just made ​​above me remember determine whether the air and did not remember the following judgment , but now resolved or thank two reminders

没有评论:

发表评论