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

namespace MeterConditionLibrary
{
    public class validArea
    {
        MeterWorkCarActualFirstService meterWorkCarActualFirstService = new MeterWorkCarActualFirstService();

        MeterBaseSpotInfoService meterBaseSpotInfoService = new MeterBaseSpotInfoService();
        public bool ValidMethod(MeterBaseSpotInfo spot,string carNo)
        {
            //查询该车号一次数据
            RESTfulResult<List<MeterWorkCarActualFirst>> rmFirst = meterWorkCarActualFirstService.doQueryByFlag(new MeterWorkCarActualFirst { carNo = carNo });
            if (rmFirst.Succeed)
            {
                if (rmFirst.Data == null || rmFirst.Data.Count == 0)
                {
                    return true;
                }
                else
                {
                    //查询称点信息
                    RESTfulResult<List<MeterBaseSpotInfo>> rmSpot = meterBaseSpotInfoService.doQueryWf(new MeterBaseSpotInfo { baseSpotNo = rmFirst.Data[0].baseSpotNo });
                    if (rmSpot.Succeed)
                    {
                        if (rmSpot.Data == null || rmSpot.Data.Count == 0)
                        {
                            return true;
                        }
                        else
                        {
                            if (rmSpot.Data[0].spotAreaNo == spot.spotAreaNo)
                            {
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                    }
                }
            }
            return true;
        }
    }
}
