优化首页的统计接口,提高查询速度

This commit is contained in:
jishenghua
2024-04-27 00:58:11 +08:00
parent 4fe3408a25
commit a6334c7345
9 changed files with 233 additions and 212 deletions

View File

@@ -7,6 +7,7 @@ import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.vo.DepotItemStockWarningCount;
import com.jsh.erp.datasource.vo.DepotItemVoBatchNumberList;
import com.jsh.erp.datasource.vo.InOutPriceVo;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.depot.DepotService;
import com.jsh.erp.service.depotHead.DepotHeadService;
@@ -806,33 +807,69 @@ public class DepotItemController {
Map<String, Object> map = new HashMap<String, Object>();
try {
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();
List<String> list = Tools.getLastMonths(6);
JSONArray buyPriceList = new JSONArray();
for(String month: list) {
for(String month: monthList) {
JSONObject obj = new JSONObject();
BigDecimal outPrice = depotItemService.inOrOutPrice("入库", "采购", month);
BigDecimal inPrice = depotItemService.inOrOutPrice("出库", "采购退货", month);
BigDecimal outPrice = BigDecimal.ZERO;
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("y", roleService.parseHomePriceByLimit(outPrice.subtract(inPrice), "buy", priceLimit, "***", request));
buyPriceList.add(obj);
}
map.put("buyPriceList", buyPriceList);
JSONArray salePriceList = new JSONArray();
for(String month: list) {
for(String month: monthList) {
JSONObject obj = new JSONObject();
BigDecimal outPrice = depotItemService.inOrOutPrice("出库", "销售", month);
BigDecimal inPrice = depotItemService.inOrOutPrice("入库", "销售退货", month);
BigDecimal outPrice = BigDecimal.ZERO;
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("y", roleService.parseHomePriceByLimit(outPrice.subtract(inPrice), "sale", priceLimit, "***", request));
salePriceList.add(obj);
}
map.put("salePriceList", salePriceList);
JSONArray retailPriceList = new JSONArray();
for(String month: list) {
for(String month: monthList) {
JSONObject obj = new JSONObject();
BigDecimal outPrice = depotItemService.inOrOutRetailPrice("出库", "零售", month);
BigDecimal inPrice = depotItemService.inOrOutRetailPrice("入库", "零售退货", month);
BigDecimal outPrice = BigDecimal.ZERO;
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("y", roleService.parseHomePriceByLimit(outPrice.subtract(inPrice), "retail", priceLimit, "***", request));
retailPriceList.add(obj);

View File

@@ -241,18 +241,7 @@ public interface DepotHeadMapperEx {
List<DepotHead> getDepotHeadListByCreator(@Param("creatorArray") String[] creatorArray);
BigDecimal getBuyAndSaleBasicStatistics(
@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,
List<InOutPriceVo> getBuyAndSaleStatisticsList(
@Param("beginTime") String beginTime,
@Param("endTime") String endTime,
@Param("creatorArray") String[] creatorArray,

View File

@@ -4,6 +4,7 @@ import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.vo.DepotItemStockWarningCount;
import com.jsh.erp.datasource.vo.DepotItemVo4Stock;
import com.jsh.erp.datasource.vo.DepotItemVoBatchNumberList;
import com.jsh.erp.datasource.vo.InOutPriceVo;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
@@ -133,17 +134,7 @@ public interface DepotItemMapperEx {
@Param("depotList") List<Long> depotList,
@Param("forceFlag") Boolean forceFlag);
BigDecimal inOrOutPrice(
@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,
List<InOutPriceVo> inOrOutPriceList(
@Param("beginTime") String beginTime,
@Param("endTime") String endTime,
@Param("creatorArray") String[] creatorArray,

View File

@@ -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;
}

View File

@@ -1224,60 +1224,126 @@ public class DepotHeadService {
String yearBegin, String yearEnd, HttpServletRequest request) throws Exception {
Long userId = userService.getUserId(request);
String priceLimit = userService.getRoleTypeByUserId(userId).getPriceLimit();
Boolean forceFlag = systemConfigService.getForceApprovalFlag();
String [] creatorArray = getCreatorArray();
List<InOutPriceVo> inOutPriceVoList = depotHeadMapperEx.getBuyAndSaleStatisticsList(yearBegin, yearEnd, creatorArray, forceFlag);
Map<String, Object> map = new HashMap<>();
//今日
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); //今日零售退货
BigDecimal todayBuy = BigDecimal.ZERO; //今日采购入库
BigDecimal todayBuyBack = BigDecimal.ZERO; //今日采购退货
BigDecimal todaySale = BigDecimal.ZERO; //今日销售出库
BigDecimal todaySaleBack = BigDecimal.ZERO; //今日销售退货
BigDecimal todayRetailSale = BigDecimal.ZERO; //今日零售出库
BigDecimal todayRetailSaleBack = BigDecimal.ZERO; //今日零售退货
for(InOutPriceVo item: inOutPriceVoList) {
if(item.getOperTime().compareTo(Tools.strToDate(today))>=0 && item.getOperTime().compareTo(Tools.strToDate(getNow3()))<=0) {
if("入库".equals(item.getType()) && "采购".equals(item.getSubType())) {
todayBuy = todayBuy.add(item.getDiscountLastMoney());
}
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("入库", "采购",
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); //本月零售退货
BigDecimal monthBuy = BigDecimal.ZERO; //本月采购入库
BigDecimal monthBuyBack = BigDecimal.ZERO; //本月采购退货
BigDecimal monthSale = BigDecimal.ZERO; //本月销售出库
BigDecimal monthSaleBack = BigDecimal.ZERO; //本月销售退货
BigDecimal monthRetailSale = BigDecimal.ZERO; //本月零售出库
BigDecimal monthRetailSaleBack = BigDecimal.ZERO; //本月零售退货
for(InOutPriceVo item: inOutPriceVoList) {
if(item.getOperTime().compareTo(Tools.strToDate(monthFirstDay))>=0 && item.getOperTime().compareTo(Tools.strToDate(getNow3()))<=0) {
if("入库".equals(item.getType()) && "采购".equals(item.getSubType())) {
monthBuy = monthBuy.add(item.getDiscountLastMoney());
}
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("入库", "采购",
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); //昨日零售退货
BigDecimal yesterdayBuy = BigDecimal.ZERO; //昨日采购入库
BigDecimal yesterdayBuyBack = BigDecimal.ZERO; //昨日采购退货
BigDecimal yesterdaySale = BigDecimal.ZERO; //昨日销售出库
BigDecimal yesterdaySaleBack = BigDecimal.ZERO; //昨日销售退货
BigDecimal yesterdayRetailSale = BigDecimal.ZERO; //昨日零售出库
BigDecimal yesterdayRetailSaleBack = BigDecimal.ZERO; //昨日零售退货
for(InOutPriceVo item: inOutPriceVoList) {
if(item.getOperTime().compareTo(Tools.strToDate(yesterdayBegin))>=0 && item.getOperTime().compareTo(Tools.strToDate(yesterdayEnd))<=0) {
if("入库".equals(item.getType()) && "采购".equals(item.getSubType())) {
yesterdayBuy = yesterdayBuy.add(item.getDiscountLastMoney());
}
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("入库", "采购",
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); //今年零售退货
BigDecimal yearBuy = BigDecimal.ZERO; //今年采购入库
BigDecimal yearBuyBack = BigDecimal.ZERO; //今年采购退货
BigDecimal yearSale = BigDecimal.ZERO; //今年销售出库
BigDecimal yearSaleBack = BigDecimal.ZERO; //今年销售退货
BigDecimal yearRetailSale = BigDecimal.ZERO; //今年零售出库
BigDecimal yearRetailSaleBack = BigDecimal.ZERO; //今年零售退货
for(InOutPriceVo item: inOutPriceVoList) {
if(item.getOperTime().compareTo(Tools.strToDate(yearBegin))>=0 && item.getOperTime().compareTo(Tools.strToDate(yearEnd))<=0) {
if("入库".equals(item.getType()) && "采购".equals(item.getSubType())) {
yearBuy = yearBuy.add(item.getDiscountLastMoney());
}
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("todaySale", roleService.parseHomePriceByLimit(todaySale.subtract(todaySaleBack), "sale", priceLimit, "***", request));
map.put("todayRetailSale", roleService.parseHomePriceByLimit(todayRetailSale.subtract(todayRetailSaleBack), "retail", priceLimit, "***", request));
@@ -1293,18 +1359,6 @@ public class DepotHeadService {
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 {
DepotHead depotHead = new DepotHead();
try{

View File

@@ -9,6 +9,7 @@ import com.jsh.erp.datasource.mappers.*;
import com.jsh.erp.datasource.vo.DepotItemStockWarningCount;
import com.jsh.erp.datasource.vo.DepotItemVo4Stock;
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.JshException;
import com.jsh.erp.service.depot.DepotService;
@@ -369,44 +370,18 @@ public class DepotItemService {
}
/**
* 统计采购销售的总金额
* @param type
* @param subType
* @param month
* 统计采购销售、零售的总金额列表
* @param beginTime
* @param endTime
* @return
* @throws Exception
*/
public BigDecimal inOrOutPrice(String type, String subType, String month) throws Exception{
BigDecimal result= BigDecimal.ZERO;
public List<InOutPriceVo> inOrOutPriceList(String beginTime, String endTime) throws Exception{
List<InOutPriceVo> result = new ArrayList<>();
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.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();
result = depotItemMapperEx.inOrOutPriceList(beginTime, endTime, creatorArray, forceFlag);
}catch(Exception e){
JshException.readFail(logger, e);
}

View File

@@ -83,6 +83,29 @@ public class Tools {
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
*

View File

@@ -1086,26 +1086,12 @@
and ifnull(delete_flag,'0') !='1'
</select>
<select id="getBuyAndSaleBasicStatistics" resultType="java.math.BigDecimal">
select
ifnull(sum(discount_last_money),0) from
(select distinct dh.id, dh.discount_last_money
<select id="getBuyAndSaleStatisticsList" resultType="com.jsh.erp.datasource.vo.InOutPriceVo">
select distinct dh.id, dh.discount_last_money, dh.total_price, dh.type, dh.sub_type, dh.oper_time
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="hasSupplier == 1">
and dh.organ_id is not null
</if>
<if test="hasSupplier == 0">
and dh.organ_id is null
</if>
left join jsh_depot_item di on dh.id = di.header_id and ifnull(di.delete_flag,'0') !='1'
where di.id is not null
and (dh.type='入库' or dh.type='出库')
<if test="beginTime != null">
and dh.oper_time >= #{beginTime}
</if>
@@ -1123,41 +1109,6 @@
)
</if>
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 &lt;= #{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 id="debtList" parameterType="com.jsh.erp.datasource.entities.DepotHeadExample" resultMap="ResultMapEx">

View File

@@ -631,14 +631,12 @@
</if>
</select>
<select id="inOrOutPrice" resultType="java.math.BigDecimal">
select ifnull(sum(discount_last_money),0) as allMoney from
(select distinct dh.id, dh.discount_last_money
<select id="inOrOutPriceList" resultType="com.jsh.erp.datasource.vo.InOutPriceVo">
select distinct dh.id, dh.discount_last_money, dh.total_price, dh.type, dh.sub_type, dh.oper_time
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}
left join jsh_depot_item di on dh.id = di.header_id and ifnull(di.delete_flag,'0') != '1'
where di.id is not null
and (dh.type='入库' or dh.type='出库')
and dh.oper_time &gt;= #{beginTime}
and dh.oper_time &lt;= #{endTime}
<if test="forceFlag">
@@ -651,32 +649,7 @@
</foreach>
)
</if>
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 &gt;= #{beginTime}
and dh.oper_time &lt;= #{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
and ifnull(dh.delete_flag,'0') != '1'
</select>
<select id="getSkuStockCheckSumByDepotList" resultType="java.math.BigDecimal">
@@ -1102,4 +1075,5 @@
order by dh.id desc, di.id desc
limit 0,1
</select>
</mapper>