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.
174 lines
9.4 KiB
174 lines
9.4 KiB
using ICSSoft.ERPWMS.Entity;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ICSSoft.ERPWMS.SQL
|
|
{
|
|
public class GetDNInfo
|
|
{
|
|
public static Result Get(GetDNCondition condition)
|
|
{
|
|
Result res = new Result();
|
|
try
|
|
{
|
|
if (condition.PageIndex == null)
|
|
{
|
|
throw new Exception("页码未传!");
|
|
}
|
|
if (condition.PageSize == null)
|
|
{
|
|
throw new Exception("每页数量未传!");
|
|
}
|
|
if (string.IsNullOrWhiteSpace(condition.WorkPoint))
|
|
{
|
|
res.IsSuccess = false;
|
|
res.Message = "站点参数为空!";
|
|
return res;
|
|
}
|
|
string WorkPoint = ICSHelper.GetConnectStringTest(condition.WorkPoint);
|
|
|
|
if (WorkPoint == "NotExit")
|
|
{
|
|
throw new Exception("站点编码不存在!");
|
|
}
|
|
|
|
string sql1 = @"Select distinct a.ID,a.DNCode as '到货单号',a.Sequence as '到货单行号',a.VenCode as '供应商代码',a.InvCode as '物料代码',a.Quantity as '数量',
|
|
a.Amount as '辅计量数量',a.Status as '状态',a.CreatePerson as '创建人',a.CreateDateTime as '创建时间',n.POCode as '采购订单',n.Sequence as '采购订单行号',
|
|
a.ASNCode as '送货单号',a.WorkPoint as '站点',a.Mtime as '操作时间',d.cFree1 as '自由项1',d.cFree2 as '自由项2',
|
|
d.cFree3 as '自由项3',d.cFree4 as '自由项4',d.cFree2 as '自由项5',a.dntype as '类型'
|
|
from ICSDeliveryNotice a
|
|
inner JOIN ICSASNDETAIL C ON A.ASNCode = C.ASNCode and a.WorkPoint = c.WorkPoint
|
|
INNER JOIN ICSInventoryLot e ON c.LotNo=e.LotNo AND a.InvCode=e.InvCode AND c.WorkPoint=e.WorkPoint and a.ExtensionID = e.ExtensionID
|
|
INNER JOIN ICSInventoryLotDetail m on e.LotNo=m.LotNo and e.WorkPoint=m.WorkPoint
|
|
INNER JOIN ICSPurchaseOrder n ON m.TransCode =n.POCode AND m.TransSequence=n.Sequence AND a.PODetailID=n.PODetailID AND m.WorkPoint=n.WorkPoint
|
|
inner JOIN ICSExtension D ON e.ExtensionID = D.ID and e.WorkPoint = d.WorkPoint
|
|
where a.WorkPoint ='{0}' and a.dntype='1'";
|
|
|
|
string sql2 = @"Select distinct a.ID,a.ODNCode as '到货单号',a.Sequence as '到货单行号',a.VenCode as '供应商代码',a.InvCode as '物料代码',a.Quantity as '数量',
|
|
a.Amount as '辅计量数量',a.Status as '状态',a.CreatePerson as '创建人',a.CreateDateTime as '创建时间',n.OOCode as '采购订单',n.Sequence as '采购订单行号',
|
|
a.OASNCode as '送货单号',a.WorkPoint as '站点',a.Mtime as '操作时间',d.cFree1 as '自由项1',d.cFree2 as '自由项2',
|
|
d.cFree3 as '自由项3',d.cFree4 as '自由项4',d.cFree2 as '自由项5',a.ODNType as '类型'
|
|
from ICSODeliveryNotice a
|
|
inner JOIN ICSASNDETAIL C ON A.OASNCode = C.ASNCode and a.WorkPoint = c.WorkPoint
|
|
INNER JOIN ICSInventoryLot e ON c.LotNo=e.LotNo AND a.InvCode=e.InvCode AND c.WorkPoint=e.WorkPoint and a.ExtensionID = e.ExtensionID
|
|
INNER JOIN ICSInventoryLotDetail m on e.LotNo=m.LotNo and e.WorkPoint=m.WorkPoint
|
|
INNER JOIN ICSOutsourcingOrder n ON m.TransCode =n.OOCode AND m.TransSequence=n.Sequence AND a.OODetailID=n.OODetailID AND m.WorkPoint=n.WorkPoint
|
|
inner JOIN ICSExtension D ON e.ExtensionID = D.ID and e.WorkPoint = d.WorkPoint
|
|
where a.WorkPoint ='{0}' and a.ODNType='1'";
|
|
sql1 = string.Format(sql1, WorkPoint);
|
|
sql2 = string.Format(sql2, WorkPoint);
|
|
|
|
if (condition.dModifyDateFrom != null)
|
|
{
|
|
sql1 += " and a.Mtime >= '{0}'";
|
|
sql1 = string.Format(sql1, condition.dModifyDateFrom);
|
|
sql2 += " and a.Mtime >= '{0}'";
|
|
sql2 = string.Format(sql2, condition.dModifyDateFrom);
|
|
}
|
|
if (condition.dModifyDateTo != null)
|
|
{
|
|
sql1 += " and a.Mtime <= '{0}'";
|
|
sql1 = string.Format(sql1, condition.dModifyDateTo);
|
|
sql2 += " and a.Mtime <= '{0}'";
|
|
sql2 = string.Format(sql2, condition.dModifyDateTo);
|
|
}
|
|
if (condition.ASNCode != null)
|
|
{
|
|
sql1 += " and a.ASNCode like '%{0}%'";
|
|
sql1 = string.Format(sql1, condition.ASNCode);
|
|
sql2 += " and a.OASNCode like '%{0}%'";
|
|
sql2 = string.Format(sql2, condition.ASNCode);
|
|
}
|
|
if (condition.PO != null)
|
|
{
|
|
sql1 += " and n.POCode like '%{0}%'";
|
|
sql1 = string.Format(sql1, condition.PO);
|
|
sql2 += " and n.OOCode like '%{0}%'";
|
|
sql2 = string.Format(sql2, condition.PO);
|
|
}
|
|
|
|
|
|
|
|
string sql = sql1 + " Union All " + sql2;
|
|
|
|
string sqlNew = @" select * from (select aa.*,rn=ROW_NUMBER() over(order by ID) from( ";
|
|
sqlNew += sql;
|
|
sqlNew += ") aa)bb where bb.rn between {0} and {1} ";
|
|
sqlNew = string.Format(sqlNew, (condition.PageIndex - 1) * condition.PageSize + 1, condition.PageIndex * condition.PageSize);
|
|
|
|
|
|
DataTable dt = ICSHelper.GetDataTable(sqlNew);
|
|
List<GetDNEntity> entityList = new List<GetDNEntity>();
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
GetDNEntity entity = new GetDNEntity();
|
|
|
|
entity.ID = dr["ID"].ToString();
|
|
entity.DNCode = dr["到货单号"].ToString();
|
|
entity.DNLine = string.IsNullOrWhiteSpace(dr["到货单行号"].ToString()) ? 1 : Convert.ToInt32(dr["到货单行号"].ToString());
|
|
entity.VenCode = dr["供应商代码"].ToString();
|
|
entity.DNType = string.IsNullOrWhiteSpace(dr["类型"].ToString()) ? 1 : Convert.ToInt32(dr["类型"].ToString());
|
|
entity.InvCode = dr["物料代码"].ToString();
|
|
entity.Quantity = string.IsNullOrWhiteSpace(dr["数量"].ToString()) ? 0.00m : Convert.ToDecimal(dr["数量"].ToString());
|
|
entity.Amount = string.IsNullOrWhiteSpace(dr["辅计量数量"].ToString()) ? 0.00m : Convert.ToDecimal(dr["辅计量数量"].ToString());
|
|
entity.Status = dr["状态"].ToString();
|
|
entity.CreatePerson = dr["创建人"].ToString();
|
|
if (string.IsNullOrWhiteSpace(dr["创建时间"].ToString()))
|
|
{
|
|
entity.CreateDate = null;
|
|
}
|
|
else
|
|
{
|
|
entity.CreateDate = Convert.ToDateTime(dr["创建时间"].ToString());
|
|
}
|
|
entity.PO = dr["采购订单"].ToString();
|
|
entity.POLine = string.IsNullOrWhiteSpace(dr["采购订单行号"].ToString()) ? 1 : Convert.ToInt32(dr["采购订单行号"].ToString());
|
|
entity.ASNCode = dr["送货单号"].ToString();
|
|
entity.ASNLine = 1;
|
|
entity.Extension1 = dr["自由项1"].ToString();
|
|
entity.Extension2 = dr["自由项2"].ToString();
|
|
entity.Extension3 = dr["自由项3"].ToString();
|
|
entity.Extension4 = dr["自由项4"].ToString();
|
|
entity.Extension5 = dr["自由项5"].ToString();
|
|
if (string.IsNullOrWhiteSpace(dr["操作时间"].ToString()))
|
|
{
|
|
entity.dModifyDate = null;
|
|
}
|
|
else
|
|
{
|
|
entity.dModifyDate = Convert.ToDateTime(dr["操作时间"].ToString());
|
|
}
|
|
entity.WorkPoint = dr["站点"].ToString();
|
|
|
|
entityList.Add(entity);
|
|
}
|
|
|
|
|
|
res.IsSuccess = true;
|
|
res.Message = "执行成功!";
|
|
res.data = entityList;
|
|
return res;
|
|
}
|
|
else
|
|
{
|
|
res.IsSuccess = true;
|
|
res.Message = "查询无数据!";
|
|
res.data = entityList;
|
|
return res;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
res.IsSuccess = false;
|
|
res.Message = ex.Message;
|
|
return res;
|
|
}
|
|
}
|
|
}
|
|
}
|