栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

仓库ERP管理系统(springboot)

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

仓库ERP管理系统(springboot)

演示地址仓库ERP管理系统springboot 01 系统概述

基于SpringBoot框架和SaaS模式非常好用的ERP软件目前专注进销存+财务功能。主要模块有零售管理、采购管理、销售管理、仓库管理、财务管理、报表查询、系统管理等。支持预付款、收入支出、仓库调拨、组装拆卸、订单等特色功能。拥有库存状况、出入库统计等报表。权限控制更加精确

02 技术

> springboot + mybatis + easyui

03 运行环境
  • 开发工具idea/eclipse推荐使用idea
  • maven3+并且在开发工具中配置好
  • jdk1.8+推荐1.8
  • MySQL5.5+, 推荐5.75.6
04 技术架构
  • 核心框架SpringBoot 2.0.0
  • 持久层框架Mybatis 1.3.2
  • 日志管理Log4j 2.10.0
  • JS框架Jquery 1.8.0
  • UI框架: EasyUI 1.9.4
  • 模板框架: AdminLTE 2.4.0
  • 项目管理框架:Maven 3.2.3
05 功能模块
  • 零售管理
  • 采购管理
  • 销售管理
  • 仓库管理
  • 财务管理
  • 报表查询
  • 商品管理
  • 基本信息
  • 系统管理
06 项目结构

07 运行截图 零售关系-》零售出库

采购管理-》采购入库

财务管理-》收入单

商品管理-》商品信息

08 主要代码 用户管理
package com.jsh.erp.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.Tenant;
import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.entities.UserEx;
import com.jsh.erp.datasource.vo.TreeNodeEx;
import com.jsh.erp.exception.BusinessParamCheckingException;
import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.tenant.TenantService;
import com.jsh.erp.service.user.UserService;
import com.jsh.erp.utils.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.security.NoSuchAlgorithmException;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;


@RestController
@RequestMapping(value = "/user")
public class UserController {
    private Logger logger = LoggerFactory.getLogger(UserController.class);

    @Value("${manage.roleId}")
    private Integer manageRoleId;

    @Resource
    private UserService userService;

    @Resource
    private TenantService tenantService;

    @Resource
    private LogService logService;

    private static String message = "成功";
    private static final String HTTP = "http://";
    private static final String CODE_OK = "200";

