本篇文章为大家展示了如何用Java代码实现进销存管理系统,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。
一、项目简述
本系统功能包括: 库存管理,入库管理,出库管理,往来管理,基础资料, 系统管理,消息中心,系统监控等等。
二、项目运行
环境配置: Jdk1.8 + Tomcat8.5 + 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 (简化代码)等
采购发票登记代码:
@Api(tags="采购发票登记")@RestController@RequestMapping("/finance/finPurInvoice")@Slf4jpublic class FinPurInvoiceController {@Autowiredprivate IFinPurInvoiceService finPurInvoiceService;@Autowiredprivate IFinPurInvoiceEntryService finPurInvoiceEntryService;@AutoLog(value = "采购发票登记-分页列表查询")@ApiOperation(value="采购发票登记-分页列表查询", notes="采购发票登记-分页列表查询")@GetMapping(value = {"/list", "/list/{isRubric}"})public Result<?> queryPageList(FinPurInvoice finPurInvoice, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req) {QueryWrapper<FinPurInvoice> queryWrapper = QueryGenerator.initQueryWrapper(finPurInvoice, req.getParameterMap());Page<FinPurInvoice> page = new Page<FinPurInvoice>(pageNo, pageSize);IPage<FinPurInvoice> pageList = finPurInvoiceService.page(page, queryWrapper);return Result.ok(pageList);}@AutoLog(value = "采购发票登记-添加")@ApiOperation(value="采购发票登记-添加", notes="采购发票登记-添加")@PostMapping(value = "/add")public Result<?> add(@RequestBody FinPurInvoicePage finPurInvoicePage) {FinPurInvoice finPurInvoice = new FinPurInvoice();BeanUtils.copyProperties(finPurInvoicePage, finPurInvoice);finPurInvoiceService.saveMain(finPurInvoice, finPurInvoicePage.getFinPurInvoiceEntryList());return Result.ok("添加成功!");}@AutoLog(value = "采购发票登记-编辑")@ApiOperation(value="采购发票登记-编辑", notes="采购发票登记-编辑")@PutMapping(value = "/edit")public Result<?> edit(@RequestBody FinPurInvoicePage finPurInvoicePage) {FinPurInvoice finPurInvoice = new FinPurInvoice();BeanUtils.copyProperties(finPurInvoicePage, finPurInvoice);FinPurInvoice finPurInvoiceEntity = finPurInvoiceService.getById(finPurInvoice.getId());if(finPurInvoiceEntity==null) {return Result.error("未找到对应数据");}finPurInvoiceService.updateMain(finPurInvoice, finPurInvoicePage.getFinPurInvoiceEntryList());return Result.ok("编辑成功!");}@AutoLog(value = "采购发票登记-通过id删除")@ApiOperation(value="采购发票登记-通过id删除", notes="采购发票登记-通过id删除")@DeleteMapping(value = "/delete")public Result<?> delete(@RequestParam(name="id",required=true) String id) {finPurInvoiceService.delMain(id);return Result.ok("删除成功!");}@AutoLog(value = "采购发票登记-批量删除")@ApiOperation(value="采购发票登记-批量删除", notes="采购发票登记-批量删除")@DeleteMapping(value = "/deleteBatch")public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {this.finPurInvoiceService.delBatchMain(Arrays.asList(ids.split(",")));return Result.ok("批量删除成功!");}@AutoLog(value = "采购发票登记-通过id查询")@ApiOperation(value="采购发票登记-通过id查询", notes="采购发票登记-通过id查询")@GetMapping(value = "/queryById")public Result<?> queryById(@RequestParam(name="id",required=true) String id) {FinPurInvoice finPurInvoice = finPurInvoiceService.getById(id);if(finPurInvoice==null) {return Result.error("未找到对应数据");}return Result.ok(finPurInvoice); }@AutoLog(value = "明细通过主表ID查询")@ApiOperation(value="明细主表ID查询", notes="明细-通主表ID查询")@GetMapping(value = "/queryFinPurInvoiceEntryByMainId")public Result<?> queryFinPurInvoiceEntryListByMainId(@RequestParam(name="id",required=true) String id) {List<FinPurInvoiceEntry> finPurInvoiceEntryList = finPurInvoiceEntryService.selectByMainId(id);return Result.ok(finPurInvoiceEntryList);} @RequestMapping(value = {"/exportXls", "/exportXls/{isRubric}"}) public ModelAndView exportXls(HttpServletRequest request, FinPurInvoice finPurInvoice) { // Step.1 组装查询条件查询数据 QueryWrapper<FinPurInvoice> queryWrapper = QueryGenerator.initQueryWrapper(finPurInvoice, request.getParameterMap()); LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); //Step.2 获取导出数据 List<FinPurInvoice> queryList = finPurInvoiceService.list(queryWrapper); // 过滤选中数据 String selections = request.getParameter("selections"); List<FinPurInvoice> finPurInvoiceList = new ArrayList<FinPurInvoice>(); if(oConvertUtils.isEmpty(selections)) { finPurInvoiceList = queryList; }else { List<String> selectionList = Arrays.asList(selections.split(",")); finPurInvoiceList = queryList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList()); } // Step.3 组装pageList List<FinPurInvoicePage> pageList = new ArrayList<FinPurInvoicePage>(); for (FinPurInvoice main : finPurInvoiceList) { FinPurInvoicePage vo = new FinPurInvoicePage(); BeanUtils.copyProperties(main, vo); List<FinPurInvoiceEntry> finPurInvoiceEntryList = finPurInvoiceEntryService.selectByMainId(main.getId()); vo.setFinPurInvoiceEntryList(finPurInvoiceEntryList); pageList.add(vo); } // Step.4 AutoPoi 导出Excel ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); mv.addObject(NormalExcelConstants.FILE_NAME, "采购发票登记列表"); mv.addObject(NormalExcelConstants.CLASS, FinPurInvoicePage.class); mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("采购发票登记数据", "导出人:"+sysUser.getRealname(), "采购发票登记")); mv.addObject(NormalExcelConstants.DATA_LIST, pageList); return mv; } @RequestMapping(value = "/importExcel", method = RequestMethod.POST) public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { MultipartFile file = entity.getValue();// 获取上传文件对象 ImportParams params = new ImportParams(); params.setTitleRows(2); params.setHeadRows(1); params.setNeedSave(true); try { List<FinPurInvoicePage> list = ExcelImportUtil.importExcel(file.getInputStream(), FinPurInvoicePage.class, params); for (FinPurInvoicePage page : list) { FinPurInvoice po = new FinPurInvoice(); BeanUtils.copyProperties(page, po); finPurInvoiceService.saveMain(po, page.getFinPurInvoiceEntryList()); } return Result.ok("文件导入成功!数据行数:" + list.size()); } catch (Exception e) { log.error(e.getMessage(),e); return Result.error("文件导入失败:"+e.getMessage()); } finally { try { file.getInputStream().close(); } catch (IOException e) { e.printStackTrace(); } } } return Result.ok("文件导入失败!"); } @AutoLog(value = "采购发票登记-通过id审核") @ApiOperation(value="采购发票登记-通过id审核", notes="采购发票登记-通过id审核") @PutMapping(value = "/approve") public Result<?> approve(@RequestBody JSONObject json) { finPurInvoiceService.approve(json.getString("id")); return Result.ok("审核通过!"); } }
上述内容就是如何用Java代码实现进销存管理系统,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注编程网行业资讯频道。