基于javaweb+mysql的springboot医药进销存管理系统(java+springboot+html+echarts+jquery+maven+mysql)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot医药进销存管理系统(java+springboot+html+echarts+jquery+maven+mysql)
功能介绍
医药进销存系统,主要分两种角色:员工、客户。本系统具有进销存系统的通用性,可以修改为其它进销存系统,如家电进销存、手机进销存等;
员工登录后主要功能模块有: 我的面板:个人信息、修改信息、修改密码; 员工管理:员工添加、员工查询; 药品管理:药品类别添加、药品类别查询、药品添加、药品查询; 客户管理:客户查询; 供货商管理:供货商添加、供货商查询; 账单管理:进货添加、进货查询、退货账单、销售账单查询; 客户登录后主要功能模块有: 我的面板:个人信息、修改信息、修改密码;
购买药品:药品展示、已购药品;
环境需要
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版本;
系统框架
1.后端:SpringBoot
2.前端:HTML+Echarts+JQuery
使用说明
-
使用IDEA/Eclipse/MyEclipse导入后端项目源码,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;
-
使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 3. 运行项目前,需要配置好MqSQL数据库,在application.properties中修改数据库对应的配置文件; 4. 配置Tomcat,在Tomcat中运行后端项目; 5. 运行成功后,在浏览器中访问:http://localhost:8888 6. 客户和员工对应数据库表t_customers和t_employees表,用户名是手机号,密码也是对应的手机号 客户账号:15133480838 密码:15133480838
员工账号:15133330551 密码:15133330551
}else if(e instanceof EmailDuplicateException){
rr.setState(401); //401-邮箱冲突
}else if(e instanceof OnExistException){
rr.setState(402); //402-入库单号冲突
}else if(e instanceof CategoryNameDuplicateException){
rr.setState(403); //403-药品类别名称重复异常
}else if(e instanceof UserNotFoundException){
rr.setState(404); //404-用户不存在异常
}else if(e instanceof BarCodeDuplicateException){
rr.setState(405); //405-药品条形码重复异常
}else if(e instanceof PhoneNotFoundException){
rr.setState(406); //手机号不存在异常
}else if(e instanceof PasswordNotMatchException){
rr.setState(407); //密码不存在异常
}else if(e instanceof YearMonthException){
rr.setState(406); //客户时间异常
}else if(e instanceof SupplierNotFoundException){
rr.setState(407); //供货商不存在异常
}else if(e instanceof PermissionsInsufficientException){
rr.setState(406); //员工权限不足异常
}else if(e instanceof InventoryFoundException){
rr.setState(407); //库存不足异常
}else if(e instanceof InventoryException){
rr.setState(406); //修改库存异常
}else if(e instanceof ForeignKeyReferenceException){
rr.setState(407); //外键引用异常
}
else if(e instanceof InsertException){
rr.setState(500); //500插入数据异常
}else if(e instanceof UpdateException){
rr.setState(501); //501修改数据异常
}else if(e instanceof DeleteException){
rr.setState(502); //501删除改数据异常
}
return rr;
}
}
String suffix = "";
if(beginIndex > 0) {
suffix = originalFilename.substring(beginIndex);
}
String filename = prefic+suffix;
File dest = new File(parent,filename);
try {
file.transferTo(dest);
} catch (IllegalStateException e) {
e.printStackTrace();
throw new FileIllegalStateException("上传头像错误!存储头像文件时状态异常!");
} catch (IOException e) {
e.printStackTrace();
throw new FileIOException("上传头像错误!读写文件时出现错误!");
}
Integer uid = getUidFromSession(session);
String avatar = "/"+UPLOAD_DIR+"/"+filename;
customerService.changeAvatar(avatar,uid);
return new ResponseResult<String>(SUCCESS,avatar);
}
/**
* 查询客户的数量
*/
@RequestMapping("/selectIdCount")
public ResponseResult<Long> selectIdCount(){
Long count = customerService.getselectIdCount();
return new ResponseResult<Long>(SUCCESS,count);
}
/**
* 图表展示,客户流量,输入年份,展示该年每一个月的客户注册量
* @param createdTime
* @return
*/
@RequestMapping("/selectYearTime")
public ResponseResult<List<CustomerTime>> selectYearTime(String createdTime){
String str = createdTime.substring(0, createdTime.indexOf("-"));
Map<String,Object> map = new HashMap<String,Object>();
map.put("createdTime", str);
List<CustomerTime> customerTimeList = customerService.getselectYearMonth(map);
return new ResponseResult<List<CustomerTime>>(SUCCESS,customerTimeList);
}
}
}
}
return allDrugStock;
}
/**
* 删除某条数据
*/
@Override
public void deleteDrugStock(String ids,HttpSession session) {
String[] id = ids.split(",");
String username = session.getAttribute("username").toString();
Date now = new Date();
for(int i=0;i<id.length;i++){
System.err.println(Integer.parseInt(id[i]));
Integer upd = updateIsDelete(Integer.parseInt(id[i]),username,now);
if(upd!=1){
throw new InsertException("删除数据时出现未知错误!!");
}
}
}
/**
* 在员工表和供货商表药品表中查询所有存在的id,名字,并且返回出去
*/
@Override
public List<List<Map<Integer, String>>> findDrgEmpSupId() {
List<List<Map<Integer, String>>> UAN = new ArrayList<List<Map<Integer, String>>>();
List<Map<Integer, String>> drgId = new ArrayList<Map<Integer, String>>();
List<Map<Integer, String>> supId = new ArrayList<Map<Integer, String>>();
List<Map<Integer, String>> empId = new ArrayList<Map<Integer, String>>();
Integer count = 1;
List<Drug> drg = findDrgByUidUsername();
for(Drug d : drg){
if(!count.equals(d.getIsDelete())){
Map<Integer, String> drgmap = new HashMap<Integer, String>();
drgmap.put(d.getId(), d.getDrugName());
drgId.add(drgmap);
}
}
UAN.add(drgId);
List<Supplier> sup = findSupByUidUsername();
for(Supplier s : sup){
if(!count.equals(s.getIsDelete())){
Map<Integer, String> supmap = new HashMap<Integer, String>();
supmap.put(s.getUid(), s.getUsername());
supId.add(supmap);
}
}
UAN.add(supId);
Integer count = 1;
List<Drug> drg = findDrgByUidUsername();
for(Drug d : drg){
if(!count.equals(d.getIsDelete())){
Map<Integer, String> drgmap = new HashMap<Integer, String>();
drgmap.put(d.getId(), d.getDrugName());
drgId.add(drgmap);
}
}
UAN.add(drgId);
List<Supplier> sup = findSupByUidUsername();
for(Supplier s : sup){
if(!count.equals(s.getIsDelete())){
Map<Integer, String> supmap = new HashMap<Integer, String>();
supmap.put(s.getUid(), s.getUsername());
supId.add(supmap);
}
}
UAN.add(supId);
List<Employees> emp = findEmpByUidUsername();
for(Employees e : emp){
if(!count.equals(e.getIsDelete())){
Map<Integer, String> empmap = new HashMap<Integer, String>();
empmap.put(e.getUid(), e.getUsername());
empId.add(empmap);
}
}
UAN.add(empId);
return UAN;
}
/**
* 查询员工表uid,username
* @return
*/
private List<Employees> findEmpByUidUsername(){
List<Employees> list = employees.findByUidUsername();
return list;
}
/**
* 查询药品里面所有的id以及药品名字
* @return
*/
throw new InsertException("删除数据时出现未知错误!!");
}
}
}
/**
* 在员工表和供货商表药品表中查询所有存在的id,名字,并且返回出去
*/
@Override
public List<List<Map<Integer, String>>> findDrgEmpSupId() {
List<List<Map<Integer, String>>> UAN = new ArrayList<List<Map<Integer, String>>>();
List<Map<Integer, String>> drgId = new ArrayList<Map<Integer, String>>();
List<Map<Integer, String>> supId = new ArrayList<Map<Integer, String>>();
List<Map<Integer, String>> empId = new ArrayList<Map<Integer, String>>();
Integer count = 1;
List<Drug> drg = findDrgByUidUsername();
for(Drug d : drg){
if(!count.equals(d.getIsDelete())){
Map<Integer, String> drgmap = new HashMap<Integer, String>();
drgmap.put(d.getId(), d.getDrugName());
drgId.add(drgmap);
}
}
UAN.add(drgId);
List<Supplier> sup = findSupByUidUsername();
for(Supplier s : sup){
if(!count.equals(s.getIsDelete())){
Map<Integer, String> supmap = new HashMap<Integer, String>();
supmap.put(s.getUid(), s.getUsername());
supId.add(supmap);
}
}
UAN.add(supId);
List<Employees> emp = findEmpByUidUsername();
for(Employees e : emp){
if(!count.equals(e.getIsDelete())){
Map<Integer, String> empmap = new HashMap<Integer, String>();
empmap.put(e.getUid(), e.getUsername());
empId.add(empmap);
}
}
UAN.add(empId);
return UAN;
}
/**
* 进货业务层实现类
*
*/
@Service
public class DrugStockServiceImpl implements IDrugStockService{
@Autowired
private DrugStockDao drugstock;//进货表持久层
@Autowired
private DrugDao drugDao;//药品表持久层
@Autowired
private SupplierDao supplier;//供货商持久层
@Autowired
private EmployeesDao employees;//员工持久层
/**
* 修改数据
*/
@Override
public Integer modificationDrugStock(DrugStock drugStock) throws InsertException{
Integer upd = updateDrugStock(drugStock);
return upd;
}
/**
* 添加进货信息
*/
@Override
public Integer addDrugStock(DrugStock drugStock , HttpSession session)throws InsertException,OnExistException{
//先根据入库单据号查询数据库是否有这条数据
String documentNo = drugStock.getDocumentNo();
if(findBydocumentNo(documentNo) != 0){
throw new OnExistException("入库单据号已存在!!!");
}
//因为前段穿过来的数据不完整,需要在后台补上完整的信息(是否删除,创建人,创建时间,修改人,修改时间)
drugStock.setIsDelete(0);
//创建人需要登入后在session中获取
drugStock.setCreatedUser(session.getAttribute("username").toString());
drugStock.setCreatedTime(new Date());
@RestController
@RequestMapping("/drugCategory")
public class DrugCategoryController extends BaseController{
@Autowired //自动装配
private IDrugCategoryService drugCategoryService;
/**
* 添加数据。药品类别信息
* @param user
* @return 返回成功
*/
@RequestMapping("/addDrugCategory")
public ResponseResult<Void> addDrugCategory(DrugCategory drugCategory) {
drugCategoryService.addDrugCategory(drugCategory);
return new ResponseResult<Void>(SUCCESS);
}
/**
* 查询药品类别数据,多条件查询
* @param drugCategory
* @return
* @throws JsonProcessingException
*/
@RequestMapping("/selectDrugCategory")
public ResponseResult<PaginationVO<DrugCategory>> selectDrugCategory(String categoryName,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);
List<StockReturn> allStockReturn = stockReturnService.findAll((pageNoStr-1)*pageSizeStr,pageSizeStr,documentNo);
//解决前后端json遍历的时间问题(把vo换成jsonObj)
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.registerJsonValueProcessor(Date.class, new JsonDateValueProcessor());
JSONArray jsonArr = JSONArray.fromObject(allStockReturn, jsonConfig);
return new ResponseResult<JSONArray>(SUCCESS,jsonArr);
}
/**
* 添加退货信息
* @param stockReturn 退货信息
* @param session 获取登录的用户名
* @return 返回成功与否
*/
@PostMapping("/addstockreturn")
public ResponseResult<Void> addStockReturn(StockReturn stockReturn,HttpSession session){
System.err.println(stockReturn);
stockReturnService.addStockReturn(stockReturn, session.getAttribute("username").toString());
return new ResponseResult<>(SUCCESS);
}
}
/**
* 进货业务层接口
*
*/
public interface IDrugStockService {
/**
* 修改数据
* @param drugStock 需要修改的数据
* @return 返回受影响的行数
* @throws InsertException 数据操作异常
*/
Integer modificationDrugStock(DrugStock drugStock) throws InsertException;
/**
* 删除客户数据
* @param uid
* @param session
* @return
*/
@RequestMapping("/deleteCustomer")
public ResponseResult<Void> deleteCustomer(Integer uid,HttpSession session){
String username = (String) session.getAttribute("username");
customerService.getdeleteId(uid, username);
return new ResponseResult<Void>(SUCCESS);
}
/**
* 修改客户数据
*/
@RequestMapping("/updateCustomer")
public ResponseResult<Void> updateCustomer(Customer customer,HttpSession session){
String username = (String) session.getAttribute("username");
customerService.getupdateCustomer(customer, username);
return new ResponseResult<Void>(SUCCESS);
}
/**
* 展示个人信息
*/
@RequestMapping("/getfindByUid")
public ResponseResult<Customer> getfindByUid(Integer uid){
Customer customer = customerService.getfindByUid(uid);
return new ResponseResult<Customer>(SUCCESS,customer);
}
/**
* 修改密码
*/
@RequestMapping("/getfindByUidPassword")
public ResponseResult<Void> getfindByUidPassword(Integer uid,HttpSession session,String oldPassword,String newPassword){
String username = (String) session.getAttribute("username");
customerService.getfindByUidPassword(uid, username, oldPassword, newPassword);
return new ResponseResult<Void>(SUCCESS);
}
/**
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);
* 根据uid查询药品全部数据
* @param uid
* @return
*/
@RequestMapping("/findId")
public ResponseResult<Drug> getfindId(Integer id){
Drug data = drugService.getfindId(id);
return new ResponseResult<Drug>(SUCCESS,data);
};
/**
* 修改药品数据
* @param drug
* @param session
* @return
*/
@RequestMapping("/updateIdDrug")
public ResponseResult<Void> updateIdDrug(Drug drug,HttpSession session) {
String username = (String) session.getAttribute("username");
drugService.getupdateIdDrug(drug, username);
return new ResponseResult<Void>(SUCCESS);
}
/**
* 根据id删除药品数据
* @param id
* @param session
* @return
*/
@RequestMapping("/deleteIdDrug")
public ResponseResult<Void> deleteIdDrug(String id,HttpSession session) {
String[] ids = id.split(",");
String username = (String) session.getAttribute("username");
drugService.getdeleteIdDrug(ids, username);
return new ResponseResult<Void>(SUCCESS);
}
/**
* 查询药品的数量
*/
@RequestMapping("/selectIdCount")
public ResponseResult<Long> selectIdCount(){
Long count = drugService.getselectIdCount();
return new ResponseResult<Long>(SUCCESS,count);
}
}
@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){
}
try {
ExcelFromInterface excelInterface=new ExcelFromServiceImpl();
excelInterface.excel(title, rowName, list, url);
} catch (Exception e) { }
return new ResponseResult<Void>(SUCCESS);
}
}
@RestController
@RequestMapping("/logOperation")
public class LogOperationController extends BaseController{
@Autowired //自动装配
private ILogOperationService logOperationService;
/**
* 查询日志数据,多条件查询
* @param drugCategory
* @return
* @throws JsonProcessingException
*/
@RequestMapping("/selectLogOperation")
public ResponseResult<JSONObject> selectDrugCategory
(String category,String location,String time,String pageNoStr,String pageSizeStr) throws JsonProcessingException {
//获取参数
long pageNo = 1; //如果没有传数据,默认为第一页
jsonConfig.registerJsonValueProcessor(Date.class, new JsonDateValueProcessor());
JSONArray jsonArr = JSONArray.fromObject(drugStocks, jsonConfig);
return new ResponseResult<JSONArray>(SUCCESS,jsonArr);
}
/**
* 删除数据
* @param Id 需要删除的id
* @param session 获取绑定数据
* @return 返回结果
*/
@PostMapping("/deletebyid")
public ResponseResult<Void> deleteDrugStock(String Id,HttpSession session){
drugStockService.deleteDrugStock(Id,session);
return new ResponseResult<Void>(SUCCESS);
}
}
@RestController
@RequestMapping("/excel")
public class ExcelDrugController extends BaseController {
@Autowired //自动装配
private IDrugService drugService;
@RequestMapping("/excelDrug")
public ResponseResult<Void> ExcelDrug(
String drugName,String unit,String origin,Integer categoryId) {
System.err.println(drugName+","+unit+","+origin+","+categoryId);
String title="药品表";
String[] rowName = new String[]{"药品名","药品类别","条形码","简称","规格","单位","产地","批准文号","进货价","销售价","库存","销售总量","药品备注"};
Map<String ,Object> map = new HashMap<String ,Object>();
* 添加数据。药品类别信息
* @param user
* @return 返回成功
*/
@RequestMapping("/addDrug")
public ResponseResult<Void> addDrug(Drug drug,HttpSession session) {
String username = (String) session.getAttribute("username");
drugService.addDrug(drug, username);
return new ResponseResult<Void>(SUCCESS);
}
/**
* 为添加药品时,药品类别选择所设计
* @return
*/
@RequestMapping("/selectDrugCategory")
public ResponseResult<List<DrugCategory>> selectDrugCategory(){
List<DrugCategory> list = drugCategoryService.getfindByCategoryIdCategoryName();
return new ResponseResult<List<DrugCategory>>(SUCCESS,list);
}
/**
* 查询药品数据(关联查询)药品类别表,后期改为多条件查询
* @param drugCategory
* @return
* @throws JsonProcessingException
*/
@RequestMapping("/selectDrug")
public ResponseResult<PaginationVO<DrugANDDrugCategory>> selectDrug(String drugName,String unit,String origin,Integer categoryId,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("drugName", drugName);
map.put("unit", unit);
map.put("origin", origin);
map.put("beginNo", beginNo);
map.put("categoryId", categoryId);
map.put("pageSize", pageSize);
PaginationVO<DrugANDDrugCategory> vo = drugService.getselectDrug(map);
return new ResponseResult<PaginationVO<DrugANDDrugCategory>>(SUCCESS,vo);
}
* @param categoryId
* @return
*/
@RequestMapping("/selectDrugCategory_categoryId")
public ResponseResult<DrugCategory> getselectDrugCategoryBycategoryId(Integer categoryId) {
DrugCategory drugCategory = drugCategoryService.getselectDrugCategoryBycategoryId(categoryId);
return new ResponseResult<DrugCategory>(SUCCESS,drugCategory);
}
/**
* 根据id修改数据
* @param categoryId
* @return
*/
@RequestMapping("/updateDrugCategory_categoryId")
public ResponseResult<Void> getupdateDrugCategoryBycategoryId(DrugCategory drugCategory) {
drugCategoryService.getupdateDrugCategoryBycategoryId(drugCategory);
return new ResponseResult<Void>(SUCCESS);
}
}
/**
*
*/
public interface IDrugStockService {
/**
* 修改数据
* @param drugStock 需要修改的数据
* @return 返回受影响的行数
* @throws InsertException 数据操作异常
*/
Integer modificationDrugStock(DrugStock drugStock) throws InsertException;
/**
* 删除某条数据
* @param ids 需要删除的id字符串
* @param session session获取登入名
*/
void deleteDrugStock(String ids,HttpSession session);
/**
* 查询所有的进货数据
* @return
*/
List<DrugStockFindAll> findDrugStock(Integer pageNoStr,Integer pageSizeStr,String documentNo);
/**
* 添加进货清单
* @param drugstock
* @return
*/
Integer addDrugStock(DrugStock drugStock,HttpSession session)throws InsertException;
/**
* 查询供货商表,员工表,药品表所有的id与姓名
* @return 查询到的id
*/
List<List<Map<Integer, String>>> findDrgEmpSupId();
}