Browse Source

Mao update

master
Mao 3 years ago
parent
commit
6f769f994b
  1. 4
      ICSSoft.WMS.WebAPI/ICSSoft.Common/DataToJsonHelper.cs
  2. 6
      ICSSoft.WMS.WebAPI/ICSSoft.Common/ERPUrl.cs
  3. 4
      ICSSoft.WMS.WebAPI/ICSSoft.Common/TransTypeEnum.cs
  4. 112
      ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs
  5. 21
      ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs
  6. 80
      ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseService.cs
  7. 40
      ICSSoft.WMS.WebAPI/ICSSoft.WMS.WebAPI/Controllers/WMSBarCoreController.cs

4
ICSSoft.WMS.WebAPI/ICSSoft.Common/DataToJsonHelper.cs

@ -46,6 +46,10 @@ namespace ICSSoft.Common
/// <returns></returns>
public static string DataSetToJson(DataSet dataSet,string RelationName,string column)
{
//if (!dataSet.Tables[0].Columns.Contains(column))
//{
//}
DataRelation dataRelation = new DataRelation(RelationName, dataSet.Tables[0].Columns[column], dataSet.Tables[1].Columns[column]);
dataSet.Relations.Add(dataRelation);

6
ICSSoft.WMS.WebAPI/ICSSoft.Common/ERPUrl.cs

@ -76,6 +76,12 @@
/// 一步式调拨单
/// </summary>
public static string OneStepTransferDocInURL = url+ "OneStepTransferDocIn/Approve";
/// <summary>
/// 调拨单
/// </summary>
public static string StepTransferDocInURL = url + "OneStepTransferDocIn/Create";
/// <summary>
/// 两步调出
/// </summary>

4
ICSSoft.WMS.WebAPI/ICSSoft.Common/TransTypeEnum.cs

@ -116,6 +116,10 @@ namespace ICSSoft.Common
[DBValue("21")]
OneStepTransferDocIn, //(合并发料)
[Description("调拨")]
[DBValue("69")]
StepTransferDocIn, //(合并发料)
[Description("两步调出")]
[DBValue("22")]
TwoStepTransferDocOut, //(合并发料)

112
ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs

@ -227,28 +227,18 @@ namespace ICSSoft.DataProject
#region SLQ
sql = @"SELECT a.ID,
{0}
a.InvCode,
inv.InvName,
inv.InvStd,
a.Quantity,
inv.InvUnit,
a.SelectLevel AS LocationCode,
a.Amount,
a.WHCode,
inv.AmountUnit,
wh.WarehouseName AS WHName,
a.MUSER AS [User],
a.MTIME AS [MTime]
FROM {1}
INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint
LEFT JOIN ICSWarehouse wh ON a.WHCode=wh.WarehouseCode AND a.WorkPoint=wh.WorkPoint
FROM {1}
WHERE {2} ";
#endregion
columns = @"a.CheckCode AS TransCode,
a.ID AS DetailID,
'' AS Type,
row_number() OVER (ORDER BY a.InvCode) AS TransSequence,
a.ActualQuantity AS IssueQuantity,";
a.ID,
'' AS Type,";
tableName = @"ICSCheck a ";
@ -318,6 +308,11 @@ namespace ICSSoft.DataProject
where = @" a.TransferNO='{0}' AND a.WorkPoint='{1}' AND a.Status='1' ";
}
#endregion
#region 调拨(合并发料)
else if (TransType == TransTypeEnum.StepTransferDocIn.GetDescription())
{
}
#endregion
#region 两步调出(合并发料)
else if (TransType == TransTypeEnum.TwoStepTransferDocOut.GetDescription())
{
@ -833,6 +828,7 @@ namespace ICSSoft.DataProject
|| TransType == TransTypeEnum.MOIssueDoc.GetDescription() //生产发料
|| TransType == TransTypeEnum.SalesShipmentDoc.GetDescription() //销售出库
|| TransType == TransTypeEnum.OneStepTransferDocIn.GetDescription() //一步调拨
|| TransType == TransTypeEnum.StepTransferDocIn.GetDescription() //调拨
|| TransType == TransTypeEnum.TwoStepTransferDocOut.GetDescription() //两步调出
|| TransType == TransTypeEnum.OtherOutDoc.GetDescription() //其他出库
|| TransType == TransTypeEnum.Check.GetDescription() //盘点
@ -1162,9 +1158,9 @@ namespace ICSSoft.DataProject
{
string Lot = drLot["LotNo"].ToString();
string rowFilter = "InvCode='" + drLot["InvCode"] + "'";
CheckTrans(dataView, rowFilter, string.Format(language.GetNameByCode("WMSAPIInfo041"), Lot, drLot["InvCode"]));
//CheckTrans(dataView, rowFilter, string.Format(language.GetNameByCode("WMSAPIInfo041"), Lot, drLot["InvCode"]));
rowFilter += " AND (LEN(ISNULL(WHCode,''))<=0 OR (LEN(ISNULL(WHCode,''))>0 AND WHCode='" + drLot["WHCode"] + "'))";
CheckTrans(dataView, rowFilter, string.Format(language.GetNameByCode("WMSAPIInfo042"), Lot, drLot["WHCode"]));
//CheckTrans(dataView, rowFilter, string.Format(language.GetNameByCode("WMSAPIInfo042"), Lot, drLot["WHCode"]));
//盘点不需要对比以下属性
if (TransType == TransTypeEnum.Check.GetDescription())
continue;
@ -3559,7 +3555,7 @@ namespace ICSSoft.DataProject
}
#endregion
#region 调拨
#region 一步调拨
/// <summary>
/// 一步调拨
/// </summary>
@ -3671,6 +3667,88 @@ namespace ICSSoft.DataProject
}
#endregion
#region 调拨
/// <summary>
/// 调拨
/// </summary>
/// <param name="JsonData"></param>
/// <returns></returns>
public static DataTable TransferDocCreate(List<TransferDoc> JsonData)
{
var language = LanguageHelper.GetName("WMSAPIInfo");
if (JsonData.Count <= 0)
{
throw new Exception(language.GetNameByCode("WMSAPIInfo007"));//"传送数据为空!"
}
using (SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString))
{
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
try
{
string sql = string.Empty;
string Identification = Guid.NewGuid().ToString();
foreach (var item in JsonData)
{
string MergeID = "";
foreach (var itemInfo in item.Detail)
{
//验证仓库库位信息
sql = @"IF NOT EXISTS(SELECT a.ID FROM ICSWareHouse a WHERE a.WarehouseCode='{0}' AND a.WorkPoint='{1}')
BEGIN
RAISERROR('" + language.GetNameByCode("WMSAPIInfo069") + @"',16,1);
RETURN
END
IF NOT EXISTS(SELECT a.ID FROM ICSLocation a WHERE a.LocationCode='{2}' AND a.WorkPoint='{1}')
BEGIN
RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo070"), "{2}") + @"',16,1);
RETURN
END
IF NOT EXISTS(SELECT a.ID
FROM ICSWareHouse a
INNER JOIN ICSLocation b ON a.ID=b.WHID AND a.WorkPoint=b.WorkPoint
WHERE a.WarehouseCode='{0}' AND a.WorkPoint='{1}' AND b.LocationCode='{2}')
BEGIN
RAISERROR('" + language.GetNameByCode("WMSAPIInfo071") + @"',16,1);
RETURN
END";
sql = string.Format(sql, itemInfo.WarehouseCode, item.WorkPoint, itemInfo.LocationCode);
DBHelper.ExecuteNonQuery(sql, cmd);
//更新条码信息
ICSWareHouseLotInfoService.WareHouseLotInfoTransfer(Identification, item.TransCode, item.TransSequence, itemInfo.WarehouseCode, itemInfo.LocationCode,
itemInfo.LotNo, itemInfo.CurrentQuantity, item.User, item.WorkPoint, "6", TransTypeEnum.StepTransferDocIn.GetDescription<DBValue>(), cmd, language, MergeID);
}
}
ICSWareHouseService.StepTransferDocInERP(TransTypeEnum.StepTransferDocIn.GetDescription(), Identification, cmd, language);
DataTable table = GetData(Identification, 3, cmd);
cmd.Transaction.Commit();
return table;
}
catch (Exception ex)
{
if (cmd.Transaction != null)
cmd.Transaction.Rollback();
log.Error(ex.Message);
throw new Exception(ex.Message);
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Dispose();
}
}
}
#endregion
#region 移库
/// <summary>
/// 移库

