diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs index c075e06..58bed75 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs @@ -2046,7 +2046,7 @@ a.ExtensionID tableName = @"ICSDeliveryNotice a "; - where = @" a.DNCode='{0}' AND a.WorkPoint='{1}' AND a.DNType='1' AND a.Status<>'1'"; + where = @" a.EATTRIBUTE10='{0}' AND a.WorkPoint='{1}' AND a.DNType='1' AND a.Status='1'"; singleWhere = @" a.DNCode='{0}' AND a.WorkPoint='{1}'"; } @@ -32809,7 +32809,8 @@ END as NEWLotNo RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo060"), "{0}") + @"',16,1); RETURN END - ", item.User, item.WorkPoint) + sql; + ", item.User, item.WorkPoint) + + sql; if (!DBHelper.ExecuteNonQuery(sql, cmd)) { throw new Exception(language.GetNameByCode("WMSAPIInfo011")); //"到货单信息创建失败! @@ -33198,5 +33199,134 @@ INNER JOIN ICSExtension extt ON ISNULL(ext.ProjectCode, '')+'~'+CASE WHEN (invBa } } + public static DataTable ICSCodingInNewBarcodeByClientCreate(List JsonData) + { + var language = LanguageHelper.GetName("WMSAPIInfo"); + string Identification = Guid.NewGuid().ToString(); + 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(); + string Colspan = string.Empty; + string IDD = string.Empty; + cmd.Transaction = sqlTran; + cmd.Connection = conn; + cmd.CommandTimeout = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["TimeOut"]); + try + { + string codes = string.Empty; + string sql = string.Empty; + + foreach (var item in JsonData) + { + + //检验自由项 + Colspan = item.ProjectCode + "~" + item.BatchCode + "~" + item.Version + + "~" + item.Brand + "~" + item.cFree1 + + "~" + item.cFree2 + "~" + item.cFree3 + "~" + item.cFree4 + + "~" + item.cFree5 + "~" + item.cFree6 + "~" + item.cFree7 + + "~" + item.cFree8 + "~" + item.cFree9 + "~" + item.cFree10; + sql = @"select ID,Colspan from ICSExtension a + where Colspan='{0}' and WorkPoint='{1}'"; + sql = string.Format(sql, Colspan, item.WorkPoint); + DataTable dttt = DBHelper.SQlReturnData(sql, cmd); + if (dttt.Rows.Count == 0) + { + IDD = Guid.NewGuid().ToString(); + sql = @"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint) + select '{17}','{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}',GETDATE(),'{15}',f.F_RealName,'{16}'from Sys_SRM_User f where f.F_Account='{15}' and f.F_Location='{16}'"; + sql = string.Format(sql, Colspan, item.ProjectCode, item.BatchCode, item.Version, item.Brand, item.cFree1, item.cFree2, item.cFree3, item.cFree4, item.cFree5, item.cFree6, item.cFree7, item.cFree8, item.cFree9, item.cFree10, item.User, item.WorkPoint, IDD); + if (!DBHelper.ExecuteNonQuery(sql, cmd)) + { + throw new Exception(language.GetNameByCode("WMSAPIInfo366")); + } + } + else + { + IDD = dttt.Rows[0]["ID"].ToString(); + } + + string checkSql = @" + -- 查询物料编码是否存在 + IF NOT EXISTS(SELECT 1 FROM ICSInventory WHERE EATTRIBUTE5='{1}' AND WorkPoint='{2}') + BEGIN + RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo524"), "{1}") + @"',16,1) + RETURN + END + -- 查询条码表条数 + SELECT COUNT(1) FROM ICSInventoryLot WHERE LotNo='{0}' AND WorkPoint='{2}' + "; + checkSql = string.Format(checkSql, item.LotNo, item.InvCode, item.WorkPoint); + log.Debug("查询条码条数SQL:" + checkSql); + int lotNum = (int)(DBHelper.ExecuteScalar(checkSql, cmd) == null ? "0" : DBHelper.ExecuteScalar(checkSql, cmd)); + log.Debug("本次查询条码表 " + item.LotNo + " 条数:" + lotNum); + if (lotNum > 0) + { + //条码存在的情况下,验证是否已入库 + sql = @" + IF EXISTS(SELECT a.LotNo FROM ICSWareHouseLotInfo a WHERE a.LotNo='{0}' AND a.WorkPoint='{1}') + BEGIN + RAISERROR('" + language.GetNameByCode("WMSAPIInfo164") + @"',16,1); + RETURN + END"; + sql = string.Format(sql, item.LotNo, item.WorkPoint); + DBHelper.ExecuteNonQuery(sql, cmd); + } + else + { + //插入条码表 + sql = @" + -- 插入条码表 + INSERT INTO ICSInventoryLot(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,Type,MUSER,MUSERName,MTIME,WorkPoint,ExtensionID,EATTRIBUTE10,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE11,EATTRIBUTE12,EATTRIBUTE13) + VALUES(NEWID(),'{0}',(SELECT InvCode FROM ICSInventory WHERE EATTRIBUTE5='{1}' AND WorkPoint='{5}'),'{2}','9999-12-31',{3},'25','{4}',(SELECT F_RealName FROM Sys_SRM_User WHERE F_Account='{4}' AND F_Location='{5}'),GETDATE(),'{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}') + Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint,TransID) + Values('{0}','','','{4}',(SELECT F_RealName FROM Sys_SRM_User WHERE F_Account='{4}' AND F_Location='{5}'),GETDATE(),'{5}','' ) + "; + sql = string.Format(sql, item.LotNo, item.InvCode, item.MTIME, item.Quantity, item.User, item.WorkPoint, IDD, item.BatchCode, item.VenCode, item.MPN, item.StreamCode, item.SpecialRequire, item.CreateDate); + log.Debug("赋码入库创建条码SQL:" + Environment.NewLine + sql); + + if (!DBHelper.ExecuteNonQuery(sql, cmd)) + { + throw new Exception(language.GetNameByCode("WMSAPIInfo173"));//"条码表写入失败!" + } + } + + codes += "'" + item.LotNo + item.WorkPoint + "',"; + } + + #region 查询返回数据 + sql = @"SELECT lot.LotNo,lot.InvCode,lot.Quantity,lot.EATTRIBUTE10 AS BatchCode,lot.EATTRIBUTE8 AS VenCode,lot.EATTRIBUTE9 AS MPN,lot.EATTRIBUTE11 AS StreamCode,lot.EATTRIBUTE13 AS CreateDate,lot.EATTRIBUTE12 AS SpecialRequire,inv.InvName + FROM ICSInventoryLot lot + INNER JOIN ICSInventory inv ON inv.EATTRIBUTE5=lot.InvCode AND inv.WorkPoint=lot.WorkPoint + WHERE lot.LotNo+lot.WorkPoint IN ({0})"; + sql = string.Format(sql, codes.Substring(0, codes.Length - 1)); + DataTable data = DBHelper.SQlReturnData(sql, cmd); + #endregion + cmd.Transaction.Commit(); + return data; + } + 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(); + } + } + } + } } \ No newline at end of file diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.WMS.WebAPI/Controllers/WMSBarCoreController.cs b/ICSSoft.WMS.WebAPI/ICSSoft.WMS.WebAPI/Controllers/WMSBarCoreController.cs index c3205e3..65c3d71 100644 --- a/ICSSoft.WMS.WebAPI/ICSSoft.WMS.WebAPI/Controllers/WMSBarCoreController.cs +++ b/ICSSoft.WMS.WebAPI/ICSSoft.WMS.WebAPI/Controllers/WMSBarCoreController.cs @@ -6826,6 +6826,47 @@ namespace ICSSoft.WebAPI.Controllers return result; } + #region 创建客供料的解析条码 + [HttpPost] + [Route("api/CodingInNewBarcodeByClient/Create")] + public HttpResponseMessage ICSCodingInNewBarcodeByClientCreate([FromBody]object JsonData) + { + log.Info("创建客供料解析条码传入值" + JsonData); + try + { + List model = new List(); + if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]") + { + model = JsonConvert.DeserializeObject>(JsonData.ToString()); + lock (key) + { + var resultStr = ICSSubmitService.ICSCodingInNewBarcodeByClientCreate(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 + } }