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.
420 lines
20 KiB
420 lines
20 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.VendId;
|
|
po_detail.供应商名称 = itm.VendName;
|
|
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 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.SubSite;
|
|
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;
|
|
_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.ERP订单号 = 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.BeginTime == null ? string.Empty : itm.BeginTime.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.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 List<SCP_PRICE_EXPORT> GET_PRICE_EXECEL_Mode2(List<string> p_lst, bool p_IsDetail = false)
|
|
{
|
|
DataSet _ds = new DataSet();
|
|
var _exportDetailList = new List<SCP_PRICE_EXPORT>();
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
|
|
{
|
|
|
|
|
|
var _po = db.TB_PRICE.Where(p => p_lst.Contains(p.UID.ToString())).ToList();
|
|
|
|
|
|
_po.ForEach(itm =>
|
|
{
|
|
var po_detail = new SCP_PRICE_EXPORT();
|
|
po_detail.标识 = itm.UID.ToString();
|
|
po_detail.币种 = itm.Curr;
|
|
po_detail.单位 = itm.Unit;
|
|
po_detail.备注 = itm.Remarks;
|
|
po_detail.域 = itm.Site;
|
|
po_detail.零件编码 = itm.PartCode;
|
|
po_detail.供应商编号 = itm.VendId;
|
|
po_detail.地点 = itm.SubSite;
|
|
po_detail.是否临时价格 = itm.TemporaryPrice.ToString();
|
|
po_detail.零件基础价格 = itm.Amt.ToString();
|
|
po_detail.开始时间 = itm.StartTime.ToString();
|
|
po_detail.结束时间 = itm.EndTime.ToString();
|
|
po_detail.最新开始时间 = "";
|
|
po_detail.最新结束时间 = "";
|
|
_exportDetailList.Add(po_detail);
|
|
});
|
|
|
|
//var _dt = ConvertHelper.ToDataTable(_exportList);
|
|
//_ds.Tables.Add(_dt);
|
|
}
|
|
return _exportDetailList;
|
|
}
|
|
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.项目编号 = !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.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_ARRIVE_EXECEL(List<string> p_lst,string p_vendid="")
|
|
{
|
|
DataSet _ds = new DataSet();
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
|
|
{
|
|
List<V_TB_ARRIVE> _ls = new List<V_TB_ARRIVE>();
|
|
if (!string.IsNullOrEmpty(p_vendid))
|
|
{ _ls = db.V_TB_ARRIVE.Where(p => p_lst.Contains(p.ArrvBillNum) && p.VendId == p_vendid).ToList(); }
|
|
else
|
|
{
|
|
_ls = db.V_TB_ARRIVE.Where(p => p_lst.Contains(p.ArrvBillNum) ).ToList();
|
|
}
|
|
|
|
var str=JsonHelper.GetJson(_ls);
|
|
var _exportList = new List<SCP_ARRIVE_EXPORT>();
|
|
_ls.ForEach(itm =>
|
|
{
|
|
var _entity = new SCP_ARRIVE_EXPORT();
|
|
_entity.状态 = itm.State_DESC;
|
|
_entity.单据类型 = itm.BillType_DESC;
|
|
_entity.到货单号 = itm.ArrvBillNum;
|
|
_entity.发货单号 = itm.AsnBillNum;
|
|
_entity.要货看板号 = itm.AskBillNum;
|
|
_entity.订单号 = itm.PoBillNum;
|
|
_entity.供应商 = itm.VendName;
|
|
_entity.供应商编码 = itm.VendId;
|
|
_entity.地点 = itm.SubSite;
|
|
_entity.地点名称 = itm.Site_Desc;
|
|
_entity.到货日期 = itm.ShipTime == null ? string.Empty : itm.ShipTime.ToString("yyyyMMdd");
|
|
_exportList.Add(_entity);
|
|
});
|
|
var _dt = ConvertHelper.ToDataTable(_exportList);
|
|
_ds.Tables.Add(_dt);
|
|
var _exportDetailList = new List<SCP_ARRIVE_DETAIL_EXPORT>();
|
|
|
|
List<V_TB_ARRIVE_DETAIL> _detailList = new List<V_TB_ARRIVE_DETAIL>();
|
|
if (!string.IsNullOrEmpty(p_vendid))
|
|
{
|
|
_detailList = db.V_TB_ARRIVE_DETAIL.Where(p => p_lst.Contains(p.ArrvBillNum) && p.VendId == p_vendid).ToList();
|
|
}
|
|
else
|
|
{
|
|
_detailList = db.V_TB_ARRIVE_DETAIL.Where(p => p_lst.Contains(p.ArrvBillNum) ).ToList();
|
|
}
|
|
|
|
|
|
_detailList.ForEach(itm => {
|
|
var _entity = new SCP_ARRIVE_DETAIL_EXPORT();
|
|
_entity.单据号 =itm.ArrvBillNum;
|
|
_entity.发货单号 = itm.AsnBillNum;
|
|
_entity.订单号 = itm.PoBillNum;
|
|
_entity.订单行 = itm.PoLine.ToString();
|
|
_entity.零件号 = itm.PartCode;
|
|
_entity.零件名称 = itm.PartDesc1;
|
|
_entity.单位 = itm.Unit;
|
|
_entity.数量 = itm.Qty.ToString();
|
|
_entity.时间 = itm.ShipTime == null ? string.Empty : itm.ShipTime.Value.ToString("yyyyMMdd");
|
|
_entity.备注 = itm.Remark;
|
|
_exportDetailList.Add(_entity);
|
|
});
|
|
var _list_dt = ConvertHelper.ToDataTable(_exportDetailList);
|
|
_ds.Tables.Add(_list_dt);
|
|
}
|
|
return _ds;
|
|
}
|
|
}
|
|
}
|
|
|