陆晔 2 years ago
parent
commit
958732a9ff
  1. 136
      WMS-BS/NFine.Application/WMS/BlitemApp.cs

136
WMS-BS/NFine.Application/WMS/BlitemApp.cs

@ -12,6 +12,8 @@ using System.Configuration;
using System.Net; using System.Net;
using System.IO; using System.IO;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using System.Data.SqlClient;
using ICS.Data;
namespace NFine.Application.WMS namespace NFine.Application.WMS
{ {
@ -187,20 +189,140 @@ SELECT Grid as GeValue,Grid +'格' as GeName FROM ICSLocation WITH (NOLOCK) WHE
return dt; return dt;
} }
//public string AddICSCheck(string Parameter)
//{
// string msg = "";
// string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "Check/Create";
// string result = HttpPost(APIURL, Parameter);
// JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
// string MessAge = Obj["Message"].ToString();
// string Success = Obj["Success"].ToString();
// if (Success.ToUpper() == "FALSE")
// {
// msg = MessAge;
// }
// return msg;
//}
/// <summary>
/// 新增盘点单接口
/// </summary>
/// <param name="Parameter"></param>
/// <returns></returns>
public string AddICSCheck(string Parameter) public string AddICSCheck(string Parameter)
{ {
string msg = ""; string msg = "";
string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "Check/Create";
string result = HttpPost(APIURL, Parameter);
JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
string MessAge = Obj["Message"].ToString();
string Success = Obj["Success"].ToString();
if (Success.ToUpper() == "FALSE")
try
{
List<ICSCheck> model = JsonConvert.DeserializeObject<List<ICSCheck>>(Parameter.ToString());
if (model == null || model.Count<=0)
{
msg = "操作失败";
return msg;
}
string sql = string.Empty;
foreach (var item in model)
{
if (string.IsNullOrEmpty(item.User))
{
throw new Exception("操作人不能为空!");//"操作人不能为空!");
}
if (string.IsNullOrEmpty(item.WorkPoint))
{
throw new Exception("站点不能为空");//"站点不能为空!"
}
//创建盘点单
foreach (var itemInfo in item.Detail)
{
string Code = string.Empty;
//获取单号
sql = @"IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{0}' AND F_Location='{1}')
BEGIN
RAISERROR('',16,1);
RETURN
END
DECLARE @MaxNO INT,@date varchar(20)='CHK'+SUBSTRING(CONVERT(varchar(8), GETDATE(), 112), 1, 8)
SELECT @MaxNO=SUBSTRING(MAX(CheckCode),LEN(@date)+1,LEN(MAX(CheckCode))-LEN(@date))+1 FROM ICSCheck
WHERE SUBSTRING(CheckCode, 1, LEN(@date))=@date
IF @MaxNO IS NULL
BEGIN
SELECT @date+'00001' AS Code
END
ELSE
BEGIN
SELECT @date+REPLICATE('0',5-LEN(@MaxNO))+CAST(@MaxNO AS nvarchar(10)) AS Code
END ";
sql = string.Format(sql, item.User, item.WorkPoint);
Code = SqlHelper.ExecuteScalar(sql).ToString();
if (string.IsNullOrWhiteSpace(Code))
{
throw new Exception("盘点单号不能为空");//"盘点单单号不能为空!");
}
int len = itemInfo.SelectLevel.Length;
sql = @"IF NOT EXISTS(SELECT id FROM ICSWareHouseLotInfo WHERE SUBSTRING(LocationCode,1,{4}) = '{1}')
BEGIN
RAISERROR('!',16,1);
RETURN
END
INSERT INTO ICSCheck (ID,CheckCode,SelectLevel,Status,Quantity,Amount,MUSER,MUSERName,MTIME,WorkPoint)
SELECT NEWID(),'{0}','{1}','2',SUM(a.Quantity),0,b.F_Account,b.F_RealName,GETDATE(),b.F_Location
FROM ICSWareHouseLotInfo a
INNER JOIN Sys_SRM_User b ON b.F_Account='{2}' AND b.F_Location='{3}'
WHERE SUBSTRING(a.LocationCode,1,{4}) = '{1}'
GROUP BY b.F_Account,b.F_RealName,b.F_Location";
sql = string.Format(sql, Code, itemInfo.SelectLevel, item.User, item.WorkPoint, len);
if (SqlHelper.ExecuteNonQuery(sql)<=0)
{ {
msg = MessAge;
throw new Exception("盘点单创建失败");//"盘点单创建失败!");
}
}
}
}
catch (Exception ex)
{
msg = ex.Message;
} }
return msg; return msg;
} }
/// <summary>
///
/// </summary>
public class ICSCheck
{
/// <summary>
/// 用户
/// </summary>
public string User { get; set; }
/// <summary>
/// 操作时间
/// </summary>
public string MTIME { get; set; }
/// <summary>
///
/// 站点
/// </summary>
public string WorkPoint { get; set; }
/// <summary>
/// 详情
/// </summary>
public List<Detail> Detail { get; set; }
}
/// <summary>
///
/// </summary>
public class Detail
{
/// <summary>
/// 仓库编码
/// </summary>
public string SelectLevel { get; set; }
}
//接口api解析 //接口api解析

Loading…
Cancel
Save