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

namespace Common
{
    public class MeterWorkPreLinkService
    {
        public RESTfulResult<List<MeterWorkPreLink>> doQueryWf(MeterWorkPreLink info)
        {
            DbHelper db = new DbHelper();
            RESTfulResult<PageList<List<MeterWorkPreLink>>> rm = db.doOption<PageList<List<MeterWorkPreLink>>>("meterworkprelinks", "/", new object[] { info }, 0);

            RESTfulResult<List<MeterWorkPreLink>> result = new RESTfulResult<List<MeterWorkPreLink>>();
            result.Succeed = rm.Succeed;
            result.Status = rm.Status;
            result.Message = rm.Message;
            result.ResultMessage = rm.ResultMessage;
            result.Code = rm.Code;
            if (rm.Succeed && rm.Data != null && rm.Data.list != null)
            {
                result.Data = rm.Data.list.OrderBy(s => s.predictionNo).ThenBy(s => s.seqNo).ToList();
            }
            return result;
        }

        /// <summary>
        /// 一车联运判断上一车有没有进行卸货确认
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public RESTfulResult<int> combinedLink(MeterWorkPreLink info)
        {
            DbHelper db = new DbHelper();
            RESTfulResult<int> rm = db.doOption<int>("meterworkprelinks", "combinedLink", new object[] { info }, 1);
            return rm;
        }


        /// <summary>
        /// 采购、销售业务查询是否存在历史未卸货的数据
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public RESTfulResult<List<MeterWorkPreLink>> doQueryNoXh(MeterWorkPreLink info)
        {

            DbHelper db = new DbHelper();
            RESTfulResult<List<MeterWorkPreLink>> result = db.doOption<List<MeterWorkPreLink>>("meterworkprelinks", "doQueryNoXh", new object[] { info }, 1);
            return result;
        }
    }
}
