UnlockLocationServiceImpl.java 3.08 KB
package com.huaheng.api.wcs.service.unlockLocation;


import com.huaheng.api.wcs.domain.TaskFinishDomain;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.config.container.domain.Container;
import com.huaheng.pc.config.container.service.ContainerService;
import com.huaheng.pc.config.location.domain.Location;
import com.huaheng.pc.config.location.service.LocationService;
import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @ClassName UnlockLocationServiceImpl
 * @Description TODO
 * @Author Administrator
 * @Date 2019/12/1814:50
 */
@Service
public class UnlockLocationServiceImpl implements UnlockLocationService {

    @Autowired
    private TaskHeaderService taskService;
    @Autowired
    private ContainerService containerService;
    @Autowired
    private LocationService locationService;

    @Override
    @Transactional
    public AjaxResult unlockLocation(TaskFinishDomain taskFinishDomain) {

        //查找任务
        TaskHeader task = taskService.getById(Integer.valueOf(taskFinishDomain.getTaskNo()));
        if (task == null) {
            return AjaxResult.error("任务号错误,没有找到该任务");
        }
        if (task.getStatus() == 100) {
            return AjaxResult.success("任务已完成");
        }
        if (task.getUnlockLocation()==2) {
            return AjaxResult.success("任务号已释放库位,不能重复释放");
        }
        if (task.getTaskType() == 200 || task.getTaskType() == 400 || task.getTaskType() == 700
                || task.getTaskType() == 900) {
            //解锁容器
            Container container = new Container();
            container.setCode(task.getContainerCode());
            container.setWarehouseCode(taskFinishDomain.getWarehouseCode());
            container = containerService.selectFirstEntity(container);
            if (container == null) {
                return AjaxResult.error(task.getContainerCode() + "在系统中不存在");
            }

            //解锁库位
            Location location = new Location();
            location.setCode(task.getFromLocation());
            location.setWarehouseCode(taskFinishDomain.getWarehouseCode());
            location = locationService.selectFirstEntity(location);
            if (location == null) {
                return AjaxResult.error(task.getFromLocation() + "在系统中不存在");
            }

//            container.setLocationCode("");
//            container.setStatus("empty");
//            containerService.updateById(container);

            location.setContainerCode("");
            location.setStatus("empty");
            locationService.updateById(location);
        }
        task.setStatus(30);
        task.setUnlockLocation(2);
        taskService.updateById(task);
        return AjaxResult.success("成功");
    }
}