StationService.java 3.34 KB
package com.huaheng.pc.config.station.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.support.Convert;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.Wrappers;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.pc.config.container.domain.Container;
import com.huaheng.pc.config.container.service.ContainerService;
import com.huaheng.pc.config.containerType.domain.ContainerType;
import com.huaheng.pc.config.containerType.service.ContainerTypeService;
import org.springframework.stereotype.Service;

import java.util.*;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.pc.config.station.domain.Station;
import com.huaheng.pc.config.station.mapper.StationMapper;

import javax.annotation.Resource;

/**
 * Created by Enzo Cotter on 2019/10/11.
 */

@Service("stationService")
public class StationService extends ServiceImpl<StationMapper, Station> {
    @Resource
    private ContainerService containerService;
    @Resource
    private ContainerTypeService containerTypeService;


    public List<Station> selectlist(){
        LambdaQueryWrapper<Station> lambdaQueryWrapper = Wrappers.lambdaQuery();
        List<Station> list =  this.list(lambdaQueryWrapper);
        return list;
    }
    public Station getStaionByCode(String code,String warehouseCode){
        Station station = this.getOne(
                new LambdaQueryWrapper<Station>()
                        .eq(Station::getWarehouseCode, warehouseCode)
                        .eq(Station::getCode, code)
                        .last("limit 1"));
        return station;
    }
    public List<Station> getStationByAreaType(String area,String stationtype,String warehouseCode){
        LambdaQueryWrapper<Station> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(StringUtils.isNotEmpty(area),Station::getArea, area);
        queryWrapper.eq(StringUtils.isNotEmpty(stationtype),Station::getStationType, stationtype);
        queryWrapper.eq(StringUtils.isNotEmpty(warehouseCode),Station::getWarehouseCode, warehouseCode);
        List<Station> stationList = this.list(queryWrapper);
        return stationList;
    }
    public List<Station> getStationByContainers(String containerCode,String type,String stationType){
        Container container = containerService.getContainerByCode(containerCode, ShiroUtils.getWarehouseCode());
        ContainerType containerType = containerTypeService.getContainerTypeByCode(container.getContainerType(), container.getWarehouseCode());
        Map<String, Object> map = new HashMap<>();
        if (container == null) {
            return null;
        }
        String area=containerType.getArea();

        List<Integer> types = new ArrayList<>();
        if (StringUtils.isNotEmpty(type)){
            types = Arrays.asList(Convert.toIntArray(type));
        }

        LambdaQueryWrapper<Station> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(StringUtils.isNotEmpty(area),Station::getArea, area);
        queryWrapper.in(StringUtils.isNotEmpty(type),Station::getType, types);
        queryWrapper.eq(StringUtils.isNotEmpty(stationType),Station::getStationType, stationType);
        List<Station> stationList = this.list(queryWrapper);
        return stationList;
    }

}