作者主页:源码空间站2022
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
项目介绍
系统主要功能包括:
首页
零售管理:零售出库、零售退货;
采购管理:采购订单、采购入库、采购退货;
销售管理:销售订单、销售出库、销售退货;
仓库管理:其它入库、其它出库、调拨出库、组装单、拆卸单;
财务管理:收入单、支出单、收款单、付款单、转账单、收预付款;
报表查询:库存状况、结算账户、进货统计、销售统计、入库明细、出库明细、入库汇总、出库汇总、客户对账、供应商对账、库存预警;
商品管理:商品类别、商品信息、计量单位、序列号;
基本资料:供应商信息、客户信息、会员信息、仓库信息、收支项目、结算账户、经手人管理;
系统管理:角色管理、机构管理、用户管理、日志管理、系统配置;
环境需要
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.数据库:MySql 5.7或8.0版本;
6.是否Maven项目:是;
技术栈
* 核心框架:SpringBoot 2.0.0
* 持久层框架:Mybatis 1.3.2
* 日志管理:Log4j 2.10.0
* JS框架:Jquery 1.8.0
* UI框架: EasyUI 1.3.5
* 模板框架: AdminLTE 2.4.0
* 项目管理框架: Maven 3.2.3
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中application.properties配置文件中的数据库配置改为自己的配置;
4. 运行com.jsh.erp包中的ErpApplication类,启动项目。(使用SpringBoot的启动方式)
5. 浏览器地址访问登录页面http://localhost:8080/login.html
默认管理员账号:admin,管理员账号一些特殊模块不具有修改权限,建议使用普通账号:jsh,密码都为123456
运行截图
代码相关
人员前端控制器
@RestController
@RequestMapping(value = "/person")
public class PersonController {
private Logger logger = LoggerFactory.getLogger(PersonController.class);
@Resource
private PersonService personService;
@GetMapping(value = "/getAllList")
public BaseResponseInfo getAllList(HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
List<Person> personList = personService.getPerson();
map.put("personList", personList);
res.code = 200;
res.data = personList;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
/**
* 根据Id获取经手人信息
* @param personIDs
* @param request
* @return
*/
@GetMapping(value = "/getPersonByIds")
public BaseResponseInfo getPersonByIds(@RequestParam("personIDs") String personIDs,
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
String names = personService.getPersonByIds(personIDs);
map.put("names", names);
res.code = 200;
res.data = map;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
/**
* 根据类型获取经手人信息
* @param type
* @param request
* @return
*/
@GetMapping(value = "/getPersonByType")
public BaseResponseInfo getPersonByType(@RequestParam("type") String type,
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
List<Person> personList = personService.getPersonByType(type);
map.put("personList", personList);
res.code = 200;
res.data = map;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
/**
* 根据类型获取经手人信息 1-业务员,2-仓管员,3-财务员
* @param typeNum
* @param request
* @return
*/
@PostMapping(value = "/getPersonByNumType")
public JSONArray getPersonByNumType(@RequestParam("type") String typeNum,
HttpServletRequest request)throws Exception {
JSONArray dataArray = new JSONArray();
try {
String type = "";
if (typeNum.equals("1")) {
type = "业务员";
} else if (typeNum.equals("2")) {
type = "仓管员";
} else if (typeNum.equals("3")) {
type = "财务员";
}
List<Person> personList = personService.getPersonByType(type);
if (null != personList) {
for (Person person : personList) {
JSONObject item = new JSONObject();
item.put("id", person.getId());
item.put("name", person.getName());
dataArray.add(item);
}
}
} catch(Exception e){
e.printStackTrace();
}
return dataArray;
}
/**
* create by: qiankunpingtai
* website:https://qiankunpingtai.cn
* description:
* 批量删除经手人信息
* create time: 2019/3/29 11:15
* @Param: ids
* @return java.lang.Object
*/
@RequestMapping(value = "/batchDeletePersonByIds")
public Object batchDeletePersonByIds(@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= personService.batchDeletePersonByIdsNormal(ids);
}else if(BusinessConstants.DELETE_TYPE_FORCE.equals(deleteType)){
i= personService.batchDeletePersonByIds(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.PERSON_DELETE_FAILED_CODE,ExceptionConstants.PERSON_DELETE_FAILED_MSG,ids);
throw new BusinessRunTimeException(ExceptionConstants.PERSON_DELETE_FAILED_CODE,
ExceptionConstants.PERSON_DELETE_FAILED_MSG);
}
return result;
}
}
用户前端控制器
@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 = "loginame", required = false) String loginame,
@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 = loginame.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 {
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<String, Object> data = new HashMap<String, Object>();
data.put("msgTip", msgTip);
/**
* 在IE模式下,无法获取到user数据,
* 在此处明确添加上user信息
* */
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<String, Object> data = new HashMap<String, Object>();
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<String, Object> objectMap = new HashMap<String, Object>();
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<String, Object> objectMap = new HashMap<String, Object>();
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);
}
}
/**
* 获取全部用户数据列表
* @param request
* @return
*/
@GetMapping(value = "/getAllList")
public BaseResponseInfo getAllList(HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
try {
Map<String, Object> data = new HashMap<String, Object>();
List<User> 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;
}
/**
* create by: cjl
* description:
* 查询分页用户列表
* create time: 2019/3/8 15:08
* @Param: pageSize
* @Param: currentPage
* @Param: search
* @return java.lang.String
*/
@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<String, Object> parameterMap = new HashMap<String, Object>();
//查询参数
JSONObject obj= JSON.parseObject(search);
Set<String> key= obj.keySet();
for(String keyEach: key){
parameterMap.put(keyEach,obj.getString(keyEach));
}
PageQueryInfo queryInfo = new PageQueryInfo();
Map<String, Object> objectMap = new HashMap<String, Object>();
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<UserEx> list = userService.getUserList(parameterMap);
//获取分页查询后的数据
PageInfo<UserEx> pageInfo = new PageInfo<>(list);
objectMap.put("page", queryInfo);
if (list == null) {
queryInfo.setRows(new ArrayList<Object>());
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);
}
/**
* create by: cjl
* description:
* 新增用户及机构和用户关系
* create time: 2019/3/8 16:06
* @Param: beanJson
* @return java.lang.Object
*/
@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;
}
/**
* 注册用户
* @param loginame
* @param password
* @return
* @throws Exception
*/
@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); //检查用户名和登录名
userService.registerUser(ue,manageRoleId,request);
return result;
}
/**
* create by: cjl
* description:
* 修改用户及机构和用户关系
* create time: 2019/3/8 16:06
* @Param: beanJson
* @return java.lang.Object
*/
@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<TreeNodeEx> 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;
}
}
如果也想学习本系统,下面领取。回复:091springboot