源码获取:关注文末gongzhonghao,输入014领取下载链接
开发工具:IDEA,数据库mysql
技术:springboot+mybatis
系统主要分两个角色,客户和员工
package cn.tedu.drug.controller;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.core.JsonProcessingException;
import cn.tedu.drug.entity.DrugSales;
import cn.tedu.drug.entity.DrugSalesANDCustomer;
import cn.tedu.drug.entity.domain.PaginationVO;
import cn.tedu.drug.service.IDrugSalesService;
import cn.tedu.drug.util.JsonDateValueProcessor;
import cn.tedu.drug.util.ResponseResult;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
@RestController
@RequestMapping("/drugSales")
public class DrugSalesController extends BaseController{
@Autowired //自动装配
private IDrugSalesService drugSalesService;
/**
* 添加销售数据
* @return
*/
@RequestMapping("/insertDrugSales")
public ResponseResult<Void> addDrugSales(String ids,String number,HttpSession session){
DrugSales drugSales = new DrugSales();
drugSales.setInventoryQuantity(Integer.parseInt(number)); //添加销售数量
drugSales.setCustomerId( getUidFromSession(session) ); //添加客户id
String[] id = ids.split(",");
String username = session.getAttribute("username").toString();
drugSalesService.addDrugSales(id, drugSales, username);
return new ResponseResult<Void>(SUCCESS);
}
/**
* 查询数据,多条件查询
* @param drugCategory
* @return
* @throws JsonProcessingException
*/
@RequestMapping("/selectDrugSales")
public ResponseResult<JSONObject> selectDrugSales
(String drugName,String storageTime,String pageNoStr,String pageSizeStr,HttpSession session)
throws JsonProcessingException {
//获取参数
long pageNo = 1; //如果没有传数据,默认为第一页
if( pageNoStr != null && pageNoStr.trim().length()>0 ){
pageNo = Long.parseLong(pageNoStr);
}
int pageSize = 1; //如果没有传数据,默认为10条数据
if( pageSizeStr != null && pageSizeStr.trim().length()>0 ){
pageSize = Integer.parseInt(pageSizeStr);
}
long beginNo = (pageNo-1)*pageSize;
Map<String ,Object> map = new HashMap<String ,Object>();
map.put("beginNo", beginNo);
map.put("pageSize", pageSize);
map.put("storageTime", storageTime);
map.put("drugName", drugName);
map.put("customerId", getUidFromSession(session));
PaginationVO<DrugSales> vo = drugSalesService.getSelectDrugSales(map);
//解决前后端json遍历的时间问题(把vo换成jsonObj)
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.registerJsonValueProcessor(Date.class, new JsonDateValueProcessor());
JSONObject jsonObj = JSONObject.fromObject(vo, jsonConfig);
return new ResponseResult<JSONObject>(SUCCESS,jsonObj);
}
/**
* 查询数据,多条件查询,销售账单
* @param drugCategory
* @return
* @throws JsonProcessingException
*/
@RequestMapping("/getselectDrugSales")
public ResponseResult<JSONObject> getselectDrugSales
(String drugName,String storageTime,String username,String pageNoStr,String pageSizeStr)
throws JsonProcessingException {
//获取参数
long pageNo = 1; //如果没有传数据,默认为第一页
if( pageNoStr != null && pageNoStr.trim().length()>0 ){
pageNo = Long.parseLong(pageNoStr);
}
int pageSize = 1; //如果没有传数据,默认为10条数据
if( pageSizeStr != null && pageSizeStr.trim().length()>0 ){
pageSize = Integer.parseInt(pageSizeStr);
}
long beginNo = (pageNo-1)*pageSize;
Map<String ,Object> map = new HashMap<String ,Object>();
map.put("beginNo", beginNo);
map.put("pageSize", pageSize);
map.put("storageTime", storageTime);
map.put("drugName", drugName);
map.put("username", username);
PaginationVO<DrugSalesANDCustomer> vo = drugSalesService.getfindDrugSales(map);
//解决前后端json遍历的时间问题(把vo换成jsonObj)
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.registerJsonValueProcessor(Date.class, new JsonDateValueProcessor());
JSONObject jsonObj = JSONObject.fromObject(vo, jsonConfig);
return new ResponseResult<JSONObject>(SUCCESS,jsonObj);
}
/**
* 查询供货商的数量
*/
@RequestMapping("/selectIdCount")
public ResponseResult<Long> selectIdCount(){
Long count = drugSalesService.getselectIdCount();
return new ResponseResult<Long>(SUCCESS,count);
}
}
package cn.tedu.drug.controller;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.tedu.drug.entity.DrugStock;
import cn.tedu.drug.entity.DrugStockFindAll;
import cn.tedu.drug.service.IDrugStockService;
import cn.tedu.drug.util.JsonDateValueProcessor;
import cn.tedu.drug.util.ResponseResult;
import net.sf.json.JSONArray;
import net.sf.json.JsonConfig;
/**
*/
@RestController
@RequestMapping(“/drugstock”)
public class DrugStockController extends BaseController{
@Autowired
private IDrugStockService drugStockService;
/**
* 修改数据
* @return 返回成功与否
*/
@PostMapping("/update")
public ResponseResult update(DrugStock drugStock){
drugStockService.modificationDrugStock(drugStock);
return new ResponseResult(SUCCESS);
}
/**
* 插入进货数据
* @param drugStock 需要插入的数据
* @return 返回执行信息错误与否
*/
@PostMapping("/insert")
public ResponseResult add(DrugStock drugStock,HttpSession session){
drugStockService.addDrugStock(drugStock,session);
return new ResponseResult(SUCCESS);
}
/**
* 查询员工与客户中所有已存在的id
* @return 返回list集合封装的id
*/
@GetMapping("/findid")
public ResponseResult>>> findEmpSupId(){
List>> id = drugStockService.findDrgEmpSupId();
return new ResponseResult>>>(SUCCESS, id);
}
/**
* 查询所有的drugStock
* @return 返回结果
*/
@GetMapping("/findall")
public ResponseResult findAllDrugStock(Integer pageNoStr,Integer pageSizeStr,String documentNo){
List drugStocks = drugStockService.findDrugStock((pageNoStr-1)*pageSizeStr,pageSizeStr,documentNo);
//解决前后端json遍历的时间问题(把vo换成jsonObj)
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.registerJsonValueProcessor(Date.class, new JsonDateValueProcessor());
JSONArray jsonArr = JSONArray.fromObject(drugStocks, jsonConfig);
return new ResponseResult(SUCCESS,jsonArr);
}
/**
* 删除数据
* @param Id 需要删除的id
* @param session 获取绑定数据
* @return 返回结果
*/
@PostMapping("/deletebyid")
public ResponseResult deleteDrugStock(String Id,HttpSession session){
drugStockService.deleteDrugStock(Id,session);
return new ResponseResult(SUCCESS);
}
}