no message
							parent
							
								
									e3b87d1423
								
							
						
					
					
						commit
						c406d91b57
					
				| 
						 | 
					@ -21,10 +21,7 @@ import org.apache.commons.lang3.StringUtils;
 | 
				
			||||||
import org.springframework.stereotype.Service;
 | 
					import org.springframework.stereotype.Service;
 | 
				
			||||||
import org.springframework.transaction.annotation.Transactional;
 | 
					import org.springframework.transaction.annotation.Transactional;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.HashSet;
 | 
					import java.util.*;
 | 
				
			||||||
import java.util.List;
 | 
					 | 
				
			||||||
import java.util.Objects;
 | 
					 | 
				
			||||||
import java.util.Set;
 | 
					 | 
				
			||||||
import java.util.stream.Collectors;
 | 
					import java.util.stream.Collectors;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Slf4j
 | 
					@Slf4j
 | 
				
			||||||
| 
						 | 
					@ -37,33 +34,29 @@ public class NioF3AppServiceImpl implements NioF3AppService {
 | 
				
			||||||
    private final AgvTaskService agvTaskService;
 | 
					    private final AgvTaskService agvTaskService;
 | 
				
			||||||
    private final KMReService kmReService;
 | 
					    private final KMReService kmReService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    @Transactional(rollbackFor = Exception.class)
 | 
					    @Transactional(rollbackFor = Exception.class)
 | 
				
			||||||
    public void bindSmallItemPicking(BindSmall bindSmall) {
 | 
					    public void bindSmallItemPicking(BindSmall bindSmall) {
 | 
				
			||||||
        //验证参数
 | 
					        // 验证参数
 | 
				
			||||||
        validateParams(bindSmall);
 | 
					        validateParams(bindSmall);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //验证Les任务
 | 
					        // 验证Les任务
 | 
				
			||||||
        List<Les> lesList = validateLes(bindSmall.getSrcPositionCode(), bindSmall.getOnlineNo());
 | 
					        List<Les> lesList = validateLes(bindSmall.getSrcPositionCode(), bindSmall.getOnlineNo());
 | 
				
			||||||
        List<Long> lesIds = lesList.stream().map(Les::getId).collect(Collectors.toList());
 | 
					        List<Long> lesIds = lesList.stream().map(Les::getId).collect(Collectors.toList());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //验证起点是否有Agv任务
 | 
					        // 获取目标点位
 | 
				
			||||||
        validateAgvTask(bindSmall.getSrcPositionCode());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //获取目标点位
 | 
					 | 
				
			||||||
        String endPointCode = getEndPointCode(lesList);
 | 
					        String endPointCode = getEndPointCode(lesList);
 | 
				
			||||||
 | 
					 | 
				
			||||||
        // 4. 仅对关键更新操作加锁
 | 
					 | 
				
			||||||
        String lockKey = bindSmall.getSrcPositionCode().intern();
 | 
					 | 
				
			||||||
        AgvTask agvTask;
 | 
					        AgvTask agvTask;
 | 
				
			||||||
        synchronized (lockKey) {
 | 
					        synchronized (bindSmall.getSrcPositionCode().intern()) {
 | 
				
			||||||
            //生成Agv任务
 | 
					            // 验证起点是否有Agv任务
 | 
				
			||||||
 | 
					            validateAgvTask(bindSmall.getSrcPositionCode());
 | 
				
			||||||
 | 
					            // 生成任务
 | 
				
			||||||
            agvTask = agvTaskService.createAgvTask(BizStatus.OPEN, null, bindSmall.getSrcPositionCode(), endPointCode, "TUGGER");
 | 
					            agvTask = agvTaskService.createAgvTask(BizStatus.OPEN, null, bindSmall.getSrcPositionCode(), endPointCode, "TUGGER");
 | 
				
			||||||
            //绑定任务
 | 
					            // 绑定任务
 | 
				
			||||||
            bindLesAgvTask(agvTask.getId(), lesIds);
 | 
					            bindLesAgvTask(agvTask.getId(), lesIds);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        // 下发任务
 | 
				
			||||||
        //下发任务
 | 
					 | 
				
			||||||
        kmReService.sendAgvTask(agvTask, kmReService.sendAgvTaskQYCJson(agvTask, bindSmall.getShooter(), null));
 | 
					        kmReService.sendAgvTask(agvTask, kmReService.sendAgvTaskQYCJson(agvTask, bindSmall.getShooter(), null));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -100,8 +93,8 @@ public class NioF3AppServiceImpl implements NioF3AppService {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private void validateAgvTask(String pointCode) {
 | 
					    private void validateAgvTask(String pointCode) {
 | 
				
			||||||
        Boolean bool = agvTaskService.findByStartSlotCode(pointCode, "MOVE", "TUGGER");
 | 
					        Long taskCount = agvTaskService.findByStartSlotCode(pointCode, "MOVE", "TUGGER");
 | 
				
			||||||
        if (bool) {
 | 
					        if (taskCount > 0) {
 | 
				
			||||||
            throw new BadRequestException(pointCode + "点位有任务,请勿重复下发");
 | 
					            throw new BadRequestException(pointCode + "点位有任务,请勿重复下发");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -135,20 +128,16 @@ public class NioF3AppServiceImpl implements NioF3AppService {
 | 
				
			||||||
        //验证料箱号
 | 
					        //验证料箱号
 | 
				
			||||||
        validateBoxNos(lesList, boxNos);
 | 
					        validateBoxNos(lesList, boxNos);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //验证起点是否有Agv任务
 | 
					 | 
				
			||||||
        validateAgvTask(bindLarge.getSrcPositionCode());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //获取目标点位
 | 
					        //获取目标点位
 | 
				
			||||||
        String endPointCode = getEndPointCode(lesList);
 | 
					        String endPointCode = getEndPointCode(lesList);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // 4. 仅对关键更新操作加锁
 | 
					 | 
				
			||||||
        String lockKey = bindLarge.getSrcPositionCode().intern();
 | 
					 | 
				
			||||||
        AgvTask agvTask;
 | 
					        AgvTask agvTask;
 | 
				
			||||||
        synchronized (lockKey) {
 | 
					        synchronized (bindLarge.getSrcPositionCode().intern()) {
 | 
				
			||||||
            //生成Agv任务
 | 
					            // 验证起点是否有Agv任务
 | 
				
			||||||
 | 
					            validateAgvTask(bindLarge.getSrcPositionCode());
 | 
				
			||||||
 | 
					            // 生成任务
 | 
				
			||||||
            agvTask = agvTaskService.createAgvTask(BizStatus.OPEN, null, bindLarge.getSrcPositionCode(), endPointCode, "TUGGER");
 | 
					            agvTask = agvTaskService.createAgvTask(BizStatus.OPEN, null, bindLarge.getSrcPositionCode(), endPointCode, "TUGGER");
 | 
				
			||||||
 | 
					            // 绑定任务
 | 
				
			||||||
            //绑定任务
 | 
					 | 
				
			||||||
            bindLesAgvTask(agvTask.getId(), lesIds);
 | 
					            bindLesAgvTask(agvTask.getId(), lesIds);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -42,6 +42,5 @@ public interface AgvTaskRepository extends JpaRepository<AgvTask, Long>, JpaSpec
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Query(value = "select count(agv.id) from AgvTask agv where agv.endSlotCode=:endSlotCode and agv.type=:type and agv.jobType=:jobType and agv.status in ('OPEN','ATCALL','UP_CONTAINER')  ")
 | 
					    @Query(value = "select count(agv.id) from AgvTask agv where agv.endSlotCode=:endSlotCode and agv.type=:type and agv.jobType=:jobType and agv.status in ('OPEN','ATCALL','UP_CONTAINER')  ")
 | 
				
			||||||
    @Lock(LockModeType.PESSIMISTIC_WRITE)
 | 
					 | 
				
			||||||
    Long findByEndSlotCode(String endSlotCode, String type, String jobType);
 | 
					    Long findByEndSlotCode(String endSlotCode, String type, String jobType);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -115,7 +115,7 @@ public interface AgvTaskService {
 | 
				
			||||||
     * @param type          任务类型
 | 
					     * @param type          任务类型
 | 
				
			||||||
     * @param jobType       作业类型
 | 
					     * @param jobType       作业类型
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    Boolean findByStartSlotCode(String startSlotCode, String type, String jobType);
 | 
					    Long findByStartSlotCode(String startSlotCode, String type, String jobType);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 根据终点查询是否有重复任务
 | 
					     * 根据终点查询是否有重复任务
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,6 +18,7 @@ package com.youchain.businessdata.service.impl;
 | 
				
			||||||
import com.youchain.basicdata.domain.Stock;
 | 
					import com.youchain.basicdata.domain.Stock;
 | 
				
			||||||
import com.youchain.businessdata.domain.*;
 | 
					import com.youchain.businessdata.domain.*;
 | 
				
			||||||
import com.youchain.businessdata.service.*;
 | 
					import com.youchain.businessdata.service.*;
 | 
				
			||||||
 | 
					import com.youchain.exception.BadRequestException;
 | 
				
			||||||
import com.youchain.utils.*;
 | 
					import com.youchain.utils.*;
 | 
				
			||||||
import com.youchain.businessdata.repository.AgvTaskRepository;
 | 
					import com.youchain.businessdata.repository.AgvTaskRepository;
 | 
				
			||||||
import com.youchain.businessdata.service.dto.AgvTaskDto;
 | 
					import com.youchain.businessdata.service.dto.AgvTaskDto;
 | 
				
			||||||
| 
						 | 
					@ -143,8 +144,8 @@ public class AgvTaskServiceImpl implements AgvTaskService {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public Boolean findByStartSlotCode(String startSlotCode, String type, String jobType) {
 | 
					    public Long findByStartSlotCode(String startSlotCode, String type, String jobType) {
 | 
				
			||||||
        return agvTaskRepository.findByStartSlotCode(startSlotCode, type, jobType)>0;
 | 
					        return agvTaskRepository.findByStartSlotCode(startSlotCode, type, jobType);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue