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.
|
|
using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using ICS.WCF.Base; using ICSSoft.Entity;
namespace ICS.IFeaturesValue { public class FeaturesValue { public FormICSCreatedArrivalNoticeModel FindByApproveDate(ValueModel d) { StringBuilder strHead = new StringBuilder(); strHead.AppendLine("***************接口传入参数记录****************:"); strHead.AppendLine("开始时间:" + d.StartTime); strHead.AppendLine("结束时间:" + d.EndTime); strHead.AppendLine("***************接口传入参数记录****************:"); Appconfig.WriteLogFile(strHead.ToString(), "U9采购/委外信息接口日志"); StringBuilder resultlog = new StringBuilder(); FormICSCreatedArrivalNoticeModel result = new FormICSCreatedArrivalNoticeModel(); List<FeaturesValueModel> returnValue = new List<FeaturesValueModel>(); try { //判断是否有时间戳传入
DateTime time1 = Appconfig.TimestampToDateTime(d.StartTime); DateTime time2 = Appconfig.TimestampToDateTime(d.EndTime); string ERPDB = Appconfig.GetBPERPStr(); DataTable _dt_ = new DataTable(); string sql_new = @" select DISTINCT d.Code,a.ID,a.DocNo,a.SubType,a.ModifiedOn,c.Description from PM_PurchaseOrder a
LEFT JOIN PM_POMemo b on a.ID=b.PurchaseOrder LEFT JOIN PM_POMemo_Trl c on b.ID=c.ID LEFT JOIN Base_Organization d on a.Org=d.ID WHERE 1 = 1 and d.Code='02' ";
//写入传入内容数据
if (!string.IsNullOrEmpty(d.StartTime.ToString()) && d.StartTime != 0) sql_new += " and a.ModifiedOn >= '" + time1 + "'"; if (!string.IsNullOrEmpty(d.StartTime.ToString()) && d.EndTime != 0) sql_new += " and a.[ModifiedOn] <= '" + time2 + "'"; sql_new = string.Format(sql_new,ERPDB); _dt_ = DBhlper.Query(sql_new, Appconfig.GetU9ConnStr()); if (_dt_ == null || _dt_.Rows.Count <= 0) { throw new Exception("该采购/委外信息不存在"); } //循环获取数据入返回集合内
foreach (DataRow dr in _dt_.Rows) { FeaturesValueModel model = new FeaturesValueModel(); model.OrgID = dr["Code"].ToString(); model.POID = dr["ID"].ToString(); model.PONo = dr["DocNo"].ToString(); model.POType = Convert.ToInt32(dr["SubType"].ToString()); model.CreateDate = Convert.ToDateTime(dr["ModifiedOn"].ToString()); model.Remarks = dr["Description"].ToString();
string sql_new1 = @"select DISTINCT a.ID,a.DocLineNo,a.ItemInfo_ItemCode,a.PurQtySU as RequireQty,a.PurQtySU as AcceptQty,g.DeliveryDate,
(case a.Status WHEN '2' THEN '1' ELSE '0' end) as Status,f.Code, e.Description from PM_POLine a LEFT JOIN PM_PurchaseOrder b on a.PurchaseOrder=b.ID LEFT JOIN CBO_ItemMaster c on a.ItemInfo_ItemCode=c.Code LEFT JOIN PM_POMemo d on a.ID=d.PurchaseOrder LEFT JOIN PM_POMemo_Trl e on d.ID=e.ID LEFT JOIN Base_UOM f on c.InventoryUOM=f.ID LEFT JOIN PM_POShipLine g on a.DocLineNo=g.POLine
where a.PurchaseOrder='" + dr["ID"].ToString() + @"' ";
sql_new1 = string.Format(sql_new1); DataTable _dt_1 = DBhlper.Query(sql_new1, Appconfig.GetU9ConnStr()); List<POs> lstpo = new List<POs>(); foreach (DataRow dr1 in _dt_1.Rows) { POs pomodel = new POs(); pomodel.RowNo = dr1["DocLineNo"].ToString(); pomodel.POSID = dr1["ID"].ToString(); pomodel.ItemNo = dr1["ItemInfo_ItemCode"].ToString(); pomodel.Postdate = dr1["DeliveryDate"].ToString(); pomodel.RequireQty = Convert.ToDecimal(dr1["RequireQty"].ToString()); pomodel.AcceptQty = Convert.ToDecimal(dr1["AcceptQty"].ToString()); pomodel.UomNo = dr1["Code"].ToString(); pomodel.IsClose = Convert.ToInt32(dr1["Status"].ToString()); pomodel.Remarks = dr1["Description"].ToString(); lstpo.Add(pomodel); }
model.POS = lstpo;
returnValue.Add(model); } 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 = ex.Message; result.ResData = null; result.IsCompress = false; result.IsSuccess = false; StringBuilder str = new StringBuilder(); str.AppendLine("U9采购/委外信息获取失败"); str.AppendLine("开始时间:" + d.StartTime); str.AppendLine("结束时间:" + d.EndTime); 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<FeaturesValueModel> ResData { get; set; } public bool IsCompress { get; set; } public bool IsSuccess { get; set; } } } }
|