| | |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springblade.modules.farmplant.service.FarmProductStockService; |
| | | import org.springblade.modules.process.service.IProcessService; |
| | | import org.springblade.modules.processInv.entity.ProcessInv; |
| | | import org.springblade.modules.processInv.service.IProcessInvService; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import org.springblade.modules.sale.vo.SaleVO; |
| | | import org.springblade.modules.sale.service.ISaleService; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 销售记录表 控制器 |
| | |
| | | |
| | | private final ISaleService saleService; |
| | | private final FarmProductStockService farmProductStockService; |
| | | |
| | | // private final IProcessService processService; |
| | | private final IProcessInvService processInvService; |
| | | /** |
| | | * 详情 |
| | | */ |
| | |
| | | @PostMapping("/submit") |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "新增或修改", notes = "传入sale") |
| | | public R submit(@Valid @RequestBody Sale sale) { |
| | | boolean res = farmProductStockService.stockCompare(sale.getSaleNum(),sale.getStrainId()); |
| | | public R submit(@Valid @RequestBody SaleVO sale) { |
| | | boolean res = farmProductStockService.stockCompare(sale.getSaleNum(),sale.getProid()); |
| | | if (!res){ |
| | | throw new org.springblade.core.log.exception.ServiceException(StringUtil.format("当前库存不足!")); |
| | | }else { |
| | | //库存充足,减去相应库存 |
| | | farmProductStockService.stockReduce(sale.getSaleNum(),sale.getStrainId()); |
| | | farmProductStockService.stockReduce(sale.getSaleNum(),sale.getProid()); |
| | | } |
| | | return R.status(saleService.saveOrUpdate(sale)); |
| | | } |
| | | |
| | | /** |
| | | * 新增或修改 销售记录表(加工产品) |
| | | */ |
| | | @PostMapping("/submitProcess") |
| | | @ApiOperationSupport(order = 8) |
| | | @ApiOperation(value = "新增或修改", notes = "传入sale") |
| | | public R submitProcess(@Valid @RequestBody SaleVO sale) { |
| | | // //对比加工表库存量 |
| | | // boolean res = processService.stockCompare(sale.getSaleNum(),sale.getProid()); |
| | | // if (!res){ |
| | | // throw new org.springblade.core.log.exception.ServiceException(StringUtil.format("当前库存不足!")); |
| | | // }else { |
| | | // //库存充足,减去相应库存 |
| | | // processService.stockReduce(sale.getSaleNum(),sale.getProid()); |
| | | // } |
| | | // return R.status(saleService.saveOrUpdate(sale)); |
| | | //对比加工表库存量 |
| | | boolean res = processInvService.stockCompare(sale.getSaleNum(),sale.getProid()); |
| | | if (!res){ |
| | | throw new org.springblade.core.log.exception.ServiceException(StringUtil.format("当前库存不足!")); |
| | | }else { |
| | | //库存充足,减去相应库存 |
| | | processInvService.stockReduce(sale.getSaleNum(),sale.getProid()); |
| | | //更新updateTIme 和 updateUser |
| | | ProcessInv processInv = new ProcessInv(); |
| | | processInv.setUpdateUser(sale.getCreateUser()); |
| | | processInv.setUpdateTime(new Date()); |
| | | processInv.setId(Long.parseLong(sale.getProid())); |
| | | processInvService.updateById(processInv); |
| | | } |
| | | return R.status(saleService.saveOrUpdate(sale)); |
| | | } |
| | | |
| | | /** |
| | | * 删除 销售记录表 |
| | |
| | | * 大屏销售统计 |
| | | */ |
| | | @GetMapping("/selctSaletCount") |
| | | public R selctSaletCount() { |
| | | return R.data(saleService.selctSaletCount()); |
| | | public R selctSaletCount(String farmId) { |
| | | return R.data(saleService.selctSaletCount(farmId)); |
| | | } |
| | | |
| | | /** |
| | | * 统计今年和去年的销售总额 |
| | | */ |
| | | @GetMapping("/selctSaletZ") |
| | | public R selctSaletZ() { |
| | | return R.data(saleService.selctSaletZ()); |
| | | public R selctSaletZ(SaleVO sale) { |
| | | return R.data(saleService.selctSaletZ(sale)); |
| | | } |
| | | |
| | | /** |
| | | * 统计市场流通/去年流通量/本月流通量 |
| | | * @param sale |
| | | * @return |
| | | */ |
| | | @GetMapping("/selectMarketCirculate") |
| | | public R selectMarketCirculate() { |
| | | return R.data(saleService.selectMarketCirculate()); |
| | | public R selectMarketCirculate(SaleVO sale) { |
| | | return R.data(saleService.selectMarketCirculate(sale)); |
| | | } |
| | | |
| | | /** |
| | | * 按行政区统计市场流通 |
| | | */ |
| | | @GetMapping("/selectMarketDistrict") |
| | | public R selectMarketDistrict() { |
| | | return R.data(saleService.selectMarketDistrict()); |
| | | public R selectMarketDistrict(String farmId,String startTime,String endTime) { |
| | | return R.data(saleService.selectMarketDistrict(farmId,startTime,endTime)); |
| | | } |
| | | |
| | | } |