WarehousePointController.java
2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.huaheng.api.jindie.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.api.jindie.domain.WarehousePoint;
import com.huaheng.api.jindie.service.WarehousePointService;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.pc.config.material.domain.Material;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/warehousePoint")
public class WarehousePointController {
@Resource
private WarehousePointService warehousePointService;
@PostMapping("/getData")
@ResponseBody
public Map<String, Object> getData () {
LambdaQueryWrapper<WarehousePoint> queryWrapper = Wrappers.lambdaQuery();
List<WarehousePoint> warehousePointList = warehousePointService.list(queryWrapper);
warehousePointList = warehousePointList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WarehousePoint::getFNumber))), ArrayList::new));
List<Map<String, Object>> list = new ArrayList<>();
for (WarehousePoint warehousePoint : warehousePointList) {
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("selected", true);
resultMap.put("id", warehousePoint.getFNumber());
resultMap.put("text", warehousePoint.getFName());
list.add(resultMap);
}
Map<String, Object> map = new HashMap<>();
map.put("results", list);
return map; // 不返回页面只返回数据
}
@PostMapping("/getFFlexEntryId")
@ResponseBody
public Map<String, Object> getFFlexEntryId (String stockId) {
LambdaQueryWrapper<WarehousePoint> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(WarehousePoint::getFNumber,stockId);
List<WarehousePoint> warehousePointList = warehousePointService.list(queryWrapper);
Set<String> fFlexEntryIds = warehousePointList.stream().map(WarehousePoint::getFFlexEntryId).collect(Collectors.toSet());
Map<String, Object> map = new HashMap<>();
map.put("results", fFlexEntryIds);
return map; // 不返回页面只返回数据
}
}