浏览代码

对账报表

24282 1 年之前
父节点
当前提交
a69cdfb0b7

+ 30 - 4
sd-business/src/main/java/com/sd/business/controller/statement/StatementOfAccountMergeController.java

@@ -1,6 +1,8 @@
 package com.sd.business.controller.statement;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.common.annotation.NonInterception;
+import com.sd.business.entity.statement.dto.ExportDocumentDto;
 import com.sd.business.entity.statement.dto.GetDocumentDto;
 import com.sd.business.entity.statement.dto.StatementOfAccountMergePageDto;
 import com.sd.business.entity.statement.vo.DocumentByBomVo;
@@ -10,10 +12,7 @@ import com.sd.business.entity.statement.vo.StatementOfAccountMergePageVo;
 import com.sd.business.service.statement.StatementOfAccountMergeService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 
@@ -65,4 +64,31 @@ public class StatementOfAccountMergeController {
         return statementOfAccountMergeService.getDocumentByOrder(dto);
     }
 
+    /**
+     * 导出sku对账单
+     */
+    @NonInterception
+    @GetMapping("/exportDocumentBySku")
+    public void exportDocumentBySku(@Validated ExportDocumentDto dto) {
+        statementOfAccountMergeService.export(dto, 1);
+    }
+
+    /**
+     * 导出bom对账单
+     */
+    @NonInterception
+    @GetMapping("/exportDocumentByBom")
+    public void exportDocumentByBom(@Validated ExportDocumentDto dto) {
+        statementOfAccountMergeService.export(dto, 2);
+    }
+
+    /**
+     * 导出订单对账单
+     */
+    @NonInterception
+    @GetMapping("/exportDocumentByOrder")
+    public void exportDocumentByOrder(@Validated ExportDocumentDto dto) {
+        statementOfAccountMergeService.export(dto, 3);
+    }
+
 }

+ 33 - 0
sd-business/src/main/java/com/sd/business/entity/statement/dto/ExportDocumentDto.java

@@ -0,0 +1,33 @@
+package com.sd.business.entity.statement.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotBlank;
+
+@Getter
+@Setter
+public class ExportDocumentDto {
+
+    /**
+     * 对账单id集合
+     */
+    @NotBlank(message = "对账单id集合不能为空")
+    private String idGroupConcat;
+
+    /**
+     * 部门名称
+     */
+    private String departmentName;
+
+    /**
+     * 开始时间
+     */
+    private String beginDate;
+
+    /**
+     * 结束时间
+     */
+    private String endDate;
+
+}

+ 9 - 0
sd-business/src/main/java/com/sd/business/service/statement/StatementOfAccountMergeService.java

@@ -1,6 +1,7 @@
 package com.sd.business.service.statement;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.sd.business.entity.statement.dto.ExportDocumentDto;
 import com.sd.business.entity.statement.dto.GetDocumentDto;
 import com.sd.business.entity.statement.dto.StatementOfAccountMergePageDto;
 import com.sd.business.entity.statement.vo.DocumentByBomVo;
@@ -40,4 +41,12 @@ public interface StatementOfAccountMergeService {
      */
     List<DocumentByOrderVo> getDocumentByOrder(GetDocumentDto dto);
 
+    /**
+     * 导出
+     *
+     * @param dto  导出参数
+     * @param type 1sku 2bom 3订单
+     */
+    void export(ExportDocumentDto dto, int type);
+
 }

+ 33 - 0
sd-business/src/main/java/com/sd/business/service/statement/impl/StatementOfAccountMergeServiceImpl.java

@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.PageUtils;
 import com.sd.business.entity.order.po.OrderInfo;
+import com.sd.business.entity.statement.dto.ExportDocumentDto;
 import com.sd.business.entity.statement.dto.GetDocumentDto;
 import com.sd.business.entity.statement.dto.StatementOfAccountMergePageDto;
 import com.sd.business.entity.statement.po.StatementOfAccount;
@@ -20,6 +21,7 @@ import com.sd.business.entity.statement.vo.DocumentBySkuVo;
 import com.sd.business.entity.statement.vo.StatementOfAccountMergePageVo;
 import com.sd.business.service.department.DepartmentService;
 import com.sd.business.service.order.OrderService;
+import com.sd.business.service.statement.StatementOfAccountExportService;
 import com.sd.business.service.statement.StatementOfAccountMergeService;
 import com.sd.business.service.statement.StatementOfAccountService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -52,6 +54,9 @@ public class StatementOfAccountMergeServiceImpl implements StatementOfAccountMer
     @Autowired
     private OrderService orderService;
 
+    @Autowired
+    private StatementOfAccountExportService statementOfAccountExportService;
+
 
     @Override
     public Page<StatementOfAccountMergePageVo> getPage(StatementOfAccountMergePageDto dto) {
@@ -170,6 +175,34 @@ public class StatementOfAccountMergeServiceImpl implements StatementOfAccountMer
         return statementOfAccountService.getDocumentByOrder(getIdList(dto));
     }
 
+    @Override
+    public void export(ExportDocumentDto dto, int type) {
+
+        List<Long> idList = Arrays.stream(dto.getIdGroupConcat().split(","))
+                .map(Convert::toLong)
+                .filter(Objects::nonNull)
+                .distinct()
+                .collect(Collectors.toList());
+
+        String departmentName = dto.getDepartmentName();
+        String beginDate = dto.getBeginDate();
+        String endDate = dto.getEndDate();
+
+        switch (type) {
+            case 1:
+                statementOfAccountExportService.exportDocumentBySku(idList, departmentName, beginDate, endDate);
+                break;
+            case 2:
+                statementOfAccountExportService.exportDocumentByBom(idList, departmentName, beginDate, endDate);
+                break;
+            case 3:
+                statementOfAccountExportService.exportDocumentByOrder(idList, departmentName, beginDate, endDate);
+                break;
+            default:
+                throw new ServiceException("未知对账单类型");
+        }
+    }
+
     private List<Long> getIdList(GetDocumentDto dto) {
 
         String idGroupConcat = dto.getIdGroupConcat();