/*
 *  Copyright 2019-2020 Zheng Jie
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.youchain.businessdata.rest;

import com.youchain.DuplicateSubmission.DuplicateSubmission;
import com.youchain.annotation.AnonymousAccess;
import com.youchain.annotation.Log;
import com.youchain.appupdate.inputJson.ScanItemCode;
import com.youchain.basicdata.domain.BomAccount;
import com.youchain.basicdata.domain.Item;
import com.youchain.basicdata.domain.Point;
import com.youchain.basicdata.repository.BomAccountRepository;
import com.youchain.basicdata.repository.ItemRepository;
import com.youchain.basicdata.repository.PointRepository;
import com.youchain.businessdata.domain.*;
import com.youchain.businessdata.inputJson.XdMoveReq;
import com.youchain.businessdata.inputJson.ZzkwMoveReq;
import com.youchain.businessdata.inputJson.buttenJson.InvYW;
import com.youchain.businessdata.inputJson.buttenJson.InventoryButton;
import com.youchain.businessdata.repository.InventoryRepository;
import com.youchain.businessdata.repository.TaskRepository;
import com.youchain.businessdata.returnJson.RInvQuery;
import com.youchain.businessdata.returnJson.XdInventory;
import com.youchain.businessdata.service.InventoryLogService;
import com.youchain.businessdata.service.InventoryService;
import com.youchain.businessdata.service.ItemKeyService;
import com.youchain.businessdata.service.dto.*;
import com.youchain.businessdata.service.dto.jsonDto.CxjlDto;
import com.youchain.exception.BadRequestException;
import com.youchain.exception.handler.ApiResult;
import com.youchain.utils.BaseStatus;
import com.youchain.utils.BillParmType;
import com.youchain.utils.BizStatus;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;

import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

/**
 * @author huojin
 * @website https://eladmin.vip
 * @date 2023-08-22
 **/
@RestController
@RequiredArgsConstructor
@Api(tags = "inventory管理")
@RequestMapping("/api/inventory")
@Slf4j
public class InventoryController {

    private final InventoryService inventoryService;
    private final InventoryRepository inventoryRepository;
    private final InventoryLogService inventoryLogService;
    private final TaskRepository taskRepository;
    private final PointRepository pointRepository;
    private final ItemRepository itemRepository;
    private final BomAccountRepository bomAccountRepository;
    private final ItemKeyService itemKeyService;

    @Log("导出数据")
    @ApiOperation("导出数据")
    @GetMapping(value = "/download")
    @AnonymousAccess
    public void exportInventory(HttpServletResponse response, InventoryQueryCriteria criteria) throws Exception {
        inventoryService.download(inventoryService.queryAll(criteria), response);
    }

    @Log("导出线边数据")
    @ApiOperation("导出线边数据")
    @GetMapping(value = "/downloadXb")
    @AnonymousAccess
    public void downloadXb(HttpServletResponse response, InventoryQueryCriteria criteria) throws Exception {
        List<InventoryDto> contentList = inventoryService.queryAll(criteria);
        if(criteria.getBetc()&&criteria.getPointType().equals("HCKW")&&contentList.size()>0){
            //得到bom刻印台车
            List<Object[]> tckws=bomAccountRepository.queryTckwBom();
            Map<String, Integer> tckw_tyl=new HashMap<>();
            for(Object[] tckw:tckws){
                String key=tckw[0].toString()+tckw[1].toString()+tckw[2].toString()+tckw[3].toString();
                Integer singles =Integer.parseInt(tckw[4].toString());
                tckw_tyl.put(key,singles);
            }
            for (InventoryDto dto: contentList) {
                // 计算qty值（这里示例，具体逻辑根据业务需求）
                String key=dto.getPoint().getCode()+dto.getStockCode()+dto.getItemKey().getItem().getId()+dto.getItemKey().getPropC1();
                dto.setWeight(tckw_tyl.get(key)==null?1d:tckw_tyl.get(key)+0d);
                dto.setVolume(dto.getQuantity()/dto.getWeight());
            }
        }
        inventoryService.downloadXb(contentList, response);
    }
    @Log("导出协同数据")
    @ApiOperation("导出协同数据")
    @GetMapping(value = "/downloadXt")
    @AnonymousAccess
    public void downloadXt(HttpServletResponse response, InventoryQueryCriteria criteria) throws Exception {
        inventoryService.downloadXt(inventoryService.queryAll(criteria), response);
    }
    @Log("导出制造数据")
    @ApiOperation("导出制造数据")
    @GetMapping(value = "/downloadZz")
    @AnonymousAccess
    public void downloadZz(HttpServletResponse response, InventoryQueryCriteria criteria) throws Exception {
        List<InventoryQueryDto> all= inventoryService.queryInvAll(criteria);
        inventoryService.downloadZz(all, response);
    }

