package com.jwipc.portal;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.google.common.collect.Sets;
import com.jwipc.order.entity.PurchaseOrderDevPlan;
import com.jwipc.order.logic.DeliveryOrderLogic;
import com.jwipc.order.service.IPurchaseOrderDetailService;
import com.jwipc.order.service.IPurchaseOrderDevPlanService;
import com.jwipc.test.BaseTest;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Set;

/**
 * <p> </p>
 *
 * @author ZhangJie
 * @version 1.0
 * @since JDK 1.8
 */
@Slf4j
public class PurchaseOrderTest extends BaseTest {
    @Autowired
    private IPurchaseOrderDetailService purchaseOrderDetailService;
    @Autowired
    private DeliveryOrderLogic deliveryOrderLogic;

    @Autowired
    private IPurchaseOrderDevPlanService purchaseOrderDevPlanService;

//    @Test
//    public void test() {
//        final List<PurchaseOrderDetail> list = purchaseOrderDetailService.list();
//        for (PurchaseOrderDetail purchaseOrderDetail : list) {
//            purchaseOrderDetailService.update(new LambdaUpdateWrapper<PurchaseOrderDetail>()
//                    .set(PurchaseOrderDetail::getId, IdWorker.getId())
//                    .eq(PurchaseOrderDetail::getOrderRow, purchaseOrderDetail.getOrderRow())
//                    .eq(PurchaseOrderDetail::getOrderCode, purchaseOrderDetail.getOrderCode()));
//        }
//    }

    @Test
    public void ttt(){
        Set<String> codes = Sets.newHashSet("C2461200001");
        deliveryOrderLogic.complateDelivery(codes);
    }

    @Test
    public void tttt(){
        //先取最早的日期
        final PurchaseOrderDevPlan one = purchaseOrderDevPlanService.getOne(
                new LambdaQueryWrapper<>(PurchaseOrderDevPlan.class)
                        .eq(PurchaseOrderDevPlan::getPurchaseOrder, "4000001191")
                        .eq(PurchaseOrderDevPlan::getLineItem, "10")
                        .apply("(schedule_delivery_quantity-received_quantity)>0")
                        .orderByAsc(PurchaseOrderDevPlan::getLastRequireDate), false);
        log.info("{}",one);
    }

}
