From 51889b97a85b070cbb80a5bb2893149c80448d5d Mon Sep 17 00:00:00 2001
From: 1 <1>
Date: 星期二, 30 十二月 2025 16:31:15 +0800
Subject: [PATCH] #导出优化
---
src/main/java/com/zy/asrs/controller/LocDetlController.java | 113 +++++++++++++++++++++++++++++---------------------------
1 files changed, 59 insertions(+), 54 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/LocDetlController.java b/src/main/java/com/zy/asrs/controller/LocDetlController.java
index c71cc64..ad44284 100644
--- a/src/main/java/com/zy/asrs/controller/LocDetlController.java
+++ b/src/main/java/com/zy/asrs/controller/LocDetlController.java
@@ -17,6 +17,7 @@
import com.zy.asrs.entity.LocOwner;
import com.zy.asrs.entity.Mat;
import com.zy.asrs.entity.param.AbnormalLocDetlParam;
+import com.zy.asrs.entity.param.ExportParam;
import com.zy.asrs.entity.result.LocDetlAll;
import com.zy.asrs.entity.result.LocDetlDTO;
import com.zy.asrs.mapper.LocDetlMapper;
@@ -26,7 +27,7 @@
import com.zy.common.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
-
+import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
@@ -297,51 +298,27 @@
}
List<LocDetl> list = locDetlService.selectList(wrapper);
List<LocDetl> result = new ArrayList<>();
-
- Page<LocDetl> groupLocDetl = locDetlService.getStockStatis2(toPage(1, 10000, param, LocDetl.class));
-// for (LocDetl locDetl : groupLocDetl.getRecords()) {
for (LocDetl locDetl : list) {
-// AbnormalLocDetlParam abnormalLocDetlParam = new AbnormalLocDetlParam();
-// Mat mat = matService.selectOne(new EntityWrapper<Mat>()
-// .eq("matnr", locDetl.getMatnr()));
-// if (Cools.isEmpty(mat)) {
-// continue;
-// }
-// if (!Cools.isEmpty(mat.getStoreMax()) || !Cools.isEmpty(mat.getStoreMin())) {
-// abnormalLocDetlParam.setStoreMax(mat.getStoreMax());
-// abnormalLocDetlParam.setStoreMaxDate(mat.getStoreMaxDate());
-// abnormalLocDetlParam.setStoreMin(mat.getStoreMin());
-// abnormalLocDetlParam.setAnfme(locDetl.getAnfme());//鏁伴噺
-// abnormalLocDetlParam.setMaktx(mat.getMaktx());//鍟嗗搧鍚嶇О
-// abnormalLocDetlParam.setMatnr(mat.getMatnr());//鍟嗗搧缂栧彿
-// abnormalLocDetlParam.setSpecs(mat.getSpecs());
-// abnormalLocDetlParam.setBatch(locDetl.getBatch());
-// abnormalLocDetlParam.setLocNo(locDetl.getLocNo());//搴撲綅鍙�
-// abnormalLocDetlParam.setZpallet(locDetl.getZpallet());//鎵樼洏鏉$爜
-// abnormalLocDetlParam.setBarcode(locDetl.getStandby2());//鏉$爜upc
-// abnormalLocDetlParam.setUnit(locDetl.getStandby1());//瀹㈡埛po
-// abnormalLocDetlParam.setSku(locDetl.getSku());//瀹㈡埛sku
-// abnormalLocDetlParam.setSupp(locDetl.getSupp());//渚涘簲鍟�
-// abnormalLocDetlParam.setManu(locDetl.getBoxType1());//璐т富
-// abnormalLocDetlParam.setOrderNo(locDetl.getOrderNo());//閲囪喘鍗曞彿
-// abnormalLocDetlParam.setMemo(locDetl.getMemo());//澶囨敞
-// abnormalLocDetlParam.setModiTime(locDetl.getModiTime());//淇敼鏃堕棿
-// SimpleDateFormat simple = new SimpleDateFormat("yyyyMMdd");
-// Date maxDate = simple.parse(locDetl.getBatch());
-// long time = maxDate.getTime();
-// Date now = new Date();
-// long time1 = now.getTime();
-// abnormalLocDetlParam.setNowTime((int) ((time1 - time) / (1000 * 60 * 60 * 24)));
-
-// if (!Cools.isEmpty(mat.getStoreMax()) && locDetl.getAnfme() > mat.getStoreMax()) {
- result.add(locDetl);
-// } else if (!Cools.isEmpty(mat.getStoreMin()) && locDetl.getAnfme() < mat.getStoreMin()) {
-// result.add(abnormalLocDetlParam);
-// }
-// }
+ result.add(locDetl);
}
return R.ok(exportSupport(result, fields));
}
+//
+// @RequestMapping(value = "/locDetl/statis/export/auth")
+// @ManagerAuth(memo = "搴撳瓨缁熻瀵煎嚭锛堝綋鍓嶇瓫閫夋潯浠讹級")
+// public R statisExport(@RequestBody JSONObject json) {
+// // 鑾峰彇鍓嶇浼犵殑瀛楁鍒楄〃
+// List<String> fields = JSONObject.parseArray(json.getJSONArray("fields").toJSONString(), String.class);
+//
+// // 鑾峰彇鎼滅储鍙傛暟锛岃浆鎴� DTO
+// ExportParam param = json.getJSONObject("locDetl").toJavaObject(ExportParam.class);
+//
+// // 鐩存帴璋冪敤 Mapper 鏂规硶锛堝叏閲忔暟鎹紝涓嶅垎椤碉級
+// List<LocDetl> list = locDetlMapper.selectStatisForExport(param);
+//
+// // 瀵煎嚭
+// return R.ok(exportSupport(list, fields));
+// }
@RequestMapping(value = "/locDetl/selectOwner/list/auth")
@ManagerAuth
@@ -430,29 +407,57 @@
}
return R.ok().add(stockStatis);
}
+ @RequestMapping(value = "/locDetl/statis/export/auth")
+ @ManagerAuth(memo = "搴撳瓨缁熻瀵煎嚭")
+ public R statisExport(@RequestBody JSONObject json) {
+ // 鑾峰彇鎼滅储鍙傛暟
+ ExportParam param = json.getJSONObject("locDetl").toJavaObject(ExportParam.class);
- @Autowired
- private LocDetlMapper LocDetlMapper;
+ // 鏌ヨ鍏ㄩ噺姹囨�绘暟鎹�
+ List<LocDetl> list = locDetlMapper.selectStockStatisExport(param);
- @RequestMapping(value = "/locDetl/statis/export")
-// @ManagerAuth
- public void statisExport(HttpServletResponse response) throws IOException {
- List<LocDetl> excel = LocDetlMapper.getStockStatisExcel();
- for (LocDetl locDetl : excel) {
+ // 鍚屾鐗╂枡淇℃伅锛堜繚鎸佸師鏈夐�昏緫锛�
+ for (LocDetl locDetl : list) {
Mat mat = matService.selectByMatnr(locDetl.getMatnr());
if (mat != null) {
locDetl.sync(mat);
}
}
+
+ // 鐩存帴杩斿洖 JSON 鏁版嵁鏁扮粍
+ return R.ok(list); // 鎴� R.ok().put("data", list)
+ }
+ private void exportExcel(HttpServletResponse response, List<LocDetl> list, List<String> fields, String fileName) throws Exception {
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
- String fileName = URLEncoder.encode("搴撳瓨鏄庣粏缁熻鎶ヨ〃", "UTF-8");
- response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
+ response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(fileName + ".xlsx", "UTF-8"));
+
EasyExcel.write(response.getOutputStream(), LocDetl.class)
- .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
- .sheet("琛�1")
- .doWrite(excel);
+ .sheet("搴撳瓨缁熻")
+ .doWrite(list);
}
+ @Autowired
+ private LocDetlMapper LocDetlMapper;
+
+// @RequestMapping(value = "/locDetl/statis/export")
+//// @ManagerAuth
+// public void statisExport(HttpServletResponse response) throws IOException {
+// List<LocDetl> excel = LocDetlMapper.getStockStatisExcel();
+// for (LocDetl locDetl : excel) {
+// Mat mat = matService.selectByMatnr(locDetl.getMatnr());
+// if (mat != null) {
+// locDetl.sync(mat);
+// }
+// }
+// response.setContentType("application/vnd.ms-excel");
+// response.setCharacterEncoding("utf-8");
+// String fileName = URLEncoder.encode("搴撳瓨鏄庣粏缁熻鎶ヨ〃", "UTF-8");
+// response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
+// EasyExcel.write(response.getOutputStream(), LocDetl.class)
+// .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
+// .sheet("琛�1")
+// .doWrite(excel);
+// }
/**
* 鑾峰彇搴撳瓨鎬绘暟
--
Gitblit v1.9.1