    @GetMapping
    @Log("查询inventory")
    @ApiOperation("查询inventory")
    @AnonymousAccess
    public ResponseEntity<Object> queryInventory(InventoryQueryCriteria criteria, Pageable pageable) {
//        if (criteria.getItemCodeOne() != null && criteria.getItemCode() != null) {
//            criteria.setItemCodeOne(null);
//        }
        Map<String,Object> list=inventoryService.queryAll(criteria, pageable);
        if(criteria.getBetc()&&criteria.getPointType().equals("HCKW")){
            if (list.containsKey("content") && list.get("content") instanceof List) {
                List<InventoryDto> contentList = (List<InventoryDto>) list.get("content");
                //得到bom刻印台车
                List<Object[]> tckws=bomAccountRepository.queryTckwBom();
                Map<String, Integer> tckw_tyl=new HashMap<>();
                for(Object[] tckw:tckws){
                    String key=tckw[0].toString()+tckw[1].toString()+tckw[2].toString()+tckw[3].toString();
                    Integer singles =Integer.parseInt(tckw[4].toString());
                    tckw_tyl.put(key,singles);
                }
                for (InventoryDto dto: contentList) {
                    // 计算qty值（这里示例，具体逻辑根据业务需求）
                    String key=dto.getPoint().getCode()+dto.getStockCode()+dto.getItemKey().getItem().getId()+dto.getItemKey().getPropC1();
                    dto.setWeight(tckw_tyl.get(key)==null?1d:tckw_tyl.get(key)+0d);
                    dto.setVolume(dto.getQuantity()/dto.getWeight());
                }
                // 如果需要，将修改后的列表放回原map
                list.put("content", contentList);
            }
        }
        return new ResponseEntity<>(list, HttpStatus.OK);
//        return new ResponseEntity<>(inventoryService.queryInvAll(criteria, pageable), HttpStatus.OK);
    }

    @GetMapping(value = "/queryInventoryZz")
    @Log("查询制造库存")
    @ApiOperation("查询制造库存")
    @AnonymousAccess
    public ResponseEntity<Object> queryInventoryZz(InventoryQueryCriteria criteria, Pageable pageable) {
        return new ResponseEntity<>(inventoryService.queryInvAll(criteria, pageable), HttpStatus.OK);
    }

    @PostMapping
    @Log("新增inventory")
    @ApiOperation("新增inventory")
    @PreAuthorize("@el.check('super:man')")
    public ResponseEntity<Object> createInventory(@Validated @RequestBody Inventory resources) {
        return new ResponseEntity<>(inventoryService.create(resources), HttpStatus.CREATED);
    }

    @PutMapping
    @Log("修改inventory")
    @ApiOperation("修改inventory")
    @PreAuthorize("@el.check('super:man')")
    public ResponseEntity<Object> updateInventory(@Validated @RequestBody Inventory resources) {
        //库存修改
        Inventory inventory = inventoryRepository.getById(resources.getId());
        ItemKey itemKey=inventory.getItemKey();
        if (inventory.getQuantity()>resources.getQuantity()){//以前的大于现在的
            inventoryLogService.storeInventoryLog(BizStatus.INVENTORY_ADJUST, BizStatus.REDUCE, null, inventory.getArea(), itemKey, inventory.getPoint(), inventory.getPoint(), inventory.getStock(), inventory.getStock(), inventory.getQuantity(), (inventory.getQuantity() - resources.getQuantity()),
                    inventory.getStockCode(),null,BizStatus.INVENTORY_ADJUST, inventory.getId(), inventory.getId(), resources.getDescription());
        }else {
            inventoryLogService.storeInventoryLog(BizStatus.INVENTORY_ADJUST, BizStatus.ADD, null, inventory.getArea(), itemKey, inventory.getPoint(), inventory.getPoint(), inventory.getStock(), inventory.getStock(), inventory.getQuantity(), (resources.getQuantity()-inventory.getQuantity()),
                    inventory.getStockCode(),null,BizStatus.INVENTORY_ADJUST, inventory.getId(), inventory.getId(), resources.getDescription());
        }
        inventory.setQuantity(resources.getQuantity());
        inventoryService.update(inventory);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }

