| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 日志统计控制器层 |
| | |
| | | public R queryViewLocMapRows(){ |
| | | return R.ok().add(reportQueryMapper.getViewLocRowTotal()); |
| | | } |
| | | @RequestMapping("/viewLocMapList/layers.action") |
| | | public R queryViewLocMapLevs(){ |
| | | return R.ok().add(reportQueryMapper.getViewLocLevTotal()); |
| | | } |
| | | |
| | | @RequestMapping("/viewLocMapList.action") |
| | | public R queryViewLocMapListByPages(@RequestParam(defaultValue = "1")Integer row){ |
| | | // 获取排级数据 |
| | | // 表格标题:列 ===>> 升序 |
| | | List<String> bays = reportQueryMapper.getViewLocBayCount(row); |
| | | // !表格第一列放层级数 |
| | | bays.add(0, ""); |
| | | // 表格行:层 ====>> 倒序 |
| | | List<String> levs = reportQueryMapper.getViewLocLevCount(row); |
| | | List<Map<String, Object>> body = new ArrayList<>(); |
| | | for (String lev : levs){ |
| | | // 获取层级数据 |
| | | List<ViewLocMapDto> dtos = reportQueryMapper.getViewLocBays(row, Integer.parseInt(lev)); |
| | | // !表格第一列放层级数 |
| | | dtos.add(0, new ViewLocMapDto(null ,null, lev)); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("loc", dtos); |
| | | body.add(map); |
| | | } |
| | | public R queryViewLocMapListByPages( |
| | | @RequestParam(required = false, defaultValue = "0") Integer row, |
| | | @RequestParam(required = false) Integer layer) { |
| | | |
| | | Map<String, Object> result = new HashMap<>(); |
| | | result.put("title", bays); |
| | | List<String> title = new ArrayList<>(); |
| | | List<Map<String, Object>> body = new ArrayList<>(); |
| | | |
| | | if (layer != null && layer > 0) { |
| | | // ── 按层显示所有排 × 所有列 ─────────────────────────────── |
| | | |
| | | // 1. 表头:所有 bay |
| | | List<String> allBays = reportQueryMapper.getAllBays(); // 或生成 1 到 maxBay |
| | | title.add(""); // 第一列放排号 |
| | | title.addAll(allBays); |
| | | |
| | | // 2. 获取该层所有库位 |
| | | List<ViewLocMapDto> locs = reportQueryMapper.getLocMapByLayer(layer); |
| | | |
| | | // 3. 按 row 分组(推荐用 Map 或 Stream 分组) |
| | | Map<Integer, List<ViewLocMapDto>> rowMap = locs.stream() |
| | | .collect(Collectors.groupingBy(ViewLocMapDto::getRow1)); |
| | | |
| | | // 4. 遍历所有排,生成每一行 |
| | | List<Integer> allRows = reportQueryMapper.getAllRows(); |
| | | for (Integer currentRow : allRows) { |
| | | List<ViewLocMapDto> rowData = rowMap.getOrDefault(currentRow, new ArrayList<>()); |
| | | |
| | | // 按 bay 排序并补齐空位 |
| | | Map<Integer, ViewLocMapDto> bayMap = rowData.stream() |
| | | .collect(Collectors.toMap(ViewLocMapDto::getBay1, d -> d)); |
| | | |
| | | List<ViewLocMapDto> line = new ArrayList<>(); |
| | | // 第一列:排号 |
| | | line.add(new ViewLocMapDto(null, null, String.valueOf(currentRow))); |
| | | |
| | | // 填充所有 bay |
| | | for (String bayStr : allBays) { |
| | | int bay = Integer.parseInt(bayStr); |
| | | ViewLocMapDto dto = bayMap.get(bay); |
| | | if (dto != null) { |
| | | line.add(dto); |
| | | } else { |
| | | // 无库位 → 补空 |
| | | line.add(new ViewLocMapDto(null, 0, null)); // 或自定义空状态 |
| | | } |
| | | } |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("loc", line); |
| | | body.add(map); |
| | | } |
| | | } |
| | | else { |
| | | // ── 按排模式(原有逻辑) ───────────────────── |
| | | title = reportQueryMapper.getViewLocBayCount(row); |
| | | title.add(0, ""); |
| | | |
| | | List<String> levs = reportQueryMapper.getViewLocLevCount(row); |
| | | body = new ArrayList<>(); |
| | | |
| | | for (String lev : levs) { |
| | | List<ViewLocMapDto> dtos = reportQueryMapper.getViewLocBays(row, Integer.parseInt(lev)); |
| | | dtos.add(0, new ViewLocMapDto(null, null, lev)); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("loc", dtos); |
| | | body.add(map); |
| | | } |
| | | } |
| | | |
| | | result.put("title", title); |
| | | result.put("body", body); |
| | | return R.ok(result); |
| | | } |
| | | // @RequestMapping("/viewLocMapList.action") |
| | | // public R queryViewLocMapListByPages(@RequestParam(defaultValue = "0")Integer row){ |
| | | // // 获取排级数据 |
| | | // // 表格标题:列 ===>> 升序 |
| | | // List<String> bays = reportQueryMapper.getViewLocBayCount(row); |
| | | // // !表格第一列放层级数 |
| | | // bays.add(0, ""); |
| | | // // 表格行:层 ====>> 倒序 |
| | | // List<String> levs = reportQueryMapper.getViewLocLevCount(row); |
| | | // List<Map<String, Object>> body = new ArrayList<>(); |
| | | // for (String lev : levs){ |
| | | // // 获取层级数据 |
| | | // List<ViewLocMapDto> dtos = reportQueryMapper.getViewLocBays(row, Integer.parseInt(lev)); |
| | | // // !表格第一列放层级数 |
| | | // dtos.add(0, new ViewLocMapDto(null ,null, lev)); |
| | | // Map<String, Object> map = new HashMap<>(); |
| | | // map.put("loc", dtos); |
| | | // body.add(map); |
| | | // } |
| | | // Map<String, Object> result = new HashMap<>(); |
| | | // result.put("title", bays); |
| | | // result.put("body", body); |
| | | // return R.ok(result); |
| | | // } |
| | | |
| | | |
| | | //------------------站点日入出库次数统计-------------------------------------- |
| | |
| | | public R viewWorkCountInList(@RequestParam(defaultValue = "1")Integer curr, |
| | | @RequestParam(defaultValue = "10")Integer limit, |
| | | @RequestParam Map<String, Object> param){ |
| | | List<ViewWorkCountInView> allCountIn = reportQueryMapper.selectWorkCountIn(Integer.valueOf((String) param.get("pageNumber")), Integer.valueOf((String) param.get("pageSize"))); |
| | | Integer total = reportQueryMapper.selectWorkCountInTotal(); |
| | | String startTime = "1970.1.2"; |
| | | String endTime = "2099.1.2"; |
| | | if (!Cools.isEmpty(param.get("query_date"))) { |
| | | String queryDate = (String) param.get("query_date"); |
| | | String[] split = queryDate.split(" - "); |
| | | startTime= split[0].split(" ")[0].replace("-","."); |
| | | endTime = split[1].split(" ")[0].replace("-","."); |
| | | } |
| | | List<ViewWorkCountInView> allCountIn = reportQueryMapper.selectWorkCountIn(Integer.valueOf((String) param.get("pageNumber")), Integer.valueOf((String) param.get("pageSize")), (String) param.get("matnr"), startTime,endTime); |
| | | Integer total = reportQueryMapper.selectWorkCountInTotal((String) param.get("matnr"), startTime,endTime); |
| | | Page<ViewWorkCountInView> page = new Page<>(); |
| | | page.setRecords(allCountIn); |
| | | page.setTotal(total); |
| | | return R.ok(page); |
| | | Integer sum = reportQueryMapper.selectWorkCountInSum((String) param.get("matnr"), startTime,endTime); |
| | | HashMap<String, Object> result = new HashMap<>(); |
| | | result.put("page",page); |
| | | result.put("sum",sum); |
| | | return R.ok(result); |
| | | } |
| | | |
| | | /** |
| | |
| | | public R viewWorkCountOutList(@RequestParam(defaultValue = "1")Integer curr, |
| | | @RequestParam(defaultValue = "10")Integer limit, |
| | | @RequestParam Map<String, Object> param){ |
| | | List<ViewWorkCountInView> allCountIn = reportQueryMapper.selectWorkCountOut(Integer.valueOf((String) param.get("pageNumber")), Integer.valueOf((String) param.get("pageSize"))); |
| | | Integer total = reportQueryMapper.selectWorkCountOutTotal(); |
| | | String startTime = "1970.1.2"; |
| | | String endTime = "2099.1.2"; |
| | | if (!Cools.isEmpty(param.get("query_date"))) { |
| | | String queryDate = (String) param.get("query_date"); |
| | | String[] split = queryDate.split(" - "); |
| | | startTime= split[0].split(" ")[0].replace("-","."); |
| | | endTime = split[1].split(" ")[0].replace("-","."); |
| | | } |
| | | List<ViewWorkCountInView> allCountIn = reportQueryMapper.selectWorkCountOut(Integer.valueOf((String) param.get("pageNumber")), Integer.valueOf((String) param.get("pageSize")), (String) param.get("matnr"), startTime,endTime); |
| | | Integer total = reportQueryMapper.selectWorkCountOutTotal((String) param.get("matnr"), startTime,endTime); |
| | | Page<ViewWorkCountInView> page = new Page<>(); |
| | | page.setRecords(allCountIn); |
| | | page.setTotal(total); |
| | | return R.ok(page); |
| | | Integer sum = reportQueryMapper.selectWorkCountOutSum((String) param.get("matnr"), startTime,endTime); |
| | | HashMap<String, Object> result = new HashMap<>(); |
| | | result.put("page",page); |
| | | result.put("sum",sum); |
| | | return R.ok(result); |
| | | } |
| | | |
| | | //excel导出 |