基于javaweb+mysql的springboot进销存管理系统(前后端分离+java+vue+springboot+ssm+mysql+maven+redis)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Node.js≥10
开发工具
后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SpringBoot进销存管理系统(前后端分离+java+vue+springboot+ssm+mysql+maven+redis)
一、项目简述
本系统功能包括: 库存管理,入库管理,出库管理,往来管理,基础资料, 系统管理,消息中心,系统监控等等。
二、项目运行
环境配置: Jdk1.8 + Mysql + HBuilderX ( Webstorm也 行)+ Eclispe ( IntelliJ IDEA ,Eclispe,MyEclispe , Sts都支持)。
项目技术: Springboot + Maven + Mybatis-plus+ Vue + Redis + Shiro + Druid + logback 组成,B/S模萤;,其他:fastjson, poi, Swagger-ui, quartz, lombok (简化代码)等
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}
}
}
@Override
public void sendWebSocketMsg(String[] userIds, String cmd) {
JSONObject obj = new JSONObject();
obj.put(WebsocketConst.MSG_CMD, cmd);
webSocket.sendMoreMessage(userIds, obj.toJSONString());
}
@Override
public List<LoginUser> queryAllUserByIds(String[] userIds) {
QueryWrapper<SysUser> queryWrapper = new QueryWrapper<SysUser>().eq("status",1).eq("del_flag",0);
queryWrapper.in("id",userIds);
List<LoginUser> loginUsers = new ArrayList<>();
List<SysUser> sysUsers = userMapper.selectList(queryWrapper);
for (SysUser user:sysUsers) {
LoginUser loginUser=new LoginUser();
BeanUtils.copyProperties(user, loginUser);
loginUsers.add(loginUser);
}
return loginUsers;
}
/**
* 推送签到人员信息
* @param userId
*/
@Override
public void meetingSignWebsocket(String userId) {
JSONObject obj = new JSONObject();
result.error500("未找到对应用户!");
}else {
SysUser user = JSON.parseObject(jsonObject.toJSONString(), SysUser.class);
user.setUpdateTime(new Date());
user.setPassword(sysUser.getPassword());
sysUserService.updateById(user);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
result.error500("操作失败!");
}
return result;
}
}
*/
@Slf4j
@RestController
@RequestMapping("/sys/user")
public class SysUserController {
@Autowired
private ISysBaseAPI sysBaseAPI;
@Autowired
private ISysUserService sysUserService;
@Autowired
private ISysDepartService sysDepartService;
@Autowired
private ISysUserRoleService sysUserRoleService;
@Autowired
private ISysUserDepartService sysUserDepartService;
@Autowired
private ISysUserRoleService userRoleService;
@Autowired
private ISysDepartRoleUserService departRoleUserService;
@Autowired
private ISysDepartRoleService departRoleService;
@Autowired
private RedisUtil redisUtil;
@Value("${jeecg.path.upload}")
private String upLoadPath;
/**
* 获取用户列表数据
* @param user
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@PermissionData(pageComponent = "system/UserList")
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Result<IPage<SysUser>> queryPageList(SysUser user,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,HttpServletRequest req) {
Result<IPage<SysUser>> result = new Result<IPage<SysUser>>();
QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(user, req.getParameterMap());
@RequestMapping(value = "/loadDict/{dictCode}", method = RequestMethod.GET)
public Result<List<DictModel>> loadDict(@PathVariable String dictCode,@RequestParam(name="keyword") String keyword, @RequestParam(value = "sign",required = false) String sign,HttpServletRequest request) {
log.info(" 加载字典表数据,加载关键字: "+ keyword);
Result<List<DictModel>> result = new Result<List<DictModel>>();
List<DictModel> ls = null;
try {
if(dictCode.indexOf(",")!=-1) {
String[] params = dictCode.split(",");
if(params.length!=3) {
result.error500("字典Code格式不正确!");
return result;
}
ls = sysDictService.queryTableDictItems(params[0],params[1],params[2],keyword);
result.setSuccess(true);
result.setResult(ls);
log.info(result.toString());
}else {
result.error500("字典Code格式不正确!");
}
} catch (Exception e) {
log.error(e.getMessage(),e);
result.error500("操作失败");
return result;
}
return result;
}
/**
* 根据字典code加载字典text 返回
*/
@RequestMapping(value = "/loadDictItem/{dictCode}", method = RequestMethod.GET)
public Result<List<String>> loadDictItem(@PathVariable String dictCode,@RequestParam(name="key") String key, @RequestParam(value = "sign",required = false) String sign,HttpServletRequest request) {
Result<List<String>> result = new Result<>();
try {
if(dictCode.indexOf(",")!=-1) {
String[] params = dictCode.split(",");
if(params.length!=3) {
result.error500("字典Code格式不正确!");
return result;
}
List<String> texts = sysDictService.queryTableDictByKeys(params[0], params[1], params[2], key.split(","));
/**
* @Description: 部门权限表
* @Version: V1.0
*/
@Slf4j
@Api(tags="部门权限表")
@RestController
@RequestMapping("/sys/sysDepartPermission")
public class SysDepartPermissionController extends JeecgController<SysDepartPermission, ISysDepartPermissionService> {
@Autowired
private ISysDepartPermissionService sysDepartPermissionService;
@Autowired
private ISysPermissionDataRuleService sysPermissionDataRuleService;
@Autowired
private ISysPermissionService sysPermissionService;
@Autowired
private ISysDepartRolePermissionService sysDepartRolePermissionService;
/**
* 分页列表查询
*/
@AutoLog(value = "往来核销单-编辑")
@ApiOperation(value="往来核销单-编辑", notes="往来核销单-编辑")
@PutMapping(value = "/edit")
public Result<?> edit(@RequestBody FinReceivableCheckPage finReceivableCheckPage) {
FinReceivableCheck finReceivableCheck = new FinReceivableCheck();
BeanUtils.copyProperties(finReceivableCheckPage, finReceivableCheck);
FinReceivableCheck finReceivableCheckEntity = finReceivableCheckService.getById(finReceivableCheck.getId());
if(finReceivableCheckEntity==null) {
return Result.error("未找到对应数据");
}
finReceivableCheckService.updateMain(finReceivableCheck, finReceivableCheckPage.getFinReceivableCheckEntryList());
return Result.ok("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "往来核销单-通过id删除")
@ApiOperation(value="往来核销单-通过id删除", notes="往来核销单-通过id删除")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
finReceivableCheckService.delMain(id);
return Result.ok("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "往来核销单-批量删除")
@ApiOperation(value="往来核销单-批量删除", notes="往来核销单-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.finReceivableCheckService.delBatchMain(Arrays.asList(ids.split(",")));
return Result.ok("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
/**
* @Description: 底层共通业务API,提供其他独立模块调用
* @Version:V1.0
*/
@Slf4j
@Service
public class SysBaseApiImpl implements ISysBaseAPI {
/** 当前系统数据库类型 */
private static String DB_TYPE = "";
@Autowired
private ISysMessageTemplateService sysMessageTemplateService;
return Result.ok("删除用户成功");
}
/**
* 批量删除用户
*/
//@RequiresRoles({"admin"})
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
sysBaseAPI.addLog("批量删除用户, ids: " +ids ,CommonConstant.LOG_TYPE_2, 3);
this.sysUserService.deleteBatchUsers(ids);
return Result.ok("批量删除用户成功");
}
/**
* 冻结&解冻用户
* @param jsonObject
* @return
*/
//@RequiresRoles({"admin"})
@RequestMapping(value = "/frozenBatch", method = RequestMethod.PUT)
public Result<SysUser> frozenBatch(@RequestBody JSONObject jsonObject) {
Result<SysUser> result = new Result<SysUser>();
try {
String ids = jsonObject.getString("ids");
String status = jsonObject.getString("status");
String[] arr = ids.split(",");
for (String id : arr) {
if(oConvertUtils.isNotEmpty(id)) {
this.sysUserService.update(new SysUser().setStatus(Integer.parseInt(status)),
new UpdateWrapper<SysUser>().lambda().eq(SysUser::getId,id));
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
result.error500("操作失败"+e.getMessage());
}
result.success("操作成功!");
return result;
}
@RequestMapping(value = "/queryById", method = RequestMethod.GET)
public Result<SysUser> queryById(@RequestParam(name = "id", required = true) String id) {
Result<SysUser> result = new Result<SysUser>();
SysUser sysUser = sysUserService.getById(id);
List<SysAnnouncement> listSysAnnouncements = ExcelImportUtil.importExcel(file.getInputStream(), SysAnnouncement.class, params);
for (SysAnnouncement sysAnnouncementExcel : listSysAnnouncements) {
if(sysAnnouncementExcel.getDelFlag()==null){
sysAnnouncementExcel.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
}
sysAnnouncementService.save(sysAnnouncementExcel);
}
return Result.ok("文件导入成功!数据行数:" + listSysAnnouncements.size());
} catch (Exception e) {
log.error(e.getMessage(),e);
return Result.error("文件导入失败!");
} finally {
try {
file.getInputStream().close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return Result.error("文件导入失败!");
}
/**
*同步消息
* @param anntId
* @return
*/
@RequestMapping(value = "/syncNotic", method = RequestMethod.GET)
public Result<SysAnnouncement> syncNotic(@RequestParam(name="anntId",required=false) String anntId, HttpServletRequest request) {
Result<SysAnnouncement> result = new Result<SysAnnouncement>();
JSONObject obj = new JSONObject();
if(StringUtils.isNotBlank(anntId)){
SysAnnouncement sysAnnouncement = sysAnnouncementService.getById(anntId);
if(sysAnnouncement==null) {
result.error500("未找到对应实体");
}else {
if(sysAnnouncement.getMsgType().equals(CommonConstant.MSG_TYPE_ALL)) {
obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_TOPIC);
obj.put(WebsocketConst.MSG_ID, sysAnnouncement.getId());
obj.put(WebsocketConst.MSG_TXT, sysAnnouncement.getTitile());
webSocket.sendAllMessage(obj.toJSONString());
}else {
// 2.插入用户通告阅读标记表记录
String userId = sysAnnouncement.getUserIds();
if(oConvertUtils.isNotEmpty(userId)){
String[] userIds = userId.substring(0, (userId.length()-1)).split(",");
obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_USER);
obj.put(WebsocketConst.MSG_ID, sysAnnouncement.getId());
obj.put(WebsocketConst.MSG_TXT, sysAnnouncement.getTitile());
webSocket.sendMoreMessage(userIds, obj.toJSONString());
return result.substring(0, result.length() - 1);
}
//update-begin--Author:zhoujf Date:20180503 for:TASK #2500 【代码生成器】代码生成器开发一通用模板生成功能
/**
* 将下划线大写方式命名的字符串转换为驼峰式。(首字母写)
* 如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。</br>
* 例如:hello_world->HelloWorld
*
* @param name
* 转换前的下划线大写方式命名的字符串
* @return 转换后的驼峰式命名的字符串
*/
public static String camelNameCapFirst(String name) {
StringBuilder result = new StringBuilder();
// 快速检查
if (name == null || name.isEmpty()) {
// 没必要转换
return "";
} else if (!name.contains("_")) {
// 不含下划线,仅将首字母小写
return name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase();
}
// 用下划线将原始字符串分割
String camels[] = name.split("_");
for (String camel : camels) {
// 跳过原始字符串中开头、结尾的下换线或双重下划线
if (camel.isEmpty()) {
continue;
}
// 其他的驼峰片段,首字母大写
result.append(camel.substring(0, 1).toUpperCase());
result.append(camel.substring(1).toLowerCase());
}
return result.toString();
}
//update-end--Author:zhoujf Date:20180503 for:TASK #2500 【代码生成器】代码生成器开发一通用模板生成功能
/**
* 将驼峰命名转化成下划线
* @param para
* @return
*/
public static String camelToUnderline(String para){
if(para.length()<3){
return para.toLowerCase();
}
StringBuilder sb=new StringBuilder(para);
int temp=0;//定位
//从第三个字符开始 避免命名不规范
for(int i=2;i<para.length();i++){
/**
* @Description: 部门权限表
* @Version: V1.0
*/
@Slf4j
@Api(tags="部门权限表")
@RestController
@RequestMapping("/sys/sysDepartPermission")
public class SysDepartPermissionController extends JeecgController<SysDepartPermission, ISysDepartPermissionService> {
@Autowired
private ISysDepartPermissionService sysDepartPermissionService;
@Autowired
private ISysPermissionDataRuleService sysPermissionDataRuleService;
@Autowired
private ISysPermissionService sysPermissionService;
@Autowired
private ISysDepartRolePermissionService sysDepartRolePermissionService;
/**
* 分页列表查询
*
* @param sysDepartPermission
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@ApiOperation(value="部门权限表-分页列表查询", notes="部门权限表-分页列表查询")
@GetMapping(value = "/list")
public Result<?> queryPageList(SysDepartPermission sysDepartPermission,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<SysDepartPermission> queryWrapper = QueryGenerator.initQueryWrapper(sysDepartPermission, req.getParameterMap());
Page<SysDepartPermission> page = new Page<SysDepartPermission>(pageNo, pageSize);
List<String> ids = new ArrayList<>();
try {
LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
query.orderByAsc(SysPermission::getSortNo);
List<SysPermission> list = sysPermissionService.list(query);
for(SysPermission sysPer : list) {
ids.add(sysPer.getId());
}
List<TreeModel> treeList = new ArrayList<>();
getTreeModelList(treeList, list, null);
Map<String,Object> resMap = new HashMap<String,Object>();
resMap.put("treeList", treeList); //全部树节点数据
resMap.put("ids", ids);//全部树ids
result.setResult(resMap);
result.setSuccess(true);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return result;
}
private void getTreeModelList(List<TreeModel> treeList,List<SysPermission> metaList,TreeModel temp) {
for (SysPermission permission : metaList) {
String tempPid = permission.getParentId();
TreeModel tree = new TreeModel(permission.getId(), tempPid, permission.getName(),permission.getRuleFlag(), permission.isLeaf());
if(temp==null && oConvertUtils.isEmpty(tempPid)) {
treeList.add(tree);
if(!tree.getIsLeaf()) {
getTreeModelList(treeList, metaList, tree);
}
}else if(temp!=null && tempPid!=null && tempPid.equals(temp.getKey())){
temp.getChildren().add(tree);
if(!tree.getIsLeaf()) {
getTreeModelList(treeList, metaList, tree);
}
}
}
}
}
return Result.error("请先保存角色菜单权限!");
}else {
sysRolePermission.setDataRuleIds(dataRuleIds);
this.sysRolePermissionService.updateById(sysRolePermission);
}
} catch (Exception e) {
log.error("SysRoleController.saveDatarule()发生异常:" + e.getMessage(),e);
return Result.error("保存失败");
}
return Result.ok("保存成功!");
}
/**
* 用户角色授权功能,查询菜单权限树
* @param request
* @return
*/
@RequestMapping(value = "/queryTreeList", method = RequestMethod.GET)
public Result<Map<String,Object>> queryTreeList(HttpServletRequest request) {
Result<Map<String,Object>> result = new Result<>();
//全部权限ids
List<String> ids = new ArrayList<>();
try {
LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
query.orderByAsc(SysPermission::getSortNo);
List<SysPermission> list = sysPermissionService.list(query);
for(SysPermission sysPer : list) {
ids.add(sysPer.getId());
}
List<TreeModel> treeList = new ArrayList<>();
getTreeModelList(treeList, list, null);
Map<String,Object> resMap = new HashMap<String,Object>();
resMap.put("treeList", treeList); //全部树节点数据
resMap.put("ids", ids);//全部树ids
result.setResult(resMap);
result.setSuccess(true);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return result;
}
if(!tree.getIsLeaf()) {
getTreeModelList(treeList, metaList, tree);
}
}else if(temp!=null && tempPid!=null && tempPid.equals(temp.getKey())){
temp.getChildren().add(tree);
if(!tree.getIsLeaf()) {
getTreeModelList(treeList, metaList, tree);
}
}
}
}
}
/**
* <p>
* 用户表 前端控制器
* </p>
*
/**
* @Description: 销售发票登记
* @Version: V1.0
*/
@Api(tags="销售发票登记")
@RestController
@RequestMapping("/finance/finSalInvoice")
@Slf4j
public class FinSalInvoiceController {
@Autowired
private IFinSalInvoiceService finSalInvoiceService;
@Autowired
@AutoLog(value = "往来核销单-通过id查询")
@ApiOperation(value="往来核销单-通过id查询", notes="往来核销单-通过id查询")
@GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
FinReceivableCheck finReceivableCheck = finReceivableCheckService.getById(id);
if(finReceivableCheck==null) {
return Result.error("未找到对应数据");
}
return Result.ok(finReceivableCheck);
}
/**
* 通过id查询
*
* @param id
* @return
*/
@AutoLog(value = "往来核销明细集合-通过id查询")
@ApiOperation(value="往来核销明细集合-通过id查询", notes="往来核销明细-通过id查询")
@GetMapping(value = "/queryFinReceivableCheckEntryByMainId")
public Result<?> queryFinReceivableCheckEntryListByMainId(@RequestParam(name="id",required=true) String id) {
List<FinReceivableCheckEntry> finReceivableCheckEntryList = finReceivableCheckEntryService.selectByMainId(id);
return Result.ok(finReceivableCheckEntryList);
}
/**
* 导出excel
*
* @param request
* @param finReceivableCheck
*/
@RequestMapping(value = {"/exportXls", "/exportXls/{receivableCheckType}"})
public ModelAndView exportXls(HttpServletRequest request, FinReceivableCheck finReceivableCheck) {
// Step.1 组装查询条件查询数据
QueryWrapper<FinReceivableCheck> queryWrapper = QueryGenerator.initQueryWrapper(finReceivableCheck, request.getParameterMap());
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
//Step.2 获取导出数据
List<FinReceivableCheck> queryList = finReceivableCheckService.list(queryWrapper);
// 过滤选中数据
String selections = request.getParameter("selections");
List<FinReceivableCheck> finReceivableCheckList = new ArrayList<FinReceivableCheck>();
if(oConvertUtils.isEmpty(selections)) {
finReceivableCheckList = queryList;
}else {
List<String> selectionList = Arrays.asList(selections.split(","));
/**
* 添加
* @param sysCategory
* @return
*/
@PostMapping(value = "/add")
public Result<SysCategory> add(@RequestBody SysCategory sysCategory) {
Result<SysCategory> result = new Result<SysCategory>();
try {
sysCategoryService.addSysCategory(sysCategory);
result.success("添加成功!");
} catch (Exception e) {
log.error(e.getMessage(),e);
result.error500("操作失败");
}
return result;
}
/**
* 编辑
* @param sysCategory
* @return
*/
@PutMapping(value = "/edit")
public Result<SysCategory> edit(@RequestBody SysCategory sysCategory) {
Result<SysCategory> result = new Result<SysCategory>();
SysCategory sysCategoryEntity = sysCategoryService.getById(sysCategory.getId());
if(sysCategoryEntity==null) {
result.error500("未找到对应实体");
}else {
sysCategoryService.updateSysCategory(sysCategory);
result.success("修改成功!");
}
return result;
}
/**
* 通过id删除
* @param id
* @return
*/
@DeleteMapping(value = "/delete")
public Result<SysCategory> delete(@RequestParam(name="id",required=true) String id) {
Result<SysCategory> result = new Result<SysCategory>();
SysCategory sysCategory = sysCategoryService.getById(id);
if(sysCategory==null) {
result.error500("未找到对应实体");
}else {
boolean ok = sysCategoryService.removeById(id);
if(ok) {
result.success("删除成功!");