    @PostMapping("/updateInvQueuedQty")
    @Log("调整占用数")
    @ApiOperation("调整占用数")
    @PreAuthorize("@el.check('super:man')")
    @Transactional
    @AnonymousAccess
    public ResponseEntity<Object> updateInvQueuedQty(@Validated @RequestBody HashMap map) {
        //库存修改
        Long id=Long.parseLong(map.get("id").toString());
        Double update_zys=Double.parseDouble(map.get("zys").toString());
        String description=map.get("description").toString();
        Inventory inv = inventoryRepository.getById(id);
        double task_zys=taskRepository.getItemKeyQty(inv.getItemKey().getId());
        if(update_zys<task_zys){
            throw  new BadRequestException("占用数量不能小于"+task_zys);
        }
        inventoryLogService.storeInventoryLog(BizStatus.INVENTORY_ADJUST, BizStatus.REDUCE, "修改占用数", inv.getArea(), inv.getItemKey(), inv.getPoint(), inv.getPoint(), inv.getStock(), inv.getStock(), inv.getQueuedQty(), (inv.getQueuedQty() - update_zys),
                null,null,BizStatus.INVENTORY_ADJUST, inv.getId(), inv.getId(), inv.getDescription());
        inv.setQueuedQty(update_zys);
        inventoryService.update(inv);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }

    @DeleteMapping
    @Log("删除inventory")
    @ApiOperation("删除inventory")
    @PreAuthorize("@el.check('super:man')")
    public ResponseEntity<Object> deleteInventory(@RequestBody Long[] ids) {
        inventoryService.deleteAll(ids);
        return new ResponseEntity<>(HttpStatus.OK);
    }

    @GetMapping(value = "/queryInv")
    @Log("查询inventory")
    @ApiOperation("查询inventory")
    @PreAuthorize("@el.check('super:man')")
    public ResponseEntity<Object> queryInv(InvQueryCriteria criteria, Pageable pageable) {
        return new ResponseEntity<>(inventoryService.queryAll(criteria), HttpStatus.OK);
    }


    @PostMapping("/knywInventory")
    @Log("库内移位")
    @ApiOperation("库内移位")
    @PreAuthorize("@el.check('super:man')")
    public ResponseEntity<Object> knywInventory(@RequestBody InvYW invYW) {
        inventoryService.kuneMovePosition(invYW);
        return new ResponseEntity<>("库内移位成功", HttpStatus.CREATED);
    }

    @PostMapping("/queryInvApp")
    @Log("APP库存查询")
    @ApiOperation("APP库存查询")
    @AnonymousAccess
    public ApiResult queryInvApp(@RequestBody ScanItemCode scan) {
        String code=scan.getItemCode();
        if(code!=null&&code.length()>=81){
            code=code.substring(3, 13);
        }
        String pointCode=scan.getPointCode();
        String[] str=pointCode.split("]");
        if(str.length>1){//固定库位标签
            pointCode=str[3];
        }
        List<RInvQuery> qs=inventoryService.queryInvApp(code,pointCode);
        return ApiResult.result(200, "", qs);
    }

    @GetMapping("/queryPickDetailXd")
    @Log("拣货确认-箱单库存记录")
    @ApiOperation("拣货确认-箱单库存记录")
    @AnonymousAccess
    public  ResponseEntity<Object> queryPickDetailXd(TaskQueryCriteria criteria){
        List<XdInventory> invs = inventoryService.queryInvForPickDetail(criteria.getPickDetailId());
        return new ResponseEntity<>(invs,HttpStatus.OK);
    }

