使用报表添加手术间查询条件

调拨入库合并同批次效期药品
This commit is contained in:
maqiao 2025-05-22 11:33:49 +08:00
parent a9f937508a
commit d783b9c631
9 changed files with 91 additions and 38 deletions

View File

@ -3,7 +3,7 @@
<connectionStrings> <connectionStrings>
<!-- 数据库连接字符串 --> <!-- 数据库连接字符串 -->
<!--<add name="database" connectionString="server=127.0.0.1;database=wpf_dm_program;userid=root;password=qq1223" />--> <!--<add name="database" connectionString="server=127.0.0.1;database=wpf_dm_program;userid=root;password=qq1223" />-->
<add name="database" connectionString="server=192.168.50.252;port=3306;database=xiangtan_mazuike_xx;userid=root;password=qq1223" /> <add name="database" connectionString="server=127.0.0.1;port=3306;database=xiangtan_mazuike_xx;userid=root;password=root" />
</connectionStrings> </connectionStrings>
<!--<runtime> <!--<runtime>
--><!--配置之后Appdomain.CurrentDomain.UnhandledException 事件的 IsTerminating 就变成了 false 啦!也就是说,程序并不会因为这次的异常而崩溃退出。--><!-- --><!--配置之后Appdomain.CurrentDomain.UnhandledException 事件的 IsTerminating 就变成了 false 啦!也就是说,程序并不会因为这次的异常而崩溃退出。--><!--
@ -37,7 +37,7 @@
<!-- 按处方还药或者按取药记录还药 1:处方ReturnDrugWindow22药品ReturnDrugWindow--> <!-- 按处方还药或者按取药记录还药 1:处方ReturnDrugWindow22药品ReturnDrugWindow-->
<add key="returnDrugMode" value="1" /> <add key="returnDrugMode" value="1" />
<!-- 自动退出时间单位秒为0时不自动退出 --> <!-- 自动退出时间单位秒为0时不自动退出 -->
<add key="autoExit" value="0"/> <add key="autoExit" value="5"/>
<!-- 无操作退出录像时间单位秒为0时不退出录像 --> <!-- 无操作退出录像时间单位秒为0时不退出录像 -->
<add key="stopRecord" value="180"/> <add key="stopRecord" value="180"/>

View File

