24282 1 жил өмнө
parent
commit
10c40038a5

+ 9 - 0
sd-business/src/main/java/com/sd/business/controller/inventory/InventoryBackupController.java

@@ -3,6 +3,7 @@ package com.sd.business.controller.inventory;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.common.annotation.NonInterception;
 import com.sd.business.entity.inventory.dto.InventoryBackupSelectDto;
+import com.sd.business.entity.inventory.dto.InventorySelectDto;
 import com.sd.business.entity.inventory.vo.InventoryBackupVo;
 import com.sd.business.service.inventory.InventoryBackupService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -45,4 +46,12 @@ public class InventoryBackupController {
         inventoryBackupService.exportExcel(dto);
     }
 
+    /**
+     * 库存日期分组分页
+     */
+    @PostMapping("/groupPage")
+    public Page<InventoryBackupVo> groupPage(@RequestBody InventorySelectDto dto) {
+        return inventoryBackupService.groupPage(dto);
+    }
+
 }

+ 5 - 0
sd-business/src/main/java/com/sd/business/entity/inventory/vo/InventoryBackupVo.java

@@ -60,4 +60,9 @@ public class InventoryBackupVo extends InventoryBackup {
     @ExcelProperty(value = "总库存", index = 7)
     private BigDecimal totalQuantity;
 
+    /**
+     * 备份日期
+     */
+    private String backupDateStr;
+
 }

+ 6 - 0
sd-business/src/main/java/com/sd/business/service/inventory/InventoryBackupService.java

@@ -3,6 +3,7 @@ package com.sd.business.service.inventory;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.common.core.service.BaseService;
 import com.sd.business.entity.inventory.dto.InventoryBackupSelectDto;
+import com.sd.business.entity.inventory.dto.InventorySelectDto;
 import com.sd.business.entity.inventory.po.InventoryBackup;
 import com.sd.business.entity.inventory.vo.InventoryBackupVo;
 
@@ -27,4 +28,9 @@ public interface InventoryBackupService extends BaseService<InventoryBackup> {
      */
     void exportExcel(InventoryBackupSelectDto dto);
 
+    /**
+     * 库存日期分组分页
+     */
+    Page<InventoryBackupVo> groupPage(InventorySelectDto dto);
+
 }

+ 26 - 0
sd-business/src/main/java/com/sd/business/service/inventory/impl/InventoryBackupServiceImpl.java

@@ -7,6 +7,7 @@ import com.sd.business.entity.bom.po.Bom;
 import com.sd.business.entity.bom.po.BomSpec;
 import com.sd.business.entity.department.po.Department;
 import com.sd.business.entity.inventory.dto.InventoryBackupSelectDto;
+import com.sd.business.entity.inventory.dto.InventorySelectDto;
 import com.sd.business.entity.inventory.po.Inventory;
 import com.sd.business.entity.inventory.po.InventoryBackup;
 import com.sd.business.entity.inventory.vo.InventoryBackupVo;
@@ -84,4 +85,29 @@ public class InventoryBackupServiceImpl extends ServiceImpl<InventoryBackupMappe
         ExcelUtil.export(response, DateUtil.format(new Date(), "yyyy-MM-dd库存数据"), "库存数据", list, InventoryBackupVo.class);
     }
 
+    @Override
+    public Page<InventoryBackupVo> groupPage(InventorySelectDto dto) {
+
+        Page<InventoryBackupVo> page = Sql.create(InventoryBackupVo.class)
+                .select(InventoryBackup::getBackupDate)
+                .from(InventoryBackup.class)
+                .ge(InventoryBackup::getBackupDate, dto.getBeginTime())
+                .le(InventoryBackup::getBackupDate, dto.getEndTime())
+                .orderByDesc(InventoryBackup::getId)
+                .groupBy(InventoryBackup::getBackupDate)
+                .page(dto);
+
+        List<InventoryBackupVo> records = page.getRecords();
+        if (records.isEmpty()) {
+            return page;
+        }
+
+        for (InventoryBackupVo record : records) {
+            record.setBackupDateStr(DateUtil.format(record.getBackupDate(), "yyyy-MM-dd"));
+            record.setBackupDate(DateUtil.offsetDay(record.getBackupDate(), 1));
+        }
+
+        return page;
+    }
+
 }