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.
245 lines
10 KiB
245 lines
10 KiB
using NFine.Data.Extensions;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Text;
|
|
using NFine.Code;
|
|
using NFine.Repository;
|
|
using System.Data.Common;
|
|
using NFine.Domain._03_Entity.SRM;
|
|
using Newtonsoft.Json;
|
|
using System.Configuration;
|
|
using System.Net;
|
|
using System.IO;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace NFine.Application.WMS
|
|
{
|
|
public class BlitemApp : RepositoryFactory<ICSVendor>
|
|
{
|
|
public DataTable GetGridJson(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
|
|
#region [SQL]
|
|
string sql = @"SELECT isnull(c.SumQty,0) as SumQty ,a.Quantity,a.ID, a.CheckCode, a.SelectLevel,a.InvCode,b.InvName,a.Batchcode,a.Status, a.Amount, a.MUSER, a.MUSERName, a.MTIME, a.WorkPoint
|
|
from dbo.ICSCheck a
|
|
left join dbo.ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
left join (select a.CheckCode,a.BatchCode,b.InvCode,sum(a.Quantity) as SumQty from dbo.ICSCheckDetail a left join dbo.ICSInventoryLot b on a.LotNo=b.LotNo group by a.CheckCode,a.BatchCode,b.InvCode) c on a.CheckCode=c.CheckCode and a.InvCode=c.InvCode and c.BatchCode = a.BatchCode";
|
|
sql += " WHERE 1=1";
|
|
sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
|
|
#endregion
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
sql += " and a.CheckCode like '%" + queryParam["POCode"].ToString() + "%' ";
|
|
}
|
|
}
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
{
|
|
sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
|
|
}
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
|
|
{
|
|
sql += " and VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
|
|
}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
public DataTable GetSubGridJson(string CheckCode, string InvCode,string BatchCode ,ref Pagination jqgridparam)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
string sql = @" SELECT distinct a.ID, b.InvCode,
|
|
b.InvName ,
|
|
b.InvStd ,
|
|
a.LotNo,
|
|
a.Quantity,
|
|
|
|
d.WarehouseCode,
|
|
d.LocationCode,
|
|
a.PrimaryQuantity,
|
|
a.PrimaryAmount,
|
|
a.ReplayQuantity,
|
|
a.ReplayAmount,
|
|
a.CheckQuantity,
|
|
a.CheckAmount
|
|
|
|
FROM ICSCheckDetail a
|
|
left join ICSInventoryLot c on a.LotNo=c.LotNO and a.WorkPoint=c.WorkPoint
|
|
left join ICSInventory b on c.InvCode=b.InvCode AND c.WorkPoint=b.WorkPoint
|
|
left join ICSWareHouseLotInfo d on c.LotNO=d.LotNO AND c.WorkPoint=d.WorkPoint
|
|
WHERE a.CheckCode='" + CheckCode + "'and b.InvCode='"+ InvCode + "' and isnull(a.BatchCode,'')='" + BatchCode + "' and a.WorkPoint in ('" + WorkPoint + "')";
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
public string DeleteICSCheckDetail(string ID)
|
|
{
|
|
//站点信息
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
try
|
|
{
|
|
sql = string.Format(@"DELETE FROM ICSCheckDetail WHERE ID ='{0}' and WorkPoint ='{1}'", ID, WorkPoint);
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取仓库
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetWHCode()
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string sql = @" select '' as ID,'' as WarehouseName union all
|
|
SELECT ID+'|'+WarehouseCode,WarehouseName FROM ICSWarehouse WITH (NOLOCK) WHERE WorkPoint = '{0}' ";
|
|
sql = string.Format(sql, WorkPoint);
|
|
//string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
|
|
//if (role != "admin")
|
|
//{
|
|
// sql += " and b.WorkPoint='" + WorkPoint + "'";
|
|
//}
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
public DataTable GetQU(string WHCodeID)
|
|
{
|
|
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string sql = @" select '' as QUValue,'' as QUName union all
|
|
SELECT Region as QUValue,Region+'区' as QUName FROM ICSLocation WITH (NOLOCK) WHERE WHID = '{0}' AND WorkPoint='{1}'
|
|
";
|
|
sql = string.Format(sql, WHCodeID, WorkPoint);
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
public DataTable GetPai(string WHCodeID, string Qu)
|
|
{
|
|
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string sql = @" select '' as PaiValue,'' as PaiName union all
|
|
SELECT Row as PaiValue,Row+'排' as PaiName FROM ICSLocation WITH (NOLOCK) WHERE WHID = '{0}' AND WorkPoint='{1}' and Region='{2}'
|
|
";
|
|
sql = string.Format(sql, WHCodeID, WorkPoint, Qu);
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
public DataTable GetHuoJia(string WHCodeID, string Qu,string Pai)
|
|
{
|
|
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string sql = @" select '' as HuoJiaValue,'' as HuoJiaName union all
|
|
SELECT GoodsShelf as HuoJiaValue,GoodsShelf +'货架' as HuoJiaName FROM ICSLocation WITH (NOLOCK) WHERE WHID = '{0}' AND WorkPoint='{1}' and Region='{2}' and Row='{3}'
|
|
|
|
";
|
|
sql = string.Format(sql, WHCodeID, WorkPoint, Qu,Pai);
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
public DataTable GetCeng(string WHCodeID, string Qu, string Pai,string HuoJia)
|
|
{
|
|
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string sql = @" select '' as CengValue,'' as CengName union all
|
|
SELECT Tier as CengValue,Tier +'层' as CengName FROM ICSLocation WITH (NOLOCK) WHERE WHID = '{0}' AND WorkPoint='{1}' and Region='{2}' and Row='{3}' and GoodsShelf ='{4}'
|
|
|
|
";
|
|
sql = string.Format(sql, WHCodeID, WorkPoint, Qu, Pai,HuoJia);
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
public DataTable GetGe(string WHCodeID, string Qu, string Pai, string HuoJia,string Ceng)
|
|
{
|
|
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string sql = @" select '' as GeValue,'' as GeName union all
|
|
SELECT Grid as GeValue,Grid +'格' as GeName FROM ICSLocation WITH (NOLOCK) WHERE WHID = '{0}' AND WorkPoint='{1}' and Region='{2}' and Row='{3}' and GoodsShelf ='{4}' and Tier='{5}'
|
|
|
|
";
|
|
sql = string.Format(sql, WHCodeID, WorkPoint, Qu, Pai, HuoJia,Ceng);
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
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;
|
|
}
|
|
|
|
|
|
//接口api解析
|
|
public static string HttpPost(string url, string body)
|
|
{
|
|
try
|
|
{
|
|
Encoding encoding = Encoding.UTF8;
|
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
|
request.Method = "POST";
|
|
request.Accept = "application/json, text/javascript, */*"; //"text/html, application/xhtml+xml, */*";
|
|
request.ContentType = "application/json; charset=utf-8";
|
|
|
|
byte[] buffer = encoding.GetBytes(body);
|
|
request.ContentLength = buffer.Length;
|
|
request.GetRequestStream().Write(buffer, 0, buffer.Length);
|
|
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
|
using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding))
|
|
{
|
|
return reader.ReadToEnd();
|
|
}
|
|
}
|
|
catch (WebException ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
|
|
public string DeleteICSCheck(string keyValue)
|
|
{
|
|
//站点信息
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string sql = string.Empty;
|
|
try
|
|
{
|
|
sql += string.Format(@"DELETE FROM dbo.ICSCheck WHERE CheckCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
sql += string.Format(@"DELETE FROM dbo.ICSCheckDetail WHERE CheckCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
|
|
}
|
|
}
|