    @PostMapping(value = "/login")
    public baseResponseInfo login(@RequestParam(value = "loginName", required = false) String loginName,
   @RequestParam(value = "password", required = false) String password,
   HttpServletRequest request)throws Exception {
 logger.info("============用户登录 login 方法调用开始==============");
 String msgTip = "";
 User user=null;
 baseResponseInfo res = new baseResponseInfo();
 try {
     String username = loginName.trim();
     password = password.trim();
     //判断用户是否已经登录过登录过不再处理
     Object userInfo = request.getSession().getAttribute("user");
     User sessionUser = new User();
     if (userInfo != null) {
  sessionUser = (User) userInfo;
     }
     if (sessionUser != null && username.equalsIgnoreCase(sessionUser.getLoginame())) {
  logger.info("====用户 " + username + "已经登录过, login 方法调用结束====");
  msgTip = "user already login";
     }
     //获取用户状态
     int userStatus = -1;
     try {
  request.getSession().removeAttribute("tenantId");
  userStatus = userService.validateUser(username, password);
     } catch (Exception e) {
  e.printStackTrace();
  logger.error(">>>>>>>>>>>>>用户  " + username + " 登录 login 方法 访问服务层异常====", e);
  msgTip = "access service exception";
     }
     switch (userStatus) {
  case ExceptionCodeConstants.UserExceptionCode.USER_NOT_EXIST:
      msgTip = "user is not exist";
      break;
  case ExceptionCodeConstants.UserExceptionCode.USER_PASSWORD_ERROR:
      msgTip = "user password error";
      break;
  case ExceptionCodeConstants.UserExceptionCode.BLACK_USER:
      msgTip = "user is black";
      break;
  case ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION:
      msgTip = "access service error";
      break;
  default:
      try {
   msgTip = "user can login";
   //验证通过 可以登录放入session记录登录日志
   user = userService.getUserByUserName(username);
   request.getSession().setAttribute("user",user);
   if(user.getTenantId()!=null) {
Tenant tenant = tenantService.getTenantByTenantId(user.getTenantId());
if(tenant!=null) {
    Long tenantId = tenant.getTenantId();
    Integer userNumLimit = tenant.getUserNumLimit();
    Integer billsNumLimit = tenant.getBillsNumLimit();
    if(tenantId!=null) {
 request.getSession().setAttribute("tenantId",tenantId); //租户tenantId
 request.getSession().setAttribute("userNumLimit",userNumLimit); //用户限制数
 request.getSession().setAttribute("billsNumLimit",billsNumLimit); //单据限制数
    }
}
   }
   logService.insertLog("用户",
    new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_LOGIN).append(user.getId()).toString(),
    ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
      } catch (Exception e) {
   e.printStackTrace();
   logger.error(">>>>>>>>>>>>>>>查询用户名为:" + username + " 用户信息异常", e);
      }
      break;
     }
     Map data = new HashMap();
     data.put("msgTip", msgTip);
     
     if(user!=null){
  data.put("user",user);
     }
     res.code = 200;
     res.data = data;
     logger.info("===============用户登录 login 方法调用结束===============");
 } catch(Exception e){
     e.printStackTrace();
     logger.error(e.getMessage());
     res.code = 500;
     res.data = "用户登录失败";
 }
 return res;
    }

    @GetMapping(value = "/getUserSession")
    public baseResponseInfo getSessionUser(HttpServletRequest request)throws Exception {
 baseResponseInfo res = new baseResponseInfo();
 try {
     Map data = new HashMap();
     Object userInfo = request.getSession().getAttribute("user");
     if(userInfo!=null) {
  User user = (User) userInfo;
  user.setPassword(null);
  data.put("user", user);
     }
     res.code = 200;
     res.data = data;
 } catch(Exception e){
     e.printStackTrace();
     res.code = 500;
     res.data = "获取session失败";
 }
 return res;
    }

    @GetMapping(value = "/logout")
    public baseResponseInfo logout(HttpServletRequest request, HttpServletResponse response)throws Exception {
 baseResponseInfo res = new baseResponseInfo();
 try {
     request.getSession().removeAttribute("user");
     request.getSession().removeAttribute("tenantId");
     request.getSession().removeAttribute("userNumLimit");
     request.getSession().removeAttribute("billsNumLimit");
     response.sendRedirect("/login.html");
 } catch(Exception e){
     e.printStackTrace();
     res.code = 500;
     res.data = "退出失败";
 }
 return res;
    }

    @PostMapping(value = "/resetPwd")
    public String resetPwd(@RequestParam("id") Long id,
  HttpServletRequest request) throws Exception {
 Map objectMap = new HashMap();
 String password = "123456";
 String md5Pwd = Tools.md5Encryp(password);
 int update = userService.resetPwd(md5Pwd, id);
 if(update > 0) {
     return returnJson(objectMap, message, ErpInfo.OK.code);
 } else {
     return returnJson(objectMap, message, ErpInfo.ERROR.code);
 }
    }

