企业固定资产管理系统(jsp+ssh框架+数据库SQL)

资源管理系统

  • 项目截图浏览
    • 数据库表浏览图
    • 登录
    • 主界面
    • 采购登记
    • 物资审核入库
    • 资产出库菜单
    • 资产处理菜单
    • 查询统计菜单
    • 系统管理菜单
    • 基础信息——物资管理
    • 查询统计——部门汇总
    • 查询统计——采购单详细表
    • Action——Goods
    • DAO层——查询

项目截图浏览

运行环境

Myeclipse+sqlServer+tomcat(jdk,tomcat自由选择7-10)

企业固定资产管理系统(jsp+ssh框架+数据库SQL)_第1张图片

数据库表浏览图

企业固定资产管理系统(jsp+ssh框架+数据库SQL)_第2张图片

登录

企业固定资产管理系统(jsp+ssh框架+数据库SQL)_第3张图片

主界面

采购登记

企业固定资产管理系统(jsp+ssh框架+数据库SQL)_第4张图片

物资审核入库

图片: 企业固定资产管理系统(jsp+ssh框架+数据库SQL)_第5张图片

资产出库菜单

图片:
企业固定资产管理系统(jsp+ssh框架+数据库SQL)_第6张图片

资产处理菜单

图片:
企业固定资产管理系统(jsp+ssh框架+数据库SQL)_第7张图片

查询统计菜单

图片:
企业固定资产管理系统(jsp+ssh框架+数据库SQL)_第8张图片

系统管理菜单

图片:
企业固定资产管理系统(jsp+ssh框架+数据库SQL)_第9张图片

基础信息——物资管理

图片:
企业固定资产管理系统(jsp+ssh框架+数据库SQL)_第10张图片

查询统计——部门汇总

图片:
企业固定资产管理系统(jsp+ssh框架+数据库SQL)_第11张图片

查询统计——采购单详细表

图片:
企业固定资产管理系统(jsp+ssh框架+数据库SQL)_第12张图片

Action——Goods

物资处理类源码展示

// Goods Action
package com.action;

import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForward;
import com.actionForm.GoodsForm;
import com.dao.*;
import org.apache.struts.action.Action;

public class Goods extends Action {
    private GoodsDAO goodsDAO=null;
    public Goods(){
        goodsDAO=new GoodsDAO();
    }
    public ActionForward execute(ActionMapping mapping, ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response) {

        String action=request.getParameter("action");

        if(action.equals("") || action==null){
            request.setAttribute("error","您的操作有误!");
            return mapping.findForward("error");
        }else if(action.equals("goodsRequest")){
            return goodsQuery(mapping,form,request,response);
        }else if(action.equals("goodsadd")){
            return goodsAdd(mapping,form,request,response);
        }else if(action.equals("goodsMquery")){
            return goodsModiQuery(mapping,form,request,response);
        }else if(action.equals("goodsmodify")){
            return goodsModify(mapping,form,request,response);
        }else if(action.equals("goodsdel")){
            return goodsdel(mapping,form,request,response);
        }
        request.setAttribute("error","您的操作有误!");
        return mapping.findForward("error");
    }
    public ActionForward goodsQuery(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response){
        String str=null;
        int ifdel=0;   //获取未被删除的物资
        request.setAttribute("goodslist0",goodsDAO.query(str,ifdel));
        ifdel=1;   //获取已被删除的物资
        request.setAttribute("goodslist1",goodsDAO.query(str,ifdel));
        return mapping.findForward("goodsQuery");
    }
    //添加物资信息
    public ActionForward goodsAdd(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response){
        GoodsForm goodsForm = (GoodsForm) form;
//        goodsForm.setName(chStr.toChinese(goodsForm.getName()));
//        goodsForm.setSpec(chStr.toChinese(goodsForm.getSpec()));
//        goodsForm.setUnit(chStr.toChinese(goodsForm.getUnit()));
//        goodsForm.setProducer(chStr.toChinese(goodsForm.getProducer()));
        int rtn=goodsDAO.insert(goodsForm);
        if (rtn == 1) {
            return mapping.findForward("goodsaddok");
        } else if (rtn == 2) {
            request.setAttribute("error", "该物资信息已经添加!");
            return mapping.findForward("error");
        } else {
            request.setAttribute("error", "物资信息添加失败!");
            return mapping.findForward("error");
        }
    }
    //修改物资信息的查询
    public ActionForward goodsModiQuery(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response){
        int id=Integer.parseInt(request.getParameter("id"));
        request.setAttribute("goodsForm",goodsDAO.query(id));
        return mapping.findForward("goodsModiQuery");
    }
    //修改物资信息
    public ActionForward goodsModify(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response){
        GoodsForm goodsForm = (GoodsForm) form;
        int rtn=goodsDAO.update(goodsForm);
        if (rtn == 1) {
            return mapping.findForward("goodsmodifyok");
        }else {
            request.setAttribute("error", "物资信息修改失败!");
            return mapping.findForward("error");
        }
    }
    //删除/恢复物资信息
    public ActionForward goodsdel(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response){
    int id=Integer.parseInt(request.getParameter("id"));
    byte val=Byte.parseByte(request.getParameter("val"));
    int rtn=goodsDAO.del(id,val);
    if(rtn==1){
         return mapping.findForward("goodsdelok");
    }else{
        request.setAttribute("error", "物资信息删除/恢复失败!");
        return mapping.findForward("error");
    }
}

}


