WarehousePointController.java 2.54 KB
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; // 不返回页面只返回数据
    }
}