    @PostMapping(value = "/updatePwd")
    public String updatePwd(@RequestParam("userId") Long userId, @RequestParam("password") String password,
@RequestParam("oldpwd") String oldpwd, HttpServletRequest request)throws Exception {
 Integer flag = 0;
 Map objectMap = new HashMap();
 try {
     User user = userService.getUser(userId);
     String oldPassword = Tools.md5Encryp(oldpwd);
     String md5Pwd = Tools.md5Encryp(password);
     //必须和原始密码一致才可以更新密码
     if(user.getLoginame().equals("jsh")){
  flag = 3; //管理员jsh不能修改密码
     } else if (oldPassword.equalsIgnoreCase(user.getPassword())) {
  user.setPassword(md5Pwd);
  flag = userService.updateUserByObj(user); //1-成功
     } else {
  flag = 2; //原始密码输入错误
     }
     objectMap.put("status", flag);
     if(flag > 0) {
  return returnJson(objectMap, message, ErpInfo.OK.code);
     } else {
  return returnJson(objectMap, message, ErpInfo.ERROR.code);
     }
 } catch (Exception e) {
     logger.error(">>>>>>>>>>>>>修改用户ID为  " + userId + "密码信息失败", e);
     flag = 3;
     objectMap.put("status", flag);
     return returnJson(objectMap, message, ErpInfo.ERROR.code);
 }
    }

    
    @GetMapping(value = "/getAllList")
    public baseResponseInfo getAllList(HttpServletRequest request)throws Exception {
 baseResponseInfo res = new baseResponseInfo();
 try {
     Map data = new HashMap();
     List dataList = userService.getUser();
     if(dataList!=null) {
  data.put("userList", dataList);
     }
     res.code = 200;
     res.data = data;
 } catch(Exception e){
     e.printStackTrace();
     res.code = 500;
     res.data = "获取失败";
 }
 return res;
    }
    
    @GetMapping(value = "/getUserList")
    public String getUserList(@RequestParam(value = Constants.PAGE_SIZE, required = false) Integer pageSize,
    @RequestParam(value = Constants.CURRENT_PAGE, required = false) Integer currentPage,
    @RequestParam(value = Constants.SEARCH, required = false) String search)throws Exception {

 Map parameterMap = new HashMap();
 //查询参数
 JSonObject obj= JSON.parseObject(search);
 Set key= obj.keySet();
 for(String keyEach: key){
     parameterMap.put(keyEach,obj.getString(keyEach));
 }
 PageQueryInfo queryInfo = new PageQueryInfo();
 Map objectMap = new HashMap();
 if (pageSize == null || pageSize <= 0) {
     pageSize = BusinessConstants.DEFAULT_PAGINATION_PAGE_SIZE;
 }
 if (currentPage == null || currentPage <= 0) {
     currentPage = BusinessConstants.DEFAULT_PAGINATION_PAGE_NUMBER;
 }
 PageHelper.startPage(currentPage,pageSize,true);
 List list = userService.getUserList(parameterMap);
 //获取分页查询后的数据
 PageInfo pageInfo = new PageInfo<>(list);
 objectMap.put("page", queryInfo);
 if (list == null) {
     queryInfo.setRows(new ArrayList());
     queryInfo.setTotal(BusinessConstants.DEFAULT_LIST_NULL_NUMBER);
     return returnJson(objectMap, "查找不到数据", ErpInfo.OK.code);
 }
 queryInfo.setRows(list);
 queryInfo.setTotal(pageInfo.getTotal());
 return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
    }

    
    @PostMapping("/addUser")
    @ResponseBody
    public Object addUser(@RequestParam("info") String beanJson, HttpServletRequest request)throws Exception{
 JSonObject result = ExceptionConstants.standardSuccess();
 Long userNumLimit = Long.parseLong(request.getSession().getAttribute("userNumLimit").toString());
 Long count = userService.countUser(null,null);
 if(count>= userNumLimit) {
     throw new BusinessParamCheckingException(ExceptionConstants.USER_OVER_LIMIT_FAILED_CODE,
      ExceptionConstants.USER_OVER_LIMIT_FAILED_MSG);
 } else {
     UserEx ue= JSON.parseObject(beanJson, UserEx.class);
     userService.addUserAndOrgUserRel(ue);
 }
 return result;
    }


    
    @PostMapping(value = "/registerUser")
    public Object registerUser(@RequestParam(value = "loginame", required = false) String loginame,
   @RequestParam(value = "password", required = false) String password,
   HttpServletRequest request)throws Exception{
 JSonObject result = ExceptionConstants.standardSuccess();
 UserEx ue= new UserEx();
 ue.setUsername(loginame);
 ue.setLoginame(loginame);
 ue.setPassword(password);
 userService.checkUserNameAndLoginName(ue); //检查用户名和登录名
 ue = userService.registerUser(ue,manageRoleId,request);
 return result;
    }
    
