将首页的统计接口进行拆分,以提高查询速度
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
|
||||
|
||||
@@ -1200,6 +1200,87 @@ public class DepotHeadService {
|
||||
return map;
|
||||
}
|
||||
|
||||
public Map<String, Object> getBuyAndSaleStatisticsByType(String type, String today, String monthFirstDay, String yesterdayBegin, String yesterdayEnd,
|
||||
String yearBegin, String yearEnd, HttpServletRequest request) throws Exception {
|
||||
Long userId = userService.getUserId(request);
|
||||
String priceLimit = userService.getRoleTypeByUserId(userId).getPriceLimit();
|
||||
String [] creatorArray = getCreatorArray();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
//今日
|
||||
if("today".equals(type)) {
|
||||
BigDecimal todayBuy = getBuyAndSaleBasicStatistics("入库", "采购",
|
||||
1, today, getNow3(), creatorArray); //今日采购入库
|
||||
BigDecimal todayBuyBack = getBuyAndSaleBasicStatistics("出库", "采购退货",
|
||||
1, today, getNow3(), creatorArray); //今日采购退货
|
||||
BigDecimal todaySale = getBuyAndSaleBasicStatistics("出库", "销售",
|
||||
1, today, getNow3(), creatorArray); //今日销售出库
|
||||
BigDecimal todaySaleBack = getBuyAndSaleBasicStatistics("入库", "销售退货",
|
||||
1, today, getNow3(), creatorArray); //今日销售退货
|
||||
BigDecimal todayRetailSale = getBuyAndSaleRetailStatistics("出库", "零售",
|
||||
today, getNow3(), creatorArray); //今日零售出库
|
||||
BigDecimal todayRetailSaleBack = getBuyAndSaleRetailStatistics("入库", "零售退货",
|
||||
today, getNow3(), creatorArray); //今日零售退货
|
||||
map.put("todayBuy", roleService.parseHomePriceByLimit(todayBuy.subtract(todayBuyBack), "buy", priceLimit, "***", request));
|
||||
map.put("todaySale", roleService.parseHomePriceByLimit(todaySale.subtract(todaySaleBack), "sale", priceLimit, "***", request));
|
||||
map.put("todayRetailSale", roleService.parseHomePriceByLimit(todayRetailSale.subtract(todayRetailSaleBack), "retail", priceLimit, "***", request));
|
||||
}
|
||||
//本月
|
||||
if("month".equals(type)) {
|
||||
BigDecimal monthBuy = getBuyAndSaleBasicStatistics("入库", "采购",
|
||||
1, monthFirstDay, getNow3(), creatorArray); //本月采购入库
|
||||
BigDecimal monthBuyBack = getBuyAndSaleBasicStatistics("出库", "采购退货",
|
||||
1, monthFirstDay, getNow3(), creatorArray); //本月采购退货
|
||||
BigDecimal monthSale = getBuyAndSaleBasicStatistics("出库", "销售",
|
||||
1, monthFirstDay, getNow3(), creatorArray); //本月销售出库
|
||||
BigDecimal monthSaleBack = getBuyAndSaleBasicStatistics("入库", "销售退货",
|
||||
1, monthFirstDay, getNow3(), creatorArray); //本月销售退货
|
||||
BigDecimal monthRetailSale = getBuyAndSaleRetailStatistics("出库", "零售",
|
||||
monthFirstDay, getNow3(), creatorArray); //本月零售出库
|
||||
BigDecimal monthRetailSaleBack = getBuyAndSaleRetailStatistics("入库", "零售退货",
|
||||
monthFirstDay, getNow3(), creatorArray); //本月零售退货
|
||||
map.put("monthBuy", roleService.parseHomePriceByLimit(monthBuy.subtract(monthBuyBack), "buy", priceLimit, "***", request));
|
||||
map.put("monthSale", roleService.parseHomePriceByLimit(monthSale.subtract(monthSaleBack), "sale", priceLimit, "***", request));
|
||||
map.put("monthRetailSale", roleService.parseHomePriceByLimit(monthRetailSale.subtract(monthRetailSaleBack), "retail", priceLimit, "***", request));
|
||||
}
|
||||
//昨日
|
||||
if("yesterday".equals(type)) {
|
||||
BigDecimal yesterdayBuy = getBuyAndSaleBasicStatistics("入库", "采购",
|
||||
1, yesterdayBegin, yesterdayEnd, creatorArray); //昨日采购入库
|
||||
BigDecimal yesterdayBuyBack = getBuyAndSaleBasicStatistics("出库", "采购退货",
|
||||
1, yesterdayBegin, yesterdayEnd, creatorArray); //昨日采购退货
|
||||
BigDecimal yesterdaySale = getBuyAndSaleBasicStatistics("出库", "销售",
|
||||
1, yesterdayBegin, yesterdayEnd, creatorArray); //昨日销售出库
|
||||
BigDecimal yesterdaySaleBack = getBuyAndSaleBasicStatistics("入库", "销售退货",
|
||||
1, yesterdayBegin, yesterdayEnd, creatorArray); //昨日销售退货
|
||||
BigDecimal yesterdayRetailSale = getBuyAndSaleRetailStatistics("出库", "零售",
|
||||
yesterdayBegin, yesterdayEnd, creatorArray); //昨日零售出库
|
||||
BigDecimal yesterdayRetailSaleBack = getBuyAndSaleRetailStatistics("入库", "零售退货",
|
||||
yesterdayBegin, yesterdayEnd, creatorArray); //昨日零售退货
|
||||
map.put("yesterdayBuy", roleService.parseHomePriceByLimit(yesterdayBuy.subtract(yesterdayBuyBack), "buy", priceLimit, "***", request));
|
||||
map.put("yesterdaySale", roleService.parseHomePriceByLimit(yesterdaySale.subtract(yesterdaySaleBack), "sale", priceLimit, "***", request));
|
||||
map.put("yesterdayRetailSale", roleService.parseHomePriceByLimit(yesterdayRetailSale.subtract(yesterdayRetailSaleBack), "retail", priceLimit, "***", request));
|
||||
}
|
||||
//今年
|
||||
if("year".equals(type)) {
|
||||
BigDecimal yearBuy = getBuyAndSaleBasicStatistics("入库", "采购",
|
||||
1, yearBegin, yearEnd, creatorArray); //今年采购入库
|
||||
BigDecimal yearBuyBack = getBuyAndSaleBasicStatistics("出库", "采购退货",
|
||||
1, yearBegin, yearEnd, creatorArray); //今年采购退货
|
||||
BigDecimal yearSale = getBuyAndSaleBasicStatistics("出库", "销售",
|
||||
1, yearBegin, yearEnd, creatorArray); //今年销售出库
|
||||
BigDecimal yearSaleBack = getBuyAndSaleBasicStatistics("入库", "销售退货",
|
||||
1, yearBegin, yearEnd, creatorArray); //今年销售退货
|
||||
BigDecimal yearRetailSale = getBuyAndSaleRetailStatistics("出库", "零售",
|
||||
yearBegin, yearEnd, creatorArray); //今年零售出库
|
||||
BigDecimal yearRetailSaleBack = getBuyAndSaleRetailStatistics("入库", "零售退货",
|
||||
yearBegin, yearEnd, creatorArray); //今年零售退货
|
||||
map.put("yearBuy", roleService.parseHomePriceByLimit(yearBuy.subtract(yearBuyBack), "buy", priceLimit, "***", request));
|
||||
map.put("yearSale", roleService.parseHomePriceByLimit(yearSale.subtract(yearSaleBack), "sale", priceLimit, "***", request));
|
||||
map.put("yearRetailSale", roleService.parseHomePriceByLimit(yearRetailSale.subtract(yearRetailSaleBack), "retail", priceLimit, "***", request));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public BigDecimal getBuyAndSaleBasicStatistics(String type, String subType, Integer hasSupplier,
|
||||
String beginTime, String endTime, String[] creatorArray) throws Exception {
|
||||
Boolean forceFlag = systemConfigService.getForceApprovalFlag();
|
||||
|
||||
Reference in New Issue
Block a user