From 37fe5d4a6ca31cc33771e9e1011a11d7d1a540f8 Mon Sep 17 00:00:00 2001 From: maqiao <625215135@qq.com> Date: Thu, 17 Apr 2025 10:55:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=8B=A8=E5=A4=8D=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E5=8F=96=E8=B0=83=E6=8B=A8=E5=8D=95=E7=8A=B6=E6=80=81status?= =?UTF-8?q?=E4=B8=BA2=E7=9A=84=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DM_Weight/Models/DrugInfo.cs | 8 ++++++-- DM_Weight/Port/PortUtil.cs | 13 +++++++++--- .../ViewModels/InvoiceInNewWindowViewModel.cs | 20 +++++++++++-------- .../ViewModels/ReturnDrugWindow2ViewModel.cs | 4 ++-- 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/DM_Weight/Models/DrugInfo.cs b/DM_Weight/Models/DrugInfo.cs index f77fadb..edaed39 100644 --- a/DM_Weight/Models/DrugInfo.cs +++ b/DM_Weight/Models/DrugInfo.cs @@ -93,7 +93,11 @@ namespace DM_Weight.Models [SugarColumn(IsIgnore = true)] public string drug_name_spec { get; set; } - //[SugarColumn(ColumnName = "drug_name_spec")] - //public string Name { get; set; } + + /// + /// 药品单位转换率 + /// + [SugarColumn(ColumnName = "convert_ratio")] + public int ConvertRatio { get; set; } } } diff --git a/DM_Weight/Port/PortUtil.cs b/DM_Weight/Port/PortUtil.cs index 348cd51..046c7ec 100644 --- a/DM_Weight/Port/PortUtil.cs +++ b/DM_Weight/Port/PortUtil.cs @@ -545,7 +545,7 @@ namespace DM_Weight.Port } else { - Thread.Sleep(100); + Thread.Sleep(200); // 灯在闪烁继续监听状态 GetBackDoorState(); } @@ -700,7 +700,7 @@ namespace DM_Weight.Port while (_length != length && end.Subtract(start).TotalMilliseconds < timeout) { _length = serialPort.BytesToRead; - if (_length == 0&& operation.Equals("开储物箱")) + if (_length == 0 && operation.Equals("开储物箱")) { _length = serialPort.BytesToRead; @@ -712,6 +712,13 @@ namespace DM_Weight.Port logger.Info($"再次发送OpenStorage:{Convert.ToHexString(bufferWrite)};{end}"); } } + if (_length == 0 && operation.Equals("查储物箱状态")) + { + Thread.Sleep(200); + byte[] bufferWrite = new byte[] { 0xaa, (byte)(_doorAddr), 0x02, 0x00, 0x00, 0x00, 0x00, 0xee }; + canBusSerial.Write(bufferWrite, 0, 8); + logger.Info($"再次发送查储物箱状态指令:{Convert.ToHexString(bufferWrite)};{end}"); + } end = DateTime.Now; } if (_length != length) @@ -817,7 +824,7 @@ namespace DM_Weight.Port byte[] buffer = new byte[] { 0xaa, (byte)(_doorAddr), 0x02, 0x00, 0x00, 0x00, 0x00, 0xee }; canBusSerial.Write(buffer, 0, 8); - return await GetBufferByPort(canBusSerial, 8); + return await GetBufferByPort(canBusSerial, 8, "查储物箱状态"); } // 打开电控门储物箱(有灯使能) diff --git a/DM_Weight/ViewModels/InvoiceInNewWindowViewModel.cs b/DM_Weight/ViewModels/InvoiceInNewWindowViewModel.cs index b9d63a6..689ce3d 100644 --- a/DM_Weight/ViewModels/InvoiceInNewWindowViewModel.cs +++ b/DM_Weight/ViewModels/InvoiceInNewWindowViewModel.cs @@ -291,7 +291,7 @@ namespace DM_Weight.ViewModels 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"; + string strSql = @"SELECT SUM(IF(di.small_unit=io.units,io.quantity,io.quantity*di.convert_ratio)) AS SumQuantity, COUNT(io.ID) AS CountNum,io.INVOICE_NO AS InvoiceNo,io.drug_id AS DrugId,io.QUANTITY AS quantity,io.drug_manu_no AS drugManuNo FROM IN_OUT_INVOICE io inner join drug_info di on io.drug_id=di.drug_id WHERE io.INVOICE_NO=@INVOICE_NO GROUP BY io.INVOICE_NO,io.DRUG_ID"; var invoices = SqlSugarHelper.Db.SqlQueryable(strSql) .AddParameters(new @@ -323,8 +323,8 @@ namespace DM_Weight.ViewModels } //ChannelStock stock = new ChannelStock(); //查询每种药有多少个批次 - var invoicesManuNo = SqlSugarHelper.Db.Queryable() - .Where(iManuNo => iManuNo.InvoiceNo == invoices[i].InvoiceNo && iManuNo.DrugId == invoices[i].DrugId && iManuNo.Status == 0 && iManuNo.Type == 2 && iManuNo.CancelFlag == 0).ToList(); + var invoicesManuNo = SqlSugarHelper.Db.Queryable().Includes(oi=>oi.DrugInfo).InnerJoin((oi,di)=>oi.DrugId==di.DrugId) + .Where(oi => oi.InvoiceNo == invoices[i].InvoiceNo && oi.DrugId == invoices[i].DrugId && oi.Status == 2 && oi.Type == 2 && oi.CancelFlag == 0).ToList(); for (int j = 0; j < invoicesManuNo.Count; j++) { //查询是否有库存 @@ -366,7 +366,7 @@ namespace DM_Weight.ViewModels .Select(it => { var ret = it.First(); - ret.AddQuantity = invoicesManuNo[j].quantity; + ret.AddQuantity = invoicesManuNo[j].Units== invoicesManuNo[j].DrugInfo.SmallUnit? invoicesManuNo[j].quantity: invoicesManuNo[j].quantity* invoicesManuNo[j].DrugInfo.ConvertRatio; return ret; }) .ToList(); @@ -525,6 +525,10 @@ namespace DM_Weight.ViewModels ChannelStock it = record[i]; + if(it.AddQuantity<=0) + { + continue; + } if (it.BoardType == 6 && it.PosNo == 0) { _portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity); @@ -623,7 +627,7 @@ namespace DM_Weight.ViewModels { // 更新屏显库存 //List singleChannels = record.FindAll(it => it.BoardType != 1); - List singleChannels = record.Where(it => it.BoardType != 1) + List singleChannels = record.Where(it => it.BoardType != 1&&it.AddQuantity>0) .GroupBy(it => new { it.DrawerNo, it.ColNo }) .Select(it => { @@ -744,8 +748,8 @@ namespace DM_Weight.ViewModels var sb = new StringBuilder(); //sb.Append("select i.invoice_no as InvoiceNo, i.invoice_date as InvoiceDate, COUNT(i.id) as `Count`, SUM(i.quantity) as quantity, p1.pharmacy_name as PharmacyName1, p2.pharmacy_name as PharmacyName2 from in_out_invoice i"); sb.Append(" SELECT count(1) as Count, i.InvoiceNo, i.InvoiceDate, sum(i.quantity) as quantity, p1.pharmacy_name as PharmacyName1, p2.pharmacy_name PharmacyName2 from "); - sb.Append(" (SELECT drug_id,in_pharmacy_id,out_pharmacy_id, invoice_no as InvoiceNo, DATE_FORMAT(Invoice_Date,'%Y-%m-%d') as InvoiceDate, SUM(quantity) as quantity "); - sb.Append(" FROM in_out_invoice where status=@Status and type=@type and cancel_flag=@CancelFlag GROUP BY invoice_no,drug_id) i "); + sb.Append(" (SELECT io.drug_id,io.in_pharmacy_id,io.out_pharmacy_id, io.invoice_no as InvoiceNo, DATE_FORMAT(io.Invoice_Date,'%Y-%m-%d') as InvoiceDate, SUM(IF(di.small_unit=io.units,io.quantity,io.quantity*di.convert_ratio)) as quantity "); + sb.Append(" FROM in_out_invoice io inner join drug_info di on io.drug_id=di.drug_id where io.status=@Status and io.type=@type and io.cancel_flag=@CancelFlag GROUP BY io.invoice_no,io.drug_id) i "); sb.Append(" inner join ( select c.drug_id as drug_id from channel_list c where c.machine_id = '" + (ConfigurationManager.AppSettings["machineId"] ?? "DM1") + "' group by c.drug_id ) di on di.drug_id = i.drug_id"); sb.Append(" left join pharmacy_info p1 on p1.pharmacy = i.in_pharmacy_id"); sb.Append(" left join pharmacy_info p2 on p2.pharmacy = i.out_pharmacy_id where 1=1"); @@ -769,7 +773,7 @@ namespace DM_Weight.ViewModels Invoices = SqlSugarHelper.Db.SqlQueryable(sb.ToString()) .AddParameters(new { - Status = 0, + Status = 2, type = 2, CancelFlag = 0, CreateTime = OrderDate, diff --git a/DM_Weight/ViewModels/ReturnDrugWindow2ViewModel.cs b/DM_Weight/ViewModels/ReturnDrugWindow2ViewModel.cs index 4fc9c05..b8f6fa6 100644 --- a/DM_Weight/ViewModels/ReturnDrugWindow2ViewModel.cs +++ b/DM_Weight/ViewModels/ReturnDrugWindow2ViewModel.cs @@ -182,7 +182,7 @@ namespace DM_Weight.ViewModels public async void OpenOrderDialog() { //if (SelectedOrder != null && SelectedOrder.DmStatus == 0 && SelectedOrder.CancelFlag == 0 && SelectedOrder.HisDispFlag == 0) - if (SelectedOrder != null && SelectedOrder.DmStatus == 1 && SelectedOrder.CancelFlag == 1 && SelectedOrder.HisDispFlag == 1) + if (SelectedOrder != null && SelectedOrder.DmStatus == 1 && SelectedOrder.CancelFlag == 1) { // 此处延时1毫秒,等待页面渲染 await Task.Delay(TimeSpan.FromMilliseconds(1)); @@ -227,7 +227,7 @@ namespace DM_Weight.ViewModels .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PatientId"), oi => oi.PatientId == SearchValue) .WhereIF(!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]), oi => oi.Pharmacy == ConfigurationManager.AppSettings["storage"]) .Where(oi => oi.DmStatus == 1) - .Where(oi => oi.HisDispFlag == 1) + //.Where(oi => oi.HisDispFlag == 1) .Where(oi => oi.CancelFlag == 1) .GroupBy(oi => oi.OrderDate) .Select(oi => oi)