package com.mq.zhongzhuanzhuangche.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/21 0021 10:08
 * 文件名称 ZhongZhuanZhuangCheEntity
 * 说明:
 * create TABLE `zhong_zhuan_zhuang_che` (
 * `id` INTEGER PRIMARY KEY AUTOINCREMENT,
 * `work_number` varchar(2000) DEFAULT NULL COMMENT '单据号',
 * `pick_up_goods_num` varchar(2000) DEFAULT NULL COMMENT '提货单号',
 * `pick_up_goods_count` varchar(2000) DEFAULT NULL COMMENT '提货件数',
 * `customer` varchar(2000) DEFAULT NULL COMMENT '客户名称',
 * `car` varchar(2000) DEFAULT NULL COMMENT '车辆编号',
 * `train_code` varchar(2000) DEFAULT NULL COMMENT '关联火车皮号',
 * `grain` varchar(2000) DEFAULT NULL COMMENT '粮油品种',
 * `platform` varchar(2000) DEFAULT NULL COMMENT '站台',
 * `position` varchar(2000) DEFAULT NULL COMMENT '货位',
 * `weight` varchar(2000) DEFAULT NULL COMMENT '皮重(公斤)',
 * `haulier` varchar(2000) DEFAULT NULL COMMENT '承运人',
 * `phone` varchar(2000) DEFAULT NULL COMMENT '承运人电话',
 * `measure_type` varchar(2000) DEFAULT NULL COMMENT '计量方式',
 * `finish_count` varchar(2000) DEFAULT NULL COMMENT '装车件数',
 * `single_weight` varchar(2000) DEFAULT NULL COMMENT '单件重量(公斤)',
 * `finish_weight` 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 ZhongZhuanZhuangCheEntity 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 order_number;
    //提货单号
    public String pick_up_goods_num;
    //提货件数
    public String pick_up_goods_count;
    //客户名称
    public String customer;
    //车辆编号
    public String car;
    //关联火车皮号
    public String train_code;
    //粮油品种
    public String grain;
    //站台
    public String platform;
    //货位
    public String position;
    //皮重(公斤)
    public String weight;
    //承运人
    public String haulier;
    //承运人电话
    public String phone;
    //计量方式
    public String measure_type;
    //业务标识
    public String work_flg;
    //装车件数
    public String finish_count;
    //单件重量(公斤)
    public String single_weight;
    //装车重量(公斤)
    public String finish_weight;
    //作业队
    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|" +
                "djh|" +
                "thdh|" +
                "20|" +
                "客户一|" +
                "云A12368|" +
                "hcph|" +
                "小麦|" +
                "站台1|" +
                "货位1|" +
                "100.00|" +
                "承运一|" +
                "13666666666|" +
                "计件|" +
                "dzzzqczc"
                ;
    }
    /**
     * 解析卡片数据
     */
    public static ZhongZhuanZhuangCheEntity initData(String result) {
        if (StringTool.isEmpty(result))
            return null;
        //正式读取字段
        String[] datas = result.split("\\|", -1);
        LogTool.i("字段数:" + datas.length + ",字段值:" + result);
        if (datas.length <= 24)
            return null;
        if (!datas[24].equals("dzzzqczc"))
            return null;//不是到站中转-汽车装车

        ZhongZhuanZhuangCheEntity entity = new ZhongZhuanZhuangCheEntity();
        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.order_number = (datas[11]);
            entity.pick_up_goods_num = (datas[12]);
            entity.pick_up_goods_count = (datas[13]);
            entity.customer = (datas[14]);
            entity.car = (datas[15]);
            entity.train_code = (datas[16]);
            entity.grain = (datas[17]);
            entity.platform = (datas[18]);
            entity.position = (datas[19]);
            entity.weight = (datas[20]);
            entity.haulier = (datas[21]);
            entity.phone = (datas[22]);
            entity.measure_type = (datas[23]);
            entity.work_flg = (datas[24]);
            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,
                order_number,
                pick_up_goods_num,
                pick_up_goods_count,
                customer,
                car,
                train_code,
                grain,
                platform,
                position,
                weight,
                haulier,
                phone,
                measure_type,
                work_flg,
                finish_count,
                single_weight,
                finish_weight,
                work_team,
                work_group,
                entd,
                start_time,
                end_time
        );
    }

}
