给首页增加昨日和今年的金额统计接口
This commit is contained in:
@@ -400,48 +400,23 @@ public class DepotHeadController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 统计今日采购额、本月采购额、今日销售额、本月销售额、今日零售额、本月零售额
|
* 统计今日采购额、昨日采购额、本月采购额、今年采购额|销售额|零售额
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/getBuyAndSaleStatistics")
|
@GetMapping(value = "/getBuyAndSaleStatistics")
|
||||||
@ApiOperation(value = "统计今日采购额、本月采购额、今日销售额、本月销售额、今日零售额、本月零售额")
|
@ApiOperation(value = "统计今日采购额、昨日采购额、本月采购额、今年采购额|销售额|零售额")
|
||||||
public BaseResponseInfo getBuyAndSaleStatistics(HttpServletRequest request) {
|
public BaseResponseInfo getBuyAndSaleStatistics(HttpServletRequest request) {
|
||||||
BaseResponseInfo res = new BaseResponseInfo();
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
|
||||||
try {
|
try {
|
||||||
String today = Tools.getNow() + BusinessConstants.DAY_FIRST_TIME;
|
String today = Tools.getNow() + BusinessConstants.DAY_FIRST_TIME;
|
||||||
String firstDay = Tools.firstDayOfMonth(Tools.getCurrentMonth()) + BusinessConstants.DAY_FIRST_TIME;
|
String monthFirstDay = Tools.firstDayOfMonth(Tools.getCurrentMonth()) + BusinessConstants.DAY_FIRST_TIME;
|
||||||
BigDecimal todayBuy = depotHeadService.getBuyAndSaleStatistics("入库", "采购",
|
String yesterdayBegin = Tools.getYesterday() + BusinessConstants.DAY_FIRST_TIME;
|
||||||
1, today, getNow3()); //今日采购入库
|
String yesterdayEnd = Tools.getYesterday() + BusinessConstants.DAY_LAST_TIME;
|
||||||
BigDecimal todayBuyBack = depotHeadService.getBuyAndSaleStatistics("出库", "采购退货",
|
String yearBegin = Tools.getYearBegin() + BusinessConstants.DAY_FIRST_TIME;
|
||||||
1, today, getNow3()); //今日采购退货
|
String yearEnd = Tools.getYearEnd() + BusinessConstants.DAY_LAST_TIME;
|
||||||
BigDecimal todaySale = depotHeadService.getBuyAndSaleStatistics("出库", "销售",
|
Map<String, Object> map = depotHeadService.getBuyAndSaleStatistics(today, monthFirstDay,
|
||||||
1, today, getNow3()); //今日销售出库
|
yesterdayBegin, yesterdayEnd, yearBegin, yearEnd);
|
||||||
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()); //本月采购入库
|
|
||||||
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.code = 200;
|
||||||
res.data = map;
|
res.data = map;
|
||||||
} catch(Exception e){
|
} catch(Exception e){
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ public interface DepotHeadMapperEx {
|
|||||||
|
|
||||||
List<DepotHead> getDepotHeadListByCreator(@Param("creatorArray") String[] creatorArray);
|
List<DepotHead> getDepotHeadListByCreator(@Param("creatorArray") String[] creatorArray);
|
||||||
|
|
||||||
BigDecimal getBuyAndSaleStatistics(
|
BigDecimal getBuyAndSaleBasicStatistics(
|
||||||
@Param("type") String type,
|
@Param("type") String type,
|
||||||
@Param("subType") String subType,
|
@Param("subType") String subType,
|
||||||
@Param("hasSupplier") Integer hasSupplier,
|
@Param("hasSupplier") Integer hasSupplier,
|
||||||
|
|||||||
@@ -38,12 +38,10 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static com.jsh.erp.utils.Tools.getCenternTime;
|
import static com.jsh.erp.utils.Tools.getCenternTime;
|
||||||
|
import static com.jsh.erp.utils.Tools.getNow3;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class DepotHeadService {
|
public class DepotHeadService {
|
||||||
@@ -829,8 +827,77 @@ public class DepotHeadService {
|
|||||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getBuyAndSaleStatistics(String type, String subType, Integer hasSupplier, String beginTime, String endTime) {
|
public Map<String, Object> getBuyAndSaleStatistics(String today, String monthFirstDay, String yesterdayBegin, String yesterdayEnd, String yearBegin, String yearEnd) {
|
||||||
return depotHeadMapperEx.getBuyAndSaleStatistics(type, subType, hasSupplier, beginTime, endTime);
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
//今日
|
||||||
|
BigDecimal todayBuy = getBuyAndSaleBasicStatistics("入库", "采购",
|
||||||
|
1, today, getNow3()); //今日采购入库
|
||||||
|
BigDecimal todayBuyBack = getBuyAndSaleBasicStatistics("出库", "采购退货",
|
||||||
|
1, today, getNow3()); //今日采购退货
|
||||||
|
BigDecimal todaySale = getBuyAndSaleBasicStatistics("出库", "销售",
|
||||||
|
1, today, getNow3()); //今日销售出库
|
||||||
|
BigDecimal todaySaleBack = getBuyAndSaleBasicStatistics("入库", "销售退货",
|
||||||
|
1, today, getNow3()); //今日销售退货
|
||||||
|
BigDecimal todayRetailSale = getBuyAndSaleRetailStatistics("出库", "零售",
|
||||||
|
today, getNow3()); //今日零售出库
|
||||||
|
BigDecimal todayRetailSaleBack = getBuyAndSaleRetailStatistics("入库", "零售退货",
|
||||||
|
today, getNow3()); //今日零售退货
|
||||||
|
//本月
|
||||||
|
BigDecimal monthBuy = getBuyAndSaleBasicStatistics("入库", "采购",
|
||||||
|
1, monthFirstDay, getNow3()); //本月采购入库
|
||||||
|
BigDecimal monthBuyBack = getBuyAndSaleBasicStatistics("出库", "采购退货",
|
||||||
|
1, monthFirstDay, getNow3()); //本月采购退货
|
||||||
|
BigDecimal monthSale = getBuyAndSaleBasicStatistics("出库", "销售",
|
||||||
|
1,monthFirstDay, getNow3()); //本月销售出库
|
||||||
|
BigDecimal monthSaleBack = getBuyAndSaleBasicStatistics("入库", "销售退货",
|
||||||
|
1,monthFirstDay, getNow3()); //本月销售退货
|
||||||
|
BigDecimal monthRetailSale = getBuyAndSaleRetailStatistics("出库", "零售",
|
||||||
|
monthFirstDay, getNow3()); //本月零售出库
|
||||||
|
BigDecimal monthRetailSaleBack = getBuyAndSaleRetailStatistics("入库", "零售退货",
|
||||||
|
monthFirstDay, getNow3()); //本月零售退货
|
||||||
|
//昨日
|
||||||
|
BigDecimal yesterdayBuy = getBuyAndSaleBasicStatistics("入库", "采购",
|
||||||
|
1, yesterdayBegin, yesterdayEnd); //昨日采购入库
|
||||||
|
BigDecimal yesterdayBuyBack = getBuyAndSaleBasicStatistics("出库", "采购退货",
|
||||||
|
1, yesterdayBegin, yesterdayEnd); //昨日采购退货
|
||||||
|
BigDecimal yesterdaySale = getBuyAndSaleBasicStatistics("出库", "销售",
|
||||||
|
1, yesterdayBegin, yesterdayEnd); //昨日销售出库
|
||||||
|
BigDecimal yesterdaySaleBack = getBuyAndSaleBasicStatistics("入库", "销售退货",
|
||||||
|
1, yesterdayBegin, yesterdayEnd); //昨日销售退货
|
||||||
|
BigDecimal yesterdayRetailSale = getBuyAndSaleRetailStatistics("出库", "零售",
|
||||||
|
yesterdayBegin, yesterdayEnd); //昨日零售出库
|
||||||
|
BigDecimal yesterdayRetailSaleBack = getBuyAndSaleRetailStatistics("入库", "零售退货",
|
||||||
|
yesterdayBegin, yesterdayEnd); //昨日零售退货
|
||||||
|
//今年
|
||||||
|
BigDecimal yearBuy = getBuyAndSaleBasicStatistics("入库", "采购",
|
||||||
|
1, yearBegin, yearEnd); //今年采购入库
|
||||||
|
BigDecimal yearBuyBack = getBuyAndSaleBasicStatistics("出库", "采购退货",
|
||||||
|
1, yearBegin, yearEnd); //今年采购退货
|
||||||
|
BigDecimal yearSale = getBuyAndSaleBasicStatistics("出库", "销售",
|
||||||
|
1, yearBegin, yearEnd); //今年销售出库
|
||||||
|
BigDecimal yearSaleBack = getBuyAndSaleBasicStatistics("入库", "销售退货",
|
||||||
|
1, yearBegin, yearEnd); //今年销售退货
|
||||||
|
BigDecimal yearRetailSale = getBuyAndSaleRetailStatistics("出库", "零售",
|
||||||
|
yearBegin, yearEnd); //今年零售出库
|
||||||
|
BigDecimal yearRetailSaleBack = getBuyAndSaleRetailStatistics("入库", "零售退货",
|
||||||
|
yearBegin, yearEnd); //今年零售退货
|
||||||
|
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));
|
||||||
|
map.put("yesterdayBuy", yesterdayBuy.subtract(yesterdayBuyBack));
|
||||||
|
map.put("yesterdaySale", yesterdaySale.subtract(yesterdaySaleBack));
|
||||||
|
map.put("yesterdayRetailSale", yesterdayRetailSale.subtract(yesterdayRetailSaleBack));
|
||||||
|
map.put("yearBuy", yearBuy.subtract(yearBuyBack));
|
||||||
|
map.put("yearSale", yearSale.subtract(yearSaleBack));
|
||||||
|
map.put("yearRetailSale", yearRetailSale.subtract(yearRetailSaleBack));
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getBuyAndSaleBasicStatistics(String type, String subType, Integer hasSupplier, String beginTime, String endTime) {
|
||||||
|
return depotHeadMapperEx.getBuyAndSaleBasicStatistics(type, subType, hasSupplier, beginTime, endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getBuyAndSaleRetailStatistics(String type, String subType, String beginTime, String endTime) {
|
public BigDecimal getBuyAndSaleRetailStatistics(String type, String subType, String beginTime, String endTime) {
|
||||||
|
|||||||
@@ -40,6 +40,40 @@ public class Tools {
|
|||||||
return new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
return new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取昨天的日期字符串
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getYesterday(){
|
||||||
|
Date date=new Date();//取时间
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(date);
|
||||||
|
//把日期往后增加一天.整数往后推,负数往前移动(1:表示明天、-1:表示昨天,0:表示今天)
|
||||||
|
calendar.add(Calendar.DATE,-1);
|
||||||
|
//这个时间就是日期往前推一天的结果
|
||||||
|
date=calendar.getTime();
|
||||||
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
return formatter.format(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当年的第一天
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getYearBegin(){
|
||||||
|
String yearStr = new SimpleDateFormat("yyyy").format(new Date());
|
||||||
|
return yearStr + "-01-01";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当年的最后一天
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getYearEnd(){
|
||||||
|
String yearStr = new SimpleDateFormat("yyyy").format(new Date());
|
||||||
|
return yearStr + "-12-31";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前月 yyyy-MM
|
* 获取当前月 yyyy-MM
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -585,7 +585,7 @@
|
|||||||
and ifnull(delete_flag,'0') !='1'
|
and ifnull(delete_flag,'0') !='1'
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getBuyAndSaleStatistics" resultType="java.math.BigDecimal">
|
<select id="getBuyAndSaleBasicStatistics" resultType="java.math.BigDecimal">
|
||||||
SELECT
|
SELECT
|
||||||
ifnull(sum(discount_last_money),0)
|
ifnull(sum(discount_last_money),0)
|
||||||
FROM jsh_depot_head
|
FROM jsh_depot_head
|
||||||
|
|||||||
Reference in New Issue
Block a user