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

namespace Common
{
    public class PreTrackNoticeService
    {
        /// <summary>
        /// 平台默认的查询接口
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public RESTfulResult<List<PreTrackNotice>> doQuery(PreTrackNotice info)
        {
            DbHelper db = new DbHelper();
            RESTfulResult<PageList<List<PreTrackNotice>>> rm = db.doOption<PageList<List<PreTrackNotice>>>("pretracknotices", "/", new object[] { info }, 0);

            RESTfulResult<List<PreTrackNotice>> result = new RESTfulResult<List<PreTrackNotice>>();
            result.Succeed = rm.Succeed;
            result.Status = rm.Status;
            result.Message = rm.Message;
            result.ResultMessage = rm.ResultMessage;
            result.Code = rm.Code;
            if (rm.Data != null && rm.Data.list != null && rm.Data.list.Count > 0)
            {
                result.Data = rm.Data.list;
            }

            return result;
        }

        /// <summary>
        /// 计算提单的合同量：空则说明合适，有值则直接显示为提示信息
        /// 本次的提单量+历史已经运输的总量，若大于提单总量，则不允许继续计量了
        /// </summary>
        /// <param name="trackScale"></param>
        /// <returns></returns>
        public RESTfulResult<string> doCalculateWeight(PreTrackScale trackScale)
        {
            DbHelper db = new DbHelper();
            RESTfulResult<string> rm = db.doOption<string>("pretracknotices", "doCalculateWeight", new object[] { trackScale }, 1);
            return rm;
        }
    }
}
