You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

384 lines
18 KiB

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity.Migrations;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using CK.SCP.Models;
using CK.SCP.Models.Enums;
using CK.SCP.Models.ScpEntity;
using CK.SCP.Models.ScpEntity.ExcelExportEnttity;
using CK.SCP.Models.ScpEntity.ExcelImportEntity;
using CK.SCP.Utils;
namespace CK.SCP.Controller
{
public class SCP_EXCEL_CONTROLLER
{
public static DataSet GET_PO_EXECEL(List<string> p_lst,bool p_IsDetail=false)
{
DataSet _ds = new DataSet();
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
if (p_IsDetail == false)
{
var _ls = db.V_TB_PO.Where(p => p_lst.Contains(p.PoBillNum)).ToList();
var _exportList = new List<SCP_PO_EXPORT>();
_ls.ForEach(itm =>
{
SCP_PO_EXPORT _export = new SCP_PO_EXPORT();
_export. = itm.State_DESC;
_export. = itm.ModType_DESC;
_export. = itm.PoBillNum;
_export.Erp订单编号 = itm.ErpBillNum;
_export. = itm.VendId;
_export. = itm.VendName;
_export. = itm.BeginTime == null ? string.Empty : ((DateTime)itm.BeginTime).ToString("yyyyMMdd");
_export. = itm.Site;
_export. = itm.Buyer;
_export. = itm.BuyerPhone;
_export. = itm.Remark;
_exportList.Add(_export);
});
var _dt = ConvertHelper.ToDataTable(_exportList);
_ds.Tables.Add(_dt);
}
var _detailList = db.V_TB_PO_DETAIL.Where(p => p_lst.Contains(p.PoBillNum)).ToList();
_detailList = SCP_PO_CONTROLLER.LOAD_PO_DETAIL_SUM(_detailList);
var _exportDetailList = new List<SCP_PO_DETAIL_EXPORT>();
_detailList.ForEach(itm =>
{
var po_detail = new SCP_PO_DETAIL_EXPORT();
po_detail. = itm.PoBillNum;
po_detail. = itm.State_DESC;
po_detail. = itm.PoLine.ToString();
po_detail. = itm.PartDesc1;
po_detail. = itm.PartCode;
po_detail. = itm.PlanQty.ToString();
po_detail. = itm.TempQty == null ? string.Empty : itm.TempQty.ToString();
po_detail. = itm.ShippedQty.ToString();
po_detail. = itm.ReceivedQty.ToString();
po_detail.退 = itm.RejectQty;
po_detail. = itm.EndTime == null ? string.Empty : ((DateTime)itm.BeginTime).ToString("yyyyMMdd"); ;
po_detail. = itm.PoUnit;
_exportDetailList.Add(po_detail);
});
var _list_dt = ConvertHelper.ToDataTable(_exportDetailList);
_ds.Tables.Add(_list_dt);
}
return _ds;
}
public static DataSet GET_OTD_VendId_REPORT_EXECEL(List<SCP_OTD_EXPORT> p_lst)
{
DataSet _ds = new DataSet();
var _exportList = new List<SCP_OTD_VendId_REPORT_EXPORT>();
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
p_lst.ForEach(itm =>
{
SCP_OTD_VendId_REPORT_EXPORT _entity = new SCP_OTD_VendId_REPORT_EXPORT();
_entity. = itm.AskBillNum;
_entity. = itm.VendId;
_entity. = itm.VendName;
_entity. = Convert.ToDateTime(itm.EndTime).ToString("yyyy/MM/dd");
_entity. = itm.AskQty.ToString();
_entity. = itm.ArriveQty.ToString();
_entity. = itm.Qty.ToString();
_entity. = itm.NntimelyQty.ToString();
_entity. = itm.OTD.ToString();
_entity. = itm.ArriveOTD.ToString();
_exportList.Add(_entity);
});
var _dt = ConvertHelper.ToDataTable(_exportList);
_ds.Tables.Add(_dt);
}
return _ds;
}
public static List<SCP_PO_DETAIL_EXPORT_MODEL> GET_PO_EXECEL_Model(List<string> p_lst, bool p_IsDetail = false)
{
DataSet _ds = new DataSet();
var _exportDetailList = new List<SCP_PO_DETAIL_EXPORT_MODEL>();
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
var _detailList = db.V_TB_PO_DETAIL.Where(p => p_lst.Contains(p.UID.ToString())).ToList();
var polist=_detailList.Select(p => p.PoBillNum);
var _po = db.V_TB_PO.Where(p =>polist.Contains(p.PoBillNum)).FirstOrDefault();
_detailList.ForEach(itm =>
{
var po_detail = new SCP_PO_DETAIL_EXPORT_MODEL();
po_detail. = itm.PoBillNum;
po_detail. = itm.PoLine.ToString();
po_detail. = itm.PartDesc1;
if (!string.IsNullOrEmpty(itm.PartDesc2))
{
po_detail. += itm.PartDesc2;
}
po_detail. = itm.PartCode;
po_detail. = "0";
po_detail. = itm.VendName;
po_detail. = itm.VendId;
po_detail. =DateTime.Now.ToShortDateString();
po_detail. = DateTime.Now.ToShortDateString();
po_detail. = itm.PoUnit;
po_detail. = _po.Site;
po_detail. = _po.Remark;
po_detail. = _po.Buyer;
po_detail. = _po.BuyerPhone;
po_detail. = itm.Price.ToString();
po_detail. = itm.Currency;
po_detail. = itm.DockCode;
po_detail. = itm.ProjectId;
po_detail. = string.Empty;
_exportDetailList.Add(po_detail);
});
//var _list_dt = ConvertHelper.ToDataTable(_exportDetailList);
//_ds.Tables.Add(_list_dt);/
}
return _exportDetailList;
}
public static DataSet GET_PALLET_EXECEL(List<string> p_lst)
{
DataSet _ds = new DataSet();
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
var _ls = db.V_TB_PALLET_DETAIL.Where(p => p_lst.Contains(p.AsnBillNum)).ToList();
var _exportList = new List<SCP_PALLET_EXPORT>();
_ls.ForEach(itm =>
{
SCP_PALLET_EXPORT _entity = new SCP_PALLET_EXPORT();
_entity. = itm.PoBillNum;
_entity. = itm.AsnBillNum;
_entity. = itm.PalletNum;
_entity. = itm.PlateNumber;
_entity. = itm.PartCode;
_entity. = itm.PartDesc1 + itm.PartDesc2;
_entity. = itm.Qty.ToString();
_entity. = itm.PackQty.ToString();
_entity. = itm.VendName;
_exportList.Add(_entity);
});
var _dt = ConvertHelper.ToDataTable(_exportList);
_ds.Tables.Add(_dt);
}
return _ds;
}
public static DataSet GET_ASK_EXECEL(List<string> p_lst)
{
DataSet _ds = new DataSet();
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
var _ls = db.V_TB_ASK.Where(p => p_lst.Contains(p.AskBillNum)).ToList();
var _exportList = new List<SCP_ASK_EXPORT>();
_ls.ForEach(itm =>
{
SCP_ASK_EXPORT _entity = new SCP_ASK_EXPORT();
_entity. = itm.State_DESC;
_entity. = itm.ModType_DESC;
_entity. = itm.AskBillNum;
_entity. = itm.PoBillNum;
_entity. = itm.ErpBillNum;
_entity. = itm.VendName;
_entity. = itm.BeginTime == null ? string.Empty : itm.BeginTime.Value.ToString("yyyyMMdd");
_entity. = itm.Site_Desc;
_entity. = itm.EndTime == null ? string.Empty : itm.EndTime.Value.ToString("yyyyMMdd");
_entity. = itm.Buyer;
_entity. = itm.BuyerPhone;
_exportList.Add(_entity);
});
var _dt = ConvertHelper.ToDataTable(_exportList);
_ds.Tables.Add(_dt);
var _detailList = db.V_TB_ASK_DETAIL.Where(p => p_lst.Contains(p.AskBillNum)).ToList();
var _exportDetailList = new List<SCP_ASK_DETAIL_EXPORT>();
_detailList.ForEach(itm =>
{
SCP_ASK_DETAIL_EXPORT _entity = new SCP_ASK_DETAIL_EXPORT();
_entity. = itm.AskBillNum;
_entity. = itm.PoLine.ToString();
_entity. = itm.PartDesc1;
_entity. = itm.PartCode;
_entity. = itm.PoUnit;
_entity. = itm.PackQty.ToString();
// _entity.币种 = itm.CurrencyDesc;
//_entity.价格 = itm.Price.ToString();
_entity. = itm.AskQty.ToString();
_entity. = string.IsNullOrEmpty(itm.Remark)?string.Empty:itm.Remark.ToString();
_entity. = itm.EndTime == null ? string.Empty : itm.EndTime.Value.ToString("yyyyMMdd");
_exportDetailList.Add(_entity);
});
var _list_dt = ConvertHelper.ToDataTable(_exportDetailList);
_ds.Tables.Add(_list_dt);
}
return _ds;
}
public static DataSet GET_ASN_EXECEL(List<string> p_lst)
{
DataSet _ds = new DataSet();
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
var _ls = db.V_TB_ASN.Where(p => p_lst.Contains(p.AsnBillNum)).ToList();
var _exportList = new List<SCP_ASN_EXPORT>();
_ls.ForEach(itm =>
{
var _entity = new SCP_ASN_EXPORT();
_entity. = itm.State_DESC;
_entity. = itm.AsnBillNum;
_entity. = itm.PlateNumber;
_entity. = itm.VendName;
_entity. = itm.PoBillNum;
_entity. = itm.ShipTime == null ? string.Empty : itm.ShipTime.Value.ToString("yyyyMMdd");
_entity. = itm.ShipUser;
_entity. = itm.ReceiveTime == null ? string.Empty : itm.ReceiveTime.Value.ToString("yyyyMMdd");
_entity. = itm.ReceiveUser;
_entity. = itm.Site_Desc;
_entity. = itm.Remark;
_exportList.Add(_entity);
});
var _dt = ConvertHelper.ToDataTable(_exportList);
_ds.Tables.Add(_dt);
var _exportDetailList = new List<SCP_ASN_DETAIL_EXPORT>();
var _detailList = db.V_TB_ASN_DETAIL.Where(p => p_lst.Contains(p.AsnBillNum)).ToList();
_detailList.ForEach(itm =>{
var _entity = new SCP_ASN_DETAIL_EXPORT();
_entity. = itm.AsnBillNum;
_entity. = itm.PackQty.ToString();
_entity. = itm.VendPartCode;
_entity. = itm.Qty.ToString();
_entity. = itm.PartCode;
_entity. = itm.PartDesc1;
_entity. = itm.CurrencyDesc;
_entity. = itm.Batch;
_entity. = itm.VendBatch;
_entity. = itm.ProduceDate==null?string.Empty: itm.ProduceDate.Value.ToString("yyyyMMdd");
_entity. = itm.PoUnit;
_entity. = itm.Price.ToString();
_exportDetailList.Add(_entity);
});
var _list_dt = ConvertHelper.ToDataTable(_exportDetailList);
_ds.Tables.Add(_list_dt);
}
return _ds;
}
public static DataSet GET_INVOICE_EXECEL(List<string> p_lst)
{
DataSet _ds = new DataSet();
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
var _ls = db.V_TB_INVOICE.Where(p => p_lst.Contains(p.InvcBillNum)).ToList();
var _exportList = new List<SCP_INVOICE_EXPORT>();
_ls.ForEach(itm =>
{
var _entity = new SCP_INVOICE_EXPORT();
_entity. = itm.State_DESC;
_entity. = itm.InvcBillNum;
_entity. = itm.InvoiceNum;
_entity. = itm.VendName;
_entity. = itm.Amount.ToString();
_entity. = itm.Tax.ToString();
_entity. = itm.TaxAmount.ToString();
_entity. = itm.ContractPrice.ToString();
_entity. = itm.BlancePrice.ToString();
_entity. = itm.Total.ToString();
_entity. = itm.CreateTime == null ? string.Empty : itm.CreateTime.Value.ToString("yyyyMMdd");
_entity. = itm.ExpressNum;
_entity. = itm.Remark;
_exportList.Add(_entity);
});
var _dt = ConvertHelper.ToDataTable(_exportList);
_ds.Tables.Add(_dt);
var _exportDetailList = new List<SCP_INVOICE_DETAIL_EXPORT>();
var _detailList = db.V_TB_INVOICE_DETAIL.Where(p => p_lst.Contains(p.InvcBillNum)).ToList();
_detailList.ForEach(itm => {
var _entity = new SCP_INVOICE_DETAIL_EXPORT();
_entity. = itm.InvcBillNum;
_entity. = itm.InvoiceNum;
_entity.ERP收货单号 = itm.ErpRecvBillNum;
_entity.WMS收货单号 = itm.RecvBillNum;
_entity. = !string.IsNullOrEmpty(itm.ProjectId)?itm.ProjectId:string.Empty;
_entity. = itm.PoBillNum;
_entity. = itm.PoLineNum.ToString();
_entity. = itm.AsnBillNum;
_entity. = itm.PartDesc1;
_entity. = itm.PartCode;
_entity. = itm.Currency;
_entity. = itm.Price.ToString();
_entity. = itm.PurCost==null?"0":itm.PurCost.Value.ToString();
_entity.= itm.StdCost == null ? "0" : itm.StdCost.Value.ToString();
// _entity.要货日期 = itm.BeginTime == null ? string.Empty : itm.BeginTime.Value.ToString("yyyyMMdd");
//_entity.折扣价格 = itm.DiscountPrice.ToString();
//_entity.折扣备注 = itm.DiscountRemark;
_entity. = itm.Qty.ToString();
_entity. = itm.Remark;
_exportDetailList.Add(_entity);
});
var _list_dt = ConvertHelper.ToDataTable(_exportDetailList);
_ds.Tables.Add(_list_dt);
}
return _ds;
}
public static DataSet GET_OTD_REPORT_EXECEL(List<SCP_OTD_EXPORT> p_lst)
{
DataSet _ds = new DataSet();
var _exportList = new List<SCP_OTD_REPORT_EXPORT>();
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
p_lst.ForEach(itm =>
{
SCP_OTD_REPORT_EXPORT _entity = new SCP_OTD_REPORT_EXPORT();
_entity. = itm.VendId;
_entity. = itm.VendName;
_entity. = itm.AskBillNum;
_entity. = itm.PartCode;
_entity. = itm.PartName;
_entity. = Convert.ToDateTime(itm.EndTime).ToString("yyyy/MM/dd");
_entity. = itm.AskQty.ToString();
_entity. = itm.ArriveQty.ToString();
_entity. = itm.Qty.ToString();
_entity. = itm.NntimelyQty.ToString();
_entity. = itm.OTD.ToString();
_entity. = itm.ArriveOTD.ToString();
_exportList.Add(_entity);
});
var _dt = ConvertHelper.ToDataTable(_exportList);
_ds.Tables.Add(_dt);
}
return _ds;
}
}
}