优化首页统计
This commit is contained in:
@@ -345,34 +345,48 @@ 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>();
|
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 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("入库", "采购",
|
BigDecimal todayBuy = depotHeadService.getBuyAndSaleStatistics("入库", "采购",
|
||||||
1, today, getNow3()); //今日采购入库
|
1, today, getNow3()); //今日采购入库
|
||||||
BigDecimal monthSale = depotHeadService.getBuyAndSaleStatistics("出库", "销售",
|
BigDecimal todayBuyBack = depotHeadService.getBuyAndSaleStatistics("出库", "采购退货",
|
||||||
1,firstDay, getNow3()); //本月销售出库
|
1, today, getNow3()); //今日采购退货
|
||||||
BigDecimal monthRetailSale = depotHeadService.getBuyAndSaleRetailStatistics("出库", "零售",
|
BigDecimal todaySale = depotHeadService.getBuyAndSaleStatistics("出库", "销售",
|
||||||
0,firstDay, getNow3()); //本月零售出库
|
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("入库", "采购",
|
BigDecimal monthBuy = depotHeadService.getBuyAndSaleStatistics("入库", "采购",
|
||||||
1, firstDay, getNow3()); //本月采购入库
|
1, firstDay, getNow3()); //本月采购入库
|
||||||
map.put("todaySale", todaySale.add(todayRetailSale));
|
BigDecimal monthBuyBack = depotHeadService.getBuyAndSaleStatistics("出库", "采购退货",
|
||||||
map.put("todayBuy", todayBuy);
|
1, firstDay, getNow3()); //本月采购退货
|
||||||
map.put("thisMonthSale", monthSale.add(monthRetailSale));
|
BigDecimal monthSale = depotHeadService.getBuyAndSaleStatistics("出库", "销售",
|
||||||
map.put("thisMonthBuy", monthBuy);
|
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){
|
||||||
|
|||||||
@@ -597,14 +597,14 @@ public class DepotItemController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 统计采购或销售的总金额
|
* 统计采购、销售、零售的总金额
|
||||||
* @param request
|
* @param request
|
||||||
* @param response
|
* @param response
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/buyOrSalePrice")
|
@GetMapping(value = "/buyOrSalePrice")
|
||||||
@ApiOperation(value = "统计采购或销售的总金额")
|
@ApiOperation(value = "统计采购、销售、零售的总金额")
|
||||||
public BaseResponseInfo buyOrSalePrice(HttpServletRequest request, HttpServletResponse response)throws Exception {
|
public BaseResponseInfo buyOrSalePrice(HttpServletRequest request, HttpServletResponse response)throws Exception {
|
||||||
BaseResponseInfo res = new BaseResponseInfo();
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
@@ -631,6 +631,16 @@ public class DepotItemController {
|
|||||||
salePriceList.add(obj);
|
salePriceList.add(obj);
|
||||||
}
|
}
|
||||||
map.put("salePriceList", salePriceList);
|
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.code = 200;
|
||||||
res.data = map;
|
res.data = map;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -155,7 +155,6 @@ public interface DepotHeadMapperEx {
|
|||||||
BigDecimal getBuyAndSaleRetailStatistics(
|
BigDecimal getBuyAndSaleRetailStatistics(
|
||||||
@Param("type") String type,
|
@Param("type") String type,
|
||||||
@Param("subType") String subType,
|
@Param("subType") String subType,
|
||||||
@Param("hasSupplier") Integer hasSupplier,
|
|
||||||
@Param("beginTime") String beginTime,
|
@Param("beginTime") String beginTime,
|
||||||
@Param("endTime") String endTime);
|
@Param("endTime") String endTime);
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,12 @@ public interface DepotItemMapperEx {
|
|||||||
@Param("beginTime") String beginTime,
|
@Param("beginTime") String beginTime,
|
||||||
@Param("endTime") String endTime);
|
@Param("endTime") String endTime);
|
||||||
|
|
||||||
|
BigDecimal inOrOutRetailPrice(
|
||||||
|
@Param("type") String type,
|
||||||
|
@Param("subType") String subType,
|
||||||
|
@Param("beginTime") String beginTime,
|
||||||
|
@Param("endTime") String endTime);
|
||||||
|
|
||||||
BigDecimal getStockCheckSum(
|
BigDecimal getStockCheckSum(
|
||||||
@Param("depotId") Long depotId,
|
@Param("depotId") Long depotId,
|
||||||
@Param("mId") Long mId,
|
@Param("mId") Long mId,
|
||||||
|
|||||||
@@ -796,8 +796,8 @@ public class DepotHeadService {
|
|||||||
return depotHeadMapperEx.getBuyAndSaleStatistics(type, subType, hasSupplier, beginTime, endTime);
|
return depotHeadMapperEx.getBuyAndSaleStatistics(type, subType, hasSupplier, beginTime, endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getBuyAndSaleRetailStatistics(String type, String subType, Integer hasSupplier, String beginTime, String endTime) {
|
public BigDecimal getBuyAndSaleRetailStatistics(String type, String subType, String beginTime, String endTime) {
|
||||||
return depotHeadMapperEx.getBuyAndSaleRetailStatistics(type, subType, hasSupplier, beginTime, endTime);
|
return depotHeadMapperEx.getBuyAndSaleRetailStatistics(type, subType, beginTime, endTime).abs();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DepotHead getDepotHead(String number)throws Exception {
|
public DepotHead getDepotHead(String number)throws Exception {
|
||||||
|
|||||||
@@ -298,6 +298,27 @@ public class DepotItemService {
|
|||||||
return result;
|
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)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public void saveDetials(String rows, Long headerId, HttpServletRequest request) throws Exception{
|
public void saveDetials(String rows, Long headerId, HttpServletRequest request) throws Exception{
|
||||||
//查询单据主表信息
|
//查询单据主表信息
|
||||||
|
|||||||
@@ -518,12 +518,6 @@
|
|||||||
<if test="subType != null">
|
<if test="subType != null">
|
||||||
and sub_type=#{subType}
|
and sub_type=#{subType}
|
||||||
</if>
|
</if>
|
||||||
<if test="hasSupplier == 1">
|
|
||||||
and organ_id is not null
|
|
||||||
</if>
|
|
||||||
<if test="hasSupplier == 0">
|
|
||||||
and organ_id is null
|
|
||||||
</if>
|
|
||||||
<if test="beginTime != null">
|
<if test="beginTime != null">
|
||||||
and oper_time >= #{beginTime}
|
and oper_time >= #{beginTime}
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
@@ -269,6 +269,15 @@
|
|||||||
and ifnull(dh.delete_flag,'0') !='1'
|
and ifnull(dh.delete_flag,'0') !='1'
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="inOrOutRetailPrice" resultType="java.math.BigDecimal">
|
||||||
|
select ifnull(sum(total_price),0) as allMoney from jsh_depot_head dh
|
||||||
|
where 1=1
|
||||||
|
and dh.type=#{type} and dh.sub_type=#{subType}
|
||||||
|
and dh.oper_time >= #{beginTime}
|
||||||
|
and dh.oper_time <= #{endTime}
|
||||||
|
and ifnull(dh.delete_flag,'0') !='1'
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="getStockCheckSum" resultType="java.math.BigDecimal">
|
<select id="getStockCheckSum" resultType="java.math.BigDecimal">
|
||||||
select ifnull(sum(di.basic_number),0) stockCheckSum from jsh_depot_head dh
|
select ifnull(sum(di.basic_number),0) stockCheckSum from jsh_depot_head dh
|
||||||
left JOIN jsh_depot_item di on dh.id=di.header_id
|
left JOIN jsh_depot_item di on dh.id=di.header_id
|
||||||
|
|||||||
Reference in New Issue
Block a user