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 MeterWorkCalibrationMainService
    {
        /// <summary>
        /// 校秤记录数据主表
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public RESTfulResult<List<MeterWorkCalibrationMain>> doQueryWf(MeterWorkCalibrationMain info)
        {
            DbHelper db = new DbHelper();
            RESTfulResult<PageList<List<MeterWorkCalibrationMain>>> rm = db.doOption<PageList<List<MeterWorkCalibrationMain>>>("meterworkcalibrationmains", "doQueryWf", new object[] { info }, 1);

            RESTfulResult<List<MeterWorkCalibrationMain>> result = new RESTfulResult<List<MeterWorkCalibrationMain>>();
            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;
        }

        public RESTfulResult<PbGetSomeModel<MeterWorkCalibrationMain, MeterWorkCalibrationBranch>> doQuerySomeWf(CommonPage<MeterWorkCalibrationMain> cpc)
        {
            DbHelper db = new DbHelper();
            RESTfulResult<PbGetSomeModel<MeterWorkCalibrationMain, MeterWorkCalibrationBranch>> rm = db.doOption<PbGetSomeModel<MeterWorkCalibrationMain, MeterWorkCalibrationBranch>>("meterworkcalibrationmains", "doQuerySomeWf", new object[] { cpc }, 1);
            return rm;
        }

        /// <summary>
        /// 查找校秤记录
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public RESTfulResult<List<MeterBaseCalibraRelation>> doQueryCalibrationWf(MeterWorkCalibrationMain info)
        {
            DbHelper db = new DbHelper();
            RESTfulResult<List<MeterBaseCalibraRelation>> rm = db.doOption<List<MeterBaseCalibraRelation>>("meterworkcalibrationmains", "doQueryCalibrationWf", new object[] { info }, 1);
            return rm;
        }

        /// <summary>
        /// 进行校秤保存
        /// </summary>
        public RESTfulResult<MeterWorkCalibrationBranch> doSaveWf(MeterWorkCalibrationMain main, MeterWorkCalibrationBranch info)
        {
            DbHelper db = new DbHelper();
            PbSomeModel<MeterWorkCalibrationMain, MeterWorkCalibrationBranch, string, string> pbSomeModel = new PbSomeModel<MeterWorkCalibrationMain, MeterWorkCalibrationBranch, string, string>();
            pbSomeModel.one = main;
            pbSomeModel.two = info;

            RESTfulResult<MeterWorkCalibrationBranch> rm = db.doOption<MeterWorkCalibrationBranch>("meterworkcalibrationbranchs", "doSaveWf", new object[] { pbSomeModel }, 1);
            return rm;
        }
    }
}
