浏览代码

采购订单导出

yzc 1 年之前
父节点
当前提交
ffe84da3c0

+ 6 - 0
hx-sale/src/main/java/com/fjhx/sale/controller/purchase/EhsdPurchaseController.java

@@ -11,6 +11,7 @@ import com.ruoyi.common.core.domain.BaseSelectDto;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 import java.util.Map;
 
@@ -105,4 +106,9 @@ public class EhsdPurchaseController {
         return ehsdPurchaseService.getNoInvoiceListBySupplyId(supplyId);
     }
 
+    @PostMapping("/excelExport")
+    public void excelExport(HttpServletResponse httpServletResponse, @RequestBody EhsdPurchaseSelectDto dto) {
+        ehsdPurchaseService.excelExport(httpServletResponse, dto);
+    }
+
 }

+ 49 - 0
hx-sale/src/main/java/com/fjhx/sale/entity/purchase/EhsdPurchaseExcelBo.java

@@ -0,0 +1,49 @@
+package com.fjhx.sale.entity.purchase;
+
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Getter
+@Setter
+@ExcelIgnoreUnannotated
+public class EhsdPurchaseExcelBo {
+    @ColumnWidth(15)
+    @ExcelProperty("业务公司")
+    private String companyName;
+    @ColumnWidth(15)
+    @ExcelProperty("采购单号")
+    private String code;
+    @ColumnWidth(15)
+    @ExcelProperty("供应商")
+    private String sellCorporationName;
+    @ColumnWidth(15)
+    @ExcelProperty("采购金额")
+    private BigDecimal amount;
+    @ColumnWidth(15)
+    @ExcelProperty("退货金额")
+    private BigDecimal backAmount;
+    @ColumnWidth(15)
+    @ExcelProperty("应付金额")
+    private BigDecimal payableAmount;
+    @ColumnWidth(15)
+    @ExcelProperty("已付款金额")
+    private BigDecimal sumPayMoney;
+    @ColumnWidth(15)
+    @ExcelProperty("采购状态")
+    private String status;
+    @ColumnWidth(15)
+    @ExcelProperty("付款状态")
+    private String payStatus;
+    @ColumnWidth(15)
+    @ExcelProperty("采购人")
+    private String userName;
+    @ColumnWidth(18)
+    @ExcelProperty("采购时间")
+    private Date createTime;
+}

+ 2 - 0
hx-sale/src/main/java/com/fjhx/sale/mapper/purchase/EhsdPurchaseMapper.java

