package com.prolog.cs.biz.outbound.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.netflix.hystrix.strategy.concurrency.HystrixRequestContext;
import com.prolog.cs.biz.outbound.model.dto.check.CheckConfirmDTO;
import com.prolog.cs.biz.outbound.model.vo.check.InnerCheckConfirmCheckVO;
import com.prolog.cs.biz.outbound.service.InnerCheckV2Service;
import com.prolog.entity.vo.ApplyForPickSlideVO;
import com.prolog.framework.authority.util.HystrixVarUtil;
import com.prolog.framework.common.message.RestMessage;
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.Map;

@RunWith(SpringRunner.class)
@SpringBootTest
@WebAppConfiguration
public class InnerCheckV2ServiceImplTest {

    @Autowired
    private InnerCheckV2ServiceImpl InnerCheckV2ServiceImpl;

    @Autowired
    private InnerCheckV2Service innerCheckService;

    @Autowired
    private PickTaskAppServiceImpl pickTaskAppService;

    @Before
    public void before() throws Exception {
        HystrixRequestContext context = HystrixRequestContext.initializeContext();
        HystrixVarUtil.setUserKey("yj-test");
    }

    @After
    public void after() throws Exception {
    }

    @Test//System.out.println(JSON.toJSONString(InnerCheckV2ServiceImpl.getCurrentContainer()));
    public void testGetCurrentContainer() throws Exception {

    }

