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.core.SpringUtils;
import com.prolog.cs.biz.outbound.dao.PickTaskDMapper;
import com.prolog.cs.biz.outbound.model.OmsDoBillHDO;
import com.prolog.cs.biz.outbound.model.PickTaskD;
import com.prolog.cs.biz.outbound.model.entity.WaveStorageDO;
import com.prolog.cs.biz.outbound.resource.PowerResource;
import com.prolog.cs.biz.outbound.service.MqOutBoundConsumer;
import com.prolog.cs.platform.power.model.Employee;
import com.prolog.entity.vo.CompleteTaskVO;
import com.prolog.entity.vo.OrderBindingGridFeedbackVO;
import com.prolog.entity.vo.OutboundCheckResultCallbackVO;
import com.prolog.framework.authority.core.dto.UserDTO;
import com.prolog.framework.authority.user.UserTemplate;
import com.prolog.framework.authority.util.HystrixVarUtil;
import com.prolog.framework.common.message.RestMessage;
import com.prolog.upcloud.base.inventory.vo.InvStockPartCheckOut;
import org.assertj.core.util.Lists;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.core.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.nio.charset.StandardCharsets;
import java.util.*;

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

    @Autowired
    private PickTaskServiceImpl pickTaskService;
    @Resource
    private PickTaskDMapper pickTaskDMapper;
    @Resource
    private MqOutBoundConsumer consumer;
    @Resource
    PowerResource powerResource;
    @Resource
    UserTemplate userTemplate;

    @Before
    public void before() throws Exception {
        HystrixRequestContext.initializeContext();
        HystrixVarUtil.setUserKey("qingniu-wms");
    }

    @After
    public void after() throws Exception {
    }

    public void testPrintWholeLabels() throws Exception {
        List<String> pickTaskDIds = new ArrayList<>();
        //pickTaskDIds.add("704316706332078080");
        pickTaskDIds.add("731236934801821696");
        pickTaskDIds.add("731236934801821697");
        pickTaskDIds.add("731236934801821698");
        pickTaskDIds.add("731236934801821699");
        pickTaskDIds.add("731236934801821700");
        pickTaskDIds.add("731236934801821701");
        pickTaskDIds.add("731236934801821702");
        pickTaskDIds.add("731236934801821703");
        pickTaskDIds.add("731236934801821704");
        pickTaskDIds.add("731236934801821705");
        List<String> barcodeIds = new ArrayList<>();
        //pickTaskDIds.add("704316706332078080");
        //barcodeIds.add("729066700984684544");
        //{"warehouseId":"726788113300975616","type":0,"pickTaskDIds":["729064261980131328"],"barcodeIds":["729066700984684544","729066700867244032","729066700925964288"]}
        //PickTaskServiceImpl.printWholeLabels(pickTaskDIds,"599581702716788736",0,"thl");
        System.out.println(JSON.toJSONString(pickTaskService.printWholeLabels(pickTaskDIds, barcodeIds,
                "726788113300975616", 0, "thl")));
    }

    @Test
    public void testQueryOutboundDataToOms() throws Exception {
        List<String> omsBillIds = new ArrayList<>();
        omsBillIds.add("ZDCTEST1012001");
        System.out.println(JSON.toJSONString(pickTaskService.queryOutboundDataToOms(omsBillIds)));
    }

    @Test
    public void outboundTaskCallback() {
        String msg = "{\n" +
                "        \"containerNo\": \"100011\",\n" +
                "        \"msgId\": \"7e808ec5-86ff-4edc-8352-e281f7cc5732\",\n" +
                "        \"weight\": null,\n" +
                "        \"wholeFlag\": null,\n" +
                "        \"subList\": [\n" +
                "            {\n" +
                "                \"taskId\": \"904360184343351296\",\n" +
                "                \"taskLineId\": \"904360184355360768\",\n" +
                "                \"workType\": \"20\",\n" +
                "                \"businessType\": \"DO_SO\",\n" +
                "                \"eisTaskId\": \"C26570D01CD6480FAB881EAA04D25A05\",\n" +
                "                \"itemId\": \"2155036\",\n" +
                "                \"lotId\": \"904352619110207488\",\n" +
                "                \"packId\": \"UOM00053\",\n" +
                "                \"ownerId\": \"748963439141064888\",\n" +
                "                \"qty\": 10,\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" +
                "    }";
        Message message = new Message(msg.getBytes(StandardCharsets.UTF_8), null);

        consumer.outboundTaskCallback(message, null);
    }

    @Test
    public void testIsAllDone() {
        PickTaskServiceImpl service = SpringUtils.getBeansByType(PickTaskServiceImpl.class);
        List<PickTaskD> list = pickTaskDMapper.getPickTaskDListByPickTaskIds(new String[]{"904360184343351296"});
        list.remove(7);
        List<PickTaskD> list2 = pickTaskDMapper.getPickTaskDListByPickTaskIds(new String[]{"904360184343351296"});
        System.out.println(Arrays.toString(service.isAllDone(list, list2)));
    }

    @Test
    public void getEmployeesTest() {
//        List<Employee> employees = pickTaskService.getEmployees(new String[]{"0711"}, "901884530611326976", "900356013474058240");
//        Assert.assertEquals(1, employees.size());
        RestMessage<Employee> msg = powerResource.getByNum("0711", "901884530611326976", "900356013474058240");
        System.out.println(JSONObject.toJSONString(msg));
    }

    @Test
    public void orderBindingGridFeedbackTest() {
        String msg = orderBindingGridFeedbackTestParams();
        OrderBindingGridFeedbackVO vo = JSONObject.parseObject(msg, OrderBindingGridFeedbackVO.class);
        pickTaskService.orderBindingGridFeedback(vo);
    }

    private static String orderBindingGridFeedbackTestParams() {
        String msg = "{\"msgId\":\"b46a2fd14f494e1ca0a4135918849b91\",\"warehouseId\":\"901884530611326976\",\"taskId\":\"960545693633269760\",\"billNo\":\"CKD202402291135\",\"enterpriseId\":\"900356013474058240\",\"gridNo\":[\"003\"]}";
        return msg;
    }

    @Test
    public void warpPendingTasksTest() {

//        String msg = "[{\"billNo\":\"CKD202402261422\",\"businessType\":\"DO_SO\",\"containerNo\":\"60000485\",\"employeeId\":\"0711\",\"inventoryQty\":28.0,\"isLack\":\"1\",\"itemId\":\"949411323110887424\",\"lackQty\":0.0,\"lotId\":\"957762801894559744\",\"msgId\":\"8a09c89b-eff2-41a3-93df-b83f69a64672\",\"ownerId\":\"748963439141064888\",\"packId\":\"949411323236716544\",\"taskId\":\"959240563805835269\",\"taskLineId\":\"959523115724050432\",\"warehouseId\":\"901884530611326976\",\"wmsLocationCode\":\"AGVL\",\"workType\":\"20\"}]";
        String msg = "[{\"billNo\":\"CKD202402261422\",\"businessType\":\"DO_SO\",\"containerNo\":\"60000485\",\"employeeId\":\"0711\",\"inventoryQty\":2.0,\"isLack\":\"1\",\"itemId\":\"949411323110887424\",\"lackQty\":0.0,\"lotId\":\"957762801894559744\",\"msgId\":\"6bfc76cd-9aed-461d-bd04-eeb01a91e6df\",\"ownerId\":\"748963439141064888\",\"packId\":\"949411323236716544\",\"taskId\":\"959240563805835269\",\"taskLineId\":\"959523115724050432\",\"warehouseId\":\"901884530611326976\",\"wmsLocationCode\":\"AGVL\",\"workType\":\"20\"}]";

        List<CompleteTaskVO> list = JSONObject.parseArray(msg, CompleteTaskVO.class);

        String[] pickTaskDIds = list.stream().map(CompleteTaskVO::getTaskLineId).distinct().toArray(String[]::new);
        cn.hutool.core.lang.Assert.notEmpty(pickTaskDIds, "EIS回告任务明细ID数据出错");

        List<PickTaskD> tasks = pickTaskDMapper.findByIds(PickTaskD.class, pickTaskDIds, null);
        cn.hutool.core.lang.Assert.notEmpty(tasks, "获取拣货任务失败");

        List<PickTaskD> taskDS = pickTaskService.warpPendingTasks(list, tasks);
        System.out.println(JSONObject.toJSONString(taskDS));
    }

    @Test
    public void packCostStockParams() {
        String msg = getPackCostStockParamsMsg();
        String msg1 = getPackCostStockParamsMsg1();
        List<PickTaskD> pendingTasks = JSONObject.parseArray(msg, PickTaskD.class);
        List<WaveStorageDO> storages = JSONObject.parseArray(msg1, WaveStorageDO.class);
        List<InvStockPartCheckOut> list = pickTaskService.packCostStockParams(pendingTasks, storages);
        System.out.println(JSONObject.toJSONString(list));
    }

    private static String getPackCostStockParamsMsg() {
        return "[{\"pick_task_d_id\":\"939874730926804992\",\"pick_task_id\":\"939874730927378432\",\"wave_storage_id\":\"939874730381545472\",\"warehouse_id\":\"901884530611326976\",\"qty\":6.0000,\"gmt_create\":\"2024-01-03 10:47:43\",\"enterprise_id\":\"900356013474058240\",\"whole_num\":\"\",\"print_count\":0,\"flow_status\":\"1\",\"pick_task_type\":1,\"src_line_id\":\"CKD202401030938\",\"src_id\":\"CKD202401030938\",\"src_code\":\"CKD202401030938\",\"bill_d_id\":\"939874707551948800\",\"bill_id\":\"939874707530977280\",\"item_id\":\"ssssslhyp002\",\"batch_id\":\"939609327545749506\",\"locator_id\":\"894288698064113664\",\"warehouse_area_code\":\"AGVL\",\"pick_model\":\"Device\"}]";
    }

    private static String getPackCostStockParamsMsg1() {
        return "[{\"id\":\"939874730381545472\",\"item_id\":\"ssssslhyp002\",\"warehouse_id\":\"901884530611326976\",\"batch_id\":\"939609327545749506\",\"batch_num\":\"939609327545749507\",\"qty\":0.0000,\"uom\":\"袋\",\"locator_id\":\"894288698064113664\",\"locator_type\":\"1\",\"expired_date\":\"2024-08-24 00:00:00\",\"production_date\":\"2022-08-24 00:00:00\",\"shelf_life_days\":700,\"volume\":27000.0000,\"warehouse_area_code\":\"AGVL\",\"pick_model\":\"Device\",\"pick_piece_group\":\"\",\"bill_id\":\"939874707530977280\",\"bill_d_id\":\"939874707551948800\",\"creator\":\"900356014887538688\",\"creator_name\":\"qingniu-wms\",\"gmt_create\":\"2024-01-03 10:47:43\",\"modifier\":\"900356014887538688\",\"modifier_name\":\"qingniu-wms\",\"gmt_modified\":\"2024-01-03 10:47:43\",\"enterprise_id\":\"900356013474058240\",\"status\":\"1\",\"wave_id\":\"939874706440458240\",\"locator_code\":\"AGVL_LOC_LHQ_001\",\"manufacturer_lot_num\":\"202310181149\",\"bldg_name\":\"建筑物001\",\"bldg_id\":\"901884621275402240\",\"type\":0,\"area_category\":\"AGVL\",\"expired_date_show\":\"20240824\",\"production_date_show\":\"20220824\",\"container_code\":\"N/A\",\"is_function_room\":0,\"container_code_qty\":6.0000}]";
    }

    @Test
    public void saveSuperVisionCode() {
        String p1 = getSaveSuperVisionCode();
        OutboundCheckResultCallbackVO vo = JSONObject.parseObject(p1, OutboundCheckResultCallbackVO.class);
        OmsDoBillHDO omsDoBillHDO = getOmsDoBillHDO();
        Employee employee = new Employee();
        employee.setUserId("7011");
        employee.setUsername("Ky");
        pickTaskService.saveSuperVisionCode(vo, omsDoBillHDO, employee, Collections.EMPTY_LIST);
    }

    private static String getSaveSuperVisionCode() {
        String p1 = "{\n" +
                "    \"warehouseId\": \"901884530611326976\",\n" +
                "    \"enterpriseId\": \"900356013474058240\",\n" +
                "    \"taskId\": \"925086724714582016\",\n" +
                "    \"billNo\": \"CKD202311231519\",\n" +
                "    \"printUrl\": \"http://172.17.200.67:33314/barcodelabel.grf\",\n" +
                "    \"taskLineId\": \"925086724714008585\",\n" +
                "    \"employeeId\": \"0711\",\n" +
                "    \"subList\":\n" +
                "    [\n" +
                "        {\n" +
                "            \"ownerId\": \"748963439141064888\",\n" +
                "            \"itemId\": \"ssssslhyp008\",\n" +
                "            \"lotId\": \"925083898701025284\",\n" +
                "            \"packId\": \"ssssslhyp008\",\n" +
                "            \"qty\": 5,\n" +
                "            \"drugSupervisionCode\":\n" +
                "            [\n" +
                "                \"87202311232023112301\",\n" +
                "                \"87202311232023112302\",\n" +
                "                \"87202311232023112303\",\n" +
                "                \"87202311232023112304\",\n" +
                "                \"87202311232023112305\"\n" +
                "            ]\n" +
                "        }\n" +
                "    ]\n" +
                "}";
        return p1;
    }

    private static OmsDoBillHDO getOmsDoBillHDO() {
        String p2 = "[\n" +
                "  {\n" +
                "    \"p_enterpriseid\": \"900356013474058240\",\n" +
                "    \"billid\": \"CKD202311091702\",\n" +
                "    \"billno\": \"CKD202311091702\",\n" +
                "    \"billtype\": \"99\",\n" +
                "    \"ref_billtype\": \"1\",\n" +
                "    \"ref_billid\": \"CKD202311091702\",\n" +
                "    \"ref_billno\": \"CKD202311091702\",\n" +
                "    \"consignorid\": \"748963439141064888\",\n" +
                "    \"consignorname\": \"江西青牛\",\n" +
                "    \"branchid\": \"901884530611326976\",\n" +
                "    \"branchcode\": \"qingniuwh\",\n" +
                "    \"branchname\": \"青牛主仓\",\n" +
                "    \"branchareaid\": null,\n" +
                "    \"brancharea\": null,\n" +
                "    \"branch_address\": null,\n" +
                "    \"shipper_type\": \"2\",\n" +
                "    \"shipperid\": \"XT00001166\",\n" +
                "    \"shippername\": \"师宗县老百姓大药房连锁有限公司\",\n" +
                "    \"cust_person\": \"曾先生\",\n" +
                "    \"cust_person_tel\": \"18166021234\",\n" +
                "    \"receive_country_no\": null,\n" +
                "    \"receive_country_name\": null,\n" +
                "    \"receive_province_no\": null,\n" +
                "    \"receive_province_name\": \"湖北省\",\n" +
                "    \"receive_city_no\": null,\n" +
                "    \"receive_city_name\": \"仙桃市\",\n" +
                "    \"receive_district_no\": null,\n" +
                "    \"receive_district_name\": \"南城新区\",\n" +
                "    \"receive_town_no\": null,\n" +
                "    \"receive_town_name\": \"\",\n" +
                "    \"receive_community_no\": null,\n" +
                "    \"receive_community_name\": \"1\",\n" +
                "    \"receive_address\": \"沔州大道中段29号\",\n" +
                "    \"ship_term\": null,\n" +
                "    \"arrival_mode\": \"2\",\n" +
                "    \"priority_level\": \"1\",\n" +
                "    \"ship_line_id\": null,\n" +
                "    \"carrier_id\": \"1\",\n" +
                "    \"carrier_name\": \"顺丰\",\n" +
                "    \"carrier_type\": \"1\",\n" +
                "    \"salesperson_id\": null,\n" +
                "    \"salesperson_name\": \"测试业务员\",\n" +
                "    \"status\": \"20\",\n" +
                "    \"bill_date\": \"2023-11-01 00:00:00\",\n" +
                "    \"attain_date\": null,\n" +
                "    \"examine_state\": null,\n" +
                "    \"tot_pcs\": 1.0000000,\n" +
                "    \"tot_qty\": 10.0000000,\n" +
                "    \"containers_num\": null,\n" +
                "    \"tot_box_num\": null,\n" +
                "    \"tot_weight\": 1.0000000,\n" +
                "    \"tot_volume\": 1.0000000,\n" +
                "    \"totnetamt\": null,\n" +
                "    \"totamt\": 1.0000000,\n" +
                "    \"rt_reason\": null,\n" +
                "    \"remark\": \"1\",\n" +
                "    \"closed_reason\": null,\n" +
                "    \"attr_str1\": null,\n" +
                "    \"attr_str2\": null,\n" +
                "    \"attr_str3\": null,\n" +
                "    \"attr_str4\": null,\n" +
                "    \"attr_str5\": null,\n" +
                "    \"attr_str6\": null,\n" +
                "    \"attr_str7\": null,\n" +
                "    \"attr_str8\": null,\n" +
                "    \"attr_str9\": null,\n" +
                "    \"attr_str10\": null,\n" +
                "    \"attr_num1\": null,\n" +
                "    \"attr_num2\": null,\n" +
                "    \"attr_num3\": null,\n" +
                "    \"attr_num4\": null,\n" +
                "    \"attr_num5\": null,\n" +
                "    \"attr_dte1\": null,\n" +
                "    \"attr_dte2\": null,\n" +
                "    \"attr_dte3\": null,\n" +
                "    \"attr_dte4\": null,\n" +
                "    \"attr_dte5\": null,\n" +
                "    \"createby\": \"ERP\",\n" +
                "    \"createdate\": \"2023-11-09 14:47:37\",\n" +
                "    \"lastmodifyby\": null,\n" +
                "    \"lastmodifydate\": null,\n" +
                "    \"p_enterprisename\": \"江西青牛\",\n" +
                "    \"caozy\": null,\n" +
                "    \"expirationdate\": null,\n" +
                "    \"printnumber\": null,\n" +
                "    \"receive_addressid\": null,\n" +
                "    \"salescontrnumb\": null,\n" +
                "    \"iskeepaccount\": null,\n" +
                "    \"paymentdaytype\": null,\n" +
                "    \"advdeliverydate\": null,\n" +
                "    \"enquirysalesman\": null,\n" +
                "    \"enquirydepartment\": null,\n" +
                "    \"agent\": null,\n" +
                "    \"sale_branchid\": null,\n" +
                "    \"sale_branchcode\": null,\n" +
                "    \"sale_branchname\": null,\n" +
                "    \"isunchecproducts\": null,\n" +
                "    \"checktype\": null,\n" +
                "    \"checkcategory\": null,\n" +
                "    \"is_emergency\": null,\n" +
                "    \"is_cancelled\": null,\n" +
                "    \"red_reason\": null,\n" +
                "    \"delivery_date\": null,\n" +
                "    \"exc_results\": null,\n" +
                "    \"exc_remarks\": null,\n" +
                "    \"consignorcode\": \"HQN001\",\n" +
                "    \"branchareacode\": null,\n" +
                "    \"shippercode\": \"XT00001166\",\n" +
                "    \"line_code\": \"1\",\n" +
                "    \"line_name\": \"1\",\n" +
                "    \"carrier_code\": \"SF\",\n" +
                "    \"salesperson_code\": null,\n" +
                "    \"exc_reason\": null,\n" +
                "    \"partly_red\": null,\n" +
                "    \"arrival_modecode\": null,\n" +
                "    \"paymentdaytypecode\": null,\n" +
                "    \"con_change_status\": null,\n" +
                "    \"department\": null,\n" +
                "    \"sf_zzdy\": null,\n" +
                "    \"printtemplateno\": null,\n" +
                "    \"cus_remark\": null,\n" +
                "    \"jjk\": null,\n" +
                "    \"operationlicenseno\": null,\n" +
                "    \"cx_memberno\": null,\n" +
                "    \"cx_membername\": null,\n" +
                "    \"idcard\": null,\n" +
                "    \"plan_delivery_date\": null,\n" +
                "    \"delivery_name\": \"\",\n" +
                "    \"shopcode\": \"QN\",\n" +
                "    \"shopname\": \"青牛\",\n" +
                "    \"salesperson_tel\": \"18166081899\",\n" +
                "    \"prepared_by\": \"1\",\n" +
                "    \"paytime\": \"2023-10-11 01:20:03\",\n" +
                "    \"payamount\": 1.0000,\n" +
                "    \"paysn\": \"1\",\n" +
                "    \"freight\": 1.0000,\n" +
                "    \"ship_bill_no\": \"1\",\n" +
                "    \"take_mode\": null,\n" +
                "    \"transport_mode\": null,\n" +
                "    \"src_plate\": \"1\",\n" +
                "    \"src_plate_billno\": \"1\",\n" +
                "    \"item_health_industry\": null\n" +
                "  }\n" +
                "]";
        OmsDoBillHDO omsDoBillHDO = JSONObject.parseObject(p2, OmsDoBillHDO.class);
        return omsDoBillHDO;
    }

    @Test
    public void printTest() {
        Employee employee = new Employee();
        employee.setUserId("7011");
        employee.setUsername("Ky");
        pickTaskService.print(getOmsDoBillHDO(), employee);
    }

    @Test
    public void getFlgByLackTasks() {
        List<WaveStorageDO> storages = null;
        List<PickTaskD> lackTasks = null;
        Map<String,Object> flg = pickTaskService.getFlgByLackTasks(storages, lackTasks);
        Assert.assertEquals("1", flg);
    }

    @Test
    public void getUserDtoKeyAndSetCache() {
        String key = "qingniufh";
        UserDTO user = pickTaskService.getUserDtoKeyAndSetCache(key);
        System.out.println(JSONObject.toJSONString(user));
    }

    @Test
    public void getUser() {
        String key = "qingniufh";
        HystrixVarUtil.setUserKey(key);
        UserDTO user = userTemplate.getUserDTO();
        System.out.println(JSONObject.toJSONString(user));
    }

    @Test
    public void getPrintNameByBusiness() {
//        String printBillCode = "imgManage-ZJBG-pdf";
        String printBillCode = "imgManage-SYZL-pdf";
        String printNameByBusiness = pickTaskService.getPrintNameByBusiness("901884530611326976", printBillCode);
        System.out.println(printNameByBusiness);
    }

    @Test
    public void printQrReport() {
        String msg = "[{\"billid\":\"XSDD0002270\",\"billno\":\"XSDD0002270\",\"billtype\":\"1\",\"ref_billtype\":\"1\",\"ref_billid\":\"XSDD0002270\",\"ref_billno\":\"XSDD0002270\",\"consignorid\":\"748963439141064888\",\"consignorname\":\"江西青牛\",\"branchid\":\"901884530611326976\",\"branchcode\":\"qingniuwh\",\"branchname\":\"青牛主仓\",\"branchareaid\":null,\"brancharea\":null,\"branch_address\":null,\"shipper_type\":\"2\",\"shipperid\":\"949407265474088960\",\"shippername\":\"思南凰佳诊所\",\"cust_person\":\"冯术芬\",\"cust_person_tel\":\"13985851000\",\"receive_country_no\":null,\"receive_country_name\":null,\"receive_province_no\":null,\"receive_province_name\":null,\"receive_city_no\":null,\"receive_city_name\":null,\"receive_district_no\":null,\"receive_district_name\":null,\"receive_town_no\":null,\"receive_town_name\":null,\"receive_community_no\":null,\"receive_community_name\":null,\"receive_address\":\"贵州省铜仁市思南县思唐街道办事处中和社区府后街188号\",\"ship_term\":null,\"arrival_mode\":\"2\",\"priority_level\":\"99\",\"ship_line_id\":null,\"carrier_id\":\"1\",\"carrier_name\":\"赣州顺丰速运有限公司\",\"carrier_type\":\"1\",\"salesperson_id\":null,\"salesperson_name\":null,\"status\":\"20\",\"bill_date\":\"2024-02-25 00:00:00\",\"attain_date\":null,\"examine_state\":null,\"tot_pcs\":null,\"tot_qty\":null,\"containers_num\":null,\"tot_box_num\":null,\"tot_weight\":null,\"tot_volume\":null,\"totnetamt\":null,\"totamt\":null,\"rt_reason\":null,\"remark\":null,\"closed_reason\":null,\"attr_str1\":null,\"attr_str2\":null,\"attr_str3\":\"1\",\"attr_str4\":\"1\",\"attr_str5\":\"1\",\"attr_str6\":null,\"attr_str7\":null,\"attr_str8\":null,\"attr_str9\":null,\"attr_str10\":\"053\",\"attr_num1\":null,\"attr_num2\":null,\"attr_num3\":null,\"attr_num4\":null,\"attr_num5\":null,\"attr_dte1\":null,\"attr_dte2\":null,\"attr_dte3\":null,\"attr_dte4\":null,\"attr_dte5\":null,\"createby\":\"ERP\",\"createdate\":\"2024-01-29 18:34:38\",\"lastmodifyby\":null,\"lastmodifydate\":null,\"p_enterpriseid\":\"900356013474058240\",\"p_enterprisename\":\"江西青牛\",\"caozy\":null,\"expirationdate\":null,\"printnumber\":null,\"receive_addressid\":null,\"salescontrnumb\":null,\"iskeepaccount\":null,\"paymentdaytype\":null,\"advdeliverydate\":null,\"enquirysalesman\":null,\"enquirydepartment\":null,\"agent\":null,\"sale_branchid\":null,\"sale_branchcode\":null,\"sale_branchname\":null,\"isunchecproducts\":null,\"checktype\":null,\"checkcategory\":null,\"is_emergency\":null,\"is_cancelled\":null,\"red_reason\":null,\"delivery_date\":null,\"exc_results\":null,\"exc_remarks\":null,\"consignorcode\":\"HQN001\",\"branchareacode\":null,\"shippercode\":\"C152000019\",\"line_code\":null,\"line_name\":null,\"carrier_code\":\"SF\",\"salesperson_code\":null,\"exc_reason\":null,\"partly_red\":null,\"arrival_modecode\":null,\"paymentdaytypecode\":null,\"con_change_status\":null,\"department\":null,\"sf_zzdy\":null,\"printtemplateno\":null,\"cus_remark\":null,\"jjk\":null,\"operationlicenseno\":null,\"cx_memberno\":null,\"cx_membername\":null,\"idcard\":null,\"plan_delivery_date\":null,\"delivery_name\":null,\"shopcode\":null,\"shopname\":null,\"salesperson_tel\":null,\"prepared_by\":\"青牛ERP\",\"paytime\":null,\"payamount\":null,\"paysn\":null,\"freight\":null,\"ship_bill_no\":null,\"take_mode\":null,\"transport_mode\":null,\"src_plate\":null,\"src_plate_billno\":null,\"item_health_industry\":\"QN\"}]";
        List<OmsDoBillHDO> bills = JSONObject.parseArray(msg, OmsDoBillHDO.class);
        pickTaskService.printQrReport(bills);
    }

    @Test
    public void printSyInfo() {
        String msg = "[{\"billid\":\"XSDD0002270\",\"billno\":\"XSDD0002270\",\"billtype\":\"1\",\"ref_billtype\":\"1\",\"ref_billid\":\"XSDD0002270\",\"ref_billno\":\"XSDD0002270\",\"consignorid\":\"748963439141064888\",\"consignorname\":\"江西青牛\",\"branchid\":\"901884530611326976\",\"branchcode\":\"qingniuwh\",\"branchname\":\"青牛主仓\",\"branchareaid\":null,\"brancharea\":null,\"branch_address\":null,\"shipper_type\":\"2\",\"shipperid\":\"949407265474088960\",\"shippername\":\"思南凰佳诊所\",\"cust_person\":\"冯术芬\",\"cust_person_tel\":\"13985851000\",\"receive_country_no\":null,\"receive_country_name\":null,\"receive_province_no\":null,\"receive_province_name\":null,\"receive_city_no\":null,\"receive_city_name\":null,\"receive_district_no\":null,\"receive_district_name\":null,\"receive_town_no\":null,\"receive_town_name\":null,\"receive_community_no\":null,\"receive_community_name\":null,\"receive_address\":\"贵州省铜仁市思南县思唐街道办事处中和社区府后街188号\",\"ship_term\":null,\"arrival_mode\":\"2\",\"priority_level\":\"99\",\"ship_line_id\":null,\"carrier_id\":\"1\",\"carrier_name\":\"赣州顺丰速运有限公司\",\"carrier_type\":\"1\",\"salesperson_id\":null,\"salesperson_name\":null,\"status\":\"20\",\"bill_date\":\"2024-02-25 00:00:00\",\"attain_date\":null,\"examine_state\":null,\"tot_pcs\":null,\"tot_qty\":null,\"containers_num\":null,\"tot_box_num\":null,\"tot_weight\":null,\"tot_volume\":null,\"totnetamt\":null,\"totamt\":null,\"rt_reason\":null,\"remark\":null,\"closed_reason\":null,\"attr_str1\":null,\"attr_str2\":null,\"attr_str3\":\"1\",\"attr_str4\":\"1\",\"attr_str5\":\"1\",\"attr_str6\":null,\"attr_str7\":null,\"attr_str8\":null,\"attr_str9\":null,\"attr_str10\":\"053\",\"attr_num1\":null,\"attr_num2\":null,\"attr_num3\":null,\"attr_num4\":null,\"attr_num5\":null,\"attr_dte1\":null,\"attr_dte2\":null,\"attr_dte3\":null,\"attr_dte4\":null,\"attr_dte5\":null,\"createby\":\"ERP\",\"createdate\":\"2024-01-29 18:34:38\",\"lastmodifyby\":null,\"lastmodifydate\":null,\"p_enterpriseid\":\"900356013474058240\",\"p_enterprisename\":\"江西青牛\",\"caozy\":null,\"expirationdate\":null,\"printnumber\":null,\"receive_addressid\":null,\"salescontrnumb\":null,\"iskeepaccount\":null,\"paymentdaytype\":null,\"advdeliverydate\":null,\"enquirysalesman\":null,\"enquirydepartment\":null,\"agent\":null,\"sale_branchid\":null,\"sale_branchcode\":null,\"sale_branchname\":null,\"isunchecproducts\":null,\"checktype\":null,\"checkcategory\":null,\"is_emergency\":null,\"is_cancelled\":null,\"red_reason\":null,\"delivery_date\":null,\"exc_results\":null,\"exc_remarks\":null,\"consignorcode\":\"HQN001\",\"branchareacode\":null,\"shippercode\":\"C152000019\",\"line_code\":null,\"line_name\":null,\"carrier_code\":\"SF\",\"salesperson_code\":null,\"exc_reason\":null,\"partly_red\":null,\"arrival_modecode\":null,\"paymentdaytypecode\":null,\"con_change_status\":null,\"department\":null,\"sf_zzdy\":null,\"printtemplateno\":null,\"cus_remark\":null,\"jjk\":null,\"operationlicenseno\":null,\"cx_memberno\":null,\"cx_membername\":null,\"idcard\":null,\"plan_delivery_date\":null,\"delivery_name\":null,\"shopcode\":null,\"shopname\":null,\"salesperson_tel\":null,\"prepared_by\":\"青牛ERP\",\"paytime\":null,\"payamount\":null,\"paysn\":null,\"freight\":null,\"ship_bill_no\":null,\"take_mode\":null,\"transport_mode\":null,\"src_plate\":null,\"src_plate_billno\":null,\"item_health_industry\":\"QN\"}]";
        List<OmsDoBillHDO> bills = JSONObject.parseArray(msg, OmsDoBillHDO.class);
        pickTaskService.printSyInfo(bills);
    }

    @Test
    public void callBackErpWhenTasksIsDone() {
        List<String> billIds = Lists.newArrayList("20240228155");
        int i = pickTaskService.callBackErpWhenTasksIsDone(billIds);
        Assert.assertEquals(billIds.size(), i);
    }
}
