自动化立体仓库 - WMS系统
1
14 小时以前 51889b97a85b070cbb80a5bb2893149c80448d5d
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);
//    }
    /**
     * 获取库存总数