@ -21,7 +21,7 @@ using NFine.Domain._03_Entity.WMS;
namespace NFine.Application.WMS
{
public class ICSMTDOCApp : RepositoryFactory < ICSVendor >
public class ICSMTDOCApp : RepositoryFactory < ICSVendor >
{
public DataTable GetGridJson ( string queryJson , ref Pagination jqgridparam )
{
@ -30,7 +30,9 @@ namespace NFine.Application.WMS
List < DbParameter > parameter = new List < DbParameter > ( ) ;
#region [SQL]
string sql = @" SELECT * FROM (select row_number() over(partition by a.MTDOCCode ORDER BY a.CreateDateTime) as row, a.MTDOCCode,a.CreatePerson,a.CreateDateTime,a.Status,a.MUSER,a.MUSERName,a.MTIME from ICSMTDOC a" ;
string sql = @ " SELECT * FROM (select row_number() over(partition by a.MTDOCCode ORDER BY a.CreateDateTime) as row, a.MTDOCCode,a.CreatePerson,a.CreateDateTime,a.Status,a.MUSER,a.MUSERName,a.MTIME
from ICSMTDOC a
LEFT JOIN ICSInventoryDetail detail on a . InvCode = detail . INVCode AND a . WHCode = detail . WHCode AND a . WorkPoint = detail . WorkPoint ";
sql + = " WHERE 1=1" ;
sql = string . Format ( sql , DbHelper . GetErpIp ( ) , DbHelper . GetErpName ( ) ) ;
#endregion
@ -41,31 +43,36 @@ namespace NFine.Application.WMS
{
sql + = " and a.MTDOCCode like '%" + queryParam [ "MTDOCCode" ] . ToString ( ) + "%' " ;
}
if ( ! string . IsNullOrWhiteSpace ( queryParam [ "Area" ] . ToString ( ) ) )
{
sql + = " and detail.LocationCode='" + queryParam [ "Area" ] . ToString ( ) + "'" ;
}
if ( ! string . IsNullOrWhiteSpace ( queryParam [ "ReleaseState" ] . ToString ( ) ) )
{
sql + = " and a.Status = '" + queryParam [ "ReleaseState" ] . 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 a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
//}
sql + = " ) t WHERE t.Row=1" ;
return Repository ( ) . FindTablePageBySql ( sql . ToString ( ) , parameter . ToArray ( ) , ref jqgridparam ) ;
}
public DataTable GetSubGridJson ( string MTDOCCode )
public DataTable GetSubGridJson ( string MTDOCCode )
{
DataTable dt = new DataTable ( ) ;
//var queryParam = queryJson.ToJObject();
string sql = string . Empty ;
List < DbParameter > parameter = new List < DbParameter > ( ) ;
string WorkPoint = NFine . Code . OperatorProvider . Provider . GetCurrent ( ) . Location . TrimEnd ( ',' ) ;
sql = @ " select a.ID,a.DepCode,d.DepName,a.WHCode,c.WarehouseName,a.Sequence,b.InvCode,b.InvName,a.Quantity,a.Amount,a.MTDOCQuantity,case WHEN a.MTDOCType='1' then '转换前' ELSE '转换后' END as MTDOCType
sql = @ " select a.ID,a.DepCode,d.DepName,a.WHCode,c.WarehouseName,a.Sequence,b.InvCode,b.InvName,a.Quantity,a.Amount,a.MTDOCQuantity,case WHEN a.MTDOCType='1' then '转换前' ELSE '转换后' END as MTDOCType , detail.LocationCode AS Area
from ICSMTDOC a
left join ICSInventory b on a . InvCode = b . InvCode and a . WorkPoint = b . WorkPoint
left join ICSWarehouse c on a . WHCode = c . WarehouseCode and a . WorkPoint = c . WorkPoint
left join ICSDepartment d on a . DepCode = d . DepCode and a . WorkPoint = d . WorkPoint
LEFT JOIN ICSInventoryDetail detail on b . InvCode = detail . INVCode AND a . WHCode = detail . WHCode AND a . WorkPoint = detail . WorkPoint
WHERE a . MTDOCCode = ' { 0 } ' and a . WorkPoint in ( ' { 1 } ' ) order by a . Sequence ";
sql = string . Format ( sql , MTDOCCode , WorkPoint ) ;
return Repository ( ) . FindTableBySql ( sql . ToString ( ) ) ;
@ -85,7 +92,7 @@ namespace NFine.Application.WMS
from ICSWareHouseLotInfo a
inner join ICSInventoryLot b on a . LotNo = b . LotNo and a . WorkPoint = b . WorkPoint
left join ICSInventory c on b . InvCode = c . InvCode and b . WorkPoint = c . WorkPoint
WHERE a . Quantity > 0 and a . WorkPoint = ' " + WorkPoint + " ' "+ wherestr;
WHERE a . Quantity > 0 and a . WorkPoint = ' " + WorkPoint + " ' " + wherestr;
return Repository ( ) . FindTablePageBySql ( sql . ToString ( ) , parameter . ToArray ( ) , ref jqgridparam ) ;
}
@ -99,7 +106,7 @@ namespace NFine.Application.WMS
if ( ! string . IsNullOrEmpty ( Invcode ) )
{
wherestr + = " and InvCode like '%" + Invcode + "%'" ;
}
string sql = @ "select distinct InvCode,InvName,InvStd,InvUnit,InvDesc from dbo.ICSInventory
WHERE WorkPoint = ' " + WorkPoint + " ' " + wherestr;
@ -107,7 +114,7 @@ namespace NFine.Application.WMS
}
public DataTable GetCode ( string Type , string Common , ref Pagination jqgridparam )
public DataTable GetCode ( string Type , string Common , ref Pagination jqgridparam )
{
string WorkPoint = NFine . Code . OperatorProvider . Provider . GetCurrent ( ) . Location ;
List < DbParameter > parameter = new List < DbParameter > ( ) ;
@ -115,13 +122,13 @@ namespace NFine.Application.WMS
DataTable table = new DataTable ( ) ;
string wherestr = "" ;
string sql = string . Empty ;
if ( Type = = "1" )
if ( Type = = "1" )
{
if ( ! string . IsNullOrEmpty ( Common ) )
{
wherestr + = " and ProjectCode like '%" + Common + "%'" ;
}
sql = @ "select distinct ProjectCode as Code from ICSExtension
sql = @ "select distinct ProjectCode as Code from ICSExtension
WHERE WorkPoint = ' " + WorkPoint + " ' " + wherestr;
}
if ( Type = = "2" )
@ -270,16 +277,16 @@ namespace NFine.Application.WMS
{
string NewMTDOCCode = dts . Rows [ 0 ] [ "NewMTDOCCode" ] . ToString ( ) ;
int COUNT = Convert . ToInt32 ( NewMTDOCCode . Substring ( 8 ) ) + 1 ;
MTDOCCode = Time + COUNT . ToString ( ) . PadLeft ( 6 , '0' ) ;
MTDOCCode = Time + COUNT . ToString ( ) . PadLeft ( 6 , '0' ) ;
}
Dictionary < string , object > dic = new Dictionary < string , object > ( ) ;
foreach ( var item in res )
{
JObject jo = ( JObject ) item ;
JObject jo = ( JObject ) item ;
DataTable dt = new DataTable ( ) ;
string NewLotNo = "" ;
string LotNo = jo [ "LotNo" ] . ToString ( ) ;
#region 根据原条码查询并创建新条码
@ -294,7 +301,7 @@ namespace NFine.Application.WMS
{
string newLotNO = dt . Rows [ 0 ] [ "NewLotNo" ] . ToString ( ) ;
int COUNT = Convert . ToInt32 ( newLotNO . Substring ( newLotNO . LastIndexOf ( '-' ) + 1 ) ) + 1 ;
NewLotNo = LotNo + "-" + COUNT . ToString ( ) ;
NewLotNo = LotNo + "-" + COUNT . ToString ( ) ;
}
#endregion
@ -315,7 +322,7 @@ namespace NFine.Application.WMS
string ocFree8 = oldLotNo . Rows [ 0 ] [ "cFree8" ] . ToString ( ) ;
string ocFree9 = oldLotNo . Rows [ 0 ] [ "cFree9" ] . ToString ( ) ;
string ocFree10 = oldLotNo . Rows [ 0 ] [ "cFree10" ] . ToString ( ) ;
if ( jo [ "FlagProjectCode" ] . ToString ( ) ! = "" & & jo [ "FlagProjectCode" ] . ToString ( ) = = "1" )
if ( jo [ "FlagProjectCode" ] . ToString ( ) ! = "" & & jo [ "FlagProjectCode" ] . ToString ( ) = = "1" )
{
oProjectCode = jo [ "ProjectCode" ] . ToString ( ) ;
}
@ -374,7 +381,7 @@ namespace NFine.Application.WMS
}
//Colspan = jo["ProjectCode"].ToString() + "~" + jo["BatchCode"].ToString() + "~" + jo["Version"].ToString() + "~" + jo["Brand"].ToString() + "~" + jo["cFree1"].ToString() + "~" + jo["cFree2"].ToString() + "~" + jo["cFree3"].ToString() + "~" + jo["cFree4"].ToString() + "~" + jo["cFree5"].ToString() + "~" + jo["cFree6"].ToString() + "~" + jo["cFree7"].ToString() + "~" + jo["cFree8"].ToString() + "~" + jo["cFree9"].ToString() + "~" + jo["cFree10"].ToString();
Colspan = oProjectCode + "~" + oBatchCode + "~" + oVersion + "~" + oBrand + "~" + ocFree1 + "~" + ocFree2 + "~" + ocFree3 + "~" + ocFree4 + "~" + ocFree5 + "~" + ocFree6 + "~" + ocFree7 + "~" + ocFree8 + "~" + ocFree9 + "~" + ocFree10 ;
Colspan = oProjectCode + "~" + oBatchCode + "~" + oVersion + "~" + oBrand + "~" + ocFree1 + "~" + ocFree2 + "~" + ocFree3 + "~" + ocFree4 + "~" + ocFree5 + "~" + ocFree6 + "~" + ocFree7 + "~" + ocFree8 + "~" + ocFree9 + "~" + ocFree10 ;
string sqlsss = string . Format ( @"select ID from ICSExtension where Colspan='{0}'" , Colspan ) ;
object ExtensionID = SqlHelper . ExecuteScalar ( sqlsss ) ;
if ( ExtensionID = = null )
@ -419,23 +426,23 @@ namespace NFine.Application.WMS
select newid ( ) , ' { 1 3 } ',' { 1 5 } ' , ProductDate , ExpirationDate , Quantity , Amount , ' { 9 } ',' 1 0 2 ' , MUSER , MUSERName , MTIME , WorkPoint , ' { 3 } ' from ICSInventoryLot
where LotNo = ' { 3 } ' ";
//新增条码关联
sql + = @ " INSERT into ICSInventoryLotDetail(LotNo,TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
sql + = @ " INSERT into ICSInventoryLotDetail(LotNo,TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
select ' { 1 3 } ' , TransCode , TransSequence , MUSER , MUSERName , MTIME , WorkPoint from ICSInventoryLotDetail
where LotNo = ' { 3 } ' ";
sql = string . Format ( sql , MTDOCCode , jo [ "WHCode" ] . ToString ( ) , Num + + , jo [ "LotNo" ] . ToString ( ) , jo [ "Quantity" ] . ToString ( ) , jo [ "Amount" ] . ToString ( ) , jo [ "MTDOCQuantity" ] . ToString ( ) , Memo , MUSER , ExtensionID , MUSER , MUSERNAME , WorkPoint , NewLotNo , Num + + , OldInvcode , TimeNow ) ;
}
if ( SqlHelper . CmdExecuteNonQueryLi ( sql ) > 0 )
{
msg = "" ;
msg = "" ;
}
else
{
msg = "形态转换失败!" ;
}
return msg ;
return msg ;
}
@ -444,7 +451,7 @@ namespace NFine.Application.WMS
{
string msg = "" ;
string MUSER = NFine . Code . OperatorProvider . Provider . GetCurrent ( ) . UserCode ;
string MUSERNAME = NFine . Code . OperatorProvider . Provider . GetCurrent ( ) . UserName ;
string MUSERNAME = NFine . Code . OperatorProvider . Provider . GetCurrent ( ) . UserName ;
string WorkPoint = NFine . Code . OperatorProvider . Provider . GetCurrent ( ) . Location ;
DateTime TimeNow = DateTime . Now ;
string sql = string . Empty ;
@ -482,13 +489,13 @@ namespace NFine.Application.WMS
sql + = @ "INSERT into ICSWareHouseLotInfoLog(ID,Identification,TransCode,TransSequence,LotNo,InvCode,ToWarehouseCode,ToLocationCode,
Quantity , Lock , TransType , BusinessCode ,
MUSER , MUSERName , MTIME , WorkPoint , EATTRIBUTE1 )
select newid ( ) , ' "+ Identification + " ' , d . MTDOCCode , d . Sequence , a . LotNo , a . InvCode , a . WarehouseCode , a . LocationCode , a . Quantity , '0' , ' 1 0 ',' 3 6 ',' " + MUSER + @" ',' " + MUSERNAME + @" ',' " + TimeNow + @" ' , a . WorkPoint , ' '
select newid ( ) , ' " + Identification + " ' , d . MTDOCCode , d . Sequence , a . LotNo , a . InvCode , a . WarehouseCode , a . LocationCode , a . Quantity , '0' , ' 1 0 ',' 3 6 ',' " + MUSER + @" ',' " + MUSERNAME + @" ',' " + TimeNow + @" ' , a . WorkPoint , ' '
from ICSWareHouseLotInfo a
left join dbo . ICSInventoryLot b on a . LotNo = b . LotNo and a . WorkPoint = b . WorkPoint
left join dbo . ICSInventoryLotDetail c on b . LotNo = c . LotNo and b . WorkPoint = c . WorkPoint
left join dbo . ICSMTDOC d on a . LotNo = d . LotNo and d . WorkPoint = c . WorkPoint
where a . LotNo = ' " + NewLotNo + " ' and a . WorkPoint = ' " + WorkPoint + " ' ";
}
@ -507,17 +514,17 @@ namespace NFine.Application.WMS
select Costre , Sequence , GroupNO , [ Type ] , InvCode , WHCode , BatchCode , ProjectCode , Quantity , Amount , Version , Brand , cFree1 , cFree2 , cFree3 , cFree4 , cFree5 , cFree6 , cFree7 , cFree8 , cFree9 , cFree10 FROM # TempERP
DROP TABLE # TempERP ";
sql = string . Format ( sql , MTDOCCode , WorkPoint ) ;
msg = CmdExecuteData ( sql , MTDOCCode , Identification ) ;
msg = CmdExecuteData ( sql , MTDOCCode , Identification ) ;
return msg ;
}
public string CmdExecuteData ( string sql , string MTDOCCode , string Identification )
public string CmdExecuteData ( string sql , string MTDOCCode , string Identification )
{
string msg = "" ;
try
{
string connString = SqlHelper . DataCenterConnString ;
SqlConnection conn = new System . Data . SqlClient . SqlConnection ( connString ) ;
conn . Open ( ) ;
@ -528,7 +535,7 @@ namespace NFine.Application.WMS
try
{
DataSet DSet = SqlCommandHelper . SQlReturnDataSet ( sql , cmd ) ;
string Inputstr = SqlHelper . DataSetToJson ( DSet , "details" , "Costre" ) ;
string APIURL = ConfigurationManager . ConnectionStrings [ "ERPAPIURL" ] . ConnectionString + "MorphologicalTransformationDoc/Create" ;
string result = HttpPost ( APIURL , Inputstr ) ;
@ -557,7 +564,7 @@ namespace NFine.Application.WMS
inner join ICSMTDOC b on a . LotNo = b . LotNo and a . WorkPoint = b . WorkPoint
where b . MTDOCCode = ' { 0 } ' and b . Sequence = ' { 1 } ' and a . Identification = ' { 2 } ' ";
ERPSql + = @" update ICSMTDOC set MTDOCID='{3}',MTDOCDetailID='{4}' where MTDOCCode='{0}' and Sequence='{1}'" ;
ERPSql = string . Format ( ERPSql , MTDOCCode , det [ "Sequence" ] . ToString ( ) , Identification , jo [ "ID" ] . ToString ( ) , det [ "DetailID" ] . ToString ( ) , jo [ "MTCode" ] . ToString ( ) , det [ "Sequence" ] . ToString ( ) ) ;
ERPSql = string . Format ( ERPSql , MTDOCCode , det [ "Sequence" ] . ToString ( ) , Identification , jo [ "ID" ] . ToString ( ) , det [ "DetailID" ] . ToString ( ) , jo [ "MTCode" ] . ToString ( ) , det [ "Sequence" ] . ToString ( ) ) ;
}
}
SqlCommandHelper . CmdExecuteNonQuery ( ERPSql , cmd ) ;
@ -568,7 +575,7 @@ namespace NFine.Application.WMS
msg = ex . Message ;
}
}
cmd . Transaction . Commit ( ) ;
//return dt;
}
@ -589,7 +596,7 @@ namespace NFine.Application.WMS
catch ( Exception ex )
{
msg = ex . Message ;
}
return msg ;
@ -896,9 +903,9 @@ namespace NFine.Application.WMS
var info = ds . Tables [ 2 ] . Select ( string . Format ( " LotNo='{0}'" , LotNo ) ) ;
if ( ! string . IsNullOrEmpty ( info [ 0 ] [ "Amount" ] . ToString ( ) ) )
{
Amount = Convert . ToDecimal ( info [ 0 ] [ "Amount" ] . ToString ( ) ) ;
Amount = Convert . ToDecimal ( info [ 0 ] [ "Amount" ] . ToString ( ) ) ;
}
string sqlsss = string . Format ( @"select ID from ICSExtension where Colspan='{0}'" , LaterColspan ) ;
object ExtensionID = SqlHelper . ExecuteScalar ( sqls ) ;