优化首页统计
This commit is contained in:
@@ -345,34 +345,48 @@ public class DepotHeadController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计今日销售额、今日进货额、本月销售额、本月进货额
|
||||
* 统计今日采购额、本月采购额、今日销售额、本月销售额、今日零售额、本月零售额
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getBuyAndSaleStatistics")
|
||||
@ApiOperation(value = "统计今日销售额、今日进货额、本月销售额、本月进货额")
|
||||
@ApiOperation(value = "统计今日采购额、本月采购额、今日销售额、本月销售额、今日零售额、本月零售额")
|
||||
public BaseResponseInfo getBuyAndSaleStatistics(HttpServletRequest request) {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
try {
|
||||
String today = Tools.getNow() + BusinessConstants.DAY_FIRST_TIME;
|
||||
String firstDay = Tools.firstDayOfMonth(Tools.getCurrentMonth()) + BusinessConstants.DAY_FIRST_TIME;
|
||||
BigDecimal todaySale = depotHeadService.getBuyAndSaleStatistics("出库", "销售",
|
||||
1, today, getNow3()); //今日销售出库
|
||||
BigDecimal todayRetailSale = depotHeadService.getBuyAndSaleRetailStatistics("出库", "零售",
|
||||
0, today, getNow3()); //今日零售出库
|
||||
BigDecimal todayBuy = depotHeadService.getBuyAndSaleStatistics("入库", "采购",
|
||||
1, today, getNow3()); //今日采购入库
|
||||
BigDecimal monthSale = depotHeadService.getBuyAndSaleStatistics("出库", "销售",
|
||||
1,firstDay, getNow3()); //本月销售出库
|
||||
BigDecimal monthRetailSale = depotHeadService.getBuyAndSaleRetailStatistics("出库", "零售",
|
||||
0,firstDay, getNow3()); //本月零售出库
|
||||
BigDecimal todayBuyBack = depotHeadService.getBuyAndSaleStatistics("出库", "采购退货",
|
||||
1, today, getNow3()); //今日采购退货
|
||||
BigDecimal todaySale = depotHeadService.getBuyAndSaleStatistics("出库", "销售",
|
||||
1, today, getNow3()); //今日销售出库
|
||||
BigDecimal todaySaleBack = depotHeadService.getBuyAndSaleStatistics("入库", "销售退货",
|
||||
1, today, getNow3()); //今日销售退货
|
||||
BigDecimal todayRetailSale = depotHeadService.getBuyAndSaleRetailStatistics("出库", "零售",
|
||||
today, getNow3()); //今日零售出库
|
||||
BigDecimal todayRetailSaleBack = depotHeadService.getBuyAndSaleRetailStatistics("入库", "零售退货",
|
||||
today, getNow3()); //今日零售退货
|
||||
BigDecimal monthBuy = depotHeadService.getBuyAndSaleStatistics("入库", "采购",
|
||||
1, firstDay, getNow3()); //本月采购入库
|
||||
map.put("todaySale", todaySale.add(todayRetailSale));
|
||||
map.put("todayBuy", todayBuy);
|
||||
map.put("thisMonthSale", monthSale.add(monthRetailSale));
|
||||
map.put("thisMonthBuy", monthBuy);
|
||||
BigDecimal monthBuyBack = depotHeadService.getBuyAndSaleStatistics("出库", "采购退货",
|
||||
1, firstDay, getNow3()); //本月采购退货
|
||||
BigDecimal monthSale = depotHeadService.getBuyAndSaleStatistics("出库", "销售",
|
||||
1,firstDay, getNow3()); //本月销售出库
|
||||
BigDecimal monthSaleBack = depotHeadService.getBuyAndSaleStatistics("入库", "销售退货",
|
||||
1,firstDay, getNow3()); //本月销售退货
|
||||
BigDecimal monthRetailSale = depotHeadService.getBuyAndSaleRetailStatistics("出库", "零售",
|
||||
firstDay, getNow3()); //本月零售出库
|
||||
BigDecimal monthRetailSaleBack = depotHeadService.getBuyAndSaleRetailStatistics("入库", "零售退货",
|
||||
firstDay, getNow3()); //本月零售退货
|
||||
map.put("todayBuy", todayBuy.subtract(todayBuyBack));
|
||||
map.put("todaySale", todaySale.subtract(todaySaleBack));
|
||||
map.put("todayRetailSale", todayRetailSale.subtract(todayRetailSaleBack));
|
||||
map.put("monthBuy", monthBuy.subtract(monthBuyBack));
|
||||
map.put("monthSale", monthSale.subtract(monthSaleBack));
|
||||
map.put("monthRetailSale", monthRetailSale.subtract(monthRetailSaleBack));
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch(Exception e){
|
||||
|
||||
@@ -597,14 +597,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();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
@@ -631,6 +631,16 @@ public class DepotItemController {
|
||||
salePriceList.add(obj);
|
||||
}
|
||||
map.put("salePriceList", salePriceList);
|
||||
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", outPrice.subtract(inPrice));
|
||||
retailPriceList.add(obj);
|
||||
}
|
||||
map.put("retailPriceList", retailPriceList);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -155,7 +155,6 @@ public interface DepotHeadMapperEx {
|
||||
BigDecimal getBuyAndSaleRetailStatistics(
|
||||
@Param("type") String type,
|
||||
@Param("subType") String subType,
|
||||
@Param("hasSupplier") Integer hasSupplier,
|
||||
@Param("beginTime") String beginTime,
|
||||
@Param("endTime") String endTime);
|
||||
|
||||
|
||||
@@ -72,6 +72,12 @@ public interface DepotItemMapperEx {
|
||||
@Param("beginTime") String beginTime,
|
||||
@Param("endTime") String endTime);
|
||||
|
||||
BigDecimal inOrOutRetailPrice(
|
||||
@Param("type") String type,
|
||||
@Param("subType") String subType,
|
||||
@Param("beginTime") String beginTime,
|
||||
@Param("endTime") String endTime);
|
||||
|
||||
BigDecimal getStockCheckSum(
|
||||
@Param("depotId") Long depotId,
|
||||
@Param("mId") Long mId,
|
||||
|
||||
@@ -796,8 +796,8 @@ public class DepotHeadService {
|
||||
return depotHeadMapperEx.getBuyAndSaleStatistics(type, subType, hasSupplier, beginTime, endTime);
|
||||
}
|
||||
|
||||
public BigDecimal getBuyAndSaleRetailStatistics(String type, String subType, Integer hasSupplier, String beginTime, String endTime) {
|
||||
return depotHeadMapperEx.getBuyAndSaleRetailStatistics(type, subType, hasSupplier, beginTime, endTime);
|
||||
public BigDecimal getBuyAndSaleRetailStatistics(String type, String subType, String beginTime, String endTime) {
|
||||
return depotHeadMapperEx.getBuyAndSaleRetailStatistics(type, subType, beginTime, endTime).abs();
|
||||
}
|
||||
|
||||
public DepotHead getDepotHead(String number)throws Exception {
|
||||
|
||||
@@ -298,6 +298,27 @@ public class DepotItemService {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计零售的总金额
|
||||
* @param type
|
||||
* @param subType
|
||||
* @param month
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public BigDecimal inOrOutRetailPrice(String type, String subType, String month) throws Exception{
|
||||
BigDecimal result= BigDecimal.ZERO;
|
||||
try{
|
||||
String beginTime = Tools.firstDayOfMonth(month) + BusinessConstants.DAY_FIRST_TIME;
|
||||
String endTime = Tools.lastDayOfMonth(month) + BusinessConstants.DAY_LAST_TIME;
|
||||
result = depotItemMapperEx.inOrOutRetailPrice(type, subType, beginTime, endTime);
|
||||
result = result.abs();
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public void saveDetials(String rows, Long headerId, HttpServletRequest request) throws Exception{
|
||||
//查询单据主表信息
|
||||
|
||||
Reference in New Issue
Block a user