TvController.java 5.78 KB
package com.huaheng.api.tv.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.api.general.domain.AdjustDomain;
import com.huaheng.api.tv.domain.ErrInfo;
import com.huaheng.api.tv.domain.TvBean;
import com.huaheng.api.wcs.domain.WcsTask;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.framework.aspectj.lang.annotation.ApiLogger;
import com.huaheng.framework.web.controller.BaseController;
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.config.zone.domain.Zone;
import com.huaheng.pc.config.zone.service.ZoneService;
import com.huaheng.pc.inventory.InventoryMaterialSummary.domain.InventoryMaterialSummary;
import com.huaheng.pc.inventory.InventoryMaterialSummary.service.InventoryMaterialSummaryService;
import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService;
import com.huaheng.pc.inventory.inventoryTransaction.domain.InventoryTransaction;
import com.huaheng.pc.inventory.inventoryTransaction.service.InventoryTransactionService;
import com.huaheng.pc.monitor.apilog.service.IApiLogService;
import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.lang.ref.WeakReference;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

@RestController
@RequestMapping("/API/WMS/v2")
public class TvController extends BaseController {

    @Resource
    private TaskHeaderService taskHeaderService;
    @Resource
    private ContainerService containerService;
    @Resource
    private LocationService locationService;
    @Resource
    private InventoryTransactionService inventoryTransactionService;
    @Resource
    private ZoneService zoneService;
    @Resource
    private InventoryDetailService inventoryDetailService;
    @Resource
    private InventoryMaterialSummaryService inventoryMaterialSummaryService;
    @Resource
    private IApiLogService apiLogService;

    @PostMapping("/getTvView")
    @ApiOperation("获取电视信息")
    @ResponseBody
    public AjaxResult getTvView(@RequestBody WcsTask wcsTask) {
       String area =  wcsTask.getArea();
       LambdaQueryWrapper<TaskHeader> taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery();
       taskHeaderLambdaQueryWrapper
                                .lt(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED)
                                .orderByDesc(TaskHeader::getId);
       List<TaskHeader> taskHeaderList = taskHeaderService.list(taskHeaderLambdaQueryWrapper);

       LambdaQueryWrapper<Container> containerEmptyLambdaQueryWrapper = Wrappers.lambdaQuery();
        containerEmptyLambdaQueryWrapper
                                    .ne(Container::getLocationCode, "")
                                    .eq(Container::getEmptyPallet,"1");
       List<Container> containerEmptyList = containerService.list(containerEmptyLambdaQueryWrapper);
        int containerEmptySize = containerEmptyList.size();

        LambdaQueryWrapper<Container> containerSomeLambdaQueryWrapper = Wrappers.lambdaQuery();
        containerSomeLambdaQueryWrapper
                .eq(Container::getEmptyPallet,"0")
                .ne(Container::getLocationCode, "");
        List<Container> containerSomeList = containerService.list(containerSomeLambdaQueryWrapper);
        int containerSomeSize = containerSomeList.size();

        LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery();
        locationLambdaQueryWrapper.eq(Location::getArea, area);
        List<Location> locationList = locationService.list(locationLambdaQueryWrapper);
        int totalLocationSize = locationList.size();

        LambdaQueryWrapper<Zone> zoneLambdaQueryWrapper = Wrappers.lambdaQuery();
        zoneLambdaQueryWrapper.eq(Zone::getArea, area);
        Zone zone = zoneService.getOne(zoneLambdaQueryWrapper);
        LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper = Wrappers.lambdaQuery();
        inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getZoneCode, zone.getCode());
        List<InventoryDetail> inventoryDetailList = inventoryDetailService.list();
        int inventorySize =containerEmptySize+containerSomeSize; //inventoryDetailList.size();


        LambdaQueryWrapper<InventoryMaterialSummary> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(InventoryMaterialSummary::getZoneCode, zone.getCode());
        List<InventoryMaterialSummary> list = inventoryMaterialSummaryService.list(lambdaQueryWrapper);
        if (list == null) {
            list = Collections.emptyList();
        }
        //筛选库存汇总数据的专用方法
        List<InventoryMaterialSummary> details = inventoryMaterialSummaryService.duplicateRemoval(list);

        List<ErrInfo> errList=apiLogService.getErrorList();

        TvBean tvBean = new TvBean();
        tvBean.setDetails(details);
        tvBean.setContainerEmptySize(containerEmptySize);
        tvBean.setContainerSomeSize(containerSomeSize);
        tvBean.setTotalLocationSize(totalLocationSize);
        tvBean.setTaskHeaderList(taskHeaderList);
        tvBean.setInventorySize(inventorySize);
        tvBean.setErrinfo(errList);
        return AjaxResult.success(tvBean);
    }
}