DAO层——查询

// Goods Action
package com.dao;

import java.util.List;
import com.actionForm.StockMainViewForm;
import com.core.MySession;
import org.hibernate.Query;
import com.actionForm.LoanForm;
import com.actionForm.IfForm;
import org.hibernate.Session;
import com.actionForm.GoodsForm;
import com.actionForm.BranchForm;
import com.actionForm.DamageForm;
import org.hibernate.SQLQuery;
import com.actionForm.GetUseForm;
import java.util.Set;

public class QueryDAO {
    private Session session = null;
    //查询采购单详细信息
    public StockMainViewForm stockDetail(int id) {
        session = MySession.openSession(); //打开Session
        StockMainViewForm stockMVF = new StockMainViewForm();
        try {
            stockMVF = (StockMainViewForm) session.get(StockMainViewForm.class,
                    id);
            System.out.println("采购详细信息的大小:" + stockMVF.getStockDetail().size());
        } catch (Exception e) {
            System.out.println("查询采购单详细信息时出错:" + e.getMessage());
        } finally {
            MySession.closeSession(session);
        }
        return stockMVF;
    }

    //查询借出单详细信息
    public LoanForm loanDetail(int id) {
        session = MySession.openSession(); //打开Session
        LoanForm loanF = null;
        try {
            loanF = (LoanForm) session.get(LoanForm.class,
                                           id);
        } catch (Exception e) {
            System.out.println("查询借出单详细信息时出错:" + e.getMessage());
        } finally {
            MySession.closeSession(session);
        }
        return loanF;
    }

//查询部门报损信息
    public List damageQuery(IfForm ifForm) {
        session = MySession.openSession(); //打开Session
        String str = ifCompose(ifForm);
        String sql = "select {damage.*},{goods.*},{branch.*} from tb_damage damage inner join tb_goods goods on damage.goodsid=goods.id inner join tb_branch branch on damage.branchid=branch.id ";
        List list = null;
        if (str == null) {
            sql = sql + " order by damage.createTime desc";
        } else {
            sql = sql + " WHERE " + str +
                  " order by damage.createTime desc";
        }
        session = MySession.openSession(); //打开Session
        System.out.println("SQL=" + sql);
        try {
            SQLQuery query = session.createSQLQuery(sql);
            query.addEntity("goods", GoodsForm.class); //将数据表与实体类关联在一起
            query.addEntity("damage", DamageForm.class);
            query.addEntity("branch", BranchForm.class);
            list = query.list();
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("查询时出现的错误信息:" + e.getMessage());
        } finally {
            MySession.closeSession(session); //关闭Session
        }
        return list;
    }

