diff --git a/DM_Weight/App.config b/DM_Weight/App.config
index f36dcbe..8d6dfc3 100644
--- a/DM_Weight/App.config
+++ b/DM_Weight/App.config
@@ -20,7 +20,7 @@
-
+
diff --git a/DM_Weight/ViewModels/CheckStockNew2WindowViewModel.cs b/DM_Weight/ViewModels/CheckStockNew2WindowViewModel.cs
index d8731d1..8fc1864 100644
--- a/DM_Weight/ViewModels/CheckStockNew2WindowViewModel.cs
+++ b/DM_Weight/ViewModels/CheckStockNew2WindowViewModel.cs
@@ -277,8 +277,14 @@ namespace DM_Weight.ViewModels
List channelStocks = grouping.ToList();
channelStocks.ForEach(it => it.process = 1);
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
+ List singleChannels = new List();
+ for (int i = 0; i < channelStocks.Count; i++)
+ {
+ ChannelStock copy = TransExpV2.Trans(channelStocks[i]);
+ singleChannels.Add(copy);
+ }
- List singleChannels = channelStocks.GroupBy(it => new
+ singleChannels = singleChannels.GroupBy(it => new
{
it.DrawerNo,
it.ColNo
diff --git a/DM_Weight/ViewModels/CheckStockNewWindowViewModel.cs b/DM_Weight/ViewModels/CheckStockNewWindowViewModel.cs
index 78023a6..b6c7f6f 100644
--- a/DM_Weight/ViewModels/CheckStockNewWindowViewModel.cs
+++ b/DM_Weight/ViewModels/CheckStockNewWindowViewModel.cs
@@ -320,8 +320,14 @@ namespace DM_Weight.ViewModels
List channelStocks = grouping.ToList();
channelStocks.ForEach(it => it.process = 1);
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
+ List singleChannels = new List();
+ for (int i = 0; i < channelStocks.Count; i++)
+ {
+ ChannelStock copy = TransExpV2.Trans(channelStocks[i]);
+ singleChannels.Add(copy);
+ }
- List singleChannels = channelStocks.GroupBy(it => new
+ singleChannels = singleChannels.GroupBy(it => new
{
it.DrawerNo,
it.ColNo
diff --git a/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs b/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs
index 6fe2b95..8ee3df5 100644
--- a/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs
+++ b/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs
@@ -202,15 +202,15 @@ namespace DM_Weight.ViewModels
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
{
- List ChannelLst = channelStocks.Where(it => it.BoardType != 1)
- .GroupBy(it => it.ColNo)
- .Select(it =>
- {
- var ret = it.First();
- ret.Quantity = it.Sum(itx => itx.Quantity);
- ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
- return ret;
- }).ToList();
+ //List ChannelLst = channelStocks.Where(it => it.BoardType != 1)
+ // .GroupBy(it => it.ColNo)
+ // .Select(it =>
+ // {
+ // var ret = it.First();
+ // ret.Quantity = it.Sum(itx => itx.Quantity);
+ // ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
+ // return ret;
+ // }).ToList();
// 发送加药数量
singleChannels.ForEach(it =>
diff --git a/DM_Weight/ViewModels/InvoiceInNewWindowViewModel.cs b/DM_Weight/ViewModels/InvoiceInNewWindowViewModel.cs
index 0a687df..6166e74 100644
--- a/DM_Weight/ViewModels/InvoiceInNewWindowViewModel.cs
+++ b/DM_Weight/ViewModels/InvoiceInNewWindowViewModel.cs
@@ -288,7 +288,7 @@ namespace DM_Weight.ViewModels
List iChannelStock = new List();
if (SelectedInvoice != null)
{
- //先查询有几种药
+ //先查询入库单中有几种药
string strSql = @"SELECT sum(Quantity) AS SumQuantity, COUNT(ID) AS CountNum,INVOICE_NO AS InvoiceNo,drug_id AS DrugId,QUANTITY AS quantity,drug_manu_no AS drugManuNo FROM IN_OUT_INVOICE WHERE INVOICE_NO=@INVOICE_NO GROUP BY INVOICE_NO,DRUG_ID";
var invoices = SqlSugarHelper.Db.SqlQueryable(strSql)
@@ -317,18 +317,18 @@ namespace DM_Weight.ViewModels
//_eventAggregator.GetEvent().Publish(alertMsg);
continue;
}
- ChannelStock stock = new ChannelStock();
+ //ChannelStock stock = new ChannelStock();
//查询每种药有多少个批次
var invoicesManuNo = SqlSugarHelper.Db.Queryable()
- .Where(iManuNo => iManuNo.InvoiceNo == invoices[i].InvoiceNo && iManuNo.DrugId == invoices[i].DrugId).ToList();
+ .Where(iManuNo => iManuNo.InvoiceNo == invoices[i].InvoiceNo && iManuNo.DrugId == invoices[i].DrugId && iManuNo.Status == 0 && iManuNo.Type != 2 && iManuNo.CancelFlag == 0).ToList();
for (int j = 0; j < invoicesManuNo.Count; j++)
{
//查询是否有库存
List stockList = SqlSugarHelper.Db.Queryable()
.Where(cs => cs.ManuNo == invoicesManuNo[j].DrugManuNo && cs.DrugId == invoicesManuNo[j].DrugId && cs.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM1")).ToList();
- stock = stockList.Count > 0 ? stockList[0] : new ChannelStock();
+ //stock = stockList.Count > 0 ? stockList[0] : new ChannelStock();
List manuNoList = SqlSugarHelper.Db.Queryable().Where(dm => dm.ManuNo == invoicesManuNo[j].DrugManuNo && dm.DrugId == invoicesManuNo[j].DrugId).ToList();
- if (stock == null || stock.Id is null)
+ if (stockList == null || stockList.Count<=0)
{
if (manuNoList == null || manuNoList.Count <= 0)
{
@@ -342,6 +342,7 @@ namespace DM_Weight.ViewModels
continue;
}
//没有库存写入一条数据
+ ChannelStock stock = new ChannelStock();
stock.MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
stock.DrawerNo = channelLst.DrawerNo;
stock.BoardType = channelLst.BoardType;
@@ -351,13 +352,21 @@ namespace DM_Weight.ViewModels
stock.ManuNo = invoicesManuNo[j].DrugManuNo;
stock.EffDate = manuNoList[0].EffDate;
stock.Chnguid = channelLst.Id;
+ stockList.Add(stock);
}
- stock.AddQuantity = invoicesManuNo[j].quantity;
+ //stock.AddQuantity = invoicesManuNo[j].quantity;
+ stockList.GroupBy(it =>it.ManuNo)
+ .Select(it =>
+ {
+ var ret = it.First();
+ ret.AddQuantity = invoicesManuNo[j].quantity;
+ return ret;
+ }).ToList();
if (channelLst.channelStocks == null)
{
channelLst.channelStocks = new List();
}
- channelLst.channelStocks.Add(stock);
+ channelLst.channelStocks.AddRange(stockList);
}
InOutInvoice copy = TransExpV2.Trans(invoices[i]);
@@ -390,6 +399,27 @@ namespace DM_Weight.ViewModels
{
if (Status == 0)
{
+ if (AddChannels == null || AddChannels.Count <= 0)
+ {
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "请输入入库数量",
+ Type = MsgType.ERROR,
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ return;
+ }
+ int totalNum = AddChannels.Sum(add => add.AddQuantity);
+ if (totalNum != SelectedInvoice.Quantity)
+ {
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "各批次添加数量要与调拨单药品总数一致!",
+ Type = MsgType.ERROR,
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ return;
+ }
enumerator.MoveNext();
Status = 1;
OpenOneByOne();
@@ -402,7 +432,13 @@ namespace DM_Weight.ViewModels
List channelStocks = grouping.ToList();
channelStocks.ForEach(it => it.process = 1);
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
- List singleChannels = channelStocks.GroupBy(it => new
+ List singleChannels = new List();
+ for (int i = 0; i < channelStocks.Count; i++)
+ {
+ ChannelStock copy= TransExpV2.Trans(channelStocks[i]);
+ singleChannels.Add(copy);
+ }
+ singleChannels = singleChannels.GroupBy(it => new
{
it.DrawerNo,
it.ColNo
@@ -422,15 +458,15 @@ namespace DM_Weight.ViewModels
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
{
- List ChannelLst = channelStocks.Where(it => it.BoardType != 1)
- .GroupBy(it => it.ColNo)
- .Select(it =>
- {
- var ret = it.First();
- ret.Quantity = it.Sum(itx => itx.Quantity);
- ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
- return ret;
- }).ToList();
+ //List ChannelLst = channelStocks.Where(it => it.BoardType != 1)
+ // .GroupBy(it => it.ColNo)
+ // .Select(it =>
+ // {
+ // var ret = it.First();
+ // ret.Quantity = it.Sum(itx => itx.Quantity);
+ // ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
+ // return ret;
+ // }).ToList();
// 发送加药数量
singleChannels.ForEach(it =>
{
diff --git a/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs b/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs
index 6472456..caf5381 100644
--- a/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs
+++ b/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs
@@ -266,7 +266,13 @@ namespace DM_Weight.ViewModels
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
- List singleChannels = channelStocks
+ List singleChannels = new List();
+ for (int i = 0; i < channelStocks.Count; i++)
+ {
+ ChannelStock copy=TransExpV2.Trans(channelStocks[i]);
+ singleChannels.Add(copy);
+ }
+ singleChannels= singleChannels
.GroupBy(it => new { it.DrawerNo, it.ColNo })
.Select(it =>
{
diff --git a/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs b/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs
index 212041b..b988b3d 100644
--- a/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs
+++ b/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs
@@ -272,7 +272,13 @@ namespace DM_Weight.ViewModels
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
//List singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
- List singleChannels = channelStocks
+ List singleChannels = new List();
+ for (int i = 0; i < channelStocks.Count; i++)
+ {
+ ChannelStock copy = TransExpV2.Trans(channelStocks[i]);
+ singleChannels.Add(copy);
+ }
+ singleChannels=singleChannels
.GroupBy(it => new { it.DrawerNo, it.ColNo })
.Select(it =>
{
diff --git a/DM_Weight/ViewModels/SelfAddDialogViewModel.cs b/DM_Weight/ViewModels/SelfAddDialogViewModel.cs
index a8c6354..aca3ea5 100644
--- a/DM_Weight/ViewModels/SelfAddDialogViewModel.cs
+++ b/DM_Weight/ViewModels/SelfAddDialogViewModel.cs
@@ -193,7 +193,13 @@ namespace DM_Weight.ViewModels
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
- List singleChannels = channelStocks
+ List singleChannels = new List();
+ for (int i = 0; i < channelStocks.Count; i++)
+ {
+ ChannelStock copy = TransExpV2.Trans(channelStocks[i]);
+ singleChannels.Add(copy);
+ }
+ singleChannels= singleChannels
.GroupBy(it => new {
it.DrawerNo, it.ColNo
})
diff --git a/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs b/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs
index 427d19e..29bfe4b 100644
--- a/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs
+++ b/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs
@@ -185,7 +185,13 @@ namespace DM_Weight.ViewModels
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
- List singleChannels = channelStocks
+ List singleChannels = new List();
+ for (int i = 0; i < channelStocks.Count; i++)
+ {
+ ChannelStock copy = TransExpV2.Trans(channelStocks[i]);
+ singleChannels.Add(copy);
+ }
+ singleChannels= singleChannels
.GroupBy(it => new { it.DrawerNo, it.ColNo })
.Select(it =>
{
diff --git a/DM_Weight/Views/InvoiceInNewWindow.xaml b/DM_Weight/Views/InvoiceInNewWindow.xaml
index e8c5bec..c442f5c 100644
--- a/DM_Weight/Views/InvoiceInNewWindow.xaml
+++ b/DM_Weight/Views/InvoiceInNewWindow.xaml
@@ -272,12 +272,12 @@
Binding="{Binding Quantity}"
Header="库存"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
-
-
+
@@ -294,7 +294,7 @@
- -->
+