    @PostMapping("/updateUser")
    @ResponseBody
    public Object updateUser(@RequestParam("info") String beanJson,@RequestParam("id") Long id)throws Exception{
 JSonObject result = ExceptionConstants.standardSuccess();
 UserEx ue= JSON.parseObject(beanJson, UserEx.class);
 ue.setId(id);
 userService.updateUserAndOrgUserRel(ue);
 return result;
    }
    @PostMapping("/deleteUser")
    @ResponseBody
    public Object deleteUser(@RequestParam("ids") String ids)throws Exception{
 JSonObject result = ExceptionConstants.standardSuccess();
 userService.batDeleteUser(ids);
 return result;
    }
    @PostMapping("/batchDeleteUser")
    @ResponseBody
    public Object batchDeleteUser(@RequestParam("ids") String ids)throws Exception{
 JSonObject result = ExceptionConstants.standardSuccess();
 userService.batDeleteUser(ids);
 return result;
    }
    @RequestMapping("/getOrganizationUserTree")
    public JSonArray getOrganizationUserTree()throws Exception{
 JSonArray arr=new JSONArray();
 List organizationUserTree= userService.getOrganizationUserTree();
 if(organizationUserTree!=null&&organizationUserTree.size()>0){
     for(TreeNodeEx node:organizationUserTree){
  String str=JSON.toJSONString(node);
  JSonObject obj=JSON.parseObject(str);
  arr.add(obj) ;
     }
 }
 return arr;
    }
}

账户管理
package com.jsh.erp.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.Account;
import com.jsh.erp.datasource.vo.AccountVo4InOutList;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.account.AccountService;
import com.jsh.erp.utils.baseResponseInfo;
import com.jsh.erp.utils.ErpInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;


@RestController
@RequestMapping(value = "/account")
public class AccountController {
    private Logger logger = LoggerFactory.getLogger(AccountController.class);

    @Resource
    private AccountService accountService;

    
    @GetMapping(value = "/findBySelect")
    public String findBySelect(HttpServletRequest request) throws Exception {
 String res = null;
 try {
     List dataList = accountService.findBySelect();
     //存放数据json数组
     JSonArray dataArray = new JSONArray();
     if (null != dataList) {
  for (Account account : dataList) {
      JSonObject item = new JSONObject();
      item.put("Id", account.getId());
      //结算账户名称
      item.put("AccountName", account.getName());
      dataArray.add(item);
  }
     }
     res = dataArray.toJSONString();
 } catch(Exception e){
     e.printStackTrace();
     res = "获取数据失败";
 }
 return res;
    }

    
    @GetMapping(value = "/getAccount")
    public baseResponseInfo getAccount(HttpServletRequest request) throws Exception {
 baseResponseInfo res = new baseResponseInfo();
 Map map = new HashMap();
 try {
     List accountList = accountService.getAccount();
     map.put("accountList", accountList);
     res.code = 200;
     res.data = map;
 } catch(Exception e){
     e.printStackTrace();
     res.code = 500;
     res.data = "获取数据失败";
 }
 return res;
    }

    
    @GetMapping(value = "/findAccountInOutList")
    public baseResponseInfo findAccountInOutList(@RequestParam("currentPage") Integer currentPage,
@RequestParam("pageSize") Integer pageSize,
@RequestParam("accountId") Long accountId,
@RequestParam("initialAmount") BigDecimal initialAmount,
HttpServletRequest request) throws Exception{
 baseResponseInfo res = new baseResponseInfo();
 Map map = new HashMap();
 try {
     List dataList = accountService.findAccountInOutList(accountId, (currentPage-1)*pageSize, pageSize);
     int total = accountService.findAccountInOutListCount(accountId);
     map.put("total", total);
     //存放数据json数组
     JSonArray dataArray = new JSONArray();
     if (null != dataList) {
  for (AccountVo4InOutList aEx : dataList) {
      String timeStr = aEx.getOperTime().toString();
      BigDecimal balance = accountService.getAccountSum(accountId, timeStr, "date").add(accountService.getAccountSumByHead(accountId, timeStr, "date"))
.add(accountService.getAccountSumByDetail(accountId, timeStr, "date")).add(accountService.getManyAccountSum(accountId, timeStr, "date")).add(initialAmount);
      aEx.setBalance(balance);
      dataArray.add(aEx);
  }
     }
     map.put("rows", dataArray);
     res.code = 200;
     res.data = map;
 } catch(Exception e){
     e.printStackTrace();
     res.code = 500;
     res.data = "获取数据失败";
 }
 return res;
    }