    //查询部门领用信息
    public List getuseQuery(IfForm ifForm) {
        session = MySession.openSession(); //打开Session
        String str = ifCompose(ifForm);
        String sql = "select {getuse.*},{goods.*},{branch.*} from tb_getuse getuse inner join tb_goods goods on getuse.goodsid=goods.id inner join tb_branch branch on getuse.branchid=branch.id ";
        List list = null;
        if (str == null) {
            sql = sql + " order by getuse.createTime desc";
        } else {
            sql = sql + " WHERE " + str +
                  " order by getuse.createTime desc";
        }
        session = MySession.openSession(); //打开Session
        System.out.println("SQL=" + sql);
        try {
            SQLQuery query = session.createSQLQuery(sql);
            query.addEntity("goods", GoodsForm.class); //将数据表与实体类关联在一起
            query.addEntity("getuse", GetUseForm.class);
            query.addEntity("branch", BranchForm.class);
            list = query.list();
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("查询时出现的错误信息:" + e.getMessage());
        } finally {
            MySession.closeSession(session); //关闭Session
        }
        return list;
    }

    //部门领用、报损信息汇总
    public List getusedamageTotal(IfForm ifForm,String form,String cfield) {
        session = MySession.openSession(); //打开Session
        String str = ifCompose(ifForm);
        String sql="";
        List list = null;
        if (str == null) {
            sql = "select sum(form."+cfield+") as amount,b.name,g.name,g.spec,g.price,g.unit,g.producer "+
                     "FROM "+form+" form JOIN form.branch b JOIN form.goods g "+
                     "GROUP BY b.name,g.name,g.spec,g.price,g.unit,g.producer";
        } else {
            sql ="select sum(form."+cfield+") as amount,b.name,g.name,g.spec,g.price,g.unit,g.producer "+
                     "FROM "+form+" form JOIN form.branch b JOIN form.goods g WHERE "+str+" "+
                     "GROUP BY b.name,g.name,g.spec,g.price,g.unit,g.producer";
        }
        System.out.println("****************:"+sql);
        session = MySession.openSession(); //打开Session
        System.out.println("SQL=" + sql);
        try {
            list = session.createQuery(sql).list();
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("查询时出现的错误信息:" + e.getMessage());
        } finally {
            MySession.closeSession(session); //关闭Session
        }
        return list;
    }
   // 查询部门汇总信息
        public List branchTotal(IfForm ifForm) {
            session = MySession.openSession(); //打开Session
            String str = ifCompose(ifForm);
            List list = null;
            String sql="select  g.name,g.spec,g.unit,g.price,t.branchname,t.lyamount,t.bsamount,(t.lyamount-t.bsamount) zyamount from tb_goods g inner join ( "+
                       "select goodsid,branchname,sum(bsamount) bsamount,sum(lyamount) lyamount from(" +
                       "select getuse.goodsid,0 as bsamount,sum(getuse.number) as lyamount,branch.name as branchname from tb_getuse getuse inner join  " +
                       " tb_branch branch on getuse.branchid=branch.id group by branch.name,getuse.goodsid " +
                       "union " +
                       "select damage.goodsid,sum(damage.damagenum) as bsamount,0 as lyamount,branch.name as branchname from tb_damage damage inner join  " +
                       " tb_branch branch on damage.branchid=branch.id group by branch.name,damage.goodsid " +
                       ") as t group by goodsid,branchname) as t on g.id=t.goodsid";

        if (str != null) {
            sql="select  g.name,g.spec,g.unit,g.price,t.branchname,t.lyamount,t.bsamount,(t.lyamount-t.bsamount) zyamount from tb_goods g inner join ( "+
              "select goodsid,branchname,sum(bsamount) bsamount,sum(lyamount) lyamount from(" +
               "select getuse.goodsid,0 as bsamount,sum(getuse.number) as lyamount,branch.name as branchname from tb_getuse getuse inner join  " +
               " tb_branch branch on getuse.branchid=branch.id and getuse."+str+"  group by branch.name,getuse.goodsid " +
               "union " +
               "select damage.goodsid,sum(damage.damagenum) as bsamount,0 as lyamount,branch.name as branchname from tb_damage damage inner join  " +
               " tb_branch branch on damage.branchid=branch.id and damage."+str+"  group by branch.name,damage.goodsid " +
               ") as t group by goodsid,branchname) as t on g.id=t.goodsid";
//            sql="select goods.name,goods.spec,goods.unit,goods.price,totle.branchname,totle.lyamount,totle.bsamount,totle.zyamount  from tb_goods goods inner join ( "+
//           " select ly.*, isnull(bsamount,0) as bsamount,(ly.lyamount-isnull(bsamount,0))as zyamount from (select getuse.goodsid,count(getuse.number)"+
//           "  as lyamount,branch.name as branchname from tb_getuse getuse"+
//           "  inner join  tb_branch branch on getuse.branchid=branch.id group by branch.name,getuse.goodsid) as ly left join "+
//           " (select damage.goodsid,count(damage.damagenum) as bsamount,branch.name as branchname from tb_damage damage inner join"+
//           "   tb_branch branch on damage.branchid=branch.id and damage."+str+" group by branch.name,damage.goodsid) as bs on ly.goodsid=bs.goodsid and ly.branchname=bs.branchname) as totle on goods.id=totle.goodsid";
}
        try {
        SQLQuery query = session.createSQLQuery(sql);
           list=query.list();
                 for(int i=0;i<list.size();i++){
                     System.out.println(list.get(i));

                 }
            } catch (Exception e) {
                e.printStackTrace();
                System.out.println("查询时出现的错误信息:" + e.getMessage());
            } finally {
                MySession.closeSession(session); //关闭Session
            }
            return list;
    }
//通用查询
    public List stockQuery(IfForm ifForm, String tablename, int state) {
        String str = ifCompose(ifForm);
        System.out.println("STR=" + str + "******************" + tablename);
        String hql = "";
        List list = null;
        if (str == null) {
            if (state == 3) { //state为3时代表查询全部数据
                hql = "From " + tablename + " order by createTime desc";
            } else {
                hql = "From " + tablename + " where state=" + state +
                      " order by createTime desc";
            }
        } else {
            hql = "From " + tablename + " WHERE " + str +
                  " order by createTime desc";
        }
        session = MySession.openSession(); //打开Session
        System.out.println("HQL=" + hql);
        try {
            Query query = session.createQuery(hql);
            list = query.list();
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("查询时出现的错误信息:" + e.getMessage());
        } finally {
            MySession.closeSession(session); //关闭Session
        }
        return list;
    }

