Browse Source

PDA服务

master
陆晔 2 years ago
parent
commit
8dce5e1d4a
  1. 12
      ICSSoft.WMS.WebAPI/ICSSoft.Common/TransTypeEnum.cs
  2. 224
      ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs
  3. 63
      ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSWareHouseLotInfoService.cs
  4. 122
      ICSSoft.WMS.WebAPI/ICSSoft.WMS.WebAPI/Controllers/WMSBarCoreController.cs

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

@ -213,5 +213,17 @@ namespace ICSSoft.Common
[DBValue("47")]
StepTransferApplicationIn,
[Description("条码查询")]
[DBValue("70")]
LOTInfoGet,
[Description("绑定")]
[DBValue("71")]
ContainerBind,
[Description("解绑")]
[DBValue("72")]
ContainerUnBind,
}
}

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

@ -970,6 +970,132 @@ namespace ICSSoft.DataProject
}
#endregion
#region 料架信息
/// <summary>
/// 料架验证
/// </summary>
/// <param name="JsonData"></param>
/// <returns></returns>
public static Result ContainerCheck(ICSContainerInfo JsonData)
{
var language = LanguageHelper.GetName("WMSAPIInfo");
DataTable table = new DataTable();
string msg = "";
using (SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString))
{
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
try
{
string TransType = JsonData.TransType;
string ContainerID = "";
if (String.IsNullOrEmpty(JsonData.ContainerCode))
{
msg = string.Format(language.GetNameByCode("WMSAPIInfo007"));//"传入数据为空!"
}
if (String.IsNullOrEmpty(JsonData.WorkPoint))
{
msg = string.Format(language.GetNameByCode("WMSAPIInfo004"));//"站点不能为空!"
}
if (TransType != TransTypeEnum.ContainerBind.GetDescription() && TransType != TransTypeEnum.ContainerUnBind.GetDescription())
{
throw new Exception(language.GetNameByCode("WMSAPIInfo199"));//"操作类型错误!"
}
string chksql = @"select ID,ContainerCode from ICSContainer
where ContainerCode='{0}' AND WorkPoint='{1}'";
chksql = string.Format(chksql, JsonData.ContainerCode, JsonData.WorkPoint);
DataTable chkdt = DBHelper.SQlReturnData(chksql, cmd);
if (chkdt.Rows.Count == 0)
{
msg = string.Format(language.GetNameByCode("WMSAPIInfo195"), JsonData.ContainerCode);//"容器不存在!"
}
else
{
ContainerID = chkdt.Rows[0]["ID"].ToString();
}
if (TransType == TransTypeEnum.ContainerBind.GetDescription())
{
chksql = @" select C.LotNo from ICSContainer A
INNER JOIN ICSContainerLot B ON B.ContainerID=A.ID AND B.WorkPoint=A.WorkPoint
INNER JOIN ICSWareHouseLotInfo C ON C.LotNo=B.LotNo AND C.WorkPoint=B.WorkPoint
WHERE A.ContainerCode='{0}' AND A.WorkPoint='{1}'";
chksql = string.Format(chksql, JsonData.ContainerCode, JsonData.WorkPoint);
chkdt = DBHelper.SQlReturnData(chksql, cmd);
if (chkdt.Rows.Count != 0)
{
msg = string.Format(language.GetNameByCode("WMSAPIInfo196"), JsonData.ContainerCode);//"容器已入库!"
}
}
else
{
chksql = @"select LotNo from ICSContainerLot
where ContainerID='{0}' AND WorkPoint='{1}'";
chksql = string.Format(chksql, ContainerID, JsonData.WorkPoint);
chkdt = DBHelper.SQlReturnData(chksql, cmd);
if (chkdt.Rows.Count == 0)
{
msg = string.Format(language.GetNameByCode("WMSAPIInfo200"), JsonData.ContainerCode);//"容器未绑定条码!"
}
else
{
string sql = @"SELECT a.ID,
con.ContainerCode,
con.ContainerName,
a.LotNo,
a.InvCode,
inv.InvName,
inv.InvStd,
a.Quantity
FROM ICSWareHouseLotInfo a
LEFT JOIN ICSContainerLot conlot ON a.LotNo=conlot.LotNo AND a.WorkPoint=conlot.WorkPoint
LEFT JOIN ICSContainer con ON conlot.ContainerID=con.ID AND conlot.WorkPoint=con.WorkPoint
INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint
WHERE bom.ContainerCode='{0}' AND a.WorkPoint='{1}' ";
sql = string.Format(sql, JsonData.ContainerCode, JsonData.WorkPoint);
log.Info("条码sql:" + sql);
table = DBHelper.SQlReturnData(sql, cmd);
}
}
Result res = new Result();
if (msg == "")
{
if (TransType == TransTypeEnum.ContainerBind.GetDescription())
{
res.Success = true;
res.Message = msg;// "接口调用成功!";
}
else
{
res.Success = true;
res.Message = msg;// "接口调用成功!";
res.Data = table;
}
}
else
{
res.Success = false;
res.Message = msg;// "返回错误信息!";
}
return res;
}
catch (Exception ex)
{
log.Error(ex.Message);
throw new Exception(ex.Message);
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Dispose();
}
}
}
#endregion
#region 条码信息
/// <summary>
/// 条码信息
@ -1694,6 +1820,25 @@ namespace ICSSoft.DataProject
LEFT JOIN (SELECT EATTRIBUTE1 AS LotNo,WorkPoint,EATTRIBUTE1+'-'+CAST((MAX(CAST(SUBSTRING(LotNo, CHARINDEX('-', LotNo)+1, LEN(LotNo)-CHARINDEX('-', LotNo)) AS INT))+1) AS VARCHAR) AS SplitLotNo FROM ICSInventoryLot GROUP BY EATTRIBUTE1,WorkPoint) split ON a.LotNo=split.LotNo AND a.WorkPoint=split.WorkPoint
LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.WarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint";
}
else if (TransType == TransTypeEnum.LOTInfoGet.GetDescription())
{
sql = @"IF EXISTS(SELECT a.ID FROM ICSWareHouseLotInfo a WHERE a.LotNo='{2}' AND a.WorkPoint='{3}' AND a.Quantity>0)
BEGIN
RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo039"), "{2}") + @"',16,1);
RETURN
END
IF NOT EXISTS(SELECT a.ID FROM ICSInventoryLot a WHERE a.LotNo='{2}' AND a.WorkPoint='{3}' )
BEGIN
RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo038"), "{2}") + @"',16,1);
RETURN
END
" + sql;
columns = @"a.Quantity,";
tableName = @" ICSInventoryLot a
INNER JOIN ICSExtension ext ON ext.ID=a.ExtensionID AND ext.WorkPoint=a.WorkPoint";
}
//出库条码
else if (isOut)
{
@ -1862,11 +2007,13 @@ namespace ICSSoft.DataProject
{//生产退料
columnsWHCODE = @"(SELECT negg.WHCODE FROM ICSMOApplyNegDetail neg LEFT JOIN ICSMOApplyNeg negg ON neg.ApplyNegCode=negg.ApplyNegCode
WHERE lotdd.TransCode=neg.ApplyNegCode AND lotdd.TransSequence=neg.Sequence AND lotdd.WorkPoint=neg.WorkPoint and negg.Type='1') AS WHCode";
}else if (LotType.Equals("2"))
}
else if (LotType.Equals("2"))
{//委外退料
columnsWHCODE = @"(SELECT negg.WHCODE FROM ICSOApplyNegDetail neg LEFT JOIN ICSOApplyNeg negg ON neg.OApplyNegCode=negg.OApplyNegCode
WHERE lotdd.TransCode=neg.OApplyNegCode AND lotdd.TransSequence=neg.Sequence AND lotdd.WorkPoint=neg.WorkPoint and negg.Type='1') AS WHCode";
}else if (LotType.Equals("3"))
}
else if (LotType.Equals("3"))
{//工单
columnsWHCODE = @"(SELECT a.WHCode FROM ICSMO a WHERE a.MOCode=lotdd.TransCode AND a.Sequence=lotdd.TransSequence AND a.WorkPoint=lotdd.WorkPoint) AS WHCode";
}
@ -6185,6 +6332,79 @@ WHERE WorkPoint='{0}' AND Quantity>ISNULL(TransferQuantity, 0) order by Transfer
}
#endregion
#region 料架条码绑定/解绑
/// <summary>
/// 料架条码绑定
/// </summary>
/// <param name="JsonData"></param>
/// <returns></returns>
public static Result ContainerBindCreate(List<ICSContainerBind> JsonData)
{
var language = LanguageHelper.GetName("WMSAPIInfo");
DataTable table = new DataTable();
string msg = "";
using (SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString))
{
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
try
{
foreach (ICSContainerBind item in JsonData)
{
string TransType = item.TransType;
if (JsonData.Count <= 0)
{
msg = string.Format(language.GetNameByCode("WMSAPIInfo007"));//"传入数据为空!"
}
if (String.IsNullOrEmpty(item.WorkPoint))
{
msg = string.Format(language.GetNameByCode("WMSAPIInfo004"));//"站点不能为空!"
}
if (String.IsNullOrEmpty(item.LotNo))
{
msg = string.Format(language.GetNameByCode("WMSAPIInfo005"));//"条码不能为空!"
}
if (String.IsNullOrEmpty(item.ContainerCode))
{
msg = string.Format(language.GetNameByCode("WMSAPIInfo197"));//"料架不能为空!"
}
if (TransType != TransTypeEnum.ContainerBind.GetDescription() && TransType != TransTypeEnum.ContainerUnBind.GetDescription())
{
msg = string.Format(language.GetNameByCode("WMSAPIInfo199"));//"操作类型错误!"
}
if (TransType == TransTypeEnum.ContainerBind.GetDescription())
{
//料架条码绑定
ICSWareHouseLotInfoService.ContainerBind(item.LotNo, item.ContainerCode, item.ContainerType, item.User, item.WorkPoint, cmd, language);
}
else
{
//料架条码解绑
ICSWareHouseLotInfoService.ContainerUnBind(item.ContainerCode, item.WorkPoint, cmd, language);
}
}
Result res = new Result();
res.Success = true;
res.Message = msg;// "接口调用成功!";
return res;
}
catch (Exception ex)
{
log.Error(ex.Message);
throw new Exception(ex.Message);
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Dispose();
}
}
}
#endregion
}
}

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

