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.
151 lines
6.7 KiB
151 lines
6.7 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using ICS.WCF.Base;
|
|
using ICSSoft.Entity;
|
|
|
|
namespace ICS.SupItem
|
|
{
|
|
public class GetSupItem
|
|
{
|
|
public FormICSCreatedArrivalNoticeModel FindByApproveDate(IItem d)
|
|
{
|
|
StringBuilder strHead = new StringBuilder();
|
|
strHead.AppendLine("***************接口传入参数记录****************:");
|
|
strHead.AppendLine("传入编码:" + d.ItemCode);
|
|
strHead.AppendLine("传入供应商:" + d.SupCode);
|
|
strHead.AppendLine("开始时间:" + d.StartTime);
|
|
strHead.AppendLine("***************接口传入参数记录****************:");
|
|
Appconfig.WriteLogFile(strHead.ToString(), "U9料品与供应商信息接口日志");
|
|
StringBuilder resultlog = new StringBuilder();
|
|
|
|
FormICSCreatedArrivalNoticeModel result = new FormICSCreatedArrivalNoticeModel();
|
|
List<PRApprovedEntity> returnValue = new List<PRApprovedEntity>();
|
|
try
|
|
{
|
|
DateTime time1 = Appconfig.TimestampToDateTime(d.StartTime);
|
|
DateTime time2 = DateTime.Parse(Appconfig.getDBTime());
|
|
string sql = @"select
|
|
A1.[Code] as ItemCode,
|
|
A1.Name as ItemName,
|
|
A.[SupplierInfo_Code] as [SupCode],
|
|
A5.Name as [SupName],
|
|
A3.[PurProcessLT] as NormalPeriod,
|
|
A.[Effective_IsEffective]
|
|
from CBO_SupplierItem as A
|
|
left join [CBO_ItemMaster] as A1 on (A.[ItemInfo_ItemID] = A1.[ID])
|
|
left join [CBO_SupplierItem_Trl] as A2
|
|
on (A2.SysMlFlag = 'zh-CN') and (A.[ID] = A2.[ID])
|
|
left join [CBO_MrpInfo] as A3 on (A1.[MrpInfo] = A3.[ID])
|
|
left join CBO_Supplier A4 on A4.Code=A.[SupplierInfo_Code]
|
|
left join CBO_Supplier_Trl A5 on A4.ID=A5.ID
|
|
where 1=1 and left(A1.[Code],2)!='20'";
|
|
|
|
if (!string.IsNullOrEmpty(d.ItemCode))
|
|
{
|
|
sql += " and A1.Code = '" + d.ItemCode + "'";
|
|
}
|
|
if (!string.IsNullOrEmpty(d.SupCode))
|
|
{
|
|
sql += " and A.SupplierInfo_Code = '" + d.SupCode + "'";
|
|
}
|
|
if (!string.IsNullOrEmpty(d.StartTime.ToString()) && d.StartTime != 0)
|
|
{
|
|
sql += " and A.ModifiedOn >= '" + time1 + "'";
|
|
}
|
|
if (!string.IsNullOrEmpty(time2.ToString()))
|
|
{
|
|
sql += " and A.ModifiedOn <= '" + time2 + "'";
|
|
}
|
|
sql += " order by A1.[Code]";
|
|
|
|
DataTable dt = DBhlper.Query(sql, Appconfig.GetU9ConnStr());
|
|
if (dt == null)
|
|
{
|
|
result.Code = -1;
|
|
result.ResMsg = "获取U9料品与供应商信息失败";
|
|
result.ResData = null;
|
|
result.IsCompress = false;
|
|
result.IsSuccess = false;
|
|
resultlog.AppendLine("获取U9料品与供应商信息失败");
|
|
resultlog.AppendLine("查询sql:" + sql);
|
|
Appconfig.WriteLogFile(resultlog.ToString(), "U9料品与供应商信息接口日志");
|
|
return result;
|
|
}
|
|
|
|
int count = dt.Rows.Count; ;
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
PRApprovedEntity PRLine = new PRApprovedEntity();
|
|
|
|
if (!string.IsNullOrWhiteSpace(dr["ItemCode"].ToString()))
|
|
{
|
|
PRLine.ItemCode = dr["ItemCode"].ToString();
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(dr["ItemName"].ToString()))
|
|
{
|
|
PRLine.ItemName = dr["ItemName"].ToString();
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(dr["SupCode"].ToString()))
|
|
{
|
|
PRLine.SupCode = dr["SupCode"].ToString();
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(dr["SupName"].ToString()))
|
|
{
|
|
PRLine.SupName = dr["SupName"].ToString();
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(dr["NormalPeriod"].ToString()))
|
|
{
|
|
PRLine.NormalPeriod = dr["NormalPeriod"].ToString();
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(dr["Effective_IsEffective"].ToString()))
|
|
{
|
|
PRLine.IsEff = Convert.ToBoolean(dr["Effective_IsEffective"].ToString().Trim());
|
|
}
|
|
returnValue.Add(PRLine);
|
|
}
|
|
int time = (DateTime.Now - time2).Seconds;
|
|
|
|
result.Code = 0;
|
|
result.ResMsg = "获取U9料品与供应商信息成功";
|
|
result.ResData = returnValue;
|
|
result.IsCompress = false;
|
|
result.IsSuccess = true;
|
|
return result;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.Code = -1;
|
|
result.ResMsg = "U9料品与供应商信息获取失败,请查看日志";
|
|
result.ResData = null;
|
|
result.IsCompress = false;
|
|
result.IsSuccess = false;
|
|
StringBuilder str = new StringBuilder();
|
|
str.AppendLine("U9料品与供应商信息获取失败");
|
|
strHead.AppendLine("传入编码:" + d.ItemCode);
|
|
strHead.AppendLine("传入供应商:" + d.SupCode);
|
|
strHead.AppendLine("开始时间:" + d.StartTime);
|
|
str.AppendLine("失败原因:" + ex.Message);
|
|
Appconfig.WriteLogFile(str.ToString(), "U9料品与供应商信息接口日志");
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 返回值
|
|
/// </summary>
|
|
public class FormICSCreatedArrivalNoticeModel
|
|
{
|
|
//0 :正常数据,-1:失败。
|
|
public int Code { get; set; }
|
|
public string ResMsg { get; set; }
|
|
public List<PRApprovedEntity> ResData { get; set; }
|
|
public bool IsCompress { get; set; }
|
|
public bool IsSuccess { get; set; }
|
|
}
|
|
}
|
|
}
|