mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 20:28:44 +08:00 
			
		
		
		
	Merge branch 'develop' of https://gitee.com/zhijiantianya/ruoyi-vue-pro into master-jdk21
This commit is contained in:
		@@ -0,0 +1,69 @@
 | 
			
		||||
package cn.iocoder.yudao.module.erp.controller.admin.statistics;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.date.LocalDateTimeUtil;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
 | 
			
		||||
import cn.iocoder.yudao.module.erp.controller.admin.statistics.vo.purchase.ErpPurchaseSummaryRespVO;
 | 
			
		||||
import cn.iocoder.yudao.module.erp.controller.admin.statistics.vo.purchase.ErpPurchaseTimeSummaryRespVO;
 | 
			
		||||
import cn.iocoder.yudao.module.erp.service.statistics.ErpPurchaseStatisticsService;
 | 
			
		||||
import io.swagger.v3.oas.annotations.Operation;
 | 
			
		||||
import io.swagger.v3.oas.annotations.Parameter;
 | 
			
		||||
import io.swagger.v3.oas.annotations.tags.Tag;
 | 
			
		||||
import jakarta.annotation.Resource;
 | 
			
		||||
import org.springframework.security.access.prepost.PreAuthorize;
 | 
			
		||||
import org.springframework.validation.annotation.Validated;
 | 
			
		||||
import org.springframework.web.bind.annotation.GetMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestParam;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import static cn.hutool.core.date.DatePattern.NORM_MONTH_PATTERN;
 | 
			
		||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 | 
			
		||||
 | 
			
		||||
@Tag(name = "管理后台 - ERP 采购统计")
 | 
			
		||||
@RestController
 | 
			
		||||
@RequestMapping("/erp/purchase-statistics")
 | 
			
		||||
@Validated
 | 
			
		||||
public class ErpPurchaseStatisticsController {
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private ErpPurchaseStatisticsService purchaseStatisticsService;
 | 
			
		||||
 | 
			
		||||
    @GetMapping("/summary")
 | 
			
		||||
    @Operation(summary = "获得采购统计")
 | 
			
		||||
    @PreAuthorize("@ss.hasPermission('erp:statistics:query')")
 | 
			
