From cf6b1cf6fa8f7784c6d7c64b7326d4662bc3d4b3 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期二, 14 十月 2025 17:39:06 +0800
Subject: [PATCH] yys 1.智能排产 2.物料看板 3.报表分析
---
main-business/src/main/java/com/ruoyi/business/dto/ProductionSchedulingStatisticsDto.java | 28 +
main-business/src/main/java/com/ruoyi/business/service/impl/PendingInventoryServiceImpl.java | 1
main-business/src/main/java/com/ruoyi/business/controller/ProductHomeController.java | 115 ++++++
main-business/src/main/java/com/ruoyi/business/entity/PurchaseRegistration.java | 31 +
main-business/pom.xml | 6
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/MyBaseEntity.java | 7
main-business/src/main/java/com/ruoyi/business/dto/CarDto.java | 29 +
main-business/src/main/java/com/ruoyi/business/entity/ProductionScheduling.java | 21 +
main-business/src/main/java/com/ruoyi/business/service/ProductHomeService.java | 43 ++
main-business/src/main/java/com/ruoyi/business/service/impl/ProductHomeServiceImpl.java | 590 ++++++++++++++++++++++++++++++++
main-business/src/main/java/com/ruoyi/business/dto/ItemListDto.java | 29 +
ruoyi-common/pom.xml | 18 +
main-business/src/main/java/com/ruoyi/business/dto/DateQueryDto.java | 1
main-business/src/main/java/com/ruoyi/business/dto/ReportStatisticsDto.java | 39 ++
main-business/src/main/java/com/ruoyi/business/dto/MaterialStatisticsDto.java | 28 +
main-business/src/main/java/com/ruoyi/business/entity/OfficialInventory.java | 32 +
main-business/src/main/java/com/ruoyi/business/entity/PendingInventory.java | 7
main-business/src/main/java/com/ruoyi/business/service/impl/PurchaseRegistrationServiceImpl.java | 5
18 files changed, 1,029 insertions(+), 1 deletions(-)
diff --git a/main-business/pom.xml b/main-business/pom.xml
index 11c92a4..19ead35 100644
--- a/main-business/pom.xml
+++ b/main-business/pom.xml
@@ -64,6 +64,12 @@
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
</dependency>
+ <dependency>
+ <groupId>io.swagger.core.v3</groupId>
+ <artifactId>swagger-annotations-jakarta</artifactId>
+ <version>2.2.22</version>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
<properties>
diff --git a/main-business/src/main/java/com/ruoyi/business/controller/ProductHomeController.java b/main-business/src/main/java/com/ruoyi/business/controller/ProductHomeController.java
new file mode 100644
index 0000000..5bbf0b3
--- /dev/null
+++ b/main-business/src/main/java/com/ruoyi/business/controller/ProductHomeController.java
@@ -0,0 +1,115 @@
+package com.ruoyi.business.controller;
+
+import com.ruoyi.business.dto.*;
+import com.ruoyi.business.entity.OfficialInventory;
+import com.ruoyi.business.entity.ProductionScheduling;
+import com.ruoyi.business.entity.PurchaseRegistration;
+import com.ruoyi.business.service.ProductHomeService;
+import com.ruoyi.common.core.domain.R;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * @author :yys
+ * @date : 2025/10/13 9:12
+ */
+@Tag(name = "鐢熶骇绠℃帶缁熻鎶ヨ〃")
+@RestController
+@RequestMapping("/productHome")
+public class ProductHomeController {
+
+ @Autowired
+ private ProductHomeService productHomeService;
+
+ @GetMapping("/productionSchedulingStatistics")
+ @Operation(summary = "鏅鸿兘鎺掍骇-鐢熶骇鎺掔▼缁熻")
+ public R<ProductionSchedulingStatisticsDto> productionSchedulingStatistics(DateQueryDto dto) {
+ return productHomeService.productionSchedulingStatistics(dto);
+ }
+
+ @GetMapping("/productionSchedulingStatisticsList")
+ @Operation(summary = "鏅鸿兘鎺掍骇-鐢熶骇鎺掔▼缁熻鍒楄〃")
+ public R<List<ProductionScheduling>> productionSchedulingStatisticsList(DateQueryDto dto) {
+ return productHomeService.productionSchedulingStatisticsList(dto);
+ }
+
+ @Operation(summary = "鏅鸿兘鎺掍骇-搴撳瓨鍘熸枡鍒楄〃")
+ @GetMapping("/productionSchedulingInventoryList")
+ public R<List<OfficialInventory>> productionSchedulingInventoryList(DateQueryDto dto) {
+ return productHomeService.productionSchedulingInventoryList(dto);
+ }
+
+ @Operation(summary = "鐗╂枡鐪嬫澘-缁熻")
+ @GetMapping("/materialStatistics")
+ public R<MaterialStatisticsDto> materialStatistics(DateQueryDto dto) {
+ return productHomeService.materialStatistics(dto);
+ }
+
+ @Operation(summary = "鐗╂枡鐪嬫澘-鐓ょ鍒嗗竷")
+ @GetMapping("/coalTypeDistribution")
+ public R<List<ItemListDto>> coalTypeDistribution(DateQueryDto dto) {
+ return productHomeService.coalTypeDistribution(dto);
+ }
+
+ @Operation(summary = "鐗╂枡鐪嬫澘-浜у湴鍒嗗竷")
+ @GetMapping("/originDistribution")
+ public R<List<ItemListDto>> originDistribution(DateQueryDto dto) {
+ return productHomeService.originDistribution(dto);
+ }
+
+ @Operation(summary = "鐗╂枡鐪嬫澘-鐑�煎垎甯�")
+ @GetMapping("/heatValueDistribution")
+ public R<List<ItemListDto>> heatValueDistribution(DateQueryDto dto) {
+ return productHomeService.heatValueDistribution(dto);
+ }
+
+ @Operation(summary = "鐗╂枡鐪嬫澘-杞︽缂栫爜缁熻")
+ @GetMapping("/carCodeDistribution")
+ public R<List<CarDto>> carCodeDistribution(DateQueryDto dto) {
+ return productHomeService.carCodeDistribution(dto);
+ }
+
+ @Operation(summary = "鐗╂枡鐪嬫澘-鏈�杩戜氦鏄撹褰�")
+ @GetMapping("/recentTransaction")
+ public R<List<PurchaseRegistration>> recentTransaction(DateQueryDto dto) {
+ return productHomeService.recentTransaction(dto);
+ }
+
+ @Operation(summary = "鎶ヨ〃鍒嗘瀽-缁熻")
+ @GetMapping("/reportStatistics")
+ public R<ReportStatisticsDto> reportStatistics(DateQueryDto dto) {
+ return productHomeService.reportStatistics(dto);
+ }
+
+ @Operation(summary = "鎶ヨ〃鍒嗘瀽-杈炬爣鐜囪秼鍔�")
+ @GetMapping("/reportTrend")
+ public R<List<ItemListDto>> reportTrend(DateQueryDto dto) {
+ return productHomeService.reportTrend(dto);
+ }
+
+ @Operation(summary = "鎶ヨ〃鍒嗘瀽-鐓ょ鍙戠儹閲忓姣�")
+ @GetMapping("/coalTypeHeatValueComparison")
+ public R<List<ItemListDto>> coalTypeHeatValueComparison(DateQueryDto dto) {
+ return productHomeService.coalTypeHeatValueComparison(dto);
+ }
+
+ @Operation(summary = "鎶ヨ〃鍒嗘瀽-鍔犲伐寰楃巼鍒嗘瀽")
+ @GetMapping("/processingRateAnalysis")
+ public R<List<ItemListDto>> processingRateAnalysis(DateQueryDto dto) {
+ return productHomeService.processingRateAnalysis(dto);
+ }
+
+ @Operation(summary = "鎶ヨ〃鍒嗘瀽-鎴愭湰缁撴瀯鍥捐氨")
+ @GetMapping("/costStructure")
+ public R<List<ItemListDto>> costStructure(DateQueryDto dto) {
+ return productHomeService.costStructure(dto);
+ }
+
+
+}
diff --git a/main-business/src/main/java/com/ruoyi/business/dto/CarDto.java b/main-business/src/main/java/com/ruoyi/business/dto/CarDto.java
new file mode 100644
index 0000000..be0b742
--- /dev/null
+++ b/main-business/src/main/java/com/ruoyi/business/dto/CarDto.java
@@ -0,0 +1,29 @@
+package com.ruoyi.business.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author :yys
+ * @date : 2025/10/13 14:03
+ */
+@Data
+@Schema
+public class CarDto {
+
+ @ApiModelProperty("杞﹁締缂栧彿")
+ @Schema(description = "杞﹁締缂栧彿")
+ private String code;
+
+ @ApiModelProperty("娆℃暟")
+ @Schema(description = "娆℃暟")
+ private Integer count;
+
+ @ApiModelProperty("鎬婚噺(鍚�)")
+ @Schema(description = "鎬婚噺(鍚�)")
+ private BigDecimal total;
+
+}
diff --git a/main-business/src/main/java/com/ruoyi/business/dto/DateQueryDto.java b/main-business/src/main/java/com/ruoyi/business/dto/DateQueryDto.java
index 4e9cc1f..908cb46 100644
--- a/main-business/src/main/java/com/ruoyi/business/dto/DateQueryDto.java
+++ b/main-business/src/main/java/com/ruoyi/business/dto/DateQueryDto.java
@@ -3,6 +3,7 @@
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
import lombok.Data;
/**
diff --git a/main-business/src/main/java/com/ruoyi/business/dto/ItemListDto.java b/main-business/src/main/java/com/ruoyi/business/dto/ItemListDto.java
new file mode 100644
index 0000000..bfb1cfd
--- /dev/null
+++ b/main-business/src/main/java/com/ruoyi/business/dto/ItemListDto.java
@@ -0,0 +1,29 @@
+package com.ruoyi.business.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author :yys
+ * @date : 2025/10/13 13:34
+ */
+@Data
+@Schema
+public class ItemListDto {
+
+ @ApiModelProperty(value = "鍚嶇О")
+ @Schema(title = "鍚嶇О")
+ private String name;
+
+ @ApiModelProperty(value = "鍊�")
+ @Schema(title = "鍊�")
+ private BigDecimal value = BigDecimal.ZERO;
+
+ @ApiModelProperty(value = "鍗犳瘮")
+ @Schema(title = "鍗犳瘮")
+ private BigDecimal percent;
+
+}
diff --git a/main-business/src/main/java/com/ruoyi/business/dto/MaterialStatisticsDto.java b/main-business/src/main/java/com/ruoyi/business/dto/MaterialStatisticsDto.java
new file mode 100644
index 0000000..4a634b3
--- /dev/null
+++ b/main-business/src/main/java/com/ruoyi/business/dto/MaterialStatisticsDto.java
@@ -0,0 +1,28 @@
+package com.ruoyi.business.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author :yys
+ * @date : 2025/10/13 10:12
+ */
+@Data
+@Schema
+public class MaterialStatisticsDto {
+
+ // 浠婃棩鍏ュ簱鎬婚噺
+ @Schema(title = "浠婃棩鍏ュ簱鎬婚噺")
+ private BigDecimal todayInboundTotal = BigDecimal.ZERO;
+
+ // 浠婃棩鍑哄簱鎬婚噺
+ @Schema(title = "浠婃棩鍑哄簱鎬婚噺")
+ private BigDecimal todayOutboundTotal = BigDecimal.ZERO;
+
+ // 褰撳墠搴撳瓨鎬婚噺
+ @Schema(title = "褰撳墠搴撳瓨鎬婚噺")
+ private BigDecimal currentInventoryTotal = BigDecimal.ZERO;
+
+}
diff --git a/main-business/src/main/java/com/ruoyi/business/dto/ProductionSchedulingStatisticsDto.java b/main-business/src/main/java/com/ruoyi/business/dto/ProductionSchedulingStatisticsDto.java
new file mode 100644
index 0000000..b22cb0c
--- /dev/null
+++ b/main-business/src/main/java/com/ruoyi/business/dto/ProductionSchedulingStatisticsDto.java
@@ -0,0 +1,28 @@
+package com.ruoyi.business.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author :yys
+ * @date : 2025/10/13 9:18
+ */
+@Schema
+@Data
+public class ProductionSchedulingStatisticsDto {
+
+ @Schema(title = "鎬绘帓浜ч噺")
+ private BigDecimal totalOutput = BigDecimal.ZERO;
+
+ @Schema(title = "宸插畬鎴愭帓浜�")
+ private BigDecimal completedScheduling = BigDecimal.ZERO;
+
+ @Schema(title = "寰呮帓浜�")
+ private BigDecimal pendingScheduling = BigDecimal.ZERO;
+
+ @Schema(title = "搴撳瓨棰勮(1-9闅忔満鏁�)")
+ private Integer inventoryWarning = (int)(Math.random()*10);
+
+}
diff --git a/main-business/src/main/java/com/ruoyi/business/dto/ReportStatisticsDto.java b/main-business/src/main/java/com/ruoyi/business/dto/ReportStatisticsDto.java
new file mode 100644
index 0000000..1f9e062
--- /dev/null
+++ b/main-business/src/main/java/com/ruoyi/business/dto/ReportStatisticsDto.java
@@ -0,0 +1,39 @@
+package com.ruoyi.business.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.models.auth.In;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Random;
+
+/**
+ * @author :yys
+ * @date : 2025/10/13 16:44
+ */
+@Data
+@Schema
+public class ReportStatisticsDto {
+
+ @ApiModelProperty("鍗曚綅鐑�艰�楃叅閲�")
+ @Schema(title = "鍗曚綅鐑�艰�楃叅閲�")
+ private BigDecimal unitHeatValue = BigDecimal.ZERO;
+
+ @ApiModelProperty("鏁翠綋杈炬爣鐜�")
+ @Schema(title = "鏁翠綋杈炬爣鐜�")
+ private BigDecimal wholeStandardRate = BigDecimal.ZERO;
+
+ @ApiModelProperty("骞冲潎鍙戠儹閲�")
+ @Schema(title = "骞冲潎鍙戠儹閲�")
+ private BigDecimal averageFuel = BigDecimal.ZERO;
+
+ @ApiModelProperty("閰嶆柟浣跨敤棰戞(1-100闅忔満鏁�)")
+ @Schema(title = "閰嶆柟浣跨敤棰戞(1-100闅忔満鏁�)")
+ private Integer frequency = new Random().nextInt(100);
+
+ @ApiModelProperty("鎬绘壒娆�(1-100闅忔満鏁�)")
+ @Schema(title = "鎬绘壒娆�(1-100闅忔満鏁�)")
+ private Integer totalBatch = new Random().nextInt(100);
+
+}
diff --git a/main-business/src/main/java/com/ruoyi/business/entity/OfficialInventory.java b/main-business/src/main/java/com/ruoyi/business/entity/OfficialInventory.java
index 8939038..b48dc03 100644
--- a/main-business/src/main/java/com/ruoyi/business/entity/OfficialInventory.java
+++ b/main-business/src/main/java/com/ruoyi/business/entity/OfficialInventory.java
@@ -6,6 +6,7 @@
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.domain.MyBaseEntity;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
@@ -19,6 +20,7 @@
*/
@Data
@TableName("official_inventory")
+@Schema
public class OfficialInventory extends MyBaseEntity {
/**
@@ -26,15 +28,25 @@
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
+
+ /**
+ *
+ * 閲囪喘鍗曞彿
+ */
+ @TableField(value = "purchase_number")
+ @Schema(title = "閲囪喘鍗曞彿")
+ private String purchaseNumber;
/**
* 寰呭叆搴搃d
*/
@TableField(value = "pending_id")
+ @Schema(title = "寰呭叆搴搃d")
private Long pendingId;
/**
* 渚涜揣鍟咺D
*/
@TableField(value = "supplier_id")
+ @Schema(title = "渚涜揣鍟咺D")
private Long supplierId;
/**
* 缂栧彿
@@ -46,52 +58,69 @@
* 鐓ゆ枡绫诲瀷 1-鎴愬搧 2-鍘熸枡
*/
@TableField(value = "type")
+ @Schema(title = "鐓ゆ枡绫诲瀷 1-鎴愬搧 2-鍘熸枡")
private Integer type;
/**
* 鐓ょ
*/
@TableField(value = "coal_id")
+ @Schema(title = "鐓ょ")
private Long coalId;
+
+ /**
+ * 鐓ょ鍚嶇О
+ */
+ @TableField(exist = false)
+ @Schema(title = "鐓ょ鍚嶇О")
+ private String coalName;
/**
* 鍗曚綅
*/
@TableField(value = "unit")
+ @Schema(title = "鍗曚綅")
private String unit;
/**
* 搴撳瓨鏁伴噺
*/
@TableField(value = "inventory_quantity")
+ @Schema(title = "搴撳瓨鏁伴噺")
private BigDecimal inventoryQuantity;
/**
* 鍗曚环锛堝惈绋庯級
*/
@TableField(value = "price_including_tax")
+ @Schema(title = "鍗曚环锛堝惈绋庯級")
private BigDecimal priceIncludingTax;
/**
* 鎬讳环锛堝惈绋庯級
*/
@TableField(value = "total_price_including_tax")
+ @Schema(title = "鎬讳环锛堝惈绋庯級")
private BigDecimal totalPriceIncludingTax;
/**
* 涓嶅惈绋庡崟浠�
*/
@TableField(value = "price_excluding_tax")
+ @Schema(title = "涓嶅惈绋庡崟浠�")
private BigDecimal priceExcludingTax;
/**
* 涓嶅惈绋庢�讳环
*/
@TableField(value = "total_price_excluding_tax")
+ @Schema(title = "涓嶅惈绋庢�讳环")
private BigDecimal totalPriceExcludingTax;
/**
* 寰呰ˉ搴�
*/
@TableField(value = "pending_replenishment")
+ @Schema(title = "寰呰ˉ搴�")
private BigDecimal pendingReplenishment;
/**
* 鐧昏浜篿d
*/
@TableField(value = "registrant_id")
+ @Schema(title = "鐧昏浜篿d")
private Long registrantId;
/**
@@ -99,17 +128,20 @@
*/
@TableField(value = "registration_date")
@JsonFormat(pattern = "yyyy-MM-dd")
+ @Schema(title = "鐧昏鏃ユ湡")
private LocalDate registrationDate;
/**
* 鐓よ川鏂规id
*/
@TableField(value = "coal_plan_id")
+ @Schema(title = "鐓よ川鏂规id")
private Long coalPlanId;
/**
* 鍚堝苟id
*/
@TableField(value = "merge_id")
+ @Schema(title = "鍚堝苟id")
private String mergeId;
}
\ No newline at end of file
diff --git a/main-business/src/main/java/com/ruoyi/business/entity/PendingInventory.java b/main-business/src/main/java/com/ruoyi/business/entity/PendingInventory.java
index 7144e12..e9d232e 100644
--- a/main-business/src/main/java/com/ruoyi/business/entity/PendingInventory.java
+++ b/main-business/src/main/java/com/ruoyi/business/entity/PendingInventory.java
@@ -33,6 +33,13 @@
*/
@TableField(value = "master_id")
private Long masterId;
+
+ /**
+ *
+ * 閲囪喘鍗曞彿
+ */
+ @TableField(value = "purchase_number")
+ private String purchaseNumber;
/**
*
* 閲囪喘id
diff --git a/main-business/src/main/java/com/ruoyi/business/entity/ProductionScheduling.java b/main-business/src/main/java/com/ruoyi/business/entity/ProductionScheduling.java
index acd3c84..c4aeedf 100644
--- a/main-business/src/main/java/com/ruoyi/business/entity/ProductionScheduling.java
+++ b/main-business/src/main/java/com/ruoyi/business/entity/ProductionScheduling.java
@@ -6,6 +6,7 @@
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.domain.MyBaseEntity;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
@@ -19,6 +20,7 @@
*/
@Data
@TableName("production_scheduling")
+@Schema
public class ProductionScheduling extends MyBaseEntity {
private static final long serialVersionUID = 1L;
@@ -32,12 +34,21 @@
* 鐢熶骇鏄庣粏id
*/
@TableField(value = "production_id")
+ @Schema(title = "鐢熶骇鏄庣粏id")
private Long productionId;
/**
* 鐓ょID
*/
@TableField(value = "coal_id")
+ @Schema(title = "鐓ょID")
private Long coalId;
+
+ /**
+ * 鐓ょ鍚嶇О
+ */
+ @Schema(title = "鐓ょ鍚嶇О")
+ @TableField(exist = false)
+ private String coalName;
/**
* 鎬绘暟閲�
@@ -51,38 +62,45 @@
* 鎺掍骇鏁伴噺
*/
@TableField(value = "scheduling_num")
+ @Schema(title = "鎺掍骇鏁伴噺")
private BigDecimal schedulingNum;
/**
* 鍏ュ簱鏁伴噺
*/
@TableField(value = "success_num")
+ @Schema(title = "鍏ュ簱鏁伴噺")
private BigDecimal successNum;
/**
* 鐓ゆ枡绫诲瀷锛�1-鎴愬搧 2-鍘熸枡锛�
*/
@TableField(value = "type")
+ @Schema(title = "鐓ゆ枡绫诲瀷锛�1-鎴愬搧 2-鍘熸枡锛�")
private Integer type;
/**
*鐘舵�侊紙1-寰呯敓浜� 2-鐢熶骇涓� 3-宸叉姤宸ワ級
*/
@TableField(value = "status")
+ @Schema(title = "鐘舵�侊紙1-寰呯敓浜� 2-鐢熶骇涓� 3-宸叉姤宸ワ級")
private Integer status;
/**
* 鍗曚綅
*/
@TableField(value = "unit")
+ @Schema(title = "鍗曚綅")
private String unit;
/**
* 宸ュ簭锛堝瓧鍏革級
*/
@TableField(value = "process")
+ @Schema(title = "宸ュ簭锛堝瓧鍏革級")
private String process;
/**
* 宸ユ椂瀹氶
*/
@TableField(value = "work_hours")
+ @Schema(title = "宸ユ椂瀹氶")
private BigDecimal workHours;
/**
* 鎺掍骇鏃ユ湡
@@ -90,16 +108,19 @@
@TableField(value = "scheduling_date")
@JsonFormat(pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
+ @Schema(title = "鎺掍骇鏃ユ湡")
private Date schedulingDate;
/**
* 鎺掍骇浜篿d
*/
@TableField(value = "scheduling_user_id")
+ @Schema(title = "鎺掍骇浜篿d")
private Long schedulingUserId;
/**
* 鎺掍骇浜哄悕绉�
*/
@TableField(value = "scheduling_user_name")
+ @Schema(title = "鎺掍骇浜哄悕绉�")
private String schedulingUserName;
}
diff --git a/main-business/src/main/java/com/ruoyi/business/entity/PurchaseRegistration.java b/main-business/src/main/java/com/ruoyi/business/entity/PurchaseRegistration.java
index 98ec5e4..f9d284c 100644
--- a/main-business/src/main/java/com/ruoyi/business/entity/PurchaseRegistration.java
+++ b/main-business/src/main/java/com/ruoyi/business/entity/PurchaseRegistration.java
@@ -5,6 +5,7 @@
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.common.core.domain.MyBaseEntity;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
@@ -18,6 +19,7 @@
*/
@Data
@TableName("purchase_registration")
+@Schema
public class PurchaseRegistration extends MyBaseEntity {
private static final long serialVersionUID = 1L;
@@ -27,77 +29,105 @@
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
+
+ /**
+ * 閲囪喘鍗曞彿
+ */
+ @TableField(value = "purchase_number")
+ @Schema(title = "閲囪喘鍗曞彿")
+ private String purchaseNumber;
/**
* 渚涘簲鍟唅d
*/
@TableField(value = "supplier_id")
+ @Schema(title = "渚涘簲鍟唅d")
private Long supplierId;
/**
* 渚涘簲鍟嗗悕绉�
*/
@TableField(value = "supplier_name")
+ @Schema(title = "渚涘簲鍟嗗悕绉�")
private String supplierName;
/**
* 鍗曚綅
*/
@TableField(value = "unit")
+ @Schema(title = "鍗曚綅")
private String unit;
/**
*
*/
@TableField(value = "coal_id")
+ @Schema(title = "鐓ゆ枡id")
private Long coalId;
+
+ /**
+ * 鐓ゆ枡鍚嶇О
+ */
+ @TableField(exist = false)
+ @Schema(title = "鐓ゆ枡鍚嶇О")
+ private String coalName;
/**
* 閲囪喘鏁伴噺
*/
@TableField(value = "purchase_quantity")
+ @Schema(title = "閲囪喘鏁伴噺")
private BigDecimal purchaseQuantity;
/**
* 鍗曚环锛堝惈绋庯級
*/
@TableField(value = "price_including_tax")
+ @Schema(title = "鍗曚环锛堝惈绋庯級")
private BigDecimal priceIncludingTax;
/**
* 鎬讳环锛堝惈绋庯級
*/
@TableField(value = "total_price_including_tax")
+ @Schema(title = "鎬讳环锛堝惈绋庯級")
private BigDecimal totalPriceIncludingTax;
/**
* 绋庣巼
*/
@TableField(value = "tax_rate")
+ @Schema(title = "绋庣巼")
private BigDecimal taxRate;
/**
* 涓嶅惈绋庡崟浠�
*/
@TableField(value = "price_excluding_tax")
+ @Schema(title = "涓嶅惈绋庡崟浠�")
private BigDecimal priceExcludingTax;
/**
* 涓嶅惈绋庢�讳环
*/
@TableField(value = "total_price_excluding_tax")
+ @Schema(title = "涓嶅惈绋庢�讳环")
private BigDecimal totalPriceExcludingTax;
/**
* 鐧昏浜篿d
*/
@TableField(value = "registrant_id")
+ @Schema(title = "鐧昏浜篿d")
private Long registrantId;
/**
* 鐧昏鏃ユ湡
*/
@TableField(value = "registration_date")
+ @Schema(title = "鐧昏鏃ユ湡")
private LocalDate registrationDate;
/**
* 杩愯垂
*/
@TableField(value = "freight")
+ @Schema(title = "杩愯垂")
private BigDecimal freight;
/**
* 绫诲瀷锛�1-鎴愬搧锛�2-鍘熸枡锛�
*/
@TableField(value = "type")
+ @Schema(title = "绫诲瀷锛�1-鎴愬搧锛�2-鍘熸枡锛�")
private Integer type;
/**
* 閲囪喘绫诲瀷
@@ -109,5 +139,6 @@
* 杞︾墝鍙�
*/
@TableField(value = "license_plate")
+ @Schema(title = "杞︾墝鍙�")
private String licensePlate;
}
\ No newline at end of file
diff --git a/main-business/src/main/java/com/ruoyi/business/service/ProductHomeService.java b/main-business/src/main/java/com/ruoyi/business/service/ProductHomeService.java
new file mode 100644
index 0000000..1c6b2b2
--- /dev/null
+++ b/main-business/src/main/java/com/ruoyi/business/service/ProductHomeService.java
@@ -0,0 +1,43 @@
+package com.ruoyi.business.service;
+
+import com.ruoyi.business.dto.*;
+import com.ruoyi.business.entity.OfficialInventory;
+import com.ruoyi.business.entity.ProductionScheduling;
+import com.ruoyi.business.entity.PurchaseRegistration;
+import com.ruoyi.common.core.domain.R;
+
+import java.util.List;
+
+/**
+ * @author :yys
+ * @date : 2025/10/13 9:11
+ */
+public interface ProductHomeService {
+ R<ProductionSchedulingStatisticsDto> productionSchedulingStatistics(DateQueryDto dto);
+
+ R<List<ProductionScheduling>> productionSchedulingStatisticsList(DateQueryDto dto);
+
+ R<List<OfficialInventory>> productionSchedulingInventoryList(DateQueryDto dto);
+
+ R<MaterialStatisticsDto> materialStatistics(DateQueryDto dto);
+
+ R<List<ItemListDto>> coalTypeDistribution(DateQueryDto dto);
+
+ R<List<ItemListDto>> originDistribution(DateQueryDto dto);
+
+ R<List<CarDto>> carCodeDistribution(DateQueryDto dto);
+
+ R<List<PurchaseRegistration>> recentTransaction(DateQueryDto dto);
+
+ R<List<ItemListDto>> heatValueDistribution(DateQueryDto dto);
+
+ R<ReportStatisticsDto> reportStatistics(DateQueryDto dto);
+
+ R<List<ItemListDto>> reportTrend(DateQueryDto dto);
+
+ R<List<ItemListDto>> coalTypeHeatValueComparison(DateQueryDto dto);
+
+ R<List<ItemListDto>> processingRateAnalysis(DateQueryDto dto);
+
+ R<List<ItemListDto>> costStructure(DateQueryDto dto);
+}
diff --git a/main-business/src/main/java/com/ruoyi/business/service/impl/PendingInventoryServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/service/impl/PendingInventoryServiceImpl.java
index f80834a..3587979 100644
--- a/main-business/src/main/java/com/ruoyi/business/service/impl/PendingInventoryServiceImpl.java
+++ b/main-business/src/main/java/com/ruoyi/business/service/impl/PendingInventoryServiceImpl.java
@@ -286,6 +286,7 @@
if (pendingInventoryDto.getOfficialId() == null) {
OfficialInventory officialInventory = new OfficialInventory();
BeanUtils.copyProperties(pendingInventory, officialInventory);
+ officialInventory.setPurchaseNumber(pendingInventory.getPurchaseNumber());
officialInventory.setId(null);
officialInventory.setCoalPlanId(pendingInventoryDto.getCoalPlanId());
officialInventory.setPendingId(pendingInventoryDto.getPId());
diff --git a/main-business/src/main/java/com/ruoyi/business/service/impl/ProductHomeServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/service/impl/ProductHomeServiceImpl.java
new file mode 100644
index 0000000..ec1c919
--- /dev/null
+++ b/main-business/src/main/java/com/ruoyi/business/service/impl/ProductHomeServiceImpl.java
@@ -0,0 +1,590 @@
+package com.ruoyi.business.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.ruoyi.basic.entity.CoalInfo;
+import com.ruoyi.basic.entity.CoalPlan;
+import com.ruoyi.basic.entity.CoalValue;
+import com.ruoyi.basic.entity.Customer;
+import com.ruoyi.basic.mapper.CoalInfoMapper;
+import com.ruoyi.basic.mapper.CoalPlanMapper;
+import com.ruoyi.basic.mapper.CoalValueMapper;
+import com.ruoyi.basic.mapper.CustomerMapper;
+import com.ruoyi.business.dto.*;
+import com.ruoyi.business.entity.*;
+import com.ruoyi.business.mapper.*;
+import com.ruoyi.business.service.ProductHomeService;
+import com.ruoyi.common.core.domain.R;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * @author :yys
+ * @date : 2025/10/13 9:11
+ */
+@Service
+@Slf4j
+public class ProductHomeServiceImpl implements ProductHomeService {
+
+ @Autowired
+ private ProductionMapper productionMapper;
+
+ @Autowired
+ private ProductionSchedulingMapper productionSchedulingMapper;
+
+ @Autowired
+ private OfficialInventoryMapper officialInventoryMapper;
+
+ @Autowired
+ private SalesRecordMapper salesRecordMapper;
+
+ @Autowired
+ private CoalInfoMapper coalInfoMapper;
+
+ @Autowired
+ private CustomerMapper customerMapper;
+
+ @Autowired
+ private PurchaseRegistrationMapper purchaseRegistrationMapper;
+
+ @Autowired
+ private CoalValueMapper coalValueMapper;
+
+ @Autowired
+ private CoalPlanMapper coalPlanMapper;
+
+ @Override
+ public R<ProductionSchedulingStatisticsDto> productionSchedulingStatistics(DateQueryDto dto) {
+ String start = dto.getEntryDateStart();
+ String end = dto.getEntryDateEnd();
+
+
+ // 浣跨敤 LambdaQueryWrapper 鏋勫缓鏌ヨ鏉′欢
+ LambdaQueryWrapper<ProductionScheduling> wrapper = new LambdaQueryWrapper<>();
+
+ if (start != null && !start.isEmpty() && end != null && !end.isEmpty()) {
+ wrapper.between(ProductionScheduling::getSchedulingDate, LocalDate.parse(start, DateTimeFormatter.ISO_LOCAL_DATE), LocalDate.parse(end, DateTimeFormatter.ISO_LOCAL_DATE));
+ }
+
+ List<ProductionScheduling> schedulingList = productionSchedulingMapper.selectList(wrapper);
+
+ ProductionSchedulingStatisticsDto result = new ProductionSchedulingStatisticsDto();
+ BigDecimal totalScheduling = BigDecimal.ZERO;
+ BigDecimal completedScheduling = BigDecimal.ZERO;
+ BigDecimal pendingScheduling = BigDecimal.ZERO;
+
+ for (ProductionScheduling scheduling : schedulingList) {
+ BigDecimal num = scheduling.getSchedulingNum();
+ if (num != null) {
+ totalScheduling = totalScheduling.add(num);
+ if (scheduling.getStatus() == 3) { // 宸叉姤宸�
+ completedScheduling = completedScheduling.add(num);
+ } else if (scheduling.getStatus() == 1) { // 寰呯敓浜�
+ pendingScheduling = pendingScheduling.add(num);
+ }
+ }
+ }
+
+ result.setTotalOutput(totalScheduling);
+ result.setCompletedScheduling(completedScheduling);
+ result.setPendingScheduling(pendingScheduling);
+
+ return R.ok(result);
+ }
+
+ @Override
+ public R<List<ProductionScheduling>> productionSchedulingStatisticsList(DateQueryDto dto) {
+ String start = dto.getEntryDateStart();
+ String end = dto.getEntryDateEnd();
+
+ // 浣跨敤 LambdaQueryWrapper 鏋勫缓鏌ヨ鏉′欢
+ LambdaQueryWrapper<ProductionScheduling> wrapper = new LambdaQueryWrapper<>();
+
+ if (start != null && !start.isEmpty() && end != null && !end.isEmpty()) {
+ wrapper.between(ProductionScheduling::getSchedulingDate, LocalDate.parse(start, DateTimeFormatter.ISO_LOCAL_DATE), LocalDate.parse(end, DateTimeFormatter.ISO_LOCAL_DATE));
+ }
+
+ List<ProductionScheduling> schedulingList = productionSchedulingMapper.selectList(wrapper);
+ // 閫氳繃鐓ょid鑾峰彇鐓ょ鍚嶇О
+ schedulingList.forEach(scheduling -> {
+ CoalInfo coalInfo = coalInfoMapper.selectById(scheduling.getCoalId());
+ scheduling.setCoalName(coalInfo.getCoal());
+ });
+ return R.ok(schedulingList);
+ }
+
+ @Override
+ public R<List<OfficialInventory>> productionSchedulingInventoryList(DateQueryDto dto) {
+ String start = dto.getEntryDateStart();
+ String end = dto.getEntryDateEnd();
+
+
+ // 浣跨敤 LambdaQueryWrapper 鏋勫缓鏌ヨ鏉′欢
+ LambdaQueryWrapper<OfficialInventory> wrapper = new LambdaQueryWrapper<>();
+
+ if (start != null && !start.isEmpty() && end != null && !end.isEmpty()) {
+ wrapper.between(OfficialInventory::getRegistrationDate, LocalDate.parse(start, DateTimeFormatter.ISO_LOCAL_DATE), LocalDate.parse(end, DateTimeFormatter.ISO_LOCAL_DATE));
+ }
+
+ List<OfficialInventory> schedulingList = officialInventoryMapper.selectList(wrapper);
+ schedulingList.forEach(scheduling -> {
+ CoalInfo coalInfo = coalInfoMapper.selectById(scheduling.getCoalId());
+ scheduling.setCoalName(coalInfo.getCoal());
+ });
+ return R.ok(schedulingList);
+ }
+
+ @Override
+ public R<MaterialStatisticsDto> materialStatistics(DateQueryDto dto) {
+ MaterialStatisticsDto result = new MaterialStatisticsDto();
+ // 鑾峰彇浠婃棩寮�濮嬫椂闂达紝缁撴潫鏃堕棿
+ LocalDateTime todayStart = LocalDateTime.of(
+ LocalDateTime.now().toLocalDate(),
+ LocalTime.MIN
+ );
+ LocalDateTime todayEnd = LocalDateTime.of(
+ LocalDateTime.now().toLocalDate(),
+ LocalTime.MAX
+ );
+ // 浣跨敤 LambdaQueryWrapper 鏋勫缓鏌ヨ鏉′欢
+ LambdaQueryWrapper<OfficialInventory> wrapper = new LambdaQueryWrapper<>();
+ wrapper.between(OfficialInventory::getRegistrationDate, todayStart, todayEnd);
+ // 鑾峰彇浠婃棩鍏ュ簱鎬婚噺
+ List<OfficialInventory> officialInventories = officialInventoryMapper.selectList(wrapper);
+ if (!CollectionUtils.isEmpty(officialInventories)) {
+ BigDecimal todayInboundTotal = officialInventories.stream()
+ .map(OfficialInventory::getInventoryQuantity)
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
+ result.setTodayInboundTotal(todayInboundTotal);
+
+ }
+ // 鑾峰彇褰撳墠搴撳瓨鎬婚噺
+ R<List<OfficialInventory>> listR = productionSchedulingInventoryList(dto);
+ if (R.isSuccess(listR)) {
+ List<OfficialInventory> officialInventoriesList = listR.getData();
+ if (!CollectionUtils.isEmpty(officialInventoriesList)) {
+ BigDecimal todayOutboundTotal = officialInventoriesList.stream()
+ .map(OfficialInventory::getInventoryQuantity)
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
+ result.setTodayOutboundTotal(todayOutboundTotal);
+ }
+ }
+ // 鑾峰彇浠婃棩鍑哄簱鎬婚噺
+ // 浣跨敤 LambdaQueryWrapper 鏋勫缓鏌ヨ鏉′欢
+ LambdaQueryWrapper<SalesRecord> wrapperSalesRecord = new LambdaQueryWrapper<>();
+ wrapperSalesRecord.between(SalesRecord::getSaleDate, todayStart, todayEnd);
+ // 鑾峰彇浠婃棩鍏ュ簱鎬婚噺
+ List<SalesRecord> salesRecords = salesRecordMapper.selectList(wrapperSalesRecord);
+ if (!CollectionUtils.isEmpty(salesRecords)) {
+ BigDecimal todayInboundTotal = salesRecords.stream()
+ .map(SalesRecord::getInventoryQuantity)
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
+ result.setTodayOutboundTotal(todayInboundTotal);
+
+ }
+ return R.ok(result);
+ }
+
+ @Override
+ public R<List<ItemListDto>> coalTypeDistribution(DateQueryDto dto) {
+ String start = dto.getEntryDateStart();
+ String end = dto.getEntryDateEnd();
+ // 鑾峰彇鐓ょ鍒楄〃
+ List<CoalInfo> coalInfoList = coalInfoMapper.selectList(null);
+
+ // 浣跨敤 LambdaQueryWrapper 鏋勫缓鏌ヨ鏉′欢
+ LambdaQueryWrapper<SalesRecord> wrapper = new LambdaQueryWrapper<>();
+
+ if (start != null && !start.isEmpty() && end != null && !end.isEmpty()) {
+ wrapper.between(SalesRecord::getRegistrationDate, LocalDate.parse(start, DateTimeFormatter.ISO_LOCAL_DATE), LocalDate.parse(end, DateTimeFormatter.ISO_LOCAL_DATE));
+ }
+ List<SalesRecord> salesRecords = salesRecordMapper.selectList(wrapper);
+ // 鏍规嵁鐓ょ杩涜鍒嗙粍锛屽苟璁$畻鍗犳瘮
+ Map<Long, List<SalesRecord>> coalTypeMap = salesRecords.stream()
+ .collect(Collectors.groupingBy(SalesRecord::getCoalId));
+
+ List<ItemListDto> itemListDtos = coalInfoList.stream().map(coalInfo -> {
+ ItemListDto itemListDto = new ItemListDto();
+ itemListDto.setName(coalInfo.getCoal());
+
+ // 璁$畻璇ョ叅绉嶇殑閿�鍞褰曟�绘暟閲�
+ List<SalesRecord> records = coalTypeMap.getOrDefault(coalInfo.getId(), Collections.emptyList());
+ BigDecimal totalQuantity = records.stream()
+ .map(SalesRecord::getInventoryQuantity)
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
+
+ itemListDto.setValue(totalQuantity);
+ return itemListDto;
+ }).collect(Collectors.toList());
+
+ // 璁$畻鎵�鏈夌叅绉嶇殑閿�鍞�婚噺
+ BigDecimal totalAll = itemListDtos.stream()
+ .map(ItemListDto::getValue)
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
+
+ // 璁剧疆鍗犳瘮
+ for (ItemListDto item : itemListDtos) {
+ if (totalAll.compareTo(BigDecimal.ZERO) > 0) {
+ BigDecimal percentage = item.getValue().multiply(BigDecimal.valueOf(100))
+ .divide(totalAll, 2, RoundingMode.HALF_UP);
+ item.setPercent(percentage);
+ } else {
+ item.setPercent(BigDecimal.ZERO);
+ }
+ }
+
+ return R.ok(itemListDtos);
+ }
+
+ @Override
+ public R<List<ItemListDto>> originDistribution(DateQueryDto dto) {
+ String start = dto.getEntryDateStart();
+ String end = dto.getEntryDateEnd();
+ // 鑾峰彇瀹㈡埛鍒楄〃
+ List<Customer> coalInfoList = customerMapper.selectList(null);
+
+ // 浣跨敤 LambdaQueryWrapper 鏋勫缓鏌ヨ鏉′欢
+ LambdaQueryWrapper<SalesRecord> wrapper = new LambdaQueryWrapper<>();
+
+ if (start != null && !start.isEmpty() && end != null && !end.isEmpty()) {
+ wrapper.between(SalesRecord::getRegistrationDate, LocalDate.parse(start, DateTimeFormatter.ISO_LOCAL_DATE), LocalDate.parse(end, DateTimeFormatter.ISO_LOCAL_DATE));
+ }
+ List<SalesRecord> salesRecords = salesRecordMapper.selectList(wrapper);
+ // 鏍规嵁鐓ょ杩涜鍒嗙粍锛屽苟璁$畻鍗犳瘮
+ Map<Long, List<SalesRecord>> coalTypeMap = salesRecords.stream()
+ .collect(Collectors.groupingBy(SalesRecord::getCustomerId));
+
+ List<ItemListDto> itemListDtos = coalInfoList.stream().map(coalInfo -> {
+ ItemListDto itemListDto = new ItemListDto();
+ itemListDto.setName(coalInfo.getCustomerName());
+
+ // 璁$畻璇ョ叅绉嶇殑閿�鍞褰曟�绘暟閲�
+ List<SalesRecord> records = coalTypeMap.getOrDefault(coalInfo.getId(), Collections.emptyList());
+ BigDecimal totalQuantity = records.stream()
+ .map(SalesRecord::getInventoryQuantity)
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
+
+ itemListDto.setValue(totalQuantity);
+ return itemListDto;
+ }).collect(Collectors.toList());
+
+ // 璁$畻鎵�鏈夌叅绉嶇殑閿�鍞�婚噺
+ BigDecimal totalAll = itemListDtos.stream()
+ .map(ItemListDto::getValue)
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
+
+ // 璁剧疆鍗犳瘮
+ for (ItemListDto item : itemListDtos) {
+ if (totalAll.compareTo(BigDecimal.ZERO) > 0) {
+ BigDecimal percentage = item.getValue().multiply(BigDecimal.valueOf(100))
+ .divide(totalAll, 2, RoundingMode.HALF_UP);
+ item.setPercent(percentage);
+ } else {
+ item.setPercent(BigDecimal.ZERO);
+ }
+ }
+
+ return R.ok(itemListDtos);
+ }
+
+ @Override
+ public R<List<CarDto>> carCodeDistribution(DateQueryDto dto) {
+ String start = dto.getEntryDateStart();
+ String end = dto.getEntryDateEnd();
+
+ // 浣跨敤 LambdaQueryWrapper 鏋勫缓鏌ヨ鏉′欢
+ LambdaQueryWrapper<PurchaseRegistration> wrapper = new LambdaQueryWrapper<>();
+
+ if (start != null && !start.isEmpty() && end != null && !end.isEmpty()) {
+ wrapper.between(PurchaseRegistration::getRegistrationDate, LocalDate.parse(start, DateTimeFormatter.ISO_LOCAL_DATE), LocalDate.parse(end, DateTimeFormatter.ISO_LOCAL_DATE));
+ }
+ List<PurchaseRegistration> purchaseRegistrations = purchaseRegistrationMapper.selectList(wrapper);
+ // 閫氳繃杞︾墝鍙峰垎缁勮幏鍙栨鏁帮紝璁$畻鎬婚噺
+ Map<String, List<PurchaseRegistration>> carMap = purchaseRegistrations.stream()
+ .collect(Collectors.groupingBy(PurchaseRegistration::getLicensePlate));
+ List<CarDto> carDtos = carMap.entrySet().stream().map(entry -> {
+ CarDto carDto = new CarDto();
+ carDto.setCode(entry.getKey());
+ carDto.setCount(entry.getValue().size());
+ carDto.setTotal(entry.getValue().stream()
+ .map(PurchaseRegistration::getPurchaseQuantity)
+ .reduce(BigDecimal.ZERO, BigDecimal::add));
+ return carDto;
+ }).collect(Collectors.toList());
+ return R.ok(carDtos);
+ }
+
+ @Override
+ public R<List<PurchaseRegistration>> recentTransaction(DateQueryDto dto) {
+ String start = dto.getEntryDateStart();
+ String end = dto.getEntryDateEnd();
+
+ // 浣跨敤 LambdaQueryWrapper 鏋勫缓鏌ヨ鏉′欢
+ LambdaQueryWrapper<PurchaseRegistration> wrapper = new LambdaQueryWrapper<>();
+
+ if (start != null && !start.isEmpty() && end != null && !end.isEmpty()) {
+ wrapper.between(PurchaseRegistration::getRegistrationDate, LocalDate.parse(start, DateTimeFormatter.ISO_LOCAL_DATE), LocalDate.parse(end, DateTimeFormatter.ISO_LOCAL_DATE));
+ }
+ List<PurchaseRegistration> purchaseRegistrations = purchaseRegistrationMapper.selectList(wrapper);
+ purchaseRegistrations.forEach(purchaseRegistration -> {
+ purchaseRegistration.setCoalName(coalInfoMapper.selectById(purchaseRegistration.getCoalId()).getCoal());
+ });
+ return R.ok(purchaseRegistrations);
+ }
+
+ @Override
+ public R<List<ItemListDto>> heatValueDistribution(DateQueryDto dto) {
+ String start = dto.getEntryDateStart();
+ String end = dto.getEntryDateEnd();
+ LambdaQueryWrapper<OfficialInventory> officialInventoryLambdaQueryWrapper = new LambdaQueryWrapper<>();
+ if (start != null && !start.isEmpty() && end != null && !end.isEmpty()) {
+ officialInventoryLambdaQueryWrapper.between(OfficialInventory::getRegistrationDate, LocalDate.parse(start, DateTimeFormatter.ISO_LOCAL_DATE), LocalDate.parse(end, DateTimeFormatter.ISO_LOCAL_DATE));
+ }
+ List<OfficialInventory> officialInventories = officialInventoryMapper.selectList(officialInventoryLambdaQueryWrapper);
+ Map<String, BigDecimal> heatValueMap = new HashMap<>();
+ BigDecimal totalQuantity = BigDecimal.ZERO;
+ for (OfficialInventory officialInventory : officialInventories) {
+ List<CoalValue> coalValues = coalValueMapper.selectList(new LambdaQueryWrapper<CoalValue>()
+ .eq(CoalValue::getPlanId, officialInventory.getId())
+ .eq(CoalValue::getFieldName, "鍙戠儹閲�"));
+ if (coalValues != null && !coalValues.isEmpty()) {
+ // 鏍规嵁鍙戠儹閲忓�艰繘琛屽垎绫荤粺璁�
+
+ heatValueMap.put("4000浠ヤ笅", BigDecimal.ZERO);
+ heatValueMap.put("4000-4500", BigDecimal.ZERO);
+ heatValueMap.put("4500-5000", BigDecimal.ZERO);
+ heatValueMap.put("5000-5500", BigDecimal.ZERO);
+ heatValueMap.put("5500-6000", BigDecimal.ZERO);
+ heatValueMap.put("6000+", BigDecimal.ZERO);
+
+ for (CoalValue coalValue : coalValues) {
+ BigDecimal heatValue = BigDecimal.valueOf(Long.parseLong(coalValue.getCoalValue()));
+ if (heatValue == null) continue;
+
+ if (heatValue.compareTo(BigDecimal.valueOf(4000)) < 0) {
+ heatValueMap.put("4000浠ヤ笅", heatValueMap.get("4000浠ヤ笅").add(officialInventory.getInventoryQuantity()));
+ } else if (heatValue.compareTo(BigDecimal.valueOf(4000)) >= 0 && heatValue.compareTo(BigDecimal.valueOf(4500)) < 0) {
+ heatValueMap.put("4000-4500", heatValueMap.get("4000-4500").add(officialInventory.getInventoryQuantity()));
+ } else if (heatValue.compareTo(BigDecimal.valueOf(4500)) >= 0 && heatValue.compareTo(BigDecimal.valueOf(5000)) < 0) {
+ heatValueMap.put("4500-5000", heatValueMap.get("4500-5000").add(officialInventory.getInventoryQuantity()));
+ } else if (heatValue.compareTo(BigDecimal.valueOf(5000)) >= 0 && heatValue.compareTo(BigDecimal.valueOf(5500)) < 0) {
+ heatValueMap.put("5000-5500", heatValueMap.get("5000-5500").add(officialInventory.getInventoryQuantity()));
+ } else if (heatValue.compareTo(BigDecimal.valueOf(5500)) >= 0 && heatValue.compareTo(BigDecimal.valueOf(6000)) < 0) {
+ heatValueMap.put("5500-6000", heatValueMap.get("5500-6000").add(officialInventory.getInventoryQuantity()));
+ } else {
+ heatValueMap.put("6000+", heatValueMap.get("6000+").add(officialInventory.getInventoryQuantity()));
+ }
+ }
+
+
+ }
+ }
+ // 璁$畻鎬婚噺
+ totalQuantity = heatValueMap.values().stream().reduce(BigDecimal.ZERO, BigDecimal::add);
+ // 灏嗙粨鏋滆浆鎹负 ItemListDto 鍒楄〃
+ BigDecimal finalTotalQuantity = totalQuantity;
+ List<ItemListDto> itemListDtos = heatValueMap.entrySet().stream()
+ .map(entry -> {
+ ItemListDto itemListDto = new ItemListDto();
+ itemListDto.setName(entry.getKey());
+ itemListDto.setValue(entry.getValue());
+ if (finalTotalQuantity.compareTo(BigDecimal.ZERO) > 0) {
+ BigDecimal percentage = entry.getValue().multiply(BigDecimal.valueOf(100))
+ .divide(finalTotalQuantity, 2, RoundingMode.HALF_UP);
+ itemListDto.setPercent(percentage);
+ }
+ return itemListDto;
+ })
+ .collect(Collectors.toList());
+ return R.ok(itemListDtos);
+ }
+
+ @Override
+ public R<ReportStatisticsDto> reportStatistics(DateQueryDto dto) {
+ ReportStatisticsDto reportStatisticsDto = new ReportStatisticsDto();
+ String start = dto.getEntryDateStart();
+ String end = dto.getEntryDateEnd();
+ LambdaQueryWrapper<OfficialInventory> officialInventoryLambdaQueryWrapper = new LambdaQueryWrapper<>();
+ if (start != null && !start.isEmpty() && end != null && !end.isEmpty()) {
+ officialInventoryLambdaQueryWrapper.between(OfficialInventory::getRegistrationDate, LocalDate.parse(start, DateTimeFormatter.ISO_LOCAL_DATE), LocalDate.parse(end, DateTimeFormatter.ISO_LOCAL_DATE));
+ }
+ List<OfficialInventory> officialInventories = officialInventoryMapper.selectList(officialInventoryLambdaQueryWrapper);
+ if(!CollectionUtils.isEmpty(officialInventories)){
+ BigDecimal reduce = officialInventories.stream()
+ .map(OfficialInventory::getInventoryQuantity)
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
+ List<CoalValue> coalValues = coalValueMapper.selectList(new LambdaQueryWrapper<CoalValue>()
+ .in(CoalValue::getPlanId, officialInventories.stream().map(OfficialInventory::getId).collect(Collectors.toList()))
+ .eq(CoalValue::getFieldName, "鍙戠儹閲�"));
+ BigDecimal totalQuantity = coalValues.stream()
+ .map(coalValue -> BigDecimal.valueOf(Long.parseLong(coalValue.getCoalValue())))
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
+
+
+ long count = coalValues.stream()
+ .filter(coalValue -> BigDecimal.valueOf(Long.parseLong(coalValue.getCoalValue())).compareTo(BigDecimal.valueOf(5000)) >= 0)
+ .count();
+
+
+ if (!coalValues.isEmpty()){
+ // 鍗曚綅鐑�艰�楃叅閲� = reduce * 1000 / totalQuantity
+ BigDecimal heatValue = reduce.multiply(BigDecimal.valueOf(1000)).divide(totalQuantity, 2, RoundingMode.HALF_UP);
+ reportStatisticsDto.setUnitHeatValue(heatValue);
+ // 骞冲潎鍙戠儹閲�
+ reportStatisticsDto.setAverageFuel(totalQuantity.divide(BigDecimal.valueOf(coalValues.size()), 2, RoundingMode.HALF_UP));
+ // 鏁翠綋杈炬爣鐜�(鍙戠儹閲忊墺5000澶у崱)
+ BigDecimal wholeStandardRate = BigDecimal.valueOf(count).divide(BigDecimal.valueOf(coalValues.size()), 2, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100));
+ reportStatisticsDto.setWholeStandardRate(wholeStandardRate);
+ }else{
+ reportStatisticsDto.setAverageFuel(BigDecimal.ZERO);
+ reportStatisticsDto.setWholeStandardRate(BigDecimal.ZERO);
+ reportStatisticsDto.setUnitHeatValue(BigDecimal.ZERO);
+ }
+ }
+ return R.ok(reportStatisticsDto);
+ }
+
+ @Override
+ public R<List<ItemListDto>> reportTrend(DateQueryDto dto) {
+ List<LocalDate> lastFiveDaysQuery = getLastFiveDaysQuery();
+ List<ItemListDto> itemListDtos = new ArrayList<>();
+ for (LocalDate s : lastFiveDaysQuery) {
+ ItemListDto itemListDto = new ItemListDto();
+ itemListDto.setName(s.toString());
+ LambdaQueryWrapper<OfficialInventory> officialInventoryLambdaQueryWrapper = new LambdaQueryWrapper<>();
+ // 鍦╯鍚庨潰鎷间笂00:00:00
+ officialInventoryLambdaQueryWrapper.eq(OfficialInventory::getRegistrationDate, s);
+ List<OfficialInventory> officialInventories = officialInventoryMapper.selectList(officialInventoryLambdaQueryWrapper);
+ if(!CollectionUtils.isEmpty(officialInventories)){
+ List<CoalValue> coalValues = coalValueMapper.selectList(new LambdaQueryWrapper<CoalValue>()
+ .in(CoalValue::getPlanId, officialInventories.stream().map(OfficialInventory::getId).collect(Collectors.toList()))
+ .eq(CoalValue::getFieldName, "鍙戠儹閲�"));
+ // 鏁翠綋杈炬爣鐜�(鍙戠儹閲忊墺5000澶у崱)
+ long count = coalValues.stream()
+ .filter(coalValue -> BigDecimal.valueOf(Long.parseLong(coalValue.getCoalValue())).compareTo(BigDecimal.valueOf(5000)) >= 0)
+ .count();
+ // 鍒ゆ柇闄ゆ暟涓嶈兘涓洪浂鐨勬儏鍐�
+ if (!coalValues.isEmpty()) {
+ BigDecimal wholeStandardRate = BigDecimal.valueOf(count).divide(BigDecimal.valueOf(coalValues.size()), 2, RoundingMode.HALF_UP);
+ itemListDto.setValue(wholeStandardRate);
+ }else{
+ itemListDto.setValue(BigDecimal.ZERO);
+ }
+
+ }
+ itemListDtos.add(itemListDto);
+ }
+ return R.ok(itemListDtos);
+ }
+
+ @Override
+ public R<List<ItemListDto>> coalTypeHeatValueComparison(DateQueryDto dto) {
+ List<LocalDate> lastFiveDaysQuery = getLastFiveDaysQuery();
+ List<ItemListDto> itemListDtos = new ArrayList<>();
+ for (LocalDate s : lastFiveDaysQuery) {
+ ItemListDto itemListDto = new ItemListDto();
+ itemListDto.setName(s.toString());
+ LambdaQueryWrapper<OfficialInventory> officialInventoryLambdaQueryWrapper = new LambdaQueryWrapper<>();
+ // 鍦╯鍚庨潰鎷间笂00:00:00
+ officialInventoryLambdaQueryWrapper.eq(OfficialInventory::getRegistrationDate, s);
+ List<OfficialInventory> officialInventories = officialInventoryMapper.selectList(officialInventoryLambdaQueryWrapper);
+ if(!CollectionUtils.isEmpty(officialInventories)){
+ List<CoalValue> coalValues = coalValueMapper.selectList(new LambdaQueryWrapper<CoalValue>()
+ .in(CoalValue::getPlanId, officialInventories.stream().map(OfficialInventory::getId).collect(Collectors.toList()))
+ .eq(CoalValue::getFieldName, "鍙戠儹閲�"));
+ // 鍙戠儹閲�(姹傚拰)
+ long count = coalValues.stream()
+ .mapToLong(coalValue -> Long.parseLong(coalValue.getCoalValue()))
+ .sum();
+ itemListDto.setValue(BigDecimal.valueOf(count));
+ }
+ itemListDtos.add(itemListDto);
+ }
+ return R.ok(itemListDtos);
+ }
+
+ @Override
+ public R<List<ItemListDto>> processingRateAnalysis(DateQueryDto dto) {
+ List<LocalDate> lastFiveDaysQuery = getLastFiveDaysQuery();
+ List<ItemListDto> itemListDtos = new ArrayList<>();
+ for (LocalDate s : lastFiveDaysQuery) {
+ ItemListDto itemListDto = new ItemListDto();
+ itemListDto.setName(s.toString());
+ // 鑾峰彇閲囪喘鏁伴噺
+ LambdaQueryWrapper<PurchaseRegistration> purchaseRegistrationLambdaQueryWrapper = new LambdaQueryWrapper<>();
+ // 鍦╯鍚庨潰鎷间笂00:00:00
+ purchaseRegistrationLambdaQueryWrapper.eq(PurchaseRegistration::getRegistrationDate, s);
+ List<PurchaseRegistration> purchaseRegistrations = purchaseRegistrationMapper.selectList(purchaseRegistrationLambdaQueryWrapper);
+ if(!CollectionUtils.isEmpty(purchaseRegistrations)){
+ BigDecimal totalQuantity = purchaseRegistrations.stream()
+ .map(PurchaseRegistration::getPurchaseQuantity)
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
+ // 鑾峰彇姝e紡搴撳瓨鏁伴噺
+ LambdaQueryWrapper<OfficialInventory> officialInventoryLambdaQueryWrapper = new LambdaQueryWrapper<>();
+ // 鍦╯鍚庨潰鎷间笂00:00:00
+ officialInventoryLambdaQueryWrapper.eq(OfficialInventory::getRegistrationDate, s);
+ List<OfficialInventory> officialInventories = officialInventoryMapper.selectList(officialInventoryLambdaQueryWrapper);
+ if(!CollectionUtils.isEmpty(officialInventories)){
+ BigDecimal officialInventoryQuantity = officialInventories.stream()
+ .map(OfficialInventory::getInventoryQuantity)
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
+ // 鍔犲伐寰楃巼 = 姝e紡搴撳瓨鏁伴噺/閲囪喘鏁伴噺
+ if(!totalQuantity.equals(BigDecimal.ZERO)){
+ itemListDto.setValue(officialInventoryQuantity.divide(totalQuantity, 2, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)));
+ }else{
+ itemListDto.setValue(BigDecimal.ZERO);
+ }
+ }
+ }
+ itemListDtos.add(itemListDto);
+ }
+ return R.ok(itemListDtos);
+ }
+
+ @Override
+ public R<List<ItemListDto>> costStructure(DateQueryDto dto) {
+ List<ItemListDto> itemListDtos = new ArrayList<>();
+ LocalDate now = LocalDate.now();
+ LocalDate startDate = now.minusDays(4);
+ LambdaQueryWrapper<Production> productionLambdaQueryWrapper = new LambdaQueryWrapper<>();
+ productionLambdaQueryWrapper.between(Production::getCreateTime, startDate, now);
+ List<Production> productions = productionMapper.selectList(productionLambdaQueryWrapper);
+ ItemListDto itemListDto = new ItemListDto();
+ itemListDto.setName("浜哄伐鎴愭湰");
+ itemListDto.setValue(productions.stream()
+ .map(Production::getLaborCost)
+ .reduce(BigDecimal.ZERO, BigDecimal::add));
+ itemListDtos.add(itemListDto);
+ ItemListDto itemListDtoOne = new ItemListDto();
+ itemListDtoOne.setName("鑳借�楁垚鏈�");
+ itemListDtoOne.setValue(productions.stream()
+ .map(Production::getEnergyConsumptionCost)
+ .reduce(BigDecimal.ZERO, BigDecimal::add));
+ itemListDtos.add(itemListDtoOne);
+ return R.ok(itemListDtos);
+ }
+
+ /**
+ * 鑾峰彇鏈�杩戜簲澶╃殑鏃堕棿闆嗗悎
+ */
+ private List<LocalDate> getLastFiveDaysQuery() {
+ LocalDate now = LocalDate.now();
+ LocalDate startDate = now.minusDays(4);
+ List<LocalDate> dates = new ArrayList<>();
+ for (int i = 0; i < 5; i++) {
+ LocalDate date = startDate.plusDays(i);
+ dates.add(date);
+ }
+ return dates;
+ }
+}
diff --git a/main-business/src/main/java/com/ruoyi/business/service/impl/PurchaseRegistrationServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/service/impl/PurchaseRegistrationServiceImpl.java
index e5bf02c..ff3ec62 100644
--- a/main-business/src/main/java/com/ruoyi/business/service/impl/PurchaseRegistrationServiceImpl.java
+++ b/main-business/src/main/java/com/ruoyi/business/service/impl/PurchaseRegistrationServiceImpl.java
@@ -14,6 +14,7 @@
import com.ruoyi.business.mapper.PendingInventoryMapper;
import com.ruoyi.business.mapper.PurchaseRegistrationMapper;
import com.ruoyi.business.service.PurchaseRegistrationService;
+import com.ruoyi.business.utils.OrderUtils;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
@@ -95,6 +96,9 @@
}
purchaseRegistration.setSupplierName(supply.getSupplierName());
if (Objects.isNull(purchaseRegistrationDto.getId())) {
+ // 鐢熸垚閲囪喘鍗曞彿
+ String pr = OrderUtils.countTodayByCreateTime(purchaseRegistrationMapper, "PR");
+ purchaseRegistration.setPurchaseNumber(pr);
// 鏂板閲囪喘鐧昏
purchaseRegistration.setRegistrationDate(LocalDate.now());
int insertCount = purchaseRegistrationMapper.insert(purchaseRegistration);
@@ -102,6 +106,7 @@
// 閲囪喘鐧昏鎴愬姛锛屽悓姝ュ垱寤哄緟鍏ュ簱璁板綍
PendingInventory pendingInventory = createPendingInventory(purchaseRegistration);
pendingInventory.setSupplierName(supply.getSupplierName());
+ pendingInventory.setPurchaseNumber(pr);
return pendingInventoryMapper.insert(pendingInventory);
}
return insertCount;
diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml
index 1ce8076..befa7bf 100644
--- a/ruoyi-common/pom.xml
+++ b/ruoyi-common/pom.xml
@@ -144,6 +144,24 @@
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>druid</artifactId>
+ <version>1.2.23</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.mchange</groupId>
+ <artifactId>mchange-commons-java</artifactId>
+ <version>0.2.15</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.swagger.core.v3</groupId>
+ <artifactId>swagger-annotations-jakarta</artifactId>
+ <version>2.2.22</version>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/MyBaseEntity.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/MyBaseEntity.java
index ab2a5f7..20897ed 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/MyBaseEntity.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/MyBaseEntity.java
@@ -6,11 +6,12 @@
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
-
+import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import java.time.LocalDateTime;
@Data
+@Schema
public class MyBaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
@@ -20,19 +21,23 @@
/** 鍒涘缓鑰� */
@TableField(fill = FieldFill.INSERT)
+ @Schema(title = "鍒涘缓鑰�")
private String createBy;
/** 鍒涘缓鏃堕棿 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.NEVER)
+ @Schema(title = "鍒涘缓鏃堕棿")
private LocalDateTime createTime;
/** 鏇存柊鑰� */
@TableField(fill = FieldFill.INSERT_UPDATE)
+ @Schema(title = "鏇存柊鑰�")
private String updateBy;
/** 鏇存柊鏃堕棿 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField(fill = FieldFill.INSERT_UPDATE)
+ @Schema(title = "鏇存柊鏃堕棿")
private LocalDateTime updateTime;
}
--
Gitblit v1.9.3