package com.prolog.cs.base.gsp.controller; 

import com.alibaba.fastjson.JSON;
import com.netflix.hystrix.strategy.concurrency.HystrixRequestContext;
import com.prolog.cs.base.gsp.QueryDTO;
import com.prolog.cs.base.gsp.model.GspUpkeepCheck;
import com.prolog.cs.base.gsp.service.impl.AutoUpKeepTask;
import com.prolog.framework.authority.util.HystrixVarUtil;
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.List;

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

    @Autowired
    private GspUpkeepCheckController GspUpkeepCheckController;

    @Autowired
    private AutoUpKeepTask autoUpKeepTask;
    
    @Before
    public void before() throws Exception { 
        HystrixRequestContext context = HystrixRequestContext.initializeContext();
        HystrixVarUtil.setUserKey("syyl-admin");
    } 
    
    @After
    public void after() throws Exception { 
    } 

    @Test//System.out.println(JSON.toJSONString(GspUpkeepCheckController.batchAdd()));
    public void testBatchAdd() throws Exception {
        String s="[{\"itemHealthCategoryName\":\"医疗器械\",\"locatorName\":\"退货库CW\",\"manufacturerName\":\"仙桃鼎成无纺布织品有限公司\",\"cargoOwnerId\":\"XIANTAO2021\",\"itemCode\":\"YY-wkkz01\",\"caseConversionRate\":50,\"stockQty\":50,\"remark\":\"首营\",\"batchId\":\"741699883953688576\",\"warehouseName\":\"康恩贝华中仓\",\"itemHealthListedLicensor\":null,\"countryOriginName\":\"湖北省仙桃市\",\"caseUom\":\"盒\",\"itemName\":\"医用外科口罩\",\"bldgId\":\"736948318315352064\",\"qualityStatus\":\"1\",\"cargoOwnerName\":\"康恩贝货主010\",\"warehouseAreaCategory\":\"THK\",\"warehouseAreaName\":\"退货库常温\",\"lotNum\":\"6789\",\"specification\":\"无菌型耳带式17.5cm*9.5cm\",\"pdateFrom\":\"2022-07-04 00:00:00\",\"bldgName\":\"建筑物001\",\"itemId\":\"0621575008\",\"storeTemperature\":\"常温\",\"warehouseId\":\"736948213336117248\",\"locatorId\":\"736951604460261376\",\"itemHealthApprovalNbr\":\"鄂食药监械生产许20110534号\",\"itemHealthRegisterNbr\":null,\"itemHealthCategory\":\"013\",\"validUntil\":\"2023-08-04 00:00:00\",\"id\":\"741699883953688576736951604460261376\",\"_row_count\":1,\"isProtected\":1}]";
        List<GspUpkeepCheck> gspUpkeepCheckList=JSON.parseArray(s,GspUpkeepCheck.class);
        System.out.println(JSON.toJSONString(GspUpkeepCheckController.batchAdd(gspUpkeepCheckList)));
    } 
    @Test//System.out.println(JSON.toJSONString(GspUpkeepCheckController.batchEdit()));
    public void testBatchEdit() throws Exception { 
        
    } 
    @Test//System.out.println(JSON.toJSONString(GspUpkeepCheckController.batchCheck()));
    public void testBatchCheck() throws Exception {
        String s="[{\"id\":\"757317280676843520\",\"code\":\"SDD76843520\",\"dcId\":\"736946838493597696\",\"warehouseId\":\"736948213336117248\",\"cargoOwnerId\":\"XIANTAO2021\",\"batchId\":null,\"planId\":null,\"planCode\":null,\"itemId\":\"2155036\",\"itemCode\":\"TW22005\",\"itemName\":\"999感冒灵（石）\",\"lotNum\":\"714142759191187457\",\"locatorId\":\"713076312125870080\",\"locatorCode\":\"ZJK-T01\",\"locatorName\":\"整件库T01\",\"stockQty\":\"1070000.0000000\",\"upkeepQty\":\"1070000.0000000\",\"pendingQty\":0,\"itemType\":null,\"upkeepOperator\":\"\",\"status\":\"4\",\"sourceType\":\"0\",\"upkeepConclusion\":null,\"checkConclusion\":null,\"recheckConclusion\":\"2\",\"conclusion\":null,\"processOpinion\":null,\"checkOperator\":null,\"checkOpinion\":\"\",\"recheckOperator\":null,\"recheckOpinion\":\"\",\"checkWaiGuan\":null,\"checkBaoZhuang\":null,\"checkChenChuTiaoJian\":null,\"checkFanDuo\":null,\"checkChuShi\":null,\"checkJiaShi\":null,\"checkShenWen\":null,\"checkJiangWen\":null,\"checkTongFeng\":null,\"checkChuChen\":null,\"qualityStatus\":null,\"thsTatus\":null,\"pendingReason\":null,\"planUpkeepDate\":\"2022-08-17 16:29:26\",\"upkeepDate\":\"2022-08-17 16:29:26\",\"checkDate\":null,\"recheckDate\":null,\"remark\":null,\"pdateFrom\":null,\"validUntil\":null,\"bldgId\":null,\"upkeepType\":null,\"manufacturerName\":\"湖北泰威防护用品有限公司\",\"itemHealthListedLicensor\":\"\",\"cargoOwnerName\":\"康恩贝货主010\",\"bldgName\":\"建筑物001\",\"warehouseName\":\"康恩贝华中仓\",\"productionDate\":null,\"expiredDate\":null,\"showProductionDate\":null,\"showExpiredDate\":null,\"outStockStatus\":null,\"inStockStatus\":null,\"caseQuantity\":1070000,\"planStockQty\":null,\"oddPieceQuantity\":0,\"outLocatorId\":null,\"outLocatorName\":null,\"outContainerCode\":\"N/A\",\"outGoodsCaseCode\":\"N/A\",\"inLocatorId\":null,\"inContainerCode\":\"N/A\",\"inGoodsCaseCode\":\"N/A\",\"reason\":null,\"comments\":null,\"gspBillId\":null,\"gspBillNo\":null,\"gspLineId\":null,\"inWhAreaCategory\":null,\"outWhAreaCategory\":\"ZJK\",\"outWhAreaCategoryName\":\"整件库\",\"inWhAreaCategoryName\":null,\"whWarehouseLocatorType\":\"0\",\"itemHealthApprovalNbr\":\"\",\"itemHealthCategoryName\":\"医疗器械\",\"warehouseRoomName\":null,\"specification\":\"175XL/180XXL\",\"caseConversionRate\":1,\"caseUom\":\"箱\",\"itemHealthRegisterNbr\":null,\"countryOriginName\":\"仙桃市彭场镇彭杨公路8号\",\"spec\":null,\"checkChongZhu\":null,\"checkFaMei\":null,\"checkFanYou\":null,\"checkChaoJie\":null,\"checkBianSe\":null,\"checkShangDou\":null,\"checkPoSun\":null,\"warehouseAreaName\":\"常温整件\",\"warehouseAreaCategory\":\"ZJK\",\"_row_count\":3,\"lotNo\":\"\"}]";
        s="[{\"id\":\"759814835876794368\",\"code\":\"SDD76794368\",\"dcId\":\"759789131546103808\",\"warehouseId\":\"759131791285161984\",\"cargoOwnerId\":\"748963439141064704\",\"batchId\":null,\"planId\":null,\"planCode\":null,\"itemId\":\"9876612\",\"itemCode\":\"Wd220630\",\"itemName\":\"医用防护服-Dw-test\",\"lotNum\":\"759779354610896896\",\"locatorId\":\"759778221368676352\",\"locatorCode\":\"ZJKHW01\",\"locatorName\":\"ZJK货位01\",\"stockQty\":\"300.0000000\",\"upkeepQty\":\"300.0000000\",\"pendingQty\":0,\"itemType\":null,\"upkeepOperator\":\"\",\"status\":\"4\",\"sourceType\":\"0\",\"upkeepConclusion\":null,\"checkConclusion\":null,\"recheckConclusion\":\"2\",\"conclusion\":null,\"processOpinion\":null,\"checkOperator\":null,\"checkOpinion\":\"\",\"recheckOperator\":null,\"recheckOpinion\":\"11\",\"checkWaiGuan\":null,\"checkBaoZhuang\":null,\"checkChenChuTiaoJian\":null,\"checkFanDuo\":null,\"checkChuShi\":null,\"checkJiaShi\":null,\"checkShenWen\":null,\"checkJiangWen\":null,\"checkTongFeng\":null,\"checkChuChen\":null,\"qualityStatus\":null,\"thsTatus\":null,\"pendingReason\":null,\"planUpkeepDate\":\"2022-08-24\",\"upkeepDate\":\"2022-08-24 13:53:57\",\"checkDate\":null,\"recheckDate\":null,\"remark\":null,\"pdateFrom\":null,\"validUntil\":null,\"bldgId\":null,\"upkeepType\":null,\"manufacturerName\":\"湖北泰威防护用品有限公司\",\"itemHealthListedLicensor\":\"\",\"cargoOwnerName\":\"思源货主010\",\"bldgName\":\"建筑物1\",\"warehouseName\":\"思源华中仓\",\"productionDate\":null,\"expiredDate\":null,\"showProductionDate\":null,\"showExpiredDate\":null,\"outStockStatus\":null,\"inStockStatus\":null,\"caseQuantity\":300,\"planStockQty\":null,\"oddPieceQuantity\":0,\"outLocatorId\":null,\"outLocatorName\":null,\"outContainerCode\":\"N/A\",\"outGoodsCaseCode\":\"N/A\",\"inLocatorId\":null,\"inContainerCode\":null,\"inGoodsCaseCode\":\"N/A\",\"reason\":null,\"comments\":null,\"gspBillId\":null,\"gspBillNo\":null,\"gspLineId\":null,\"inWhAreaCategory\":null,\"outWhAreaCategory\":\"ZJK\",\"outWhAreaCategoryName\":\"整件库\",\"inWhAreaCategoryName\":null,\"whWarehouseLocatorType\":\"0\",\"itemHealthApprovalNbr\":\"\",\"itemHealthCategoryName\":\"医疗器械\",\"warehouseRoomName\":null,\"specification\":\"175XL/180XXL\",\"caseConversionRate\":1,\"caseUom\":\"箱\",\"itemHealthRegisterNbr\":null,\"countryOriginName\":\"仙桃市彭场镇彭杨公路8号\",\"spec\":null,\"checkChongZhu\":null,\"checkFaMei\":null,\"checkFanYou\":null,\"checkChaoJie\":null,\"checkBianSe\":null,\"checkShangDou\":null,\"checkPoSun\":null,\"warehouseAreaName\":\"库区01\",\"warehouseAreaCategory\":\"ZJK\",\"_row_count\":1,\"lotNo\":\"\"}]";
        List<GspUpkeepCheck> gspUpkeepCheckList=JSON.parseArray(s,GspUpkeepCheck.class);
        System.out.println(JSON.toJSONString(GspUpkeepCheckController.batchCheck(gspUpkeepCheckList)));
    } 
    @Test//System.out.println(JSON.toJSONString(GspUpkeepCheckController.listPage()));
    public void testListPage() throws Exception {

    } 
    @Test//System.out.println(JSON.toJSONString(GspUpkeepCheckController.findByPlanId()));
    public void testFindByPlanId() throws Exception { 
        
    } 
    @Test//System.out.println(JSON.toJSONString(GspUpkeepCheckController.findUpkeepPage()));
    public void testFindUpkeepPage() throws Exception { 
        
    } 
    @Test//System.out.println(JSON.toJSONString(GspUpkeepCheckController.findPlan()));
    public void testFindPlan() throws Exception {
        QueryDTO upkeepCheckDTO=new QueryDTO();
        upkeepCheckDTO.setUpkeepType("1");
        upkeepCheckDTO.setWarehouseId("736948213336117248");
        upkeepCheckDTO.setCargoOwnerId("XIANTAO2021");
        System.out.println(JSON.toJSONString(GspUpkeepCheckController.findPlan(upkeepCheckDTO)));
    } 
    @Test//System.out.println(JSON.toJSONString(GspUpkeepCheckController.findUpkeep4MovePick()));
    public void testFindUpkeep4MovePick() throws Exception { 
        
    } 
    @Test//System.out.println(JSON.toJSONString(GspUpkeepCheckController.findUpkeepItem4MovePick()));
    public void testFindUpkeepItem4MovePick() throws Exception {
        autoUpKeepTask.autoUpKeepTask("759131791285161985","748963439141064799","789478194809016320");
    } 
    @Test//System.out.println(JSON.toJSONString(GspUpkeepCheckController.confirmUpkeepMove()));
    public void testConfirmUpkeepMove() throws Exception { 
        
    } 
    @Test//System.out.println(JSON.toJSONString(GspUpkeepCheckController.autoUpKeepTask()));
    public void testAutoUpKeepTask() throws Exception { 
        
    } 
    @Test//System.out.println(JSON.toJSONString(GspUpkeepCheckController.confirmDevice()));
    public void testConfirmDevice() throws Exception { 
        
    } 
        
} 
