如今,许多高校还在使用着传统的手写填单方式来进行报修。但是随着时代的进步,这种传统方式已经不够便利,并且因时间和地点等因素而充满了局限性。如果学生们可以直接在手机上进行报修,将会使整个报修流程更加高效、迅速,所以开发一款移动端的报修系统非常有必要。
本系统采用微信开发者工具作为程序前端开发工具,采用Java语言编写程序后端代码、IDEA或eclipse作为后端开发工具,使用MySQL作为数据库。因为小程序可以直接在微信上打开,具有便捷高效的特性,十分适合本系统,所以本系统是基于微信小程序来完成的。为了完成该系统,通过系统构思、系统分析与设计、数据库设计这几个过程,并对系统开发过程进行总结,最终实现了学生、维修人员通过微信小程序进行报修、接单的功能。
关键词:电器报修 ?Java技术 ?微信小程序 ?MySQL数据库
【598】基于ssm高校学生电器报修系统微信小程序源码和论文
Abstract
Nowadays, many colleges and universities are still using traditional hand-written forms to report for repairs. However, with the progress of the times, this traditional method is not convenient enough, and is full of limitations due to factors such as time and place. If the students can repair directly on the mobile phone, it will make the entire repair process more efficient and rapid, so it is necessary to develop a mobile repair system.
This system uses WeChat developer tools as the program front-end development tool, Java language to write the program back-end code, MyEclipse as the back-end development tool, and MySQL as the database. Because the applet can be opened directly on WeChat, with convenient and efficient features, it is very suitable for this system, so this system is based on the WeChat?Applet. In order to complete the system, through the process of system conception, system analysis and design, database design, and summarize the system development process, the function of students and maintenance personnel through the WeChat Applet to repair and order is finally achieved.
Keywords: Appliance Repair ?Java Technology ?WeChat Applet ?MySQL Database
package com.controller;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.model.Userinfo;
import com.model.Wxuser;
import com.model.Xminfo;
import com.model.Zhaopin;
import com.response.LoginResponse;
import com.response.Response;
import com.response.UinfoResponse;
import com.response.WxuserListResponse;
import com.response.WxuserResponse;
import com.response.XminfoListResponse;
import com.response.ZhaopinListResponse;
import com.response.ZhaopinResponse;
import com.service.UserinfoService;
import com.service.WxuserService;
import com.service.XminfoService;
import com.service.ZhaopinService;
@Controller
@RequestMapping(value = "/rest")
public class RestApiController {
@Autowired
private UserinfoService userinfoService;
@Autowired
private WxuserService wxuserService;
@Autowired
private ZhaopinService zhaopinService;
@Autowired
private XminfoService xminfoService;
/**
* 用户注册
*
* @param user
* @return
*/
@RequestMapping(value = "/register", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
@ResponseBody
public Response register(HttpServletRequest req, Userinfo user) {
Response sres = new Response();
try {
Userinfo uinfo = new Userinfo();
uinfo.setTel(user.getTel());
List<Userinfo> ulist = userinfoService.queryUserinfoList(uinfo,
null);
if (ulist == null || ulist.size() == 0) {
userinfoService.insertUserinfo(user);
sres.setCode(200);
} else {
sres.setCode(201); // 手机号已存在
}
} catch (Exception e) {
sres.setCode(500);
e.printStackTrace();
}
return sres;
}
/**
* 用户登录
*
* @param user
* @return
*/
@RequestMapping(value = "/ulogin")
@ResponseBody
public LoginResponse ulogin(HttpServletRequest req, Userinfo user) {
LoginResponse sres = new LoginResponse();
try {
int uid = 0;
List<Userinfo> ulist = userinfoService
.queryUserinfoList(user, null);
if (ulist != null && ulist.size() > 0) {
uid = ulist.get(0).getId();
sres.setCode(200);
sres.setOpenid(uid + "");
sres.setName(ulist.get(0).getName());
sres.setTel(ulist.get(0).getTel());
sres.setUtype(ulist.get(0).getUtype());
sres.setAddress(ulist.get(0).getAddress());
} else {
sres.setCode(201);
}
} catch (Exception e) {
sres.setCode(500);
e.printStackTrace();
}
return sres;
}
/**
* 用户资料
*
* @param user
* @return
*/
@RequestMapping(value = "/uinfo")
@ResponseBody
public UinfoResponse uinfo(HttpServletRequest req) {
UinfoResponse sres = new UinfoResponse();
int uid = Integer.parseInt(req.getParameter("uid"));
try {
Userinfo uinfo = userinfoService.queryUserinfoById(uid);
sres.setUinfo(uinfo);
sres.setCode(200);
} catch (Exception e) {
sres.setCode(500);
e.printStackTrace();
}
return sres;
}
/**
* 修改个人资料
*
* @param user
* @return
*/
@RequestMapping(value = "/updateuser")
@ResponseBody
public Response updateuser(HttpServletRequest req, Userinfo userinfo) {
Response sres = new Response();
try {
userinfoService.updateUserinfo(userinfo);
sres.setCode(200);
} catch (Exception e) {
sres.setCode(500);
e.printStackTrace();
}
return sres;
}
/**
* 维修人员信息列表
*
* @param req
* @return
*/
@RequestMapping(value = "/tlist")
@ResponseBody
public WxuserListResponse tlist(HttpServletRequest req) {
WxuserListResponse sres = new WxuserListResponse();
try {
String keywords = req.getParameter("keywords");
Wxuser teainfo = new Wxuser();
teainfo.setState("通过");
teainfo.setKeywords(keywords);
List<Wxuser> dlist = wxuserService.queryWxuserList(teainfo, null);
sres.setCode(200);
sres.setDlist(dlist);
} catch (Exception e) {
sres.setCode(500);
e.printStackTrace();
}
return sres;
}
/**
* 维修项目列表
*
* @param req
* @return
*/
@RequestMapping(value = "/xmlist")
@ResponseBody
public XminfoListResponse xmlist(HttpServletRequest req) {
XminfoListResponse sres = new XminfoListResponse();
try {
List<Xminfo> dlist = xminfoService.queryXminfoList(new Xminfo(), null);
sres.setCode(200);
sres.setDlist(dlist);
} catch (Exception e) {
sres.setCode(500);
e.printStackTrace();
}
return sres;
}
/**
* 自己查看维修人员信息详情
*
* @param req
* @return
*/
@RequestMapping(value = "/tinfoView")
@ResponseBody
public WxuserResponse tinfoView(HttpServletRequest req) {
WxuserResponse sres = new WxuserResponse();
try {
Wxuser teainfo = null;
int uid = Integer.parseInt(req.getParameter("uid") == null ? "0"
: req.getParameter("uid"));
Wxuser tinfo = new Wxuser();
tinfo.setUid(uid);
List<Wxuser> tlist = wxuserService.queryWxuserList(tinfo, null);
if (tlist != null && tlist.size() > 0) {
teainfo = tlist.get(0);
}
sres.setCode(200);
sres.setDinfo(teainfo);
} catch (Exception e) {
sres.setCode(500);
e.printStackTrace();
}
return sres;
}
/**
* 修改维修人员信息
*
* @param req
* @return
*/
@RequestMapping(value = "/updateTinfo")
@ResponseBody
public Response updateTinfo(HttpServletRequest req, Wxuser wxuser) {
Response sres = new Response();
try {
if (wxuser.getId() != null) {
wxuserService.updateWxuser(wxuser);
} else {
wxuser.setState("待审核");
wxuserService.insertWxuser(wxuser);
}
sres.setCode(200);
} catch (Exception e) {
sres.setCode(500);
e.printStackTrace();
}
return sres;
}
/**
* 报修单列表 任务大厅
*
* @param req
* @return
*/
@RequestMapping(value = "/zplist")
@ResponseBody
public ZhaopinListResponse zplist(HttpServletRequest req) {
ZhaopinListResponse sres = new ZhaopinListResponse();
try {
Zhaopin zinfo = new Zhaopin();
zinfo.setState("待接单");
String keywords = req.getParameter("keywords");
zinfo.setKeywords(keywords);
List<Zhaopin> dlist = zhaopinService.queryZhaopinList(zinfo, null);
sres.setCode(200);
sres.setDlist(dlist);
} catch (Exception e) {
sres.setCode(500);
e.printStackTrace();
}
return sres;
}
/**
* 报修单详情
*
* @param req
* @return
*/
@RequestMapping(value = "/zpinfo")
@ResponseBody
public ZhaopinResponse zpinfo(HttpServletRequest req) {
ZhaopinResponse sres = new ZhaopinResponse();
try {
int id = Integer.parseInt(req.getParameter("id"));
Zhaopin zinfo = zhaopinService.queryZhaopinById(id);
if (zinfo.getWuid() != null && zinfo.getWuid() != 0) {
Wxuser wxuser = new Wxuser();
wxuser.setUid(zinfo.getWuid());
List<Wxuser> wxlist = wxuserService.queryWxuserList(wxuser,
null);
if (wxlist != null && wxlist.size() > 0) {
zinfo.setWxuserVO(wxlist.get(0));
}
}
sres.setCode(200);
sres.setDinfo(zinfo);
} catch (Exception e) {
sres.setCode(500);
e.printStackTrace();
}
return sres;
}
/**
* 发布报修单
*
* @param req
* @return
*/
@RequestMapping(value = "/addZhaopin")
@ResponseBody
public Response addZhaopin(HttpServletRequest req, Zhaopin zhaopin) {
Response sres = new Response();
try {
int xmid = Integer.parseInt(req.getParameter("xmid"));
Xminfo xminfo = xminfoService.queryXminfoById(xmid);
zhaopin.setTitle(xminfo.getName());
zhaopin.setGj(xminfo.getBj());
zhaopin.setState("待接单");
zhaopin.setFbsj(new SimpleDateFormat("yyyy-MM-dd")
.format(new Date()));
zhaopinService.insertZhaopin(zhaopin);
sres.setCode(200);
} catch (Exception e) {
sres.setCode(500);
e.printStackTrace();
}
return sres;
}
/**
* 修改报修单
*
* @param req
* @return
*/
@RequestMapping(value = "/updateZhaopin")
@ResponseBody
public Response updateZhaopin(HttpServletRequest req, Zhaopin zhaopin) {
Response sres = new Response();
try {
zhaopin.setFbsj(new SimpleDateFormat("yyyy-MM-dd")
.format(new Date()));
zhaopinService.updateZhaopin(zhaopin);
sres.setCode(200);
} catch (Exception e) {
sres.setCode(500);
e.printStackTrace();
}
return sres;
}
/**
* 删除报修单
*
* @param req
* @return
*/
@RequestMapping(value = "/delZhaopin")
@ResponseBody
public Response delZhaopin(HttpServletRequest req) {
Response sres = new Response();
try {
int id = Integer.parseInt(req.getParameter("id"));
zhaopinService.deleteZhaopin(id);
sres.setCode(200);
} catch (Exception e) {
sres.setCode(500);
e.printStackTrace();
}
return sres;
}
/**
* 我发布的报修单
*
* @param req
* @return
*/
@RequestMapping(value = "/myzplist")
@ResponseBody
public ZhaopinListResponse myzplist(HttpServletRequest req) {
ZhaopinListResponse sres = new ZhaopinListResponse();
try {
int uid = Integer.parseInt(req.getParameter("uid"));
Zhaopin zinfo = new Zhaopin();
zinfo.setUid(uid);
List<Zhaopin> dlist = zhaopinService.queryZhaopinList(zinfo, null);
sres.setCode(200);
sres.setDlist(dlist);
} catch (Exception e) {
sres.setCode(500);
e.printStackTrace();
}
return sres;
}
/**
* 维修人员接单
*
* @param req
* @return
*/
@RequestMapping(value = "/jiedan")
@ResponseBody
public Response jiedan(HttpServletRequest req) {
Response sres = new Response();
try {
int id = Integer.parseInt(req.getParameter("id"));
int uid = Integer.parseInt(req.getParameter("uid"));
Wxuser wxuser = new Wxuser();
wxuser.setUid(uid);
List<Wxuser> wlist = wxuserService.queryWxuserList(wxuser, null);
if (wlist != null && wlist.size() > 0) {
wxuser = wlist.get(0);
if (wxuser.getState().equals("通过")) {
Zhaopin zinfo = zhaopinService.queryZhaopinById(id);
zinfo.setWuid(uid);
zinfo.setState("已接单");
zhaopinService.updateZhaopin(zinfo);
sres.setCode(200);
} else {
sres.setCode(202);
}
} else {
sres.setCode(201);
}
} catch (Exception e) {
sres.setCode(500);
e.printStackTrace();
}
return sres;
}
/**
* 我接的维修单 维修人员
*
* @param req
* @return
*/
@RequestMapping(value = "/mjdlist")
@ResponseBody
public ZhaopinListResponse mjdlist(HttpServletRequest req) {
ZhaopinListResponse sres = new ZhaopinListResponse();
try {
int uid = Integer.parseInt(req.getParameter("uid"));
Zhaopin zinfo = new Zhaopin();
zinfo.setWuid(uid);
List<Zhaopin> dlist = zhaopinService.queryZhaopinList(zinfo, null);
sres.setCode(200);
sres.setDlist(dlist);
} catch (Exception e) {
sres.setCode(500);
e.printStackTrace();
}
return sres;
}
/**
* 维修工报价
*
* @param req
* @return
*/
@RequestMapping(value = "/baojia")
@ResponseBody
public Response baojia(HttpServletRequest req) {
Response sres = new Response();
try {
int id = Integer.parseInt(req.getParameter("id"));
String baojia = req.getParameter("baojia");
Zhaopin zinfo = zhaopinService.queryZhaopinById(id);
zinfo.setBaojia(baojia);
zinfo.setState("已维修");
zhaopinService.updateZhaopin(zinfo);
sres.setCode(200);
} catch (Exception e) {
sres.setCode(500);
e.printStackTrace();
}
return sres;
}
/**
* 用户确认完成
*
* @param req
* @return
*/
@RequestMapping(value = "/wancheng")
@ResponseBody
public Response wancheng(HttpServletRequest req) {
Response sres = new Response();
try {
int id = Integer.parseInt(req.getParameter("id"));
Zhaopin zinfo = zhaopinService.queryZhaopinById(id);
zinfo.setState("已完成");
zhaopinService.updateZhaopin(zinfo);
sres.setCode(200);
} catch (Exception e) {
sres.setCode(500);
e.printStackTrace();
}
return sres;
}
/**
* 返修申请
*
* @param req
* @return
*/
@RequestMapping(value = "/fxsqInfo")
@ResponseBody
public Response fxsqInfo(HttpServletRequest req) {
Response sres = new Response();
try {
int id = Integer.parseInt(req.getParameter("id"));
String fxsq = req.getParameter("fxsq");
String fujian = req.getParameter("fujian");
Zhaopin zinfo = zhaopinService.queryZhaopinById(id);
zinfo.setFxsq(fxsq);
zinfo.setFujian(fujian);
zinfo.setState("申请返修");
zhaopinService.updateZhaopin(zinfo);
sres.setCode(200);
} catch (Exception e) {
sres.setCode(500);
e.printStackTrace();
}
return sres;
}
/**
* 上传文件
*
* @param user
* @return
*/
@RequestMapping(value = "/uploadFile")
@ResponseBody
public String uploadFile(HttpServletRequest req, HttpServletResponse res,
Userinfo user) {
String url = "";
try {
FileItemFactory factory = new DiskFileItemFactory();
// 创建文件上传处理器
ServletFileUpload upload = new ServletFileUpload(factory);
// 开始解析请求信息
List items = null;
try {
items = upload.parseRequest(req);
} catch (FileUploadException e) {
e.printStackTrace();
}
// 对所有请求信息进行判断
Iterator iter = items.iterator();
while (iter.hasNext()) {
FileItem item = (FileItem) iter.next();
// 信息为普通的格式
if (item.isFormField()) {
String fieldName = item.getFieldName();
String value = item.getString();
}
// 信息为文件格式
else {
String fileName = item.getName();
int index = fileName.lastIndexOf(".");
fileName = fileName.substring(index);
String fname = new SimpleDateFormat("yyyyMMddHHmmss")
.format(new Date())
+ fileName;
String basePath = req.getRealPath("/upload");
String furl = "/upload/" + fname;
File file = new File(basePath, fname);
try {
item.write(file);
url = furl;
} catch (Exception e) {
e.printStackTrace();
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return url;
}
}