论基于Java的CRM客户关系管理系统的设计和实现java+jsp+mysql的实现

要对客户关系管理系统进行设计和实现,需要经过需求分析,数据库分析和设计,功能的详细实现,测试这几个步骤。

在需求分析阶段,给出了该系统的功能需求,有客户管理,产品管理和系统管理,并给出了相应的用例图,在总体层次图上能看出CRM的大概功能。在数据库的设计阶段上,根据逻辑E-R图和表的逻辑结构,设计出9张表,有部门表,职务表,岗位表,角色表,员工表,省市表,客户表,产品类别表,产品信息表。并给出建表语句。

1、下载并安装mysql,将脚本执行至数据库中;
2、配置java环境,使用jdk8,配置环境变量,下载IntelliJ IDEA 2019.2.4 或者 eclipse,该工具为java代码编译器
3、下载Maven,配置至环境变量,将构建器为Maven,类库配置成阿里库
4、将工程导入后,在application-local.yml文件中配置数据库
5、在logback-prod.xml文件中配置log日志
6、配置完毕后,即可启动

完成一个客户关系管理系统,主要是给广大用户和企业员工提供使用,该系统要实现的功能模块:
1.    登录管理模块:用户使用正确的账号和密码,登录到系统内部。
2.    客户管理模块:可以添加,修改,删除,查询客户信息,通过这个模块就可以录入客户的详细信息。
3.    产品管理模块:通过这个模块可以对企业的产品进行管理,增加,修改,删除,查询产品信息。正是因为这个模块,才可能为客户快速的推送服务。
4.    系统管理模块:系统管理模块的目的就是定义角色,不同的角色拥有不同的权限

 代码已经上传github,下载地址: https://github.com/21503882/client

 

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.crm.biz.HrEmployeeBiz;


import com.crm.biz.SysAppBiz;
import com.crm.biz.SysLoginBiz;
import com.crm.biz.SysMenuBiz;
import com.crm.info.HrEmployee;
import com.crm.info.SysLogin;
import com.crm.tools.Md5;
import com.crm.tools.Scopes;
import com.crm.tools.ValidateCode;
import com.crm.tools.WebTools;
import com.crm.vobj.SysMenuVobj;
import com.opensymphony.xwork2.ActionSupport;