21
ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs

@ -286,13 +286,19 @@ namespace ICSSoft.DataProject
RETURN
END
IF EXISTS(SELECT id FROM ICSWareHouseLotInfo WHERE WarehouseCode='{9}' AND LocationCode='{10}' AND WorkPoint='{1}' AND LotNo = '{0}')
BEGIN
RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo355")) + @"',16,1);
RETURN
END
INSERT INTO ICSWareHouseLotInfoLog(ID,Identification,TransCode,TransSequence,LotNo,InvCode,
FromWarehouseCode,FromLocationCode,ToWarehouseCode,ToLocationCode,Quantity,
Memo,Lock,TransType,BusinessCode,ERPUpload,ERPID,
ERPDetailID,ERPCode,ERPSequence,MUSER,MUSERName,
MTIME,WorkPoint,EATTRIBUTE1,MergeID)
SELECT NEWID(),'{3}','{4}','{5}',a.LotNo ,a.InvCode ,
c.WarehouseCode,c.LocationCode,'{9}','{10}','{6}',
SELECT NEWID(),'{3}','','',a.LotNo ,a.InvCode ,
c.WarehouseCode,c.LocationCode,'{9}','{10}',{6},
'','0','{7}','{8}','0','',
'','','',f.F_Account ,f.F_RealName ,
SYSDATETIME() ,a.WorkPoint ,'','{11}'
@ -313,7 +319,7 @@ namespace ICSSoft.DataProject
RAISERROR('" + language.GetNameByCode("WMSAPIInfo038") + @"',16,1);
RETURN
END
IF EXISTS(SELECT a.ID FROM ICSWareHouseLotInfo a WHERE LotNo='{0}' AND WorkPoint='{1}' AND a.Quantity<'{4}')
IF EXISTS(SELECT a.ID FROM ICSWareHouseLotInfo a WHERE LotNo='{0}' AND WorkPoint='{1}' AND a.Quantity<{4})
BEGIN
RAISERROR('" + language.GetNameByCode("WMSAPIInfo167") + @"',16,1);
RETURN
@ -963,6 +969,15 @@ namespace ICSSoft.DataProject
WHERE c.TransferID='{0}' AND a.Identification='{1}' AND ERPUpload='0' AND c.Type='1'
";
}
//调拨
else if (TransType == TransTypeEnum.OneStepTransferDocIn.GetDescription())
{
ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
FROM ICSWareHouseLotInfoLog a
INNER JOIN ICSTransfer c ON a.TransCode=c.TransferNO AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
WHERE c.TransferID='{0}' AND a.Identification='{1}' AND ERPUpload='0' AND c.Type='1'
";
}
//两步调出
else if (TransType == TransTypeEnum.TwoStepTransferDocOut.GetDescription())
{

80
ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseService.cs

@ -117,6 +117,86 @@ namespace ICSSoft.DataProject
}
#endregion
#region 调拨
/// <summary>
/// 调拨接口
/// </summary>
/// <param name="TransType"></param>
/// <param name="Identification"></param>
/// <param name="cmd"></param>
public static void StepTransferDocInERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language)
{
try
{
#region ERP开立状态单据审核
//检验调拨单是否一次性发完
string sql = @"SELECT a.ToWarehouseCode+a.MUSER+a.FromWarehouseCode AS Costre,a.ToWarehouseCode AS ToWHCode,a.FromWarehouseCode AS FromWHCode,a.MUSER,'' AS FromDepCode,'' AS ToDepCode,NULL AS TACode,ROW_NUMBER() OVER (ORDER BY a.ToWarehouseCode) AS Sequence,NULL AS TADetailID,
a.InvCode,SUM(a.Quantity) AS Quantity,0 AS Amount,con.Enable AS UpdateTodoQuantity,conStock.Enable AS UpdateStock
,a.WorkPoint,ISNULL(ext.ProjectCode, '') AS ProjectCode,CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END AS BatchCode,ISNULL(ext.Version, '') AS Version,ISNULL(ext.Brand, '') AS Brand,
ISNULL(ext.cFree1, '') AS cFree1,ISNULL(ext.cFree2, '') AS cFree2,ISNULL(ext.cFree3, '') AS cFree3,ISNULL(ext.cFree4, '') AS cFree4,ISNULL(ext.cFree5, '') AS cFree5,ISNULL(ext.cFree6, '') AS cFree6,ISNULL(ext.cFree7, '') AS cFree7,ISNULL(ext.cFree8, '') AS cFree8,ISNULL(ext.cFree9, '') AS cFree9,ISNULL(ext.cFree10, '') AS cFree10
INTO #TempERP
FROM ICSWareHouseLotInfoLog a
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint
INNER JOIN ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint
LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.ToWarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint
INNER JOIN ICSConfiguration con ON con.Code='Stock003' AND a.WorkPoint=con.WorkPoint
INNER JOIN ICSConfiguration conStock ON conStock.Code='UpdateStock006' AND a.WorkPoint=conStock.WorkPoint
WHERE a.Identification='{0}' AND ERPUpload='0'
GROUP BY a.ToWarehouseCode,a.MUSER,a.InvCode,conStock.Enable,con.Enable,a.FromWarehouseCode
,a.WorkPoint,ISNULL(ext.ProjectCode, ''),CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END,ISNULL(ext.Version, ''),ISNULL(ext.Brand, ''),
ISNULL(ext.cFree1, ''),ISNULL(ext.cFree2, ''),ISNULL(ext.cFree3, ''),ISNULL(ext.cFree4, ''),ISNULL(ext.cFree5, ''),ISNULL(ext.cFree6, ''),ISNULL(ext.cFree7, ''),ISNULL(ext.cFree8, ''),ISNULL(ext.cFree9, ''),ISNULL(ext.cFree10, '')
SELECT DISTINCT Costre,ToWHCode,FromWHCode,FromDepCode ,ToDepCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity,WorkPoint,TACode,UpdateStock FROM #TempERP
SELECT Costre,Sequence,InvCode,Quantity,Amount,TADetailID,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10
FROM #TempERP
DROP TABLE #TempERP";
sql = string.Format(sql, Identification);
DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
string Inputstr = DataToJsonHelper.DataSetToJson(ds, "details", "Costre");
string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.StepTransferDocInURL, Inputstr);
Result result = new Result();
result = JsonConvert.DeserializeObject<Result>(resultStr);
if (result.Success)
{
try
{
JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
foreach (var item in res)
{
JObject jo = (JObject)item;
JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
foreach (var detail in resdetail)
{
JObject det = (JObject)detail;
ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["DNDetailID"].ToString(), Identification, jo["ID"].ToString(), det["DetailID"].ToString(), jo["RCVTCode"].ToString(), det["Sequence"].ToString(), cmd, language);
}
}
}
catch (Exception ex)
{
log.Debug(ex.ToString());
log.Debug(resultStr);
}
}
else
{
throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
}
#endregion
}
catch (Exception)
{
throw;
}
}
#endregion
#region 两步调出
/// <summary>
/// 两步调出

