package com.prolog.cs.biz.outbound.controller; 

import com.alibaba.fastjson.JSONObject;
import com.netflix.hystrix.strategy.concurrency.HystrixRequestContext;
import com.prolog.cs.biz.outbound.dao.WmsTaskOutBackMapper;
import com.prolog.cs.biz.outbound.model.dto.InfTaskOutBackDTO;
import com.prolog.cs.biz.outbound.model.dto.InvMoveTaskPrintDto;
import com.prolog.cs.biz.outbound.model.dto.PrintAgainVo;
import com.prolog.cs.biz.outbound.model.dto.TaskPrintAgainVo;
import com.prolog.cs.biz.outbound.model.print.PrintDataWithMark;
import com.prolog.cs.biz.outbound.model.vo.InfTaskOutBackVO;
import com.prolog.cs.biz.outbound.resource.EisOutBoundResource;
import com.prolog.framework.authority.util.HystrixVarUtil;
import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.core.pojo.Page;
import lombok.extern.slf4j.Slf4j;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest
@WebAppConfiguration 
public class BillControllerTest { 

    @Autowired
    private EisOutBoundResource resource;
    @Autowired
    private WmsTaskOutBackMapper mapper;
    @Autowired
    private OmsDoBillHController billHController;
    @Autowired
    private PickTaskController pickTaskController;
    
    @Before
    public void before() throws Exception { 
        HystrixRequestContext context = HystrixRequestContext.initializeContext();
        HystrixVarUtil.setUserKey("hnsyy-test");
    } 
    
    @After
    public void after() throws Exception { 
    } 

    @Test//System.out.println(JSON.toJSONString(BillController.updateBills()));
    public void testUpdateBills() throws Exception {
//        RestMessage<String> msg = billHController.listRefBill(50);
//        System.out.println(JSONObject.toJSON(msg));
    } 
    @Test//System.out.println(JSON.toJSONString(BillController.query()));
    public void testQuery() throws Exception {
        String param = "{\"pageNum\":1,\"pageSize\":15,\"taskId\":\"\",\"billno\":\"\",\"startTime\":\"2021-09-05\",\"endTime\":\"\",\"containerno\":\"\",\"shipno\":\"\",\"templateTypes\":[]}";
        // RestMessage<Page<InvMoveTaskPrintDto>> msg = pickTaskController.taskListForPrintAgain(JSONObject.parseObject(param, PrintAgainVo.class));
        // log.info("查询结果：{}", JSONObject.toJSONString(msg));
    }
    @Test//System.out.println(JSON.toJSONString(BillController.queryForMerge()));
    public void testQueryForMerge() throws Exception {
        String param = "{\"billnos\":[\"741338168852094976\",\"741627975775952896\"],\"taskIds\":[\"741358090402320384\",\"741628590798065664\"],\"templateTypes\":[\"2\"],\"warehouseid\":\"759131791285161984\"}";
        RestMessage<List<PrintDataWithMark>> msg = pickTaskController.taskPrintAgain(JSONObject.parseObject(param, TaskPrintAgainVo.class));
        log.info("查询结果：{}", JSONObject.toJSONString(msg));
    }

    @Test//System.out.println(JSON.toJSONString(BillController.queryForMerge()));
    public void testPrint4() throws Exception {
        String param = "{\"billnos\":[\"760259166506721291\"],\"taskIds\":[null],\"warehouseid\":\"759131791285161984\"}";
        RestMessage<List<PrintDataWithMark>> msg = pickTaskController.billPrintAgain(JSONObject.parseObject(param, TaskPrintAgainVo.class));
        log.info("查询结果：{}", JSONObject.toJSONString(msg));
    }

    @Test//System.out.println(JSON.toJSONString(BillController.query()));
    public void test3() throws Exception {
        String param = "{\"pageNum\":1,\"pageSize\":15,\"taskId\":\"\",\"billno\":\"\",\"startTime\":\"2021-09-05\",\"endTime\":\"\",\"containerno\":\"\",\"shipno\":\"\",\"templateTypes\":[]}";
        /*RestMessage<Page<InvMoveTaskPrintDto>> msg = pickTaskController.billListForPrintAgain(JSONObject.parseObject(param, PrintAgainVo.class));
        log.info("查询结果：{}", JSONObject.toJSONString(msg));*/
    }
    @Test//System.out.println(JSON.toJSONString(BillController.merge()));
    public void testMerge() throws Exception {
        InfTaskOutBackDTO infTaskOutBackDTO = new InfTaskOutBackDTO();
        String param = "{\"billNo\":\"whc002\",\"businessType\":\"1\",\"expDate\":1664553600000,\"itemCode\":\"ITEM002\",\"itemName\":\"思源肠炎宁\",\"locCode\":\"LTK01-010102\",\"lotNo\":\"20211230\",\"msgId\":\"2d692f1ba4b84aef9fedf26b5c967de7\",\"ownerId\":\"ow002\",\"qty\":60.00,\"seqNo\":\"740556483502149632\",\"warehouseId\":\"whc002\",\"wmslocationCode\":\"ASRS02-010101\",\"workType\":\"10\",\"yieldDate\":1633017600000}";
//        RestMessage<?> msg = pickTaskController.infTaskOutBack(infTaskOutBackDTO);
//        log.info("查询结果：{}", JSONObject.toJSONString(msg));
    } 
        
} 