    @PostMapping("/zzrkInv")
    @Log("制造入库")
    @ApiOperation("制造入库")
    @PreAuthorize("@el.check('super:man')")
    @AnonymousAccess
    @DuplicateSubmission(5)
    public ResponseEntity<Object> zzrkInv(@RequestBody CxjlDto cxjldto) throws Exception {
        BomAccount bomAccount=bomAccountRepository.getById(cxjldto.getBom_account_id());
        Point point=bomAccount.getZPoint();
        ItemKey itemKey = itemKeyService.getItemKey(bomAccount.getItem(), null,bomAccount.getBonded());
        Inventory inventory = inventoryService.getInventory(itemKey, point.getArea(), point, point, point.getDept(), BizStatus.ZZKW_TL,null);
        double srcQty = inventory.getQuantity();
        inventory.setQuantity(inventory.getQuantity() + cxjldto.getOrder_qty());
        inventoryService.update(inventory);
        InventoryLog inventoryLog = inventoryLogService.storeInventoryLog(BizStatus.ZZKW_RK, BizStatus.ADD, "制造入库",  point.getArea(), itemKey, inventory.getPoint(), inventory.getPoint(), null, null, srcQty, cxjldto.getOrder_qty()+0d, null, null,
                BizStatus.ZZKW_TL, bomAccount.getId(), inventory.getId(), "制造入库");
        inventoryLog.setZzkw(point);
        inventoryLogService.update(inventoryLog);
        return new ResponseEntity<>(HttpStatus.OK);
    }

    @PostMapping("/xdMoveInvApp")
    @Log("箱单移位App")
    @ApiOperation("箱单移位App")
    @PreAuthorize("@el.check('super:man')")
    @AnonymousAccess
    @DuplicateSubmission(5)
    public ResponseEntity<Object> xdMoveInvApp(@RequestBody XdMoveReq xdMoveReq) throws Exception {
        String type=xdMoveReq.getType();
        String stockCode=xdMoveReq.getStockCode();
        if(stockCode.indexOf("84")==0){
            stockCode=stockCode.substring(2);
        }

        List<Inventory> invs = inventoryRepository.queryInvStockCode(stockCode);
        if (invs.size() <= 0) {
            throw new BadRequestException("没有对应的库存");
        }
        if (type.equals("xd_move_002")) {
            String pointCode=xdMoveReq.getEwm();
            String[] str=pointCode.split("]");
            String gdItemCode=null;
            if(str.length>=3) {//固定库位标签
                pointCode = str[3];
                gdItemCode= str[0];
            }
            Point dstPoint=pointRepository.findByCode(pointCode);
            if(dstPoint==null){
                throw  new BadRequestException(pointCode + "库位不存在");
            }
            if(gdItemCode==null){
                gdItemCode=dstPoint.getItemCode();
            }
            xdMoveReq.setPointId(dstPoint.getId());
            xdMoveReq.setStockCode(stockCode);
            this.xdMoveInv(xdMoveReq);
        }
        return new ResponseEntity<>("操作成功",HttpStatus.OK);
}

