using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using CY.IDAL.Inquiry;
|
using AbstractFactory;
|
using CY.Model;
|
using CY.Infrastructure.Query;
|
using CY.Model.Inquiry;
|
|
namespace CY.BLL.Inquiry
|
{
|
/// <summary>
|
/// 纸张相关业务类
|
/// </summary>
|
public class PaperInfoBLL
|
{
|
IPaperInfoDAL _iPaperInfoDAL = null;
|
|
public PaperInfoBLL()
|
{
|
_iPaperInfoDAL = Factory.GetDALByInterfaceName(DALInterface.IPaperInfoDAL) as IPaperInfoDAL;
|
}
|
|
/// <summary>
|
/// 分页获取纸张列表
|
/// </summary>
|
/// <param name="paperName">品牌名称</param>
|
/// <param name="pa">分页参数</param>
|
/// <returns></returns>
|
public IEnumerable<SysInquiry_PaperInfo> GetPaperListByPaging(string paperName, int paperTypeId,string status, Pagination pa)
|
{
|
IEnumerable<SysInquiry_PaperInfo> paperList = _iPaperInfoDAL.GetPaperListByPaging(paperName,paperTypeId,status,pa);
|
|
IList<SysInquiry_PaperInfo> tempList = new List<SysInquiry_PaperInfo>();
|
|
SysInquiry_PaperInfo model = null;
|
|
foreach (SysInquiry_PaperInfo paperModel in paperList)
|
{
|
tempList.Add(GetPaperModel(paperModel.PapeId));
|
}
|
return tempList;
|
}
|
|
|
|
/// <summary>
|
/// 根据paperId获取纸张信息
|
/// </summary>
|
/// <param name="paperId"></param>
|
/// <returns></returns>
|
public SysInquiry_PaperInfo GetPaperModel(int paperId)
|
{
|
IList<SysInquiry_PaperInfo> paperList = _iPaperInfoDAL.GetPaperList(paperId).OrderBy(p=>p.GramWeight).ToList<SysInquiry_PaperInfo>();
|
SysInquiry_PaperInfo model = new SysInquiry_PaperInfo();
|
if (paperList != null && paperList.Count() > 0)
|
{
|
model.PapeId = paperList[0].PapeId;
|
model.PaperName = paperList[0].PaperName;
|
model.Status = paperList[0].Status;
|
model.DefaultBrandId = paperList[0].DefaultBrandId;
|
model.DefaultBrandName = paperList[0].DefaultBrandName;
|
model.PaperTypeId = paperList[0].PaperTypeId;
|
model.PaperTypeName = paperList[0].PaperTypeName;
|
model.OrderNum = paperList[0].OrderNum;
|
model.GramWeights = string.Empty;
|
foreach (SysInquiry_PaperInfo paperModel in paperList)
|
{
|
model.GramWeights += paperModel.GramWeight.ToString() + "|";
|
}
|
if (!string.IsNullOrEmpty(model.GramWeights))
|
{
|
model.GramWeights = model.GramWeights.Substring(0, model.GramWeights.Length - 1);
|
}
|
}
|
return model;
|
}
|
|
/// <summary>
|
/// 获取最新排序顺序
|
/// </summary>
|
/// <returns></returns>
|
public int GetOrderNumByMax(int paperTypeId)
|
{
|
return _iPaperInfoDAL.GetOrderNumByMax(paperTypeId);
|
}
|
|
/// <summary>
|
/// 根据paperId获取其对应的品牌列表
|
/// </summary>
|
/// <param name="paperId"></param>
|
/// <returns></returns>
|
public IEnumerable<SysInquiry_BrandInfo> GetBrandInfoListByPaper(int paperId)
|
{
|
return _iPaperInfoDAL.GetBrandInfoListByPaper(paperId);
|
}
|
|
/// <summary>
|
/// 判断是否有相同的纸扎名称
|
/// </summary>
|
/// <param name="brandName"></param>
|
/// <returns></returns>
|
public bool IsExistspeperName(string peperName)
|
{
|
return _iPaperInfoDAL.IsExistspeperName(peperName);
|
}
|
|
/// <summary>
|
/// 获取最新的纸张编号
|
/// </summary>
|
/// <returns></returns>
|
public int GetNewPaperId()
|
{
|
return _iPaperInfoDAL.GetNewPaperId();
|
}
|
|
/// <summary>
|
/// 新增纸张
|
/// </summary>
|
/// <param name="modelList"></param>
|
/// <returns></returns>
|
public bool InsertPaper(IList<SysInquiry_PaperInfo> modelList,IList<SysInquiry_BrandListByPaper> brandList)
|
{
|
return _iPaperInfoDAL.InsertPaper(modelList, brandList);
|
}
|
|
/// <summary>
|
/// 修改纸张
|
/// </summary>
|
/// <param name="modelList"></param>
|
/// <returns></returns>
|
public bool UpdatePaper(IList<SysInquiry_PaperInfo> modelList,IList<SysInquiry_BrandListByPaper> brandList)
|
{
|
return _iPaperInfoDAL.UpdatePaper(modelList, brandList);
|
}
|
|
/// <summary>
|
/// 获取有效的纸张列表
|
/// </summary>
|
/// <returns></returns>
|
public IEnumerable<SysInquiry_PaperInfo> GetPaperList()
|
{
|
IEnumerable<SysInquiry_PaperInfo> paperList=_iPaperInfoDAL.GetPaperList();
|
|
IList<SysInquiry_PaperInfo> tempList = new List<SysInquiry_PaperInfo>();
|
|
SysInquiry_PaperInfo model = null;
|
|
foreach (SysInquiry_PaperInfo paperModel in paperList)
|
{
|
model = new SysInquiry_PaperInfo();
|
model.PapeId = paperModel.PapeId;
|
model.PaperName = paperModel.PaperName;
|
if (!IsExistInPaperInfoList(tempList,model.PapeId))
|
tempList.Add(model);
|
|
}
|
return tempList;
|
}
|
|
/// <summary>
|
/// 获取所有有效的纸张包括克重
|
/// </summary>
|
/// <returns></returns>
|
public IEnumerable<SysInquiry_PaperInfo> GetAllPaperList()
|
{
|
IEnumerable<SysInquiry_PaperInfo> paperList = _iPaperInfoDAL.GetAllPaperList();
|
IList<SysInquiry_PaperInfo> tempList = new List<SysInquiry_PaperInfo>();
|
|
SysInquiry_PaperInfo model = null;
|
|
foreach (SysInquiry_PaperInfo paperModel in paperList)
|
{
|
model = GetPaperModel(paperModel.PapeId);
|
if (!IsExistInPaperInfoList(tempList, model.PapeId))
|
tempList.Add(GetPaperModel(paperModel.PapeId));
|
}
|
return tempList;
|
}
|
|
/// <summary>
|
/// 根据PaperId获取所有克重
|
/// </summary>
|
/// <param name="PaperId"></param>
|
/// <returns></returns>
|
public List<SysInquiry_PaperInfo> GetPaperListBygramWeight(int paperId)
|
{
|
IEnumerable<SysInquiry_PaperInfo> paperList = _iPaperInfoDAL.GetPaperList();
|
List<SysInquiry_PaperInfo> gramWeightList = paperList.Where(p => p.PapeId == paperId).ToList<SysInquiry_PaperInfo>();
|
return gramWeightList;
|
}
|
|
private bool IsExistInPaperInfoList(IList<SysInquiry_PaperInfo> tempList, int papeId)
|
{
|
IList<SysInquiry_PaperInfo> result = tempList.Where(p => p.PapeId == papeId).ToList<SysInquiry_PaperInfo>();
|
return (result != null && result.Count > 0) ? true : false;
|
}
|
|
/// <summary>
|
/// 获取纸张所有信息包含价格
|
/// </summary>
|
/// <returns></returns>
|
public IEnumerable<Inquiry_PaperPriceInfo> GetAllPaperPriceList(int paperId, int brandId, Guid inquiryId)
|
{
|
return _iPaperInfoDAL.GetAllPaperPriceList(paperId, brandId, inquiryId);
|
}
|
|
/// <summary>
|
/// 获取纸张的默认品牌ID
|
/// </summary>
|
/// <param name="paperId"></param>
|
/// <returns></returns>
|
public int GetDefaultBrandByPaperId(int paperId)
|
{
|
SysInquiry_PaperInfo model = GetPaperModel(paperId);
|
return model.DefaultBrandId.Value;
|
}
|
|
|
|
/// <summary>
|
/// 根据纸张Id和品牌ID保存纸价
|
/// </summary>
|
/// <param name="modelList"></param>
|
/// <returns></returns>
|
public bool SavePaperPrice(List<Inquiry_PaperPriceInfo> modelList, InquiryCondition inquiryCondition)
|
{
|
return _iPaperInfoDAL.SavePaperPrice(modelList,inquiryCondition);
|
}
|
|
/// <summary>
|
/// 获取纸张的吨价
|
/// </summary>
|
/// <param name="paperId"></param>
|
/// <param name="gramWeight"></param>
|
/// <param name="brandId"></param>
|
/// <param name="inquiryId"></param>
|
/// <returns></returns>
|
public decimal GetTonsOfPrice(int paperId, int gramWeight, int brandId, Guid inquiryId)
|
{
|
return _iPaperInfoDAL.GetTonsOfPrice(paperId, gramWeight, brandId, inquiryId);
|
}
|
|
/// <summary>
|
/// 获取纸张的品牌列表,第一个是默认品牌
|
/// </summary>
|
/// <param name="paperId"></param>
|
/// <returns></returns>
|
public IList<SysInquiry_BrandInfo> GetBrandInfoByPaper(int paperId)
|
{
|
return _iPaperInfoDAL.GetBrandInfoByPaper(paperId);
|
}
|
|
|
/// <summary>
|
/// 获取纸张类型下的所有有效纸张
|
/// </summary>
|
/// <param name="paperTypeId"></param>
|
/// <returns></returns>
|
public IEnumerable<SysInquiry_PaperInfo> GetPaperListByPaperType(int paperTypeId)
|
{
|
return _iPaperInfoDAL.GetPaperListByPaperType(paperTypeId);
|
}
|
|
}
|
}
|