ZarshAddService.java 3.48 KB
package com.huaheng.pc.sap.service;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.config.location.service.LocationService;
import com.huaheng.pc.config.station.domain.Station;
import com.huaheng.pc.config.station.service.StationService;
import com.huaheng.pc.sap.domain.Zarsh;
import com.huaheng.pc.sap.mapper.ZarshMapper;
import com.huaheng.pc.task.taskDetail.service.TaskDetailService;
import com.huaheng.pc.task.taskHeader.service.WorkTaskService;

/**
 * Created by Enzo Cotter on 2022/5/11.
 * @author zhouhong
 */
@Service
public class ZarshAddService extends ServiceImpl<ZarshMapper, Zarsh> {

    @Resource
    private StationService stationService;
    @Resource
    private LocationService locationService;
    @Resource
    private TaskDetailService taskDetailService;
    @Resource
    private WorkTaskService workTaskService;

    // 创建站点到站点任务
    public void createMoveTask(String containerCode, String zoneCode, String formPort, String toPort, String uniqueId) {
        if (StringUtils.isEmpty(formPort)) {
            throw new ServiceException("未找到起点站台");
        }
        if (StringUtils.isEmpty(toPort)) {
            throw new ServiceException("未找到终点站台");
        }
        if (zoneCode.equals("E") || zoneCode.equals("D") || zoneCode.equals("F")) {
        } else {
            throw new ServiceException("不支持此任务类型");
        }
        LambdaQueryWrapper<Station> lambdaQuery_m_from = Wrappers.lambdaQuery();
        lambdaQuery_m_from.eq(Station::getByName, formPort);
        Station mfromStation = stationService.getOne(lambdaQuery_m_from);
        if (mfromStation == null) {
            throw new ServiceException(formPort + "站台异常,未找到站台");
        }
        LambdaQueryWrapper<Station> lambdaQuery_m_to = Wrappers.lambdaQuery();
        lambdaQuery_m_to.eq(Station::getByName, toPort);
        Station mtoStation = stationService.getOne(lambdaQuery_m_to);
        if (mfromStation == null) {
            throw new ServiceException(formPort + "站台异常,未找到站台");
        }
        String fromArea = mfromStation.getAreaByWcs();
        String toArea = mtoStation.getAreaByWcs();
        // 验证区域
        checkAreaByWcs(fromArea, toArea);
        AjaxResult stationToStaion =
            workTaskService.createStationToStation(containerCode, mfromStation.getCode(), mtoStation.getCode(), zoneCode, mtoStation.getCode(), uniqueId);
    }

    public void createdReceiptCrossZone() {

    }

    // 验证区域
    public void checkAreaByWcs(String fromArea, String toArea) {
        if (StringUtils.isNotEmpty(fromArea) && StringUtils.isNotEmpty(toArea)) {
            if (fromArea.equals("A") && toArea.equals("C")) {
                throw new ServiceException(fromArea + ":" + toArea + ",起点站台或库位和终点站台或库位不能跨堆垛机区域");
            } else if (fromArea.equals("C") && toArea.equals("A")) {
                throw new ServiceException(fromArea + ":" + toArea + ",起点站台或库位和终点站台或库位不能跨堆垛机区域");
            }
        }
    }
}