40
ICSSoft.WMS.WebAPI/ICSSoft.WMS.WebAPI/Controllers/WMSBarCoreController.cs

@ -1759,6 +1759,46 @@ namespace ICSSoft.WebAPI.Controllers
}
#endregion
#region 调拨单
[HttpPost]
[Route("api/TransferDoc/Create")]
public HttpResponseMessage TransferDocCreate([FromBody] object JsonData)
{
try
{
List<TransferDoc> model = new List<TransferDoc>();
if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
{
model = JsonConvert.DeserializeObject<List<TransferDoc>>(JsonData.ToString());
//WMSBarCoreService action = new WMSBarCoreService();
//var resultStr = action.TransferDocupdte(model);
var resultStr = ICSSubmitService.TransferDocCreate(model);
res.Success = true;
res.Message = LanguageHelper.GetNameSingle("WMSAPI001");// "接口调用成功!";
if (resultStr != null && resultStr.Rows.Count > 0 && resultStr.ToString() != "[]")
{
res.Data = resultStr;
}
}
}
catch (Exception ex)
{
log.Error("转换失败:" + ex.ToString());
res.Success = false;
res.Message = ex.Message;
}
finally
{
str = JsonConvert.SerializeObject(res);
result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
}
log.Debug("调拨单返回值:" + str);
return result;
}
#endregion
#region 登录 login
/// <summary>
/// 登录

|||||||
100:0
Loading…
Cancel
Save