RobotController.java 25.5 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556
package com.huaheng.api.robot.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.InventoryQueryDomain;
import com.huaheng.api.robot.service.RobotService;
import com.huaheng.api.wcs.domain.WcsTask;
import com.huaheng.api.wcs.service.emptyOutHandle.EmptyOutHandleService;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.framework.aspectj.lang.annotation.ApiLogger;
import com.huaheng.framework.aspectj.lang.annotation.Log;
import com.huaheng.framework.aspectj.lang.constant.BusinessType;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.config.container.service.ContainerService;
import com.huaheng.pc.config.containerType.service.ContainerTypeService;
import com.huaheng.pc.config.location.domain.Location;
import com.huaheng.pc.config.location.domain.LocationStatus;
import com.huaheng.pc.config.location.service.LocationService;
import com.huaheng.pc.config.material.service.MaterialService;
import com.huaheng.pc.config.station.domain.Station;
import com.huaheng.pc.config.station.service.StationService;
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.inventoryHeader.service.InventoryHeaderService;
import com.huaheng.pc.task.taskDetail.service.TaskDetailService;
import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
import com.huaheng.pc.task.taskHeader.service.ReceiptTaskService;
import com.huaheng.pc.task.taskHeader.service.ShipmentTaskService;
import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

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

    @Resource
    private EmptyOutHandleService emptyOutHandleService;
    @Resource
    private ZoneService zoneService;
    @Resource
    private InventoryDetailService inventoryDetailService;
    @Resource
    private ContainerService containerService;
    @Resource
    private ContainerTypeService containerTypeService;
    @Resource
    private TaskHeaderService taskHeaderService;
    @Resource
    private StationService stationService;
    @Resource
    private ReceiptTaskService receiptTaskService;
    @Resource
    private ShipmentTaskService shipmentTaskService;
    @Resource
    private InventoryHeaderService inventoryHeaderService;
    @Resource
    private InventoryMaterialSummaryService inventoryMaterialSummaryService;
    @Resource
    private TaskDetailService taskDetailService;
    @Resource
    private MaterialService materialService;
    @Resource
    private RobotService robotService;
    @Resource
    private LocationService locationService;


    @PostMapping("/callReceipt")
    @ApiOperation("生产入库")
    @ApiLogger(apiName = "生产入库", from = "ROBOT")
    @ResponseBody
    public AjaxResult callReceipt(@RequestBody Map<String, String> map) {
        String materialCodePLC = map.get("materialCodePLC");
        String orderNo = map.get("orderNo");
        String line = map.get("line");
        String materialCode = map.get("materialCode");
        String qty = map.get("qty");
        String area = map.get("area");
        String qcc = map.get("qc");
        int qc = QuantityConstant.QC_NOCHECK;
        if(StringUtils.isNotEmpty(qcc)) {
            qc = Integer.parseInt(qcc);
        }
        if (line == null) {
            return AjaxResult.error("没有line");
        }
        if (materialCode == null) {
            return AjaxResult.error("没有materialCode");
        }
        if (qty == null) {
            return AjaxResult.error("没有qty");
        }
        if (area == null) {
            return AjaxResult.error("没有area");
        }
        if (materialCodePLC == null) {
            return AjaxResult.error("没有materialCodePLC");
        }
        if (orderNo == null) {
            return AjaxResult.error("没有orderNo");
        }
        int materialCodePLCint = Integer.parseInt(materialCodePLC);
        int finalQc = qc;
        AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = robotService.innerCallReceipt(line,
                        materialCode, qty, area, materialCodePLCint, orderNo, finalQc);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }


    @PostMapping("/callShipment")
    @ApiOperation("生产叫料")
    @ApiLogger(apiName = "生产叫料", from = "ROBOT")
    @ResponseBody
    public AjaxResult callShipment(@RequestBody Map<String, String> map) {
        String materialCodePLC = map.get("materialCodePLC");
        String orderNo = map.get("orderNo");
        String line = map.get("line");
        String materialCode = map.get("materialCode");
        String qty = map.get("qty");
        String area = map.get("area");
        String qc = map.get("qc");
        if (line == null) {
            return AjaxResult.error("没有line");
        }
        if (materialCode == null) {
            return AjaxResult.error("没有materialCode");
        }
        if (qty == null) {
            return AjaxResult.error("没有qty");
        }
        if (area == null) {
            return AjaxResult.error("没有area");
        }
        if (materialCodePLC == null) {
            return AjaxResult.error("没有materialCodePLC");
        }
        if (orderNo == null) {
            return AjaxResult.error("没有orderNo");
        }
        int materialCodePLCint = Integer.parseInt(materialCodePLC);
        AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = robotService.innerCallShipment(line, materialCode, qty,
                        area, materialCodePLCint, orderNo);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }

    /**
     * 查询托盘库存
     */
    @PostMapping("/searchContainerInventory")
    @ApiOperation("查询托盘库存")
    @ApiLogger(apiName = "查询托盘库存", from = "ROBOT")
    @ResponseBody
    public AjaxResult searchContainerInventory(@RequestBody InventoryQueryDomain inventoryQueryDomain) {
        LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper = Wrappers.lambdaQuery();
        inventoryDetailLambdaQueryWrapper.eq(StringUtils.isNotEmpty(inventoryQueryDomain.getWarehouseCode()),
                InventoryDetail::getWarehouseCode, inventoryQueryDomain.getWarehouseCode())
                .eq(StringUtils.isNotEmpty(inventoryQueryDomain.getContainerCode()),
                        InventoryDetail::getContainerCode, inventoryQueryDomain.getContainerCode())
                .eq(StringUtils.isNotEmpty(inventoryQueryDomain.getLocationCode()),
                        InventoryDetail::getLocationCode, inventoryQueryDomain.getLocationCode())
                .eq(StringUtils.isNotEmpty(inventoryQueryDomain.getCompanyCode()),
                        InventoryDetail::getCompanyCode, inventoryQueryDomain.getCompanyCode())
                .eq(StringUtils.isNotEmpty(inventoryQueryDomain.getZoneCode()),
                        InventoryDetail::getZoneCode, inventoryQueryDomain.getZoneCode())
                .eq(StringUtils.isNotEmpty(inventoryQueryDomain.getMaterialCode()),
                        InventoryDetail::getMaterialCode, inventoryQueryDomain.getMaterialCode());
        List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(inventoryDetailLambdaQueryWrapper);
        return AjaxResult.success(inventoryDetailList);
    }

    /**
     * 查询托盘库存
     */
    @PostMapping("/searchContainer")
    @ApiOperation("查询托盘库存")
    @ApiLogger(apiName = "查询托盘库存", from = "ROBOT")
    @ResponseBody
    public AjaxResult searchContainer(@RequestBody InventoryQueryDomain inventoryQueryDomain) {
        LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper = Wrappers.lambdaQuery();
        inventoryDetailLambdaQueryWrapper.eq(StringUtils.isNotEmpty(inventoryQueryDomain.getWarehouseCode()),
                InventoryDetail::getWarehouseCode, inventoryQueryDomain.getWarehouseCode())
                .eq(StringUtils.isNotEmpty(inventoryQueryDomain.getContainerCode()),
                        InventoryDetail::getContainerCode, inventoryQueryDomain.getContainerCode())
                .eq(StringUtils.isNotEmpty(inventoryQueryDomain.getLocationCode()),
                        InventoryDetail::getLocationCode, inventoryQueryDomain.getLocationCode())
                .eq(StringUtils.isNotEmpty(inventoryQueryDomain.getCompanyCode()),
                        InventoryDetail::getCompanyCode, inventoryQueryDomain.getCompanyCode())
                .eq(StringUtils.isNotEmpty(inventoryQueryDomain.getZoneCode()),
                        InventoryDetail::getZoneCode, inventoryQueryDomain.getZoneCode())
                .eq(StringUtils.isNotEmpty(inventoryQueryDomain.getMaterialCode()),
                        InventoryDetail::getMaterialCode, inventoryQueryDomain.getMaterialCode());
        List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(inventoryDetailLambdaQueryWrapper);
        List<InventoryDetail> removeInventoryDetailList = new ArrayList<>();
        if (inventoryDetailList != null && inventoryDetailList.size() > 0) {
            for (InventoryDetail inventoryDetail : inventoryDetailList) {
                String zoneCode = inventoryDetail.getZoneCode();
                if (zoneCode.equals("H") || zoneCode.equals("I")) {
                    int taskQty = inventoryDetail.getTaskQty().intValue();
                    if (taskQty != 0) {
                        removeInventoryDetailList.add(inventoryDetail);
                    }
                }
            }
            inventoryDetailList.removeAll(removeInventoryDetailList);
        }
        return AjaxResult.success(inventoryDetailList);
    }

    @PostMapping("/back")
    @ApiOperation("wcs托盘回库")
    @ResponseBody
    public AjaxResult back(@RequestBody WcsTask wcsTask) {
        AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = robotService.innerBack(wcsTask);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }

    /**
     * 查询库存
     */
    @PostMapping("/searchInventory")
    @ApiOperation("查询库存")
    @ResponseBody
    @ApiLogger(apiName = "查询库存", from = "ROBOT")
    public AjaxResult searchInventory(@RequestBody InventoryMaterialSummary inventoryMaterialSummary) {
        String area = inventoryMaterialSummary.getArea();
        if (StringUtils.isNotEmpty(area)) {
            LambdaQueryWrapper<Zone> zoneLambdaQueryWrapper = Wrappers.lambdaQuery();
            zoneLambdaQueryWrapper.eq(Zone::getArea, area);
            Zone zone = zoneService.getOne(zoneLambdaQueryWrapper);
            inventoryMaterialSummary.setZoneCode(zone.getCode());
        }
        LambdaQueryWrapper<InventoryMaterialSummary> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper
                .eq(StringUtils.isNotEmpty(inventoryMaterialSummary.getWarehouseCode()),
                        InventoryMaterialSummary::getWarehouseCode, inventoryMaterialSummary.getWarehouseCode())
                //物料编码
                .eq(StringUtils.isNotEmpty(inventoryMaterialSummary.getMaterialCode()),
                        InventoryMaterialSummary::getMaterialCode, inventoryMaterialSummary.getMaterialCode())
                //物料名称
                .eq(StringUtils.isNotEmpty(inventoryMaterialSummary.getMaterialName()),
                        InventoryMaterialSummary::getMaterialName, inventoryMaterialSummary.getMaterialName())
                .eq(StringUtils.isNotEmpty(inventoryMaterialSummary.getZoneCode()),
                        InventoryMaterialSummary::getZoneCode, inventoryMaterialSummary.getZoneCode())
                .eq(InventoryMaterialSummary::getTaskQty, 0)
                //货主
                .eq(!StringUtils.isEmpty(inventoryMaterialSummary.getCompanyCode()),
                        InventoryMaterialSummary::getCompanyCode, inventoryMaterialSummary.getCompanyCode());
        List<InventoryMaterialSummary> list = inventoryMaterialSummaryService.list(lambdaQueryWrapper);
        if (list == null) {
            list = Collections.emptyList();
        }
        //筛选库存汇总数据的专用方法
        List<InventoryMaterialSummary> details = inventoryMaterialSummaryService.duplicateRemoval(list);
        return AjaxResult.success(details);
    }


    /**
     * 查询是否满足自动出库
     */
    @PostMapping("/searchShipmentTask")
    @ApiOperation("查询出库任务")
    @ResponseBody
    @ApiLogger(apiName = "查询出库任务", from = "ROBOT")
    public AjaxResult searchShipmentTask(@RequestBody Map<String, String> map) {
        String area = map.get("area");
        String line = map.get("line");

        if (line == null) {
            return AjaxResult.error("没有line");
        }
        if (area == null) {
            return AjaxResult.error("没有area");
        }

        LambdaQueryWrapper<Zone> zoneLambdaQueryWrapper = Wrappers.lambdaQuery();
        zoneLambdaQueryWrapper.eq(Zone::getArea,area);
        Zone zoneServiceOne = zoneService.getOne(zoneLambdaQueryWrapper);


        LambdaQueryWrapper<Station> stationLambdaQueryWrapper = Wrappers.lambdaQuery();
        stationLambdaQueryWrapper.eq(Station::getArea, area)
                .eq(Station::getLine, line);
        List<Station> stationList = stationService.list(stationLambdaQueryWrapper);
        if (stationList == null || stationList.size() == 0) {
            return AjaxResult.error("区域和线体不正确");
        }
        List<String> portCodeList = stationList.stream().map(t -> t.getCode()).collect(Collectors.toList());
        if (portCodeList == null || portCodeList.size() == 0) {
            return AjaxResult.error("线体编码或者区域不正确,没有找到对应出口");
        }
        if (portCodeList.size() > 1) {
            for (String portCode : portCodeList) {
                LambdaQueryWrapper<TaskHeader> taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery();
                taskHeaderLambdaQueryWrapper.eq(TaskHeader::getPort, portCode)
                        .eq(TaskHeader::getZoneCode,zoneServiceOne.getCode())
                        .isNull(TaskHeader::getOrderNo)
                        .in(TaskHeader::getTaskType, QuantityConstant.TASK_TYPE_SORTINGSHIPMENT,
                                QuantityConstant.TASK_TYPE_WHOLESHIPMENT)
                        .lt(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED);
                List<TaskHeader> taskHeaders = taskHeaderService.list(taskHeaderLambdaQueryWrapper);
                if (taskHeaders != null && !taskHeaders.isEmpty()) {
                    return AjaxResult.error("还存在手动任务,无法下发自动任务!");
                }
            }
        } else {
            LambdaQueryWrapper<TaskHeader> taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery();
            taskHeaderLambdaQueryWrapper.eq(TaskHeader::getPort, portCodeList.get(0))
                    .eq(TaskHeader::getZoneCode,zoneServiceOne.getCode())
                    .isNull(TaskHeader::getOrderNo)
                    .in(TaskHeader::getTaskType, QuantityConstant.TASK_TYPE_SORTINGSHIPMENT,
                            QuantityConstant.TASK_TYPE_WHOLESHIPMENT)
                    .lt(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED);
            List<TaskHeader> taskHeaders = taskHeaderService.list(taskHeaderLambdaQueryWrapper);
            if (taskHeaders != null && !taskHeaders.isEmpty()) {
                return AjaxResult.error("还存在手动任务,无法下发自动任务!");
            }
        }
        return AjaxResult.success();
    }

    /**
     * 出库抓取信息
     */
    @PostMapping("/addShipmentDetail")
    @ApiOperation("出库抓取信息")
    @ResponseBody
    @ApiLogger(apiName = "出库抓取信息", from="ROBOT")
    public AjaxResult addShipmentDetail(@RequestBody Map<String,String> map)
    {
        String containerCode = map.get("containerCode");
        String port = map.get("port");
        String materialCode = map.get("materialCode");
        String qty = map.get("qty");
        String sn = map.get("sn");
        String isPrint = map.get("isPrint");
        String position = map.get("position");
        String area = map.get("area");
        String qcc = map.get("qc");
        if(containerCode == null) {
            return AjaxResult.error("没有containerCode");
        }
        if(port == null) {
            return AjaxResult.error("没有port");
        }
        if(materialCode == null) {
            return AjaxResult.error("没有materialCode");
        }
        if(qty == null) {
            return AjaxResult.error("没有qty");
        }
        if(sn == null) {
            return AjaxResult.error("没有sn");
        }
        if(position == null) {
            return AjaxResult.error("没有position");
        }
        AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = robotService.innerAddShipmentDetail(containerCode,
                        materialCode, port, qty, sn, position, isPrint, area);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }

    /**
     * 入库抓取信息
     */
    @PostMapping("/addReceiptDetail")
    @ApiOperation("入库抓取信息")
    @ResponseBody
    @ApiLogger(apiName = "入库抓取信息", from="ROBOT")
    public AjaxResult addReceiptDetail(@RequestBody Map<String,String> map)
    {
        String containerCode = map.get("containerCode");
        String port = map.get("port");
        String materialCode = map.get("materialCode");
        String qty = map.get("qty");
        String sn = map.get("sn");
        String isPrint = map.get("isPrint");
        String position = map.get("position");
        String area = map.get("area");
        String qcc = map.get("qc");
        int qc = QuantityConstant.QC_NOCHECK;
        if(StringUtils.isNotEmpty(qcc)) {
             qc = Integer.parseInt(qcc);
        }
        if(containerCode == null) {
            return AjaxResult.error("没有containerCode");
        }
        if(port == null) {
            return AjaxResult.error("没有port");
        }
        if(materialCode == null) {
            return AjaxResult.error("没有materialCode");
        }
        if(qty == null) {
            return AjaxResult.error("没有qty");
        }
        if(position == null) {
            return AjaxResult.error("没有position");
        }
        int finalQc = qc;
        AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = robotService.innerAddReceiptDetail(containerCode,
                        materialCode, port, qty, sn, position, isPrint, area, finalQc);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }

    /**
     * 查询库位列表
     */
    @PostMapping("/getAllLocation")
    @ApiOperation("查询库位列表")
    @ResponseBody
    @ApiLogger(apiName = "查询库位列表", from="ROBOT")
    public AjaxResult getAllLocation (@RequestBody Map<String,String> map) {
        String area = map.get("area");
        if(StringUtils.isEmpty(area)) {
            return AjaxResult.error("area不能为空");
        }
        LambdaQueryWrapper<Zone> zoneLambdaQueryWrapper = Wrappers.lambdaQuery();
        zoneLambdaQueryWrapper.eq(Zone::getArea, area);
        Zone zone = zoneService.getOne(zoneLambdaQueryWrapper);
        String type = zone.getCode();
        String warehouseCode = "CS0001";
        String row = null, line = null, layer = null;

        /* 查询库位信息*/
        LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery();
        locationLambdaQueryWrapper.eq(com.huaheng.common.utils.StringUtils.isNotEmpty(row), Location::getIRow, row)
                .eq(com.huaheng.common.utils.StringUtils.isNotEmpty(line), Location::getIColumn, line)
                .eq(com.huaheng.common.utils.StringUtils.isNotEmpty(layer), Location::getILayer, layer)
                .eq(Location::getIGrid, 1) //
                .eq(com.huaheng.common.utils.StringUtils.isNotEmpty(type), Location::getLocationType, type)
                .eq(Location::getWarehouseCode, warehouseCode)
                .eq(com.huaheng.common.utils.StringUtils.isNotEmpty(type), Location::getZoneCode, type);
        List<Location> locations = locationService.list(locationLambdaQueryWrapper);
        List<Location> locationList = new ArrayList<>();

        /* 查询库存明细*/
        LambdaQueryWrapper<InventoryDetail> inventoryDetailLambda = Wrappers.lambdaQuery();
        inventoryDetailLambda.eq(InventoryDetail::getWarehouseCode, warehouseCode);
        List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(inventoryDetailLambda);

        for (Location location1 : locations) {
            InventoryDetail inventoryDetail = null;
            String materialName = null;
            for (InventoryDetail inventoryDetail2 : inventoryDetailList) {
                if(location1.getCode().equals(inventoryDetail2.getLocationCode())) {
                    inventoryDetail = inventoryDetail2;
                }
            }
            List<InventoryDetail> inventoryDetails = inventoryDetailList.stream().filter(inventoryDetail1 ->
                    inventoryDetail1.getLocationCode().equals(location1.getCode())).collect(Collectors.toList());

            int userDef3 = 0;
            String status = location1.getStatus();
            String containerCode = location1.getContainerCode();
            List<String> materialNameList = inventoryDetails.stream().map(InventoryDetail::getMaterialName).collect(Collectors.toList());
            List<String> batchList = inventoryDetails.stream().map(InventoryDetail::getBatch).collect(Collectors.toList());
            List<String> materialCodeList = inventoryDetails.stream().map(InventoryDetail::getMaterialCode).collect(Collectors.toList());
            List<BigDecimal> qtyList = inventoryDetails.stream().map(InventoryDetail::getQty).collect(Collectors.toList());
            if(QuantityConstant.STATUS_LOCATION_EMPTY.equals(status)) {
                if(com.huaheng.common.utils.StringUtils.isEmpty(containerCode)) {
                    userDef3 = LocationStatus.IDLE_EMPTY_LOCATION;
                } else {
                    if(inventoryDetail == null) {
                        userDef3 = LocationStatus.IDLE_EMPTY_CONTAINER;
                    } else {
                        location1.setMaterialName(materialNameList);
                        location1.setMaterialCode(materialCodeList);
                        location1.setBatch(batchList);
                        location1.setQty(qtyList);
                        userDef3 = LocationStatus.IDLE_FULL_CONTAINER;
                    }
                }
            } else if(QuantityConstant.STATUS_LOCATION_LOCK.equals(status)) {
                if(com.huaheng.common.utils.StringUtils.isEmpty(containerCode)) {
                    userDef3 = LocationStatus.LOCK_EMPTY_LOCATION;
                } else {
                    if(inventoryDetail == null) {
                        userDef3 = LocationStatus.LOCK_EMPTY_CONTAINER;
                    } else {
                        location1.setMaterialName(materialNameList);
                        location1.setMaterialCode(materialCodeList);
                        location1.setBatch(batchList);
                        location1.setQty(qtyList);
                        userDef3 = LocationStatus.LOCK_FULL_CONTAINER;
                    }
                }
            }

            if(location1.getDeleted()) {
                if(com.huaheng.common.utils.StringUtils.isEmpty(containerCode)) {
                    userDef3 = LocationStatus.DISABLE_EMPTY_LOCATION;
                } else {
                    if(inventoryDetail == null) {
                        userDef3 = LocationStatus.DISABLE_EMPTY_CONTAINER;
                    } else {
                        location1.setMaterialName(materialNameList);
                        location1.setMaterialCode(materialCodeList);
                        location1.setBatch(batchList);
                        location1.setQty(qtyList);
                        userDef3 = LocationStatus.DISABLE_FULL_CONTAINER;
                    }
                }
            }

            location1.setUserDef3(String.valueOf(userDef3));
            locationList.add(location1);
        }
        return AjaxResult.success(locations);
    }
}