    @Test//System.out.println(JSON.toJSONString(InnerCheckV2ServiceImpl.queryLcl()));
    public void testQueryLcl() throws Exception {
        String s = "{\n" +
                "  \"billGroupId\": \"XTDSP0015\",\n" +
                "  \"containerCode\": \"106\",\n" +
                "  \"itemBarcode\": \"\",\n" +
                "  \"lclNo\": \"\",\n" +
                "  \"pickTaskDId\": \"\",\n" +
                "  \"qty\": 1,\n" +
                "  \"stationCode\": \"FH01\",\n" +
                "  \"stationId\": \"790680498946052096\",\n" +
                "  \"userNames\": [\n" +
                "    null\n" +
                "  ],\n" +
                "  \"pickTaskId\": \"808321712822865920\",\n" +
                "  \"workCode\": \"yjtest001\",\n" +
                "  \"warehouseId\": \"759131791285161985\",\n" +
                "  \"innerCheckTaskDVOS\": [\n" +
                "    {\n" +
                "      \"warehouseId\": \"759131791285161985\",\n" +
                "      \"billType\": \"1\",\n" +
                "      \"itemId\": \"20220928\",\n" +
                "      \"consignorId\": \"748963439141064799\",\n" +
                "      \"shipperId\": \"XT00001285\",\n" +
                "      \"minSu\": null,\n" +
                "      \"middleSu\": null,\n" +
                "      \"maxSu\": null,\n" +
                "      \"isSupervise\": 0,\n" +
                "      \"noSuperviseReason\": \"scanSupervisionCodeStage==1 stage=2\",\n" +
                "      \"pickTaskDId\": \"808321712822865921\",\n" +
                "      \"billDId\": \"808320691653713920\",\n" +
                "      \"cargoOwnerName\": \"\",\n" +
                "      \"caseConversionRate\": \"\",\n" +
                "      \"isCaseOrPiece\": 1,\n" +
                "      \"billId\": \"808320691540467712\",\n" +
                "      \"srcLineId\": null,\n" +
                "      \"srcId\": null,\n" +
                "      \"billCode\": \"XTDSP0015\",\n" +
                "      \"batchNum\": \"790191059320836096\",\n" +
                "      \"qty\": 3,\n" +
                "      \"pickQty\": 3,\n" +
                "      \"checkQty\": 3,\n" +
                "      \"expiredDate\": \"2025-05-05 00:00:00\",\n" +
                "      \"productionDate\": \"2022-11-16 00:00:00\",\n" +
                "      \"itemCode\": \"20220928\",\n" +
                "      \"itemName\": \"999普通品\",\n" +
                "      \"redReason\": \"\",\n" +
                "      \"itemHealthIsDouble\": \"0\",\n" +
                "      \"itemCategoryCode\": null,\n" +
                "      \"redQty\": 0,\n" +
                "      \"lotNo\": \"20221116\",\n" +
                "      \"innerCheckDId\": null,\n" +
                "      \"waveStorageId\": \"808321710221824000\",\n" +
                "      \"check2Qty\": \"\",\n" +
                "      \"checkTime\": \"2023-01-09 10:27:28\",\n" +
                "      \"checker1\": null,\n" +
                "      \"checker2\": null,\n" +
                "      \"pickerName\": \"鹰江用户\",\n" +
                "      \"pickTime\": \"2023-01-05 10:24:58\",\n" +
                "      \"uom\": \"箱\",\n" +
                "      \"volume\": \"14.5170\",\n" +
                "      \"weight\": \"\",\n" +
                "      \"spec\": null,\n" +
                "      \"locatorCode\": \"LHK-001\",\n" +
                "      \"pickTaskType\": 1,\n" +
                "      \"salespersonName\": \"漠叔\",\n" +
                "      \"createby\": \"OMS\",\n" +
                "      \"paymentType\": null,\n" +
                "      \"remark\": \"123\",\n" +
                "      \"barcodeDId\": \"11032301060006PX\",\n" +
                "      \"lclNo\": \"2\",\n" +
                "      \"lclQty\": 3,\n" +
                "      \"specification\": \"支架14.5cm*6.5cm\",\n" +
                "      \"manufacturerId\": \"鹰江\",\n" +
                "      \"countryOriginId\": \"湖北仙桃\",\n" +
                "      \"itemHealthApprovalNbr\": \"国药准字H20000543\",\n" +
                "      \"itemIsValuable\": 0,\n" +
                "      \"itemIsFragile\": 0,\n" +
                "      \"itemIsRecheck\": 1,\n" +
                "      \"isBacteria\": 0,\n" +
                "      \"isCheck\": 1,\n" +
                "      \"isDelegate\": 0,\n" +
                "      \"isLock\": null,\n" +
                "      \"isHosted\": 1,\n" +
                "      \"itemIsSeque\": \"\",\n" +
                "      \"itemHealthCategoryName\": \"普通药品\",\n" +
                "      \"itemHealthListedLicensor\": \"2020R002077\",\n" +
                "      \"itemHealthProduceLicense\": \"\",\n" +
                "      \"itemHealthRegisterNbr\": \"\",\n" +
                "      \"itemHealthRecordNbr\": \"\",\n" +
                "      \"pieceBarcode\": null,\n" +
                "      \"caseBarcode\": null,\n" +
                "      \"barcodeOld\": null,\n" +
                "      \"barCode\": \"19982311\",\n" +
                "      \"erpItemBarcode\": \"\",\n" +
                "      \"itemAssistantCode\": \"YCXYYKZ\",\n" +
                "      \"flowStatus\": \"5\",\n" +
                "      \"cargoOwnerCode\": \"\",\n" +
                "      \"_oid\": \"11032301060006PX-808321712822865921\",\n" +
                "      \"_row_count\": 1,\n" +
                "      \"uomQty\": \"\",\n" +
                "      \"itemHealthCategory\": \"\"\n" +
                "    }\n" +
                "  ],\n" +
                "  \"boxType\": \"\",\n" +
                "  \"operateCode\": \"yjtest001\"\n" +
                "}";
        CheckConfirmDTO checkConfirmDTO = JSON.parseObject(s, CheckConfirmDTO.class);
        RestMessage<InnerCheckConfirmCheckVO> innerCheckConfirmCheckVORestMessage =innerCheckService.confirmCheck(checkConfirmDTO);

        System.out.println("1111111");
    }
    @Test//System.out.println(JSON.toJSONString(InnerCheckV2ServiceImpl.makeCheckRed()));
    public void testMakeCheckRed() throws Exception {

    }
    @Test//System.out.println(JSON.toJSONString(InnerCheckV2ServiceImpl.validRedFunc()));
    public void testValidRedFunc() throws Exception {

    }
    @Test//System.out.println(JSON.toJSONString(InnerCheckV2ServiceImpl.redFunc()));
    public void testRedFunc() throws Exception {

    }
    @Test//System.out.println(JSON.toJSONString(InnerCheckV2ServiceImpl.checkItemByNum()));
    public void testCheckItemByNum() throws Exception {

    }
    @Test//System.out.println(JSON.toJSONString(InnerCheckV2ServiceImpl.checkItem()));
    public void testCheckItem() throws Exception {

    }
    @Test//System.out.println(JSON.toJSONString(InnerCheckV2ServiceImpl.validInnerCheckFunc()));
    public void testValidInnerCheckFunc() throws Exception {

    }
    @Test//System.out.println(JSON.toJSONString(InnerCheckV2ServiceImpl.updatePickupDInnerCheckInfoFunc()));
    public void testUpdatePickupDInnerCheckInfoFunc() throws Exception {

    }
    @Test//System.out.println(JSON.toJSONString(InnerCheckV2ServiceImpl.createBarcodeFunc()));
    public void testCreateBarcodeFunc() throws Exception {

    }
    @Test//System.out.println(JSON.toJSONString(InnerCheckV2ServiceImpl.updateLcl()));
    public void testUpdateLcl() throws Exception {

    }
    @Test//System.out.println(JSON.toJSONString(InnerCheckV2ServiceImpl.updateLclQtyTemp()));
    public void testUpdateLclQtyTemp() throws Exception {

    }
    @Test//System.out.println(JSON.toJSONString(InnerCheckV2ServiceImpl.lclFunc()));
    public void testLclFunc() throws Exception {
        pickTaskAppService.getTaskHListByPickOrder("770720011168911360","759131791285161985",null,1,15);
        System.out.println("1111");
    }

    @Test
    public void applyForPickSlideTest() {
        String msg = "{\n" +
                "  \"warehouseId\": \"901884530611326976\",\n" +
                "  \"enterpriseId\": \"900356013474058240\",\n" +
                "  \"mailNo\": \"SF7444513559990\"\n" +
                "}";
        ApplyForPickSlideVO vo = JSONObject.parseObject(msg, ApplyForPickSlideVO.class);
        Map<String, Object> map = innerCheckService.applyForPickSlide(vo);
        System.out.println(JSONObject.toJSONString(map));
    }
}
