| src/main/java/com/zy/asrs/controller/LocDetlController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/main/java/com/zy/asrs/entity/param/ExportParam.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/main/java/com/zy/asrs/mapper/LocDetlMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/main/java/com/zy/asrs/service/LocDetlService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/main/resources/mapper/LocDetlMapper.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/main/webapp/static/js/locDetlStatis/locDetlStatis.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/main/webapp/views/locDetlStatis/locDetlStatis.html | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/main/webapp/views/orderCargoGrouping/orderCargoGroupingOperate.html | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
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); // } /** * 获取库存总数 src/main/java/com/zy/asrs/entity/param/ExportParam.java
New file @@ -0,0 +1,17 @@ package com.zy.asrs.entity.param; import com.zy.common.utils.Synchro; import lombok.Data; @Data public class ExportParam { private Double anfme; private String matnr; private String standby1; private String standby2; private String boxType3; public void sync(Object source) { Synchro.Copy(source, this); } } src/main/java/com/zy/asrs/mapper/LocDetlMapper.java
@@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper; import com.zy.asrs.entity.LocDetl; 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.entity.result.StockVo; @@ -52,7 +53,8 @@ List<String> selectSameDetlTodayBatch(@Param("matnr") String matnr,@Param("batch") String batch, @Param("start") Integer start, @Param("end") Integer end); List<LocDetl> getStockStatis(Map<String, Object> map); List<LocDetl> selectStatisForExport(ExportParam param); List<LocDetl> selectStockStatisExport( ExportParam param); Integer getStockStatisCount(Map<String, Object> map); List<LocDetl> getStockStatis2(Map<String, Object> map); src/main/java/com/zy/asrs/service/LocDetlService.java
@@ -54,6 +54,7 @@ List<String> getSameDetlToday(String matnr, String batch, Integer start, Integer end); Page<LocDetl> getStockStatis(Page<LocDetl> page); // List<LocDetl> getStockStatisList(Page<LocDetl> page); Double getSumAnfme(String matnr); src/main/resources/mapper/LocDetlMapper.xml
@@ -358,7 +358,22 @@ and a.standby3 like '%' + #{standby3} + '%' </if> <if test="boxType3!=null and boxType3!='' "> and a.boxType3 like '%' + #{boxType3} + '%' and a.box_type3 like '%' + #{boxType3} + '%' </if> </sql> <sql id="stockOutCondition1"> <if test="matnr!=null and matnr!='' "> and a.matnr like '%' + #{matnr} + '%' </if> <if test="standby1!=null and standby1!='' "> and a.standby1 like '%' + #{standby1} + '%' </if> <if test="standby2!=null and standby2!='' "> and a.standby2 like '%' + #{standby2} + '%' </if> <if test="boxType3!=null and boxType3!='' "> and a.box_type3 like '%' + #{boxType3} + '%' </if> </sql> @@ -386,21 +401,48 @@ <include refid="stockOutCondition"></include> </select> <select id="getStockStatis" resultType="com.zy.asrs.entity.LocDetl"> select * from ( select ROW_NUMBER() over (order by sum(a.anfme) desc) as row , a.matnr , a.batch , a.standby1 , a.standby2 , sum(a.anfme) as anfme from asr_loc_detl a where 1=1 <include refid="stockOutCondition"></include> group by a.matnr, a.batch, a.standby1, a.standby2 ) t where t.row between ((#{pageNumber}-1)*#{pageSize}+1) and (#{pageNumber}*#{pageSize}) <select id="getStockStatis" resultMap="BaseResultMap"> SELECT * FROM ( SELECT ROW_NUMBER() OVER (ORDER BY SUM(a.anfme) DESC) AS row, a.matnr, a.batch, a.standby1, a.standby2, MAX(a.box_type3) AS box_type3, -- 关键:用 MAX 避免 null 或不确定性 SUM(a.anfme) AS anfme FROM asr_loc_detl a WHERE 1=1 <include refid="stockOutCondition"/> GROUP BY a.matnr, a.batch, a.standby1, a.standby2, a.box_type3 -- 保留,因为业务需要按采购单区分 ) t WHERE t.row BETWEEN ((#{pageNumber}-1)*#{pageSize}+1) AND (#{pageNumber}*#{pageSize}) </select> <!-- 库存统计导出:全量汇总数据(不分页) --> <select id="selectStockStatisExport" resultMap="BaseResultMap"> SELECT a.matnr, a.batch, a.standby1, a.standby2, MAX(a.box_type3) AS box_type3, SUM(a.anfme) AS anfme FROM asr_loc_detl a WHERE 1=1 <include refid="stockOutCondition1"/> GROUP BY a.matnr, a.batch, a.standby1, a.standby2, a.box_type3 ORDER BY SUM(a.anfme) DESC </select> <select id="getStockStatisCount" parameterType="java.util.Map" resultType="java.lang.Integer"> src/main/webapp/static/js/locDetlStatis/locDetlStatis.js
@@ -5,6 +5,8 @@ ]; arrRemove(detlCols, "field", "anfme") arrRemove(detlCols, "field", "zpallet") arrRemove(detlCols, "field", "orderNo") arrRemove(detlCols, "field", "memo") cols.push.apply(cols, detlCols); // cols.push({field: 'anfme', align: 'center',title: '数量', style: 'font-weight: bold'} // ) @@ -103,45 +105,55 @@ var checkStatus = table.checkStatus(obj.config.id); switch(obj.event) { case 'exportAll': layer.closeAll(); layer.load(1, {shade: [0.1,'#fff']}); location.href = baseUrl + "/locDetl/statis/export"; layer.closeAll('loading'); break; case 'exportData': layer.confirm('确定导出Excel吗', {shadeClose: true}, function(){ var titles=[]; var fields=[]; obj.config.cols[0].map(function (col) { if (col.type === 'normal' && col.hide === false && col.toolbar == null) { titles.push(col.title); fields.push(col.field); } }); layer.confirm('确定导出Excel吗?', {shadeClose: true}, function(){ // 收集搜索条件 var exportData = {}; $.each($('#search-box [name]').serializeArray(), function() { exportData[this.name] = this.value; }); var param = { 'locDetl': exportData, 'fields': fields locDetl: exportData }; $.ajax({ url: baseUrl+"/locDetl/export/auth", url: baseUrl + "/locDetl/statis/export/auth", headers: {'token': localStorage.getItem('token')}, data: JSON.stringify(param), dataType:'json', contentType:'application/json;charset=UTF-8', dataType: 'json', contentType: 'application/json;charset=UTF-8', method: 'POST', success: function (res) { layer.closeAll(); if (res.code === 200) { table.exportFile(titles,res.data,'xls'); if (res.code === 200 && res.data && res.data.length > 0) { var titles = ['库存数量', '商品编号', '商品名称', '采购单号', '条码UPC', '单箱净重(kg)', '客户PO']; var fieldKeys = ['anfme', 'matnr', 'maktx', 'boxType3', 'standby2', 'weight', 'standby1']; var exportData = res.data.map(function(item) { return [ item.anfme || '', item.matnr || '', item.maktx || '', // 如果 maktx 为空可默认 item.boxType3 || '', item.standby2 || '', item.weight || '', item.standby1 || '' // 如字段是 order_no 改成 item.order_no ]; }); table.exportFile(titles, exportData, 'xls'); layer.msg('导出成功,共 ' + res.data.length + ' 条数据', {icon: 1}); } else if (res.code === 200) { layer.msg('没有符合条件的数据可导出', {icon: 2}); } else if (res.code === 403) { top.location.href = baseUrl+"/"; top.location.href = baseUrl + "/"; } else { layer.msg(res.msg) layer.msg(res.msg || '导出失败'); } }, error: function() { layer.closeAll(); layer.msg('网络错误,导出失败'); } }); }); src/main/webapp/views/locDetlStatis/locDetlStatis.html
@@ -16,7 +16,16 @@ <div id="search-box" class="layui-form layui-card-header"> <div class="layui-inline"> <div class="layui-input-inline"> <input class="layui-input" type="text" name="matnr" placeholder="商品编号" autocomplete="off"> <input class="layui-input" type="text" name="matnr" placeholder="SKU" autocomplete="off"> </div> <div class="layui-input-inline"> <input class="layui-input" type="text" name="boxType3" placeholder="采购单号" autocomplete="off"> </div> <div class="layui-input-inline"> <input class="layui-input" type="text" name="standby2" placeholder="UPC" autocomplete="off"> </div> <div class="layui-input-inline"> <input class="layui-input" type="text" name="standby1" placeholder="PO" autocomplete="off"> </div> </div> <!-- 待添加 --> src/main/webapp/views/orderCargoGrouping/orderCargoGroupingOperate.html
@@ -430,6 +430,17 @@ this.getTableDataA(); }, 10000); }, handleDetailSearch() { // 触发计算属性重新计算即可,无需额外操作 this.$forceUpdate(); // 可选,确保立即刷新(通常不需要) }, // 明细搜索重置 handleDetailReset() { this.detailSearch.standby3 = ''; this.detailSearch.boxType3 = ''; // 重置后表格自动恢复原数据 }, // 获取主表A数据 getTableDataA() {