@ -2352,5 +2352,68 @@ namespace ICSSoft.DataProject
throw;
}
}
/// <summary>
/// 料架条码绑定
/// </summary>
/// <param name="LotNo"></param>
/// <param name="ContainerCode"></param>
/// <param name="User"></param>
/// <param name="WorkPoint"></param>
/// <param name="cmd"></param>
/// <param name="language"></param>
public static void ContainerBind(string LotNo, string ContainerCode, string ContainerType, string User, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
{
try
{
///添加日志
string sql = @"IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{3}' AND F_Location='{2}')
BEGIN
RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo060"), "{3}") + @"',16,1);
RETURN
END
INSERT INTO ICSContainerLot
(ID,ContainerID,LotNo,MUSER,MUSERName,WorkPoint,MTIME,EATTRIBUTE1)
SELECT NEWID(),ID,'{0}','{3}'
,(SELECT F_RealName FROM Sys_SRM_User WHERE F_Account='{3}' AND F_Location='{2}'),'{2}',GETDATE(),'{4}' FROM ICSContainer
WHERE ContainerCode='{1}' AND WorkPoint='{2}'
";
sql = string.Format(sql, LotNo, ContainerCode, WorkPoint, User, ContainerType);
if (!DBHelper.ExecuteNonQuery(sql, cmd))
{
throw new Exception(string.Format(language.GetNameByCode("WMSAPIInfo060"), ContainerCode, LotNo));
}
}
catch (Exception)
{
throw;
}
}
/// <summary>
/// 料架条码解绑
/// </summary>
/// <param name="ContainerCode"></param>
/// <param name="WorkPoint"></param>
/// <param name="cmd"></param>
/// <param name="language"></param>
public static void ContainerUnBind(string ContainerCode, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
{
try
{
///添加日志
string sql = @"delete from ICSContainerLot
WHERE ContainerCode='{0}' AND WorkPoint='{1}'";
sql = string.Format(sql, ContainerCode, WorkPoint);
if (!DBHelper.ExecuteNonQuery(sql, cmd))
{
throw new Exception(string.Format(language.GetNameByCode("WMSAPIInfo201"), ContainerCode, ContainerCode));
}
}
catch (Exception)
{
throw;
}
}
}
}

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

