本实例使用EasyUI创建表格,元素,窗口,以及各种请求。增加,修改,查询及其他知识基本涵盖完全。有用到js创建和html创建.
整体概览:
多条件的分页查询
dialog对话框实现添加功能,加入验证
window弹窗多条件分页查询
修改信息
<%@ page contentType="text/html; charset=utf-8" import="java.util.*" language="java" %>
<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" pageEncoding="UTF-8"%>
public class QueryGoodsMovementAction extends Action {
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response)
throws Exception {
request.setCharacterEncoding("utf-8");
String startDate = request.getParameter("startDate");
String endDate = request.getParameter("endDate");
String movingCode = request.getParameter("movingCode");
int page = Integer.parseInt(request.getParameter("page"));
int rows = Integer.parseInt(request.getParameter("rows"));
QueryEasyuiDao dao = new QueryEasyuiDao();
Pagination pagination = dao.queryGoodsMovementList(page,rows,startDate, endDate, movingCode);
JSONObject json = new JSONObject();
json.put("total", pagination.getMaxElements());
json.put("rows", pagination.getPaginationList());
json = JSONObject.fromObject(json);
response.setCharacterEncoding("GBK");
response.getWriter().write(json.toString());
response.getWriter().flush();
response.getWriter().close();
return null;
}
}
public class GetAllParameterAction extends Action {
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response)
throws Exception {
ActionForm_UserInfo userinfo = (ActionForm_UserInfo) request.getSession().getAttribute("UserInfo");
String type = request.getParameter("type");
QueryEasyuiDao dao = new QueryEasyuiDao();
List resList = null;
Hashtable tab = new Hashtable();
if(type.equals("fromstor")){
resList = dao.getFromstorType();
tab.put("freight_code", 0);
tab.put("freight_info", "----请选择来源库位----");
}
if(type.equals("tostorage")){
resList = dao.getFromstorType();
tab.put("freight_code", 0);
tab.put("freight_info", "----请选择接收库位----");
}
if(type.equals("reason")){
String movement_types = request.getParameter("movement_types");
//if(movement_types!=null&&!(movement_types.equals(""))){
resList = dao.getReasonType(movement_types);
//}
tab.put("reason_code", 0);
tab.put("reason_name", "----请选择原因代码----");
}
resList.add(0,tab);
JSONArray arr = JSONArray.fromObject(resList);
response.setCharacterEncoding("GBK");
response.getWriter().write(arr.toString());
response.getWriter().flush();
response.getWriter().close();
return null;
}
}
public class GoodsMovingTypeAction extends Action {
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response)
throws Exception {
ActionForm_UserInfo userinfo = (ActionForm_UserInfo) request.getSession().getAttribute("UserInfo");
String type = request.getParameter("type");
QueryEasyuiDao dao = new QueryEasyuiDao();
List resList = dao.getMovingType();
Hashtable tab = new Hashtable();
if(type.equals("query")){
tab.put("movement_types", 0);
tab.put("summary", "----全部类型----");
}
if(type.equals("add")){
tab.put("movement_types", 0);
tab.put("summary", "----请选择移动类型----");
}
resList.add(0,tab);
JSONArray arr = JSONArray.fromObject(resList);
response.setCharacterEncoding("GBK");
response.getWriter().write(arr.toString());
response.getWriter().flush();
response.getWriter().close();
return null;
}
}
public class UpdateGoodStatusAction extends Action {
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response)
throws Exception {
ActionForm_UserInfo userinfo = (ActionForm_UserInfo) request.getSession().getAttribute("UserInfo");
String type = request.getParameter("type");
String flag = "";
QueryEasyuiDao dao = new QueryEasyuiDao();
if(type.equals("del")){
String moveid = request.getParameter("moveid");
String del_flag = request.getParameter("del_flag");
flag = dao.updateGoodDelStatusById(moveid, del_flag);
}
if(type.equals("exec")){
String moveids = request.getParameter("moveids");
flag = dao.updateGoodExecStatusById(moveids);
}
response.setCharacterEncoding("GBK");
response.getWriter().write(flag);
response.getWriter().flush();
response.getWriter().close();
return null;
}
}
public List getMovingType(){
List resList = new ArrayList();
String sql = "select mt.movement_types,(mt.movement_types||to_char(' ')||mt.summary||to_char(' ')||mt.description) as summary from gsk_v2_goodsmoving_types mt";
DataManage db;
try {
db = new DataManage();
resList = db.executeQuerys(sql);
} catch (SystemException e) {
e.printStackTrace();
} catch (NamingException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return resList;
}
public List getFromstorType(){
List resList = new ArrayList();
String sql = "select fp.freight_code,fp.freight_code||to_char(' ')||fp.freight_name||to_char(' ')||fp.freight_description freight_info from gsk_v2_freight_position fp";
DataManage db;
try {
db = new DataManage();
resList = db.executeQuerys(sql);
} catch (SystemException e) {
e.printStackTrace();
} catch (NamingException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return resList;
}
public List getReasonType(String movement_types){
List resList = new ArrayList();
String sql = "select gr.reason_code reason_code,(gr.reason_code||to_char(' ')||gr.reason_name) reason_name "
+ "from gsk_v2_goodsmoving_reasoncode gr where gr.reason_code in("
+ "select gref.reason_code from gsk_v2_gv_types_rc_ref gref "
+ "where gref.movement_types='"+movement_types+"')";
//System.out.println("getReasonTypeSQL:"+sql);
DataManage db;
try {
db = new DataManage();
resList = db.executeQuerys(sql);
} catch (SystemException e) {
e.printStackTrace();
} catch (NamingException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return resList;
}
public String updateGoodDelStatusById(String moveid ,String del_flag){
String value = del_flag.equals("0")?"1":"0";
String sql = "update gsk_v2_goodsmoving gm";
sql += " set gm.del_flag="+value;
sql += " where gm.moveid="+moveid;
try {
DataManage db = new DataManage();
//System.out.println("updateGoodStatusById:"+sql);
db.exeUpdate(sql);
return "true";
} catch (Exception ex) {
ex.printStackTrace();
}
return "false";
}
public String updateGoodExecStatusById(String moveids){
String sql = "update gsk_v2_goodsmoving gm set gm.exec_flag=0";
sql += " where gm.moveid in("+moveids+")";
try {
DataManage db = new DataManage();
//System.out.println("updateGoodExecStatusById:"+sql);
db.exeUpdate(sql);
return "true";
} catch (Exception ex) {
ex.printStackTrace();
}
return "false";
}
public String updateGoodMovingById(String moveid,String postingdate,String movementcode,String fromstoragelocatione,String tostoragelocatione,
String frommaterial,String frombatchnumbere,String quantity,String reasoncode){
String sql = "update gsk_v2_goodsmoving gm set gm.postingdate='"+postingdate
+ "',gm.movementcode='"+movementcode
+ "',gm.fromstoragelocation='"+fromstoragelocatione
+ "',gm.tostoragelocation='"+tostoragelocatione
+ "',gm.frommaterial='"+frommaterial
+ "',gm.frombatchnumber='"+frombatchnumbere
+ "',gm.tomaterial='"+frommaterial
+ "',gm.tobatchnumber='"+frombatchnumbere
+ "',gm.quantity="+quantity
+ ",gm.reasoncode="+reasoncode;
sql += " where gm.moveid="+moveid;
try {
DataManage db = new DataManage();
System.out.println("updateGoodMovingById:"+sql);
int n = db.exeUpdate(sql);
return n>=1?"true":"false";
} catch (Exception ex) {
ex.printStackTrace();
}
return "false";
}
public String addGoods(String postingdate,String movementcode,String fromstoragelocatione,String tostoragelocatione,
String frommaterial,String frombatchnumbere,String quantity,String reasoncode){
String sql = "insert into gsk_v2_goodsmoving"
+ "(moveid,postingdate,transferreno,frommaterial,fromstoragelocation,frombatchnumber,"
+ "movementcode,quantity,tomaterial,tostoragelocation,tobatchnumber,reasoncode,documentdatetime) "
+ "values(seq_gsk_goodsmoving.nextval,'"+postingdate+"',to_char(sysdate,'yyyymmdd')||to_char(seq_gsk_goodsmoving_num.nextval),"
+ "'"+frommaterial+"','"+fromstoragelocatione+"','"+frombatchnumbere+"','"+movementcode+"',"
+ "'"+quantity+"','"+frommaterial+"','"+tostoragelocatione+"','"+frombatchnumbere+"','"+reasoncode+"',to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'))";
try {
DataManage db = new DataManage();
//System.out.println("addGoods:"+sql);
int n = db.exeUpdate(sql);
return n>=1?"true":"false";
} catch (Exception ex) {
ex.printStackTrace();
}
return "false";
}
public Pagination queryGoodsMovementList( int pageNumber,int pageSize,String startDate,String endDate, String movingCode){
//List> resList = new ArrayList>();
String sql = "select gm.moveid,gm.postingdate,gm.transferreno,gm.movementcode,"
+ "(gm.movementcode||to_char('/')||gmt.summary||to_char('/')||gmt.description) as movementcodename ,"
+ "gm.fromstoragelocation,gm.tostoragelocation,gm.frommaterial, gm.frombatchnumber,"
+ "gm.quantity,gm.reasoncode,(gm.reasoncode||to_char('/')||gmr.reason_name) as reasoncodename,gm.documentdatetime,"
+ "gm.exec_flag,gm.del_flag from gsk_v2_goodsmoving gm left join gsk_v2_goodsmoving_types gmt "
+ "on gm.movementcode = gmt.movement_types left join gsk_v2_goodsmoving_reasoncode gmr "
+ "on gm.reasoncode = gmr.reason_code where 1=1";
if(startDate!=null&&!(startDate.equals(""))){
sql += " and gm.indate >= to_date('"+startDate+" 00:00:00','yyyy-mm-dd hh24:mi:ss')";
}
if(endDate!=null&&!(endDate.equals(""))){
sql += " and gm.indate <= to_date('"+endDate+" 23:59:29','yyyy-mm-dd hh24:mi:ss')";
}
if(movingCode!=null&&!(movingCode.equals(""))){
sql += " and gm.movementcode = '" + movingCode + "' ";
}
sql += " order by gm.moveid desc";
/*sql += " and a.create_date between " +
" to_date('" + startDate +
" 00:00:00', 'yyyy-mm-dd hh24:mi:ss') and " +
" to_date('" + endDate +
" 23:59:59', 'yyyy-mm-dd hh24:mi:ss')";*/
//System.out.println("queryGoodsMovementList---"+sql);
Pagination page = new OraclePagination(sql,pageSize,pageNumber);
return page;
/*try {
DataManage db = new DataManage();
resList = db.executeQuerys(sql);
} catch (SystemException e) {
e.printStackTrace();
} catch (NamingException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return resList;*/
}
/**
* 查询ERP商品信息
*/
public Pagination queryErpGoods(int pagemun,int pagesize,String erp_name,String erp_produce,String companyId){
//String dbl = basicDao.getApplyDBlink(companyId);
String sql = " select com_goods_id,goods_name,goods_desc,product_location,unit_name,goods_opcode, ";
sql += " package_num from temp_com_goods where 1=1 ";
if(erp_name!=null&&!(erp_name.equals(""))){
sql += " and (goods_name like '%"+erp_name+"%' or goods_opcode like ";
sql += " '%"+erp_name+"%' or upper(goods_spell) like '%"+erp_name.toUpperCase()+"%' ) ";
}
if(erp_produce!=null&&!(erp_produce.equals(""))){
sql += " and product_location like '%"+erp_produce+"%' ";
}
//System.out.println("queryErpGoodsSQL:"+sql);
Pagination page = new OraclePagination(sql,pagesize,pagemun);
return page;
}
public interface Pagination {
public boolean isFirst();
public boolean isLast();
public boolean hasNext();
public boolean hasPrevious();
public int getMaxElements();
public int getMaxPages();
public int getNext();
public int getPrevious();
public int getPageSize();
public int getPageNumber();
public List getPaginationList();
public String getToolBar(String url);
public String getToolBar(String url,String formName);
public String getToolBar(String url,String formName,boolean isIE);
public void setPageSize(int pageSize);
public void setPageNumber(int pageNumber);
}