将首页的统计接口进行拆分,以提高查询速度
This commit is contained in:
@@ -463,12 +463,12 @@ public class DepotHeadController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计今日采购额、昨日采购额、本月采购额、今年采购额|销售额|零售额
|
||||
* 统计今日采购额、昨日采购额、本月采购额、今年采购额|销售额|零售额——后续将废弃
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getBuyAndSaleStatistics")
|
||||
@ApiOperation(value = "统计今日采购额、昨日采购额、本月采购额、今年采购额|销售额|零售额")
|
||||
@ApiOperation(value = "统计今日采购额、昨日采购额、本月采购额、今年采购额|销售额|零售额——后续将废弃")
|
||||
public BaseResponseInfo getBuyAndSaleStatistics(HttpServletRequest request) {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
@@ -490,6 +490,34 @@ public class DepotHeadController {
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分别统计今日(today)采购额、昨日(yesterday)采购额、本月(month)采购额、今年(year)采购额|销售额|零售额
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getBuyAndSaleStatisticsByType")
|
||||
@ApiOperation(value = "统计今日采购额、昨日采购额、本月采购额、今年采购额|销售额|零售额")
|
||||
public BaseResponseInfo getBuyAndSaleStatisticsByType(@RequestParam("type") String type, HttpServletRequest request) {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
String today = Tools.getNow() + BusinessConstants.DAY_FIRST_TIME;
|
||||
String monthFirstDay = Tools.firstDayOfMonth(Tools.getCurrentMonth()) + BusinessConstants.DAY_FIRST_TIME;
|
||||
String yesterdayBegin = Tools.getYesterday() + BusinessConstants.DAY_FIRST_TIME;
|
||||
String yesterdayEnd = Tools.getYesterday() + BusinessConstants.DAY_LAST_TIME;
|
||||
String yearBegin = Tools.getYearBegin() + BusinessConstants.DAY_FIRST_TIME;
|
||||
String yearEnd = Tools.getYearEnd() + BusinessConstants.DAY_LAST_TIME;
|
||||
Map<String, Object> map = depotHeadService.getBuyAndSaleStatisticsByType(type, today, monthFirstDay,
|
||||
yesterdayBegin, yesterdayEnd, yearBegin, yearEnd, request);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据当前用户获取操作员数组,用于控制当前用户的数据权限,限制可以看到的单据范围
|
||||
* 注意:该接口提供给部分插件使用,勿删
|
||||
|
||||
@@ -792,14 +792,14 @@ public class DepotItemController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计采购、销售、零售的总金额
|
||||
* 统计采购、销售、零售的总金额——后续将废弃
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping(value = "/buyOrSalePrice")
|
||||
@ApiOperation(value = "统计采购、销售、零售的总金额")
|
||||
@ApiOperation(value = "统计采购、销售、零售的总金额——后续将废弃")
|
||||
public BaseResponseInfo buyOrSalePrice(HttpServletRequest request,
|
||||
HttpServletResponse response)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
@@ -848,6 +848,117 @@ public class DepotItemController {
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计采购的总金额
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping(value = "/getBuyPrice")
|
||||
@ApiOperation(value = "统计采购的总金额")
|
||||
public BaseResponseInfo getBuyPrice(HttpServletRequest request,
|
||||
HttpServletResponse response)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
try {
|
||||
Long userId = userService.getUserId(request);
|
||||
String priceLimit = userService.getRoleTypeByUserId(userId).getPriceLimit();
|
||||
List<String> list = Tools.getLastMonths(6);
|
||||
JSONArray buyPriceList = new JSONArray();
|
||||
for(String month: list) {
|
||||
JSONObject obj = new JSONObject();
|
||||
BigDecimal outPrice = depotItemService.inOrOutPrice("入库", "采购", month);
|
||||
BigDecimal inPrice = depotItemService.inOrOutPrice("出库", "采购退货", month);
|
||||
obj.put("x", month);
|
||||
obj.put("y", roleService.parseHomePriceByLimit(outPrice.subtract(inPrice), "buy", priceLimit, "***", request));
|
||||
buyPriceList.add(obj);
|
||||
}
|
||||
map.put("buyPriceList", buyPriceList);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "统计失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计销售的总金额
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping(value = "/getSalePrice")
|
||||
@ApiOperation(value = "统计销售的总金额")
|
||||
public BaseResponseInfo getSalePrice(HttpServletRequest request,
|
||||
HttpServletResponse response)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
try {
|
||||
Long userId = userService.getUserId(request);
|
||||
String priceLimit = userService.getRoleTypeByUserId(userId).getPriceLimit();
|
||||
List<String> list = Tools.getLastMonths(6);
|
||||
JSONArray salePriceList = new JSONArray();
|
||||
for(String month: list) {
|
||||
JSONObject obj = new JSONObject();
|
||||
BigDecimal outPrice = depotItemService.inOrOutPrice("出库", "销售", month);
|
||||
BigDecimal inPrice = depotItemService.inOrOutPrice("入库", "销售退货", month);
|
||||
obj.put("x", month);
|
||||
obj.put("y", roleService.parseHomePriceByLimit(outPrice.subtract(inPrice), "sale", priceLimit, "***", request));
|
||||
salePriceList.add(obj);
|
||||
}
|
||||
map.put("salePriceList", salePriceList);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "统计失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计零售的总金额
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping(value = "/getRetailPrice")
|
||||
@ApiOperation(value = "统计零售的总金额")
|
||||
public BaseResponseInfo getRetailPrice(HttpServletRequest request,
|
||||
HttpServletResponse response)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
try {
|
||||
Long userId = userService.getUserId(request);
|
||||
String priceLimit = userService.getRoleTypeByUserId(userId).getPriceLimit();
|
||||
List<String> list = Tools.getLastMonths(6);
|
||||
JSONArray retailPriceList = new JSONArray();
|
||||
for(String month: list) {
|
||||
JSONObject obj = new JSONObject();
|
||||
BigDecimal outPrice = depotItemService.inOrOutRetailPrice("出库", "零售", month);
|
||||
BigDecimal inPrice = depotItemService.inOrOutRetailPrice("入库", "零售退货", month);
|
||||
obj.put("x", month);
|
||||
obj.put("y", roleService.parseHomePriceByLimit(outPrice.subtract(inPrice), "retail", priceLimit, "***", request));
|
||||
retailPriceList.add(obj);
|
||||
}
|
||||
map.put("retailPriceList", retailPriceList);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "统计失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取批次商品列表信息
|
||||
* @param request
|
||||
|
||||
Reference in New Issue
Block a user