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

网友投稿 426 2022-09-15


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 queryWrapper = QueryGenerator.initQueryWrapper(finPurInvoice, req.getParameterMap());

Page page = new Page(pageNo, pageSize);

IPage 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 Resuhttp://lt.error("未找到对应数据");

}

finPurInvoiceService.updateMain(finPurInvoice, finPurInvoicePage.getFinPurInSbnsKNvoiceEntryList());

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 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 queryWrapper = QueryGenerator.initQueryWrapper(finPurInvoice, request.getParameterMap());

LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

//Step.2 获取导出数据

List queryList = finPurInvoiceService.list(queryWrapper);

// 过滤选中数据

String selections = request.getParameter("selections");

List finPurInvoiceList = new ArrayList();

if(oConvertUtils.isEmpty(selections)) {

finPurInvoiceList = queryList;

}else {

List selectionList = Arrays.asList(selections.split(","));

finSbnsKNPurInvoiceList = queryList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());

}

// Step.3 组装pageList

List pageList = new ArrayList();

for (FinPurInvoice main : finPurInvoiceList) {

FinPurInvoicePage vo = new FinPurInvoicePage();

BeanUtils.copyProperties(main, vo);

List 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 fileMap = multipartRequest.getFileMap();

for (Map.Entry entity : fileMap.entrySet()) {

MultipartFile file = entity.getValue();// 获取上传文件对象

ImportParams params = new ImportParams();

params.setTitleRows(2);

params.setHeadRows(1);

params.setNeedSave(true);

try {

List 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("审核通过!");

}

}


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:网络基础实验
下一篇:IPv6地址分类(ipv6地址共分几类)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~