package com.mq.zhicang.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/8 0008 18:03
 * 文件名称 ZhiCangEntity
 * 说明:
 * <p>
 * create TABLE `zhicang_info` (
 * `id` INTEGER PRIMARY KEY AUTOINCREMENT,
 * `task_code` varchar(2000) DEFAULT NULL COMMENT '任务编码',
 * `period_id` varchar(2000) DEFAULT NULL COMMENT '期间ID',
 * `unit_id` varchar(2000) DEFAULT NULL COMMENT '单位ID',
 * `version_id` varchar(2000) DEFAULT NULL COMMENT '版本ID',
 * `report_type` varchar(2000) DEFAULT NULL COMMENT '报表类型',
 * `report_id` varchar(2000) DEFAULT NULL COMMENT '报表ID',
 * `next_id` varchar(2000) DEFAULT NULL COMMENT '下环节ID',
 * `work_index_id` varchar(2000) DEFAULT NULL COMMENT '业务编码指标ID',
 * `process_id` varchar(2000) DEFAULT NULL COMMENT '流程ID',
 * `work_number` varchar(2000) DEFAULT NULL COMMENT '单据号(入门单号)',
 * `status` varchar(2000) DEFAULT NULL COMMENT '状态',
 * `car` varchar(2000) DEFAULT NULL COMMENT '车辆编号',
 * `grain` varchar(2000) DEFAULT NULL COMMENT '粮油品种',
 * `level` varchar(2000) DEFAULT NULL COMMENT '粮食等级',
 * `plan_house` varchar(2000) DEFAULT NULL COMMENT '拟入出仓号',
 * `plan_position` varchar(2000) DEFAULT NULL COMMENT '拟入出货位号',
 * `quality` varchar(2000) DEFAULT NULL COMMENT '粮食质量信息',
 * `weight` varchar(2000) DEFAULT NULL COMMENT '毛/皮重(公斤)',
 * `customer` varchar(2000) DEFAULT NULL COMMENT '客户名称',
 * `work_flg` varchar(2000) DEFAULT NULL COMMENT '业务标识',
 * `real_house` varchar(2000) DEFAULT NULL COMMENT '实际仓房',
 * `real_position` varchar(2000) DEFAULT NULL COMMENT '实际货位',
 * `deduct_water` varchar(2000) DEFAULT NULL COMMENT '现场扣水',
 * `deduct_sundries` varchar(2000) DEFAULT NULL COMMENT '现场扣杂',
 * `deduct_other` varchar(2000) DEFAULT NULL COMMENT '现场扣其他',
 * `deduct_pack` varchar(2000) DEFAULT NULL COMMENT '包装物扣量',
 * `deduct_percent` varchar(2000) DEFAULT NULL COMMENT '现场扣百分比',
 * `work_unit` varchar(2000) DEFAULT NULL COMMENT '作业方名称',
 * `start_time` varchar(2000) DEFAULT NULL COMMENT '作业开始时间',
 * `end_time` varchar(2000) DEFAULT NULL COMMENT '作业结束时间',
 * `remark` varchar(2000) DEFAULT NULL COMMENT '备注',
 * `keeper` varchar(2000) DEFAULT NULL COMMENT '保管员',
 * `pack_type` 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 '作业组',
 * `real_house_id` varchar(2000) DEFAULT NULL COMMENT '实际仓房ID',
 * `real_position_id` varchar(2000) DEFAULT NULL COMMENT '实际货位ID',
 * `stop_reasons` varchar(2000) DEFAULT NULL COMMENT '终止原因'
 * ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='值仓IC卡表';
 **/
public class ZhiCangEntity 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 car;
    //粮油品种
    public String grain;
    //粮食等级
    public String level;
    //拟入出仓号
    public String plan_house;
    //拟入出货位号
    public String plan_position;
    //质量信息
    public String quality;
    //毛/皮重(公斤)
    public String weight;
    //业务标识
    public String work_flg;
    //实际仓房
    public String real_house;
    //实际货位
    public String real_position;
    //现场扣水
    public String deduct_water;
    //现场扣杂
    public String deduct_sundries;
    //现场扣其他
    public String deduct_other;
    //包装物扣量
    public String deduct_pack;
    //现场扣百分比
    public String deduct_percent;
    //作业方名称
    public String work_unit;
    //作业开始时间
    public String start_time;
    //作业结束时间
    public String end_time;
    //备注
    public String remark;
    //保管员
    public String keeper;
    //客户名称
    public String customer;
    //包装方式
    public String pack_type;
    //装卸件数
    public String finish_count;
    //作业队
    public String work_team;
    //作业组
    public String work_group;
    //实际仓房id
    public String real_house_id;
    //实际货位id
    public String real_position_id;
    //终止原因
    public String stop_reasons;
    // 是否回杂
    public String back_impurity;

    /**
     * 模拟卡片数据
     */
    public static String testCardData() {
        return "crkyw|" +
                "11|" +
                "164|" +
                "ec93fe656f584052a1fc854080f32eee|" +
                "1|" +
                "dc44cd5c97ea11e9ab6a009027e007ac|" +
                "5|" +
                "I_4028810b5cf6f918015cf707e5120002|" +
                "A7B1FDB54DE7B32D6F8067FEFE2BF52F|" +
                "qcrk_20120190626006|" +
                "0|" +
                "测试车辆编号|" +
                "测试粮食品种|" +
                "测试粮食等级|" +
                "测试仓号|" +
                "测试货位|" +
                "测试质量信息|" +
                "测试毛/皮重|" +
                "测试客户名称|" +
                "zc";

    }

    /**
     * 解析卡片数据
     */
    public static ZhiCangEntity 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("zc"))
            return null;//不是值仓数据

        ZhiCangEntity entity = new ZhiCangEntity();
        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.car = (datas[11]);
            entity.grain = (datas[12]);
            entity.level = (datas[13]);
            entity.plan_house = (datas[14]);
            entity.plan_position = (datas[15]);
            entity.quality = (datas[16]);
            entity.weight = (datas[17]);
            entity.customer = (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,
                car,
                grain,
                level,
                plan_house,
                plan_position,
                quality,
                weight,
                customer,
                work_flg,
                real_house,
                real_position,
                deduct_water,
                deduct_sundries,
                deduct_other,
                deduct_pack,
                deduct_percent,
                work_unit,
                start_time,
                end_time,
                remark,
                keeper,
                pack_type,
                finish_count,
                work_team,
                work_group,
                real_house_id,
                real_position_id
        );
    }

    /**
     * 获取写入信息天津
     */
    public String getWriteDataTianjin() {
        return handleDatas(
                task_code,
                period_id,
                unit_id,
                version_id,
                report_type,
                report_id,
                next_id,
                work_index_id,
                process_id,
                work_number,
                status,
                car,
                grain,
                level,
                plan_house,
                plan_position,
                quality,
                weight,
                customer,
                work_flg,
                real_house,
                real_position,
                deduct_water,
                deduct_sundries,
                deduct_other,
                deduct_pack,
                deduct_percent,
                work_unit,
                start_time,
                end_time,
                remark,
                keeper,
                pack_type,
                finish_count,
                work_team,
                work_group,
                real_house_id,
                real_position_id,
                stop_reasons
        );
    }

    /**
     * 获取写入信息 山西
     */
    public String getWriteDataShanxi() {
        return handleDatas(
                task_code,
                period_id,
                unit_id,
                version_id,
                report_type,
                report_id,
                next_id,
                work_index_id,
                process_id,
                work_number,
                status,
                car,
                grain,
                level,
                plan_house,
                plan_position,
                quality,
                weight,
                customer,
                work_flg,
                real_house,
                real_position,
                deduct_water,
                deduct_sundries,
                deduct_other,
                deduct_pack,
                deduct_percent,
                work_unit,
                start_time,
                end_time,
                remark,
                keeper,
                pack_type,
                finish_count,
                work_team,
                work_group,
                real_house_id,
                real_position_id,
                back_impurity
        );
    }

}