    /***************************组合查询条件字符串的方法***************************************/
    //组合查询条件字符串的方法
    public String ifCompose(IfForm ifForm) {
        String str = null;
        String flag[] = ifForm.getFlag(); //定义一个字符型数组,获取表单中复选框提交的数据
        if (flag != null) {
            str = "";
            for (int i = 0; i < flag.length; i++) {
                str = str + oneIf(ifForm, flag[i]);
                if (i < flag.length - 1) {
                    str = str + " and ";
                }
            }
        }
        return str;
    }

    //根据传递的参数组合单个条件的方法
    public String oneIf(IfForm ifForm, String flagv) {
        String str = null;
        if ("a".equals(flagv)) { //按指定字段查询
            if (ifForm.getF() != null) {
                str = ifForm.getF() + " like '%" +
                      ifForm.getKey() + "%'"; //此处需要进行转码
            }
            System.out.println("按指定字段查询:" + str);
        }
        if ("b".equals(flagv)) { //按时间段查询
            String sdate = ifForm.getSdate();
            String edate = ifForm.getEdate();
            if (sdate != null && edate != null) {
                str = "createTime between '" + sdate + "' and '" + edate +
                      " 23:59:59'";
            }
            System.out.println("日期" + str);
        }
        if ("c".equals(flagv)) { //按状态查询
            int state = ifForm.getState();
            str = "state=" + state + "";
            System.out.println("状态:" + str);
        }
        return str;
    }
    /***************************************************************************/

}






本项目源码下载地址(点击进入)

再附一个myeclipse+jsp+servlet+mysql+tomcat环境的资产管理系统项目:
https://download.csdn.net/download/hgx378378/10809369

效果如图
企业固定资产管理系统(jsp+ssh框架+数据库SQL)_第13张图片

你可能感兴趣的:(java)