From aa2d520a06c371e76ef26c78d426a01fca76a2fc Mon Sep 17 00:00:00 2001 From: zhangc <zc@123> Date: 星期五, 07 二月 2025 14:56:35 +0800 Subject: [PATCH] 1 --- src/main/java/com/zy/asrs/controller/LocDetlController.java | 67 ++++++++++++++++++++------------- 1 files changed, 40 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/LocDetlController.java b/src/main/java/com/zy/asrs/controller/LocDetlController.java index 553be70..1a5ff03 100644 --- a/src/main/java/com/zy/asrs/controller/LocDetlController.java +++ b/src/main/java/com/zy/asrs/controller/LocDetlController.java @@ -1,7 +1,5 @@ package com.zy.asrs.controller; -import com.alibaba.excel.EasyExcel; -import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.mapper.EntityWrapper; @@ -21,9 +19,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.net.URLEncoder; import java.util.*; @RestController @@ -39,7 +34,7 @@ @RequestMapping(value = "/locDetl/update") public R update1() { if (!locDetlService.updateLocNo("0402805", "0402804")) { - return R.error(); + return R.error("鍙傛暟缂哄け"); } return R.ok(); } @@ -92,7 +87,7 @@ @RequestParam(required = false)String condition, @RequestParam Map<String, Object> param, @RequestParam(required = false)Boolean unreason){ - if (unreason) { + if (!Cools.isEmpty(unreason) && unreason) { return R.ok(locDetlService.selectPage(new Page<>(curr, limit), new EntityWrapper<LocDetl>() .where(" DATALENGTH( batch ) != 11 or\n" + @@ -155,11 +150,21 @@ @ManagerAuth(memo = "搴撲綅鏄庣粏淇敼") public R update(LocDetl locDetl){ if (Cools.isEmpty(locDetl) || null==locDetl.getMatnr()){ - return R.error(); + return R.error("鍙傛暟缂哄け"); } locDetl.setModiUser(getUserId()); locDetl.setModiTime(new Date()); locDetlService.updateById(locDetl); + return R.ok(); + } + + @RequestMapping(value = "/locDetl/updateStockFreeze/auth") + @ManagerAuth(memo = "搴撲綅鍐荤粨") + public R updateStockFreeze(LocDetl locDetl){ + if (Cools.isEmpty(locDetl) || null==locDetl.getMatnr()){ + return R.error("鍙傛暟缂哄け"); + } + locDetlService.updateStockFreeze(locDetl.getMatnr(), locDetl.getLocNo(), locDetl.getStockFreeze()); return R.ok(); } @@ -168,7 +173,7 @@ public R delete(@RequestParam String param){ List<LocDetl> list = JSONArray.parseArray(param, LocDetl.class); if (Cools.isEmpty(list)){ - return R.error(); + return R.error("鍙傛暟缂哄け"); } for (LocDetl entity : list){ locDetlService.delete(new EntityWrapper<>(entity)); @@ -178,7 +183,7 @@ @RequestMapping(value = "/locDetl/export/auth") @ManagerAuth(memo = "搴撲綅鏄庣粏瀵煎嚭") - public R export(@RequestBody JSONObject param){ + public synchronized R export(@RequestBody JSONObject param){ List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); EntityWrapper<LocDetl> wrapper = new EntityWrapper<>(); Map<String, Object> map = excludeTrash(param.getJSONObject("locDetl")); @@ -246,24 +251,32 @@ @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); +// } + @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); + @ManagerAuth(memo = "搴撲綅鏄庣粏瀵煎嚭") + public synchronized R statisExport(@RequestBody JSONObject param){ + List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); + List<LocDetl> stockStatisExcel = LocDetlMapper.getStockStatisExcel(); + return R.ok(exportSupport(stockStatisExcel, fields)); } /** -- Gitblit v1.9.1