优化首页的统计接口,提高查询速度
This commit is contained in:
@@ -7,6 +7,7 @@ import com.jsh.erp.constants.ExceptionConstants;
|
|||||||
import com.jsh.erp.datasource.entities.*;
|
import com.jsh.erp.datasource.entities.*;
|
||||||
import com.jsh.erp.datasource.vo.DepotItemStockWarningCount;
|
import com.jsh.erp.datasource.vo.DepotItemStockWarningCount;
|
||||||
import com.jsh.erp.datasource.vo.DepotItemVoBatchNumberList;
|
import com.jsh.erp.datasource.vo.DepotItemVoBatchNumberList;
|
||||||
|
import com.jsh.erp.datasource.vo.InOutPriceVo;
|
||||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||||
import com.jsh.erp.service.depot.DepotService;
|
import com.jsh.erp.service.depot.DepotService;
|
||||||
import com.jsh.erp.service.depotHead.DepotHeadService;
|
import com.jsh.erp.service.depotHead.DepotHeadService;
|
||||||
@@ -806,33 +807,69 @@ public class DepotItemController {
|
|||||||
Map<String, Object> map = new HashMap<String, Object>();
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
try {
|
try {
|
||||||
Long userId = userService.getUserId(request);
|
Long userId = userService.getUserId(request);
|
||||||
|
List<String> monthList = Tools.getLastMonths(6);
|
||||||
|
String beginTime = Tools.firstDayOfMonth(monthList.get(0)) + BusinessConstants.DAY_FIRST_TIME;
|
||||||
|
String endTime = Tools.getNow() + BusinessConstants.DAY_LAST_TIME;
|
||||||
|
List<InOutPriceVo> inOrOutPriceList = depotItemService.inOrOutPriceList(beginTime, endTime);
|
||||||
String priceLimit = userService.getRoleTypeByUserId(userId).getPriceLimit();
|
String priceLimit = userService.getRoleTypeByUserId(userId).getPriceLimit();
|
||||||
List<String> list = Tools.getLastMonths(6);
|
|
||||||
JSONArray buyPriceList = new JSONArray();
|
JSONArray buyPriceList = new JSONArray();
|
||||||
for(String month: list) {
|
for(String month: monthList) {
|
||||||
JSONObject obj = new JSONObject();
|
JSONObject obj = new JSONObject();
|
||||||
BigDecimal outPrice = depotItemService.inOrOutPrice("入库", "采购", month);
|
BigDecimal outPrice = BigDecimal.ZERO;
|
||||||
BigDecimal inPrice = depotItemService.inOrOutPrice("出库", "采购退货", month);
|
BigDecimal inPrice = BigDecimal.ZERO;
|
||||||
|
for(InOutPriceVo item: inOrOutPriceList) {
|
||||||
|
String billOperMonth = Tools.dateToStr(item.getOperTime(), "yyyy-MM");
|
||||||
|
if(month.equals(billOperMonth)) {
|
||||||
|
if("入库".equals(item.getType()) && "采购".equals(item.getSubType())) {
|
||||||
|
outPrice = outPrice.add(item.getDiscountLastMoney());
|
||||||
|
}
|
||||||
|
if("出库".equals(item.getType()) && "采购退货".equals(item.getSubType())) {
|
||||||
|
inPrice = inPrice.add(item.getDiscountLastMoney());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
obj.put("x", month);
|
obj.put("x", month);
|
||||||
obj.put("y", roleService.parseHomePriceByLimit(outPrice.subtract(inPrice), "buy", priceLimit, "***", request));
|
obj.put("y", roleService.parseHomePriceByLimit(outPrice.subtract(inPrice), "buy", priceLimit, "***", request));
|
||||||
buyPriceList.add(obj);
|
buyPriceList.add(obj);
|
||||||
}
|
}
|
||||||
map.put("buyPriceList", buyPriceList);
|
map.put("buyPriceList", buyPriceList);
|
||||||
JSONArray salePriceList = new JSONArray();
|
JSONArray salePriceList = new JSONArray();
|
||||||
for(String month: list) {
|
for(String month: monthList) {
|
||||||
JSONObject obj = new JSONObject();
|
JSONObject obj = new JSONObject();
|
||||||
BigDecimal outPrice = depotItemService.inOrOutPrice("出库", "销售", month);
|
BigDecimal outPrice = BigDecimal.ZERO;
|
||||||
BigDecimal inPrice = depotItemService.inOrOutPrice("入库", "销售退货", month);
|
BigDecimal inPrice = BigDecimal.ZERO;
|
||||||
|
for(InOutPriceVo item: inOrOutPriceList) {
|
||||||
|
String billOperMonth = Tools.dateToStr(item.getOperTime(), "yyyy-MM");
|
||||||
|
if(month.equals(billOperMonth)) {
|
||||||
|
if("出库".equals(item.getType()) && "销售".equals(item.getSubType())) {
|
||||||
|
outPrice = outPrice.add(item.getDiscountLastMoney());
|
||||||
|
}
|
||||||
|
if("入库".equals(item.getType()) && "销售退货".equals(item.getSubType())) {
|
||||||
|
inPrice = inPrice.add(item.getDiscountLastMoney());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
obj.put("x", month);
|
obj.put("x", month);
|
||||||
obj.put("y", roleService.parseHomePriceByLimit(outPrice.subtract(inPrice), "sale", priceLimit, "***", request));
|
obj.put("y", roleService.parseHomePriceByLimit(outPrice.subtract(inPrice), "sale", priceLimit, "***", request));
|
||||||
salePriceList.add(obj);
|
salePriceList.add(obj);
|
||||||
}
|
}
|
||||||
map.put("salePriceList", salePriceList);
|
map.put("salePriceList", salePriceList);
|
||||||
JSONArray retailPriceList = new JSONArray();
|
JSONArray retailPriceList = new JSONArray();
|
||||||
for(String month: list) {
|
for(String month: monthList) {
|
||||||
JSONObject obj = new JSONObject();
|
JSONObject obj = new JSONObject();
|
||||||
BigDecimal outPrice = depotItemService.inOrOutRetailPrice("出库", "零售", month);
|
BigDecimal outPrice = BigDecimal.ZERO;
|
||||||
BigDecimal inPrice = depotItemService.inOrOutRetailPrice("入库", "零售退货", month);
|
BigDecimal inPrice = BigDecimal.ZERO;
|
||||||
|
for(InOutPriceVo item: inOrOutPriceList) {
|
||||||
|
String billOperMonth = Tools.dateToStr(item.getOperTime(), "yyyy-MM");
|
||||||
|
if(month.equals(billOperMonth)) {
|
||||||
|
if("出库".equals(item.getType()) && "零售".equals(item.getSubType())) {
|
||||||
|
outPrice = outPrice.add(item.getTotalPrice().abs());
|
||||||
|
}
|
||||||
|
if("入库".equals(item.getType()) && "零售退货".equals(item.getSubType())) {
|
||||||
|
inPrice = inPrice.add(item.getTotalPrice().abs());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
obj.put("x", month);
|
obj.put("x", month);
|
||||||
obj.put("y", roleService.parseHomePriceByLimit(outPrice.subtract(inPrice), "retail", priceLimit, "***", request));
|
obj.put("y", roleService.parseHomePriceByLimit(outPrice.subtract(inPrice), "retail", priceLimit, "***", request));
|
||||||
retailPriceList.add(obj);
|
retailPriceList.add(obj);
|
||||||
|
|||||||
@@ -241,18 +241,7 @@ public interface DepotHeadMapperEx {
|
|||||||
|
|
||||||
List<DepotHead> getDepotHeadListByCreator(@Param("creatorArray") String[] creatorArray);
|
List<DepotHead> getDepotHeadListByCreator(@Param("creatorArray") String[] creatorArray);
|
||||||
|
|
||||||
BigDecimal getBuyAndSaleBasicStatistics(
|
List<InOutPriceVo> getBuyAndSaleStatisticsList(
|
||||||
@Param("type") String type,
|
|
||||||
@Param("subType") String subType,
|
|
||||||
@Param("hasSupplier") Integer hasSupplier,
|
|
||||||
@Param("beginTime") String beginTime,
|
|
||||||
@Param("endTime") String endTime,
|
|
||||||
@Param("creatorArray") String[] creatorArray,
|
|
||||||
@Param("forceFlag") Boolean forceFlag);
|
|
||||||
|
|
||||||
BigDecimal getBuyAndSaleRetailStatistics(
|
|
||||||
@Param("type") String type,
|
|
||||||
@Param("subType") String subType,
|
|
||||||
@Param("beginTime") String beginTime,
|
@Param("beginTime") String beginTime,
|
||||||
@Param("endTime") String endTime,
|
@Param("endTime") String endTime,
|
||||||
@Param("creatorArray") String[] creatorArray,
|
@Param("creatorArray") String[] creatorArray,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.jsh.erp.datasource.entities.*;
|
|||||||
import com.jsh.erp.datasource.vo.DepotItemStockWarningCount;
|
import com.jsh.erp.datasource.vo.DepotItemStockWarningCount;
|
||||||
import com.jsh.erp.datasource.vo.DepotItemVo4Stock;
|
import com.jsh.erp.datasource.vo.DepotItemVo4Stock;
|
||||||
import com.jsh.erp.datasource.vo.DepotItemVoBatchNumberList;
|
import com.jsh.erp.datasource.vo.DepotItemVoBatchNumberList;
|
||||||
|
import com.jsh.erp.datasource.vo.InOutPriceVo;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@@ -133,17 +134,7 @@ public interface DepotItemMapperEx {
|
|||||||
@Param("depotList") List<Long> depotList,
|
@Param("depotList") List<Long> depotList,
|
||||||
@Param("forceFlag") Boolean forceFlag);
|
@Param("forceFlag") Boolean forceFlag);
|
||||||
|
|
||||||
BigDecimal inOrOutPrice(
|
List<InOutPriceVo> inOrOutPriceList(
|
||||||
@Param("type") String type,
|
|
||||||
@Param("subType") String subType,
|
|
||||||
@Param("beginTime") String beginTime,
|
|
||||||
@Param("endTime") String endTime,
|
|
||||||
@Param("creatorArray") String[] creatorArray,
|
|
||||||
@Param("forceFlag") Boolean forceFlag);
|
|
||||||
|
|
||||||
BigDecimal inOrOutRetailPrice(
|
|
||||||
@Param("type") String type,
|
|
||||||
@Param("subType") String subType,
|
|
||||||
@Param("beginTime") String beginTime,
|
@Param("beginTime") String beginTime,
|
||||||
@Param("endTime") String endTime,
|
@Param("endTime") String endTime,
|
||||||
@Param("creatorArray") String[] creatorArray,
|
@Param("creatorArray") String[] creatorArray,
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.jsh.erp.datasource.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author jishenghua
|
||||||
|
* @Date 2024-04-26 22:23
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class InOutPriceVo {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private BigDecimal discountLastMoney;
|
||||||
|
|
||||||
|
private BigDecimal totalPrice;
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
private String subType;
|
||||||
|
|
||||||
|
private Date operTime;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1224,60 +1224,126 @@ public class DepotHeadService {
|
|||||||
String yearBegin, String yearEnd, HttpServletRequest request) throws Exception {
|
String yearBegin, String yearEnd, HttpServletRequest request) throws Exception {
|
||||||
Long userId = userService.getUserId(request);
|
Long userId = userService.getUserId(request);
|
||||||
String priceLimit = userService.getRoleTypeByUserId(userId).getPriceLimit();
|
String priceLimit = userService.getRoleTypeByUserId(userId).getPriceLimit();
|
||||||
|
Boolean forceFlag = systemConfigService.getForceApprovalFlag();
|
||||||
String [] creatorArray = getCreatorArray();
|
String [] creatorArray = getCreatorArray();
|
||||||
|
List<InOutPriceVo> inOutPriceVoList = depotHeadMapperEx.getBuyAndSaleStatisticsList(yearBegin, yearEnd, creatorArray, forceFlag);
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
//今日
|
//今日
|
||||||
BigDecimal todayBuy = getBuyAndSaleBasicStatistics("入库", "采购",
|
BigDecimal todayBuy = BigDecimal.ZERO; //今日采购入库
|
||||||
1, today, getNow3(), creatorArray); //今日采购入库
|
BigDecimal todayBuyBack = BigDecimal.ZERO; //今日采购退货
|
||||||
BigDecimal todayBuyBack = getBuyAndSaleBasicStatistics("出库", "采购退货",
|
BigDecimal todaySale = BigDecimal.ZERO; //今日销售出库
|
||||||
1, today, getNow3(), creatorArray); //今日采购退货
|
BigDecimal todaySaleBack = BigDecimal.ZERO; //今日销售退货
|
||||||
BigDecimal todaySale = getBuyAndSaleBasicStatistics("出库", "销售",
|
BigDecimal todayRetailSale = BigDecimal.ZERO; //今日零售出库
|
||||||
1, today, getNow3(), creatorArray); //今日销售出库
|
BigDecimal todayRetailSaleBack = BigDecimal.ZERO; //今日零售退货
|
||||||
BigDecimal todaySaleBack = getBuyAndSaleBasicStatistics("入库", "销售退货",
|
for(InOutPriceVo item: inOutPriceVoList) {
|
||||||
1, today, getNow3(), creatorArray); //今日销售退货
|
if(item.getOperTime().compareTo(Tools.strToDate(today))>=0 && item.getOperTime().compareTo(Tools.strToDate(getNow3()))<=0) {
|
||||||
BigDecimal todayRetailSale = getBuyAndSaleRetailStatistics("出库", "零售",
|
if("入库".equals(item.getType()) && "采购".equals(item.getSubType())) {
|
||||||
today, getNow3(), creatorArray); //今日零售出库
|
todayBuy = todayBuy.add(item.getDiscountLastMoney());
|
||||||
BigDecimal todayRetailSaleBack = getBuyAndSaleRetailStatistics("入库", "零售退货",
|
}
|
||||||
today, getNow3(), creatorArray); //今日零售退货
|
if("出库".equals(item.getType()) && "采购退货".equals(item.getSubType())) {
|
||||||
|
todayBuyBack = todayBuyBack.add(item.getDiscountLastMoney());
|
||||||
|
}
|
||||||
|
if("出库".equals(item.getType()) && "销售".equals(item.getSubType())) {
|
||||||
|
todaySale = todaySale.add(item.getDiscountLastMoney());
|
||||||
|
}
|
||||||
|
if("入库".equals(item.getType()) && "销售退货".equals(item.getSubType())) {
|
||||||
|
todaySaleBack = todaySaleBack.add(item.getDiscountLastMoney());
|
||||||
|
}
|
||||||
|
if("出库".equals(item.getType()) && "零售".equals(item.getSubType())) {
|
||||||
|
todayRetailSale = todayRetailSale.add(item.getTotalPrice().abs());
|
||||||
|
}
|
||||||
|
if("入库".equals(item.getType()) && "零售退货".equals(item.getSubType())) {
|
||||||
|
todayRetailSaleBack = todayRetailSaleBack.add(item.getTotalPrice().abs());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//本月
|
//本月
|
||||||
BigDecimal monthBuy = getBuyAndSaleBasicStatistics("入库", "采购",
|
BigDecimal monthBuy = BigDecimal.ZERO; //本月采购入库
|
||||||
1, monthFirstDay, getNow3(), creatorArray); //本月采购入库
|
BigDecimal monthBuyBack = BigDecimal.ZERO; //本月采购退货
|
||||||
BigDecimal monthBuyBack = getBuyAndSaleBasicStatistics("出库", "采购退货",
|
BigDecimal monthSale = BigDecimal.ZERO; //本月销售出库
|
||||||
1, monthFirstDay, getNow3(), creatorArray); //本月采购退货
|
BigDecimal monthSaleBack = BigDecimal.ZERO; //本月销售退货
|
||||||
BigDecimal monthSale = getBuyAndSaleBasicStatistics("出库", "销售",
|
BigDecimal monthRetailSale = BigDecimal.ZERO; //本月零售出库
|
||||||
1,monthFirstDay, getNow3(), creatorArray); //本月销售出库
|
BigDecimal monthRetailSaleBack = BigDecimal.ZERO; //本月零售退货
|
||||||
BigDecimal monthSaleBack = getBuyAndSaleBasicStatistics("入库", "销售退货",
|
for(InOutPriceVo item: inOutPriceVoList) {
|
||||||
1,monthFirstDay, getNow3(), creatorArray); //本月销售退货
|
if(item.getOperTime().compareTo(Tools.strToDate(monthFirstDay))>=0 && item.getOperTime().compareTo(Tools.strToDate(getNow3()))<=0) {
|
||||||
BigDecimal monthRetailSale = getBuyAndSaleRetailStatistics("出库", "零售",
|
if("入库".equals(item.getType()) && "采购".equals(item.getSubType())) {
|
||||||
monthFirstDay, getNow3(), creatorArray); //本月零售出库
|
monthBuy = monthBuy.add(item.getDiscountLastMoney());
|
||||||
BigDecimal monthRetailSaleBack = getBuyAndSaleRetailStatistics("入库", "零售退货",
|
}
|
||||||
monthFirstDay, getNow3(), creatorArray); //本月零售退货
|
if("出库".equals(item.getType()) && "采购退货".equals(item.getSubType())) {
|
||||||
|
monthBuyBack = monthBuyBack.add(item.getDiscountLastMoney());
|
||||||
|
}
|
||||||
|
if("出库".equals(item.getType()) && "销售".equals(item.getSubType())) {
|
||||||
|
monthSale = monthSale.add(item.getDiscountLastMoney());
|
||||||
|
}
|
||||||
|
if("入库".equals(item.getType()) && "销售退货".equals(item.getSubType())) {
|
||||||
|
monthSaleBack = monthSaleBack.add(item.getDiscountLastMoney());
|
||||||
|
}
|
||||||
|
if("出库".equals(item.getType()) && "零售".equals(item.getSubType())) {
|
||||||
|
monthRetailSale = monthRetailSale.add(item.getTotalPrice().abs());
|
||||||
|
}
|
||||||
|
if("入库".equals(item.getType()) && "零售退货".equals(item.getSubType())) {
|
||||||
|
monthRetailSaleBack = monthRetailSaleBack.add(item.getTotalPrice().abs());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//昨日
|
//昨日
|
||||||
BigDecimal yesterdayBuy = getBuyAndSaleBasicStatistics("入库", "采购",
|
BigDecimal yesterdayBuy = BigDecimal.ZERO; //昨日采购入库
|
||||||
1, yesterdayBegin, yesterdayEnd, creatorArray); //昨日采购入库
|
BigDecimal yesterdayBuyBack = BigDecimal.ZERO; //昨日采购退货
|
||||||
BigDecimal yesterdayBuyBack = getBuyAndSaleBasicStatistics("出库", "采购退货",
|
BigDecimal yesterdaySale = BigDecimal.ZERO; //昨日销售出库
|
||||||
1, yesterdayBegin, yesterdayEnd, creatorArray); //昨日采购退货
|
BigDecimal yesterdaySaleBack = BigDecimal.ZERO; //昨日销售退货
|
||||||
BigDecimal yesterdaySale = getBuyAndSaleBasicStatistics("出库", "销售",
|
BigDecimal yesterdayRetailSale = BigDecimal.ZERO; //昨日零售出库
|
||||||
1, yesterdayBegin, yesterdayEnd, creatorArray); //昨日销售出库
|
BigDecimal yesterdayRetailSaleBack = BigDecimal.ZERO; //昨日零售退货
|
||||||
BigDecimal yesterdaySaleBack = getBuyAndSaleBasicStatistics("入库", "销售退货",
|
for(InOutPriceVo item: inOutPriceVoList) {
|
||||||
1, yesterdayBegin, yesterdayEnd, creatorArray); //昨日销售退货
|
if(item.getOperTime().compareTo(Tools.strToDate(yesterdayBegin))>=0 && item.getOperTime().compareTo(Tools.strToDate(yesterdayEnd))<=0) {
|
||||||
BigDecimal yesterdayRetailSale = getBuyAndSaleRetailStatistics("出库", "零售",
|
if("入库".equals(item.getType()) && "采购".equals(item.getSubType())) {
|
||||||
yesterdayBegin, yesterdayEnd, creatorArray); //昨日零售出库
|
yesterdayBuy = yesterdayBuy.add(item.getDiscountLastMoney());
|
||||||
BigDecimal yesterdayRetailSaleBack = getBuyAndSaleRetailStatistics("入库", "零售退货",
|
}
|
||||||
yesterdayBegin, yesterdayEnd, creatorArray); //昨日零售退货
|
if("出库".equals(item.getType()) && "采购退货".equals(item.getSubType())) {
|
||||||
|
yesterdayBuyBack = yesterdayBuyBack.add(item.getDiscountLastMoney());
|
||||||
|
}
|
||||||
|
if("出库".equals(item.getType()) && "销售".equals(item.getSubType())) {
|
||||||
|
yesterdaySale = yesterdaySale.add(item.getDiscountLastMoney());
|
||||||
|
}
|
||||||
|
if("入库".equals(item.getType()) && "销售退货".equals(item.getSubType())) {
|
||||||
|
yesterdaySaleBack = yesterdaySaleBack.add(item.getDiscountLastMoney());
|
||||||
|
}
|
||||||
|
if("出库".equals(item.getType()) && "零售".equals(item.getSubType())) {
|
||||||
|
yesterdayRetailSale = yesterdayRetailSale.add(item.getTotalPrice().abs());
|
||||||
|
}
|
||||||
|
if("入库".equals(item.getType()) && "零售退货".equals(item.getSubType())) {
|
||||||
|
yesterdayRetailSaleBack = yesterdayRetailSaleBack.add(item.getTotalPrice().abs());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//今年
|
//今年
|
||||||
BigDecimal yearBuy = getBuyAndSaleBasicStatistics("入库", "采购",
|
BigDecimal yearBuy = BigDecimal.ZERO; //今年采购入库
|
||||||
1, yearBegin, yearEnd, creatorArray); //今年采购入库
|
BigDecimal yearBuyBack = BigDecimal.ZERO; //今年采购退货
|
||||||
BigDecimal yearBuyBack = getBuyAndSaleBasicStatistics("出库", "采购退货",
|
BigDecimal yearSale = BigDecimal.ZERO; //今年销售出库
|
||||||
1, yearBegin, yearEnd, creatorArray); //今年采购退货
|
BigDecimal yearSaleBack = BigDecimal.ZERO; //今年销售退货
|
||||||
BigDecimal yearSale = getBuyAndSaleBasicStatistics("出库", "销售",
|
BigDecimal yearRetailSale = BigDecimal.ZERO; //今年零售出库
|
||||||
1, yearBegin, yearEnd, creatorArray); //今年销售出库
|
BigDecimal yearRetailSaleBack = BigDecimal.ZERO; //今年零售退货
|
||||||
BigDecimal yearSaleBack = getBuyAndSaleBasicStatistics("入库", "销售退货",
|
for(InOutPriceVo item: inOutPriceVoList) {
|
||||||
1, yearBegin, yearEnd, creatorArray); //今年销售退货
|
if(item.getOperTime().compareTo(Tools.strToDate(yearBegin))>=0 && item.getOperTime().compareTo(Tools.strToDate(yearEnd))<=0) {
|
||||||
BigDecimal yearRetailSale = getBuyAndSaleRetailStatistics("出库", "零售",
|
if("入库".equals(item.getType()) && "采购".equals(item.getSubType())) {
|
||||||
yearBegin, yearEnd, creatorArray); //今年零售出库
|
yearBuy = yearBuy.add(item.getDiscountLastMoney());
|
||||||
BigDecimal yearRetailSaleBack = getBuyAndSaleRetailStatistics("入库", "零售退货",
|
}
|
||||||
yearBegin, yearEnd, creatorArray); //今年零售退货
|
if("出库".equals(item.getType()) && "采购退货".equals(item.getSubType())) {
|
||||||
|
yearBuyBack = yearBuyBack.add(item.getDiscountLastMoney());
|
||||||
|
}
|
||||||
|
if("出库".equals(item.getType()) && "销售".equals(item.getSubType())) {
|
||||||
|
yearSale = yearSale.add(item.getDiscountLastMoney());
|
||||||
|
}
|
||||||
|
if("入库".equals(item.getType()) && "销售退货".equals(item.getSubType())) {
|
||||||
|
yearSaleBack = yearSaleBack.add(item.getDiscountLastMoney());
|
||||||
|
}
|
||||||
|
if("出库".equals(item.getType()) && "零售".equals(item.getSubType())) {
|
||||||
|
yearRetailSale = yearRetailSale.add(item.getTotalPrice().abs());
|
||||||
|
}
|
||||||
|
if("入库".equals(item.getType()) && "零售退货".equals(item.getSubType())) {
|
||||||
|
yearRetailSaleBack = yearRetailSaleBack.add(item.getTotalPrice().abs());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
map.put("todayBuy", roleService.parseHomePriceByLimit(todayBuy.subtract(todayBuyBack), "buy", priceLimit, "***", request));
|
map.put("todayBuy", roleService.parseHomePriceByLimit(todayBuy.subtract(todayBuyBack), "buy", priceLimit, "***", request));
|
||||||
map.put("todaySale", roleService.parseHomePriceByLimit(todaySale.subtract(todaySaleBack), "sale", priceLimit, "***", request));
|
map.put("todaySale", roleService.parseHomePriceByLimit(todaySale.subtract(todaySaleBack), "sale", priceLimit, "***", request));
|
||||||
map.put("todayRetailSale", roleService.parseHomePriceByLimit(todayRetailSale.subtract(todayRetailSaleBack), "retail", priceLimit, "***", request));
|
map.put("todayRetailSale", roleService.parseHomePriceByLimit(todayRetailSale.subtract(todayRetailSaleBack), "retail", priceLimit, "***", request));
|
||||||
@@ -1293,18 +1359,6 @@ public class DepotHeadService {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getBuyAndSaleBasicStatistics(String type, String subType, Integer hasSupplier,
|
|
||||||
String beginTime, String endTime, String[] creatorArray) throws Exception {
|
|
||||||
Boolean forceFlag = systemConfigService.getForceApprovalFlag();
|
|
||||||
return depotHeadMapperEx.getBuyAndSaleBasicStatistics(type, subType, hasSupplier, beginTime, endTime, creatorArray, forceFlag);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getBuyAndSaleRetailStatistics(String type, String subType,
|
|
||||||
String beginTime, String endTime, String[] creatorArray) throws Exception {
|
|
||||||
Boolean forceFlag = systemConfigService.getForceApprovalFlag();
|
|
||||||
return depotHeadMapperEx.getBuyAndSaleRetailStatistics(type, subType, beginTime, endTime, creatorArray, forceFlag).abs();
|
|
||||||
}
|
|
||||||
|
|
||||||
public DepotHead getDepotHead(String number)throws Exception {
|
public DepotHead getDepotHead(String number)throws Exception {
|
||||||
DepotHead depotHead = new DepotHead();
|
DepotHead depotHead = new DepotHead();
|
||||||
try{
|
try{
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.jsh.erp.datasource.mappers.*;
|
|||||||
import com.jsh.erp.datasource.vo.DepotItemStockWarningCount;
|
import com.jsh.erp.datasource.vo.DepotItemStockWarningCount;
|
||||||
import com.jsh.erp.datasource.vo.DepotItemVo4Stock;
|
import com.jsh.erp.datasource.vo.DepotItemVo4Stock;
|
||||||
import com.jsh.erp.datasource.vo.DepotItemVoBatchNumberList;
|
import com.jsh.erp.datasource.vo.DepotItemVoBatchNumberList;
|
||||||
|
import com.jsh.erp.datasource.vo.InOutPriceVo;
|
||||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||||
import com.jsh.erp.exception.JshException;
|
import com.jsh.erp.exception.JshException;
|
||||||
import com.jsh.erp.service.depot.DepotService;
|
import com.jsh.erp.service.depot.DepotService;
|
||||||
@@ -369,44 +370,18 @@ public class DepotItemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 统计采购或销售的总金额
|
* 统计采购、销售、零售的总金额列表
|
||||||
* @param type
|
* @param beginTime
|
||||||
* @param subType
|
* @param endTime
|
||||||
* @param month
|
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public BigDecimal inOrOutPrice(String type, String subType, String month) throws Exception{
|
public List<InOutPriceVo> inOrOutPriceList(String beginTime, String endTime) throws Exception{
|
||||||
BigDecimal result= BigDecimal.ZERO;
|
List<InOutPriceVo> result = new ArrayList<>();
|
||||||
try{
|
try{
|
||||||
String [] creatorArray = depotHeadService.getCreatorArray();
|
String [] creatorArray = depotHeadService.getCreatorArray();
|
||||||
Boolean forceFlag = systemConfigService.getForceApprovalFlag();
|
Boolean forceFlag = systemConfigService.getForceApprovalFlag();
|
||||||
String beginTime = Tools.firstDayOfMonth(month) + BusinessConstants.DAY_FIRST_TIME;
|
result = depotItemMapperEx.inOrOutPriceList(beginTime, endTime, creatorArray, forceFlag);
|
||||||
String endTime = Tools.lastDayOfMonth(month) + BusinessConstants.DAY_LAST_TIME;
|
|
||||||
result = depotItemMapperEx.inOrOutPrice(type, subType, beginTime, endTime, creatorArray, forceFlag);
|
|
||||||
}catch(Exception e){
|
|
||||||
JshException.readFail(logger, e);
|
|
||||||
}
|
|
||||||
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 [] creatorArray = depotHeadService.getCreatorArray();
|
|
||||||
Boolean forceFlag = systemConfigService.getForceApprovalFlag();
|
|
||||||
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, creatorArray, forceFlag);
|
|
||||||
result = result.abs();
|
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
JshException.readFail(logger, e);
|
JshException.readFail(logger, e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,6 +83,29 @@ public class Tools {
|
|||||||
return new SimpleDateFormat("yyyy-MM").format(new Date());
|
return new SimpleDateFormat("yyyy-MM").format(new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得指定时间,格式为yyyy-MM-dd HH:mm:ss或yyyy-MM-dd
|
||||||
|
*
|
||||||
|
* @return 格式化后的日期格式
|
||||||
|
*/
|
||||||
|
public static String dateToStr(Date date, String format) {
|
||||||
|
if(date!=null) {
|
||||||
|
return new SimpleDateFormat(format).format(date);
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将日期的字符串格式转为时间格式
|
||||||
|
* @param dateString
|
||||||
|
* @return
|
||||||
|
* @throws ParseException
|
||||||
|
*/
|
||||||
|
public static Date strToDate(String dateString) throws ParseException {
|
||||||
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 日期格式
|
||||||
|
return formatter.parse(dateString); // 字符串转换为Date
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 获取指定日期格式 yyyy-MM-dd
|
* 获取指定日期格式 yyyy-MM-dd
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1086,26 +1086,12 @@
|
|||||||
and ifnull(delete_flag,'0') !='1'
|
and ifnull(delete_flag,'0') !='1'
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getBuyAndSaleBasicStatistics" resultType="java.math.BigDecimal">
|
<select id="getBuyAndSaleStatisticsList" resultType="com.jsh.erp.datasource.vo.InOutPriceVo">
|
||||||
select
|
select distinct dh.id, dh.discount_last_money, dh.total_price, dh.type, dh.sub_type, dh.oper_time
|
||||||
ifnull(sum(discount_last_money),0) from
|
|
||||||
(select distinct dh.id, dh.discount_last_money
|
|
||||||
from jsh_depot_head dh
|
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 and ifnull(di.delete_flag,'0') !='1'
|
||||||
where 1=1
|
where di.id is not null
|
||||||
and di.id is not null
|
and (dh.type='入库' or dh.type='出库')
|
||||||
<if test="type != null">
|
|
||||||
and dh.type=#{type}
|
|
||||||
</if>
|
|
||||||
<if test="subType != null">
|
|
||||||
and dh.sub_type=#{subType}
|
|
||||||
</if>
|
|
||||||
<if test="hasSupplier == 1">
|
|
||||||
and dh.organ_id is not null
|
|
||||||
</if>
|
|
||||||
<if test="hasSupplier == 0">
|
|
||||||
and dh.organ_id is null
|
|
||||||
</if>
|
|
||||||
<if test="beginTime != null">
|
<if test="beginTime != null">
|
||||||
and dh.oper_time >= #{beginTime}
|
and dh.oper_time >= #{beginTime}
|
||||||
</if>
|
</if>
|
||||||
@@ -1123,41 +1109,6 @@
|
|||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
and ifnull(dh.delete_flag,'0') !='1'
|
and ifnull(dh.delete_flag,'0') !='1'
|
||||||
and ifnull(di.delete_flag,'0') !='1') tb
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="getBuyAndSaleRetailStatistics" resultType="java.math.BigDecimal">
|
|
||||||
select
|
|
||||||
ifnull(sum(total_price),0) from
|
|
||||||
(select distinct dh.id, dh.total_price
|
|
||||||
from jsh_depot_head dh
|
|
||||||
left join jsh_depot_item di on dh.id = di.header_id
|
|
||||||
where 1=1
|
|
||||||
and di.id is not null
|
|
||||||
<if test="type != null">
|
|
||||||
and dh.type=#{type}
|
|
||||||
</if>
|
|
||||||
<if test="subType != null">
|
|
||||||
and dh.sub_type=#{subType}
|
|
||||||
</if>
|
|
||||||
<if test="beginTime != null">
|
|
||||||
and dh.oper_time >= #{beginTime}
|
|
||||||
</if>
|
|
||||||
<if test="endTime != null">
|
|
||||||
and dh.oper_time <= #{endTime}
|
|
||||||
</if>
|
|
||||||
<if test="forceFlag">
|
|
||||||
and (dh.status = '1' or dh.status = '2' or dh.status = '3')
|
|
||||||
</if>
|
|
||||||
<if test="creatorArray != null">
|
|
||||||
and dh.creator in (
|
|
||||||
<foreach collection="creatorArray" item="creator" separator=",">
|
|
||||||
#{creator}
|
|
||||||
</foreach>
|
|
||||||
)
|
|
||||||
</if>
|
|
||||||
and ifnull(dh.delete_flag,'0') !='1'
|
|
||||||
and ifnull(di.delete_flag,'0') !='1') tb
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="debtList" parameterType="com.jsh.erp.datasource.entities.DepotHeadExample" resultMap="ResultMapEx">
|
<select id="debtList" parameterType="com.jsh.erp.datasource.entities.DepotHeadExample" resultMap="ResultMapEx">
|
||||||
|
|||||||
@@ -631,14 +631,12 @@
|
|||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="inOrOutPrice" resultType="java.math.BigDecimal">
|
<select id="inOrOutPriceList" resultType="com.jsh.erp.datasource.vo.InOutPriceVo">
|
||||||
select ifnull(sum(discount_last_money),0) as allMoney from
|
select distinct dh.id, dh.discount_last_money, dh.total_price, dh.type, dh.sub_type, dh.oper_time
|
||||||
(select distinct dh.id, dh.discount_last_money
|
|
||||||
from jsh_depot_head dh
|
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 and ifnull(di.delete_flag,'0') != '1'
|
||||||
where 1=1
|
where di.id is not null
|
||||||
and di.id is not null
|
and (dh.type='入库' or dh.type='出库')
|
||||||
and dh.type=#{type} and dh.sub_type=#{subType}
|
|
||||||
and dh.oper_time >= #{beginTime}
|
and dh.oper_time >= #{beginTime}
|
||||||
and dh.oper_time <= #{endTime}
|
and dh.oper_time <= #{endTime}
|
||||||
<if test="forceFlag">
|
<if test="forceFlag">
|
||||||
@@ -652,31 +650,6 @@
|
|||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
and ifnull(dh.delete_flag,'0') != '1'
|
and ifnull(dh.delete_flag,'0') != '1'
|
||||||
and ifnull(di.delete_flag, '0') != '1') tb
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="inOrOutRetailPrice" resultType="java.math.BigDecimal">
|
|
||||||
select ifnull(sum(total_price),0) as allMoney from
|
|
||||||
(select distinct dh.id, dh.total_price
|
|
||||||
from jsh_depot_head dh
|
|
||||||
left join jsh_depot_item di on dh.id = di.header_id
|
|
||||||
where 1=1
|
|
||||||
and di.id is not null
|
|
||||||
and dh.type=#{type} and dh.sub_type=#{subType}
|
|
||||||
and dh.oper_time >= #{beginTime}
|
|
||||||
and dh.oper_time <= #{endTime}
|
|
||||||
<if test="forceFlag">
|
|
||||||
and (dh.status = '1' or dh.status = '2' or dh.status = '3')
|
|
||||||
</if>
|
|
||||||
<if test="creatorArray != null">
|
|
||||||
and dh.creator in (
|
|
||||||
<foreach collection="creatorArray" item="creator" separator=",">
|
|
||||||
#{creator}
|
|
||||||
</foreach>
|
|
||||||
)
|
|
||||||
</if>
|
|
||||||
and ifnull(dh.delete_flag,'0') !='1'
|
|
||||||
and ifnull(di.delete_flag, '0') != '1') tb
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getSkuStockCheckSumByDepotList" resultType="java.math.BigDecimal">
|
<select id="getSkuStockCheckSumByDepotList" resultType="java.math.BigDecimal">
|
||||||
@@ -1102,4 +1075,5 @@
|
|||||||
order by dh.id desc, di.id desc
|
order by dh.id desc, di.id desc
|
||||||
limit 0,1
|
limit 0,1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user