@ -258,7 +258,43 @@ namespace ICSSoft.WebAPI.Controllers
return result;
}
/// <summary>
/// 验证箱号是否可用
/// </summary>
/// <param name="JsonData"></param>
/// <returns></returns>
[HttpPost]
[Route("api/ContainerCheck/Get")]
public HttpResponseMessage ContainerCheck([FromBody] object JsonData)
{
log.Info("获取条码信息传入值" + JsonData);
try
{
if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
{
ICSContainerInfo model = new ICSContainerInfo();
model = JsonConvert.DeserializeObject<ICSContainerInfo>(JsonData.ToString());
//var resultStr = ICSSubmitService.BarCodeInformationGet(model);
//res.Success = true;
//res.Message = LanguageHelper.GetNameSingle("WMSAPI001");// "接口调用成功!";
//res.Data = resultStr;
res = ICSSubmitService.ContainerCheck(model);
}
}
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;
}
/// <summary>
/// 使用中
/// 获取条码信息
@ -2062,5 +2098,89 @@ namespace ICSSoft.WebAPI.Controllers
}
#endregion
#region 条码容器绑定
/// <summary>
/// 条码容器绑定
/// </summary>
/// <param name="JsonData"></param>
/// <returns></returns>
[HttpPost]
[Route("api/ContainerBind/Create")]
public HttpResponseMessage ContainerBindCreate([FromBody] object JsonData)
{
log.Info("合并传入值" + JsonData);
try
{
if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
{
List<ICSContainerBind> model = new List<ICSContainerBind>();
model = JsonConvert.DeserializeObject<List<ICSContainerBind>>(JsonData.ToString());
//WMSBarCoreService action = new WMSBarCoreService();
//var resultStr = action.LOTMergeCreate(model);
//res.Success = true;
//res.Message = LanguageHelper.GetNameSingle("WMSAPI001");// "接口调用成功!";
////res.Data = resultStr;
res = ICSSubmitService.ContainerBindCreate(model);
}
}
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 条码容器绑定
/// <summary>
/// 条码容器绑定
/// </summary>
/// <param name="JsonData"></param>
/// <returns></returns>
[HttpPost]
[Route("api/ContainerUnBind/Create")]
public HttpResponseMessage ContainerUnBindCreate([FromBody] object JsonData)
{
log.Info("合并传入值" + JsonData);
try
{
if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
{
List<ICSContainerBind> model = new List<ICSContainerBind>();
model = JsonConvert.DeserializeObject<List<ICSContainerBind>>(JsonData.ToString());
//WMSBarCoreService action = new WMSBarCoreService();
//var resultStr = action.LOTMergeCreate(model);
//res.Success = true;
//res.Message = LanguageHelper.GetNameSingle("WMSAPI001");// "接口调用成功!";
////res.Data = resultStr;
res = ICSSubmitService.ContainerBindCreate(model);
}
}
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
}
}
Loading…
Cancel
Save