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 | 128 +++++++++++++++++++++++++++---------------
1 files changed, 82 insertions(+), 46 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/LocDetlController.java b/src/main/java/com/zy/asrs/controller/LocDetlController.java
index edfb2a5..ad44284 100644
--- a/src/main/java/com/zy/asrs/controller/LocDetlController.java
+++ b/src/main/java/com/zy/asrs/controller/LocDetlController.java
@@ -12,10 +12,12 @@
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.common.R;
+import com.zy.asrs.entity.FrozenParam;
import com.zy.asrs.entity.LocDetl;
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;
@@ -25,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;
@@ -252,6 +254,26 @@
return R.ok();
}
+ @PostMapping(value = "/locDetl/frozenInventory")
+ @ManagerAuth(memo = "搴撳瓨鍐荤粨")
+ public R frozen(@RequestBody List<FrozenParam> param){
+ if (param.size() == 0) {
+ return R.parse("鏈敹鍒版暟鎹�");
+ }
+
+ return locDetlService.frozenInventory(param);
+ }
+
+ @PostMapping(value = "/locDetl/unfreezeInventory")
+ @ManagerAuth(memo = "搴撳瓨瑙e喕")
+ public R unfreeze(@RequestBody List<FrozenParam> param){
+ if (param.size() == 0) {
+ return R.parse("鏈敹鍒版暟鎹�");
+ }
+
+ return locDetlService.unfreezeInventory(param);
+ }
+
@RequestMapping(value = "/locDetl/export/auth")
@ManagerAuth(memo = "搴撲綅鏄庣粏瀵煎嚭")
public R export(@RequestBody JSONObject param){
@@ -275,42 +297,28 @@
.where("loc_no like '" + row + "%'");
}
List<LocDetl> list = locDetlService.selectList(wrapper);
- List<AbnormalLocDetlParam> result = new ArrayList<>();
-
- Page<LocDetl> groupLocDetl = locDetlService.getStockStatis2(toPage(1, 10000, param, LocDetl.class));
- for (LocDetl locDetl : groupLocDetl.getRecords()) {
- 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());
-
-// 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(abnormalLocDetlParam);
- } else if (!Cools.isEmpty(mat.getStoreMin()) && locDetl.getAnfme() < mat.getStoreMin()) {
- result.add(abnormalLocDetlParam);
- }
- }
+ List<LocDetl> result = new ArrayList<>();
+ for (LocDetl locDetl : list) {
+ 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
@@ -399,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