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.
121 lines
5.4 KiB
121 lines
5.4 KiB
using CK.SCP.Controller;
|
|
using CK.SCP.Models;
|
|
using CK.SCP.Models.Enums;
|
|
using CK.SCP.Models.ScpEntity;
|
|
using CK.SCP.Models.ScpEntity.ExcelExportEnttity;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.Entity.Migrations;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Runtime.Serialization.Json;
|
|
using System.Text;
|
|
using System.Web;
|
|
using System.Web.Services;
|
|
|
|
namespace SCP.Views.BasicData
|
|
{
|
|
/// <summary>
|
|
/// WebService1 的摘要说明
|
|
/// </summary>
|
|
[WebService(Namespace = "http://tempuri.org/")]
|
|
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
|
|
[System.ComponentModel.ToolboxItem(false)]
|
|
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。
|
|
[System.Web.Script.Services.ScriptService]
|
|
public class WebService1 : System.Web.Services.WebService
|
|
{
|
|
[WebMethod]
|
|
public string getObjectByJson(string jsonString)
|
|
{
|
|
// 实例化DataContractJsonSerializer对象,需要待序列化的对象类型
|
|
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(V_TB_ASK_DETAIL));
|
|
//把Json传入内存流中保存
|
|
jsonString = "[" + jsonString + "]";
|
|
MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(jsonString));
|
|
// 使用ReadObject方法反序列化成对象
|
|
object ob = serializer.ReadObject(stream);
|
|
V_TB_ASK_DETAIL ls = (V_TB_ASK_DETAIL)ob;
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
|
|
{
|
|
List<string> ErrorList = new List<string>();
|
|
String str = ls.PoBillNum.ToString();
|
|
String str1 = ls.VendId.ToString();
|
|
String str2 = ls.PartCode.ToString();
|
|
var lsA = db.TB_PO.Count(p => p.PoBillNum == ls.PoBillNum && p.VendId == ls.VendId);
|
|
if (lsA == 0)
|
|
{
|
|
ErrorList.Add(string.Format("订单号【{0}】不存在", str));
|
|
}
|
|
var ls1 = db.TA_PART.Count(P => P.PartCode == ls.PartCode);
|
|
if (ls1 == 0)
|
|
{
|
|
ErrorList.Add(string.Format("零件号【{0}】不存在", str2));
|
|
}
|
|
var ved = db.TB_PO_DETAIL.Count(p => p.PoBillNum == ls.PoBillNum && p.PartCode == ls.PartCode);
|
|
if (ved == 0)
|
|
{
|
|
ErrorList.Add(string.Format("订单号【{0}】中不存在零件号【{1}】", str1, str2));
|
|
}
|
|
else
|
|
{
|
|
var lv = db.TB_PO_DETAIL.SingleOrDefault(p => p.PoBillNum == ls.PoBillNum && p.PartCode == ls.PartCode);
|
|
if (lv.PlanQty < ls.AskQty)
|
|
{
|
|
ErrorList.Add(string.Format("订单号【{0}】中零件号【{1}】的要货数量超过SCP中的最大要货数量", str1, str2));
|
|
}
|
|
}
|
|
var lt = db.TB_ASK.Count(p => p.PoBillNum == ls.PoBillNum && p.VendId == ls.VendId && p.EndTime == ls.EndTime);
|
|
if (ErrorList.Count() == 0)
|
|
{
|
|
TB_ASK ASK = new TB_ASK();
|
|
if (lt == 0)
|
|
{
|
|
ASK.AskBillNum = SCP_BILLCODE_CONTROLLER.MakeASKCode();
|
|
ASK.PoBillNum = ls.PoBillNum;
|
|
ASK.VendId = ls.VendId;
|
|
ASK.Site = "BJBMPT";
|
|
ASK.CreateTime = ls.CreateTime;
|
|
ASK.CreateUser = ls.CreateUser;
|
|
ASK.UpdateTime = DateTime.Now;
|
|
ASK.UpdateUser = ls.CreateUser;
|
|
ASK.IsDeleted = false;
|
|
ASK.GUID = Guid.NewGuid();
|
|
ASK.State = (int)AskState.Release;
|
|
ASK.ModType = 1;
|
|
ASK.BeginTime = ls.CreateTime;
|
|
ASK.EndTime = ls.EndTime;
|
|
ASK.ErpBillNum = ls.PoBillNum;
|
|
ASK.Buyer = ls.CreateUser;
|
|
ASK.SubSite = ls.SubSite;
|
|
db.TB_ASK.AddOrUpdate(ASK);
|
|
db.SaveChanges();
|
|
}
|
|
TB_ASK_DETAIL ASKK = new TB_ASK_DETAIL();
|
|
ASKK.AskBillNum = ASK.AskBillNum;
|
|
ASKK.PoBillNum = ls.PoBillNum;
|
|
ASKK.PoLine = ls.PoLine;
|
|
ASKK.PartCode = ls.PartCode;
|
|
ASKK.Currency = "CNY";
|
|
ASKK.Price = ls.Price;
|
|
ASKK.AskQty = ls.AskQty;
|
|
ASKK.BeginTime = DateTime.Now;
|
|
ASKK.EndTime = ls.EndTime;
|
|
ASKK.PoUnit = ls.PoUnit;
|
|
ASKK.LocUnit = ls.PoUnit;
|
|
ASKK.State = (int)AskState.Release;
|
|
ASKK.CreateTime = ls.CreateTime;
|
|
ASKK.CreateUser = ls.CreateUser;
|
|
ASKK.IsDeleted = false;
|
|
ASKK.GUID = Guid.NewGuid();
|
|
ASKK.SubSite = ls.SubSite;
|
|
ASKK.Site = "BJBMPT";
|
|
ASKK.Extend1 = ls.Extend1;
|
|
db.TB_ASK_DETAIL.AddOrUpdate(ASKK);
|
|
db.SaveChanges();
|
|
}
|
|
return ErrorList.ToString();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|