📄 orderaction.java
字号:
package com.easyjf.asp.action;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.easyjf.asp.business.ActiveUser;
import com.easyjf.asp.business.Customer;
import com.easyjf.asp.business.OrderInfo;
import com.easyjf.asp.business.OrderList;
import com.easyjf.asp.business.SystemDept;
import com.easyjf.util.CommUtil;
import com.easyjf.web.ActionContext;
import com.easyjf.web.Module;
import com.easyjf.web.Page;
import com.easyjf.web.WebForm;
import com.easyjf.web.tools.AbstractCmdAction;
import com.easyjf.web.tools.DbPageList;
import com.easyjf.web.tools.IActiveUser;
public class OrderAction extends AbstractCmdAction {
private final DecimalFormat df=new DecimalFormat("0");
private final static SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
public IActiveUser getCurrentUser(WebForm form) {
return (IActiveUser)ActionContext.getContext().getSession().getAttribute("user");
}
//执行登录检验
public Object doBefore(WebForm form,Module module) {
if(ActionContext.getContext().getSession().getAttribute("user")==null)return new Page("goto","/nologin.htm","html");
return null;
}
public Page doInit(WebForm form, Module module) {
// TODO Auto-generated method stub
return doNew(form,module);
}
public Page doNew(WebForm form, Module module) {
doEditLastInputOrder(form,(ActiveUser)this.getCurrentUser(form));
return module.findPage("edit");
}
public Page doTempSave(WebForm form, Module module) {
doSave(form,(ActiveUser)this.getCurrentUser(form));
doEditLastInputOrder(form,(ActiveUser)this.getCurrentUser(form));
return module.findPage("edit");
}
public Page doSave(WebForm form, Module module) {
doSave(form,(ActiveUser)this.getCurrentUser(form));
doEditLastInputOrder(form,(ActiveUser)this.getCurrentUser(form));
return module.findPage("edit");
}
public Page doEdit(WebForm form, Module module) {
String cid=CommUtil.null2String(form.get("cid"));
String sn=CommUtil.null2String(form.get("orderSn"));
OrderInfo order=null;
if(!cid.equals(""))order=OrderInfo.read(cid);
else if(!sn.equals(""))order=OrderInfo.readBySn(sn);
if(order!=null)
{
form.addResult("cid",order.getCid());
form.addResult("totalAmount",order.getAmount());
form.addResult("status",order.getStatus());
form.addResult("payment",order.getPayment());
form.addResult("delivery",order.getDelivery());
if(order.getDeliveryDept()!=null && (!order.getDeliveryDept().equals("")))
form.addResult("deliveryDept",Customer.readBySn(order.getDeliveryDept()));
form.addResult("vdate",CommUtil.format(order.getVdate()));
form.addResult("customer",Customer.readBySn(order.getCustomerSn()));
form.addResult("orderSn",order.getSn());
form.addResult("linkMan",order.getLinkMan());
List list=order.children();
if(list!=null){
form.addResult("orderList",order.children());
form.addResult("childNum",new Integer(list.size()));
}
list=OrderInfo.query("status=-1 and cid<>'"+order.getCid()+"'");
form.addResult("otherList",list);
}
return module.findPage("edit");
}
public Page doDel(WebForm form, Module module) {
ActiveUser user=(ActiveUser)this.getCurrentUser(form);
String cid=CommUtil.null2String(form.get("cid"));
String sn=CommUtil.null2String(form.get("orderSn"));
OrderInfo order=null;
if(!cid.equals(""))order=OrderInfo.read(cid);
else if(!sn.equals(""))order=OrderInfo.readBySn(sn);
if(order!=null)
{
order.del();
form.addResult("msg","删除成功!");
}
else
form.addResult("msg","删除失败!");
//doQuery(form,user);
doEditLastInputOrder(form,user);
return module.findPage("edit");
}
public Page doList(WebForm form, Module module) {
doQuery(form,(ActiveUser)this.getCurrentUser(form));
return module.findPage("list");
}
public Page doQuery(WebForm form, Module module) {
return doList(form,module);
}
public Page doManage(WebForm form, Module module) {
doEdit(form,module);
return module.findPage("manage");
}
public Page doManageSave(WebForm form, Module module) {
ActiveUser user=(ActiveUser)this.getCurrentUser(form);
doManageSave(form,user);
doEdit(form,module);
return module.findPage("manage");
}
public Page doPrint(WebForm form, Module module) {
ActiveUser user=(ActiveUser)this.getCurrentUser(form);
SystemDept dept=SystemDept.readBySn(user.getDept());
if(dept!=null)form.addResult("deptTitle",dept.getTitle());
String cid=CommUtil.null2String(form.get("cid"));
String sn=CommUtil.null2String(form.get("orderSn"));
OrderInfo order=null;
//System.out.println(cid);
if(!cid.equals(""))order=OrderInfo.read(cid);
else if(!sn.equals(""))order=OrderInfo.readBySn(sn);
if(order!=null)
{
form.addResult("cid",order.getCid());
form.addResult("totalAmount",df.format(order.getAmount().setScale(2)));
form.addResult("status",order.getStatus());
//form.addResult("vdate",CommUtil.format(order.getVdate()));
form.addResult("vdate",CommUtil.format(new Date()));
form.addResult("linkMan",order.getLinkMan());
form.addResult("tel",order.getTel());
form.addResult("customer",Customer.readBySn(order.getCustomerSn()));
form.addResult("orderSn",order.getSn());
List list=order.children();
if(list!=null){
Map map=new HashMap();
map.put("sequence",new Integer(list.size()+1));
map.put("productSn"," ");
map.put("title","合 计");
//Format f=new DecimalFormat(".00");
map.put("amount",order.getAmount().setScale(2));
list.add(map);
form.addResult("orderList",list);
form.addResult("childNum",new Integer(list.size()));
}
list=OrderInfo.query("status=-1 and cid<>'"+order.getCid()+"'");
form.addResult("otherList",list);
}
return module.findPage("print");
}
public Page doTotalPrint(WebForm form, Module module) {
ActiveUser user=(ActiveUser)this.getCurrentUser(form);
SystemDept dept=SystemDept.readBySn(user.getDept());
if(dept!=null)form.addResult("deptTitle",dept.getTitle());
String orderType=CommUtil.null2String(form.get("orderType"));
String orderField=CommUtil.null2String(form.get("orderField"));
String scope="status>=0 and belongDept=?";
Collection paras=new ArrayList();
paras.add(user.getDept());
String customerSn=CommUtil.null2String(form.get("customerSn"));
String vdate1=CommUtil.null2String(form.get("vdate1"));
String vdate2=CommUtil.null2String(form.get("vdate2"));
if(!customerSn.equals(""))
{
scope+=" and customerSn=?";
paras.add(customerSn);
}
if(vdate2.equals("")&& !vdate1.equals(""))
{
scope+=" and vdate=?";
paras.add(vdate1);
}
else if(!vdate1.equals(""))
{
scope+=" and vdate>=?";
paras.add(vdate1);
}
if(!vdate2.equals(""))
{
scope+=" and vdate<?";
paras.add(vdate2);
}
if(orderField.equals(""))
{
orderField="vdate";
orderType="desc";
}
scope +=" order by "+orderField;
if(!orderType.equals(""))scope+=" "+orderType;
DbPageList pList=new DbPageList(OrderInfo.class,scope,paras);
pList.doList(1,-1);
if(pList!=null)
{
List list=pList.getResult();
BigDecimal total=new BigDecimal(0.0);
if(list!=null){
for(int i=0;i<list.size();i++)
{
total=total.add(((OrderInfo)list.get(i)).getAmount());
}}
form.addResult("list",list);
form.addResult("pages",new Integer(pList.getPages()));
form.addResult("rows",new Integer(pList.getRowCount()));
form.addResult("page",new Integer(pList.getCurrentPage()));
form.addResult("totalAmount",total);
form.addResult("vdate",sdf.format(new Date()));
//form.addResult("gotoPageHTML ",CommUtil.showPageHtml(pList.getCurrentPage(),pList.getPages()));
}
form.addResult("vdate",CommUtil.format(new Date()));
return module.findPage("totalPrint");
}
public Page doListPrint(WebForm form, Module module) {
ActiveUser u=(ActiveUser)this.getCurrentUser(form);
SystemDept dept=SystemDept.readBySn(u.getDept());
if(dept!=null)form.addResult("deptTitle",dept.getTitle());
int currentPage=CommUtil.null2Int(form.get("page"));
int pageSize=CommUtil.null2Int(form.get("pageSize"));
String orderType=CommUtil.null2String(form.get("orderType"));
String orderField=CommUtil.null2String(form.get("orderField"));
if(currentPage<1)currentPage=1;
if(pageSize<1)pageSize=15;
String scope="status>=0 and belongDept=?";
Collection paras=new ArrayList();
paras.add(u.getDept());
String customerSn=CommUtil.null2String(form.get("customerSn"));
String vdate1=CommUtil.null2String(form.get("vdate1"));
String vdate2=CommUtil.null2String(form.get("vdate2"));
if(!customerSn.equals(""))
{
scope+=" and customerSn=?";
paras.add(customerSn);
}
if(vdate2.equals("")&& !vdate1.equals(""))
{
scope+=" and vdate=?";
paras.add(vdate1);
}
else if(!vdate1.equals(""))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -