您好,登錄后才能下訂單哦!
本篇文章為大家展示了如何用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 (簡化代碼)等
/** * @Description: 采購發票登記 * @Author: jeecg-boot * @Version: V1.0 */ @Api(tags="采購發票登記") @RestController @RequestMapping("/finance/finPurInvoice") @Slf4j public class FinPurInvoiceController { @Autowired private IFinPurInvoiceService finPurInvoiceService; @Autowired private IFinPurInvoiceEntryService finPurInvoiceEntryService; /** * 分頁列表查詢 * * @param finPurInvoice * @param pageNo * @param pageSize * @param req * @return */ @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); } /** * 添加 * * @param finPurInvoicePage * @return */ @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("添加成功!"); } /** * 編輯 * * @param finPurInvoicePage * @return */ @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("編輯成功!"); } /** * 通過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) { finPurInvoiceService.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.finPurInvoiceService.delBatchMain(Arrays.asList(ids.split(","))); return Result.ok("批量刪除成功!"); } /** * 通過id查詢 * * @param id * @return */ @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); } /** * 通過id查詢 * * @param id * @return */ @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); } /** * 導出excel * * @param request * @param finPurInvoice */ @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; } /** * 通過excel導入數據 * * @param request * @param response * @return */ @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代碼實現進銷存管理系統,你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。