@Scope("prototype")
@Controller("hrEmployeeAction")
public class HrEmployeeAction extends ActionSupport implements
        ServletResponseAware, ServletRequestAware {
    HttpServletResponse response;
    HttpServletRequest request;

    public void setServletResponse(HttpServletResponse arg0) {
        this.response = arg0;
    }

    public void setServletRequest(HttpServletRequest arg0) {
        this.request = arg0;
    }

    private HrEmployeeBiz hrEmployeeBiz;

    private SysAppBiz sysAppBiz;
    private SysMenuBiz sysMenuBiz;
    private SysLoginBiz sysLoginBiz;

    public void setSysLoginBiz(SysLoginBiz sysLoginBiz) {
        this.sysLoginBiz = sysLoginBiz;
    }

    public void setSysMenuBiz(SysMenuBiz sysMenuBiz) {
        this.sysMenuBiz = sysMenuBiz;
    }

    public void setHrEmployeeBiz(HrEmployeeBiz hrEmployeeBiz) {
        this.hrEmployeeBiz = hrEmployeeBiz;
    }

    public void setSysAppBiz(SysAppBiz sysAppBiz) {
        this.sysAppBiz = sysAppBiz;
    }

    /**
     * login.jsp页面的验证码生成
     */
    public void ajaxValidateCode() {
        response.setContentType("image/jpeg");// 设置相应类型,告诉浏览器输出的内容为图片
        response.setHeader("Pragma", "No-cache");// 设置响应头信息,告诉浏览器不要缓存此内容
        response.setHeader("Cache-Control", "no-cache");
        response.setDateHeader("Expire", 0);
        ValidateCode randomValidateCode = new ValidateCode();
        try {
            ValidateCode.code = randomValidateCode.getRandcode(request,
                    response);// 输出图片方法
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    
    private File headfile;
    public File getHeadfile() {
        return headfile;
    }
    public void setHeadfile(File headfile) {
        this.headfile = headfile;
    }
    private String headfileFileName,headfileContentType;
    public String getHeadfileFileName() {
        HrEmployee emp=((HrEmployee)Scopes.getSessionMap().get("emp"));
        return emp.getUid()+""+headfileFileName;
    }
    public void setHeadfileFileName(String headfileFileName) {
        this.headfileFileName = headfileFileName.substring(headfileFileName.lastIndexOf('.'));
    }
    public String getHeadfileContentType() {
        return headfileContentType;
    }
    public void setHeadfileContentType(String headfileContentType) {
        this.headfileContentType = headfileContentType;
    }

    public String uploadHead(){
        try{
            String path=ServletActionContext.getServletContext().getRealPath("/img/upfile");
            byte[] buff = new byte[1024];
            FileInputStream fis = new FileInputStream(getHeadfile());
            FileOutputStream fos = new FileOutputStream(path+"\\"+getHeadfileFileName());
            int length=fis.read(buff);
            while(length>0){
                fos.write(buff,0,length);
                length=fis.read(buff);
            }
            fis.close();
            fos.flush();
            fos.close();
            HrEmployee newemp = hrEmployeeBiz.updateHead(getHeadfileFileName());
            Scopes.getSessionMap().put("emp", newemp);
        }catch (Exception e) {
            e.printStackTrace();
        }
        return "uphead";
    }
    HrEmployee employee;
    public HrEmployee getEmployee() {
        return employee;
    }
    public void setEmployee(HrEmployee employee) {
        this.employee = employee;
    }
    
    public String empUpdate(){
        HrEmployee loyee = hrEmployeeBiz.empUpdate(employee);
        Scopes.getSessionMap().put("emp", loyee);
        return "uphead";
    }
    private String newpwd;

    public void setNewpwd(String newpwd) {
        this.newpwd = newpwd;
    }

    public String empUpdatePwd(){
        HrEmployee loyee=hrEmployeeBiz.updatePwd(newpwd);
        Scopes.getSessionMap().put("emp", loyee);
        return "uphead";
    }
    public String ajaxValidatePwd(){
        HrEmployee emp=((HrEmployee)Scopes.getSessionMap().get("emp"));
        String data="";
        if (emp.getPwd().equals(pwd)) {
            data="1";
        }else{
            data="0";
        }
        Scopes.getRequestMap().put("data", data);
        return "ajax";
    }
    
    private String theme;
    public void setTheme(String theme) {
        this.theme = theme;
    }
    public String changeTheme(){
        HrEmployee loyee = hrEmployeeBiz.updateTheme(theme);
        Scopes.getSessionMap().put("emp", loyee);
        return "ajax";
    }

    private String name, pwd, inpcode;

    // 登录名接收
    public void setName(String name) {
        this.name = name.trim();
    }

    // 登录密码接收
    public void setPwd(String pwd) {
        if (!pwd.trim().equals("")) {
            this.pwd = Md5.MD5(pwd.trim());
        } else {
            this.pwd = pwd.trim();
        }
    }

    // 登录验证码接收
    public void setInpcode(String inpcode) {
        this.inpcode = inpcode.trim();
    }

    /**
     * 登录方法 登录成功的用户 Session 的key = 'emp'
     * 
     * @return
     */
    public String login() {
        if (inpcode.equalsIgnoreCase(ValidateCode.code)) {
            // 登录
            HrEmployee employee = hrEmployeeBiz.login(name, pwd);
            if (employee != null) {
                if (employee.getCanlogin() == 1) {
                    Scopes.getSessionMap().put("emp", employee);
                    List<SysMenuVobj> menuVobjs = sysMenuBiz.findShowMenusByRole(employee.getSysRole());
                    Scopes.getSessionMap().put("menus", menuVobjs);
                    sysLoginBiz.add(new SysLogin());
                    return "login";
                } else {
                    Scopes.getRequestMap().put("err", "您没有权限登录,请联系管理员");
                    // 您没有权限登录
                    return "loginerr";
                }
            } else {
                Scopes.getRequestMap().put("err", "您输入账号或密码错误");
                // 账户密码错误
                return "loginerr";
            }
        } else {
            Scopes.getRequestMap().put("err", "您输入验证码错误");
            // 验证码错误
            return "loginerr";
        }
    }
    public String loginOut(){
        Scopes.getSessionMap().remove("emp");
        Scopes.getSessionMap().remove("menus");
        return "loginerr";
    }
    
    public String execute(){
        List<HrEmployee> employees = hrEmployeeBiz.findAllEmps();
        Scopes.getRequestMap().put("emps", employees);
        return "show";
    }
    private int id;

    public void setId(int id) {
        this.id = id;
    }

    public String findOne(){
        HrEmployee employee=hrEmployeeBiz.findOne(id);
        Scopes.getRequestMap().put("emp", employee);
        return "findone";
    }
    public String deleteById(){
        hrEmployeeBiz.deleteFlase(id);
        return "deletefalse";
    }
    private HrEmployee emp;
    public HrEmployee getEmp() {
        return emp;
    }

    public void setEmp(HrEmployee emp) {
        this.emp = emp;
    }

    public String update(){
        hrEmployeeBiz.update(emp);
        return "update";
    }
    
    public String add(){
        hrEmployeeBiz.add(emp);
        return "add";
    }

    private int depid;

    public void setDepid(int depid) {
        this.depid = depid;
    }
    
    public String ajaxGetEmpsByDepId() {
        List<HrEmployee> employees = hrEmployeeBiz.findEmpsByDepId(depid);
        WebTools.jsonClearEmps(employees);
        String data = WebTools.convertJson(employees);
        Scopes.getRequestMap().put("data", data);
        return "ajax";
    }
    public String ajaxGetEmps(){
        List<HrEmployee> employees = hrEmployeeBiz.findAllEmps();
        HrEmployee employee=(HrEmployee)Scopes.getSessionMap().get("emp");
        for (int i = 0; i < employees.size(); i++) {
            if (employees.get(i).getId().equals(employee.getId())) {
                employees.remove(employees.get(i));
            }
        }
        System.out.println(employees.size());
        WebTools.jsonClearEmps(employees);
        String data = WebTools.convertJson(employees);
        Scopes.getRequestMap().put("data", data);
        return "ajax";
    }
    
    public String trashAll(){
        Scopes.getRequestMap().put("emps", hrEmployeeBiz.findTrashAll());
        return "trash";
    }
    
    public String trashDel(){
        hrEmployeeBiz.deleteById(id);
        return trashAll();
    }
    
    public String trashAdd(){
        hrEmployeeBiz.doTrashAdd(id);
        return trashAll();
    }
}

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<!DOCTYPE html>

<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->

<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->

<!--[if !IE]><!-->
<html lang="cn">
<!--<![endif]-->

<!-- BEGIN HEAD -->

<head>

<meta charset="utf-8" />

<title>index.jsp</title>

<meta content="width=device-width, initial-scale=1.0" name="viewport" />

<meta content="" name="description" />

<meta content="" name="author" />

<jsp:include page="media/ui_css.jsp"></jsp:include>

<link rel="shortcut icon" href="media/image/favicon.ico" />
<script type="text/javascript">
    function showtime() {
        var today, hour, second, minute, year, month, date;
        var strDate;
        today = new Date();
        var n_day = today.getDay();
        switch (n_day) {
        case 0:
            strDate = "星期日";
            break;
        case 1:
            strDate = "星期一";
            break;
        case 2:
            strDate = "星期二";
            break;
        case 3:
            strDate = "星期三";
            break;
        case 4:
            strDate = "星期四";
            break;
        case 5:
            strDate = "星期五";
            break;
        case 6:
            strDate = "星期六";
            break;
        case 7:
            strDate = "星期日";
            break;
        }
        year = today.getFullYear();
        month = today.getMonth() + 1;
        date = today.getDate();
        hour = today.getHours();
        minute = today.getMinutes();
        second = today.getSeconds();
        if (month < 10)
            month = "0" + month;
        if (date < 10)
            date = "0" + date;
        if (hour < 10)
            hour = "0" + hour;
        if (minute < 10)
            minute = "0" + minute;
        if (second < 10)
            second = "0" + second;
        document.getElementById('time').innerHTML = year + " 年 " + month
                + " 月 " + date + " 日 " + strDate + " " + hour + ":" + minute
                + ":" + second; //显示时间 
        setTimeout("showtime();", 1000); //设定函数自动执行时间为 1000 ms(1 s) 
    }
</script>
</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<body class="page-header-fixed">
    <jsp:include page="main_pages/top.jsp"></jsp:include>
    <!-- BEGIN 容器 -->
    <div class="page-container row-fluid">
        <jsp:include page="main_pages/left.jsp"></jsp:include>
        <!-- BEGIN 开始页面 -->
        <div class="page-content">
            <!-- ---------------------------------------------- -->
            <!-- BEGIN 页面容器-->
            <div class="container-fluid">
                <!-- BEGIN 页面标题-->
                <div class="row-fluid">
                    <div class="span12">
                        <!-- BEGIN 风格定制 -->
                        <jsp:include page="/main_pages/styleset.jsp"></jsp:include>
                        <!-- END 风格定制 --> 
                        <!-- BEGIN 网页的标题和面包屑-->
                        <h3 class="page-title">
                            我的桌面 <small>我的办公信息导航页</small>
                        </h3>
                        <ul class="breadcrumb">
                            <li>
                                <i class="icon-home"></i>
                                <a href="#">我的桌面</a> 
                                <i class="icon-angle-right"></i>
                            </li>
                        </ul>
                        <!-- END 网页的标题和面包屑-->
                    </div>
                </div>
                <!-- END 页面标题-->
                <!-- BEGIN 网页内容-->
                <div class="tiles">
                    <div class="tile double-down bg-blue">
                        <div class="tile-body"><i class="icon-bell"></i></div>
                        <div class="tile-object">
                            <div class="name">我的便签</div>
                            <div class="number">6</div>
                        </div>
                    </div>
                    <div class="tile bg-green">
                        <div class="tile-body"><i class="icon-calendar"></i></div>
                        <div class="tile-object">
                            <div class="name">我的日程</div>
                            <div class="number">12</div>
                        </div>
                    </div>
                    <div class="tile double bg-blue">
                        <div class="corner"></div>
                        <div class="check"></div>
                        <div class="tile-body">
                            <h4>support@metronic.com</h4>
                            <p>Re:  Project Update!</p>
                            <p>24 may 2017 12.30PM  the project plan update meeting...</p>
                        </div>
                        <div class="tile-object">
                            <div class="name"> <i class="icon-envelope"></i> </div>
                            <div class="number"> 14 </div> 
                        </div>
                    </div>
                    <div class="tile bg-red">
                        <div class="corner"></div>
                        <div class="tile-body">
                            <i class="icon-user"></i>
                        </div>
                        <div class="tile-object">
                            <div class="name">我的联系人</div>
                            <div class="number">452</div>
                        </div>
                    </div>
                    <div class="tile double bg-purple">
                        <div class="corner"></div>
                        <div class="tile-body">
                            <i class="icon-folder-close"></i>
                        </div>
                        <div class="tile-object">
                            <div class="name">我的合同</div>
                            <div class="number">43</div>
                        </div>
                    </div>
                    <div class="tile bg-yellow">
                        <div class="tile-body"><i class="icon-user-md"></i></div>
                        <div class="tile-object">
                            <div class="name">我的客户</div>
                            <div class="number">121</div>
                        </div>
                    </div>
                    <div class="tile image">
                        <div class="tile-body">
                            <img src="media/image/image2.jpg" alt="">
                        </div>
                        <div class="tile-object">
                            <div class="name">我的跟进</div>
                            <div class="number">12</div>
                        </div>
                    </div>
                    <div class="tile bg-green">
                        <div class="tile-body">
                            <i class="icon-comments-alt"></i>
                        </div>
                        <div class="tile-object">
                            <div class="name">我签名的发票</div>
                            <div class="number">12
                            </div>
                        </div>
                    </div>
                    <div class="tile double bg-grey">
                        <div class="tile-body">
                            <img src="media/image/photo2.jpg" alt="" class="pull-right" style="height:114px;width: 258px;">
                        </div>
                        <div class="tile-object">
                            <div class="name">
                                <i class="icon-twitter"></i>
                            </div>
                            <div class="number"><span id="time"></span></div>
                        </div>
                    </div>
                    <div class="tile bg-blue">
                        <div class="tile-body">
                            <i class="icon-edit"></i>
                        </div>
                        <div class="tile-object">
                            <div class="name">我的订单</div>
                            <div class="number">12</div>
                        </div>
                    </div>
                    <div class="tile bg-green">
                        <div class="tile-body">
                            <i class="icon-bar-chart"></i>
                        </div>
                        <div class="tile-object">
                            <div class="name">我的收款</div>
                            <div class="number">3</div>
                        </div>
                    </div>
                    <div class="tile bg-purple" url="pages_public/public_new.jsp">
                        <div class="tile-body">
                            <i class="icon-briefcase"></i>
                        </div>
                        <div class="tile-object">
                            <div class="name">公司新闻</div>
                            <div class="number">11</div>
                        </div>
                    </div>
                    <div class="tile image double">
                        <div class="tile-body">
                            <img src="media/image/image4.jpg" alt="">
                        </div>
                        <div class="tile-object">
                            <div class="name">公司聊天室</div>
                            <div class="number">222</div>
                        </div>
                    </div>
                    <div class="tile bg-purple">
                        <div class="tile-body"><i class="icon-plane"></i></div>
                        <div class="tile-object">
                            <div class="name">公司公告</div>
                            <div class="number">34</div>
                        </div>
                    </div>
                    <div class="tile bg-yellow">
                        <div class="corner"></div>
                        <div class="check"></div>
                        <div class="tile-body">
                            <i class="icon-cogs"></i>
                        </div>
                        <div class="tile-object">
                            <div class="name">我的设置</div>
                        </div>
                    </div>
                    <div class="tile bg-red">
                        <div class="corner"></div>
                        <div class="check"></div>
                        <div class="tile-body">
                            <i class="icon-lock"></i>
                        </div>
                        <div class="tile-object">
                            <div class="name">锁屏</div>
                        </div>
                    </div>
                </div>
                <br>
                <!-- END 网页内容-->
            </div>
            <!-- END 页面容器-->
            <!-- --------------------------------------------------------- -->
        </div>
        <!-- END 页面 -->
    </div>
    <!-- END 容器 -->
    <jsp:include page="main_pages/foot.jsp"></jsp:include>
    <jsp:include page="media/ui_js.jsp"></jsp:include>
    <script src="media/js/app.js"></script>
    <script>
        jQuery(document).ready(function() {
            App.init();
            showtime();
            $('.tile').click(function(){
                var url=$(this).attr('url');
                location.href=url;
            });
        });
    </script>
    <!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>

  • 0
    点赞
  • 0
    评论
  • 5
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

©️2021 CSDN 皮肤主题: 游动-白 设计师:白松林 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值