From f649f3bd098b172d68441aea99bdc6273f7fdb4e Mon Sep 17 00:00:00 2001
From: tangzy <tangzy123456>
Date: Sat, 16 Jul 2022 10:58:04 +0800
Subject: [PATCH] 统计
---
src/main/java/org/springblade/modules/sale/controller/SaleController.java | 38 +++++++++++++++++++++++++++++++++-----
1 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/src/main/java/org/springblade/modules/sale/controller/SaleController.java b/src/main/java/org/springblade/modules/sale/controller/SaleController.java
index b2ee976..187b23e 100644
--- a/src/main/java/org/springblade/modules/sale/controller/SaleController.java
+++ b/src/main/java/org/springblade/modules/sale/controller/SaleController.java
@@ -28,6 +28,8 @@
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.StringUtil;
+import org.springblade.modules.farmplant.service.FarmProductStockService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -49,6 +51,7 @@
public class SaleController extends BladeController {
private final ISaleService saleService;
+ private final FarmProductStockService farmProductStockService;
/**
* 详情
@@ -109,7 +112,14 @@
@PostMapping("/submit")
@ApiOperationSupport(order = 6)
@ApiOperation(value = "新增或修改", notes = "传入sale")
- public R submit(@Valid @RequestBody Sale sale) {
+ public R submit(@Valid @RequestBody SaleVO sale) {
+ boolean res = farmProductStockService.stockCompare(sale.getSaleNum(),sale.getStrainId());
+ if (!res){
+ throw new org.springblade.core.log.exception.ServiceException(StringUtil.format("当前库存不足!"));
+ }else {
+ //库存充足,减去相应库存
+ farmProductStockService.stockReduce(sale.getSaleNum(),sale.getStrainId());
+ }
return R.status(saleService.saveOrUpdate(sale));
}
@@ -127,17 +137,35 @@
/**
* 大屏销售统计
*/
- @PostMapping("/selctSaletCount")
- public R selctSaletCount(String year) {
- return R.data(saleService.selctSaletCount(year));
+ @GetMapping("/selctSaletCount")
+ public R selctSaletCount() {
+ return R.data(saleService.selctSaletCount());
}
/**
* 统计今年和去年的销售总额
*/
- @PostMapping("/selctSaletZ")
+ @GetMapping("/selctSaletZ")
public R selctSaletZ() {
return R.data(saleService.selctSaletZ());
}
+ /**
+ * 统计市场流通/去年流通量/本月流通量
+ * @param sale
+ * @return
+ */
+ @GetMapping("/selectMarketCirculate")
+ public R selectMarketCirculate(SaleVO sale) {
+ return R.data(saleService.selectMarketCirculate(sale));
+ }
+
+ /**
+ * 按行政区统计市场流通
+ */
+ @GetMapping("/selectMarketDistrict")
+ public R selectMarketDistrict() {
+ return R.data(saleService.selectMarketDistrict());
+ }
+
}
--
Gitblit v1.9.3