文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

Java实战范例之进销存管理系统的实现

2024-04-02 19:55

关注

一、项目简述

本系统功能包括: 库存管理,入库管理,出库管理,往来管理,基础资料, 系统管理,消息中心,系统监控等等。

二、项目运行

环境配置: 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")
@Slf4j
public class FinPurInvoiceController {
	@Autowired
	private IFinPurInvoiceService finPurInvoiceService;
	@Autowired
	private 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 实战范例之进销存管理系统的实现的文章就介绍到这了,更多相关Java 进销存管理系统内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     807人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     351人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     314人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     433人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     221人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-后端开发
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