java

关注公众号 jb51net

关闭
首页 > 软件编程 > java > Java CRM客户管理系统

Java 实战项目之CRM客户管理系统的实现流程

作者:qq_1334611189

读万卷书不如行万里路,只学书上的理论是远远不够的,只有在实战中才能获得能力的提升,本篇文章手把手带你用java+SSM+jsp+mysql+maven实现一个CRM客户管理系统,大家可以在过程中查缺补漏,提升水平

一、项目简述

功能包括: 用户管理,系统管理,客户管理,客户服务,客户关怀, 销售机会,统计管理等等。

二、项目运行

环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)

项目技术: JSP +Spring + SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等。

员工操作:

/**
 * @author 员工操作
 */
@RestController
@RequestMapping("/employee")
@CrossOrigin
@Slf4j
public class EmployeeController {
    @Autowired
    private EmployeeService employeeService;
    @Autowired
    private DepartmentService departmentService;
    @Autowired
    private JobService jobService;
    @Autowired
    private EduLevelMapper eduLevelMapper;
    @Autowired
    private EmployeeMapper employeeMapper;
    /**
     * 搜索接口
     */
    @GetMapping("/search")
    public Result search(@RequestParam(name = "name", required = false,defaultValue = "") String name,
                         @RequestParam(name = "current", required = false, defaultValue = "1") Integer current,
                         @RequestParam(name = "size", required = false, defaultValue = "10") Integer size) {
        return employeeService.list(current, size, name);
    }
 
    /**
     * 分页查询接口
     *
     * @param current
     * @param size
     * @return
     */
    @GetMapping("/list")
    public Result list(@RequestParam(name = "current", required = false, defaultValue = "1") Integer current,
                       @RequestParam(name = "size", required = false, defaultValue = "10") Integer size) {
        return employeeService.list(current, size, null);
    }
 
    /**
     * 根据id获取员工具体信息
     * @param id
     * @return
     */
    @GetMapping("/getUserById")
    public EmployeeDTO getUserAllInfoById(@RequestParam(name = "id") Integer id) {
        return employeeService.getUserById(id);
    }
 
    /**
     * 根据员工获取信息
     * @param id
     * @return
     */
    @GetMapping("/getEmployeeById")
    public Employee getUserById(@RequestParam(name = "id") Integer id) {
        return employeeMapper.selectById(id);
    }
    /**
     * 增加员工接口
     *
     * @param employee
     * @return
     */
    @PostMapping("/add")
    public Map<String, Object> addUser(@RequestBody Employee employee) {
        log.info(employee.toString());
        return employeeService.add(employee);
    }
 
    /**
     * 更新用户
     * @param employee
     * @return
     */
    @PostMapping("/update")
    public Map<String, Object> updateUser(@RequestBody Employee employee) {
        log.info(employee.toString());
        return employeeService.update(employee);
    }
 
    /**
     * 删除用户
     * @param id
     * @return
     */
    @GetMapping("/delete")
    public Result deleteEmployeeById(@RequestParam(name = "id") Integer id) {
        return employeeService.deleteEmployeeById(id);
    }
 
    /**
     * 辞退员工
     *
     * @param id
     * @return
     */
    @GetMapping("/dismiss")
    public Map<String, Object> dismissEmployeeById(@RequestParam(name = "id") Integer id) {
        return employeeService.dismissEmployeeById(id);
    }
 
    /**
     * 得到所以工作,部门,学历信息
     *
     * @return
     */
    @GetMapping("/otherInfo")
    public Result getAllOtherInfo() {
        Map<String, Object> info = new HashMap<>();
        info.put("departments", departmentService.selectAll());
        info.put("jobs", jobService.selectAll());
        info.put("eduLevels", eduLevelMapper.selectList(null));
        return Result.success(info);
    }
 
    @GetMapping("/map")
    public Result getMap() {
        return employeeService.getMap();
    }
}

人事管理相关接口:

/**
 * 人事管理相关接口
 */
@RestController
@CrossOrigin
@RequestMapping("/personnel")
public class PersonnelController {
    @Autowired
    private PersonnelService personnelService;
 
    /**
     * 所以人事记录接口
     * @param current
     * @param size
     * @return
     */
    @GetMapping("/list")
    public Result list(@RequestParam(name = "current", required = false, defaultValue = "1") Integer current,
                       @RequestParam(name = "size", required = false, defaultValue = "10") Integer size) {
        return personnelService.list(current, size);
    }
 
 
}

服务端:

/**
 * websocket 服务端
 * 注意: websocket 不能被代理,还有下面几个注解修饰的方法必须是public的
 */
 
@Component
@ServerEndpoint("/websocket/login")
@Slf4j
public class WebSocketServer {
//    static Log log = LogFactory.get(WebSocketServer.class);
    /**
     * 记录连接数量
     */
    private static int onlineCount = 0;
    /**
     * juc中的线程安全容器
     */
    private static CopyOnWriteArraySet<WebSocketServer> webSocketSet = new CopyOnWriteArraySet<>();
    /**
     * 存放websocket 中的会话
     */
    private Session session;
 
    /**
     * 连接建立成功调用的方法
     */
    @OnOpen
    public void onOpen(Session session) {
        this.session = session;
        webSocketSet.add(this);
        addOnlineCount();
        log.info("新增一个websocket连接,现在连接数" + getOnlineCount());
    }
 
    /**
     * websocket 连接断开调用的方法
     */
    @OnClose
    public void onClose() {
        webSocketSet.remove(this);
        subOnlineCount();
        log.info("断开websocket一个连接,现在连接数:" + getOnlineCount());
    }
 
    /**
     * 收到消息调用此方法
     *
     * @param message
     * @param session
     */
    @OnMessage
    public void onMessage(String message, Session session) {
        log.info("websocket 收到消息了: " + message);
        try {
            sendInfo("hello, too!!!", "text");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
 
    /**
     * 发生错误调用的方法
     *
     * @param session
     * @param throwable
     */
    @OnError
    public void onError(Session session, Throwable throwable) {
        log.error("发送错误,  ");
        throwable.printStackTrace();
    }
 
    /**
     * 实现主动推送消息到客户端
     */
    public void sendMessage(String message) throws IOException {
        if (session != null) {
            this.session.getBasicRemote().sendText(message);
        } else {
            log.info("session为空");
        }
    }
 
    public static void sendInfo(Object message, String type) throws IOException {
        log.info("推送消息到窗口,推送内容:" + message);
        Map<String, Object> resultMap = new HashMap<>();
        resultMap.put("type", type);
        resultMap.put("message", message);
        JSONObject jsonObject = JSONUtil.parseObj(resultMap);
        for (WebSocketServer item : webSocketSet) {
            try {
                //这里可以设定只推送给这个sid的,为null则全部推送
                item.sendMessage(jsonObject.toString());
            } catch (IOException e) {
                continue;
            }
        }
    }
 
    public static synchronized int getOnlineCount() {
        return onlineCount;
    }
 
    public static synchronized void addOnlineCount() {
        WebSocketServer.onlineCount++;
    }
 
    public static synchronized void subOnlineCount() {
        WebSocketServer.onlineCount--;
    }
}

以上就是Java 实战项目之CRM客户管理系统的实现流程的详细内容,更多关于Java CRM客户管理系统的资料请关注脚本之家其它相关文章!

您可能感兴趣的文章:
阅读全文