From 92d4fac0b58498efc6be7764f00364535beb3d71 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期二, 08 七月 2025 18:02:00 +0800
Subject: [PATCH] 1.首页数据 2.装备数据
---
main-business/src/main/java/com/ruoyi/business/controller/HomePageController.java | 55 +++
main-business/src/main/java/com/ruoyi/business/service/impl/EquipmentManagementServiceImpl.java | 17 +
main-business/src/main/resources/mapper/EquipmentUsageRecordMapper.xml | 33 ++
main-business/src/main/java/com/ruoyi/business/service/EquipmentUsageRecordService.java | 23 +
main-business/src/main/java/com/ruoyi/business/entity/EquipmentUsageRecord.java | 66 ++++
main-business/src/main/java/com/ruoyi/business/service/EquipmentManagementService.java | 5
main-business/src/main/java/com/ruoyi/business/service/impl/EquipmentUsageRecordServiceImpl.java | 84 ++++++
main-business/src/main/java/com/ruoyi/business/mapper/EquipmentUsageRecordMapper.java | 18 +
main-business/src/main/resources/db/migration/postgresql/V20250707155600__create_table_equipment_usage_record.sql | 39 ++
main-business/src/main/java/com/ruoyi/business/dto/EquipmentUsageRecordDto.java | 12
main-business/src/main/java/com/ruoyi/business/vo/EquipmentManagementVo.java | 13
main-business/src/main/java/com/ruoyi/business/dto/YearlyQueryDto.java | 26 +
main-business/src/main/java/com/ruoyi/business/mapper/SalesRecordMapper.java | 6
main-business/src/main/java/com/ruoyi/business/service/impl/OfficialInventoryServiceImpl.java | 24 +
main-business/src/main/java/com/ruoyi/business/service/impl/SalesRecordServiceImpl.java | 286 ++++++++++++++++++++
main-business/src/main/java/com/ruoyi/business/service/OfficialInventoryService.java | 4
main-business/src/main/resources/mapper/SalesRecordMapper.xml | 14
main-business/src/main/java/com/ruoyi/business/controller/EquipmentManagementController.java | 13
main-business/src/main/resources/db/migration/postgresql/V20250701142700__create_table_equipment_management.sql | 4
main-business/src/main/java/com/ruoyi/business/service/SalesRecordService.java | 8
main-business/src/main/java/com/ruoyi/business/dto/HomePageDto.java | 31 ++
main-business/src/main/java/com/ruoyi/business/entity/EquipmentManagement.java | 4
main-business/src/main/java/com/ruoyi/business/controller/EquipmentUsageRecordController.java | 47 +++
23 files changed, 825 insertions(+), 7 deletions(-)
diff --git a/main-business/src/main/java/com/ruoyi/business/controller/EquipmentManagementController.java b/main-business/src/main/java/com/ruoyi/business/controller/EquipmentManagementController.java
index 1a30f74..aa157c5 100644
--- a/main-business/src/main/java/com/ruoyi/business/controller/EquipmentManagementController.java
+++ b/main-business/src/main/java/com/ruoyi/business/controller/EquipmentManagementController.java
@@ -7,9 +7,13 @@
import com.ruoyi.business.entity.EquipmentManagement;
import com.ruoyi.business.entity.Production;
import com.ruoyi.business.service.EquipmentManagementService;
+import com.ruoyi.business.vo.EquipmentManagementVo;
import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.utils.bean.BeanUtils;
import org.springframework.web.bind.annotation.*;
import lombok.AllArgsConstructor;
+
+import java.util.List;
/**
* <p>
@@ -52,5 +56,12 @@
return R.ok(equipmentManagementService.delByIds(ids));
}
-
+ /**
+ * 璁惧list
+ */
+ @GetMapping("/equipmentList")
+ public R<List<EquipmentManagementVo>> selectEquipmentList() {
+ List<EquipmentManagementVo> equipmentManagementVo = equipmentManagementService.selectEquipmentList();
+ return R.ok(equipmentManagementVo);
+ }
}
diff --git a/main-business/src/main/java/com/ruoyi/business/controller/EquipmentUsageRecordController.java b/main-business/src/main/java/com/ruoyi/business/controller/EquipmentUsageRecordController.java
new file mode 100644
index 0000000..f7f1b90
--- /dev/null
+++ b/main-business/src/main/java/com/ruoyi/business/controller/EquipmentUsageRecordController.java
@@ -0,0 +1,47 @@
+package com.ruoyi.business.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.business.dto.EquipmentManagementDto;
+import com.ruoyi.business.dto.EquipmentUsageRecordDto;
+import com.ruoyi.business.entity.EquipmentManagement;
+import com.ruoyi.business.entity.EquipmentUsageRecord;
+import com.ruoyi.business.service.EquipmentUsageRecordService;
+import com.ruoyi.common.core.domain.R;
+import org.springframework.web.bind.annotation.*;
+import lombok.AllArgsConstructor;
+
+/**
+ * <p>
+ * 璁惧浣跨敤璁板綍琛� 鍓嶇鎺у埗鍣�
+ * </p>
+ *
+ * @author ld
+ * @since 2025-07-07
+ */
+
+@RestController
+@AllArgsConstructor
+@RequestMapping("/equipmentUsageRecord")
+public class EquipmentUsageRecordController {
+
+ private EquipmentUsageRecordService equipmentUsageRecordService;
+
+ /**
+ * 璁惧浣跨敤璁板綍琛ㄦ煡璇�
+ */
+ @GetMapping("/list")
+ public R<IPage<EquipmentUsageRecordDto>> list(Page<EquipmentUsageRecord> page, EquipmentUsageRecordDto equipmentUsageRecordDto) {
+ IPage<EquipmentUsageRecordDto> list = equipmentUsageRecordService.selectUsageRecordList(page, equipmentUsageRecordDto);
+ return R.ok(list);
+ }
+
+ /**
+ * 璁惧浣跨敤璁板綍琛ㄦ柊澧炰慨鏀�
+ */
+ @PostMapping("/addOrEditUsageRecord")
+ public R addOrEditUsageRecord(@RequestBody EquipmentUsageRecordDto equipmentUsageRecordDto) {
+ return R.ok(equipmentUsageRecordService.addOrEditUsageRecord(equipmentUsageRecordDto));
+ }
+
+}
diff --git a/main-business/src/main/java/com/ruoyi/business/controller/HomePageController.java b/main-business/src/main/java/com/ruoyi/business/controller/HomePageController.java
new file mode 100644
index 0000000..d4f3814
--- /dev/null
+++ b/main-business/src/main/java/com/ruoyi/business/controller/HomePageController.java
@@ -0,0 +1,55 @@
+package com.ruoyi.business.controller;
+
+import com.ruoyi.business.dto.HomePageDto;
+import com.ruoyi.business.dto.YearlyQueryDto;
+import com.ruoyi.business.service.OfficialInventoryService;
+import com.ruoyi.business.service.SalesRecordService;
+import com.ruoyi.common.core.domain.R;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@AllArgsConstructor
+@RequestMapping("/homePage")
+public class HomePageController {
+
+ private SalesRecordService salesRecordService;
+
+ private OfficialInventoryService officialInventoryService;
+
+ @GetMapping("/allInfo")
+ private R<HomePageDto> homePageDto() {
+ HomePageDto homePageDto = new HomePageDto();
+ Map<String, Object> map = salesRecordService.selectAllInfo();
+ //钀ユ敹閲戦
+ homePageDto.setRevenueAmount((BigDecimal) map.get("revenueAmount"));
+ homePageDto.setChangeRate(map.get("changeRate").toString());
+ homePageDto.setTrend(map.get("trend").toString());
+ //渚涘簲閲�
+ homePageDto.setSaleQuantity((BigDecimal) map.get("saleQuantity"));
+ homePageDto.setSaleQuantityRate(map.get("saleQuantityRate").toString());
+ homePageDto.setTrendQuantity(map.get("trendQuantity").toString());
+ //钀ユ敹鍒嗗竷
+ homePageDto.setRevenueDistribution((Map<String, BigDecimal>) map.get("revenueDistribution"));
+ //搴撳瓨缁熻
+ Map<String, BigDecimal> maps = officialInventoryService.selectOfficialAllInfo();
+ homePageDto.setInventory(maps);
+ //鏈堝害缁熻
+
+ //閿�鍞暟鎹�
+ homePageDto.setSalesResults((List<Map<String, Object>>) map.get("salesResults"));
+
+ return R.ok(homePageDto);
+ }
+
+ @PostMapping("/yearlySales")
+ public R<Map<String, Object>> getYearlyMonthlySales(@RequestBody YearlyQueryDto query) {
+ Map<String, Object> data = salesRecordService.getYearlyMonthlySales(query);
+ return R.ok(data);
+ }
+
+}
diff --git a/main-business/src/main/java/com/ruoyi/business/dto/EquipmentUsageRecordDto.java b/main-business/src/main/java/com/ruoyi/business/dto/EquipmentUsageRecordDto.java
new file mode 100644
index 0000000..9710cd0
--- /dev/null
+++ b/main-business/src/main/java/com/ruoyi/business/dto/EquipmentUsageRecordDto.java
@@ -0,0 +1,12 @@
+package com.ruoyi.business.dto;
+
+import com.ruoyi.business.entity.EquipmentUsageRecord;
+import lombok.Data;
+
+@Data
+public class EquipmentUsageRecordDto extends EquipmentUsageRecord {
+
+ private String equipmentNo; //璁惧缂栧彿
+
+ private String equipmentName; //璁惧鍚嶇О
+}
diff --git a/main-business/src/main/java/com/ruoyi/business/dto/HomePageDto.java b/main-business/src/main/java/com/ruoyi/business/dto/HomePageDto.java
new file mode 100644
index 0000000..152da9e
--- /dev/null
+++ b/main-business/src/main/java/com/ruoyi/business/dto/HomePageDto.java
@@ -0,0 +1,31 @@
+package com.ruoyi.business.dto;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Map;
+
+@Data
+public class HomePageDto {
+
+ //钀ユ敹閲戦
+ private BigDecimal revenueAmount;
+ //钀ユ敹閲戦杈冩槰鏃�
+ private String changeRate;
+ //钀ユ敹瓒嬪娍
+ private String trend;
+ //閿�鍞暟閲忥紝渚涘簲閲�
+ private BigDecimal saleQuantity;
+ //渚涘簲閲忚緝鏄ㄦ棩
+ private String saleQuantityRate;
+ //渚涘簲瓒嬪娍
+ private String trendQuantity;
+ //钀ユ敹鍒嗗竷
+ private Map<String, BigDecimal> revenueDistribution;
+ //搴撳瓨缁熻
+ private Map<String, BigDecimal> inventory;
+ //閿�鍞暟鎹�
+ private List<Map<String, Object>> salesResults;
+
+}
diff --git a/main-business/src/main/java/com/ruoyi/business/dto/YearlyQueryDto.java b/main-business/src/main/java/com/ruoyi/business/dto/YearlyQueryDto.java
new file mode 100644
index 0000000..e3275a0
--- /dev/null
+++ b/main-business/src/main/java/com/ruoyi/business/dto/YearlyQueryDto.java
@@ -0,0 +1,26 @@
+package com.ruoyi.business.dto;
+
+import jakarta.validation.constraints.*;
+import lombok.Data;
+
+import static com.ruoyi.common.utils.DateUtils.parseDate;
+
+@Data
+public class YearlyQueryDto {
+
+ @Size(min = 2, max = 2, message = "鏃堕棿鑼冨洿蹇呴』鍖呭惈寮�濮嬪拰缁撴潫鏃ユ湡")
+ private String[] timeRange;
+
+ @AssertTrue(message = "鏃ユ湡鏍煎紡蹇呴』涓篩YYY-MM")
+ public boolean isTimeRangeValid() {
+ try {
+ if (timeRange == null || timeRange.length != 2) return false;
+ parseDate(timeRange[0]);
+ parseDate(timeRange[1]);
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+}
diff --git a/main-business/src/main/java/com/ruoyi/business/entity/EquipmentManagement.java b/main-business/src/main/java/com/ruoyi/business/entity/EquipmentManagement.java
index 4cb21c4..742d5c4 100644
--- a/main-business/src/main/java/com/ruoyi/business/entity/EquipmentManagement.java
+++ b/main-business/src/main/java/com/ruoyi/business/entity/EquipmentManagement.java
@@ -28,8 +28,8 @@
/**
* 璁惧缂栧彿
*/
- @TableField(value = "equipment_id")
- private String equipmentId;
+ @TableField(value = "equipment_no")
+ private String equipmentNo;
/**
* 璁惧鍚嶇О
*/
diff --git a/main-business/src/main/java/com/ruoyi/business/entity/EquipmentUsageRecord.java b/main-business/src/main/java/com/ruoyi/business/entity/EquipmentUsageRecord.java
new file mode 100644
index 0000000..b4d0fc3
--- /dev/null
+++ b/main-business/src/main/java/com/ruoyi/business/entity/EquipmentUsageRecord.java
@@ -0,0 +1,66 @@
+package com.ruoyi.business.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.Data;
+import com.ruoyi.common.core.domain.MyBaseEntity;
+
+import java.time.LocalDate;
+
+/**
+ * 璁惧浣跨敤璁板綍琛� 瀹炰綋绫�
+ *
+ * @author ld
+ * @date 2025-07-07
+ */
+@Data
+@TableName("equipment_usage_record")
+public class EquipmentUsageRecord extends MyBaseEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 涓婚敭ID
+ */
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+ /**
+ * 璁惧ID
+ */
+ @TableField(value = "equipment_id")
+ private Long equipmentId;
+ /**
+ * 浣跨敤鏁伴噺
+ */
+ @TableField(value = "usage_quantity")
+ private Integer usageQuantity;
+ /**
+ * 浣跨敤浜篒D
+ */
+ @TableField(value = "user_id")
+ private Long userId;
+ /**
+ * 閮ㄩ棬ID
+ */
+ @TableField(value = "department_id")
+ private Long departmentId;
+ /**
+ * 璁惧鐘舵�侊紙姝e父/鏁呴殰/缁翠慨涓級
+ */
+ @TableField(value = "equipment_status")
+ private String equipmentStatus;
+ /**
+ * 浣跨敤寮�濮嬫椂闂�
+ */
+ @TableField(value = "usage_start_time")
+ private LocalDate usageStartTime;
+ /**
+ * 浣跨敤缁撴潫鏃堕棿
+ */
+ @TableField(value = "usage_end_time")
+ private LocalDate usageEndTime;
+ /**
+ * 澶囨敞淇℃伅
+ */
+ @TableField(value = "remarks")
+ private String remarks;
+}
\ No newline at end of file
diff --git a/main-business/src/main/java/com/ruoyi/business/mapper/EquipmentUsageRecordMapper.java b/main-business/src/main/java/com/ruoyi/business/mapper/EquipmentUsageRecordMapper.java
new file mode 100644
index 0000000..2d35200
--- /dev/null
+++ b/main-business/src/main/java/com/ruoyi/business/mapper/EquipmentUsageRecordMapper.java
@@ -0,0 +1,18 @@
+package com.ruoyi.business.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.business.entity.EquipmentUsageRecord;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ * 璁惧浣跨敤璁板綍琛� Mapper 鎺ュ彛
+ * </p>
+ *
+ * @author ld
+ * @since 2025-07-07
+ */
+@Mapper
+public interface EquipmentUsageRecordMapper extends BaseMapper<EquipmentUsageRecord> {
+
+}
diff --git a/main-business/src/main/java/com/ruoyi/business/mapper/SalesRecordMapper.java b/main-business/src/main/java/com/ruoyi/business/mapper/SalesRecordMapper.java
index 57e6f8f..f71e69c 100644
--- a/main-business/src/main/java/com/ruoyi/business/mapper/SalesRecordMapper.java
+++ b/main-business/src/main/java/com/ruoyi/business/mapper/SalesRecordMapper.java
@@ -1,8 +1,13 @@
package com.ruoyi.business.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.business.dto.SalesRecordDto;
import com.ruoyi.business.entity.SalesRecord;
import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.time.LocalDate;
+import java.util.List;
/**
* <p>
@@ -15,4 +20,5 @@
@Mapper
public interface SalesRecordMapper extends BaseMapper<SalesRecord> {
+ List<SalesRecord> findByDateRange(@Param("startDate")LocalDate startDate, @Param("endDate") LocalDate endDate);
}
diff --git a/main-business/src/main/java/com/ruoyi/business/service/EquipmentManagementService.java b/main-business/src/main/java/com/ruoyi/business/service/EquipmentManagementService.java
index 2cbca4b..ef9a7db 100644
--- a/main-business/src/main/java/com/ruoyi/business/service/EquipmentManagementService.java
+++ b/main-business/src/main/java/com/ruoyi/business/service/EquipmentManagementService.java
@@ -5,6 +5,9 @@
import com.ruoyi.business.dto.EquipmentManagementDto;
import com.ruoyi.business.entity.EquipmentManagement;
import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.business.vo.EquipmentManagementVo;
+
+import java.util.List;
/**
* <p>
@@ -21,4 +24,6 @@
int addOrEditEquipment(EquipmentManagementDto equipmentManagementDto);
int delByIds(Long[] ids);
+
+ List<EquipmentManagementVo> selectEquipmentList();
}
diff --git a/main-business/src/main/java/com/ruoyi/business/service/EquipmentUsageRecordService.java b/main-business/src/main/java/com/ruoyi/business/service/EquipmentUsageRecordService.java
new file mode 100644
index 0000000..08af3cb
--- /dev/null
+++ b/main-business/src/main/java/com/ruoyi/business/service/EquipmentUsageRecordService.java
@@ -0,0 +1,23 @@
+package com.ruoyi.business.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.business.dto.EquipmentUsageRecordDto;
+import com.ruoyi.business.entity.EquipmentManagement;
+import com.ruoyi.business.entity.EquipmentUsageRecord;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ * 璁惧浣跨敤璁板綍琛� 鏈嶅姟绫�
+ * </p>
+ *
+ * @author ld
+ * @since 2025-07-07
+ */
+public interface EquipmentUsageRecordService extends IService<EquipmentUsageRecord> {
+
+ IPage<EquipmentUsageRecordDto> selectUsageRecordList(Page<EquipmentUsageRecord> page, EquipmentUsageRecordDto equipmentUsageRecordDto);
+
+ int addOrEditUsageRecord(EquipmentUsageRecordDto equipmentUsageRecordDto);
+}
diff --git a/main-business/src/main/java/com/ruoyi/business/service/OfficialInventoryService.java b/main-business/src/main/java/com/ruoyi/business/service/OfficialInventoryService.java
index 392ef27..98d7270 100644
--- a/main-business/src/main/java/com/ruoyi/business/service/OfficialInventoryService.java
+++ b/main-business/src/main/java/com/ruoyi/business/service/OfficialInventoryService.java
@@ -7,7 +7,9 @@
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.business.vo.OfficialInventoryVo;
+import java.math.BigDecimal;
import java.util.List;
+import java.util.Map;
/**
* <p>
@@ -28,4 +30,6 @@
List<OfficialInventoryVo> selectOfficialList(OfficialInventoryVo officialInventoryVo);
List<OfficialInventory> selectOfficialAll();
+
+ Map<String, BigDecimal> selectOfficialAllInfo();
}
diff --git a/main-business/src/main/java/com/ruoyi/business/service/SalesRecordService.java b/main-business/src/main/java/com/ruoyi/business/service/SalesRecordService.java
index 7786086..4a2f691 100644
--- a/main-business/src/main/java/com/ruoyi/business/service/SalesRecordService.java
+++ b/main-business/src/main/java/com/ruoyi/business/service/SalesRecordService.java
@@ -4,7 +4,11 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.business.dto.SalesRecordDto;
+import com.ruoyi.business.dto.YearlyQueryDto;
import com.ruoyi.business.entity.SalesRecord;
+import jakarta.validation.Valid;
+
+import java.util.Map;
/**
* <p>
@@ -21,4 +25,8 @@
int addOrEditSalesRecord(SalesRecordDto salesRecordDto);
int delByIds(Long[] ids);
+
+ Map<String, Object> selectAllInfo();
+
+ Map<String, Object> getYearlyMonthlySales(@Valid YearlyQueryDto query);
}
diff --git a/main-business/src/main/java/com/ruoyi/business/service/impl/EquipmentManagementServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/service/impl/EquipmentManagementServiceImpl.java
index 1ac61c9..dbad9ab 100644
--- a/main-business/src/main/java/com/ruoyi/business/service/impl/EquipmentManagementServiceImpl.java
+++ b/main-business/src/main/java/com/ruoyi/business/service/impl/EquipmentManagementServiceImpl.java
@@ -10,11 +10,13 @@
import com.ruoyi.business.mapper.EquipmentManagementMapper;
import com.ruoyi.business.service.EquipmentManagementService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.business.vo.EquipmentManagementVo;
import com.ruoyi.common.utils.bean.BeanUtils;
import org.springframework.stereotype.Service;
import lombok.RequiredArgsConstructor;
import java.util.Arrays;
+import java.util.List;
import java.util.Objects;
/**
@@ -35,7 +37,6 @@
Page<EquipmentManagement> entityPage = equipmentManagementMapper.selectPage(page, null);
IPage<EquipmentManagementDto> dtoPage = new Page<>();
BeanUtils.copyProperties(entityPage, dtoPage);
-
return dtoPage;
}
@@ -51,6 +52,20 @@
}
@Override
+ public List<EquipmentManagementVo> selectEquipmentList() {
+ List<EquipmentManagement> equipmentManagements = equipmentManagementMapper.selectList(null);
+ return equipmentManagements.stream()
+ .map(equipment -> {
+ EquipmentManagementVo vo = new EquipmentManagementVo();
+ vo.setId(equipment.getId()); // 璁惧id
+ vo.setEquipmentName(equipment.getEquipmentName()); // 璁惧鍚嶇О
+ vo.setQuantity(equipment.getQuantity()); // 鏁伴噺
+ return vo;
+ })
+ .toList();
+ }
+
+ @Override
public int delByIds(Long[] ids) {
return equipmentManagementMapper.deleteByIds(Arrays.asList(ids));
}
diff --git a/main-business/src/main/java/com/ruoyi/business/service/impl/EquipmentUsageRecordServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/service/impl/EquipmentUsageRecordServiceImpl.java
new file mode 100644
index 0000000..a1d8661
--- /dev/null
+++ b/main-business/src/main/java/com/ruoyi/business/service/impl/EquipmentUsageRecordServiceImpl.java
@@ -0,0 +1,84 @@
+package com.ruoyi.business.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.basic.entity.Supply;
+import com.ruoyi.business.dto.EquipmentManagementDto;
+import com.ruoyi.business.dto.EquipmentUsageRecordDto;
+import com.ruoyi.business.entity.EquipmentManagement;
+import com.ruoyi.business.entity.EquipmentUsageRecord;
+import com.ruoyi.business.mapper.EquipmentManagementMapper;
+import com.ruoyi.business.mapper.EquipmentUsageRecordMapper;
+import com.ruoyi.business.service.EquipmentUsageRecordService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.utils.bean.BeanUtils;
+import org.springframework.stereotype.Service;
+import lombok.RequiredArgsConstructor;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+/**
+ * <p>
+ * 璁惧浣跨敤璁板綍琛� 鏈嶅姟瀹炵幇绫�
+ * </p>
+ *
+ * @author ld
+ * @since 2025-07-07
+ */
+@Service
+@RequiredArgsConstructor
+public class EquipmentUsageRecordServiceImpl extends ServiceImpl<EquipmentUsageRecordMapper, EquipmentUsageRecord> implements EquipmentUsageRecordService {
+
+ private final EquipmentUsageRecordMapper equipmentUsageRecordMapper;
+
+ private final EquipmentManagementMapper equipmentManagementMapper;
+
+ @Override
+ public IPage<EquipmentUsageRecordDto> selectUsageRecordList(Page<EquipmentUsageRecord> page, EquipmentUsageRecordDto equipmentUsageRecordDto) {
+ Page<EquipmentUsageRecord> entityPage = equipmentUsageRecordMapper.selectPage(page, null);
+ IPage<EquipmentUsageRecordDto> dtoPage = new Page<>();
+ BeanUtils.copyProperties(entityPage, dtoPage);
+
+ List<Long> eqIds = entityPage.getRecords().stream().map(EquipmentUsageRecord::getEquipmentId).toList();
+ //鎵归噺鏌ヨ
+ Map<Long, EquipmentManagement> equipmentManagementMap;
+ if (!eqIds.isEmpty()) {
+ List<EquipmentManagement> infos = equipmentManagementMapper.selectList(new LambdaQueryWrapper<EquipmentManagement>().in(EquipmentManagement::getId, eqIds));
+ equipmentManagementMap = infos.stream().collect(Collectors.toMap(EquipmentManagement::getId, Function.identity()));
+ } else {
+ equipmentManagementMap = new HashMap<>();
+ }
+ //鍖归厤鏁版嵁
+ List<EquipmentUsageRecordDto> dtoRecords = entityPage.getRecords().stream().map(entity -> {
+ EquipmentUsageRecordDto dto = new EquipmentUsageRecordDto();
+ BeanUtils.copyProperties(entity, dto);
+
+ EquipmentManagement equipment = equipmentManagementMap.get(entity.getEquipmentId());
+ if (equipment != null) {
+ dto.setEquipmentNo(equipment.getEquipmentNo());
+ dto.setEquipmentName(equipment.getEquipmentName());
+ }
+ return dto;
+ }).toList();
+
+ dtoPage.setRecords(dtoRecords);
+ return dtoPage;
+ }
+
+ @Override
+ public int addOrEditUsageRecord(EquipmentUsageRecordDto equipmentUsageRecordDto) {
+ EquipmentUsageRecord equipmentUsageRecord = new EquipmentUsageRecord();
+ BeanUtils.copyProperties(equipmentUsageRecordDto, equipmentUsageRecord);
+ if (Objects.isNull(equipmentUsageRecordDto.getId())) {
+ return equipmentUsageRecordMapper.insert(equipmentUsageRecord);
+ } else {
+ return equipmentUsageRecordMapper.updateById(equipmentUsageRecord);
+ }
+ }
+}
diff --git a/main-business/src/main/java/com/ruoyi/business/service/impl/OfficialInventoryServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/service/impl/OfficialInventoryServiceImpl.java
index ceafff7..131b109 100644
--- a/main-business/src/main/java/com/ruoyi/business/service/impl/OfficialInventoryServiceImpl.java
+++ b/main-business/src/main/java/com/ruoyi/business/service/impl/OfficialInventoryServiceImpl.java
@@ -26,7 +26,9 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import java.math.BigDecimal;
import java.util.*;
+import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -330,4 +332,26 @@
}
}
+ @Override
+ public Map<String, BigDecimal> selectOfficialAllInfo() {
+ // 1. 鏌ヨ official_inventory 琛ㄦ暟鎹�
+ List<OfficialInventory> officialInventories = officialInventoryMapper.selectList(null);
+
+ // 鐢ㄤ簬瀛樺偍鏈�缁堢粨鏋滐紝key 涓虹叅绉嶅悕绉帮紝value 涓哄簱瀛樻暟閲忔嫾鎺モ�滃惃鈥�
+ Map<String, BigDecimal> resultMap = new LinkedHashMap<>();
+
+ // 2. 閬嶅巻鏌ヨ缁撴灉锛屽叧鑱� coalInfo 鑾峰彇鐓ょ鍚嶇О骞剁粍瑁呮暟鎹�
+ for (OfficialInventory inventory : officialInventories) {
+ Long coalId = inventory.getCoalId();
+ // 鏍规嵁 coalId 鍒� coalInfoMapper 鏌ヨ鐓ょ鍚嶇О
+ CoalInfo coalInfo = coalInfoMapper.selectById(coalId);
+ if (coalInfo != null) {
+ String coalName = coalInfo.getCoal(); // 鍋囪 CoalInfo 鏈� getCoalName 鏂规硶鑾峰彇鐓ょ鍚嶇О
+ BigDecimal quantity = inventory.getInventoryQuantity();
+ resultMap.put(coalName, quantity);
+ }
+ }
+ return resultMap;
+ }
+
}
diff --git a/main-business/src/main/java/com/ruoyi/business/service/impl/SalesRecordServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/service/impl/SalesRecordServiceImpl.java
index 46d6e5b..2f162a7 100644
--- a/main-business/src/main/java/com/ruoyi/business/service/impl/SalesRecordServiceImpl.java
+++ b/main-business/src/main/java/com/ruoyi/business/service/impl/SalesRecordServiceImpl.java
@@ -1,6 +1,7 @@
package com.ruoyi.business.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -10,6 +11,7 @@
import com.ruoyi.basic.mapper.CoalInfoMapper;
import com.ruoyi.basic.mapper.CustomerMapper;
import com.ruoyi.business.dto.SalesRecordDto;
+import com.ruoyi.business.dto.YearlyQueryDto;
import com.ruoyi.business.entity.OfficialInventory;
import com.ruoyi.business.entity.SalesRecord;
import com.ruoyi.business.mapper.OfficialInventoryMapper;
@@ -23,12 +25,21 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.DecimalFormat;
import java.time.LocalDate;
+import java.time.YearMonth;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
+import java.time.temporal.TemporalAdjusters;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
+import java.util.*;
/**
* <p>
@@ -218,4 +229,279 @@
// 鎵ц鎵归噺閫昏緫鍒犻櫎
return salesRecordMapper.update(null, updateWrapper);
}
+
+ @Override
+ public Map<String, Object> getYearlyMonthlySales(YearlyQueryDto query) {
+ // 1. 澶勭悊榛樿鏌ヨ锛堜笉浼犲弬鏁版椂锛�
+ if (query == null || query.getTimeRange() == null || query.getTimeRange().length == 0) {
+ query = getDefaultQuery();
+ }
+
+ // 2. 瑙f瀽鏃堕棿鑼冨洿
+ LocalDate[] dateRange = parseAndValidateDateRange(query.getTimeRange());
+ LocalDate startDate = dateRange[0];
+ LocalDate endDate = dateRange[1];
+
+ // 3. 鏌ヨ鏁版嵁
+ List<SalesRecord> records = salesRecordMapper.findByDateRange(
+ startDate.withDayOfMonth(1),
+ endDate.withDayOfMonth(1).with(TemporalAdjusters.lastDayOfMonth())
+ );
+
+ // 4. 鏋勫缓鍝嶅簲
+ return buildResponse(query.getTimeRange(), records, startDate, endDate);
+ }
+
+ // 鑾峰彇榛樿鏌ヨ锛堝綋鍓嶅勾搴︽渶杩�6涓湀锛�
+ private YearlyQueryDto getDefaultQuery() {
+ LocalDate now = LocalDate.now();
+ LocalDate startDate = now.minusMonths(5).withDayOfMonth(1);
+
+ String[] timeRange = {
+ startDate.format(DateTimeFormatter.ofPattern("yyyy-MM")),
+ now.format(DateTimeFormatter.ofPattern("yyyy-MM"))
+ };
+
+ YearlyQueryDto defaultQuery = new YearlyQueryDto();
+ defaultQuery.setTimeRange(timeRange);
+ return defaultQuery;
+ }
+
+ // 瑙f瀽骞堕獙璇佹棩鏈熻寖鍥�
+ private LocalDate[] parseAndValidateDateRange(String[] timeRange) {
+ if (timeRange == null || timeRange.length != 2) {
+ throw new IllegalArgumentException("鏃堕棿鑼冨洿鍙傛暟鏍煎紡涓嶆纭�");
+ }
+
+ LocalDate startDate = parseDate(timeRange[0]);
+ LocalDate endDate = parseDate(timeRange[1]);
+
+ if (startDate.isAfter(endDate)) {
+ throw new IllegalArgumentException("寮�濮嬫棩鏈熶笉鑳芥櫄浜庣粨鏉熸棩鏈�");
+ }
+
+ return new LocalDate[]{startDate, endDate};
+ }
+
+ // 瑙f瀽鏃ユ湡锛堟牸寮忥細yyyy-MM锛�
+ private LocalDate parseDate(String dateStr) {
+ try {
+ return YearMonth.parse(dateStr).atDay(1);
+ } catch (DateTimeParseException e) {
+ throw new IllegalArgumentException("鏃ユ湡鏍煎紡涓嶆纭紝搴斾负 yyyy-MM", e);
+ }
+ }
+
+ // 鏋勫缓鍝嶅簲鏁版嵁
+ private Map<String, Object> buildResponse(String[] timeRange,
+ List<SalesRecord> records,
+ LocalDate startDate,
+ LocalDate endDate) {
+ Map<String, Object> response = new LinkedHashMap<>();
+ response.put("timeRange", timeRange);
+ response.put("data", formatMonthlyData(records, startDate, endDate));
+ response.put("isDefaultQuery", timeRange.equals(getDefaultQuery().getTimeRange()));
+ return response;
+ }
+
+ // 鏍煎紡鍖栨湀搴︽暟鎹�
+ private Map<String, Integer> formatMonthlyData(List<SalesRecord> records,
+ LocalDate startDate,
+ LocalDate endDate) {
+ // 棰勫畾涔夋牸寮忓寲鍣�
+ DateTimeFormatter monthFormatter = DateTimeFormatter.ofPattern("yyyy-MM");
+
+ // 浣跨敤 TreeMap 鑷姩鎸夐敭鎺掑簭
+ Map<String, Integer> monthlyData = records.stream()
+ .collect(Collectors.groupingBy(
+ r -> r.getSaleDate().format(monthFormatter),
+ TreeMap::new,
+ // 鍏抽敭淇敼锛氬鐞� saleQuantity 涓� null 鐨勬儏鍐碉紝榛樿鎸� 0 璁$畻
+ Collectors.summingInt(r -> {
+ BigDecimal quantity = r.getSaleQuantity();
+ return quantity != null ? quantity.intValue() : 0; // 涓夌洰杩愮畻绗﹀垽鏂�
+ })
+ ));
+
+ // 濉厖缂哄け鏈堜唤
+ YearMonth start = YearMonth.from(startDate);
+ YearMonth end = YearMonth.from(endDate);
+
+ for (YearMonth month = start; !month.isAfter(end); month = month.plusMonths(1)) {
+ String monthKey = month.format(monthFormatter);
+ monthlyData.putIfAbsent(monthKey, 0);
+ }
+
+ return monthlyData;
+ }
+
+ @Override
+ public Map<String, Object> selectAllInfo() {
+ Map<String, Object> result = new LinkedHashMap<>();
+
+ //钀ユ敹閲戦
+ LocalDate today = LocalDate.now();
+ LocalDate yesterday = today.minusDays(1);
+
+ BigDecimal revenueAmount;
+ List<SalesRecord> salesRecords = salesRecordMapper.selectList(null);
+ revenueAmount = salesRecords.stream()
+ .map(SalesRecord::getTotalAmount)
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
+
+ //浠婃棩钀ユ敹
+ BigDecimal todayRevenue = salesRecords.stream()
+ .filter(record -> today.equals(record.getSaleDate()))
+ .map(SalesRecord::getTotalAmount)
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
+
+ //鏄ㄦ棩钀ユ敹
+ BigDecimal yesterdayRevenue = salesRecords.stream()
+ .filter(record -> yesterday.equals(record.getSaleDate()))
+ .map(SalesRecord::getTotalAmount)
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
+
+ // 璁$畻澧為暱鐧惧垎姣�
+ BigDecimal increases = BigDecimal.ZERO;
+ String trend = "+";
+
+ if (yesterdayRevenue.compareTo(BigDecimal.ZERO) != 0) {
+ increases = todayRevenue.subtract(yesterdayRevenue)
+ .divide(yesterdayRevenue, 4, RoundingMode.HALF_UP)
+ .multiply(new BigDecimal(100));
+
+ if (increases.compareTo(BigDecimal.ZERO) > 0) {
+ trend = "+";
+ } else if (increases.compareTo(BigDecimal.ZERO) < 0) {
+ trend = "鈥�";
+ }
+ }
+
+ // 6. 鏍煎紡鍖栫櫨鍒嗘瘮鏄剧ず
+ DecimalFormat formatNo = new DecimalFormat("0.00%");
+ String changeRate = formatNo.format(increases.divide(new BigDecimal(100), 4, RoundingMode.HALF_UP));
+
+ //渚涘簲閲�
+ BigDecimal saleQuantity = salesRecords.stream()
+ .map(SalesRecord::getSaleQuantity)
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
+
+ //浠婃棩渚涘簲閲�
+ BigDecimal todaySaleQuantity = salesRecords.stream()
+ .filter(record -> today.equals(record.getSaleDate()))
+ .map(SalesRecord::getSaleQuantity)
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
+
+ //鏄ㄦ棩渚涘簲閲�
+ BigDecimal yesterdaySaleQuantity = salesRecords.stream()
+ .filter(record -> yesterday.equals(record.getSaleDate()))
+ .map(SalesRecord::getSaleQuantity)
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
+
+ // 璁$畻澧為暱鐧惧垎姣�
+ BigDecimal increasesQuantity = BigDecimal.ZERO;
+ String trendQuantity = "+";
+
+ if (yesterdaySaleQuantity.compareTo(BigDecimal.ZERO) != 0) {
+ increasesQuantity = todaySaleQuantity.subtract(yesterdaySaleQuantity)
+ .divide(yesterdaySaleQuantity, 4, RoundingMode.HALF_UP)
+ .multiply(new BigDecimal(100));
+
+ if (increasesQuantity.compareTo(BigDecimal.ZERO) > 0) {
+ trendQuantity = "+";
+ } else if (increasesQuantity.compareTo(BigDecimal.ZERO) < 0) {
+ trendQuantity = "鈥�";
+ }
+ }
+
+ // 鏍煎紡鍖栨暟閲忕櫨鍒嗘瘮鏄剧ず
+ DecimalFormat formatNoQuantity = new DecimalFormat("0.00%");
+ String saleQuantityRate = formatNoQuantity.format(increasesQuantity.divide(new BigDecimal(100), 4, RoundingMode.HALF_UP));
+
+ //钀ユ敹鍒嗗竷
+ //鑾峰彇鎵�鏈夌叅绉嶄俊鎭�(id鍜屽悕绉扮殑鏄犲皠)
+ Map<Long, String> coalIdToNameMap = coalInfoMapper.selectList(null).stream()
+ .collect(Collectors.toMap(
+ CoalInfo::getId,
+ CoalInfo::getCoal
+ ));
+
+ // 3. 鎸夌叅绉岻D缁熻鎬婚噾棰�
+ Map<Long, BigDecimal> revenueByCoalId = salesRecords.stream()
+ .collect(Collectors.groupingBy(
+ SalesRecord::getCoalId,
+ Collectors.reducing(
+ BigDecimal.ZERO,
+ SalesRecord::getTotalAmount,
+ BigDecimal::add
+ )
+ ));
+
+ // 鐓ょ閿�鍞垎甯冿紙鍗曠嫭浣滀负涓�涓瓙Map锛�
+ Map<String, BigDecimal> revenueDistribution = new LinkedHashMap<>();
+ coalIdToNameMap.forEach((id, name) -> {
+ BigDecimal amount = revenueByCoalId.getOrDefault(id, BigDecimal.ZERO)
+ .setScale(2, RoundingMode.HALF_UP);
+ if (amount.compareTo(BigDecimal.ZERO) > 0) {
+ revenueDistribution.put(name, amount);
+ }
+ });
+
+ //閿�鍞暟鎹�
+ // 鎸塩oalId鍒嗙粍骞跺悎骞舵暟閲忓拰閲戦
+ Map<Long, Map<String, Object>> resultMap = new LinkedHashMap<>();
+
+ for (SalesRecord record : salesRecords) {
+ Long coalId = record.getCoalId();
+
+ // 灏嗘暟閲忓拰閲戦杞崲涓築igDecimal
+ BigDecimal quantity = record.getInventoryQuantity();
+ BigDecimal amount = record.getTotalAmount();
+
+ if (resultMap.containsKey(coalId)) {
+ Map<String, Object> existing = resultMap.get(coalId);
+
+ // 鑾峰彇鐜版湁鐨凚igDecimal鍊�
+ BigDecimal existingQuantity = (BigDecimal) existing.get("inventoryQuantity");
+ BigDecimal existingAmount = (BigDecimal) existing.get("totalAmount");
+
+ // 浣跨敤BigDecimal杩涜鍔犳硶杩愮畻
+ existing.put("inventoryQuantity", existingQuantity.add(quantity));
+ existing.put("totalAmount", existingAmount.add(amount));
+ } else {
+ Map<String, Object> newRecord = new HashMap<>();
+ newRecord.put("coalId", coalId);
+ newRecord.put("inventoryQuantity", quantity);
+ newRecord.put("totalAmount", amount);
+ resultMap.put(coalId, newRecord);
+ }
+ }
+
+ // 3. 鑾峰彇鎵�鏈夋秹鍙婄殑coalId
+ List<Long> coalIds = new ArrayList<>(resultMap.keySet());
+
+ // 4. 鎵归噺鏌ヨ鐓ょ淇℃伅骞跺~鍏呭埌缁撴灉涓�
+ if (!coalIds.isEmpty()) {
+ List<CoalInfo> coalInfos = coalInfoMapper.selectBatchIds(coalIds);
+ for (CoalInfo coalInfo : coalInfos) {
+ Map<String, Object> record = resultMap.get(coalInfo.getId());
+ if (record != null) {
+ record.put("coalName", coalInfo.getCoal());
+ }
+ }
+ }
+
+ // 鏈�缁堢粨鏋滄槸涓�涓狶ist<Map>锛屾瘡涓狹ap鍖呭惈鍚堝苟鍚庣殑閿�鍞暟鎹拰瀵瑰簲鐨勭叅绉嶄俊鎭�
+ List<Map<String, Object>> results = new ArrayList<>(resultMap.values());
+ result.put("revenueAmount", revenueAmount.setScale(2, RoundingMode.HALF_UP));
+ result.put("changeRate", changeRate);
+ result.put("trend", trend);
+ result.put("saleQuantity", saleQuantity);
+ result.put("saleQuantityRate", saleQuantityRate);
+ result.put("trendQuantity", trendQuantity);
+ result.put("revenueDistribution", revenueDistribution);
+ result.put("salesResults", results);
+
+ return result;
+ }
}
diff --git a/main-business/src/main/java/com/ruoyi/business/vo/EquipmentManagementVo.java b/main-business/src/main/java/com/ruoyi/business/vo/EquipmentManagementVo.java
new file mode 100644
index 0000000..3ec641c
--- /dev/null
+++ b/main-business/src/main/java/com/ruoyi/business/vo/EquipmentManagementVo.java
@@ -0,0 +1,13 @@
+package com.ruoyi.business.vo;
+
+import lombok.Data;
+
+@Data
+public class EquipmentManagementVo {
+
+ private Long id; //璁惧id
+
+ private String equipmentName; //璁惧鍚嶇О
+
+ private Integer quantity; //鏁伴噺
+}
diff --git a/main-business/src/main/resources/db/migration/postgresql/V20250701142700__create_table_equipment_management.sql b/main-business/src/main/resources/db/migration/postgresql/V20250701142700__create_table_equipment_management.sql
index 0abb2b1..a682429 100644
--- a/main-business/src/main/resources/db/migration/postgresql/V20250701142700__create_table_equipment_management.sql
+++ b/main-business/src/main/resources/db/migration/postgresql/V20250701142700__create_table_equipment_management.sql
@@ -3,7 +3,7 @@
CREATE TABLE equipment_management
(
id BIGSERIAL PRIMARY KEY, -- 涓婚敭 ID
- equipment_id VARCHAR(50) NOT NULL, -- 璁惧缂栧彿
+ equipment_no VARCHAR(50) NOT NULL, -- 璁惧缂栧彿
equipment_name VARCHAR(100) NOT NULL, -- 璁惧鍚嶇О
quantity INT NOT NULL DEFAULT 0, -- 鏁伴噺
specification VARCHAR(50) NOT NULL, -- 瑙勬牸鍨嬪彿
@@ -27,7 +27,7 @@
COMMENT
ON COLUMN equipment_management.id IS ' 涓婚敭 ID';
COMMENT
-ON COLUMN equipment_management.equipment_id IS ' 璁惧缂栧彿 ';
+ON COLUMN equipment_management.equipment_no IS ' 璁惧缂栧彿 ';
COMMENT
ON COLUMN equipment_management.equipment_name IS ' 璁惧鍚嶇О ';
COMMENT
diff --git a/main-business/src/main/resources/db/migration/postgresql/V20250707155600__create_table_equipment_usage_record.sql b/main-business/src/main/resources/db/migration/postgresql/V20250707155600__create_table_equipment_usage_record.sql
new file mode 100644
index 0000000..eb2446d
--- /dev/null
+++ b/main-business/src/main/resources/db/migration/postgresql/V20250707155600__create_table_equipment_usage_record.sql
@@ -0,0 +1,39 @@
+-- 鍒涘缓璁惧浣跨敤璁板綍琛� equipment_usage_record
+CREATE TABLE equipment_usage_record
+(
+id BIGSERIAL PRIMARY KEY, -- 涓婚敭ID锛岃嚜鍔ㄩ�掑
+ equipment_id BIGINT NOT NULL, -- 璁惧ID锛屽叧鑱旇澶囦俊鎭〃锛屼笉鍏佽涓虹┖
+ usage_quantity INT NOT NULL, -- 浣跨敤鏁伴噺锛屼笉鍏佽涓虹┖
+ user_id BIGINT NOT NULL, -- 浣跨敤浜篒D锛屽叧鑱旂敤鎴疯〃锛屼笉鍏佽涓虹┖
+ department_id BIGINT , -- 閮ㄩ棬ID锛屽叧鑱旈儴闂ㄨ〃锛屼笉鍏佽涓虹┖
+ equipment_status VARCHAR(50) NOT NULL, -- 璁惧鐘舵�侊紙濡傦細姝e父銆佹晠闅溿�佺淮淇腑锛夛紝涓嶅厑璁镐负绌�
+ usage_start_time TIMESTAMP NOT NULL, -- 浣跨敤寮�濮嬫椂闂达紝涓嶅厑璁镐负绌�
+ usage_end_time TIMESTAMP, -- 浣跨敤缁撴潫鏃堕棿锛屽彲涓虹┖锛堟湭褰掕繕鏃讹級
+ remarks VARCHAR(1000), -- 澶囨敞淇℃伅锛屽彲涓虹┖
+
+ deleted INT NOT NULL DEFAULT 0, -- 杞垹闄ゆ爣蹇楋細0=鏈垹闄わ紝1=宸插垹闄�
+ create_by VARCHAR(255), -- 鍒涘缓浜虹敤鎴峰悕
+ create_time TIMESTAMP WITHOUT TIME ZONE, -- 鍒涘缓鏃堕棿锛岄粯璁ゅ綋鍓嶆椂闂�
+ update_by VARCHAR(255), -- 鏈�鍚庢洿鏂颁汉鐢ㄦ埛鍚�
+ update_time TIMESTAMP WITHOUT TIME ZONE -- 鏈�鍚庢洿鏂版椂闂�
+);
+
+-- 涓鸿〃娣诲姞娉ㄩ噴
+COMMENT ON TABLE equipment_usage_record IS '璁惧浣跨敤璁板綍琛�';
+
+-- 涓哄瓧娈垫坊鍔犳敞閲�
+COMMENT ON COLUMN equipment_usage_record.id IS '涓婚敭ID';
+COMMENT ON COLUMN equipment_usage_record.equipment_id IS '璁惧ID';
+COMMENT ON COLUMN equipment_usage_record.usage_quantity IS '浣跨敤鏁伴噺';
+COMMENT ON COLUMN equipment_usage_record.user_id IS '浣跨敤浜篒D';
+COMMENT ON COLUMN equipment_usage_record.department_id IS '閮ㄩ棬ID';
+COMMENT ON COLUMN equipment_usage_record.equipment_status IS '璁惧鐘舵�侊紙姝e父/鏁呴殰/缁翠慨涓級';
+COMMENT ON COLUMN equipment_usage_record.usage_start_time IS '浣跨敤寮�濮嬫椂闂�';
+COMMENT ON COLUMN equipment_usage_record.usage_end_time IS '浣跨敤缁撴潫鏃堕棿';
+COMMENT ON COLUMN equipment_usage_record.remarks IS '澶囨敞淇℃伅';
+
+COMMENT ON COLUMN equipment_usage_record.deleted IS '杞垹闄ゆ爣蹇楋紝0=鏈垹闄わ紝1=宸插垹闄�';
+COMMENT ON COLUMN equipment_usage_record.create_by IS '鍒涘缓璇ヨ褰曠殑鐢ㄦ埛';
+COMMENT ON COLUMN equipment_usage_record.create_time IS '璁板綍鍒涘缓鏃堕棿';
+COMMENT ON COLUMN equipment_usage_record.update_by IS '鏈�鍚庝慨鏀硅璁板綍鐨勭敤鎴�';
+COMMENT ON COLUMN equipment_usage_record.update_time IS '璁板綍鏈�鍚庢洿鏂版椂闂�';
\ No newline at end of file
diff --git a/main-business/src/main/resources/mapper/EquipmentUsageRecordMapper.xml b/main-business/src/main/resources/mapper/EquipmentUsageRecordMapper.xml
new file mode 100644
index 0000000..a0dc897
--- /dev/null
+++ b/main-business/src/main/resources/mapper/EquipmentUsageRecordMapper.xml
@@ -0,0 +1,33 @@
+<?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="com.ruoyi.business.mapper.EquipmentUsageRecordMapper">
+
+ <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 -->
+ <resultMap id="BaseResultMap" type="com.ruoyi.business.entity.EquipmentUsageRecord">
+ <id column="id" property="id" />
+ <result column="deleted" property="deleted" />
+ <result column="create_by" property="createBy" />
+ <result column="create_time" property="createTime" />
+ <result column="update_by" property="updateBy" />
+ <result column="update_time" property="updateTime" />
+ <result column="equipment_id" property="equipmentId" />
+ <result column="usage_quantity" property="usageQuantity" />
+ <result column="user_id" property="userId" />
+ <result column="department_id" property="departmentId" />
+ <result column="equipment_status" property="equipmentStatus" />
+ <result column="usage_start_time" property="usageStartTime" />
+ <result column="usage_end_time" property="usageEndTime" />
+ <result column="remarks" property="remarks" />
+ </resultMap>
+
+ <!-- 閫氱敤鏌ヨ缁撴灉鍒� -->
+ <sql id="Base_Column_List">
+ deleted,
+ create_by,
+ create_time,
+ update_by,
+ update_time,
+ id, equipment_id, usage_quantity, user_id, department_id, equipment_status, usage_start_time, usage_end_time, remarks
+ </sql>
+
+</mapper>
\ No newline at end of file
diff --git a/main-business/src/main/resources/mapper/SalesRecordMapper.xml b/main-business/src/main/resources/mapper/SalesRecordMapper.xml
index d284f8a..3eb8495 100644
--- a/main-business/src/main/resources/mapper/SalesRecordMapper.xml
+++ b/main-business/src/main/resources/mapper/SalesRecordMapper.xml
@@ -14,7 +14,6 @@
<result column="customer_id" property="customerId" />
<result column="customer" property="customer" />
<result column="coal_id" property="coalId" />
- <result column="coal" property="coal" />
<result column="price_including_tax" property="priceIncludingTax" />
<result column="inventory_quantity" property="inventoryQuantity" />
<result column="unit" property="unit" />
@@ -39,5 +38,18 @@
deleted,
id, sale_date, customer_id, customer, coal_id, coal, price_including_tax, inventory_quantity, unit, sale_quantity, sale_price, total_amount, tax_coal, tax_trans, gross_profit, net_profit, registrant_id, registrant, registration_date
</sql>
+ <select id="findByDateRange" resultType="com.ruoyi.business.entity.SalesRecord">
+ SELECT
+ sale_date,
+ SUM(sale_quantity) AS saleQuantity
+ FROM
+ sales_record
+ WHERE
+ sale_date BETWEEN #{startDate}::date AND #{endDate}::date
+ GROUP BY
+ sale_date
+ ORDER BY
+ sale_date ASC
+ </select>
</mapper>
\ No newline at end of file
--
Gitblit v1.9.3