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.
212 lines
11 KiB
212 lines
11 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
using Quartz;
|
|
|
|
|
|
namespace ICSSoft.FromERP
|
|
{
|
|
/// <summary>
|
|
/// 委外到货(退货单)
|
|
/// </summary>
|
|
public class ICSDeliveryNotice : IJob
|
|
{
|
|
private static object key = new object();
|
|
private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
public void Execute(IJobExecutionContext context)
|
|
{
|
|
try
|
|
{
|
|
lock (key)
|
|
{
|
|
log.Info("开始……………………………………………………………………");
|
|
Execute();
|
|
log.Info("结束……………………………………………………………………");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Error(ex.ToString());
|
|
}
|
|
}
|
|
|
|
public void Execute()
|
|
{
|
|
try
|
|
{
|
|
string conStr = ICSHelper.GetConnectString();
|
|
string Namespace = this.GetType().Namespace;
|
|
string WHCode = ICSHelper.GetConfigString()["WHCode"];
|
|
string Date = ICSHelper.GetConfigString()["Date"];
|
|
string DocNO = ICSHelper.GetConfigString()["DocNo"];
|
|
string str = "";
|
|
|
|
DataTable dt = ICSHelper.GetERPDB(conStr);
|
|
using (FramDataContext db = new FramDataContext(conStr))
|
|
{
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
#region 检验合格单同步
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
SAPGetChkDocInfoZS.ZWMS_SK_WS_CHECK client = new SAPGetChkDocInfoZS.ZWMS_SK_WS_CHECK();
|
|
SAPGetChkDocInfoZS.ZWMS_SK_WS_CHECK1 Info = new SAPGetChkDocInfoZS.ZWMS_SK_WS_CHECK1();
|
|
if (DocNO != "")
|
|
{
|
|
Info.PRUEFLOS = DocNO;
|
|
Info.CHG_DATE = "";
|
|
}
|
|
if (Date != "")
|
|
{
|
|
Info.PRUEFLOS = "";
|
|
Info.CHG_DATE = Date;
|
|
}
|
|
if (DocNO == "" && Date == "")
|
|
{
|
|
Info.PRUEFLOS = "";
|
|
Info.CHG_DATE = DateTime.Now.Year + "-" + DateTime.Now.Month.ToString().PadLeft(2, '0') + "-" + DateTime.Now.Day.ToString().PadLeft(2, '0');
|
|
}
|
|
Info.WERKS = dr["WorkPointCode"].ToString();
|
|
Info.ZCHECK_HEAD = new SAPGetChkDocInfoZS.ZWMS_SK_CHECK_HEAD[1];
|
|
Info.ZCHECK_ITEM = new SAPGetChkDocInfoZS.ZWMS_SK_CHECK_ITEM[1];
|
|
|
|
|
|
SAPGetChkDocInfoZS.ZWMS_SK_WS_CHECKResponse result = new SAPGetChkDocInfoZS.ZWMS_SK_WS_CHECKResponse();
|
|
client.Timeout = 300000;
|
|
result = client.CallZWMS_SK_WS_CHECK(Info);
|
|
List<SAPGetChkDocInfoZS.ZWMS_SK_CHECK_ITEM> ItemInfoList = new List<SAPGetChkDocInfoZS.ZWMS_SK_CHECK_ITEM>();
|
|
ItemInfoList.AddRange(result.ZCHECK_ITEM);
|
|
foreach (SAPGetChkDocInfoZS.ZWMS_SK_CHECK_HEAD HeadInfo in result.ZCHECK_HEAD)
|
|
{
|
|
string LineNum = "10";
|
|
var ItemInfo = ItemInfoList.Where(a => a.PRUEFLOS == HeadInfo.PRUEFLOS);
|
|
foreach (SAPGetChkDocInfoZS.ZWMS_SK_CHECK_ITEM Item in ItemInfo)
|
|
{
|
|
str = Item.PRUEFLOS;
|
|
string ExtensionID = "";
|
|
bool isNew = false;
|
|
string Colspan = "";
|
|
if (Item.SOBKZ == "E")
|
|
{
|
|
Colspan = Item.KDAUF + "~~~" + Item.KDPOS + "~~~~~~~~~~";
|
|
}
|
|
else
|
|
{
|
|
Colspan = "~~~~~~~~~~~~~";
|
|
}
|
|
var Extensionline = db.ICSExtension.SingleOrDefault(a => a.Colspan == Colspan && a.WorkPoint == HeadInfo.WERKS);
|
|
if (Extensionline == null)
|
|
{
|
|
ExtensionID = AppConfig.GetGuid();
|
|
Extensionline = new ICSExtension();
|
|
Extensionline.ID = ExtensionID;
|
|
Extensionline.BatchCode = "";
|
|
Extensionline.Version = "";
|
|
if (Item.SOBKZ == "E")
|
|
{
|
|
Extensionline.Brand = Item.KDPOS;//销售凭证项目
|
|
Extensionline.ProjectCode = Item.KDAUF;//销售凭证
|
|
}
|
|
else
|
|
{
|
|
Extensionline.Brand = "";//销售凭证项目
|
|
Extensionline.ProjectCode = "";//销售凭证
|
|
}
|
|
Extensionline.cFree1 = "";
|
|
Extensionline.cFree2 = "";
|
|
Extensionline.cFree3 = "";
|
|
Extensionline.cFree4 = "";
|
|
Extensionline.cFree5 = "";
|
|
Extensionline.cFree6 = "";
|
|
Extensionline.cFree7 = "";
|
|
Extensionline.cFree8 = "";
|
|
Extensionline.cFree9 = "";
|
|
Extensionline.cFree10 = "";
|
|
Extensionline.Colspan = Colspan;
|
|
Extensionline.MTIME = DateTime.Now;
|
|
Extensionline.MUSER = "JOB";
|
|
Extensionline.MUSERName = "JOB";
|
|
Extensionline.WorkPoint = HeadInfo.WERKS;
|
|
|
|
db.ICSExtension.InsertOnSubmit(Extensionline);
|
|
db.SubmitChanges();
|
|
}
|
|
else
|
|
{
|
|
ExtensionID = Extensionline.ID;
|
|
}
|
|
var rcvline = db.ICSDeliveryNotice.SingleOrDefault(a => a.DNCode == Item.PRUEFLOS && a.InvCode == Item.MATNR.TrimStart('0') && a.WorkPoint == HeadInfo.WERKS);
|
|
if (rcvline == null)
|
|
{
|
|
isNew = true;
|
|
rcvline = new Frame.Data.Entity.ICSDeliveryNotice();
|
|
rcvline.ID = AppConfig.GetGuid();
|
|
rcvline.RCVQuantity = 0;
|
|
rcvline.DNCode = Item.PRUEFLOS;//检验批编号
|
|
rcvline.Sequence = LineNum;//行号
|
|
rcvline.InvCode = Item.MATNR.TrimStart('0');//物料编码
|
|
LineNum = (Convert.ToInt32(LineNum) + 10).ToString();
|
|
}
|
|
|
|
rcvline.VenCode = HeadInfo.LIFNR;//供应商
|
|
rcvline.DepCode = HeadInfo.NAME1;//供应商名称
|
|
rcvline.DNType = "1";
|
|
rcvline.WorkPoint = HeadInfo.WERKS;//站点//工厂
|
|
rcvline.CreatePerson = "JOB";
|
|
rcvline.CreateDateTime = Convert.ToDateTime(HeadInfo.VDATUM);//检验时间
|
|
rcvline.POID = HeadInfo.AUFNR;//订单号
|
|
rcvline.DNID = HeadInfo.EBELN;//采购凭证号
|
|
rcvline.DNDetailID = HeadInfo.EBELP;//采购凭证的项目
|
|
rcvline.Quantity = Item.HGMENGE;//可入库数量
|
|
rcvline.Amount = 0;
|
|
rcvline.WHCode = Item.LGORT;//仓库 //库存地点
|
|
rcvline.Status = "2";
|
|
rcvline.EATTRIBUTE1 = Item.MEMO;
|
|
rcvline.MUSER = "JOB";
|
|
rcvline.MUSERName = "JOB";
|
|
rcvline.MTIME = DateTime.Now;
|
|
rcvline.ExtensionID = ExtensionID;
|
|
//新增字段
|
|
rcvline.InspectionType =HeadInfo.ART;//检验类型
|
|
rcvline.InvoDescribe = Item.MAKTX;//物料描述
|
|
rcvline.Unity = Item.MEINS;//单位
|
|
rcvline.StockIndicator =Item.SOBKZ;//特殊库存标识
|
|
rcvline.DepositArea = Item.LTKZA;//存放区域
|
|
rcvline.ModificationDate = HeadInfo.TEST1;//检验修改日期
|
|
rcvline.TrackingNumber = HeadInfo.TEST2;//需求跟踪号
|
|
rcvline.NonconformingForm = HeadInfo.TEST3;//不合格单
|
|
|
|
|
|
if (isNew == true)
|
|
{
|
|
db.ICSDeliveryNotice.InsertOnSubmit(rcvline);
|
|
}
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string xxx = str;
|
|
db.Transaction.Rollback();
|
|
log.Error(ex.ToString());
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Error(ex.ToString());
|
|
}
|
|
}
|
|
}
|
|
}
|