package org.ts.ddcs.DataTemplate;

import com.alibaba.fastjson.JSONObject;
import org.ts.ddcs.Log.LogHelper;
import org.ts.ddcs.Tool.BytesHelp;

import java.util.LinkedList;
import java.util.List;

/**
 * 0x F1
 * 水资源 下行文件
 */

@SuppressWarnings("all")
public class DataTemplateSzyCF1 extends DataTemplateSzy2012 {

    private String dataInfo;

    @Override
    public void Stream() {
        try {
            if (dataLen > 0) {
                int count = 0;
                byte[] packageIndexBuff = BytesHelp.subBytes(this.dataArea, count, 2);
                int packageIndex = BytesHelp.bytes2Int(packageIndexBuff, 0, 2);
                count += 2;
                JSONObject data = new JSONObject();
                data.put("func", "F1");
                List<JSONObject> items = new LinkedList<>();
                JSONObject item = new JSONObject();
                item.put("name", "文件上传");
                item.put("value", "第 " + packageIndex + " 包");
                items.add(item);
                data.put("data", items);
                this.dataInfo = data.toJSONString();
                if (count != this.dataArea.length) {
                    LogHelper.info("******************* F1 DATA ERROR******************* ");
                }
            }
        } catch (Exception e) {
            LogHelper.error(e);
        }
    }

    @Override
    public String getDataInfo() {
        return dataInfo;
    }

    @Override
    public boolean ClearCommand() {

        return true;
    }

    @Override
    public String GetViewName() {
        return "文件传输报";
    }
}
