using com.hnshituo.core.webapp.vo;
using Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MeterConditionLibrary
{
    public class validCalibration
    {
        public bool ValidMethod(MeterWorkCalibrationMain scale, out string msgInfo)
        {
            msgInfo = "";

            //若计量员记录则不验证，则为true
            if (PbCache.isNotValid)
            {
                return true;
            }

            MeterWorkCalibrationMainService service = new MeterWorkCalibrationMainService();
            RESTfulResult<List<MeterBaseCalibraRelation>> rmR = service.doQueryCalibrationWf(scale);
            if (rmR.Succeed)
            {
                //查到了数据就认为还有未校秤的数据
                if (rmR.Data != null && rmR.Data.Count > 0)
                {
                    msgInfo = "未校秤无法计量";
                    return false;
                }
                else 
                {
                    return true; 
                }
            }
            else
            {
                msgInfo = "获取校秤数据失败";
                return false;
            }
        }
    }
}
