using com.hnshituo.core.webapp.vo;
using Common;
using System;
using System.Collections.Generic;

namespace MeterConditionLibrary
{
    /// <summary>
    /// 九钢专用
    /// </summary>
    public class validUnloadAutomatic
    {
        public void ValidMethod(PreTrackScale scale)
        {
            Log lg = Log.GetInstance();
            try
            {
                string sqlUload = @"select  t.matter_no, t.prediction_type,t.meter_type_no from meter_base_auto_unload t where "
                    +"t.matter_no = '" + scale.matterNo + "'  and   t.prediction_type= '" + scale.predictionType + "'  and  t.meter_type_no='" + scale.meterTypeNo + "'  and VALUE_FLAG ='0'";
                PbModelDbService<List<PreTrackScale>> pbModelDbServiceLims = new PbModelDbService<List<PreTrackScale>>();
                RESTfulResult<List<PreTrackScale>> rESLims2 = pbModelDbServiceLims.executeSqlDataWf(sqlUload);
                if (rESLims2 != null && rESLims2.Data != null && rESLims2.Data.Count > 0)
                {
                    //自动装卸货
                    string sqlaDoUload = @"update METER_WORK_PRE_LINK set VALUE_FLAG = '1' ,UPDATE_MAN_NO = 'system', "
                        + "UPDATE_MAN_NAME = '自动装卸货' ,UPDATE_TIME = sysdate where PREDICTION_NO = '" + scale.predictionNo + "' and LINK_CODE in ('001021004','001021007') and VALUE_FLAG ='0'";
                    RESTfulResult<List<PreTrackScale>> resultUpdate = pbModelDbServiceLims.executeSqlDataWf(sqlaDoUload);
                    if (!resultUpdate.Succeed)
                    {
                        lg.WriteLog(17, "车号：" + scale.carNo + "；预报编号：" + scale.predictionNo + "自动装卸货失败！" + resultUpdate.ResultMessage);
                    }
                    else
                    {
                        lg.WriteLog(17, "车号：" + scale.carNo + "；预报编号：" + scale.predictionNo + "自动装卸货完成！");
                    }
                }
            }
            catch (Exception ex)
            {
                lg.WriteLog(17, "validUnloadAutomatic的ValidMethod方法" + ex);
            }
        }
    }
}