From 17647a1a5f834acf5b1c1b4b9671f433424e227e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=86=92=E6=9E=97=E6=9D=B0?= <1205395967@qq.com>
Date: Wed, 8 Feb 2023 11:28:45 +0800
Subject: [PATCH] =?UTF-8?q?=E5=BB=BA=E8=AE=AE=E5=BA=93=E4=BD=8D=E3=80=81?=
=?UTF-8?q?=E4=B8=8A=E6=9E=B6=E4=BB=93=E5=BA=93=E7=AE=A1=E6=8E=A7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ICSControlModeService.cs | 48 ++++++
.../ICSSoft.DataProject/ICSSubmitService.cs | 152 ++++++++++++++++--
2 files changed, 191 insertions(+), 9 deletions(-)
diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSControlModeService.cs b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSControlModeService.cs
index d883d84..0992710 100644
--- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSControlModeService.cs
+++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSControlModeService.cs
@@ -70,6 +70,54 @@ namespace ICSSoft.DataProject
}
}
+
+ ///
+ /// 获取建议库位方式
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static ControlMode GetSuLocation()
+ {
+ using (SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString))
+ {
+ conn.Open();
+ SqlCommand cmd = new SqlCommand();
+ SqlTransaction sqlTran = conn.BeginTransaction();
+ cmd.Transaction = sqlTran;
+ cmd.Connection = conn;
+ try
+ {
+ string sql = @"SELECT Top 1 a.F_ItemCode as itemCode,a.F_ItemName as itemName,a.F_EnabledMark as enableMark
+ FROM [dbo].[Sys_SRM_ItemsDetail] a
+ LEFT JOIN [dbo].[Sys_SRM_Items] b ON a.F_ItemId=b.F_Id AND b.F_EnabledMark='1'
+ WHERE F_ItemId='c8767643-1429-48b1-ad31-c6b19a1dfcb9'AND a.F_EnabledMark='1' ORDER BY a.F_ItemCode";
+
+ DataTable table = DBHelper.SQlReturnData(sql, cmd);
+ string json = JsonConvert.SerializeObject(table);
+ List model = JsonConvert.DeserializeObject>(json);
+ cmd.Transaction.Commit();
+ return model[0];
+ }
+ 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();
+ }
+ }
+ }
+
///
/// 根据条码获取信息
///
diff --git a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs
index 648ff09..6381378 100644
--- a/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs
+++ b/ICSSoft.WMS.WebAPI/ICSSoft.DataProject/ICSSubmitService.cs
@@ -1009,6 +1009,7 @@ namespace ICSSoft.DataProject
string sql = "";
string Losql = "";
string sqlNew = "";
+ string LotType = "";
#region SLQ
if (TransType == TransTypeEnum.LocationSeatch.GetDescription())
{
@@ -1198,6 +1199,8 @@ namespace ICSSoft.DataProject
#endregion
bool isOut = false; //出库标记
string columns = string.Empty; //查询源头单据表的特殊列名
+ string columnsWHNAME = string.Empty;
+ string columnsWHCODE = string.Empty;
string tableName = string.Empty; //查询源头单据表名
string where = string.Empty; //排序
if (TransType == TransTypeEnum.PurchaseReceiveDoctNegative.GetDescription() //采购退货
@@ -1776,7 +1779,8 @@ namespace ICSSoft.DataProject
if (ScanType == "LOTNO")
{
- sql = @"
+
+ sql = @"
IF NOT EXISTS(SELECT a.ID FROM ICSInventoryLot a WHERE a.LotNo = '{2}' AND a.WorkPoint = '{3}')
BEGIN
@@ -1799,17 +1803,147 @@ namespace ICSSoft.DataProject
END
" + sql;
+
+
+ ControlMode mode = ICSControlModeService.GetSuLocation();
+
+ //获取条码类型
+ sql = @"IF EXISTS(SELECT Type FROM ICSInventoryLot WHERE LotNo='{0}' AND WorkPoint='{1}')
+ BEGIN
+ RAISERROR('" + language.GetNameByCode("WMSAPIInfo461") + @"',16,1);
+ RETURN
+ END
+ SELECT Type FROM ICSInventoryLot WHERE LotNo='{0}' AND WorkPoint='{1}'";
+ sql = string.Format(sql, JsonData.Code, JsonData.WorkPoint);
+ DataTable dt = DBHelper.SQlReturnData(sql, cmd);
+ LotType = dt.Rows[0]["Type"].ToString();
+
+
+ if (mode.itemCode.Equals("LocationRemind01"))
+ {
+ columnsWHNAME = @"
+ (SELECT Top 1 locat.LocationName from ICSWareHouseLotInfoLog log
+ LEFT JOIN ICSLocation locat on locat.LocationCode=log.ToLocationCode and log.WorkPoint=locat.WorkPoint where log.TransType='2' and a.InvCode=log.InvCode AND a.WorkPoint=log.WorkPoint
+ ORDER BY log.Mtime desc) AS LocationName,";
+
+
+
+ }
+ else if (mode.itemCode.Equals("LocationRemind02"))
+ {
+ columnsWHNAME = @"
+ STUFF(
+ (SELECT DISTINCT ',' + LocationName
+ from ICSLocation wh
+ LEFT JOIN ICSWareHouseLotInfo lotinfo on wh.LocationCode=lotinfo.LocationCode and wh.WorkPoint=lotinfo.WorkPoint
+ WHERE a.InvCode=lotinfo.InvCode AND a.WorkPoint=lotinfo.WorkPoint and lotinfo.Quantity>0
+ FOR xml path('')
+ ),1,1,''
+ ) AS LocationName,";
+
+
+ }
+ else
+ {
+ columnsWHNAME = @"
+ STUFF(
+ (SELECT DISTINCT ',' + LocationName
+ from ICSLocation wh
+ LEFT JOIN ICSWareHouseLotInfoLog lotinfo on wh.LocationCode=lotinfo.ToLocationCode and wh.WorkPoint=lotinfo.WorkPoint
+ WHERE a.InvCode=lotinfo.InvCode AND a.WorkPoint=lotinfo.WorkPoint and (lotinfo.TransType='2' OR lotinfo.TransType='3')
+ FOR xml path('')
+ ),1,1,''
+ ) AS LocationName,";
+
+ }
+
+ #region 根据条码类型找到单据仓库信息
+ if (LotType.Equals("1"))
+ {//生产退料
+ 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"))
+ {//委外退料
+ 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"))
+ {//工单
+ columnsWHCODE = @"(SELECT a.WHCode FROM ICSMO a WHERE a.MOCode=lotdd.TransCode AND a.Sequence=lotdd.TransSequence AND a.WorkPoint=lotdd.WorkPoint) AS WHCode";
+ }
+ else if (LotType.Equals("4"))
+ {//销售退货
+ columnsWHCODE = @"(SELECT a.WHCode FROM ICSSDN a WHERE a.SDNCode=lotdd.TransCode AND a.Sequence=lotdd.TransSequence AND a.WorkPoint=lotdd.WorkPoint) AS WHCode";
+ }
+ else if (LotType.Equals("5"))
+ {//其他入库
+ columnsWHCODE = @"(SELECT a.WHCode FROM ICSOtherIn a WHERE a.InCode=lotdd.TransCode AND a.Sequence=lotdd.TransSequence AND a.WorkPoint=lotdd.WorkPoint) AS WHCode";
+ }
+ else if (LotType.Equals("6"))
+ {//归还单
+ columnsWHCODE = @"(SELECT a.WHCode FROM ICSReturn a WHERE a.ReturnCode=lotdd.TransCode AND a.Sequence=lotdd.TransSequence AND a.WorkPoint=lotdd.WorkPoint) AS WHCode";
+ }
+ else if (LotType.Equals("7"))
+ {//采购到货单
+ columnsWHCODE = @"(SELECT a.WHCode FROM ICSDeliveryNotice a WHERE a.DNCode=lotdd.TransCode AND a.Sequence=lotdd.TransSequence AND a.WorkPoint=lotdd.WorkPoint a.DNType='1') AS WHCode";
+ }
+ else if (LotType.Equals("8"))
+ {//委外到货单
+ columnsWHCODE = @"(SELECT a.WHCode FROM ICSODeliveryNotice a WHERE a.ODNCode=lotdd.TransCode AND a.Sequence=lotdd.TransSequence AND a.WorkPoint=lotdd.WorkPoint and a.ODNType='1') AS WHCode";
+ }
+ else if (LotType.Equals("9"))
+ {//成品入库单
+ columnsWHCODE = @"(SELECT a.WHCode FROM ICSManufactureReceive a WHERE a.RCVCode=lotdd.TransCode AND a.Sequence=lotdd.TransSequence AND a.WorkPoint=lotdd.WorkPoint) AS WHCode";
+ }
+ else if (LotType.Equals("10"))
+ {//拒收单
+ columnsWHCODE = @"(SELECT a.WHCode FROM ICSDeliveryNotice a WHERE a.DNCode=lotdd.TransCode AND a.Sequence=lotdd.TransSequence AND a.WorkPoint=lotdd.WorkPoint AND a.DNType='3') AS WHCode";
+ }
+ else if (LotType.Equals("11"))
+ {//委外拒收单
+ columnsWHCODE = @"(SELECT a.WHCode FROM ICSODeliveryNotice a WHERE a.ODNCode=lotdd.TransCode AND a.Sequence=lotdd.TransSequence AND a.WorkPoint=lotdd.WorkPoint and a.ODNType='3') AS WHCode";
+ }
+ else if (LotType.Equals("12"))
+ {//领料申请退料
+ 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='2') AS WHCode";
+ }
+ else if (LotType.Equals("13"))
+ {//材料出库退料
+ 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='3') AS WHCode";
+ }
+ else if (LotType.Equals("14"))
+ {//委外领料申请退料
+ 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='2') AS WHCode";
+ }
+ else if (LotType.Equals("15"))
+ {//委外材料出库退料
+ 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='3') AS WHCode";
+ }
+ else if (LotType.Equals("16"))
+ {//返工工单
+ columnsWHCODE = @"(SELECT pick.WHCode FROM ICSMOPick pick LEFT JOIN ICSMO moo ON pick.MODetailID=moo.MODetailID AND pick.WorkPoint=moo.WorkPoint
+ WHERE moo.MOCode=lotdd.TransCode AND pick.Sequence=lotdd.TransSequence AND pick.WorkPoint=lotdd.WorkPoint) AS WHCode ";
+ }
+ #endregion
+
columns = @"ISNULL(ins.QualifiedQuantity+ins.WaiveQuantity, a.Quantity) AS Quantity,
- a.Quantity*(a.Amount/a.Quantity) AS Amount,
- '' AS WHCode,
- '' AS WHName,
- '' AS LocationCode,
- '' AS LocationName,
- ext.BatchCode AS BatchCode,";
+ a.Quantity*(a.Amount/a.Quantity) AS Amount,
+ '{0}','' AS WHName,
+ '' AS LocationCode,
+ '{1}'
+ ext.BatchCode AS BatchCode,";
tableName = @"ICSInventoryLot a
- INNER JOIN ICSExtension ext ON a.ExtensionID=ext.ID AND a.WorkPoint=ext.WorkPoint
- LEFT JOIN ICSInspection ins ON a.LotNo=ins.LotNo AND a.WorkPoint=ins.WorkPoint";
+ INNER JOIN ICSExtension ext ON a.ExtensionID=ext.ID AND a.WorkPoint=ext.WorkPoint
+ LEFT JOIN ICSInventoryLotDetail lotdd ON lotdd.LotNo=a.LotNo AND a.WorkPoint=lotdd.WorkPoint
+ LEFT JOIN ICSInspection ins ON a.LotNo=ins.LotNo AND a.WorkPoint=ins.WorkPoint";
+
+ columns = string.Format(columns, columnsWHCODE, columnsWHNAME);
+
+
}
else
{