package com.ruoyi.web.controller.shipping.controller;


import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.warehouseBusiness.domain.TWarehouseBills;
import com.ruoyi.warehouseBusiness.service.ITWarehouseBillsService;
import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/splitsingle/updateWareSign")
public class TSignController extends BaseController {

    //主表service
    @Autowired
    private ITWarehouseBillsService tWarehousebillsService;

    /**
     * 旧单的id与新单的所有的信息，拆成两份，旧单的箱量为原数量减去新单的数量
     * @param tWarehousebills            仓库出入表
     * @param tWarehousebillsCntr        订单从表
     * @param tWarehousebillsCntritems   箱明细表
     * @return
     */
    @PostMapping("/wareChaiSign")
    public AjaxResult updateSignChai(@RequestParam String tWarehousebills,
                                     @RequestParam String tWarehousebillsCntr,
                                     @RequestParam String tWarehousebillsCntritems,
                                     @RequestParam("fOriginalbillno") String fOriginalbillno) {
        if (StringUtils.isEmpty(tWarehousebills)){
            return AjaxResult.error("未找到订单主表信息,请确认");
        }
        if (StringUtils.isEmpty(tWarehousebillsCntr)){
            return AjaxResult.error("未找到订单从表信息,请确认");
        }
        if (StringUtils.isEmpty(tWarehousebillsCntritems)){
            return AjaxResult.error("未找到箱明细表信息,请确认");
        }
        //旧单可以拆，新单不可以拆，拆出的新单的箱数
        return tWarehousebillsService.updateMessageSign(tWarehousebills,tWarehousebillsCntr,tWarehousebillsCntritems,fOriginalbillno);
    }

}