From 761ca93d047dd672f78536cc6a8cfbbafd8b7a5f Mon Sep 17 00:00:00 2001 From: psh Date: Mon, 12 Aug 2024 17:47:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=93=E5=AD=98=E8=AE=B0=E5=BD=95=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MaterialDataController.java | 15 ++++++- .../sch/data/service/MaterialDataService.java | 2 + .../service/impl/MaterialDataServiceImpl.java | 39 +++++++++++++++++-- .../src/views/wms/sch/data/index.vue | 2 +- 4 files changed, 52 insertions(+), 6 deletions(-) diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/controller/MaterialDataController.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/controller/MaterialDataController.java index b77c4e9..7d36581 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/controller/MaterialDataController.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/controller/MaterialDataController.java @@ -3,6 +3,7 @@ package org.nl.wms.sch.data.controller; import org.nl.common.base.TableDataInfo; import org.nl.common.domain.query.PageQuery; +import org.nl.common.logging.annotation.Log; import org.nl.wms.sch.data.service.MaterialDataService; import org.nl.wms.sch.data.service.dto.MaterialDataDto; import org.nl.wms.sch.data.service.dto.MaterialDataRequest; @@ -14,9 +15,11 @@ import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import io.swagger.annotations.*; + import java.io.IOException; import javax.servlet.http.HttpServletResponse; import java.util.Map; + import lombok.extern.slf4j.Slf4j; /** @@ -35,8 +38,16 @@ public class MaterialDataController { @GetMapping @ApiOperation("查询data") //@PreAuthorize("@el.check('materialData:list')") - public ResponseEntity query(MaterialDataRequest whereJson, PageQuery page){ - return new ResponseEntity<>(TableDataInfo.build(materialDataService.queryAll(whereJson,page)),HttpStatus.OK); + public ResponseEntity query(MaterialDataRequest whereJson, PageQuery page) { + return new ResponseEntity<>(TableDataInfo.build(materialDataService.queryAll(whereJson, page)), HttpStatus.OK); + } + + @Log("导出接口方法地址") + @ApiOperation("导出接口方法地址") + @GetMapping(value = "/download") + //@PreAuthorize("@el.check('Address:list')") + public void download(HttpServletResponse response, MaterialDataRequest whereJson, PageQuery page) throws IOException { + materialDataService.download(whereJson, page, response); } } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/MaterialDataService.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/MaterialDataService.java index e8a6c2d..53b1004 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/MaterialDataService.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/MaterialDataService.java @@ -30,5 +30,7 @@ public interface MaterialDataService extends IService { */ IPage queryAll(MaterialDataRequest whereJson, PageQuery pageable); + void download(MaterialDataRequest whereJson, PageQuery pageable, HttpServletResponse response) throws IOException; + } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/impl/MaterialDataServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/impl/MaterialDataServiceImpl.java index 866b74d..9b3c26f 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/impl/MaterialDataServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/data/service/impl/MaterialDataServiceImpl.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.RequiredArgsConstructor; import org.nl.common.domain.query.PageQuery; import org.nl.common.exception.BadRequestException; +import org.nl.common.utils.FileUtil; import org.nl.wms.sch.data.service.MaterialDataService; import org.nl.wms.sch.data.service.dao.mapper.MaterialDataMapper; import org.nl.wms.sch.data.service.dto.MaterialDataDto; @@ -16,15 +17,15 @@ import org.nl.wms.sch.material.service.dao.Material; import org.nl.wms.sch.material.service.dao.mapper.MaterialMapper; import org.nl.wms.sch.report.service.dto.ReportDto; import org.nl.wms.sch.report.service.dto.ReportQuery; +import org.nl.wms.sch.report.service.dto.YlDto; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.data.domain.Pageable; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.io.IOException; +import java.util.*; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; @@ -33,6 +34,8 @@ import com.alibaba.fastjson.JSONObject; import lombok.extern.slf4j.Slf4j; import cn.hutool.core.util.ObjectUtil; +import javax.servlet.http.HttpServletResponse; + /** * @description 服务实现 * @author psh @@ -53,4 +56,34 @@ public class MaterialDataServiceImpl extends ServiceImpl pages = new Page<>(pageQuery.getPage() + 1, pageQuery.getSize()); + materialDataMapper.set(); + pages = materialDataMapper.queryAll(pages, query); + List> list = new ArrayList<>(); + for(MaterialDataResponse materialDataResponse:pages.getRecords()){ + Map mp = new LinkedHashMap<>(); + mp.put("客户编码",materialDataResponse.getSupplierCode()); + mp.put("客户名称",materialDataResponse.getSupplierName()); + mp.put("物料编码",materialDataResponse.getProductName()); + mp.put("日期",materialDataResponse.getDate()); + mp.put("规格",materialDataResponse.getSpecification()); + mp.put("来料批次",materialDataResponse.getBatch()); + mp.put("棒源等级",materialDataResponse.getBarLevel()); + mp.put("昨日结存实际长度(mm)",materialDataResponse.getSc_length()); + mp.put("昨日结存实际重量(KG)",materialDataResponse.getSy_weight()); + mp.put("来料入库实际长度(mm)",materialDataResponse.getLl_length()); + mp.put("来料入库实际重量(KG)",materialDataResponse.getLl_weight()); + mp.put("领料批次",materialDataResponse.getPickingBatch()); + mp.put("生产领料实际长度(mm)",materialDataResponse.getSc_length()); + mp.put("生产领料实际重量(KG)",materialDataResponse.getSc_weight()); + mp.put("结存实际长度(mm)",materialDataResponse.getJc_length()); + mp.put("结存实际重量(KG)",materialDataResponse.getJc_weight()); + list.add(mp); + } + FileUtil.downloadExcel(list, response); + } + } diff --git a/lms/nladmin-ui/src/views/wms/sch/data/index.vue b/lms/nladmin-ui/src/views/wms/sch/data/index.vue index 009ea64..adc9696 100644 --- a/lms/nladmin-ui/src/views/wms/sch/data/index.vue +++ b/lms/nladmin-ui/src/views/wms/sch/data/index.vue @@ -126,7 +126,7 @@ export default { add: false, edit: false, del: false, - download: false, + download: true, reset: false }, query: {