    @PostMapping("/zzkwMoveInvApp")
    @Log("制造库位移位App")
    @ApiOperation("制造库位移位App")
    @PreAuthorize("@el.check('super:man')")
    @AnonymousAccess
    @DuplicateSubmission(5)
    public ResponseEntity<Object> zzkwMoveInvApp(@RequestBody ZzkwMoveReq zzkwMoveReq) throws Exception {
        String type=zzkwMoveReq.getType();
        String srcPointCode=zzkwMoveReq.getSrcPointCode();
        String dstPointCode=zzkwMoveReq.getDstPointCode();
        Point srcPoint=null;
        Point dstPoint=null;
        List<BomAccount> bs=new ArrayList<>();
        if(srcPointCode==null||srcPointCode.equals("")){
            throw  new BadRequestException("请扫描源库位");
        }
        //解析二维码内容
        String[] srcStr=srcPointCode.split("]");
        if(srcStr.length>=3) {//固定库位标签
            String pointCode = srcStr[3];
            String bomItemCode=srcStr[0];
            String bonded=srcStr[2];
            srcPoint=pointRepository.findByCode(pointCode);
            Item item=itemRepository.findByCode(bomItemCode);
            bs=bomAccountRepository.queryEwmJx(item.getId(),srcPoint.getId(),bonded);
        }else {
            srcPoint=pointRepository.findByCode(srcPointCode);
        }
        if(dstPointCode!=null&&!dstPointCode.equals("")) {
            String[] dstStr=dstPointCode.split("]");
            if(dstStr.length>=3) {//固定库位标签
                String pointCode = dstStr[3];
                String bomItemCode=dstStr[0];
                String bonded=dstStr[2];
                dstPoint=pointRepository.findByCode(pointCode);
                Item item=itemRepository.findByCode(bomItemCode);
                bs=bomAccountRepository.queryEwmJx(item.getId(),dstPoint.getId(),bonded);
            }else {
                dstPoint=pointRepository.findByCode(dstPointCode);
            }
        }
        if(bs.size()>0) {
            BomAccount bomAccount=bs.get(0);
            CxjlDto cxjlDto=new CxjlDto();
            //查询BOM，寻找收容数
            cxjlDto.setRk_id(bomAccount.getRArea().getId());
            cxjlDto.setItem_id(bomAccount.getItem().getId());
            cxjlDto.setZzkw_id(bomAccount.getZPoint().getId());
            cxjlDto.setBonded(bomAccount.getBonded());
            cxjlDto.setArea_name(bomAccount.getRArea().getName());
            cxjlDto.setPoint_code(bomAccount.getZPoint().getCode());
            cxjlDto.setItem_name(bomAccount.getItem().getName());
            cxjlDto.setItem_code(bomAccount.getItem().getCode());
            if(!type.equals("zzkc_move")) {
                return new ResponseEntity<>(cxjlDto, HttpStatus.OK);
            }
        }else{
            return new ResponseEntity<>("扫描成功", HttpStatus.OK);
        }
        if(type.equals("zzkc_move")) {
            if(bs.size()<=0) {
                throw  new BadRequestException("源库位或目标库位为制造库位");
            }
            if(srcPoint==null||dstPoint==null) {
                throw  new BadRequestException("请扫描库位");
            }
            if(!srcPoint.getType().equals(BaseStatus.ZZKW)&&(srcPoint.getArea().getName()).indexOf("盘点")<0&&(srcPoint.getArea().getName()).indexOf("临时")<=-1) {
                throw  new BadRequestException(srcPoint.getCode()+"该功能仅限于制造库位或临时库位或盘点库位");
            }
            if(!dstPoint.getType().equals(BaseStatus.ZZKW)&&(dstPoint.getArea().getName()).indexOf("盘点")<0&&(dstPoint.getArea().getName()).indexOf("临时")<0) {
                throw  new BadRequestException(dstPoint.getCode()+"该功能仅限于制造库位或临时库位或盘点库位");
            }
            BomAccount bomAccount=bs.get(0);
            Item item=bomAccount.getItem();
            double move_qty=zzkwMoveReq.getMoveQty();
            ItemKey itemKey = itemKeyService.getItemKey(item, null, bomAccount.getBonded());
            Inventory srcInventory = inventoryService.getInventory(itemKey, srcPoint.getArea(), srcPoint, srcPoint, srcPoint.getDept(), BizStatus.MOVE, null);
            if(srcInventory==null){
                throw new BadRequestException(item.getCode()+"该库位无该批次库存");
            }
            int invQty=(int)(srcInventory.getQuantity()- srcInventory.getQueuedQty());
            if(invQty<move_qty){
                throw new BadRequestException(item.getCode()+"库存可用不足");
            }
            double srcQty = srcInventory.getQuantity();
            srcInventory.setQuantity(srcInventory.getQuantity() - move_qty);
            inventoryService.update(srcInventory);
            InventoryLog inventoryLog = inventoryLogService.storeInventoryLog(BizStatus.MOVE, BizStatus.REDUCE, "制造移位APP", srcPoint.getArea(), itemKey, srcInventory.getPoint(), srcInventory.getPoint(), null, null, srcQty, move_qty + 0d, null, null,
                    BizStatus.ZZKW_MOVE, null, srcInventory.getId(), "制造移位APP");

            Inventory dstInventory = inventoryService.getInventory(itemKey, dstPoint.getArea(), dstPoint, dstPoint, dstPoint.getDept(), BizStatus.MOVE, null);
            double srcQty2 = dstInventory.getQuantity();
            dstInventory.setQuantity(dstInventory.getQuantity() + move_qty);
            inventoryService.update(dstInventory);
            InventoryLog dstInventoryLog = inventoryLogService.storeInventoryLog(BizStatus.MOVE, BizStatus.ADD, "制造移位APP", dstPoint.getArea(), itemKey, dstInventory.getPoint(), dstInventory.getPoint(), null, null, srcQty2, move_qty + 0d, null, null,
                    BizStatus.ZZKW_MOVE, null, dstInventory.getId(), "制造移位APP");

        }

        return new ResponseEntity<>("操作成功",HttpStatus.OK);
    }