    @PostMapping(value = "/updateAmountIsDefault")
    public String updateAmountIsDefault(@RequestParam("isDefault") Boolean isDefault,
     @RequestParam("accountId") Long accountId,
     HttpServletRequest request) throws Exception{
 Map objectMap = new HashMap();
 int res = accountService.updateAmountIsDefault(isDefault, accountId);
 if(res > 0) {
     return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
 } else {
     return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
 }
    }
    
    @RequestMapping(value = "/batchDeleteAccountByIds")
    public Object batchDeleteAccountByIds(@RequestParam("ids") String ids,@RequestParam(value="deleteType",
     required =false,defaultValue=BusinessConstants.DELETE_TYPE_NORMAL)String deleteType) throws Exception {

 JSonObject result = ExceptionConstants.standardSuccess();
 
 int i=0;
 if(BusinessConstants.DELETE_TYPE_NORMAL.equals(deleteType)){
      i= accountService.batchDeleteAccountByIdsNormal(ids);
 }else if(BusinessConstants.DELETE_TYPE_FORCE.equals(deleteType)){
      i= accountService.batchDeleteAccountByIds(ids);
 }else{
     logger.error("异常码[{}],异常提示[{}],参数,ids[{}],deleteType[{}]",
      ExceptionConstants.DELETE_REFUSED_CODE,ExceptionConstants.DELETE_REFUSED_MSG,ids,deleteType);
     throw new BusinessRunTimeException(ExceptionConstants.DELETE_REFUSED_CODE,
      ExceptionConstants.DELETE_REFUSED_MSG);
 }
 if(i<1){
     logger.error("异常码[{}],异常提示[{}],参数,ids[{}]",
      ExceptionConstants.ACCOUNT_DELETE_FAILED_CODE,ExceptionConstants.ACCOUNT_DELETE_FAILED_MSG,ids);
     throw new BusinessRunTimeException(ExceptionConstants.ACCOUNT_DELETE_FAILED_CODE,
      ExceptionConstants.ACCOUNT_DELETE_FAILED_MSG);
 }
 return result;
    }

}

10 如何使用
  1. 下载代码后解压缩
  2. 导入
  • 将项目导入到开发工具当中
  • 配置maven因为我是直接从我工程中打包的里面含有我本地的maven配置,所以需要重新配置一下
  • 导入sql到MySQL当中修改application.properties中的数据源信息和你自己的对应上就可以了
  • 启动之后会有网址访问提示直接访问就ok。默认用户名密码admin/123456

演示地址仓库ERP管理系统springboot

说明此源码来源于网络若有侵权请联系删除

转载请注明:文章转载自 www.mshxw.com
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号