package com.mq.zhongzhuanxiezai.db;

import com.mq.mylibrary.db.BaseEntity;
import com.mq.mylibrary.tool.LogTool;
import com.mq.mylibrary.tool.StringTool;

import java.io.Serializable;

/**
 * 创建人 mQ
 * 创建时间 2019/8/20 0020 16:18
 * 文件名称 XieZaiEntity
 * 说明:
 * create TABLE `zhong_zhuan_xie_zai` (
 * `id` INTEGER PRIMARY KEY AUTOINCREMENT,
 * `check_number` varchar(2000) DEFAULT NULL COMMENT '检斤单号',
 * `work_number` varchar(2000) DEFAULT NULL COMMENT '单据号',
 * `customer` varchar(2000) DEFAULT NULL COMMENT '客户名称',
 * `grain` varchar(2000) DEFAULT NULL COMMENT '粮油品种',
 * `car` varchar(2000) DEFAULT NULL COMMENT '车辆编号',
 * `weight` varchar(2000) DEFAULT NULL COMMENT '毛重(公斤)',
 * `haulier` varchar(2000) DEFAULT NULL COMMENT '承运人',
 * `phone` varchar(2000) DEFAULT NULL COMMENT '承运人电话',
 * `platform` varchar(2000) DEFAULT NULL COMMENT '站台',
 * `position` varchar(2000) DEFAULT NULL COMMENT '货位',
 * `finish_count` varchar(2000) DEFAULT NULL COMMENT '卸载件数',
 * `work_team` varchar(2000) DEFAULT NULL COMMENT '作业队',
 * `work_group` varchar(2000) DEFAULT NULL COMMENT '作业组',
 * `entd` varchar(2000) DEFAULT NULL COMMENT '登记人',
 * `start_time` varchar(2000) DEFAULT NULL COMMENT '作业开始时间',
 * `end_time` varchar(2000) DEFAULT NULL COMMENT '作业结束时间'
 * ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='发运中转-汽车卸载表';
 **/
public class XieZaiEntity extends BaseEntity implements Serializable {

    //任务编码
    public String task_code;
    //期间ID
    public String period_id;
    //单位ID
    public String unit_id;
    //版本ID
    public String version_id;
    //报表类型
    public String report_type;
    //报表ID
    public String report_id;
    //下环节ID
    public String next_id;
    //业务编码指标ID
    public String work_index_id;
    //流程ID
    public String process_id;
    //单据号(入门单号)
    public String work_number;
    //状态
    public String status;
    //检斤单号
    public String check_number;
    //单据号
    public String order_number;
    //客户名称
    public String customer;
    //粮油品种
    public String grain;
    //车辆编号
    public String car;
    //毛重(公斤)
    public String weight;
    //承运人
    public String haulier;
    //承运人电话
    public String phone;
    //业务标识
    public String work_flg;
    //站台
    public String platform;
    //货位
    public String position;
    //卸载件数
    public String finish_count;
    //作业队
    public String work_team;
    //作业组
    public String work_group;
    //登记人
    public String entd;
    //作业开始时间
    public String start_time;
    //作业结束时间
    public String end_time;

    /**
     * 模拟卡片数据
     */
    public static String testCardData() {
        return "crkyw|" +
                "11|" +
                "164|" +
                "ec93fe656f584052a1fc854080f32eee|" +
                "1|" +
                "dc44cd5c97ea11e9ab6a009027e007ac|" +
                "5|" +
                "I_4028810b5cf6f918015cf707e5120002|" +
                "A7B1FDB54DE7B32D6F8067FEFE2BF52F|" +
                "qcrk_20120190626006|" +
                "0|" +
                "jjdh_20120190626006|" +
                "qcrk_20120190626006|" +
                "测试客户名称|" +
                "测试粮油品种|" +
                "测试车辆编号|" +
                "测试毛重|" +
                "测试承运人|" +
                "测试电话|" +
                "fyzzqcxz";
    }

    /**
     * 解析卡片数据
     */
    public static XieZaiEntity initData(String result) {
        if (StringTool.isEmpty(result))
            return null;

        //正式读取字段
        String[] datas = result.split("\\|", -1);
        LogTool.i("字段数:" + datas.length + ",字段值:" + result);
        if (datas.length <= 19)
            return null;
        if (!datas[19].equals("fyzzqcxz"))
            return null;//不是发运中转-汽车卸载

        XieZaiEntity entity = new XieZaiEntity();
        try {
            entity.task_code = (datas[0]);
            entity.period_id = (datas[1]);
            entity.unit_id = (datas[2]);
            entity.version_id = (datas[3]);
            entity.report_type = (datas[4]);
            entity.report_id = (datas[5]);
            entity.next_id = (datas[6]);
            entity.work_index_id = (datas[7]);
            entity.process_id = (datas[8]);
            entity.work_number = (datas[9]);
            entity.status = (datas[10]);
            entity.check_number = (datas[11]);
            entity.order_number = (datas[12]);
            entity.customer = (datas[13]);
            entity.grain = (datas[14]);
            entity.car = (datas[15]);
            entity.weight = (datas[16]);
            entity.haulier = (datas[17]);
            entity.phone = (datas[18]);
            entity.work_flg = (datas[19]);
            return entity;
        } catch (Exception e) {
            LogTool.e(e.toString());
            return null;
        }
    }


    /**
     * 获取写入信息
     */
    public String getWriteData() {
        return handleDatas(
                task_code,
                period_id,
                unit_id,
                version_id,
                report_type,
                report_id,
                next_id,
                work_index_id,
                process_id,
                work_number,
                status,
                check_number,
                order_number,
                customer,
                grain,
                car,
                weight,
                haulier,
                phone,
                work_flg,
                platform,
                position,
                finish_count,
                work_team,
                work_group,
                entd,
                start_time,
                end_time
        );
    }

}