@@ -26,6 +26,8 @@ public interface EhsdPurchaseMapper extends BaseMapper<EhsdPurchase> {
      */
     Page<EhsdPurchaseVo> getPage(@Param("page") Page<Object> page, @Param("ew") IWrapper<EhsdPurchase> wrapper);
 
+    List<EhsdPurchaseVo> getList(@Param("ew") IWrapper<EhsdPurchase> wrapper);
+
     boolean updatePurchaseId(Long id, Long newId, Long userId, Long oldPurchaseId);
 
     List<EhsdPurchaseProductVo> getProductPriceInfo(@Param("ew") IWrapper<Object> wrapper);

+ 3 - 2
hx-sale/src/main/java/com/fjhx/sale/service/purchase/EhsdPurchaseService.java

@@ -8,6 +8,7 @@ import com.fjhx.sale.entity.purchase.po.EhsdPurchase;
 import com.fjhx.sale.entity.purchase.vo.EhsdPurchaseVo;
 import com.ruoyi.common.core.service.BaseService;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 import java.util.Map;
 
@@ -75,8 +76,8 @@ public interface EhsdPurchaseService extends BaseService<EhsdPurchase> {
 
     /**
      * 更新到货状态
-     *
-     * @param id
      */
     void updateArrivalStatus(Long id);
+
+    void excelExport(HttpServletResponse httpServletResponse, EhsdPurchaseSelectDto dto);
 }

+ 43 - 12
hx-sale/src/main/java/com/fjhx/sale/service/purchase/impl/EhsdPurchaseServiceImpl.java

@@ -20,6 +20,7 @@ import com.fjhx.common.enums.FlowStatusEnum1;
 import com.fjhx.common.service.corporation.CorporationService;
 import com.fjhx.common.service.documentary.GetDocumentaryBusinessTemplate;
 import com.fjhx.common.utils.Assert;
+import com.fjhx.common.utils.excel.util.ExcelUtil;
 import com.fjhx.flow.entity.flow.po.FlowExample;
 import com.fjhx.flow.enums.FlowStatusEnum;
 import com.fjhx.flow.service.flow.FlowExampleService;
@@ -51,6 +52,7 @@ import com.fjhx.sale.entity.contract.vo.ContractBudgetVo;
 import com.fjhx.sale.entity.pack.po.PackDetail;
 import com.fjhx.sale.entity.pack.po.PackDetailProduct;
 import com.fjhx.sale.entity.pack.vo.PackDetailProductVo;
+import com.fjhx.sale.entity.purchase.EhsdPurchaseExcelBo;
 import com.fjhx.sale.entity.purchase.dto.EhsdPurchaseDto;
 import com.fjhx.sale.entity.purchase.dto.EhsdPurchaseSelectDto;
 import com.fjhx.sale.entity.purchase.po.*;
@@ -90,6 +92,7 @@ import org.apache.commons.collections4.MapUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.servlet.http.HttpServletResponse;
 import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -158,15 +161,7 @@ public class EhsdPurchaseServiceImpl extends ServiceImpl<EhsdPurchaseMapper, Ehs
     @Autowired
     private WarehouseService warehouseService;
 
-    /**
-     * 分页
-     *
-     * @param dto
-     * @return
-     */
-    @Override
-    public Page<EhsdPurchaseVo> getPage(EhsdPurchaseSelectDto dto) {
-        IWrapper<EhsdPurchase> wrapper = getWrapper();
+    private void setPageWrapper(EhsdPurchaseSelectDto dto, IWrapper<EhsdPurchase> wrapper) {
         if (ObjectUtils.isNotEmpty(dto.getStatus())) {
             wrapper.eq("t1", EhsdPurchase::getStatus, dto.getStatus());
         }
@@ -191,11 +186,11 @@ public class EhsdPurchaseServiceImpl extends ServiceImpl<EhsdPurchaseMapper, Ehs
 
         //过滤作废的数据
         wrapper.ne("t1", EhsdPurchase::getStatus, FlowStatusEnum1.CANCELLATION.getKey());
+    }
 
-        Page<EhsdPurchaseVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
-        List<EhsdPurchaseVo> records = page.getRecords();
+    private void setPageInfo(List<EhsdPurchaseVo> records) {
         if (ObjectUtils.isEmpty(records)) {
-            return page;
+            return;
         }
         //  赋值流程id
         flowExampleService.setFlowId(records, EhsdPurchaseVo::setFlowId);
@@ -235,6 +230,22 @@ public class EhsdPurchaseServiceImpl extends ServiceImpl<EhsdPurchaseMapper, Ehs
             //赋值生产公司名称
             record.setCompanyName(companyNameMap.get(record.getCompanyId()));
         }
+    }
+
+    /**
+     * 分页
+     */
+    @Override
+    public Page<EhsdPurchaseVo> getPage(EhsdPurchaseSelectDto dto) {
+        IWrapper<EhsdPurchase> wrapper = getWrapper();
+
+        setPageWrapper(dto, wrapper);
+
+
+        Page<EhsdPurchaseVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
+        List<EhsdPurchaseVo> records = page.getRecords();
+
+        setPageInfo(records);
 
         return page;
     }
@@ -799,4 +810,24 @@ public class EhsdPurchaseServiceImpl extends ServiceImpl<EhsdPurchaseMapper, Ehs
         );
     }
 
+    @Override
+    public void excelExport(HttpServletResponse httpServletResponse, EhsdPurchaseSelectDto dto) {
+        IWrapper<EhsdPurchase> wrapper = getWrapper();
+        setPageWrapper(dto, wrapper);
+        List<EhsdPurchaseVo> list = baseMapper.getList(wrapper);
+        setPageInfo(list);
+
+        Map<Integer, String> flowStatusMap = FlowStatusEnum1.getMap();
+
+        List<EhsdPurchaseExcelBo> ehsdPurchaseExcelBos = BeanUtil.copyToList(list, EhsdPurchaseExcelBo.class);
+        for (EhsdPurchaseExcelBo bo : ehsdPurchaseExcelBos) {
+            //审批状态
+            bo.setStatus(flowStatusMap.get(Integer.valueOf(bo.getStatus())));
+            //付款状态
+            bo.setPayStatus("0".equals(bo.getPayStatus()) ? "未付款" : "10".equals(bo.getPayStatus()) ? "部分付款" : "已付款");
+        }
+
+        ExcelUtil.export(httpServletResponse, ehsdPurchaseExcelBos, EhsdPurchaseExcelBo.class);
+    }
+
 }

+ 9 - 2
hx-sale/src/main/resources/mapper/purchase/EhsdPurchaseMapper.xml

@@ -1,12 +1,19 @@
 <?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.fjhx.sale.mapper.purchase.EhsdPurchaseMapper">
-    <select id="getPage" resultType="com.fjhx.sale.entity.purchase.vo.EhsdPurchaseVo">
+    <sql id="list">
         SELECT t1.*,
                t2.`name` AS supplyName
         FROM ehsd_purchase t1
                  LEFT JOIN supplier_info t2 ON t1.sell_corporation_id = t2.id
-            ${ew.customSqlSegment}
+    </sql>
+    <select id="getPage" resultType="com.fjhx.sale.entity.purchase.vo.EhsdPurchaseVo">
+        <include refid="list"/>
+        ${ew.customSqlSegment}
+    </select>
+    <select id="getList" resultType="com.fjhx.sale.entity.purchase.vo.EhsdPurchaseVo">
+        <include refid="list"/>
+        ${ew.customSqlSegment}
     </select>
 
     <update id="updatePurchaseId">