package com.ruoyi.web.modules.trading;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import com.ruoyi.web.modules.trading.domain.BizEntryIsolation;
import com.ruoyi.web.modules.trading.domain.BizEntryIsolationAlloc;
import com.ruoyi.web.modules.trading.domain.BizIsolationPen;
import com.ruoyi.web.modules.trading.domain.BizSupplier;
import com.ruoyi.web.modules.trading.support.EntryIsolationRules;
import com.ruoyi.web.modules.trading.support.SupplierRules;

/**
 * 入场隔离登记测试样本。
 */
public final class EntryIsolationTestSamples
{
    public static final Long SUPPLIER_ID = 1L;

    public static final Long PEN_ID_1 = 1L;

    public static final Long PEN_ID_2 = 2L;

    private EntryIsolationTestSamples()
    {
    }

    public static BizSupplier activeSupplier()
    {
        BizSupplier s = new BizSupplier();
        s.setId(SUPPLIER_ID);
        s.setSupplierName("扎西牧民合作社");
        s.setDelFlag(SupplierRules.DEL_FLAG_NORMAL);
        return s;
    }

    public static BizIsolationPen activePen(Long id, String code)
    {
        BizIsolationPen p = new BizIsolationPen();
        p.setId(id);
        p.setPenCode(code);
        p.setDelFlag(SupplierRules.DEL_FLAG_NORMAL);
        return p;
    }

    public static BizEntryIsolation validSaveRow() throws ParseException
    {
        BizEntryIsolation row = new BizEntryIsolation();
        row.setEntryTime(parseDateTime("2026-05-20 10:00:00"));
        row.setSupplierId(SUPPLIER_ID);
        row.setCertNo("QZ20260520001");
        row.setQuantity(2);
        row.setEarTagList(Arrays.asList("E001", "E002"));
        row.setIsolationDays(7);
        BizEntryIsolationAlloc a1 = new BizEntryIsolationAlloc();
        a1.setPenId(PEN_ID_1);
        a1.setEarTagList(Arrays.asList("E001"));
        BizEntryIsolationAlloc a2 = new BizEntryIsolationAlloc();
        a2.setPenId(PEN_ID_2);
        a2.setEarTagList(Arrays.asList("E002"));
        row.setPenAllocList(Arrays.asList(a1, a2));
        return row;
    }

    public static Date parseDateTime(String text) throws ParseException
    {
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(text);
    }

    public static Date expectedReleaseDate() throws ParseException
    {
        return new SimpleDateFormat("yyyy-MM-dd").parse("2026-05-27");
    }
}
