基于javaweb+mysql的jsp+servletcrm客户关系管理系统(java+layui+echarts+jsp+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的JSP+Servletcrm客户关系管理系统(java+layui+echarts+jsp+mysql)
功能介绍
该项目未使用spring框架,实现了用户登录,权限控制,数据统计,以及市场活动、线索、客户、联系人、交易管理的CRUD, 使用Proxy实现Service层的动态代理,实现DAO层事务控制,有助于深入理解web项目。管理员还包含系统设置:用户管理、角色管理、 权限管理;其中角色管理可以设置总经理、副总经理、销售经理、综合事务等角色的权限菜单。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 6.数据库:MySql 5.7版本;
技术栈
- 后端:Servlet+Mybatis 2. 前端:Layui+jquery+echarts+JSP
使用说明
- 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,下载所需jar包; 2. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 3. 将项目中db.properties配置文件中的数据库配置改为自己的配置 4. 配置tomcat,然后运行项目,输入localhost:8080/xxx 登录 5. 管理员账户: admin 密码:123456 普通员工账户:zs 密码:123
deleteClue(request,response);
} else if("/controller/deleteClues".equals(path)){
deleteClues(request,response);
} else if("/controller/convert".equals(path)){
convert(request,response);
}
}
private void convert(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("进入线索转换convert...");
clueService = (ClueService) ServiceFactory.getService(new ClueServiceImpl());
String clueId = request.getParameter("clueId");
String isCreateTran = request.getParameter("isCreateTran");
String createBy = ((User)request.getSession().getAttribute("user")).getName();
Tran tran = null;
if("yes".equals(isCreateTran)){
String id = IdUtil.simpleUUID();
String name = request.getParameter("name");
String money = request.getParameter("money");
String expectedDate = request.getParameter("expectedDate");
String stage = request.getParameter("stage");
String activityId = request.getParameter("activityId");
String createTime = DateUtil.now();
tran = new Tran();
tran.setId(id);
tran.setName(name);
tran.setMoney(money);
tran.setExpectedDate(expectedDate);
tran.setStage(stage);
tran.setActivityId(activityId);
tran.setCreateBy(createBy);
tran.setCreateTime(createTime);
}
boolean flag = clueService.convert(clueId,createBy,tran);
request.setAttribute("convertRes",flag);
request.getRequestDispatcher("/pages/clue.jsp").forward(request,response);
}
private void deleteClues(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入批量删除线索deleteClues...");
clueService = (ClueService) ServiceFactory.getService(new ClueServiceImpl());
String[] ids = request.getParameterValues("id");
boolean flag = clueService.deleteClues(ids);
response.getWriter().print(flag);
}
private void deleteClue(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入单条删除线索deleteClue...");
clueService = (ClueService) ServiceFactory.getService(new ClueServiceImpl());
customer.setOwner(owner);
customer.setName(name);
customer.setWebsite(website);
customer.setTel(tel);
customer.setNextContactDate(nextContactDate);
customer.setAddress(address);
customer.setDescription(description);
customer.setContactSummary(contactSummary);
customer.setCreateBy(createBy);
customer.setCreateTime(createTime);
customerService = (CustomerService) ServiceFactory.getService(new CustomerServiceImpl());
boolean flag = customerService.addCustomer(customer);
response.getWriter().print(flag);
}
private void getCustomer(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入查询客户getCustomer...");
String name = request.getParameter("name");
String owner = request.getParameter("owner");
int page = Integer.parseInt(request.getParameter("page"));
int limit = Integer.parseInt(request.getParameter("limit"));
int pageNumber = (page-1)*limit;
int pageSize = limit;
customerService = (CustomerService) ServiceFactory.getService(new CustomerServiceImpl());
Map<String,Object> param = new HashMap<>();
param.put("name",name);
param.put("owner",owner);
param.put("pageNumber",pageNumber);
param.put("pageSize",pageSize);
PageVO<Customer> vo = customerService.getCustomer(param);
Map<String,Object> map = new HashMap<>();
map.put("code",0);
map.put("message","请求成功");
map.put("count",vo.getTotal());
map.put("data",vo.getDatas());
JSONUtil.getJSON(response,map);
}
}
System.out.println("进入删除交易deleteTran...");
String id = request.getParameter("id");
tranService = (TranService) ServiceFactory.getService(new TranServiceImpl());
boolean flag = tranService.deleteTran(id);
response.getWriter().print(flag);
}
private void addTran(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入添加交易addTran...");
String id = IdUtil.simpleUUID();
String owner = request.getParameter("owner");
String money = request.getParameter("money");
String name = request.getParameter("name");
String expectedDate = request.getParameter("expectedDate");
String customer = request.getParameter("customer"); //Tran实体类中没有属性,继续传入service
String stage = request.getParameter("stage");
String type = request.getParameter("type");
String source = request.getParameter("source");
String activityId = request.getParameter("activityId");
String contactId = request.getParameter("contactId");
String createBy = ((User)request.getSession().getAttribute("user")).getName();
String createTime = DateUtil.now();
String description = request.getParameter("description");
String contactSummary = request.getParameter("contactSummary");
String nextContactDate = request.getParameter("nextContactDate");
Tran tran = new Tran();
tran.setId(id);
tran.setOwner(owner);
tran.setMoney(money);
tran.setName(name);
tran.setExpectedDate(expectedDate);
tran.setStage(stage);
tran.setType(type);
tran.setSource(source);
tran.setActivityId(activityId);
tran.setContactId(contactId);
tran.setNextContactDate(nextContactDate);
tran.setCreateBy(createBy);
tran.setCreateTime(createTime);
tran.setDescription(description);
tran.setContactSummary(contactSummary);
tranService = (TranService) ServiceFactory.getService(new TranServiceImpl());
boolean flag = tranService.addTran(tran,customer);
response.getWriter().print(flag);
Map<String,Object> map = new HashMap<>();
try {
User user = userService.login(username,password);
request.getSession().setAttribute("user",user);
map.put("success",true);
JSONUtil.getJSON(response,map);
} catch (Exception e) {
String msg = e.getMessage();
map.put("success",false);
map.put("msg",msg);
JSONUtil.getJSON(response,map);
}
}
}
public class ActivityController extends HttpServlet {
private ActivityService activityService = null;
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String path = request.getServletPath();
map.put("count",activityList.size());
map.put("data",activityList);
JSONUtil.getJSON(response,map);
}
private void getActivityByCid(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入getActivityByCid...");
activityService = (ActivityService) ServiceFactory.getService(new ActivityServiceImpl());
String clueId = request.getParameter("clueId");
List<Activity> activityList = activityService.getActivityByCid(clueId);
// Map<String,Object> map = new HashMap<>();
// map.put("code",0);
// map.put("message","请求成功");
// map.put("count",activityList.size());
// map.put("data",activityList);
JSONUtil.getJSON(response,activityList);
}
private void deleteActivities(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入deleteActivities");
activityService = (ActivityService) ServiceFactory.getService(new ActivityServiceImpl());
String[] ids = request.getParameterValues("id");
boolean flag = activityService.deleteActivities(ids);
response.getWriter().print(flag);
}
private void deleteActivity(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入deleteActivity");
activityService = (ActivityService) ServiceFactory.getService(new ActivityServiceImpl());
String id = request.getParameter("id");
int res = activityService.deleteActivity(id);
boolean flag = (res==1?true:false);
response.getWriter().print(flag);
}
private void updateActivity(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入updateActivity");
activityService = (ActivityService) ServiceFactory.getService(new ActivityServiceImpl());
String id = request.getParameter("id");
String owner = request.getParameter("owner");
String name = request.getParameter("name");
String startDate = request.getParameter("startDate");
String endDate = request.getParameter("endDate");
String cost = request.getParameter("cost");
String description = request.getParameter("description");
String editTime = DateUtil.now();
String url = request.getParameter("url");
String orderNo = request.getParameter("orderNo");
Permission permission = new Permission();
permission.setId(IdUtil.simpleUUID());
permission.setTitle(title);
permission.setUrl(url);
permission.setOrderNo(orderNo);
permission.setCreateTime(DateUtil.now());
permissionService = (PermissionService) ServiceFactory.getService(new PermissionServiceImpl());
Map<String,Object> map = permissionService.addPermission(permission);
if((boolean)map.get("success")){
updateApplication(request,response);
}
JSONUtil.getJSON(response,map);
}
private void getPermissionList(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入获取权限列表getPermissionList...");
String title = request.getParameter("title");
int page = Integer.parseInt(request.getParameter("page"));
int limit = Integer.parseInt(request.getParameter("limit"));
int pageNumber = (page-1)*limit;
int pageSize = limit;
Map<String,Object> param = new HashMap<>();
param.put("title",title);
param.put("pageNumber",pageNumber);
param.put("pageSize",pageSize);
permissionService = (PermissionService) ServiceFactory.getService(new PermissionServiceImpl());
PageVO<Permission> vo = permissionService.getPermissionList(param);
Map<String,Object> map = new HashMap<>();
map.put("code",0);
map.put("message","请求成功");
map.put("count",vo.getTotal());
map.put("data",vo.getDatas());
JSONUtil.getJSON(response,map);
}
//更新application中的缓存
private void updateApplication(HttpServletRequest request, HttpServletResponse response){
ServletContext application = request.getServletContext();
PermissionService permissionService = (PermissionService) ServiceFactory.getService(new PermissionServiceImpl());
List<Permission> permissionList = permissionService.getPermission();
application.setAttribute("permissions",permissionList);
System.out.println("进入解除线索和市场活动关系removeClueActivity...");
String id = request.getParameter("id");
clueService = (ClueService) ServiceFactory.getService(new ClueServiceImpl());
boolean flag = clueService.removeClueActivity(id);
response.getWriter().print(flag);
}
private void addClueActivity(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入添加线索和市场活动关系addClueActivity...");
String clueId = request.getParameter("cid");
String[] activityIds = request.getParameterValues("aid");
clueService = (ClueService) ServiceFactory.getService(new ClueServiceImpl());
boolean flag = clueService.addClueActivity(clueId,activityIds);
response.getWriter().print(flag);
}
private void clueDetail(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
System.out.println("进入查询线索详细信息detailClue...");
clueService = (ClueService) ServiceFactory.getService(new ClueServiceImpl());
String id = request.getParameter("id");
Clue clue = clueService.detailClue(id);
request.setAttribute("clue",clue);
request.getRequestDispatcher("/pages/clue-detail.jsp").forward(request,response);
}
private void addClue(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入addClue...");
clueService = (ClueService) ServiceFactory.getService(new ClueServiceImpl());
String id = IdUtil.simpleUUID();
String fullname = request.getParameter("fullname");
String appellation = request.getParameter("appellation");
String owner = request.getParameter("owner");
String company = request.getParameter("company");
String job = request.getParameter("job");
String email = request.getParameter("email");
String tel = request.getParameter("tel");
String website = request.getParameter("website");
String phone = request.getParameter("phone");
String state = request.getParameter("state");
String source = request.getParameter("source");
permission.setTitle(title);
permission.setUrl(url);
permission.setOrderNo(orderNo);
permission.setCreateTime(DateUtil.now());
permissionService = (PermissionService) ServiceFactory.getService(new PermissionServiceImpl());
Map<String,Object> map = permissionService.addPermission(permission);
if((boolean)map.get("success")){
updateApplication(request,response);
}
JSONUtil.getJSON(response,map);
}
private void getPermissionList(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入获取权限列表getPermissionList...");
String title = request.getParameter("title");
int page = Integer.parseInt(request.getParameter("page"));
int limit = Integer.parseInt(request.getParameter("limit"));
int pageNumber = (page-1)*limit;
int pageSize = limit;
Map<String,Object> param = new HashMap<>();
param.put("title",title);
param.put("pageNumber",pageNumber);
param.put("pageSize",pageSize);
permissionService = (PermissionService) ServiceFactory.getService(new PermissionServiceImpl());
PageVO<Permission> vo = permissionService.getPermissionList(param);
Map<String,Object> map = new HashMap<>();
map.put("code",0);
map.put("message","请求成功");
map.put("count",vo.getTotal());
map.put("data",vo.getDatas());
JSONUtil.getJSON(response,map);
}
//更新application中的缓存
private void updateApplication(HttpServletRequest request, HttpServletResponse response){
ServletContext application = request.getServletContext();
PermissionService permissionService = (PermissionService) ServiceFactory.getService(new PermissionServiceImpl());
List<Permission> permissionList = permissionService.getPermission();
application.setAttribute("permissions",permissionList);
}
}
changePwd(request,response);
}else if("/controller/addUser".equals(path)){
addUser(request,response);
}else if("/controller/getUserList".equals(path)){
getUserList(request,response);
}else if("/controller/deleteUsers".equals(path)){
deleteUsers(request,response);
}else if("/controller/getUserById".equals(path)){
getUserById(request,response);
}else if("/controller/updateUser2".equals(path)){
updateUser2(request,response);
}else if("/controller/resetPwd".equals(path)){
resetPwd(request,response);
}else if("/controller/welcome".equals(path)){
getDatas(request,response);
}
}
private void getDatas(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
System.out.println("进入首页获取数据getDatas...");
userService = (UserService) ServiceFactory.getService(new UserServiceImpl());
Map<String,Object> map = userService.getDatas();
request.setAttribute("activities",map.get("activities"));
request.setAttribute("clues",map.get("clues"));
request.setAttribute("trans",map.get("trans"));
request.setAttribute("owners",map.get("owners"));
request.setAttribute("volumes",map.get("volumes"));
request.getRequestDispatcher("/pages/welcome.jsp").forward(request,response);
}
private void resetPwd(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入重置密码resetPwd...");
String id = request.getParameter("id");
userService = (UserService) ServiceFactory.getService(new UserServiceImpl());
boolean flag = userService.resetPwd(id);
response.getWriter().print(flag);
}
private void updateUser2(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入修改用户详情updateUser2...");
String id = request.getParameter("id");
String name = request.getParameter("name");
String username = request.getParameter("username");
String isEnable =request.getParameter("isEnable");
String isAdmin =request.getParameter("isAdmin");
String[] roleIds = request.getParameterValues("roleIds");
String email =request.getParameter("email");
String remark =request.getParameter("remark");
User user = new User();
user.setId(id);
request.setAttribute("convertRes",flag);
request.getRequestDispatcher("/pages/clue.jsp").forward(request,response);
}
private void deleteClues(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入批量删除线索deleteClues...");
clueService = (ClueService) ServiceFactory.getService(new ClueServiceImpl());
String[] ids = request.getParameterValues("id");
boolean flag = clueService.deleteClues(ids);
response.getWriter().print(flag);
}
private void deleteClue(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入单条删除线索deleteClue...");
clueService = (ClueService) ServiceFactory.getService(new ClueServiceImpl());
String id = request.getParameter("id");
boolean flag = clueService.deleteClue(id);
response.getWriter().print(flag);
}
private void updateClue(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入线索修改updateClue...");
clueService = (ClueService) ServiceFactory.getService(new ClueServiceImpl());
String id = request.getParameter("id");
String fullname = request.getParameter("fullname");
String appellation = request.getParameter("appellation");
String owner = request.getParameter("owner");
String company = request.getParameter("company");
String job = request.getParameter("job");
String email = request.getParameter("email");
String tel = request.getParameter("tel");
String website = request.getParameter("website");
String phone = request.getParameter("phone");
String state = request.getParameter("state");
String source = request.getParameter("source");
String editBy = ((User)request.getSession().getAttribute("user")).getName();
String editTime = DateUtil.now();
String description = request.getParameter("description");
String contactSummary = request.getParameter("contactSummary");
String nextContactDate = request.getParameter("nextContactDate");
String address = request.getParameter("address");
Clue clue = new Clue();
clue.setId(id);
clue.setFullname(fullname);
clue.setAppellation(appellation);
clue.setOwner(owner);
}else if("/controller/updateCustomer".equals(path)){
updateCustomer(request,response);
}else if("/controller/deleteCustomer".equals(path)){
deleteCustomer(request,response);
}else if("/controller/deleteCustomers".equals(path)){
deleteCustomers(request,response);
}else if("/controller/getCustomerName".equals(path)){
getCustomerName(request,response);
}else if("/controller/getCustomerByName".equals(path)){
getCustomerByName(request,response);
}
}
private void getCustomerByName(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入获取客户名称getCustomerByName");
String name = request.getParameter("keywords");
List<Customer> customerList = null;
if(name!=null&&!"".equals(name)){
customerService = (CustomerService) ServiceFactory.getService(new CustomerServiceImpl());
customerList = customerService.getCustomerByName(name);
}
Map<String,Object> map = new HashMap<>();
map.put("code",0);
map.put("content",customerList);
map.put("type","success");
JSONUtil.getJSON(response,map);
}
private void getCustomerName(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入获取客户名称getCustomerName");
customerService = (CustomerService) ServiceFactory.getService(new CustomerServiceImpl());
List<Customer> customerList = customerService.getCustomerName();
JSONUtil.getJSON(response,customerList);
}
private void deleteCustomers(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入批量删除客户deleteCustomers...");
customerService = (CustomerService) ServiceFactory.getService(new CustomerServiceImpl());
String[] ids = request.getParameterValues("id");
Map<String,Object> map = customerService.deleteCustomers(ids);
JSONUtil.getJSON(response,map);
}
permission.setCreateTime(DateUtil.now());
permissionService = (PermissionService) ServiceFactory.getService(new PermissionServiceImpl());
Map<String,Object> map = permissionService.addPermission(permission);
if((boolean)map.get("success")){
updateApplication(request,response);
}
JSONUtil.getJSON(response,map);
}
private void getPermissionList(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入获取权限列表getPermissionList...");
String title = request.getParameter("title");
int page = Integer.parseInt(request.getParameter("page"));
int limit = Integer.parseInt(request.getParameter("limit"));
int pageNumber = (page-1)*limit;
int pageSize = limit;
Map<String,Object> param = new HashMap<>();
param.put("title",title);
param.put("pageNumber",pageNumber);
param.put("pageSize",pageSize);
permissionService = (PermissionService) ServiceFactory.getService(new PermissionServiceImpl());
PageVO<Permission> vo = permissionService.getPermissionList(param);
Map<String,Object> map = new HashMap<>();
map.put("code",0);
map.put("message","请求成功");
map.put("count",vo.getTotal());
map.put("data",vo.getDatas());
JSONUtil.getJSON(response,map);
}
//更新application中的缓存
private void updateApplication(HttpServletRequest request, HttpServletResponse response){
ServletContext application = request.getServletContext();
PermissionService permissionService = (PermissionService) ServiceFactory.getService(new PermissionServiceImpl());
List<Permission> permissionList = permissionService.getPermission();
application.setAttribute("permissions",permissionList);
}
}
public Log4JInitServlet() {
super();
}
public void init(ServletConfig config) throws ServletException {
System.out.println("正在初始化 log4j日志设置信息");
String log4jLocation = config.getInitParameter("log4j-properties-location");
ServletContext sc = config.getServletContext();
if (log4jLocation == null) {
System.err.println("没有找到log4j-properties-location, 所以使用 BasicConfigurator初始化");
BasicConfigurator.configure();
} else {
String webAppPath = sc.getRealPath("/");
String log4jProp = webAppPath + log4jLocation;
File yoMamaYesThisSaysYoMama = new File(log4jProp);
if (yoMamaYesThisSaysYoMama.exists()) {
System.out.println(log4jProp + "初始化日志设置信息");
PropertyConfigurator.configure(log4jProp);
} else {
System.err.println(log4jProp+ " 文件没有找到, 所以使用 BasicConfigurator初始化");
BasicConfigurator.configure();
}
}
super.init(config);
}
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
}
}
String appellation = request.getParameter("appellation");
String customerId = request.getParameter("customerId");
String job = request.getParameter("job");
String phone = request.getParameter("phone");
String email = request.getParameter("email");
String birth = request.getParameter("birth");
String source = request.getParameter("source");
String description = request.getParameter("description");
String contactSummary = request.getParameter("contactSummary");
String nextContactDate = request.getParameter("nextContactDate");
String address = request.getParameter("address");
String createBy = ((User)request.getSession().getAttribute("user")).getName();
String createTime = DateUtil.now();
Contacts contacts = new Contacts();
contacts.setId(id);
contacts.setFullname(fullname);
contacts.setAppellation(appellation);
contacts.setCustomerId(customerId);
contacts.setJob(job);
contacts.setPhone(phone);
contacts.setEmail(email);
contacts.setBirth(birth);
contacts.setSource(source);
contacts.setDescription(description);
contacts.setContactSummary(contactSummary);
contacts.setNextContactDate(nextContactDate);
contacts.setAddress(address);
contacts.setCreateBy(createBy);
contacts.setCreateTime(createTime);
contactsService = (ContactsService)ServiceFactory.getService(new ContactsServiceImpl());
boolean flag = contactsService.addContacts(contacts);
response.getWriter().print(flag);
}
private void getContacts(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入查询联系人getContacts...");
String fullname = request.getParameter("fullname");
String company = request.getParameter("company");
int page = Integer.parseInt(request.getParameter("page"));
int limit = Integer.parseInt(request.getParameter("limit"));
int pageNumber = (page-1)*limit;
int pageSize = limit;
Map<String,Object> param = new HashMap<>();
param.put("fullname",fullname);
param.put("company",company);
System.out.println("进入查询线索和用户getClueByIdAndUser...");
String id = request.getParameter("id");
clueService = (ClueService) ServiceFactory.getService(new ClueServiceImpl());
Map map = clueService.getClueByIdAndUser(id);
JSONUtil.getJSON(response, map);
}
private void removeClueActivity(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入解除线索和市场活动关系removeClueActivity...");
String id = request.getParameter("id");
clueService = (ClueService) ServiceFactory.getService(new ClueServiceImpl());
boolean flag = clueService.removeClueActivity(id);
response.getWriter().print(flag);
}
private void addClueActivity(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入添加线索和市场活动关系addClueActivity...");
String clueId = request.getParameter("cid");
String[] activityIds = request.getParameterValues("aid");
clueService = (ClueService) ServiceFactory.getService(new ClueServiceImpl());
boolean flag = clueService.addClueActivity(clueId,activityIds);
response.getWriter().print(flag);
}
private void clueDetail(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
System.out.println("进入查询线索详细信息detailClue...");
clueService = (ClueService) ServiceFactory.getService(new ClueServiceImpl());
String id = request.getParameter("id");
Clue clue = clueService.detailClue(id);
request.setAttribute("clue",clue);
request.getRequestDispatcher("/pages/clue-detail.jsp").forward(request,response);
}
private void addClue(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入addClue...");
clueService = (ClueService) ServiceFactory.getService(new ClueServiceImpl());
String id = IdUtil.simpleUUID();
String fullname = request.getParameter("fullname");
String appellation = request.getParameter("appellation");
String owner = request.getParameter("owner");
String company = request.getParameter("company");
String job = request.getParameter("job");
String email = request.getParameter("email");
customer.setNextContactDate(nextContactDate);
customer.setAddress(address);
customer.setDescription(description);
customer.setContactSummary(contactSummary);
customer.setCreateBy(createBy);
customer.setCreateTime(createTime);
customerService = (CustomerService) ServiceFactory.getService(new CustomerServiceImpl());
boolean flag = customerService.addCustomer(customer);
response.getWriter().print(flag);
}
private void getCustomer(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入查询客户getCustomer...");
String name = request.getParameter("name");
String owner = request.getParameter("owner");
int page = Integer.parseInt(request.getParameter("page"));
int limit = Integer.parseInt(request.getParameter("limit"));
int pageNumber = (page-1)*limit;
int pageSize = limit;
customerService = (CustomerService) ServiceFactory.getService(new CustomerServiceImpl());
Map<String,Object> param = new HashMap<>();
param.put("name",name);
param.put("owner",owner);
param.put("pageNumber",pageNumber);
param.put("pageSize",pageSize);
PageVO<Customer> vo = customerService.getCustomer(param);
Map<String,Object> map = new HashMap<>();
map.put("code",0);
map.put("message","请求成功");
map.put("count",vo.getTotal());
map.put("data",vo.getDatas());
JSONUtil.getJSON(response,map);
}
}
contacts.setDescription(description);
contacts.setContactSummary(contactSummary);
contacts.setNextContactDate(nextContactDate);
contacts.setAddress(address);
contacts.setCreateBy(createBy);
contacts.setCreateTime(createTime);
contactsService = (ContactsService)ServiceFactory.getService(new ContactsServiceImpl());
boolean flag = contactsService.addContacts(contacts);
response.getWriter().print(flag);
}
private void getContacts(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入查询联系人getContacts...");
String fullname = request.getParameter("fullname");
String company = request.getParameter("company");
int page = Integer.parseInt(request.getParameter("page"));
int limit = Integer.parseInt(request.getParameter("limit"));
int pageNumber = (page-1)*limit;
int pageSize = limit;
Map<String,Object> param = new HashMap<>();
param.put("fullname",fullname);
param.put("company",company);
param.put("pageNumber",pageNumber);
param.put("pageSize",pageSize);
contactsService = (ContactsService)ServiceFactory.getService(new ContactsServiceImpl());
PageVO<Contacts> vo = contactsService.getContacts(param);
Map<String,Object> map = new HashMap<>();
map.put("code",0);
map.put("message","请求成功");
map.put("count",vo.getTotal());
map.put("data",vo.getDatas());
JSONUtil.getJSON(response,map);
}
}
String stage = request.getParameter("stage");
String editBy = ((User)request.getSession().getAttribute("user")).getName();
String editTime = DateUtil.now();
Tran tran = new Tran();
tran.setId(id);;
tran.setMoney(money);
tran.setExpectedDate(expectedDate);
tran.setStage(stage);
tran.setEditBy(editBy);
tran.setEditTime(editTime);
Map<String,String> s2p = (Map<String,String>)request.getServletContext().getAttribute("s2p");
tran.setPossibility(s2p.get(stage));
tranService = (TranService) ServiceFactory.getService(new TranServiceImpl());
boolean flag = tranService.changeStage(tran);
Map<String,Object> map = new HashMap<>();
map.put("success",flag);
map.put("tran",tran);
JSONUtil.getJSON(response,map);
}
private void updateTran(HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("进入修改交易updateTran...");
String id = request.getParameter("id");
String owner = request.getParameter("owner");
String money = request.getParameter("money");
String name = request.getParameter("name");
String expectedDate = request.getParameter("expectedDate");
String stage = request.getParameter("stage");
String type = request.getParameter("type");
String source = request.getParameter("source");
String activityId = request.getParameter("activityId");
String contactId = request.getParameter("contactId");
String editBy = ((User)request.getSession().getAttribute("user")).getName();
String editTime = DateUtil.now();
String description = request.getParameter("description");
String contactSummary = request.getParameter("contactSummary");
String nextContactDate = request.getParameter("nextContactDate");
Tran tran = new Tran();
tran.setId(id);
tran.setOwner(owner);
tran.setMoney(money);
tran.setName(name);
tran.setExpectedDate(expectedDate);
tran.setStage(stage);
tran.setType(type);
tran.setSource(source);
tran.setActivityId(activityId);
tran.setContactId(contactId);
tran.setNextContactDate(nextContactDate);
tran.setEditBy(editBy);
tran.setEditTime(editTime);
tran.setDescription(description);
tran.setContactSummary(contactSummary);
tranService = (TranService) ServiceFactory.getService(new TranServiceImpl());