BigScreenService.java 5.61 KB
package com.huaheng.api.general.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.api.general.domain.BigScreenTask;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.pc.task.taskDetail.domain.TaskDetail;
import com.huaheng.pc.task.taskDetail.service.TaskDetailService;
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.Component;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @author yiwenpeng
 * @date 2022/9/7 09:51
 */
@Component
public class BigScreenService {

    @Resource
    TaskHeaderService taskHeaderService;

    @Resource
    TaskDetailService taskDetailService;


    public List<BigScreenTask> selectReceiptTask() {
        List<TaskHeader> taskHeaders = taskHeaderService.list(new LambdaQueryWrapper<TaskHeader>()
                .eq(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED)//任务完成
                .eq(TaskHeader::getZoneCode, "B")
                .in(TaskHeader::getTaskType, QuantityConstant.TASK_TYPE_WHOLERECEIPT, QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT)//整盘入库、补充入库
                .orderByDesc(TaskHeader::getCreated)
                .last("limit 10"));
        List<BigScreenTask> bigScreenTaskList = new ArrayList<>();

        for (TaskHeader taskHeader : taskHeaders) {
            List<TaskDetail> taskDetails=taskDetailService.list(new LambdaQueryWrapper<TaskDetail>().eq(TaskDetail::getTaskId,taskHeader.getId()));
            if (taskDetails.size()==0) {
                continue;
            }
            TaskDetail taskDetail=taskDetails.get(0);
            BigScreenTask bigScreenTask = new BigScreenTask();
            bigScreenTask.setTaskId(taskHeader.getId());
            bigScreenTask.setQty(taskDetail.getQty());
            bigScreenTask.setMaterialCode(taskDetail.getMaterialCode());
            bigScreenTask.setToLocation(taskHeader.getToLocation());
            bigScreenTask.setMaterialName(taskDetail.getMaterialName());
            bigScreenTask.setFromLocation(taskHeader.getFromLocation());
            bigScreenTask.setContainerCode(taskHeader.getContainerCode());
            bigScreenTask.setMaterialCode(taskDetail.getMaterialCode());
            if (taskHeader.getStatus().toString().equals("1")) {
                bigScreenTask.setStatus("创建状态");
            } else if (taskHeader.getStatus().toString().equals("100")) {
                bigScreenTask.setStatus("任务完成");
            } else {
                bigScreenTask.setStatus("执行状态");
            }
            if (taskHeader.getTaskType().toString().equals("100")) {
                bigScreenTask.setTaskType("整盘入库");
            }
            if (taskHeader.getTaskType().toString().equals("200")) {
                bigScreenTask.setTaskType("补充入库");
            }
            //if (taskHeader.getTaskType().toString().equals("900")) {
            //    bigScreenTask.setTaskType("盘点任务");
            //}
            bigScreenTaskList.add(bigScreenTask);
        }
        return bigScreenTaskList;
    }

    public List<BigScreenTask> selectShipmentTask() {
        List<TaskHeader> taskHeaders = taskHeaderService.list(new LambdaQueryWrapper<TaskHeader>()
                .eq(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED)//任务完成
                .eq(TaskHeader::getZoneCode, "B")
                .in(TaskHeader::getTaskType, QuantityConstant.TASK_TYPE_WHOLESHIPMENT, QuantityConstant.TASK_TYPE_SORTINGSHIPMENT)//整盘出库、分拣出库
                .orderByDesc(TaskHeader::getCreated)
                .last("limit 10"));

        List<BigScreenTask> bigScreenTaskList = new ArrayList<>();

        for (TaskHeader taskHeader : taskHeaders) {
            List<TaskDetail> taskDetails=taskDetailService.list(new LambdaQueryWrapper<TaskDetail>().eq(TaskDetail::getTaskId,taskHeader.getId()));
            if (taskDetails.size()==0) {
                continue;
            }
            TaskDetail taskDetail=taskDetails.get(0);
            BigScreenTask bigScreenTask = new BigScreenTask();
            bigScreenTask.setQty(taskDetail.getQty());
            bigScreenTask.setMaterialName(taskDetail.getMaterialName());
            bigScreenTask.setTaskId(taskHeader.getId());
            bigScreenTask.setMaterialCode(taskDetail.getMaterialCode());
            bigScreenTask.setToLocation(taskHeader.getToLocation());
            bigScreenTask.setFromLocation(taskHeader.getFromLocation());
            bigScreenTask.setContainerCode(taskHeader.getContainerCode());
            if (taskHeader.getStatus().toString().equals("1")) {
                bigScreenTask.setStatus("创建状态");
            } else if (taskHeader.getStatus().toString().equals("100")) {
                bigScreenTask.setStatus("任务完成");
            } else {
                bigScreenTask.setStatus("执行状态");
            }
            if (taskHeader.getTaskType().toString().equals("300")) {
                bigScreenTask.setTaskType("整盘出库");
            }
            if (taskHeader.getTaskType().toString().equals("400")) {
                bigScreenTask.setTaskType("分拣出库");
            }
            //if (taskHeader.getTaskType().toString().equals("900")) {
            //    bigScreenTask.setTaskType("盘点任务");
            //}
            bigScreenTaskList.add(bigScreenTask);
        }
        return bigScreenTaskList;
    }

}