|
@@ -1,8 +1,23 @@
|
|
|
package com.ruoyi.ams.agv.car.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.comparator.CompareUtil;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import com.ruoyi.ams.agv.car.domain.CarInfo;
|
|
|
+import com.ruoyi.ams.agv.car.dto.CarInfoDTO;
|
|
|
+import com.ruoyi.ams.agv.car.mapper.CarInfoMapper;
|
|
|
import com.ruoyi.ams.agv.car.service.ICarInfoService;
|
|
|
+import com.ruoyi.ams.task.domain.WcsTask;
|
|
|
+import com.ruoyi.ams.task.service.IWcsTaskService;
|
|
|
+import com.ruoyi.base.constant.Constant;
|
|
|
+import com.ruoyi.common.utils.ConvertUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
/**
|
|
|
* 入库单Service业务层处理
|
|
|
*
|
|
@@ -11,4 +26,25 @@ import org.springframework.stereotype.Service;
|
|
|
*/
|
|
|
@Service
|
|
|
public class CarInfoServiceImpl implements ICarInfoService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CarInfoMapper carInfoMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IWcsTaskService wcsTaskService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<CarInfoDTO> queryCarInfo(){
|
|
|
+ List<CarInfo> carInfoList = carInfoMapper.selectList(Wrappers.<CarInfo>lambdaQuery().eq(CarInfo::getActiveFlag, "Y"));
|
|
|
+ if (CollectionUtil.isEmpty(carInfoList)) return Lists.newArrayList();
|
|
|
+ List<WcsTask> wcsTaskList = wcsTaskService.queryAgvWcsTask(carInfoList.stream().map(CarInfo::getCarNo).collect(Collectors.toList()), Constant.TASK_STS.TASK4.getValue());
|
|
|
+ return carInfoList.stream().map(item -> {
|
|
|
+ CarInfoDTO carInfoDTO = ConvertUtils.sourceToTarget(item, CarInfoDTO.class);
|
|
|
+ Boolean flag = wcsTaskList.stream().anyMatch(wcsTask -> CompareUtil.compare(item.getCarNo(), wcsTask.getAgvNo()) == 0);
|
|
|
+ carInfoDTO.setTaskNo(flag ? wcsTaskList.stream().filter(wcsTask -> CompareUtil.compare(item.getCarNo(), wcsTask.getAgvNo()) == 0).findFirst().get().getTaskNo(): null);
|
|
|
+ carInfoDTO.setState(flag ? Constant.AGV_STATUS.BUSY.getValue(): Constant.AGV_STATUS.FREE.getValue());
|
|
|
+ return carInfoDTO;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
}
|