一、项目简述
功能包括: 仓库管理,出入库管理,仓库人员管理,基本信息管理, 供应商信息,系统管理等等。
二、项目运行
环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
项目技术: JSP +Spring + SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等。
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
* @return 返回一个map,其中:key 为 result表示操作的结果,包括:success 与 error
*/
@RequestMapping(value = "deleteCustomer", method = RequestMethod.GET)
public
@ResponseBody
Map<String, Object> deleteCustomer(@RequestParam("customerID") String customerIDStr) throws CustomerManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
// 参数检查
if (StringUtils.isNumeric(customerIDStr)) {
// 转换为 Integer
Integer customerID = Integer.valueOf(customerIDStr);
// 刪除
String result = customerManageService.deleteCustomer(customerID) ? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
responseContent.setResponseResult(result);
} else
responseContent.setResponseResult(Response.RESPONSE_RESULT_ERROR);
return responseContent.generateResponse();
}
@RequestMapping(value = "/**/customerManage")
@Controller
public class CustomerManageHandler {
@Autowired
private CustomerManageService customerManageService;
private static final String SEARCH_BY_ID = "searchByID";
private static final String SEARCH_BY_NAME = "searchByName";
private static final String SEARCH_ALL = "searchAll";
/**
* 通用的结果查询方法
*
* @param searchType 查询方式
* @param keyWord 查询关键字
* @param offset 分页偏移值
* @param limit 分页大小
* @return 返回指定条件查询的结果
*/
private Map<String, Object> query(String searchType, String keyWord, int offset, int limit) throws CustomerManageServiceException {
Map<String, Object> queryResult = null;
switch (searchType) {
case SEARCH_BY_ID:
if (StringUtils.isNumeric(keyWord))
queryResult = customerManageService.selectById(Integer.valueOf(keyWord));
responseContent.setResponseResult(result);
responseContent.setResponseTotal(total);
responseContent.setCustomerInfo("available", available);
return responseContent.generateResponse();
}
/**
* 导出客户信息
*
* @param searchType 查找类型
* @param keyWord 查找关键字
* @param response HttpServletResponse
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "exportCustomer", method = RequestMethod.GET)
public void exportCustomer(@RequestParam("searchType") String searchType, @RequestParam("keyWord") String keyWord,
HttpServletResponse response) throws CustomerManageServiceException, IOException {
String fileName = "customerInfo.xlsx";
List<Customer> customers = null;
Map<String, Object> queryResult = query(searchType, keyWord, -1, -1);
if (queryResult != null) {
customers = (List<Customer>) queryResult.get("data");
}
// 获取生成的文件
@ResponseBody
Map<String, Object> getGoodsList(@RequestParam("searchType") String searchType,
@RequestParam("offset") int offset, @RequestParam("limit") int limit,
@RequestParam("keyWord") String keyWord) throws GoodsManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
List<Supplier> rows = null;
long total = 0;
// 查询
Map<String, Object> queryResult = query(searchType, keyWord, offset, limit);
if (queryResult != null) {
rows = (List<Supplier>) queryResult.get("data");
total = (long) queryResult.get("total");
}
// 设置 Response
货物信息管理请求:
/**
* 货物信息管理请求 Handler
*/
@RequestMapping(value = "/**/goodsManage")
@Controller
public class GoodsManageHandler {
@Autowired
private GoodsManageService goodsManageService;
private static final String SEARCH_BY_ID = "searchByID";
private static final String SEARCH_BY_NAME = "searchByName";
private static final String SEARCH_ALL = "searchAll";
/**
* 通用的记录查询
*
* @param searchType 查询类型
* @param keyWord 查询关键字
@ResponseBody
Map<String, Object> getGoodsInfo(@RequestParam("goodsID") Integer goodsID) throws GoodsManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
String result = Response.RESPONSE_RESULT_ERROR;
// 获取货物信息
Goods goods = null;
Map<String, Object> queryResult = goodsManageService.selectById(goodsID);
if (queryResult != null) {
goods = (Goods) queryResult.get("data");
if (goods != null) {
result = Response.RESPONSE_RESULT_SUCCESS;
}
}
// 设置 Response
responseContent.setResponseResult(result);
responseContent.setResponseData(goods);
return responseContent.generateResponse();
}
*
* @param goods 货物信息
* @return 返回一个map,其中:key 为 result表示操作的结果,包括:success 与 error
*/
@RequestMapping(value = "updateGoods", method = RequestMethod.POST)
public
@ResponseBody
Map<String, Object> updateGoods(@RequestBody Goods goods) throws GoodsManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
// 更新
String result = goodsManageService.updateGoods(goods) ? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
// 设置 Response
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
* 删除货物记录
*
* @param goodsID 货物ID
inputStream.close();
outputStream.close();
}
}
}
客户信息管理请求:
/**
* 客户信息管理请求 Handler
*
*/
@RequestMapping(value = "/**/customerManage")
@Controller
public class CustomerManageHandler {
@Autowired
private CustomerManageService customerManageService;
private static final String SEARCH_BY_ID = "searchByID";
private static final String SEARCH_BY_NAME = "searchByName";
private static final String SEARCH_ALL = "searchAll";
/**
public class SystemLogHandler {
@Autowired
private SystemLogService systemLogService;
/**
* 查询系统的登入登出日志
*
* @param userIDStr 用户ID
* @param accessType 记录类型(登入、登出或全部)
* @param startDateStr 记录的起始日期
* @param endDateStr 记录的结束日期
* @param offset 分页的偏移值
* @param limit 分页的大小
* @return 返回 JSON 数据 其中:Key为rows的值代表所有记录数据,Key为total的值代表记录的总条数
* @throws SystemLogServiceException SystemLogServiceException
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "getAccessRecords", method = RequestMethod.GET)
public @ResponseBody
Map<String, Object> getAccessRecords(@RequestParam("userID") String userIDStr,
@RequestParam("accessType") String accessType,
@RequestMapping(value = "addCustomer", method = RequestMethod.POST)
public
@ResponseBody
Map<String, Object> addCustomer(@RequestBody Customer customer) throws CustomerManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
// 添加记录
String result = customerManageService.addCustomer(customer) ? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
* 查询指定 customer ID 客户的信息
*
* @param customerID 客户ID
* @return 返回一个map,其中:key 为 result 的值为操作的结果,包括:success 与 error;key 为 data
* 的值为客户信息
*/
@RequestMapping(value = "getCustomerInfo", method = RequestMethod.GET)
public
@ResponseBody
Map<String, Object> getCustomerInfo(@RequestParam("customerID") String customerID) throws CustomerManageServiceException {
// 获取生成的文件
File file = customerManageService.exportCustomer(customers);
// 写出文件
if (file != null) {
// 设置响应头
response.addHeader("Content-Disposition", "attachment;filename=" + fileName);
FileInputStream inputStream = new FileInputStream(file);
OutputStream outputStream = response.getOutputStream();
byte[] buffer = new byte[8192];
int len;
while ((len = inputStream.read(buffer, 0, buffer.length)) > 0) {
outputStream.write(buffer, 0, len);
outputStream.flush();
}
inputStream.close();
outputStream.close();
}
}
}
系统操作日志请求:
/**
* 系统操作日志请求 Handler
*
*/
@Controller
@RequestMapping(value = "/systemLog")