package com.prolog.upcloud.base.wh.operate.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.prolog.entity.vo.OutboundTaskCallbackVO;
import com.prolog.upcloud.base.wh.operate.service.InvCheckService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.List;

@SpringBootTest
@RunWith(SpringRunner.class)
public class InvCheckServiceImplTest {

    @Resource
    private InvCheckService checkService;

    @Test
    public void updateStatus4CheckByEis() {
        String msg = "[\n" +
                "  {\n" +
                "    \"containerNo\": \"959\",\n" +
                "    \"msgId\": \"7e808ec5-86ff-4edc-8352-e281f7cc5732\",\n" +
                "    \"weight\": null,\n" +
                "    \"wholeFlag\": null,\n" +
                "    \"subList\": [\n" +
                "      {\n" +
                "        \"taskId\": \"904360184343351296\",\n" +
                "        \"taskLineId\": \"757325431195176960\",\n" +
                "        \"workType\": \"20\",\n" +
                "        \"businessType\": \"DO_SO\",\n" +
                "        \"eisTaskId\": \"C26570D01CD6480FAB881EAA04D25A05\",\n" +
                "        \"itemId\": \"2155036\",\n" +
                "        \"lotId\": \"904352619110207488\",\n" +
                "        \"packId\": \"UOM00053\",\n" +
                "        \"ownerId\": \"748963439141064888\",\n" +
                "        \"qty\": 1,\n" +
                "        \"enterpriseId\": \"891063172566487040\",\n" +
                "        \"warehouseId\": \"891420072483098624\",\n" +
                "        \"billNo\": \"904347633483649024\",\n" +
                "        \"wmsLocationCode\": \"MJZ\",\n" +
                "        \"originalArea\": null,\n" +
                "        \"locNo\": null,\n" +
                "        \"targetArea\": \"\",\n" +
                "        \"targetLocation\": \"\"\n" +
                "      }\n" +
                "    ]\n" +
                "  }\n" +
                "]";
        List<OutboundTaskCallbackVO> list = JSONObject.parseArray(msg, OutboundTaskCallbackVO.class);
        list.forEach(checkService::updateStatus4CheckByEis);
    }
}