@ -1363,7 +1363,8 @@ namespace DM_Weight.Port
} }
logger.Info($"开始写标签指令:{Convert.ToHexString(buffer)}"); logger.Info($"开始写标签指令:{Convert.ToHexString(buffer)}");
canBusSerial.Write(buffer, 0, 8); canBusSerial.Write(buffer, 0, 8);
logger.Info($"写标签指令:{Convert.ToHexString(buffer)}"); byte[] retBuffer= await GetBufferByPort(canBusSerial, 8);
logger.Info($"收到写标签回复:{Convert.ToHexString(retBuffer)}");
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -370,7 +370,7 @@ namespace DM_Weight.Report
/// 使用登记册 /// 使用登记册
/// 能按麻醉师名字、时间结合起来查找 /// 能按麻醉师名字、时间结合起来查找
/// </summary> /// </summary>
public static void UserAccount(DateTime? startDate, DateTime? endDate, string Name) public static void UserAccount(DateTime? startDate, DateTime? endDate, string Name, string box)
{ {
// 定义Grid++Report报表主对象 // 定义Grid++Report报表主对象
@ -385,7 +385,7 @@ namespace DM_Weight.Report
SELECT re.create_time as OptDate, di.drug_name as DrugName,di.Drug_spec as DrugSpec,dt.Set_manu_no as ManuNo,re.patient_name as PName, SELECT re.create_time as OptDate, di.drug_name as DrugName,di.Drug_spec as DrugSpec,dt.Set_manu_no as ManuNo,re.patient_name as PName,
CONCAT(use_dose,dose_unit) as UDose,CONCAT(residual_dose,dose_unit) as ReDose,if(residual_dose>0,'是','否') as Disposal, CONCAT(use_dose,dose_unit) as UDose,CONCAT(residual_dose,dose_unit) as ReDose,if(residual_dose>0,'是','否') as Disposal,
re.anaesthetist_name as AName,re.operator_name as OName,re.supervisor_name as CName,of.operator as EmpRecive,'' as EmpMedicRecive,re.disposal_time as DisposalTime,of.win_no as WinNo re.anaesthetist_name as AName,re.operator_name as OName,re.supervisor_name as CName,of.operator as EmpRecive,'' as EmpMedicRecive,re.disposal_time as DisposalTime,of.win_no as WinNo
from surgical_residual re inner join drug_info di on re.drug_id=di.drug_id left join hkc_order_finish of on re.order_no=of.order_no left join order_detail_sm dt on re.order_no=dt.order_no from surgical_residual re inner join drug_info di on re.drug_id=di.drug_id left join hkc_order_finish of on re.order_no=of.order_no and of.state=2 left join order_detail_sm dt on re.order_no=dt.order_no
where re.create_time > '{startDate}' and re.create_time< '{endDate}'"; where re.create_time > '{startDate}' and re.create_time< '{endDate}'";
@ -394,6 +394,10 @@ namespace DM_Weight.Report
{ {
SQL += " AND re.anaesthetist_name='" + Name + "' "; SQL += " AND re.anaesthetist_name='" + Name + "' ";
} }
if (!string.IsNullOrEmpty(box))
{
SQL += " AND of.win_no='" + box + "' ";
}
SQL += " ORDER BY re.create_time"; SQL += " ORDER BY re.create_time";
Report.DetailGrid.Recordset.ConnectionString = gridConnectionString; Report.DetailGrid.Recordset.ConnectionString = gridConnectionString;
Report.DetailGrid.Recordset.QuerySQL = SQL; Report.DetailGrid.Recordset.QuerySQL = SQL;

View File

@ -316,7 +316,7 @@ namespace DM_Weight.ViewModels
} }
} }
enumerable = ChannelStocks.Where(cs=>cs.TakeQuantity>0).GroupBy(cs => cs.DrawerNo, cs => cs); enumerable = ChannelStocks.Where(cs => cs.TakeQuantity > 0).GroupBy(cs => cs.DrawerNo, cs => cs);
enumerator = enumerable.GetEnumerator(); enumerator = enumerable.GetEnumerator();
enumerator.MoveNext(); enumerator.MoveNext();
Status = 1; Status = 1;
@ -367,7 +367,7 @@ namespace DM_Weight.ViewModels
// 完成按钮 // 完成按钮
public DelegateCommand TakeFinish public DelegateCommand TakeFinish
{ {
get => new DelegateCommand(() => get => new DelegateCommand(async () =>
{ {
if (!_isFinishClick) if (!_isFinishClick)
{ {
@ -398,8 +398,8 @@ namespace DM_Weight.ViewModels
} }
} }
} }
string InvoiceId = "AddJiaoJie_" + CurrentTimeMillis(); string InvoiceId = "AddJiaoJie_" + CurrentTimeMillis();
var f = SqlSugarHelper.Db.UseTran(() => var f = SqlSugarHelper.Db.UseTran(() =>
@ -487,7 +487,7 @@ namespace DM_Weight.ViewModels
//newStock.Chnguid = jiaoStock.Chnguid; //newStock.Chnguid = jiaoStock.Chnguid;
//newStock.BaseQuantity = jiaoStock.BaseQuantity; //newStock.BaseQuantity = jiaoStock.BaseQuantity;
newStock.ManuNo = Jiaojie_ChannelStocks[i].ManuNo; newStock.ManuNo = Jiaojie_ChannelStocks[i].ManuNo;
newStock.EffDate=Jiaojie_ChannelStocks[i].EffDate; newStock.EffDate = Jiaojie_ChannelStocks[i].EffDate;
newStock.DrawerNo = Jiaojie_ChannelStocks[i].DrawerNo; newStock.DrawerNo = Jiaojie_ChannelStocks[i].DrawerNo;
newStock.DrugId = Jiaojie_ChannelStocks[i].DrugId; newStock.DrugId = Jiaojie_ChannelStocks[i].DrugId;
newStock.AddToJJNum = Jiaojie_ChannelStocks[i].NeedNum; newStock.AddToJJNum = Jiaojie_ChannelStocks[i].NeedNum;
@ -533,7 +533,7 @@ namespace DM_Weight.ViewModels
newStock.DrawerNo = Jiaojie_ChannelStocks[i].DrawerNo; newStock.DrawerNo = Jiaojie_ChannelStocks[i].DrawerNo;
newStock.DrugId = Jiaojie_ChannelStocks[i].DrugId; newStock.DrugId = Jiaojie_ChannelStocks[i].DrugId;
newStock.ManuNo = csStock.ManuNo; newStock.ManuNo = csStock.ManuNo;
newStock.EffDate=csStock.EffDate; newStock.EffDate = csStock.EffDate;
newStock.AddToJJNum = Jiaojie_ChannelStocks[i].NeedNum; newStock.AddToJJNum = Jiaojie_ChannelStocks[i].NeedNum;
newStock.NeedNum = 0; newStock.NeedNum = 0;
newStock.Id = Guid.NewGuid().ToString(); newStock.Id = Guid.NewGuid().ToString();
@ -627,25 +627,25 @@ namespace DM_Weight.ViewModels
{ {
//Task.Factory.StartNew(() => //Task.Factory.StartNew(() =>
//{ //{
// 更新屏显库存 // 更新屏显库存
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType == 5); //List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType == 5);
//if (singleChannels.Count > 0) //if (singleChannels.Count > 0)
//{ //{
// singleChannels.ForEach(it => // singleChannels.ForEach(it =>
// { // {
// _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity); // _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
// Thread.Sleep(150); // Thread.Sleep(150);
// }); // });
//} //}
List<ChannelStock> singleChannelsBoxSmart = record.FindAll(it => it.BoardType == 35); List<ChannelStock> singleChannelsBoxSmart = record.FindAll(it => it.BoardType == 35);
if ((singleChannelsBoxSmart.Count > 0 ? singleChannelsBoxSmart[0].BoardType : 1) == 35) if ((singleChannelsBoxSmart.Count > 0 ? singleChannelsBoxSmart[0].BoardType : 1) == 35)
{
for (int i = 0; i < singleChannelsBoxSmart.Count; i++)
{ {
singleChannelsBoxSmart.ForEach(async it => ChannelStock it = singleChannelsBoxSmart[i];
{ await _portUtil.WriteQuantityMethod((it.Quantity - it.CheckQuantity), it.DrawerNo, it.ColNo);
await _portUtil.WriteQuantityMethod((it.Quantity - it.CheckQuantity), it.DrawerNo, it.ColNo);
await Task.Delay(20);
});
} }
}
//}); //});
AlertMsg alertMsg = new AlertMsg AlertMsg alertMsg = new AlertMsg
{ {

View File

@ -267,6 +267,7 @@ namespace DM_Weight.ViewModels
Task.Delay(200); Task.Delay(200);
_portUtil.WriteChannelInfoMethod(6, item.ManuNo, item.DrawerNo, item.ColNo); _portUtil.WriteChannelInfoMethod(6, item.ManuNo, item.DrawerNo, item.ColNo);
Task.Delay(200); Task.Delay(200);
Task.Delay(200);
_portUtil.ShowContentMethod(item.DrawerNo, item.ColNo); _portUtil.ShowContentMethod(item.DrawerNo, item.ColNo);
Task.Delay(200); Task.Delay(200);
} }

View File

@ -564,6 +564,10 @@ namespace DM_Weight.ViewModels
stop(); stop();
System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() => System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
{ {
if (DialogHost.IsDialogOpen("RootDialog"))
{
DialogHost.Close("RootDialog");
}
_regionManager.RequestNavigate("ContentRegion", "EmptyWindow"); _regionManager.RequestNavigate("ContentRegion", "EmptyWindow");
_regionManager.RequestNavigate("MainRegion", "LoginWindow"); _regionManager.RequestNavigate("MainRegion", "LoginWindow");
})); }));

View File

@ -8,6 +8,7 @@ using Prism.Events;
using Prism.Mvvm; using Prism.Mvvm;
using Prism.Regions; using Prism.Regions;
using Prism.Services.Dialogs; using Prism.Services.Dialogs;
using SqlSugar;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
@ -198,10 +199,32 @@ namespace DM_Weight.ViewModels
if (SelectedInvoice != null) if (SelectedInvoice != null)
{ {
var invoices = SqlSugarHelper.Db.Queryable<InOutInvoice>() var invoices = SqlSugarHelper.Db.Queryable<InOutInvoice>()
.Includes<DrugInfo>(i => i.DrugInfo) .LeftJoin(
.LeftJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (i, t) => i.DrugId == t.DrugId) SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(i => i.InvoiceNo == SelectedInvoice.InvoiceNo&&i.Status==1&&i.Type==2&&i.CancelFlag==0) .Where(cs => cs.DrawerType == 1)
.ToList(); .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
.GroupBy(cs => cs.DrugId), (i, t) => i.DrugId == t.DrugId
)
.Includes<DrugInfo>(i => i.DrugInfo)
.Where(i => i.InvoiceNo == SelectedInvoice.InvoiceNo && i.Status == 1 && i.Type == 2 && i.CancelFlag == 0)
.MergeTable().GroupBy(i => new { i.DrugId, i.DrugManuNo })
.Select(i => new InOutInvoice
{
DrugId = i.DrugId,
DrugEffDate = i.DrugEffDate,
DrugManuNo = i.DrugManuNo,
quantity = SqlFunc.AggregateSum(i.quantity),
DrugInfo=i.DrugInfo
})
.ToList();
//.Select((i, t) => new InOutInvoice
// {
// DrugId = i.DrugId,
// DrugEffDate = i.DrugEffDate,
// DrugManuNo = i.DrugManuNo,
// quantity = i.quantity,
// DrugInfo = i.DrugInfo
// }).ToList();
foreach (var invoice in invoices) foreach (var invoice in invoices)
{ {
List<ChannelStock> q = SqlSugarHelper.Db.Queryable<ChannelStock>() List<ChannelStock> q = SqlSugarHelper.Db.Queryable<ChannelStock>()
@ -219,10 +242,10 @@ namespace DM_Weight.ViewModels
if (q.Count <= 0) if (q.Count <= 0)
{ {
//strMsg += $"药品{invoice.DrugInfo.DrugName}未绑定;"; //strMsg += $"药品{invoice.DrugInfo.DrugName}未绑定;";
ChannelStock cs= new ChannelStock(); ChannelStock cs = new ChannelStock();
cs.ColNo = -1; cs.ColNo = -1;
cs.EffDate = invoice.DrugEffDate; cs.EffDate = invoice.DrugEffDate;
cs.ManuNo=invoice.DrugManuNo; cs.ManuNo = invoice.DrugManuNo;
cs.DrugInfo = invoice.DrugInfo; cs.DrugInfo = invoice.DrugInfo;
cs.Quantity = 0; cs.Quantity = 0;
q.Add(cs); q.Add(cs);
@ -284,7 +307,7 @@ namespace DM_Weight.ViewModels
if (flag) if (flag)
{ {
AddChannels = ChannelStocks.FindAll(it => it.AddQuantity != 0 && it.Location != "未绑定"); AddChannels = ChannelStocks.FindAll(it => it.AddQuantity != 0 && it.Location != "未绑定");
if (AddChannels == null|| AddChannels.Count<=0) if (AddChannels == null || AddChannels.Count <= 0)
{ {
AlertMsg alertMsg = new AlertMsg AlertMsg alertMsg = new AlertMsg
{ {

View File

@ -74,6 +74,21 @@ namespace DM_Weight.ViewModels
set { SetProperty(ref _User, value); } set { SetProperty(ref _User, value); }
} }
private static List<string> boxDefine =
new List<string> { "1号手术间", "2号手术间", "3号手术间", "4号手术间", "5号手术间", "6号手术间", "7号手术间", "8号手术间", "9号手术间", "10号手术间", "11号手术间", "12号手术间", "13号手术间", "14号手术间", "15号手术间", "16号手术间", "17号手术间", "18号手术间" };
private List<string> _Boxs = boxDefine;
public List<string> Boxs
{
get => _Boxs;
set { SetProperty(ref _Boxs, value); }
}
private string _Box;
public string Box
{
get => _Box;
set { SetProperty(ref _Box, value); }
}
private static readonly DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); private static readonly DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public long CurrentTimeMillis() public long CurrentTimeMillis()
{ {
@ -95,7 +110,6 @@ namespace DM_Weight.ViewModels
public void OnNavigatedFrom(NavigationContext navigationContext) public void OnNavigatedFrom(NavigationContext navigationContext)
{ {
} }
/// <summary> /// <summary>
/// 导出账册 /// 导出账册
/// </summary> /// </summary>
@ -103,7 +117,7 @@ namespace DM_Weight.ViewModels
{ {
get => new DelegateCommand(() => get => new DelegateCommand(() =>
{ {
GridReportUtil.UserAccount(StartDate, EndDate, User == null ? "" : User.Nickname); GridReportUtil.UserAccount(StartDate, EndDate, User == null ? "" : User.Nickname, Box);
}); });
} }

View File

@ -55,7 +55,13 @@
ItemsSource="{Binding UserInfos}" ItemsSource="{Binding UserInfos}"
SelectedItem="{Binding User}" SelectedItem="{Binding User}"
DisplayMemberPath="Nickname" IsEditable="True" IsTextSearchEnabled="False"/> DisplayMemberPath="Nickname" IsEditable="True" IsTextSearchEnabled="False"/>
<ComboBox Width="130"
Margin="16 0 6 0"
Grid.Column="2"
materialDesign:HintAssist.Hint="手术间"
ItemsSource="{Binding Boxs}"
SelectedItem="{Binding Box}"
IsEditable="True" IsTextSearchEnabled="False"/>
</StackPanel> </StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right"> <StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
<Button <Button