    @PostMapping("/xdMoveInv")
    @Log("箱单移位")
    @ApiOperation("箱单移位")
    @PreAuthorize("@el.check('super:man')")
    @AnonymousAccess
    @DuplicateSubmission(5)
    public ResponseEntity<Object> xdMoveInv(@RequestBody XdMoveReq xdMoveReq) throws Exception {
        Point point=pointRepository.getById(xdMoveReq.getPointId());
        if(!point.getType().equals("CH")) {
            throw new BadRequestException("库位类型需为材管库位");
        }
        List<Inventory> srcInvs=inventoryRepository.queryInvStockCode(xdMoveReq.getStockCode());
        if(srcInvs.size()<=0){
            throw new BadRequestException("没有对应的库存");
        }
        for(Inventory srcInventory:srcInvs){
            double srcQty=srcInventory.getQuantity();
            Point srcPoint=srcInventory.getPoint();
            if(srcInventory.getQueuedQty()>0){
                throw new BadRequestException("已占用，不能移位");
            }
            if(point.getId().equals(srcInventory.getPoint().getId())){
                throw new BadRequestException("库位相同，不能移位");
            }
            if(point.getItemCode()!=null&&!point.getItemCode().equals("")){
                if(!point.getItemCode().equals(srcInventory.getItemKey().getItem().getCode())){
                    throw new BadRequestException("库位品番"+point.getItemCode()+"不一致，不能移位");
                }
            }
            Long invId=srcInventory.getId();
            //查找目标库存
            List<Inventory> dstInvs=inventoryRepository.queryInvXdMove(point.getId(),srcInventory.getItemKey().getId(),xdMoveReq.getStockCode());
            if(dstInvs.size()>0) {
                for (Inventory dstInventory : dstInvs) {
                    dstInventory.setArea(point.getArea());
                    dstInventory.setPoint(point);
                    dstInventory.setPointCode(point.getCode());
                    dstInventory.setQuantity(srcQty);
                    inventoryRepository.save(dstInventory);
                    invId=dstInventory.getId();
                }
                srcInventory.setQuantity(0d);
                inventoryRepository.save(srcInventory);
            }else{
                //如果没有直接将现有数据换成该目标库位
                srcInventory.setArea(point.getArea());
                srcInventory.setPoint(point);
                srcInventory.setPointCode(point.getCode());
                inventoryRepository.save(srcInventory);
            }
            InventoryLog inventoryLog = inventoryLogService.storeInventoryLog(BizStatus.XD_MOVE, BizStatus.REDUCE, "箱单移位",  point.getArea(), srcInventory.getItemKey(), srcPoint, point, null, null, srcQty, srcInventory.getQuantity(), xdMoveReq.getStockCode(), null,
                    BizStatus.XD_MOVE, null, invId, "箱单移位");
        }
        return new ResponseEntity<>("操作成功",HttpStatus.OK);
    }
}