		||||
    public CommonResult<ErpPurchaseSummaryRespVO> getPurchaseSummary() {
 | 
			
		||||
        LocalDateTime today = LocalDateTimeUtils.getToday();
 | 
			
		||||
        LocalDateTime yesterday = LocalDateTimeUtils.getYesterday();
 | 
			
		||||
        LocalDateTime month = LocalDateTimeUtils.getMonth();
 | 
			
		||||
        LocalDateTime year = LocalDateTimeUtils.getYear();
 | 
			
		||||
        ErpPurchaseSummaryRespVO summary = new ErpPurchaseSummaryRespVO()
 | 
			
		||||
                .setTodayPrice(purchaseStatisticsService.getPurchasePrice(today, null))
 | 
			
		||||
                .setYesterdayPrice(purchaseStatisticsService.getPurchasePrice(yesterday, today))
 | 
			
		||||
                .setMonthPrice(purchaseStatisticsService.getPurchasePrice(month, null))
 | 
			
		||||
                .setYearPrice(purchaseStatisticsService.getPurchasePrice(year, null));
 | 
			
		||||
        return success(summary);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @GetMapping("/time-summary")
 | 
			
		||||
    @Operation(summary = "获得采购时间段统计")
 | 
			
		||||
    @Parameter(name = "count", description = "时间段数量", example = "6")
 | 
			
		||||
    @PreAuthorize("@ss.hasPermission('erp:statistics:query')")
 | 
			
		||||
    public CommonResult<List<ErpPurchaseTimeSummaryRespVO>> getPurchaseTimeSummary(
 | 
			
		||||
            @RequestParam(value = "count", defaultValue = "6") Integer count) {
 | 
			
		||||
        List<ErpPurchaseTimeSummaryRespVO> summaryList = new ArrayList<>();
 | 
			
		||||
        for (int i = count - 1; i >= 0; i--) {
 | 
			
		||||
            LocalDateTime startTime = LocalDateTimeUtils.beginOfMonth(LocalDateTime.now().minusMonths(i));
 | 
			
		||||
            LocalDateTime endTime = LocalDateTimeUtils.endOfMonth(startTime);
 | 
			
		||||
            summaryList.add(new ErpPurchaseTimeSummaryRespVO()
 | 
			
		||||
                    .setTime(LocalDateTimeUtil.format(startTime, NORM_MONTH_PATTERN))
 | 
			
		||||
                    .setPrice(purchaseStatisticsService.getPurchasePrice(startTime, endTime)));
 | 
			
		||||
        }
 | 
			
		||||
        return success(summaryList);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,11 @@
 | 
			
		||||
### 请求 /erp/sale-statistics/summary 接口 => 成功
 | 
			
		||||
GET {{baseUrl}}/erp/sale-statistics/summary
 | 
			
		||||
Content-Type: application/json
 | 
			
		||||
tenant-id: {{adminTenentId}}
 | 
			
		||||
Authorization: Bearer {{token}}
 | 
			
		||||
 | 
			
		||||
### 请求 /erp/sale-statistics/time-summary 接口 => 成功
 | 
			
		||||
GET {{baseUrl}}/erp/sale-statistics/time-summary
 | 
			
		||||
Content-Type: application/json
 | 
			
		||||
tenant-id: {{adminTenentId}}
 | 
			
		||||
Authorization: Bearer {{token}}
 | 
			
		||||
@@ -0,0 +1,69 @@
 | 
			
		||||
package cn.iocoder.yudao.module.erp.controller.admin.statistics;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.date.LocalDateTimeUtil;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
 | 
			
		||||
import cn.iocoder.yudao.module.erp.controller.admin.statistics.vo.sale.ErpSaleSummaryRespVO;
 | 
			
		||||
import cn.iocoder.yudao.module.erp.controller.admin.statistics.vo.sale.ErpSaleTimeSummaryRespVO;
 | 
			
		||||
import cn.iocoder.yudao.module.erp.service.statistics.ErpSaleStatisticsService;
 | 
			
		||||
import io.swagger.v3.oas.annotations.Operation;
 | 
			
		||||
import io.swagger.v3.oas.annotations.Parameter;
 | 
			
		||||
import io.swagger.v3.oas.annotations.tags.Tag;
 | 
			
		||||
import jakarta.annotation.Resource;
 | 
			
		||||
import org.springframework.security.access.prepost.PreAuthorize;
 | 
			
		||||
import org.springframework.validation.annotation.Validated;
 | 
			
		||||
import org.springframework.web.bind.annotation.GetMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestParam;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import static cn.hutool.core.date.DatePattern.NORM_MONTH_PATTERN;
 | 
			
		||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 | 
			
		||||
 | 
			
		||||
@Tag(name = "管理后台 - ERP 销售统计")
 | 
			
		||||
@RestController
 | 
			
		||||
@RequestMapping("/erp/sale-statistics")
 | 
			
		||||
@Validated
 | 
			
		||||
public class ErpSaleStatisticsController {
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private ErpSaleStatisticsService saleStatisticsService;
 | 
			
		||||
 | 
			
		||||
    @GetMapping("/summary")
 | 
			
		||||
    @Operation(summary = "获得销售统计")
 | 
			
		||||
    @PreAuthorize("@ss.hasPermission('erp:statistics:query')")
 | 
			
		||||
    public CommonResult<ErpSaleSummaryRespVO> getSaleSummary() {
 | 
			
		||||
        LocalDateTime today = LocalDateTimeUtils.getToday();
 | 
			
		||||
        LocalDateTime yesterday = LocalDateTimeUtils.getYesterday();
 | 
			
		||||
        LocalDateTime month = LocalDateTimeUtils.getMonth();
 | 
			
		||||
        LocalDateTime year = LocalDateTimeUtils.getYear();
 | 
			
		||||
        ErpSaleSummaryRespVO summary = new ErpSaleSummaryRespVO()
 | 
			
		||||
                .setTodayPrice(saleStatisticsService.getSalePrice(today, null))
 | 
			
		||||
                .setYesterdayPrice(saleStatisticsService.getSalePrice(yesterday, today))
 | 
			
		||||
                .setMonthPrice(saleStatisticsService.getSalePrice(month, null))
 | 
			
		||||
                .setYearPrice(saleStatisticsService.getSalePrice(year, null));
 | 
			
		||||
        return success(summary);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @GetMapping("/time-summary")
 | 
			
		||||
    @Operation(summary = "获得销售时间段统计")
 | 
			
		||||
    @Parameter(name = "count", description = "时间段数量", example = "6")
 | 
			
		||||
    @PreAuthorize("@ss.hasPermission('erp:statistics:query')")
 | 
			
		||||
    public CommonResult<List<ErpSaleTimeSummaryRespVO>> getSaleTimeSummary(
 | 
			
		||||
            @RequestParam(value = "count", defaultValue = "6") Integer count) {
 | 
			
		||||
        List<ErpSaleTimeSummaryRespVO> summaryList = new ArrayList<>();
 | 
			
		||||
        for (int i = count - 1; i >= 0; i--) {
 | 
			
		||||
            LocalDateTime startTime = LocalDateTimeUtils.beginOfMonth(LocalDateTime.now().minusMonths(i));
 | 
			
		||||
            LocalDateTime endTime = LocalDateTimeUtils.endOfMonth(startTime);
 | 
			
		||||
            summaryList.add(new ErpSaleTimeSummaryRespVO()
 | 
			
		||||
                    .setTime(LocalDateTimeUtil.format(startTime, NORM_MONTH_PATTERN))
 | 
			
		||||
                    .setPrice(saleStatisticsService.getSalePrice(startTime, endTime)));
 | 
			
		||||
        }
 | 
			
		||||
        return success(summaryList);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,24 @@
 | 
			
		||||
package cn.iocoder.yudao.module.erp.controller.admin.statistics.vo.purchase;
 | 
			
		||||
 | 
			
		||||
import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
import java.math.BigDecimal;
 | 
			
		||||
 | 
			
		||||
@Schema(description = "管理后台 - ERP 采购全局统计 Response VO")
 | 
			
		||||
@Data
 | 
			
		||||
public class ErpPurchaseSummaryRespVO {
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "今日采购金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
 | 
			
		||||
    private BigDecimal todayPrice;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "昨日采购金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "888")
 | 
			
		||||
    private BigDecimal yesterdayPrice;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "本月采购金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
 | 
			
		||||
    private BigDecimal monthPrice;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "今年采购金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "88888")
 | 
			
		||||
    private BigDecimal yearPrice;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,18 @@
 | 
			
		||||
package cn.iocoder.yudao.module.erp.controller.admin.statistics.vo.purchase;
 | 
			
		||||
 | 
			
		||||
import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
import java.math.BigDecimal;
 | 
			
		||||
 | 
			
		||||
@Schema(description = "管理后台 - ERP 采购某个时间段的统计 Response VO")
 | 
			
		||||
@Data
 | 
			
		||||
public class ErpPurchaseTimeSummaryRespVO {
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2022-03")
 | 
			
		||||
    private String time;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "采购金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
 | 
			
		||||
    private BigDecimal price;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,24 @@
 | 
			
		||||
package cn.iocoder.yudao.module.erp.controller.admin.statistics.vo.sale;
 | 
			
		||||
 | 
			
		||||
import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
import java.math.BigDecimal;
 | 
			
		||||
 | 
			
		||||
@Schema(description = "管理后台 - ERP 销售全局统计 Response VO")
 | 
			
		||||
@Data
 | 
			
		||||
public class ErpSaleSummaryRespVO {
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "今日销售金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
 | 
			
		||||
    private BigDecimal todayPrice;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "昨日销售金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "888")
 | 
			
		||||
    private BigDecimal yesterdayPrice;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "本月销售金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
 | 
			
		||||
    private BigDecimal monthPrice;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "今年销售金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "88888")
 | 
			
		||||
    private BigDecimal yearPrice;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,18 @@
 | 
			
		||||
package cn.iocoder.yudao.module.erp.controller.admin.statistics.vo.sale;
 | 
			
		||||
 | 
			
		||||
import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
import java.math.BigDecimal;
 | 
			
		||||
 | 
			
		||||
@Schema(description = "管理后台 - ERP 销售某个时间段的统计 Response VO")
 | 
			
		||||
@Data
 | 
			
		||||
public class ErpSaleTimeSummaryRespVO {
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2022-03")
 | 
			
		||||
    private String time;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "销售金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
 | 
			
		||||
    private BigDecimal price;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,20 @@
 | 
			
		||||
package cn.iocoder.yudao.module.erp.dal.mysql.statistics;
 | 
			
		||||
 | 
			
		||||
import org.apache.ibatis.annotations.Mapper;
 | 
			
		||||
import org.apache.ibatis.annotations.Param;
 | 
			
		||||
 | 
			
		||||
import java.math.BigDecimal;
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ERP 采购统计 Mapper
 | 
			
		||||
 *
 | 
			
		||||
 * @author 芋道源码
 | 
			
		||||
 */
 | 
			
		||||
@Mapper
 | 
			
		||||
public interface ErpPurchaseStatisticsMapper {
 | 
			
		||||
 | 
			
		||||
    BigDecimal getPurchasePrice(@Param("beginTime") LocalDateTime beginTime,
 | 
			
		||||
                                @Param("endTime") LocalDateTime endTime);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,20 @@
 | 
			
		||||
package cn.iocoder.yudao.module.erp.dal.mysql.statistics;
 | 
			
		||||
 | 
			
		||||
import org.apache.ibatis.annotations.Mapper;
 | 
			
		||||
import org.apache.ibatis.annotations.Param;
 | 
			
		||||
 | 
			
		||||
import java.math.BigDecimal;
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ERP 销售统计 Mapper
 | 
			
		||||
 *
 | 
			
		||||
 * @author 芋道源码
 | 
			
		||||
 */
 | 
			
		||||
@Mapper
 | 
			
		||||
public interface ErpSaleStatisticsMapper {
 | 
			
		||||
 | 
			
		||||
    BigDecimal getSalePrice(@Param("beginTime") LocalDateTime beginTime,
 | 
			
		||||
                            @Param("endTime") LocalDateTime endTime);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -13,6 +13,6 @@ public interface RedisKeyConstants {
 | 
			
		||||
     * KEY 格式:trade_no:{prefix}
 | 
			
		||||
     * VALUE 数据格式:编号自增
 | 
			
		||||
     */
 | 
			
		||||
    String NO = "seq_no:";
 | 
			
		||||
    String NO = "erp:seq_no:";
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,7 @@ import java.time.LocalDateTime;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 订单序号的 Redis DAO
 | 
			
		||||
 * Erp 订单序号的 Redis DAO
 | 
			
		||||
 *
 | 
			
		||||
 * @author HUIHUI
 | 
			
		||||
 */
 | 
			
		||||
 
 | 
			
		||||
@@ -164,7 +164,7 @@ public class ErpPurchaseInServiceImpl implements ErpPurchaseInService {
 | 
			
		||||
            throw exception(approve ? PURCHASE_IN_APPROVE_FAIL : PURCHASE_IN_PROCESS_FAIL);
 | 
			
		||||
        }
 | 
			
		||||
        // 1.3 校验已付款
 | 
			
		||||
        if (approve && purchaseIn.getPaymentPrice().compareTo(BigDecimal.ZERO) > 0) {
 | 
			
		||||
        if (!approve && purchaseIn.getPaymentPrice().compareTo(BigDecimal.ZERO) > 0) {
 | 
			
		||||
            throw exception(PURCHASE_IN_PROCESS_FAIL_EXISTS_PAYMENT);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -160,7 +160,7 @@ public class ErpPurchaseReturnServiceImpl implements ErpPurchaseReturnService {
 | 
			
		||||
            throw exception(approve ? PURCHASE_RETURN_APPROVE_FAIL : PURCHASE_RETURN_PROCESS_FAIL);
 | 
			
		||||
        }
 | 
			
		||||
        // 1.3 校验已退款
 | 
			
		||||
        if (approve && purchaseReturn.getRefundPrice().compareTo(BigDecimal.ZERO) > 0) {
 | 
			
		||||
        if (!approve && purchaseReturn.getRefundPrice().compareTo(BigDecimal.ZERO) > 0) {
 | 
			
		||||
            throw exception(PURCHASE_RETURN_PROCESS_FAIL_EXISTS_REFUND);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -172,7 +172,7 @@ public class ErpSaleOutServiceImpl implements ErpSaleOutService {
 | 
			
		||||
            throw exception(approve ? SALE_OUT_APPROVE_FAIL : SALE_OUT_PROCESS_FAIL);
 | 
			
		||||
        }
 | 
			
		||||
        // 1.3 校验已退款
 | 
			
		||||
        if (approve && saleOut.getReceiptPrice().compareTo(BigDecimal.ZERO) > 0) {
 | 
			
		||||
        if (!approve && saleOut.getReceiptPrice().compareTo(BigDecimal.ZERO) > 0) {
 | 
			
		||||
            throw exception(SALE_OUT_PROCESS_FAIL_EXISTS_RECEIPT);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -172,7 +172,7 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService {
 | 
			
		||||
            throw exception(approve ? SALE_RETURN_APPROVE_FAIL : SALE_RETURN_PROCESS_FAIL);
 | 
			
		||||
        }
 | 
			
		||||
        // 1.3 校验已退款
 | 
			
		||||
        if (approve && saleReturn.getRefundPrice().compareTo(BigDecimal.ZERO) > 0) {
 | 
			
		||||
        if (!approve && saleReturn.getRefundPrice().compareTo(BigDecimal.ZERO) > 0) {
 | 
			
		||||
            throw exception(SALE_RETURN_PROCESS_FAIL_EXISTS_REFUND);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,24 @@
 | 
			
		||||
package cn.iocoder.yudao.module.erp.service.statistics;
 | 
			
		||||
 | 
			
		||||
import java.math.BigDecimal;
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ERP 采购统计 Service 接口
 | 
			
		||||
 *
 | 
			
		||||
 * @author 芋道源码
 | 
			
		||||
 */
 | 
			
		||||
public interface ErpPurchaseStatisticsService {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获得采购金额
 | 
			
		||||
     *
 | 
			
		||||
     * 计算逻辑:采购出库的金额 - 采购退货的金额
 | 
			
		||||
     *
 | 
			
		||||
     * @param beginTime >= 开始时间
 | 
			
		||||
     * @param endTime < 结束时间
 | 
			
		||||
     * @return 采购金额
 | 
			
		||||
     */
 | 
			
		||||
    BigDecimal getPurchasePrice(LocalDateTime beginTime, LocalDateTime endTime);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,26 @@
 | 
			
		||||
package cn.iocoder.yudao.module.erp.service.statistics;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.module.erp.dal.mysql.statistics.ErpPurchaseStatisticsMapper;
 | 
			
		||||
import jakarta.annotation.Resource;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import java.math.BigDecimal;
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ERP 采购统计 Service 实现类
 | 
			
		||||
 *
 | 
			
		||||
 * @author 芋道源码
 | 
			
		||||
 */
 | 
			
		||||
@Service
 | 
			
		||||
public class ErpPurchaseStatisticsServiceImpl implements ErpPurchaseStatisticsService {
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private ErpPurchaseStatisticsMapper purchaseStatisticsMapper;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public BigDecimal getPurchasePrice(LocalDateTime beginTime, LocalDateTime endTime) {
 | 
			
		||||
        return purchaseStatisticsMapper.getPurchasePrice(beginTime, endTime);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,24 @@
 | 
			
		||||
package cn.iocoder.yudao.module.erp.service.statistics;
 | 
			
		||||
 | 
			
		||||
import java.math.BigDecimal;
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ERP 销售统计 Service 接口
 | 
			
		||||
 *
 | 
			
		||||
 * @author 芋道源码
 | 
			
		||||
 */
 | 
			
		||||
public interface ErpSaleStatisticsService {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获得销售金额
 | 
			
		||||
     *
 | 
			
		||||
     * 计算逻辑:销售出库的金额 - 销售退货的金额
 | 
			
		||||
     *
 | 
			
		||||
     * @param beginTime >= 开始时间
 | 
			
		||||
     * @param endTime < 结束时间
 | 
			
		||||
     * @return 销售金额
 | 
			
		||||
     */
 | 
			
		||||
    BigDecimal getSalePrice(LocalDateTime beginTime, LocalDateTime endTime);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,26 @@
 | 
			
		||||
package cn.iocoder.yudao.module.erp.service.statistics;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.module.erp.dal.mysql.statistics.ErpSaleStatisticsMapper;
 | 
			
		||||
import jakarta.annotation.Resource;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import java.math.BigDecimal;
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ERP 销售统计 Service 实现类
 | 
			
		||||
 *
 | 
			
		||||
 * @author 芋道源码
 | 
			
		||||
 */
 | 
			
		||||
@Service
 | 
			
		||||
public class ErpSaleStatisticsServiceImpl implements ErpSaleStatisticsService {
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private ErpSaleStatisticsMapper saleStatisticsMapper;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public BigDecimal getSalePrice(LocalDateTime beginTime, LocalDateTime endTime) {
 | 
			
		||||
        return saleStatisticsMapper.getSalePrice(beginTime, endTime);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,12 +0,0 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 | 
			
		||||
<mapper namespace="cn.iocoder.yudao.module.erp.dal.mysql.finance.ErpAccountMapper">
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
        一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
 | 
			
		||||
        无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
 | 
			
		||||
        代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
 | 
			
		||||
        文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
 | 
			
		||||
     -->
 | 
			
		||||
 | 
			
		||||
</mapper>
 | 
			
		||||
@@ -1,12 +0,0 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 | 
			
		||||
<mapper namespace="cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductUnitMapper">
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
        一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
 | 
			
		||||
        无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
 | 
			
		||||
        代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
 | 
			
		||||
        文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
 | 
			
		||||
     -->
 | 
			
		||||
 | 
			
		||||
</mapper>
 | 
			
		||||
@@ -1,12 +0,0 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 | 
			
		||||
<mapper namespace="cn.iocoder.yudao.module.erp.dal.mysql.sale.ErpCustomerMapper">
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
        一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
 | 
			
		||||
        无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
 | 
			
		||||
        代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
 | 
			
		||||
        文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
 | 
			
		||||
     -->
 | 
			
		||||
 | 
			
		||||
</mapper>
 | 
			
		||||
@@ -0,0 +1,23 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 | 
			
		||||
<mapper namespace="cn.iocoder.yudao.module.erp.dal.mysql.statistics.ErpPurchaseStatisticsMapper">
 | 
			
		||||
 | 
			
		||||
    <select id="getPurchasePrice" resultType="java.math.BigDecimal">
 | 
			
		||||
        SELECT
 | 
			
		||||
            (SELECT IFNULL(SUM(total_price), 0)
 | 
			
		||||
             FROM erp_purchase_in
 | 
			
		||||
             WHERE in_time >= #{beginTime}
 | 
			
		||||
               <if test="endTime != null">
 | 
			
		||||
                   AND in_time < #{endTime}
 | 
			
		||||
               </if>
 | 
			
		||||
               AND deleted = 0) -
 | 
			
		||||
            (SELECT IFNULL(SUM(total_price), 0)
 | 
			
		||||
                FROM erp_purchase_return
 | 
			
		||||
                WHERE return_time >= #{beginTime}
 | 
			
		||||
                <if test="endTime != null">
 | 
			
		||||
                    AND return_time < #{endTime}
 | 
			
		||||
                </if>
 | 
			
		||||
                AND deleted = 0)
 | 
			
		||||
    </select>
 | 
			
		||||
 | 
			
		||||
</mapper>
 | 
			
		||||
@@ -0,0 +1,23 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 | 
			
		||||
<mapper namespace="cn.iocoder.yudao.module.erp.dal.mysql.statistics.ErpSaleStatisticsMapper">
 | 
			
		||||
 | 
			
		||||
    <select id="getSalePrice" resultType="java.math.BigDecimal">
 | 
			
		||||
        SELECT
 | 
			
		||||
            (SELECT IFNULL(SUM(total_price), 0)
 | 
			
		||||
             FROM erp_sale_out
 | 
			
		||||
             WHERE out_time >= #{beginTime}
 | 
			
		||||
               <if test="endTime != null">
 | 
			
		||||
                   AND out_time < #{endTime}
 | 
			
		||||
               </if>
 | 
			
		||||
               AND deleted = 0) -
 | 
			
		||||
            (SELECT IFNULL(SUM(total_price), 0)
 | 
			
		||||
                FROM erp_sale_return
 | 
			
		||||
                WHERE return_time >= #{beginTime}
 | 
			
		||||
                <if test="endTime != null">
 | 
			
		||||
                    AND return_time < #{endTime}
 | 
			
		||||
                </if>
 | 
			
		||||
                AND deleted = 0)
 | 
			
		||||
    </select>
 | 
			
		||||
 | 
			
		||||
</mapper>
 | 
			
		||||
@@ -1,12 +0,0 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 | 
			
		||||
<mapper namespace="cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpWarehouseMapper">
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
        一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
 | 
			
		||||
        无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
 | 
			
		||||
        代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
 | 
			
		||||
        文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
 | 
			
		||||
     -->
 | 
			
		||||
 | 
			
		||||
</mapper>
 | 
			
		||||
@@ -1,12 +0,0 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 | 
			
		||||
<mapper namespace="cn.iocoder.yudao.module.erp.dal.mysql.purchase.ErpSupplierMapper">
 | 
			
		||||
 | 
			
		||||
    <!--
 | 
			
		||||
        一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
 | 
			
		||||
        无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
 | 
			
		||||
        代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
 | 
			
		||||
        文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
 | 
			
		||||
     -->
 | 
			
		||||
 | 
			
		||||
</mapper>
 | 
			
		||||
		Reference in New Issue
	
	Block a user