Compare commits

...

24 Commits

Author SHA1 Message Date
马巧 e1629fbdc7 报表查询条件添加时间选择 2025-07-28 15:16:43 +08:00
马巧 f7391b5506 修改报表 2025-07-24 10:35:53 +08:00
马巧 9915812808 修改录屏方式 2025-07-21 15:24:38 +08:00
马巧 3e34ffe912 添加录屏功能,添加可多次加药,毒麻柜无药则显示无库存或未绑定,对应的药品先不补 2025-07-10 11:52:24 +08:00
maqiao 02c626d829 所有出、入库页面均保存账册 2025-06-19 14:25:21 +08:00
maqiao d783b9c631 使用报表添加手术间查询条件
调拨入库合并同批次效期药品
2025-05-22 11:33:49 +08:00
maqiao a9f937508a 交接柜补药完成更新标签数量修改 2025-05-14 16:05:34 +08:00
maqiao 1436ad66b4 药品信息页面中基数表查询添加machine_id条件 2025-04-30 16:39:28 +08:00
maqiao 7f3dd5cc24 channel_stock写交接柜数据同时写效期字段 2025-04-28 14:54:50 +08:00
maqiao 5a27970ffc 交换柜补药写标签指令添加await 2025-04-25 15:37:28 +08:00
maqiao c971e9d1bc 交接柜补药时列出所有要补药的批次让补药人选择对应批次 2025-04-11 13:45:20 +08:00
maqiao 88b97e213f 写标签间隔时间由150改为200 2025-03-25 16:21:39 +08:00
maqiao 36b573c12b 指纹登录添加连不上数据库跳转紧急开锁页面 2025-03-05 09:49:12 +08:00
maqiao 3254fcd621 紧急开锁页面添加退出 2025-03-04 15:38:58 +08:00
maqiao 54489ac267 急诊紧急开锁添加退出按钮 2025-03-04 13:13:44 +08:00
maqiao 735785fecb 连接数据库异常添加紧急开锁功能 2025-03-03 16:07:21 +08:00
maqiao 53eb6d07cc 交接柜补药添加日志 2025-01-18 14:53:21 +08:00
maqiao c75f4811eb 交接柜补药添加日志 2025-01-18 14:52:21 +08:00
maqiao 714a037b71 跳转登录页面时先跳转EmptyWindow避免不执行OnNavigatedFrom方法 2025-01-15 18:57:17 +08:00
maqiao 58a6035add 使用报表判断用户参数是否为空 2025-01-06 13:11:57 +08:00
maqiao b58309a583 交接柜加药有该批次则更新;库存列表显示交接柜库存 2025-01-06 09:20:31 +08:00
maqiao 593b55d53f 使用登记册修改;交接柜补药处方与药品1对1 2025-01-03 17:45:51 +08:00
maqiao 00637067d3 开抽屉状态禁止切换菜单;交接柜加药更新标签数量不对修改 2024-12-24 10:19:30 +08:00
maqiao f4b859520d 添加使用登记账册报表;
修改绑定写标签及写数量相关等待时间及开启新线程写数据
调拨入库数量根据系数转换成支将未绑定药品显示出来保存时不改未绑定药品status
2024-12-19 19:55:35 +08:00
64 changed files with 4898 additions and 1130 deletions

View File

@ -3,7 +3,7 @@
<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;port=3306;database=xiangtan_mazuike_xx;userid=root;password=root" />
<add name="database" connectionString="server=127.0.0.1;port=3306;database=xtTest;userid=root;password=qq1223" />
</connectionStrings>
<!--<runtime>
--><!--配置之后Appdomain.CurrentDomain.UnhandledException 事件的 IsTerminating 就变成了 false 啦!也就是说,程序并不会因为这次的异常而崩溃退出。--><!--
@ -29,7 +29,7 @@
<!--2023/7/13 药房代码 有则写无则空 -->
<add key="storage" value="159" />
<add key="storage" value="552" />
<!-- 登录模式 1单人登录2双人登录 -->
<add key="loginMode" value="1" />
<!-- 登录顺序,指定先登录的人的名称有效值只有在登录模式等于2时才会生效 发药人【operator】审核人【reviewer】 -->
@ -42,7 +42,7 @@
<!-- 无操作退出录像时间单位秒为0时不退出录像 -->
<add key="stopRecord" value="180"/>
<add key="gridConnectionString" value="MYSQL; Database=xiangtan_mazuike; Password=root; Port=3306; Server=127.0.0.1; User=root;"/>
<add key="gridConnectionString" value="MYSQL; Database=xiangtanTest; Password=root; Port=3306; Server=192.168.50.84; User=root;"/>
<!-- 查询处方是orderNo还是orderGroupNo -->
<add key="OrderNoName" value="orderNo" />
<!-- 后门耗材板地址 没有则填写0-->
@ -54,11 +54,11 @@
<!-- 抽屉串口使用的协议232或者485 -->
<add key="DrawerProtocol" value="485" />
<!-- 抽屉串口的串口号 -->
<add key="DrawerPortPath" value="COM3" />
<add key="DrawerPortPath" value="COM2" />
<!-- can总线串口的串口号 -->
<add key="CanBusPortPath" value="COM9" />
<add key="CanBusPortPath" value="COM5" />
<!-- 条码枪串口的串口号 -->
<add key="ScanCodePortPath" value="COM8" />
<add key="ScanCodePortPath" value="COM7" />
<!--是否有冰箱抽屉0无1有一个2两个-->
@ -99,7 +99,7 @@
<!-- 指纹机号码 -->
<add key="machineNumber" value="1"/>
<!-- 指纹机ip -->
<add key="fingerIp" value="192.168.50.201"/>
<add key="fingerIp" value="192.168.50.59"/>
<!-- 多处方取药 0:不启用 1启用-->
<add key="MultiOrder" value="1"/>

View File

@ -32,6 +32,7 @@ namespace DM_Weight
/// </summary>
public partial class App : PrismApplication
{
public static bool DbConnectionFail { get; set; } = false;
private readonly ILog logger = LogManager.GetLogger(typeof(App));
public App()
{
@ -58,6 +59,11 @@ namespace DM_Weight
{
logger.Error($"发生错误:{e.Exception.Message}");
e.Handled = true;
if (e.Exception.Message.Contains("连接数据库过程中发生错误"))
{
DbConnectionFail = true;
Container.Resolve<MainWindow>();
}
}
void OnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
@ -226,6 +232,8 @@ namespace DM_Weight
containerRegistry.RegisterForNavigation<ChangeShiftsDialog, ChangeShiftsDialogViewModel>();
containerRegistry.RegisterForNavigation<AccountWindow,AccountWindowViewModel>();
//使用登记册
containerRegistry.RegisterForNavigation<UseAccountWindow, UseAccountWindowViewModel>();
#endregion
#region
@ -254,6 +262,16 @@ namespace DM_Weight
containerRegistry.RegisterForNavigation<ShowMessageDialog, ShowMessageDialogViewModel>();
containerRegistry.RegisterForNavigation<EmptyWindow, EmptyWindowViewModel>();
//紧急开锁页面
containerRegistry.RegisterForNavigation<EmergencyWindow, EmergencyWindowViewModel>();
//交接柜加药页面
containerRegistry.RegisterForNavigation<AddToJiaoJieNewWindow, AddToJiaoJieNewWindowViewModel>();
containerRegistry.RegisterDialog<DatetimeDialog>();
containerRegistry.RegisterForNavigation<DatetimeDialog, DatetimeDialogViewModel>();
}
}
}

View File

@ -13,27 +13,30 @@ namespace DM_Weight.Converter
//是否给交接柜补药已补药的则不可勾选未补药的可勾选以进行补药0未补1已补
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
int status = int.Parse(value.ToString());
if (parameter.ToString() == "EnableState")
if (value != null)
{
if (status == 0)
int status = int.Parse(value.ToString());
if (parameter.ToString() == "EnableState")
{
return true;
if (status == 0)
{
return true;
}
else
{
return false;
}
}
else
if (parameter.ToString() == "TextState")
{
return false;
}
}
if (parameter.ToString() == "TextState")
{
if (status == 0)
{
return "未取药";
}
else
{
return "已取药待入库";
if (status == 0)
{
return "未取药";
}
else
{
return "已取药待入库";
}
}
}
return "";

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
namespace DM_Weight.Converter
{
internal class TakeQuantityEnabelConverter : IValueConverter
{
//-1未绑定
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (int)value == -1 ? Visibility.Collapsed : Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return Binding.DoNothing;
}
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
namespace DM_Weight.Converter
{
internal class TakeQuantityVisiable: IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (int)(value) <0 ? Visibility.Collapsed : Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@ -71,6 +71,7 @@
<PackageReference Include="MaterialDesignThemes" Version="4.8.0" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
<PackageReference Include="Prism.Unity" Version="8.1.97" />
<PackageReference Include="SharpPromise" Version="1.7.0" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.67" />
<PackageReference Include="SuperSimpleTcp" Version="3.0.10" />
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
@ -97,6 +98,9 @@
<None Update="ReportTemp\account_book_temp.grf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="ReportTemp\account_use_temp.grf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="ReportTemp\changeShifts_temp.grf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>

View File

@ -83,7 +83,7 @@ namespace DM_Weight.Models
public int ManuStock { get; set; }
/// <summary>
/// 总结存
/// 湘谭的报表此字段用于记录空瓶数 -- 总结存
/// </summary>
[SugarColumn(ColumnName = "total_stock")]
public int TotalStock { get; set; }

View File

@ -9,7 +9,7 @@ namespace DM_Weight.Models
///
///</summary>
[SugarTable("channel_stock")]
public class ChannelStock : BindableBase
public class ChannelStock : BindableBase,ICloneable
{
/// <summary>
///
@ -112,7 +112,7 @@ namespace DM_Weight.Models
[SugarColumn(IsIgnore = true)]
public string Location
{
get => ColNo == 0 ? DrawerNo + "号交接柜" : DrawerNo + "-" + ColNo;
get => ColNo == 0 ? DrawerNo + "号交接柜" :ColNo==-1?"未绑定/无库存": ColNo == -2 ? "库存不足" : DrawerNo + "-" + ColNo;
}
private int _addQuantity = 0;
@ -211,5 +211,10 @@ namespace DM_Weight.Models
//需要加药数量
[SugarColumn(ColumnName = "col_no2")]
public int NeedNum { get; set; }
public object Clone()
{
return this.MemberwiseClone();
}
}
}

View File

@ -15,7 +15,7 @@ namespace DM_Weight.Models
public class DrugBase:BindableBase
{
private int _baseId = 0;
[SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
[SugarColumn(ColumnName = "baseid", IsPrimaryKey = true)]
public int BaseId { get=> _baseId; set { SetProperty(ref _baseId, value); } }
private string _drugId = "0";
[SugarColumn(ColumnName = "drugid")]
@ -24,7 +24,7 @@ namespace DM_Weight.Models
[SugarColumn(ColumnName = "machine_id")]
public string MachineId { get => _machineId; set { SetProperty(ref _machineId, value); } }
private int _baseQuantity = 0;
[SugarColumn(ColumnName = "base_quantity")]
[SugarColumn(ColumnName = "basequantity")]
public int BaseQuantity { get=>_baseQuantity; set{ SetProperty(ref _baseQuantity, value); } }
}

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using Prism.Mvvm;
using SqlSugar;
@ -60,7 +61,7 @@ namespace DM_Weight.Models
/// <summary>
/// <20><>װ<EFBFBD><D7B0>λ
///</summary>
[SugarColumn(ColumnName = "pack_unit")]
[SugarColumn(ColumnName = "Big_unit")]
public string PackUnit { get; set; }
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@ -72,6 +73,9 @@ namespace DM_Weight.Models
///</summary>
[SugarColumn(ColumnName = "max_stock")]
public int? MaxStock { get; set; }
///</summary>
[SugarColumn(ColumnName = "convert_ratio")]
public int ConvertRatio { get; set; }
//[SugarColumn(IsIgnore=true)]
[Navigate(NavigateType.OneToMany, nameof(ChannelStock.DrugId), nameof(DrugId))]//BookA表中的studenId
public List<ChannelStock> channelStocks { get; set; }
@ -83,14 +87,16 @@ namespace DM_Weight.Models
public int? StockQuantity { get; set; }
private DrugBase _base;
[Navigate(NavigateType.OneToOne, nameof(DrugBase.DrugId), nameof(DrugId))]
[Navigate(NavigateType.OneToOne, nameof(DrugBase.DrugId), nameof(DrugId), whereSql: "machine_id='DM3'")]
public DrugBase drugBase
{
get=> _base;
set { SetProperty(ref _base, value); }
}
//交接柜补药弹窗对应的需补药数
[SugarColumn(IsIgnore = true)]
public int? NeedQuantity { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.Models
{
public class StringVSIntModels
{
public string StringId { get; set; }
public int IntQuantity { get; set; }
}
}

View File

@ -29,6 +29,7 @@ using System.Runtime.InteropServices;
using DM_Weight.Common;
using System.Net;
using System.Text.RegularExpressions;
using System.Threading;
namespace DM_Weight.Port
{
@ -86,6 +87,9 @@ namespace DM_Weight.Port
// 是否正在操作中
public bool Operate { get; set; }
// 操作完抽屉是否点完成按钮
public bool OperateFinish { get; set; } = true;
//冰箱是否正在操作中
public bool FridgeOperate { get; set; }
@ -196,7 +200,7 @@ namespace DM_Weight.Port
if (state)
{
//抽屉全部关闭
OperateFinish = false;
string _WindowName = WindowName;
// 重新初始化数据
ResetData();
@ -550,6 +554,7 @@ namespace DM_Weight.Port
string _WindowName = WindowName;
// 重新初始化数据
ResetData();
OperateFinish = false;
// 返回消息 抽屉已经关闭
_eventAggregator.GetEvent<PortUtilEvent>().Publish(new util.DeviceMsg()
{
@ -655,6 +660,7 @@ namespace DM_Weight.Port
statue = 2;
string _WindowName = WindowName;
OperateFinish = false;
// 重新初始化数据
ResetData();
_eventAggregator.GetEvent<PortUtilEvent>().Publish(new util.DeviceMsg()
@ -1138,20 +1144,23 @@ namespace DM_Weight.Port
}
byte[] buffer = new byte[] { 0xaa, (byte)channel, 1, (byte)type, 0, 0, 0, 0xee };
canBusSerial.Write(buffer, 0, 8);
await Task.Delay(20);
logger.Info($"Type:{type};content:{content};库位:{drawerNo}-{colNo};开始写指令:{Convert.ToHexString(buffer)}");
Thread.Sleep(20);
buffer[4] = 1;
for (int i = 0; i < contentBuf.Length; i += 2)
{
buffer[5] = contentBuf[i];
buffer[6] = contentBuf[i + 1];
canBusSerial.Write(buffer, 0, 8);
await Task.Delay(20);
logger.Info($"Type:{type};content:{content};库位:{drawerNo}-{colNo};写指令:{Convert.ToHexString(buffer)}");
Thread.Sleep(20);
}
buffer[4] = 2;
buffer[5] = 0;
buffer[6] = 0;
canBusSerial.Write(buffer, 0, 8);
await Task.Delay(20);
logger.Info($"Type:{type};content:{content};库位:{drawerNo}-{colNo};结束写指令:{Convert.ToHexString(buffer)}");
Thread.Sleep(20);
}
catch (Exception ex)
{
@ -1226,12 +1235,14 @@ namespace DM_Weight.Port
{
try
{
var colNo2 = colNo % 3==0?3: colNo % 3;
canBusSerial.DiscardInBuffer();
int channel = (drawerNo * 10 + colNo);
int channel = (drawerNo * 10 + colNo2);
byte[] buffer = new byte[] { 0xaa, (byte)channel, 0x21, 0, 0, 0, 0, 0xee };
buffer[5] = (byte)(quantity >> 8);
buffer[6] = (byte)(quantity & 0xff);
canBusSerial.Write(buffer, 0, 8);
logger.Info($"{drawerNo}-{colNo}写数量:{Convert.ToHexString(buffer)}");
}
catch (Exception ex)
{
@ -1257,15 +1268,15 @@ namespace DM_Weight.Port
//var channel = drawerNo * 10 + Math.Ceiling(deColNo / 3);
int[] iNum = new int[] { 3, 2, 1 };
var colNo2 = colNo % 3 > 0 ? (colNo % 3) - 1 : 2;
var bColNo = Convert.ToInt32((iNum[colNo2]+10).ToString(),16);
var bColNo = Convert.ToInt32((iNum[colNo2] + 10).ToString(), 16);
//var index = Convert.ToInt32(((colNo % 3 == 0 ? 3 : colNo % 3)+10).ToString(),16);
int channel = Convert.ToInt32((drawerNo * 10 + Math.Ceiling((decimal)colNo / 3)).ToString(), 16);
byte[] buffer = new byte[] { 0xaa, (byte)channel, 0x09, (byte)bColNo, 0,0,0, 0xee };
byte[] buffer = new byte[] { 0xaa, (byte)channel, 0x09, (byte)bColNo, 0, 0, 0, 0xee };
canBusSerial.Write(buffer, 0, 8);
logger.Info($"清屏指令:{Convert.ToHexString(buffer)}");
}
//刷新内容
public async Task ShowContentMethod(int drawerNo, int colNo)
public async void ShowContentMethod(int drawerNo, int colNo)
{
int channel = Convert.ToInt32((drawerNo * 10 + Math.Ceiling((decimal)colNo / 3)).ToString(), 16);
byte[] buffer = new byte[] { 0xaa, (byte)channel, 0x0c, 0x00, 0x00, 0x00, 0x00, 0xee };
@ -1273,30 +1284,32 @@ namespace DM_Weight.Port
canBusSerial.Write(buffer, 0, 8);
}
// 基础数据写入方法
public async Task WriteChannelInfoMethod(int type, string content, int drawerNo, int colNo)
public async void WriteChannelInfoMethod(int type, string content, int drawerNo, int colNo)
{
try
{
canBusSerial.DiscardInBuffer();
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
byte[] contentBuf = Encoding.GetEncoding("gb2312").GetBytes(trim(content));
if (content.Length > 10)
{
content = content.Substring(0, 10);
}
byte[] contentBuf = Encoding.GetEncoding("gb2312").GetBytes(trim(content));
int channel = Convert.ToInt32((drawerNo * 10 + Math.Ceiling((decimal)colNo / 3)).ToString(), 16);
int[] iNum = new int[] { 3, 2, 1 };
var colNo2 = colNo % 3 > 0 ? (colNo % 3) - 1 : 2;
var bColNo = iNum[colNo2]+160;
var bColNo = iNum[colNo2] + 160;
//var index = (colNo % 3 == 0 ? 3 : colNo % 3)+160;
if (contentBuf.Length % 2 != 0)
{
Array.Resize(ref contentBuf, contentBuf.Length + 1);
}
byte[] buffer = new byte[] { 0xaa, (byte)channel, (byte)bColNo, (byte)type, 0, 0, 0, 0xee };
canBusSerial.Write(buffer, 0, 8);
logger.Info($"开始写标签指令:{Convert.ToHexString(buffer)}");
await Task.Delay(30);
Thread.Sleep(20);
buffer[4] = 1;
for (int i = 0; i < contentBuf.Length; i += 2)
{
@ -1304,14 +1317,14 @@ namespace DM_Weight.Port
buffer[6] = contentBuf[i + 1];
canBusSerial.Write(buffer, 0, 8);
logger.Info($"写标签指令:{Convert.ToHexString(buffer)}");
await Task.Delay(30);
Thread.Sleep(50);
}
buffer[4] = 2;
buffer[5] = 0;
buffer[6] = 0;
canBusSerial.Write(buffer, 0, 8);
logger.Info($"结束写标签指令:{Convert.ToHexString(buffer)}");
await Task.Delay(30);
Thread.Sleep(20);
}
catch (Exception ex)
@ -1326,6 +1339,50 @@ namespace DM_Weight.Port
}
}
public async Task WriteQuantityMethod(int quantity, int drawerNo, int colNo)
{
try
{
logger.Info($"写数量:{drawerNo}-{colNo}{quantity}");
canBusSerial.DiscardInBuffer();
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
string strQuantity = quantity.ToString("X");
if (strQuantity.Length % 2 != 0)
{
strQuantity = "0" + strQuantity;
}
int channel = Convert.ToInt32((drawerNo * 10 + Math.Ceiling((decimal)colNo / 3)).ToString(), 16);
int[] iNum = new int[] { 3, 2, 1 };
var colNo2 = colNo % 3 > 0 ? (colNo % 3) - 1 : 2;
var bColNo = iNum[colNo2] + 160;
byte[] buffer = new byte[] { 0xaa, (byte)channel, (byte)bColNo, 0xf2, 01, 0, 0, 0xee };
if (strQuantity.Length >= 4)
{
buffer[5] = Convert.ToByte(strQuantity.Substring(0, 2), 16);
buffer[6] = Convert.ToByte(strQuantity.Substring(2, 2), 16);
}
else
{
buffer[6] = Convert.ToByte(strQuantity.Substring(0, 2), 16);
}
logger.Info($"开始写标签指令:{Convert.ToHexString(buffer)}");
canBusSerial.Write(buffer, 0, 8);
byte[] retBuffer= await GetBufferByPort(canBusSerial, 8);
logger.Info($"收到写标签回复:{Convert.ToHexString(retBuffer)}");
}
catch (Exception ex)
{
_eventAggregator.GetEvent<PortUtilEvent>().Publish(new util.DeviceMsg()
{
EventType = util.EventType.OPENERROR,
WindowName = WindowName,
Message = $"写标签数量异常{ex.Message}"
});
logger.Info($"写标签数量异常ex:{ex.Message}");
}
}
#endregion
#region

View File

@ -365,5 +365,44 @@ namespace DM_Weight.Report
Report.PrintPreview(true);
}
/// <summary>
/// 使用登记册
/// 能按麻醉师名字、时间结合起来查找
/// </summary>
public static void UserAccount(DateTime? startDate, DateTime? endDate, string Name, string box)
{
// 定义Grid++Report报表主对象
GridppReport Report = new GridppReport();
DateTime? p_startDate = startDate ?? Convert.ToDateTime("2010-1-1");
DateTime? p_endDate = endDate ?? DateTime.Now.AddDays(1);
string p_machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
string SQL = string.Empty;
Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "account_use_temp.grf");
SQL = $@"
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,
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,SUBSTRING_INDEX(of.win_no, '号', 1) as WinNo,re.card_no as cardNo
from surgical_residual re inner join drug_info di on re.drug_id=di.drug_id inner 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}'";
if (!string.IsNullOrEmpty(Name))
{
SQL += " AND re.anaesthetist_name='" + Name + "' ";
}
if (!string.IsNullOrEmpty(box))
{
SQL += " AND of.win_no='" + box + "' ";
}
SQL += " ORDER BY re.create_time";
Report.DetailGrid.Recordset.ConnectionString = gridConnectionString;
Report.DetailGrid.Recordset.QuerySQL = SQL;
Report.PrintPreview(true);
}
}
}

View File

@ -0,0 +1,712 @@
{
"Version":"6.8.1.1",
"Font":{
"Name":"宋体",
"Size":105000,
"Weight":400,
"Charset":134
},
"Printer":{
"Oriention":"Landscape",
"TopMargin":0.3175,
"RightMargin":1,
"BottomMargin":0.3969
},
"DetailGrid":{
"CenterView":true,
"Recordset":{
"QuerySQL":"SELECT \r\n dmr.`drawer_no` AS drawerNo,\r\n dmr.`col_no` AS colNo,\r\n dmr.`type` AS `type`,\r\n CONCAT(dmr.`quantity`,IF(dmr.`type`=32,\"(空瓶)\",\"\")) AS quantity,\r\n dmr.`manu_no` AS manuNo,\r\n dmr.`eff_date` AS effDate,\r\n dmr.`operation_time` AS operationTime,\r\n di.`drug_name` AS drugName,\r\n di.`drug_spec` AS drugSpec,\r\n di.`pack_unit` AS packUnit,\r\n di.`manufactory` AS manuFactory,\r\n di.`max_stock` AS baseQuantity,\r\n dmr.`drug_id` AS drugId,\r\n ul.`user_name` AS nickname\r\nFROM\r\n dm_machine_record dmr\r\nLEFT JOIN drug_info di ON di.`drug_id` = dmr.`drug_id`\r\nLEFT JOIN user_list ul ON ul.`id` = dmr.`Operator`\r\nWHERE dmr.`type` in (31, 32)\r\n AND dmr.`machine_id` = :machine_id\r\n AND dmr.`operation_time` > :startDate\r\n AND dmr.`operation_time` < :endDate",
"Field":[
{
"Name":"药品名称",
"DBFieldName":"DrugName"
},
{
"Name":"日期",
"DBFieldName":"YearMD"
},
{
"Name":"批号",
"DBFieldName":"ManuNo"
},
{
"Name":"效期",
"Format":"yyyy/MM/dd",
"DBFieldName":"effDate"
},
{
"Name":"领入",
"DBFieldName":"InQuantity"
},
{
"Name":"规格",
"DBFieldName":"DrugSpec"
},
{
"Name":"大单位",
"DBFieldName":"BigUnit"
},
{
"Name":"小单位",
"DBFieldName":"SmallUnit"
},
{
"Name":"基数",
"DBFieldName":"BaseQuantity"
},
{
"Name":"手术间",
"DBFieldName":"shoushuJian"
},
{
"Name":"患者姓名",
"DBFieldName":"PName"
},
{
"Name":"性别",
"DBFieldName":"Sex"
},
{
"Name":"年龄",
"DBFieldName":"Age"
},
{
"Name":"住院号",
"DBFieldName":"ZYH"
},
{
"Name":"科室",
"DBFieldName":"KS"
},
{
"Name":"使用剂量",
"DBFieldName":"UseDose"
},
{
"Name":"剩余剂量",
"DBFieldName":"ResidualDose"
},
{
"Name":"余液处理时间",
"DBFieldName":"DiposalTime"
},
{
"Name":"医师",
"DBFieldName":"YS"
},
{
"Name":"复核人",
"DBFieldName":"CheckUser"
},
{
"Name":"实物",
"DBFieldName":"Stock"
},
{
"Name":"空瓶",
"DBFieldName":"empty"
},
{
"Name":"发药人",
"DBFieldName":"SendUser"
},
{
"Name":"领药人",
"DBFieldName":"InUser"
},
{
"Name":"领药复核人",
"DBFieldName":"InCheckUser"
},
{
"Name":"空瓶回收人",
"DBFieldName":"emptyUser"
},
{
"Name":"批次库存",
"DBFieldName":"CurrentStock"
}
]
},
"Column":[
{
"Name":"日期",
"Width":2.77813
},
{
"Name":"批次",
"Width":2.19604
},
{
"Name":"有效期",
"Width":2.77813
},
{
"Name":"领入",
"Width":0.820208
},
{
"Name":"手术间",
"Width":0.79375
},
{
"Name":"患者姓名",
"Width":1.61396
},
{
"Name":"性别",
"Width":1.00542
},
{
"Name":"年龄",
"Width":0.79375
},
{
"Name":"住院号",
"Width":1.5875
},
{
"Name":"科室",
"Width":2.2225
},
{
"Name":"使用剂量",
"Width":1.82563
},
{
"Name":"剩余剂量",
"Width":1.5875
},
{
"Name":"余液处理时间",
"Width":2.59292
},
{
"Name":"医师",
"Width":1.5875
},
{
"Name":"复核人",
"Width":1.79917
},
{
"Name":"空瓶回收人",
"Width":1.5875
},
{
"Name":"Column7",
"Width":1.61396
},
{
"Name":"实物",
"Width":1.40229
},
{
"Name":"空瓶",
"Width":1.19063
},
{
"Name":"发药人",
"Width":1.79917
},
{
"Name":"Column2",
"Width":1.79917
},
{
"Name":"Column8",
"Width":1.79917
}
],
"ColumnContent":{
"Height":2.01083,
"ColumnContentCell":[
{
"Column":"日期",
"TextAlign":"MiddleCenter",
"DataField":"日期"
},
{
"Column":"批次",
"TextAlign":"MiddleCenter",
"DataField":"批号"
},
{
"Column":"有效期",
"TextAlign":"MiddleCenter",
"DataField":"效期"
},
{
"Column":"领入",
"TextAlign":"MiddleCenter",
"DataField":"领入"
},
{
"Column":"手术间",
"TextAlign":"MiddleCenter",
"DataField":"手术间"
},
{
"Column":"患者姓名",
"TextAlign":"MiddleCenter",
"DataField":"患者姓名"
},
{
"Column":"性别",
"TextAlign":"MiddleCenter",
"DataField":"性别"
},
{
"Column":"年龄",
"DataField":"年龄"
},
{
"Column":"住院号",
"DataField":"住院号"
},
{
"Column":"科室",
"DataField":"科室"
},
{
"Column":"使用剂量",
"DataField":"使用剂量"
},
{
"Column":"剩余剂量",
"DataField":"剩余剂量"
},
{
"Column":"余液处理时间",
"DataField":"余液处理时间"
},
{
"Column":"医师",
"DataField":"医师"
},
{
"Column":"复核人",
"DataField":"复核人"
},
{
"Column":"空瓶回收人",
"DataField":"空瓶回收人"
},
{
"Column":"Column7"
},
{
"Column":"实物",
"DataField":"实物"
},
{
"Column":"空瓶",
"DataField":"空瓶"
},
{
"Column":"发药人",
"DataField":"发药人"
},
{
"Column":"Column2",
"DataField":"领药复核人"
},
{
"Column":"Column8",
"DataField":"批次库存"
}
]
},
"ColumnTitle":{
"Height":2.59292,
"RepeatStyle":"OnPage",
"ColumnTitleCell":[
{
"GroupTitle":false,
"Column":"日期",
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"日期"
},
{
"GroupTitle":false,
"Column":"批次",
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"批号"
},
{
"GroupTitle":false,
"Column":"有效期",
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"有效期"
},
{
"GroupTitle":false,
"Column":"领入",
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"领\r\n入"
},
{
"GroupTitle":true,
"Name":"Column1",
"ColumnTitleCell":[
{
"GroupTitle":false,
"Column":"手术间",
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"手\r\n术\r\n间"
},
{
"GroupTitle":false,
"Column":"患者姓名",
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"患者\r\n姓名"
},
{
"GroupTitle":false,
"Column":"性别",
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"性\r\n别"
},
{
"GroupTitle":false,
"Column":"年龄",
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"年\r\n龄"
},
{
"GroupTitle":false,
"Column":"住院号",
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"住院号"
},
{
"GroupTitle":false,
"Column":"科室",
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"科室"
},
{
"GroupTitle":false,
"Column":"使用剂量",
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"使用\r\n剂量"
},
{
"GroupTitle":false,
"Column":"剩余剂量",
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"剩余\r\n剂量"
},
{
"GroupTitle":false,
"Column":"余液处理时间",
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"余液\r\n处理\r\n时间"
},
{
"GroupTitle":false,
"Column":"医师",
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"医师"
},
{
"GroupTitle":false,
"Column":"复核人",
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"复核人"
}
],
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"使用"
},
{
"GroupTitle":true,
"Name":"Column6",
"ColumnTitleCell":[
{
"GroupTitle":false,
"Column":"空瓶回收人",
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"回收人"
},
{
"GroupTitle":false,
"Column":"Column7",
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"药房\r\n回收人"
}
],
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"空瓶回收"
},
{
"GroupTitle":true,
"Name":"Column3",
"ColumnTitleCell":[
{
"GroupTitle":false,
"Column":"实物",
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"实物"
},
{
"GroupTitle":false,
"Column":"空瓶",
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"空瓶"
}
],
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"结存数"
},
{
"GroupTitle":false,
"Column":"发药人",
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"发药人"
},
{
"GroupTitle":true,
"Name":"Column5",
"ColumnTitleCell":[
{
"GroupTitle":false,
"Column":"Column2",
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"复核人"
}
],
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"领药人"
},
{
"GroupTitle":false,
"Column":"Column8",
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"批次库存"
}
]
}
},
"PageHeader":{
"Height":0
},
"Parameter":[
{
"Name":"startDate",
"DataType":"DateTime",
"Format":"yyyy-MM-dd hh:mm:ss",
"Value":"2023/1/1"
},
{
"Name":"endDate",
"DataType":"DateTime",
"Format":"yyyy-MM-dd hh:mm:ss",
"Value":"2023/4/28 23:59:59"
},
{
"Name":"machine_id",
"Value":"DM1"
}
],
"ReportHeader":[
{
"Name":"ReportHeader1",
"Height":1.5875,
"Control":[
{
"Type":"MemoBox",
"Name":"MemoBox2",
"Dock":"Fill",
"Font":{
"Name":"宋体",
"Size":217500,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"湘谭县人民医院麻醉药品、精神药品专用账册、使用登记册(手术室)"
}
],
"RepeatOnPage":true
},
{
"Name":"ReportHeader2",
"Height":1.00542,
"Control":[
{
"Type":"MemoBox",
"Name":"MemoBox3",
"Dock":"Fill",
"Border":{
"Styles":"[DrawLeft|DrawTop|DrawRight]"
},
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"Text":"药品名称:[#药品名称#] 规格:[#规格#] 单位:[#大单位#] 基数:[#基数#]"
}
],
"RepeatOnPage":true
}
]
}

View File

@ -0,0 +1,452 @@
{
"Version":"6.8.1.1",
"Font":{
"Name":"宋体",
"Size":105000,
"Weight":400,
"Charset":134
},
"Printer":{
"Oriention":"Landscape",
"LeftMargin":1,
"TopMargin":1.42875,
"RightMargin":1,
"BottomMargin":1.8
},
"DetailGrid":{
"CenterView":true,
"AppendBlankRow":true,
"Recordset":{
"Field":[
{
"Name":"日期",
"Type":"DateTime",
"Format":"M/d",
"DBFieldName":"OptDate"
},
{
"Name":"品名",
"DBFieldName":"DrugName"
},
{
"Name":"规格",
"DBFieldName":"DrugSpec"
},
{
"Name":"批号",
"DBFieldName":"ManuNo"
},
{
"Name":"床号",
"DBFieldName":"BedNum"
},
{
"Name":"病人姓名",
"DBFieldName":"PName"
},
{
"Name":"使用剂量",
"DBFieldName":"UDose"
},
{
"Name":"剩余剂量",
"DBFieldName":"ReDose"
},
{
"Name":"处理",
"DBFieldName":"Disposal"
},
{
"Name":"医师",
"DBFieldName":"AName"
},
{
"Name":"执行者",
"DBFieldName":"OName"
},
{
"Name":"核对者",
"DBFieldName":"CName"
},
{
"Name":"空安瓿批号",
"DBFieldName":"EmpManuNO"
},
{
"Name":"空安瓿回收者",
"DBFieldName":"EmpRecive"
},
{
"Name":"空安瓿药房接收者",
"DBFieldName":"EmpMedicRecive"
}
]
},
"Column":[
{
"Name":"日期",
"Width":1.77271
},
{
"Name":"品名",
"Width":3.41313
},
{
"Name":"规格",
"Width":2.35479
},
{
"Name":"批号",
"Width":2.24896
},
{
"Name":"床号",
"Width":2.43417
},
{
"Name":"病人姓名",
"Width":1.79917
},
{
"Name":"使用剂量",
"Width":1.79917
},
{
"Name":"剩余剂量",
"Width":1.98438
},
{
"Name":"处理",
"Width":2.35479
},
{
"Name":"医师",
"Width":1.79917
},
{
"Name":"执行者",
"Width":1.61396
},
{
"Name":"核对者",
"Width":1.5875
},
{
"Name":"空安瓿批号",
"Width":1.61396
},
{
"Name":"空安瓿回收者",
"Width":2.19604
},
{
"Name":"空安瓿药房接收者",
"Width":1.61396
}
],
"ColumnContent":{
"Height":0.85,
"ColumnContentCell":[
{
"Column":"日期",
"WordWrap":true,
"TextAlign":"MiddleCenter",
"ShrinkFontToFit":true,
"DataField":"日期"
},
{
"Column":"品名",
"TextAlign":"MiddleCenter",
"DataField":"品名"
},
{
"Column":"规格",
"TextAlign":"MiddleCenter",
"DataField":"规格"
},
{
"Column":"批号",
"TextAlign":"MiddleCenter",
"DataField":"批号"
},
{
"Column":"床号",
"TextAlign":"MiddleCenter",
"DataField":"床号"
},
{
"Column":"病人姓名",
"TextAlign":"MiddleCenter",
"DataField":"病人姓名"
},
{
"Column":"使用剂量",
"TextAlign":"MiddleCenter",
"DataField":"使用剂量"
},
{
"Column":"剩余剂量",
"TextAlign":"MiddleCenter",
"DataField":"剩余剂量"
},
{
"Column":"处理",
"TextAlign":"MiddleCenter",
"DataField":"处理"
},
{
"Column":"医师",
"TextAlign":"MiddleCenter",
"DataField":"医师"
},
{
"Column":"执行者",
"TextAlign":"MiddleCenter",
"DataField":"执行者"
},
{
"Column":"核对者",
"TextAlign":"MiddleCenter",
"DataField":"核对者"
},
{
"Column":"空安瓿批号",
"TextAlign":"MiddleCenter",
"DataField":"空安瓿批号"
},
{
"Column":"空安瓿回收者",
"TextAlign":"MiddleCenter",
"DataField":"空安瓿回收者"
},
{
"Column":"空安瓿药房接收者",
"TextAlign":"MiddleCenter",
"DataField":"空安瓿药房接收者"
}
]
},
"ColumnTitle":{
"Height":1.19063,
"RepeatStyle":"OnPage",
"ColumnTitleCell":[
{
"GroupTitle":false,
"Column":"日期",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"日期"
},
{
"GroupTitle":false,
"Column":"品名",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"品名"
},
{
"GroupTitle":false,
"Column":"规格",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"规格"
},
{
"GroupTitle":false,
"Column":"批号",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"批号"
},
{
"GroupTitle":false,
"Column":"床号",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"床号"
},
{
"GroupTitle":false,
"Column":"病人姓名",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"病人\r\n姓名"
},
{
"GroupTitle":false,
"Column":"使用剂量",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"使用\r\n剂量"
},
{
"GroupTitle":false,
"Column":"剩余剂量",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"剩余\r\n剂量"
},
{
"GroupTitle":false,
"Column":"处理",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"剩余剂量\r\n是否双人\r\n在监控下\r\n用棉球或\r\n敷料作介质\r\n稀释后\r\n作医疗\r\n废物处理"
},
{
"GroupTitle":false,
"Column":"医师",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"医师"
},
{
"GroupTitle":false,
"Column":"执行者",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"执行者"
},
{
"GroupTitle":false,
"Column":"核对者",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"核对者"
},
{
"GroupTitle":false,
"Column":"空安瓿批号",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"空安瓿\r\n批号"
},
{
"GroupTitle":false,
"Column":"空安瓿回收者",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"空安瓿\r\n回收者"
},
{
"GroupTitle":false,
"Column":"空安瓿药房接收者",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"空安瓿\r\n药房\r\n接收者"
}
]
}
},
"Parameter":[
{
"Name":"machine_id"
},
{
"Name":"startDate",
"DataType":"DateTime"
},
{
"Name":"endDate",
"DataType":"DateTime"
}
],
"ReportHeader":[
{
"Name":"ReportHeader1",
"Height":1.79917,
"Control":[
{
"Type":"MemoBox",
"Name":"MemoBox1",
"Dock":"Fill",
"Center":"Both",
"Font":{
"Name":"宋体",
"Size":262500,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"麻醉药品、精神药品使用登记册"
}
],
"RepeatOnPage":true
}
]
}

View File

@ -0,0 +1,506 @@
{
"Version":"6.8.1.1",
"Font":{
"Name":"宋体",
"Size":105000,
"Weight":400,
"Charset":134
},
"Printer":{
"Oriention":"Landscape",
"LeftMargin":1,
"TopMargin":1.42875,
"RightMargin":1,
"BottomMargin":1.8
},
"DetailGrid":{
"CenterView":true,
"AppendBlankRow":true,
"Recordset":{
"Field":[
{
"Name":"日期",
"Type":"DateTime",
"Format":"M/d",
"DBFieldName":"OptDate"
},
{
"Name":"品名",
"DBFieldName":"DrugName"
},
{
"Name":"规格",
"DBFieldName":"DrugSpec"
},
{
"Name":"批号",
"DBFieldName":"ManuNo"
},
{
"Name":"床号",
"DBFieldName":"BedNum"
},
{
"Name":"病人姓名",
"DBFieldName":"PName"
},
{
"Name":"使用剂量",
"DBFieldName":"UDose"
},
{
"Name":"剩余剂量",
"DBFieldName":"ReDose"
},
{
"Name":"处理",
"DBFieldName":"Disposal"
},
{
"Name":"医师",
"DBFieldName":"AName"
},
{
"Name":"执行者",
"DBFieldName":"OName"
},
{
"Name":"核对者",
"DBFieldName":"CName"
},
{
"Name":"空安瓿批号",
"DBFieldName":"ManuNo"
},
{
"Name":"空安瓿回收者",
"DBFieldName":"EmpRecive"
},
{
"Name":"空安瓿药房接收者",
"DBFieldName":"EmpMedicRecive"
},
{
"Name":"手术间",
"DBFieldName":"WinNo"
},
{
"Name":"余液处置时间",
"DBFieldName":"DisposalTime"
},
{
"Name":"住院号",
"DBFieldName":"cardNo"
}
]
},
"Column":[
{
"Name":"日期",
"Width":1.77271
},
{
"Name":"品名",
"Width":3.41313
},
{
"Name":"规格",
"Width":2.35479
},
{
"Name":"批号",
"Width":2.83104
},
{
"Name":"手术间",
"Width":1.00542
},
{
"Name":"Column1",
"Width":2.35479
},
{
"Name":"病人姓名",
"Width":1.79917
},
{
"Name":"使用剂量",
"Width":1.79917
},
{
"Name":"剩余剂量",
"Width":1.98438
},
{
"Name":"余液处置时间",
"Width":3.22792
},
{
"Name":"处理",
"Width":2.35479
},
{
"Name":"医师",
"Width":1.79917
},
{
"Name":"执行者",
"Width":1.61396
},
{
"Name":"核对者",
"Width":1.5875
},
{
"Name":"空安瓿批号",
"Width":2.8575
},
{
"Name":"空安瓿回收者",
"Width":2.19604
},
{
"Name":"空安瓿药房接收者",
"Width":1.61396,
"Visible":false
}
],
"ColumnContent":{
"Height":0.85,
"ColumnContentCell":[
{
"Column":"日期",
"WordWrap":true,
"TextAlign":"MiddleCenter",
"ShrinkFontToFit":true,
"DataField":"日期"
},
{
"Column":"品名",
"TextAlign":"MiddleCenter",
"DataField":"品名"
},
{
"Column":"规格",
"TextAlign":"MiddleCenter",
"DataField":"规格"
},
{
"Column":"批号",
"TextAlign":"MiddleCenter",
"DataField":"批号"
},
{
"Column":"手术间",
"TextAlign":"MiddleCenter",
"DataField":"手术间"
},
{
"Column":"Column1",
"TextAlign":"MiddleCenter",
"DataField":"住院号"
},
{
"Column":"病人姓名",
"TextAlign":"MiddleCenter",
"DataField":"病人姓名"
},
{
"Column":"使用剂量",
"TextAlign":"MiddleCenter",
"DataField":"使用剂量"
},
{
"Column":"剩余剂量",
"TextAlign":"MiddleCenter",
"DataField":"剩余剂量"
},
{
"Column":"余液处置时间",
"DataField":"余液处置时间"
},
{
"Column":"处理",
"TextAlign":"MiddleCenter",
"DataField":"处理"
},
{
"Column":"医师",
"TextAlign":"MiddleCenter",
"DataField":"医师"
},
{
"Column":"执行者",
"TextAlign":"MiddleCenter",
"DataField":"执行者"
},
{
"Column":"核对者",
"TextAlign":"MiddleCenter",
"DataField":"核对者"
},
{
"Column":"空安瓿批号",
"TextAlign":"MiddleCenter",
"DataField":"批号"
},
{
"Column":"空安瓿回收者",
"TextAlign":"MiddleCenter",
"DataField":"空安瓿回收者"
},
{
"Column":"空安瓿药房接收者",
"TextAlign":"MiddleCenter",
"DataField":"空安瓿药房接收者"
}
]
},
"ColumnTitle":{
"Height":2.98979,
"RepeatStyle":"OnPage",
"ColumnTitleCell":[
{
"GroupTitle":false,
"Column":"日期",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"日期"
},
{
"GroupTitle":false,
"Column":"品名",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"品名"
},
{
"GroupTitle":false,
"Column":"规格",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"规格"
},
{
"GroupTitle":false,
"Column":"批号",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"批号"
},
{
"GroupTitle":false,
"Column":"手术间",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"手\r\n术\r\n间"
},
{
"GroupTitle":false,
"Column":"Column1",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"住院号"
},
{
"GroupTitle":false,
"Column":"病人姓名",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"病人\r\n姓名"
},
{
"GroupTitle":false,
"Column":"使用剂量",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"使用\r\n剂量"
},
{
"GroupTitle":false,
"Column":"剩余剂量",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"剩余\r\n剂量"
},
{
"GroupTitle":false,
"Column":"余液处置时间",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"余液处置\r\n时间"
},
{
"GroupTitle":false,
"Column":"处理",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"剩余剂量\r\n是否双人\r\n在监控下\r\n用棉球或\r\n敷料作介质\r\n稀释后\r\n作医疗\r\n废物处理"
},
{
"GroupTitle":false,
"Column":"医师",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"医师"
},
{
"GroupTitle":false,
"Column":"执行者",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"执行者"
},
{
"GroupTitle":false,
"Column":"核对者",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"核对者"
},
{
"GroupTitle":false,
"Column":"空安瓿批号",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"空安瓿\r\n批号"
},
{
"GroupTitle":false,
"Column":"空安瓿回收者",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"空安瓿\r\n回收者"
},
{
"GroupTitle":false,
"Column":"空安瓿药房接收者",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"空安瓿\r\n药房\r\n接收者"
}
]
}
},
"Parameter":[
{
"Name":"machine_id"
},
{
"Name":"startDate",
"DataType":"DateTime"
},
{
"Name":"endDate",
"DataType":"DateTime"
}
],
"ReportHeader":[
{
"Name":"ReportHeader1",
"Height":1.79917,
"Control":[
{
"Type":"MemoBox",
"Name":"MemoBox1",
"Dock":"Fill",
"Center":"Both",
"Font":{
"Name":"宋体",
"Size":262500,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"麻醉药品、精神药品使用登记册"
}
],
"RepeatOnPage":true
}
]
}

View File

@ -3,11 +3,13 @@ using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.util;
using log4net;
using MaterialDesignThemes.Wpf;
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using Prism.Regions;
using Prism.Services.Dialogs;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Configuration;
@ -15,12 +17,21 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Input;
using System.Windows.Media;
namespace DM_Weight.ViewModels
{
public class AddToJiaoJieDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
{
private readonly ILog logger = LogManager.GetLogger(typeof(OrderTakeDialogViewModel));
private List<DrugInfo> _drugInfoList = new List<DrugInfo>();
public List<DrugInfo> _DrugInfoList
{
get => _drugInfoList;
set => SetProperty(ref _drugInfoList, value);
}
private List<ChannelStock> _channelStocks = new List<ChannelStock>();
@ -40,17 +51,21 @@ namespace DM_Weight.ViewModels
get => _jiaojie_channelStocks;
set => SetProperty(ref _jiaojie_channelStocks, value);
}
//交接柜所在药箱下的所有药品id
List<string> drugIdLst = new List<string>();
//交接柜中无该批次添加实体
public List<ChannelStock> AddJJStock = new List<ChannelStock>();
//交接柜中有该批次更新实体
public List<ChannelStock> UpdateJJStock = new List<ChannelStock>();
/// <summary>
/// 交接柜的库位信息
/// </summary>
private ChannelStock _jiaojei_cs;
private ChannelStock _jiaojie_cs;
public ChannelStock Jiaojie_cs
{
get => _jiaojei_cs;
set => SetProperty(ref _jiaojei_cs, value);
get => _jiaojie_cs;
set => SetProperty(ref _jiaojie_cs, value);
}
private static readonly DateTime Jan1st1970 = new DateTime
(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
@ -58,6 +73,20 @@ namespace DM_Weight.ViewModels
private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
private SolidColorBrush _colorBrush;
public SolidColorBrush SnackbarBackground
{
get => _colorBrush;
set => SetProperty(ref _colorBrush, value);
}
private ISnackbarMessageQueue _snackbarMessageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(3));
public ISnackbarMessageQueue SnackbarMessageQueue
{
get => _snackbarMessageQueue;
set => SetProperty(ref _snackbarMessageQueue, value);
}
public string Title => "交接柜补药";
@ -79,18 +108,19 @@ namespace DM_Weight.ViewModels
public void OnDialogOpened(IDialogParameters parameters)
{
_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
Jiaojie_ChannelStocks = parameters.GetValue<List<ChannelStock>>("ChannelStocks");
Jiaojie_ChannelStocks = parameters.GetValue<List<ChannelStock>>("_ChannelStock");
for (int i = 0; i < Jiaojie_ChannelStocks.Count; i++)
{
ChannelStock copy = TransExpV2<ChannelStock, ChannelStock>.Trans(Jiaojie_ChannelStocks[i]);
ChannelStocks.Add(copy);
}
ChannelStocks = Jiaojie_ChannelStocks.GroupBy(cs => cs.DrugId).Select(g => new
{
DrugId = g.Key,
AddQuantity = g.Sum(s => s.AddQuantity)
}).Select(cs => new ChannelStock() { DrugId = cs.DrugId, AddQuantity = cs.AddQuantity }).ToList();
//ChannelStocks = Jiaojie_ChannelStocks.GroupBy(cs =>new { cs.DrugId }).Select(g => new
//{
// Key = g.Key,
// AddQuantity = g.Sum(s => s.AddQuantity)
//}).Select(cs => new ChannelStock() { DrugId = cs.Key.DrugId,ManuNo=cs.Key.ManuNo, AddQuantity = cs.AddQuantity }).ToList();
RequestData();
}
@ -187,74 +217,93 @@ namespace DM_Weight.ViewModels
}
public async void RequestData()
{
List<ChannelStock> channelStocks = new List<ChannelStock>();
List<string> msg = new List<string>();
//List<ChannelStock> channelStocks = new List<ChannelStock>();
List<DrugInfo> drugList = new List<DrugInfo>();
for (int i = 0; i < ChannelStocks.Count; i++)
{
DrugInfo drug = ChannelStocks[i].DrugInfo;
drug.NeedQuantity = ChannelStocks[i].AddQuantity;
List<ChannelStock> HasQChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Includes<DrugInfo>(cs => cs.DrugInfo)
//.Includes<DrugInfo>(cs => cs.DrugInfo)
.Where(cs => cs.Quantity > 0)
.Where(cs => cs.DrawerType == 1)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
.Where(cs => cs.DrugId == ChannelStocks[i].DrugId)
.OrderBy(cs => cs.EffDate)
.OrderBy(cs => cs.DrawerNo)
//.OrderBy(cs => cs.EffDate)
.OrderBy(cs => new { cs.EffDate, cs.DrawerNo, cs.ColNo })
.ToList();
if (HasQChannels == null || HasQChannels.Count <= 0)
if (HasQChannels != null && HasQChannels.Count > 0)
{
msg.Add($"有药品未绑定,请先绑定");
continue;
}
int total = HasQChannels.Sum(it => it.Quantity);
int TakeQ = ChannelStocks[i].AddQuantity;
// 说明数量足够
if (total >= TakeQ)
{
for (int j = 0; TakeQ > 0; j++)
int total = HasQChannels.Sum(it => it.Quantity);
int TakeQ = ChannelStocks[i].AddQuantity;
// 说明数量足够
//if (total >= TakeQ)
//{
//for (int j = 0; TakeQ > 0; j++)
//{
// ChannelStock stock = HasQChannels[j];
// if (TakeQ > stock.Quantity)
// {
// stock.TakeQuantity = stock.Quantity;
// channelStocks.Add(stock);
// TakeQ -= stock.Quantity;
// }
// else
// {
// stock.TakeQuantity = TakeQ;
// channelStocks.Add(stock);
// TakeQ = 0;
// }
//}
int hadTakeQ = 0;
for (int j = 0; j < HasQChannels.Count; j++)
{
ChannelStock stock = HasQChannels[j];
if (TakeQ > stock.Quantity)
if ((ChannelStocks[i].AddQuantity - hadTakeQ) > HasQChannels[j].Quantity)
{
stock.TakeQuantity = stock.Quantity;
channelStocks.Add(stock);
TakeQ -= stock.Quantity;
HasQChannels[j].TakeQuantity = HasQChannels[j].Quantity;
hadTakeQ += HasQChannels[j].Quantity;
}
else
{
stock.TakeQuantity = TakeQ;
channelStocks.Add(stock);
TakeQ = 0;
HasQChannels[j].TakeQuantity = ChannelStocks[i].AddQuantity - hadTakeQ;
break;
}
}
if (drug.channelStocks == null)
{
drug.channelStocks = new List<ChannelStock>();
}
drug.channelStocks.AddRange(HasQChannels);
//}
//else
//{
// //msg.Add($"药品【{HasQChannels[0].DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】");
// ChannelStock channel = ChannelStocks[i];
// channel.ColNo = -2;
// channel.Quantity = 0;
// channel.ManuNo = null;
// channel.EffDate = null;
// channel.Quantity = total;
// channel.TakeQuantity = 0;
// channelStocks.Add(channel);
//}
}
else
{
msg.Add($"药品【{HasQChannels[0].DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】");
}
}
if (msg.Count > 0)
{
RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
//MessageBox.Show(string.Join("\n", msg));
DialogParameters dialogParameters = new DialogParameters();
dialogParameters.Add("msgInfo", msg);
DialogServiceExtensions.ShowDialogHost(_dialogService, "ShowMessageDialog", dialogParameters, "RootDialog");
}
else
{
channelStocks.Sort((a, b) =>
{
if ((a.DrawerNo - b.DrawerNo) == 0)
ChannelStock channel = ChannelStocks[i];
channel.ColNo = -1;
channel.Quantity = 0;
channel.ManuNo = null;
channel.EffDate = null;
channel.TakeQuantity = 0;
if (drug.channelStocks == null)
{
return a.ColNo - b.ColNo;
drug.channelStocks = new List<ChannelStock>();
}
return a.DrawerNo - b.DrawerNo;
});
ChannelStocks = channelStocks;
drug.channelStocks.Add(channel);
}
_DrugInfoList.Add(drug);
}
}
public DelegateCommand OpenDrawer
@ -266,7 +315,7 @@ namespace DM_Weight.ViewModels
if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
{
//查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
bool bDrawer = ChannelStocks.Select(it => it.DrawerNo).Where(n => n > 2).Any();
bool bDrawer = _DrugInfoList.Where(di => di.channelStocks.Select(it => it.DrawerNo).Where(n => n > 2).Any()).Count() > 0;
if (bDrawer)
{
AlertMsg alertMsg = new AlertMsg
@ -279,11 +328,26 @@ namespace DM_Weight.ViewModels
}
}
enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
enumerator = enumerable.GetEnumerator();
enumerator.MoveNext();
Status = 1;
OpenOneByOne();
enumerable = _DrugInfoList.SelectMany(di => di.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);
if (enumerable != null && enumerable.Count() > 0)
{
enumerator = enumerable.GetEnumerator();
enumerator.MoveNext();
Status = 1;
OpenOneByOne();
}
else
{
AlertMsg alertMsg = new AlertMsg
{
Message = "没有可补药品!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
return;
}
}
});
@ -292,52 +356,82 @@ namespace DM_Weight.ViewModels
private void OpenOneByOne()
{
IGrouping<int, ChannelStock> grouping = enumerator.Current;
int DrawerNo = grouping.Key;
List<ChannelStock> channelStocks = grouping.ToList();
channelStocks.ForEach(it => it.process = 1);
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
// 发送取药数量
singleChannels.ForEach(it =>
if (grouping != null)
{
try
{
int DrawerNo = grouping.Key;
List<ChannelStock> channelStocks = grouping.ToList();
channelStocks.ForEach(it => it.process = 1);
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
_portUtil.TakeQuantity(DrawerNo, it.ColNo, it.TakeQuantity, it.Quantity - it.TakeQuantity);
}
catch (Exception ex)
List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
// 发送取药数量
singleChannels.ForEach(it =>
{
AlertMsg alertMsg = new AlertMsg
try
{
Message = $"打开抽屉异常{ex.Message}",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
});
_portUtil.WindowName = "OrderTakeDrugWindow";
_portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
_portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
_portUtil.DrawerNo = DrawerNo;
_portUtil.Start();
_portUtil.TakeQuantity(DrawerNo, it.ColNo, it.TakeQuantity, it.Quantity - it.TakeQuantity);
}
catch (Exception ex)
{
AlertMsg alertMsg = new AlertMsg
{
Message = $"打开抽屉异常{ex.Message}",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
});
_portUtil.WindowName = "OrderTakeDrugWindow";
_portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
_portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
_portUtil.DrawerNo = DrawerNo;
_portUtil.Start();
}
}
private bool _isFinishClick = false;
// 完成按钮
public DelegateCommand TakeFinish
{
get => new DelegateCommand(() =>
get => new DelegateCommand(async () =>
{
if (!_isFinishClick)
{
_isFinishClick = true;
List<ChannelStock> record = ChannelStocks.FindAll(it => it.TakeQuantity > 0).ToList();
List<ChannelStock> record = _DrugInfoList.SelectMany(di => di.channelStocks).Where(cs => cs.TakeQuantity > 0).ToList();
if (record.Count > 0)
{
//交接柜需要补药数量与加药数量对比,数量不一致则提示
var jjSum = from item in Jiaojie_ChannelStocks orderby item.DrugId group item by item.DrugId into g select new { DrugId = g.Key, Quantity = g.Sum(item => item.AddQuantity) };
var csSum = from item in record orderby item.DrugId group item by item.DrugId into g select new { DrugId = g.Key, Quantity = g.Sum(item => item.TakeQuantity) };
foreach (var jjItem in jjSum)
{
foreach (var csItem in csSum)
{
if (jjItem.DrugId == csItem.DrugId)
{
if (jjItem.Quantity < csItem.Quantity)
{
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
//SnackbarMessageQueue.Enqueue("输入药品数量与需要补药品数不一致!");
SnackbarMessageQueue.Enqueue("输入药品数量大于需要补药数!");
_isFinishClick = false;
return;
}
}
}
}
string InvoiceId = "AddJiaoJie_" + CurrentTimeMillis();
var f = SqlSugarHelper.Db.UseTran(() =>
{
@ -353,35 +447,6 @@ namespace DM_Weight.ViewModels
Id = it.Id,
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
////更新 交接柜 批次信息
//List<ChannelStock> jiaojieStock = Jiaojie_ChannelStocks.Where(cs => cs.DrugId == it.DrugId).ToList();
////交接柜中有该药品及批次的数据则更新;没有则插入一条
//if (jiaojieStock != null)
//{
// for (int j = 0; j < jiaojieStock.Count; j++)
// {
// if(it.Quantity> jiaojieStock[j].Quantity)
// {
// //取的数量够不够被
// }
// List<ChannelStock> searchStock = SqlSugarHelper.Db.Queryable<ChannelStock>()
// .Where(cs => cs.DrawerNo == jiaojieStock[j].DrawerNo
// && cs.DrugId == jiaojieStock[j].DrugId
// && cs.DrugId == it.DrugId
// && cs.ManuNo == it.ManuNo
// &&cs.MachineId==(ConfigurationManager.AppSettings["jj_machineId"] ?? "DM5"))
// .ToList();
// //List<ChannelStock> stockManuList = jiaojieStock.Where(cs => cs.ManuNo == it.ManuNo).ToList();
// if (searchStock == null || searchStock.Count <= 0)
// {
// SqlSugarHelper.Db.Deleteable<ChannelStock>().Where(cs=>cs.DrawerNo== jiaojieStock[j].DrawerNo&&cs.DrugId== jiaojieStock[j].DrugId&&cs.Quantity<=0).ExecuteCommand();
// jiaojieStock[j].ManuNo = it.ManuNo;
// jiaojieStock[j].Id = Guid.NewGuid().ToString();
// SqlSugarHelper.Db.Insertable(jiaojieStock[j]).ExecuteCommand();
// }
// }
//}
// 保存数据 出库记录
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
@ -405,104 +470,177 @@ namespace DM_Weight.ViewModels
for (int i = 0; i < Jiaojie_ChannelStocks.Count; i++)
{
ChannelStock jiaoStock = Jiaojie_ChannelStocks[i];
SqlSugarHelper.Db.Deleteable<ChannelStock>().Where(cs => cs.DrawerNo == jiaoStock.DrawerNo && cs.DrugId == jiaoStock.DrugId && cs.MachineId == jiaoStock.MachineId && cs.Quantity <= 0 && cs.AddToJJNum <= 0).ExecuteCommand();
List<ChannelStock> csStockList = record.Where(cs => cs.DrugId == jiaoStock.DrugId && cs.TakeQuantity > 0).ToList();
if (csStockList != null && csStockList.Count > 0)
{
int jjNeedQuantity = jiaoStock.AddQuantity;// SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerNo == jiaoStock.DrawerNo && cs.DrugId == jiaoStock.DrugId && cs.MachineId == jiaoStock.MachineId).Sum(cs => (cs.BaseQuantity-cs.Quantity));
SqlSugarHelper.Db.Deleteable<ChannelStock>().Where(cs => cs.DrawerNo == jiaoStock.DrawerNo && cs.DrugId == jiaoStock.DrugId && cs.MachineId == jiaoStock.MachineId && cs.Quantity <= 0).ExecuteCommand();
for (int j = 0; j < csStockList.Count; j++)
{
ChannelStock csStock = csStockList[j];
// 保存数据 记录
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
MachineId = jiaoStock.MachineId,
DrawerNo = jiaoStock.DrawerNo,
DrugId = jiaoStock.DrugId,
ManuNo = csStockList[j].ManuNo,
Operator = HomeWindowViewModel.Operator?.Id,
Reviewer = HomeWindowViewModel.Reviewer?.Id,
OperationTime = DateTime.Now,
Quantity = csStockList[j].TakeQuantity,
Type = 55,
Status = 2,//给交接柜补药不用还空瓶等真正用了以后再还空瓶所以先把状态置为2
InvoiceId = $"毒麻柜{csStockList[j].Location}给交接柜{jiaoStock.DrawerNo}补药"
}).ExecuteCommand();
ChannelStock csStock = (ChannelStock)csStockList[j].Clone();
ChannelStock jjStockManuNo = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.DrawerNo == jiaoStock.DrawerNo && cs.DrugId == jiaoStock.DrugId && cs.ManuNo == csStock.ManuNo && cs.MachineId == "DM5").First();
.Where(cs => cs.DrawerNo == Jiaojie_ChannelStocks[i].DrawerNo && cs.DrugId == Jiaojie_ChannelStocks[i].DrugId && cs.ManuNo == csStock.ManuNo && cs.MachineId == "DM5").First();
logger.Info($"库中{Jiaojie_ChannelStocks[i].DrawerNo}号手术间,{Jiaojie_ChannelStocks[i].DrugId},{csStock.ManuNo};有该批次{jjStockManuNo != null};jjStockManuNo是空{jjStockManuNo == null}");
if (jjStockManuNo != null)
{
int addNum = csStock.TakeQuantity;
logger.Info($"需补药数{Jiaojie_ChannelStocks[i].AddQuantity},该批次取药数{csStock.TakeQuantity}");
//有该批次
if (jiaoStock.NeedNum > csStock.TakeQuantity)
if (Jiaojie_ChannelStocks[i].AddQuantity > csStock.TakeQuantity)
{
//不够取
ChannelStock newStock = new ChannelStock();
newStock.Chnguid = jiaoStock.Chnguid;
//newStock.Chnguid = jiaoStock.Chnguid;
newStock.BaseQuantity = jiaoStock.BaseQuantity;
newStock.ManuNo = jiaoStock.ManuNo;
newStock.DrawerNo = jiaoStock.DrawerNo;
newStock.DrugId = jiaoStock.DrugId;
newStock.AddToJJNum = csStock.TakeQuantity;
newStock.Id = Guid.NewGuid().ToString();
newStock.MachineId = jiaoStock.MachineId;
newStock.Id = Guid.NewGuid().ToString();
AddJJStock.Add(newStock);
csStock.TakeQuantity = 0;
jiaoStock.NeedNum = jiaoStock.NeedNum - csStock.TakeQuantity;
newStock.ManuNo = Jiaojie_ChannelStocks[i].ManuNo;
newStock.EffDate = Jiaojie_ChannelStocks[i].EffDate;
newStock.DrawerNo = Jiaojie_ChannelStocks[i].DrawerNo;
newStock.DrugId = Jiaojie_ChannelStocks[i].DrugId;
newStock.AddToJJNum = addNum;
newStock.Id = jjStockManuNo.Id;
newStock.State = 1;
//newStock.MachineId = jiaoStock.MachineId;
//newStock.NeedNum = 0;
//newStock.Quantity = jiaoStock.Quantity + csStock.TakeQuantity;
UpdateJJStock.Add(newStock);
csStockList[j].CheckQuantity = csStockList[j].TakeQuantity;
csStockList[j].TakeQuantity = 0;
Jiaojie_ChannelStocks[i].AddQuantity = Jiaojie_ChannelStocks[i].AddQuantity - csStock.TakeQuantity;
}
else
{
//够取
jiaoStock.AddQuantity = jiaoStock.Quantity+ jiaoStock.NeedNum;
jiaoStock.NeedNum = 0;
AddJJStock.Add(jiaoStock);
csStock.Quantity = csStock.Quantity - jiaoStock.NeedNum;
//jiaoStock.AddQuantity = jiaoStock.Quantity+ jiaoStock.NeedNum;
//jiaoStock.NeedNum = 0;
//AddJJStock.Add(jiaoStock);
//csStock.Quantity = csStock.Quantity - jiaoStock.NeedNum;
//csStockList[j].Quantity = csStock.Quantity - jiaoStock.NeedNum;
ChannelStock newStock = new ChannelStock();
newStock.Chnguid = jiaoStock.Chnguid;
//newStock.Chnguid = jiaoStock.Chnguid;
newStock.BaseQuantity = jiaoStock.BaseQuantity;
newStock.ManuNo = jiaoStock.ManuNo;
newStock.DrawerNo = jiaoStock.DrawerNo;
newStock.DrugId = jiaoStock.DrugId;
newStock.AddToJJNum = csStock.TakeQuantity;
newStock.Id = Guid.NewGuid().ToString();
newStock.MachineId = jiaoStock.MachineId;
newStock.Id=Guid.NewGuid().ToString();
AddJJStock.Add(newStock);
csStock.TakeQuantity = jiaoStock.NeedNum - csStock.TakeQuantity;
jiaoStock.NeedNum = 0;
newStock.ManuNo = Jiaojie_ChannelStocks[i].ManuNo;
newStock.EffDate = Jiaojie_ChannelStocks[i].EffDate;
newStock.DrawerNo = Jiaojie_ChannelStocks[i].DrawerNo;
newStock.DrugId = Jiaojie_ChannelStocks[i].DrugId;
newStock.AddToJJNum = Jiaojie_ChannelStocks[i].AddQuantity;
newStock.Id = jjStockManuNo.Id;
newStock.State = 1;
//newStock.MachineId = jiaoStock.MachineId;
//newStock.NeedNum = 0;
//newStock.Quantity = jiaoStock.Quantity + csStock.TakeQuantity;
UpdateJJStock.Add(newStock);
csStockList[j].CheckQuantity = csStockList[j].TakeQuantity;
csStockList[j].TakeQuantity = csStock.TakeQuantity - Jiaojie_ChannelStocks[i].AddQuantity;
Jiaojie_ChannelStocks[i].AddQuantity = 0;
break;
}
}
else //没有该批次
{
if (jiaoStock.NeedNum > csStock.TakeQuantity)
if (Jiaojie_ChannelStocks[i].AddQuantity > csStock.TakeQuantity)
{
//不够取
ChannelStock newStock = new ChannelStock();
newStock.Chnguid = jiaoStock.Chnguid;
newStock.BaseQuantity = csStock.BaseQuantity;
newStock.DrawerNo = jiaoStock.DrawerNo;
newStock.DrugId = jiaoStock.DrugId;
newStock.BaseQuantity = Jiaojie_ChannelStocks[i].BaseQuantity;
newStock.Chnguid = Jiaojie_ChannelStocks[i].Chnguid;
newStock.DrawerNo = Jiaojie_ChannelStocks[i].DrawerNo;
newStock.DrugId = Jiaojie_ChannelStocks[i].DrugId;
newStock.ManuNo = csStock.ManuNo;
newStock.AddToJJNum = csStock.Quantity;
newStock.EffDate = csStock.EffDate;
newStock.AddToJJNum = csStock.TakeQuantity;
newStock.Id = Guid.NewGuid().ToString();
newStock.MachineId = jiaoStock.MachineId;
newStock.MachineId = Jiaojie_ChannelStocks[i].MachineId;
newStock.DrawerType = 1;
newStock.AddQuantity = 0;
newStock.State = 1;
AddJJStock.Add(newStock);
jiaoStock.NeedNum = jiaoStock.NeedNum - csStock.Quantity;
Jiaojie_ChannelStocks[i].AddQuantity = Jiaojie_ChannelStocks[i].AddQuantity - csStock.TakeQuantity;
csStockList[j].CheckQuantity = csStockList[j].TakeQuantity;
csStockList[j].TakeQuantity = 0;
}
else
{
//够取
ChannelStock newStock = new ChannelStock();
newStock.Chnguid = jiaoStock.Chnguid;
newStock.BaseQuantity = csStock.BaseQuantity;
newStock.DrawerNo = jiaoStock.DrawerNo;
newStock.DrugId = jiaoStock.DrugId;
newStock.Chnguid = Jiaojie_ChannelStocks[i].Chnguid;
newStock.BaseQuantity = Jiaojie_ChannelStocks[i].BaseQuantity;
newStock.DrawerNo = Jiaojie_ChannelStocks[i].DrawerNo;
newStock.DrugId = Jiaojie_ChannelStocks[i].DrugId;
newStock.ManuNo = csStock.ManuNo;
newStock.AddToJJNum = jiaoStock.NeedNum;
newStock.NeedNum = 0;
newStock.EffDate = csStock.EffDate;
newStock.AddToJJNum = Jiaojie_ChannelStocks[i].AddQuantity;
newStock.AddQuantity = 0;
newStock.Id = Guid.NewGuid().ToString();
newStock.MachineId=jiaoStock.MachineId;
newStock.MachineId = Jiaojie_ChannelStocks[i].MachineId;
newStock.DrawerType = 1;
newStock.State = 1;
AddJJStock.Add(newStock);
csStock.TakeQuantity = csStock.Quantity - newStock.AddToJJNum;
csStockList[j].CheckQuantity = csStockList[j].TakeQuantity;
csStockList[j].TakeQuantity = csStock.TakeQuantity - newStock.AddToJJNum;
break;
}
}
}
//int addQuantity= AddJJStock.Where(aj => aj.DrugId == jiaoStock.DrugId).Sum(aj => aj.AddToJJNum);
//int updateQuantity = UpdateJJStock.Where(aj => aj.DrugId == jiaoStock.DrugId).Sum(aj => aj.AddToJJNum);
int iUpdateResult = SqlSugarHelper.Db.Updateable<ChannelStock>()
.SetColumns(cs => new ChannelStock() { State = 1 })
.Where(cs => cs.DrawerNo == Jiaojie_ChannelStocks[i].DrawerNo && cs.DrugId == Jiaojie_ChannelStocks[i].DrugId && cs.MachineId == Jiaojie_ChannelStocks[i].MachineId)
.ExecuteCommand();
//jiaoStock.NeedNum = jjNeedQuantity - (addQuantity + updateQuantity);
//int iUpdateResult2 = SqlSugarHelper.Db.Updateable(jiaoStock)
// .UpdateColumns(it => new { it.NeedNum })
// .ExecuteCommand();
}
}
//保存交接柜数据
SqlSugarHelper.Db.Insertable(AddJJStock).ExecuteCommand();
if (AddJJStock != null && AddJJStock.Count > 0)
{
AddJJStock = AddJJStock.GroupBy(jj => new { jj.DrawerNo, jj.DrugId, jj.ManuNo })
.Select(jj =>
{
var ret = jj.First();
ret.AddToJJNum = jj.Sum(itx => itx.AddToJJNum);
//ret.NeedNum = 0;
return ret;
}).ToList();
SqlSugarHelper.Db.Insertable(AddJJStock).ExecuteCommand();
}
if (UpdateJJStock != null && UpdateJJStock.Count > 0)
{
UpdateJJStock = UpdateJJStock.GroupBy(jj => new { jj.DrawerNo, jj.DrugId, jj.ManuNo })
.Select(jj =>
{
var ret = jj.First();
ret.AddToJJNum = jj.Sum(itx => itx.AddToJJNum);
//ret.NeedNum = 0;
return ret;
}).ToList();
for (int i = 0; i < UpdateJJStock.Count; i++)
{
SqlSugarHelper.Db.Updateable<ChannelStock>().SetColumns(cs => new ChannelStock() { AddToJJNum = UpdateJJStock[i].AddToJJNum, State = 1 }).Where(cs => cs.Id == UpdateJJStock[i].Id).ExecuteCommand();
}
}
//保存注射剂报表信息
for (int j = 0; j < Jiaojie_ChannelStocks.Count; j++)
@ -530,33 +668,47 @@ namespace DM_Weight.ViewModels
}
}
//更新交接柜状态为 已取药未入库(等在交接柜入库后再更新交接柜库存)
List<ChannelStock> jiaojie = Jiaojie_ChannelStocks.GroupBy(cs => cs.DrawerNo).Select(cs => cs.FirstOrDefault()).ToList();
if (jiaojie != null && jiaojie.Count > 0)
{
for (int j = 0; j < jiaojie.Count; j++)
{
ChannelStock jiaojie_it = jiaojie[j];
//更新交接柜状态为 已取药未入库
SqlSugarHelper.Db.Updateable(new ChannelList()
{
State = 1,
Id = jiaojie_it.ChannelLst.Id
}).UpdateColumns(it => it.State).ExecuteCommand();
}
}
//if (Jiaojie_ChannelStocks != null)
//{
// Jiaojie_ChannelStocks.ForEach(jj =>
// {
// //更新交接柜状态为 已取药未入库
// SqlSugarHelper.Db.Updateable(new ChannelList()
// {
// State = 1,
// Id = jj.ChannelLst.Id
// }).UpdateColumns(it => it.State).ExecuteCommand();
// }
// );
//}
return true;
});
if (f.Data)
{
//Task.Factory.StartNew(() =>
//{
// 更新屏显库存
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 5);
if (singleChannels.Count > 0)
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType == 5);
//if (singleChannels.Count > 0)
//{
// singleChannels.ForEach(it =>
// {
// _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
// Thread.Sleep(150);
// });
//}
List<ChannelStock> singleChannelsBoxSmart = record.FindAll(it => it.BoardType == 35);
if ((singleChannelsBoxSmart.Count > 0 ? singleChannelsBoxSmart[0].BoardType : 1) == 35)
{
singleChannels.ForEach(it =>
for (int i = 0; i < singleChannelsBoxSmart.Count; i++)
{
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
});
ChannelStock it = singleChannelsBoxSmart[i];
await _portUtil.WriteQuantityMethod((it.Quantity - it.CheckQuantity), it.DrawerNo, it.ColNo);
}
}
//});
AlertMsg alertMsg = new AlertMsg
{
Message = "抽屉取药完成,库存已更新",
@ -575,6 +727,7 @@ namespace DM_Weight.ViewModels
}
Status = 0;
_isFinishClick = false;
_portUtil.OperateFinish = true;
//RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
}
@ -606,6 +759,7 @@ namespace DM_Weight.ViewModels
{
_portUtil.ResetData();
Status = 0;
_portUtil.OperateFinish = true;
});
}
//检查是否是冰箱抽屉(冰箱抽屉打开时需要发送冰箱延迟报警的指令)

View File

@ -0,0 +1,241 @@
using DM_Weight.Models;
using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.util;
using log4net;
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using Prism.Regions;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.ViewModels
{
internal class AddToJiaoJieNewWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime
{
private readonly ILog logger = LogManager.GetLogger(typeof(AddToJiaoJieWindowViewModel));
private static readonly DateTime Jan1st1970 = new DateTime
(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public long CurrentTimeMillis()
{
return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
}
public bool KeepAlive => false;
public bool IsNavigationTarget(NavigationContext navigationContext)
{
return true;
}
public void OnNavigatedFrom(NavigationContext navigationContext)
{
// 取消消息订阅
//_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
//_eventAggregator.GetEvent<IsSelectedEvent>().Unsubscribe(SetIsSelected);
}
private List<ChannelStock>? channelStocks;
public List<ChannelStock>? ChannelStocks
{
get => channelStocks;
set => SetProperty(ref channelStocks, value);
}
private ChannelStock _channelStock;
public ChannelStock _ChannelStock
{
get => _channelStock;
set => SetProperty(ref _channelStock, value);
}
private List<ChannelStock>? _channelStocksList;
public List<ChannelStock>? _ChannelStocksList
{
get => _channelStocksList;
set => SetProperty(ref _channelStocksList, value);
}
private List<ChannelList>? _channelLists;
public List<ChannelList>? _ChannelLists
{
get => _channelLists;
set => SetProperty(ref _channelLists, value);
}
private ChannelList _channelList;
public ChannelList _ChannelList
{
get => _channelList;
set => SetProperty(ref _channelList, value);
}
public void OnNavigatedTo(NavigationContext navigationContext)
{
RequestData();
}
private PortUtil _portUtil;
IEventAggregator _eventAggregator;
IDialogService _dialogService;
public AddToJiaoJieNewWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService)
{
_portUtil = portUtil;
_eventAggregator = eventAggregator;
_dialogService = DialogService;
}
private void RequestData()
{
ChannelStocks?.Clear();
_ChannelLists?.Clear();
//1)查询channel_stock所有要补药的药箱
ChannelStocks = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Includes<ChannelList>(cs => cs.ChannelLst)
.Includes<DrugInfo>(cs => cs.DrugInfo)
.Where(cs => cs.MachineId == (ConfigurationManager.AppSettings["jj_machineId"] ?? "DM5"))
.OrderBy(cs => cs.Chnguid)
.OrderBy(cs => cs.DrawerNo)
.ToList();
ChannelStocks = ChannelStocks.GroupBy(it => new { it.DrawerNo, it.DrugId })
.Select(it =>
{
var ret = it.First();
ret.Quantity = it.Sum(itx => itx.Quantity);
//ret.NeedNum = ret.BaseQuantity-it.Sum(itx => itx.Quantity);
return ret;
}).Where(it => it.BaseQuantity > it.Quantity)
.ToList();
if (ChannelStocks != null && ChannelStocks.Count > 0)
{
ChannelStocks.ForEach(cs => cs.AddQuantity =cs.BaseQuantity- cs.Quantity);
//2)查询channel_list将1中查询的添加到channel_list的channel_stock里供页面呈现显示
List<int> DrawerNoList = ChannelStocks.Select(cs => cs.DrawerNo).Distinct().ToList();
List<ChannelList> channelLists = new List<ChannelList>();
for (int i = 0; i < DrawerNoList.Count; i++)
{
var channelList = SqlSugarHelper.Db.Queryable<ChannelList>()
.Where(cl => cl.MachineId == (ConfigurationManager.AppSettings["jj_machineId"] ?? "DM5") && cl.DrawerNo == DrawerNoList[i])
.OrderBy(cl => cl.Id)
.OrderBy(cl => cl.DrawerNo)
.First();
if (channelList.channelStocks == null)
{
channelList.channelStocks = new List<ChannelStock>();
}
channelList.channelStocks.AddRange(ChannelStocks.Where(cs => cs.DrawerNo == DrawerNoList[i]).ToList());
if (channelList != null)
{
//if (channelList.channelStocks[0].AddToJJNum>0)
// channelList.State=1; //表示有补药
channelLists.Add(channelList);
}
}
_ChannelLists = channelLists;
}
else
{
_ChannelLists?.Clear();
_ChannelLists = new List<ChannelList>();
}
}
private int _status = 0;
public int Status { get => _status; set => SetProperty(ref _status, value); }
private bool _isEnable = true;
public bool IsEnable { get => _isEnable; set => SetProperty(ref _isEnable, value); }
private List<int> iDrawerNoLst
{ get; set; }
private int CurrentNum { get; set; }
//刷新
public DelegateCommand QueryCommand
{
get => new DelegateCommand(() => RequestData());
}
public DelegateCommand RejectReport_Download
{
get => new DelegateCommand(() =>
{
//GridReportUtil.RejectionReport("");
});
}
public DelegateCommand Account_Download
{
get => new DelegateCommand(() =>
{
//GridReportUtil.AccountNewReport();
});
}
private List<ChannelStock> csList = new List<ChannelStock>();
//取药 弹出出药列表
public DelegateCommand TakeDrugCommand
{
get => new DelegateCommand(async () =>
{
csList = _ChannelList.channelStocks.FindAll(cs => cs.ChannelLst.IsSelected).ToList();
if (csList != null && csList.Count > 0)
{
// 此处延时1毫秒等待页面渲染
await Task.Delay(TimeSpan.FromMilliseconds(1));
DialogParameters dialogParameters = new DialogParameters();
dialogParameters.Add("_ChannelStock", csList);
DialogServiceExtensions.ShowDialogHost(_dialogService, "AddToJiaoJieDialog", dialogParameters, DoDialogResult, "RootDialog");
}
else
{
AlertMsg alertMsg = new AlertMsg
{
Message = $"未选择药品,请先点选药箱号",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
_portUtil.Operate = false;
}
});
}
private void DoDialogResult(IDialogResult dialogResult)
{
RequestData();
}
private DelegateCommand _rowSelected;
public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(OpenOrderDialog);
public async void OpenOrderDialog()
{
if (_ChannelList != null && _ChannelList.channelStocks != null && _ChannelList.channelStocks.Any(cs => cs.State == 0))
{
// 此处延时1毫秒等待页面渲染
await Task.Delay(TimeSpan.FromMilliseconds(1));
//选中药箱号下的所有药品id
DialogParameters dialogParameters = new DialogParameters();
dialogParameters.Add("_ChannelStock", _ChannelList.channelStocks.Where(cs => cs.State == 0).ToList());
DialogServiceExtensions.ShowDialogHost(_dialogService, "AddToJiaoJieDialog", dialogParameters, DoDialogResult, "RootDialog");
}
if (_ChannelList != null)
{
AlertMsg alertMsg = new AlertMsg
{
Message = $"药品已取出,待入库",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
}
}
}

View File

@ -39,24 +39,44 @@ namespace DM_Weight.ViewModels
public void OnNavigatedFrom(NavigationContext navigationContext)
{
// 取消消息订阅
_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
_eventAggregator.GetEvent<IsSelectedEvent>().Unsubscribe(SetIsSelected);
//_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
//_eventAggregator.GetEvent<IsSelectedEvent>().Unsubscribe(SetIsSelected);
}
private List<ChannelStock> channelStocks;
public List<ChannelStock> ChannelStocks
private List<ChannelStock>? channelStocks;
public List<ChannelStock>? ChannelStocks
{
get => channelStocks;
set => SetProperty(ref channelStocks, value);
}
private ChannelStock _channelStock;
public ChannelStock _ChannelStock
{
get => _channelStock;
set => SetProperty(ref _channelStock, value);
}
private List<ChannelList>? _channelLists;
public List<ChannelList>? _ChannelLists
{
get => _channelLists;
set => SetProperty(ref _channelLists, value);
}
private ChannelList _channelList;
public ChannelList _ChannelList
{
get => _channelList;
set => SetProperty(ref _channelList, value);
}
public void OnNavigatedTo(NavigationContext navigationContext)
{
_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
_eventAggregator.GetEvent<IsSelectedEvent>().Subscribe(SetIsSelected);
//_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
//_eventAggregator.GetEvent<IsSelectedEvent>().Subscribe(SetIsSelected);
RequestData();
}
private PortUtil _portUtil;
@ -70,25 +90,59 @@ namespace DM_Weight.ViewModels
}
private void RequestData()
{
ChannelStocks?.Clear();
_ChannelLists?.Clear();
//1)查询channel_stock所有要补药的药箱
ChannelStocks = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Includes<ChannelList>(cs => cs.ChannelLst)
.Includes<DrugInfo>(cs => cs.DrugInfo)
.Where(cs => cs.MachineId == (ConfigurationManager.AppSettings["jj_machineId"] ?? "DM5") && cs.BaseQuantity > cs.Quantity)
.OrderBy(cs => cs.Chnguid)
.OrderBy(cs => cs.DrawerNo)
.ToList();
.Includes<ChannelList>(cs => cs.ChannelLst)
.Includes<DrugInfo>(cs => cs.DrugInfo)
.Where(cs => cs.MachineId == (ConfigurationManager.AppSettings["jj_machineId"] ?? "DM5"))
.OrderBy(cs => cs.Chnguid)
.OrderBy(cs => cs.DrawerNo)
.ToList();
ChannelStocks = ChannelStocks.GroupBy(it => new { it.DrawerNo, it.DrugId })
.Select(it =>
{
var ret = it.First();
ret.Quantity = it.Sum(itx => itx.Quantity);
//ret.NeedNum = it.Sum(itx => itx.NeedNum);
return ret;
})
}).Where(it => it.BaseQuantity > it.Quantity)
.ToList();
ChannelStocks.ForEach(cs => cs.AddQuantity = cs.BaseQuantity - cs.Quantity);
if (ChannelStocks != null && ChannelStocks.Count > 0)
{
ChannelStocks.ForEach(cs => cs.AddQuantity = cs.BaseQuantity-cs.Quantity);
//2)查询channel_list将1中查询的添加到channel_list的channel_stock里供页面呈现显示
List<int> DrawerNoList = ChannelStocks.Select(cs => cs.DrawerNo).Distinct().OrderBy(cs=>cs).ToList();
List<ChannelList> channelLists = new List<ChannelList>();
for (int i = 0; i < DrawerNoList.Count; i++)
{
var channelList = SqlSugarHelper.Db.Queryable<ChannelList>()
.Where(cl => cl.MachineId == (ConfigurationManager.AppSettings["jj_machineId"] ?? "DM5") && cl.DrawerNo == DrawerNoList[i])
.OrderBy(cl => cl.Id)
.OrderBy(cl => cl.DrawerNo)
.First();
if (channelList.channelStocks == null)
{
channelList.channelStocks = new List<ChannelStock>();
}
channelList.channelStocks.AddRange(ChannelStocks.Where(cs => cs.DrawerNo == DrawerNoList[i]).ToList());
if (channelList != null)
{
//if (channelList.channelStocks[0].AddToJJNum>0)
// channelList.State=1; //表示有补药
channelLists.Add(channelList);
}
}
_ChannelLists = channelLists;
}
else
{
_ChannelLists?.Clear();
_ChannelLists = new List<ChannelList>();
}
ICollectionView vw = CollectionViewSource.GetDefaultView(ChannelStocks);
vw.GroupDescriptions.Add(new PropertyGroupDescription("ChannelLst"));
}
private int _status = 0;
@ -106,307 +160,6 @@ namespace DM_Weight.ViewModels
{
get => new DelegateCommand(() => RequestData());
}
//一键补药
public DelegateCommand OpenDragCommand
{
get => new DelegateCommand(() =>
{
try
{
Status = 1;
IsEnable = false;
var varDrawerNO = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
.GroupBy(cs => cs.DrawerNo).Select(DrawerNo => DrawerNo).ToList();
iDrawerNoLst = varDrawerNO.Select(item => item.DrawerNo).ToList();
CurrentNum = 0;
_portUtil.SpeakAsync($"正在打开 {iDrawerNoLst[CurrentNum]} 号抽屉");
_portUtil.WindowName = "AddToJiaoJieWindow";
_portUtil.Operate = true;
//_portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
//_portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
_portUtil.DrawerNo = iDrawerNoLst[CurrentNum];
_portUtil.OpenAllDrawer();
}
catch (Exception ex)
{
AlertMsg alertMsg = new AlertMsg
{
Message = $"补药异常{ex.Message}",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
logger.Info($"AddToJiaoJieWindowViewModel异常{ex.Message}");
_portUtil.Operate = false;
}
});
}
void DoMyPrismEvent(DeviceMsg msg)
{
if (msg.WindowName == "AddToJiaoJieWindow")
{
switch (msg.EventType)
{
// 抽屉打开
case EventType.DRAWEROPEN:
if (Status == 1)
{
Status = 2;
}
CurrentNum += 1;
if (CurrentNum < iDrawerNoLst.Count)
{
_portUtil.WindowName = "AddToJiaoJieWindow";
_portUtil.Operate = true;
_portUtil.DrawerNo = iDrawerNoLst[CurrentNum];
_portUtil.OpenAllDrawer();
}
else
{
_portUtil.GetAllDrawerLockState();
}
break;
// 抽屉关闭
case EventType.DRAWERCLOSE:
if (Status == 2)
{
Status = 3;
}
_portUtil.Operate = false;
IsEnable = true;
CurrentNum = 0;
break;
// 数量变化
case EventType.UPDATEQUANTITY:
if (Status == 2)
{
ChannelStocks.ForEach(it => it.AddQuantity = msg.Quantitys[it.ColNo - 1]);
}
break;
// 打开失败
case EventType.OPENERROR:
AlertMsg alertMsg = new AlertMsg
{
Message = msg.Message,
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
Status = 0;
_portUtil.Operate = false;
IsEnable = false;
CurrentNum = 0;
break;
}
}
}
//完成按钮
public DelegateCommand AddFinish
{
get => new DelegateCommand(() =>
{
if (ChannelStocks.FindAll(cs => cs.ChannelLst.IsSelected).Count <= 0)
{
AlertMsg alertMsg = new AlertMsg
{
Message = "请选择药箱",
Type = MsgType.SUCCESS,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
return;
}
List<ChannelStock> jiaojieStocks = new List<ChannelStock>();
List<ChannelStock> cs = ChannelStocks.FindAll(cs => cs.ChannelLst.IsSelected).ToList();
for (int i = 0; i < cs.Count; i++)
{
ChannelStock copy = TransExpV2<ChannelStock, ChannelStock>.Trans(cs[i]);
jiaojieStocks.Add(copy);
}
csList = jiaojieStocks.FindAll(cs => cs.ChannelLst.IsSelected).GroupBy(cs => cs.DrugId).Select(g => new
{
DrugId = g.Key,
AddQuantity = g.Sum(s => s.AddQuantity)
}).Select(cs => new ChannelStock() { DrugId = cs.DrugId, AddQuantity = cs.AddQuantity }).ToList();
List<ChannelStock> channelStocks = new List<ChannelStock>();
List<string> msg = new List<string>();
for (int i = 0; i < csList.Count; i++)
{
List<ChannelStock> HasQChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Includes<DrugInfo>(cs => cs.DrugInfo)
.Where(cs => cs.Quantity > 0)
.Where(cs => cs.DrawerType == 1)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
.Where(cs => cs.DrugId == csList[i].DrugId)
.OrderBy(cs => cs.EffDate)
.OrderBy(cs => cs.DrawerNo)
.ToList();
int total = HasQChannels.Sum(it => it.Quantity);
int TakeQ = csList[i].AddQuantity;
// 说明数量足够
if (total >= TakeQ)
{
for (int j = 0; TakeQ > 0; j++)
{
ChannelStock stock = HasQChannels[j];
if (TakeQ > stock.Quantity)
{
stock.TakeQuantity = stock.Quantity;
channelStocks.Add(stock);
TakeQ -= stock.Quantity;
}
else
{
stock.TakeQuantity = TakeQ;
channelStocks.Add(stock);
TakeQ = 0;
}
}
}
else
{
msg.Add($"药品【{ChannelStocks[i].DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】");
}
}
if (msg.Count > 0)
{
DialogParameters dialogParameters = new DialogParameters();
dialogParameters.Add("msgInfo", msg);
DialogServiceExtensions.ShowDialogHost(_dialogService, "ShowMessageDialog", dialogParameters, "RootDialog");
return;
}
else
{
channelStocks.Sort((a, b) =>
{
if ((a.DrawerNo - b.DrawerNo) == 0)
{
return a.ColNo - b.ColNo;
}
return a.DrawerNo - b.DrawerNo;
});
}
List<ChannelStock> record = channelStocks.FindAll(it => it.TakeQuantity > 0).ToList();
if (record.Count > 0)
{
string InvoiceId = "AddJiaoJie_" + CurrentTimeMillis();
var f = SqlSugarHelper.Db.UseTran(() =>
{
for (int i = 0; i < record.Count; i++)
{
ChannelStock it = record[i];
// 更新数据 库存信息
SqlSugarHelper.Db.Updateable(new ChannelStock()
{
Quantity = it.Quantity - it.TakeQuantity,
ManuNo = it.ManuNo,
EffDate = it.EffDate,
Id = it.Id,
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
//更新 交接柜 库存信息
List<ChannelStock> jiaojie = jiaojieStocks.Where(cs => cs.DrugId == it.DrugId).ToList();
if (jiaojie != null && jiaojie.Count > 0)
{
for (int j = 0; j < jiaojie.Count; j++)
{
// 更新数据 交接柜 库存信息
ChannelStock jiaojie_it = jiaojie[j];
SqlSugarHelper.Db.Updateable(new ChannelStock()
{
Quantity = jiaojie_it.BaseQuantity,
//ManuNo = it.ManuNo,
//EffDate = it.EffDate,
Id = jiaojie_it.Id,
}).UpdateColumns(jiaojie_it => new { jiaojie_it.Quantity }).ExecuteCommand();
}
}
// 保存数据 出库记录
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
MachineId = it.MachineId,
DrawerNo = it.DrawerNo,
ColNo = it.ColNo,
DrugId = it.DrugId,
ManuNo = it.ManuNo,
EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
Operator = HomeWindowViewModel.Operator?.Id,
Reviewer = HomeWindowViewModel.Reviewer?.Id,
OperationTime = DateTime.Now,
Quantity = it.TakeQuantity,
Type = 2,
InvoiceId = InvoiceId
}).ExecuteCommand();
}
return true;
});
if (f.Data)
{
// 更新屏显库存
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 5);
if (singleChannels.Count > 0)
{
singleChannels.ForEach(it =>
{
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
});
}
AlertMsg alertMsg = new AlertMsg
{
Message = "补药完成,库存已更新",
Type = MsgType.SUCCESS,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
RequestData();
}
if (!f.IsSuccess)
{
AlertMsg alertMsg = new AlertMsg
{
Message = "补药操作失败,库存更新失败!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
}
else
{
AlertMsg alertMsg = new AlertMsg
{
Message = "补药数量有误",
Type = MsgType.ERROR
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
});
}
//取消
public DelegateCommand CancleAdd
{
get => new DelegateCommand(() =>
{
_portUtil.ResetData();
Status = 0;
IsEnable = true;
CurrentNum = 0;
});
}
public DelegateCommand RejectReport_Download
{
get => new DelegateCommand(() =>
@ -436,14 +189,16 @@ namespace DM_Weight.ViewModels
// DrugId = g.Key, AddQuantity = g.Sum(s => s.AddQuantity)
//}).Select(cs=>new ChannelStock() { DrugId=cs.DrugId,AddQuantity=cs.AddQuantity }).ToList();
csList = ChannelStocks.FindAll(cs => cs.ChannelLst.IsSelected).ToList();
csList = _ChannelList.channelStocks.FindAll(cs => cs.ChannelLst.IsSelected).ToList();
if (csList != null && csList.Count > 0)
{
// 此处延时1毫秒等待页面渲染
await Task.Delay(TimeSpan.FromMilliseconds(1));
DialogParameters dialogParameters = new DialogParameters();
dialogParameters.Add("ChannelStocks", csList);
dialogParameters.Add("_ChannelStock", csList);
//List<string> drugIdLst = ChannelStocks.FindAll(cs => cs.DrawerNo == _ChannelStock.DrawerNo).Select(cs => cs.DrugId).ToList();
//dialogParameters.Add("drugIdLst", drugIdLst);
DialogServiceExtensions.ShowDialogHost(_dialogService, "AddToJiaoJieDialog", dialogParameters, DoDialogResult, "RootDialog");
}
@ -451,7 +206,7 @@ namespace DM_Weight.ViewModels
{
AlertMsg alertMsg = new AlertMsg
{
Message = $"未选择药品,请先勾选要药箱号",
Message = $"未选择药品,请先点选药箱号",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
@ -469,36 +224,68 @@ namespace DM_Weight.ViewModels
//}
//MessageBox.Show("返回值:" + dialogResult.Result.ToString());
}
//设置选中药箱的复选框状态
private void SetIsSelected(ChannelStock channelStock)
//int AddToJiaoJieClickNum = 1;
////设置选中药箱的复选框状态
//private void SetIsSelected(ChannelStock channelStock)
//{
// if (channelStock != null)
// {
// //channelStock.ChannelLst.IsSelected = !channelStock.ChannelLst.IsSelected;
// if (channelStock.ChannelLst.State == 0)
// {
// channelStock.ChannelLst.IsSelected = !channelStock.ChannelLst.IsSelected;
// }
// else
// {
// return;
// }
// if (_ChannelList.channelStocks != null && _ChannelList.channelStocks != null)
// {
// _ChannelList.channelStocks = _ChannelList.channelStocks.Select(x =>
// {
// for (int i = 0; i < _ChannelList.channelStocks.Count; i++)
// {
// if (_ChannelList.channelStocks[i].DrawerNo == channelStock.DrawerNo)
// {
// _ChannelList.channelStocks[i].ChannelLst = channelStock.ChannelLst;
// }
// else
// {
// _ChannelList.channelStocks[i].ChannelLst.IsSelected = false;
// }
// }
// return x;
// }).ToList();
// }
// ICollectionView vw = CollectionViewSource.GetDefaultView(_ChannelList.channelStocks);
// vw.GroupDescriptions.Add(new PropertyGroupDescription("ChannelLst"));
// }
//}
private DelegateCommand _rowSelected;
public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(OpenOrderDialog);
public async void OpenOrderDialog()
{
if (channelStock != null)
if (_ChannelList != null && _ChannelList.channelStocks != null && _ChannelList.channelStocks.Any(cs=>cs.State==0))
{
//channelStock.ChannelLst.IsSelected = !channelStock.ChannelLst.IsSelected;
if (channelStock.ChannelLst.State == 0)
// 此处延时1毫秒等待页面渲染
await Task.Delay(TimeSpan.FromMilliseconds(1));
//选中药箱号下的所有药品id
DialogParameters dialogParameters = new DialogParameters();
dialogParameters.Add("_ChannelStock", _ChannelList.channelStocks.Where(cs=>cs.State==0).ToList());
DialogServiceExtensions.ShowDialogHost(_dialogService, "AddToJiaoJieDialog", dialogParameters, DoDialogResult, "RootDialog");
}
if(_ChannelList!=null)
{
AlertMsg alertMsg = new AlertMsg
{
channelStock.ChannelLst.IsSelected = !channelStock.ChannelLst.IsSelected;
}
else
{
return;
}
if (channelStock != null && ChannelStocks != null)
{
ChannelStocks = ChannelStocks.Select(x =>
{
for (int i = 0; i < ChannelStocks.Count; i++)
{
if (ChannelStocks[i].DrawerNo == channelStock.DrawerNo)
{
ChannelStocks[i].ChannelLst = channelStock.ChannelLst;
}
}
return x;
}).ToList();
}
ICollectionView vw = CollectionViewSource.GetDefaultView(ChannelStocks);
vw.GroupDescriptions.Add(new PropertyGroupDescription("ChannelLst"));
Message = $"药品已取出,待入库",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
}
}

View File

@ -655,6 +655,7 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
CreateTime = DateTime.Now,
//CreateTime = DateTime.Now,
InvoiceNo = SelectDrugPleaseClaim.PleaseNo
@ -687,6 +688,7 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
CreateTime = DateTime.Now,
InvoiceNo = "日结存"
}).ExecuteCommand();
if (iDayResult <= 0)
@ -720,6 +722,7 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
CreateTime = DateTime.Now,
InvoiceNo = "总结存"
}).ExecuteCommand();
if (iTotalResult <= 0)
@ -797,13 +800,13 @@ namespace DM_Weight.ViewModels
//将库位多批次的总库存数更新标签
await Task.Delay(200);
await _portUtil.WriteChannelInfoMethod(2, totalQuantity.ToString(), channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo);
_portUtil.WriteChannelInfoMethod(2, totalQuantity.ToString(), channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo);
await Task.Delay(200);
await _portUtil.WriteChannelInfoMethod(5, channelStockEffDate[0].EffDate, channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo);
_portUtil.WriteChannelInfoMethod(5, channelStockEffDate[0].EffDate, channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo);
await Task.Delay(200);
await _portUtil.WriteChannelInfoMethod(6, channelStockEffDate[0].ManuNo, channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo);
_portUtil.WriteChannelInfoMethod(6, channelStockEffDate[0].ManuNo, channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo);
await Task.Delay(200);
await _portUtil.ShowContentMethod(channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo);
_portUtil.ShowContentMethod(channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo);
}
}

View File

@ -17,6 +17,7 @@ using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.util;
using log4net;
using System.Threading;
namespace DM_Weight.ViewModels
{
@ -165,8 +166,12 @@ namespace DM_Weight.ViewModels
private void GetAllDrugInfos()
{
var list = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
DrugInfos = list;
string str = @"SELECT d.drug_id,d.py_code,d.drug_barcode,d.drug_brand_name,d.drug_spec,d.dosage,d.pack_unit,
d.manufactory,d.max_stock,CONCAT(drug_name,' ',drug_spec)as drug_name FROM `drug_info` d";
DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
//var list = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
//DrugInfos = list;
}
private void GetChannelsByDrawerNo()
@ -204,12 +209,12 @@ namespace DM_Weight.ViewModels
public DelegateCommand BindingDrug
{
get => new DelegateCommand(async () =>
get => new DelegateCommand(() =>
{
var SelectChannels = Channels.FindAll(item => item.IsSelected && item.Quantity == 0);
if(SelectChannels is null || SelectChannels.Count <= 0)
if (SelectChannels is null || SelectChannels.Count <= 0)
{
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
SnackbarMessageQueue.Enqueue("未选中库位或库位还存在药品无法绑定");
@ -240,28 +245,31 @@ namespace DM_Weight.ViewModels
_portUtil.WindowName = "BindingChannelDialog";
// 向显示屏写入库位信息
_portUtil.WriteChannelInfo(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo);
await Task.Delay(200);
Task.Delay(200);
_portUtil.WriteChannelInfo(2, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo);
await Task.Delay(200);
Task.Delay(200);
_portUtil.WriteChannelInfo(8, DrugInfo.Manufactory, item.DrawerNo, item.ColNo);
await Task.Delay(200);
Task.Delay(200);
_portUtil.ShowContent(item.DrawerNo, item.ColNo);
Task.Delay(200);
}
//_screenUtil.SetStockInfo(item, 1);
if(item.BoardType == 35)
if (item.BoardType == 35)
{
_portUtil.WindowName = "BindingChannelDialog";
await _portUtil.WriteChannelInfoMethod(1,DrugInfo.DrugName, item.DrawerNo, item.ColNo);
await Task.Delay(200);
await _portUtil.WriteChannelInfoMethod(3, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo);
await Task.Delay(200);
await _portUtil.WriteChannelInfoMethod(4, DrugInfo.Manufactory, item.DrawerNo, item.ColNo);
await Task.Delay(200);
await _portUtil.WriteChannelInfoMethod(5, item.EffDate, item.DrawerNo, item.ColNo);
await Task.Delay(200);
await _portUtil.WriteChannelInfoMethod(6, item.ManuNo, item.DrawerNo, item.ColNo);
await Task.Delay(200);
await _portUtil.ShowContentMethod(item.DrawerNo, item.ColNo);
_portUtil.WriteChannelInfoMethod(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo);
Task.Delay(200);
_portUtil.WriteChannelInfoMethod(3, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo);
Task.Delay(200);
_portUtil.WriteChannelInfoMethod(4, DrugInfo.Manufactory, item.DrawerNo, item.ColNo);
Task.Delay(200);
_portUtil.WriteChannelInfoMethod(5, item.EffDate, item.DrawerNo, item.ColNo);
Task.Delay(200);
_portUtil.WriteChannelInfoMethod(6, item.ManuNo, item.DrawerNo, item.ColNo);
Task.Delay(200);
Task.Delay(200);
_portUtil.ShowContentMethod(item.DrawerNo, item.ColNo);
Task.Delay(200);
}
}
@ -292,54 +300,64 @@ namespace DM_Weight.ViewModels
if (c > 0)
{
SelectChannels.ForEach(async (item) =>
SelectChannels.ForEach((item) =>
{
if (item.DrugId == null || !DrugInfo.DrugId.ToString().Equals(item.DrugId))
{
if (item.DrugId == null || !DrugInfo.DrugId.ToString().Equals(item.DrugId))
{
item.PosNo = 0;
}
if(DrugManuNo.EffDate!=null&& DrugManuNo.EffDate.Length>=10)
{
DrugManuNo.EffDate= DrugManuNo.EffDate.Substring(0,10);
}
item.DrugId = DrugInfo.DrugId.ToString();
item.ManuNo = DrugManuNo.ManuNo;
item.DrugInfo = DrugInfo;
item.EffDate = String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate.Length>=10? DrugManuNo.EffDate.Substring(0,10): DrugManuNo.EffDate);
SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
item.PosNo = 0;
}
if (DrugManuNo.EffDate != null && DrugManuNo.EffDate.Length >= 10)
{
DrugManuNo.EffDate = DrugManuNo.EffDate.Substring(0, 10);
}
item.DrugId = DrugInfo.DrugId.ToString();
item.ManuNo = DrugManuNo.ManuNo;
item.DrugInfo = DrugInfo;
item.EffDate = String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate.Length >= 10 ? DrugManuNo.EffDate.Substring(0, 10) : DrugManuNo.EffDate);
SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
if (item.BoardType == 5)
//_screenUtil.SetStockInfo(item, 1);
});
Task.Factory.StartNew(() =>
{
SelectChannels.ForEach((item) =>
{
_portUtil.WindowName = "BindingChannelDialog";
// 向显示屏写入库位信息
await _portUtil.WriteChannelInfo(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo);
await Task.Delay(200);
await _portUtil.WriteChannelInfo(2, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo);
await Task.Delay(200);
await _portUtil.WriteChannelInfo(8, DrugInfo.Manufactory, item.DrawerNo, item.ColNo);
await Task.Delay(200);
await _portUtil.WriteChannelInfo(6, DrugManuNo.ManuNo, item.DrawerNo, item.ColNo);
await Task.Delay(200);
await _portUtil.WriteChannelInfo(5, String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate.Length>=10? DrugManuNo.EffDate.Substring(0,10): DrugManuNo.EffDate), item.DrawerNo, item.ColNo);
await Task.Delay(200);
_portUtil.ShowContent(item.DrawerNo, item.ColNo);
}
if (item.BoardType == 35)
{
_portUtil.WindowName = "BindingChannelDialog";
await _portUtil.WriteChannelInfoMethod(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo);
await Task.Delay(200);
await _portUtil.WriteChannelInfoMethod(3, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo);
await Task.Delay(200);
await _portUtil.WriteChannelInfoMethod(4, DrugInfo.Manufactory, item.DrawerNo, item.ColNo);
await Task.Delay(200);
await _portUtil.WriteChannelInfoMethod(5, item.EffDate, item.DrawerNo, item.ColNo);
await Task.Delay(200);
await _portUtil.WriteChannelInfoMethod(6, item.ManuNo, item.DrawerNo, item.ColNo);
await Task.Delay(200);
await _portUtil.ShowContentMethod(item.DrawerNo, item.ColNo);
}
//_screenUtil.SetStockInfo(item, 1);
if (item.BoardType == 5)
{
_portUtil.WindowName = "BindingChannelDialog";
// 向显示屏写入库位信息
_portUtil.WriteChannelInfo(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo);
Thread.Sleep(200);
_portUtil.WriteChannelInfo(2, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo);
Thread.Sleep(200);
_portUtil.WriteChannelInfo(8, DrugInfo.Manufactory, item.DrawerNo, item.ColNo);
Thread.Sleep(200);
_portUtil.WriteChannelInfo(5, DrugManuNo.ManuNo, item.DrawerNo, item.ColNo);
Thread.Sleep(200);
_portUtil.WriteChannelInfo(6, String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate.Length >= 10 ? DrugManuNo.EffDate.Substring(0, 10) : DrugManuNo.EffDate), item.DrawerNo, item.ColNo);
Thread.Sleep(200);
_portUtil.ShowContent(item.DrawerNo, item.ColNo);
}
if (item.BoardType == 35)
{
_portUtil.WindowName = "BindingChannelDialog";
Thread.Sleep(200);
_portUtil.WriteChannelInfoMethod(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo);
Thread.Sleep(200);
_portUtil.WriteChannelInfoMethod(3, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo);
Thread.Sleep(200);
_portUtil.WriteChannelInfoMethod(4, DrugInfo.Manufactory, item.DrawerNo, item.ColNo);
Thread.Sleep(200);
_portUtil.WriteChannelInfoMethod(5, item.EffDate, item.DrawerNo, item.ColNo);
Thread.Sleep(200);
_portUtil.WriteChannelInfoMethod(6, item.ManuNo, item.DrawerNo, item.ColNo);
Thread.Sleep(200);
_portUtil.ShowContentMethod(item.DrawerNo, item.ColNo);
}
});
});
GetChannelsByDrawerNo();
}
@ -360,34 +378,41 @@ namespace DM_Weight.ViewModels
public DelegateCommand RemoveBinding
{
get => new DelegateCommand(async () =>
get => new DelegateCommand(() =>
{
var SelectChannels = Channels.FindAll(item => item.IsSelected && item.Quantity == 0);
var c = SelectChannels.Count;
if (c > 0)
{
SelectChannels.ForEach(async item =>
SelectChannels.ForEach(item =>
{
item.DrugId = null;
item.ManuNo = null;
item.EffDate = null;
item.DrugInfo = null;
SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate }).ExecuteCommand();
if (item.BoardType == 5)
});
Task.Factory.StartNew(() =>
{
SelectChannels.ForEach(item =>
{
// 清除显示屏库位信息
_portUtil.ClearContent(item.DrawerNo, item.ColNo);
await Task.Delay(200);
_portUtil.ShowContent(item.DrawerNo, item.ColNo);
}
if(item.BoardType == 35)
{
_portUtil.ClearContentMethod(item.DrawerNo, item.ColNo);
await Task.Delay(300);
_portUtil.ShowContentMethod(item.DrawerNo,item.ColNo);
}
if (item.BoardType == 5)
{
// 清除显示屏库位信息
_portUtil.ClearContent(item.DrawerNo, item.ColNo);
Thread.Sleep(200);
_portUtil.ShowContent(item.DrawerNo, item.ColNo);
}
if (item.BoardType == 35)
{
Thread.Sleep(200);
_portUtil.ClearContentMethod(item.DrawerNo, item.ColNo);
Thread.Sleep(200);
_portUtil.ShowContentMethod(item.DrawerNo, item.ColNo);
}
//_screenUtil.SetStockInfo(item, 1);
//_screenUtil.SetStockInfo(item, 1);
});
});
GetChannelsByDrawerNo();
}
@ -437,13 +462,13 @@ namespace DM_Weight.ViewModels
public void UpdateComboBoxItems(string text)
{
string str = @"SELECT d.drug_id,d.py_code,d.drug_barcode,d.drug_name,d.drug_brand_name,d.drug_spec,d.dosage,d.pack_unit,
d.manufactory,d.max_stock,CONCAT(drug_name,' ',drug_spec)as drug_name_spec FROM `drug_info` d";
if(string.IsNullOrEmpty(text))
d.manufactory,d.max_stock,CONCAT(drug_name,' ',drug_spec)as DrugName FROM `drug_info` d";
if (string.IsNullOrEmpty(text))
{
DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
return;
}
if(DrugInfos!=null)
if (DrugInfos != null)
{
DrugInfos.Clear();
}

View File

@ -15,6 +15,7 @@ using DM_Weight.Models;
using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.util;
using System.Threading;
namespace DM_Weight.ViewModels
{
@ -141,7 +142,7 @@ namespace DM_Weight.ViewModels
// 完成按钮
public DelegateCommand TakeFinish
{
get => new DelegateCommand(async() =>
get => new DelegateCommand(() =>
{
_isFinishClick = true;
List<ChannelStock> record = ChannelStocks.FindAll(it => it.Quantity != it.CheckQuantity).ToList();
@ -183,7 +184,7 @@ namespace DM_Weight.ViewModels
Operator = HomeWindowViewModel.Operator?.Id,
Reviewer = HomeWindowViewModel.Reviewer?.Id,
OperationTime = DateTime.Now,
Quantity = it.CheckQuantity - it.Quantity,
Quantity = it.CheckQuantity - it.Quantity,
Type = 4,
InvoiceId = InvoiceId
//,StockQuantity = nowChannels.Sum(it => it.Quantity),
@ -197,26 +198,27 @@ namespace DM_Weight.ViewModels
});
if (f.Data)
{
// 更新屏显库存
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
Task.Factory.StartNew(() =>
{
singleChannels.ForEach(async it =>
// 更新屏显库存
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
{
await Task.Delay(200);
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.CheckQuantity);
});
}
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 35)
{
for (int i = 0; i < singleChannels.Count; i++)
{
await Task.Delay(200);
await _portUtil.WriteChannelInfoMethod(2, (singleChannels[i].Quantity + singleChannels[i].AddQuantity).ToString(), singleChannels[i].DrawerNo, singleChannels[i].ColNo);
await Task.Delay(200);
await _portUtil.ShowContentMethod(singleChannels[i].DrawerNo, singleChannels[i].ColNo);
singleChannels.ForEach(it =>
{
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.CheckQuantity);
Thread.Sleep(150);
});
}
}
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 35)
{
for (int i = 0; i < singleChannels.Count; i++)
{
_portUtil.WriteQuantityMethod((singleChannels[i].CheckQuantity), singleChannels[i].DrawerNo, singleChannels[i].ColNo);
Thread.Sleep(200);
}
}
});
RequestData();
AlertMsg alertMsg = new AlertMsg
{
@ -236,6 +238,7 @@ namespace DM_Weight.ViewModels
}
Status = 0;
_isFinishClick = false;
_portUtil.OperateFinish = true;
}
else
{

View File

@ -0,0 +1,73 @@
using DM_Weight.Models;
using DM_Weight.msg;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.ViewModels
{
internal class DatetimeDialogViewModel : BindableBase, IDialogAware
{
public string Title => throw new NotImplementedException();
public event Action<IDialogResult> RequestClose;
private DateTime? _date = new DateTime();
public DateTime? Date
{
get => _date;
set
{
SetProperty(ref _date, value);
}
}
private DateTime? _time = new DateTime();
public DateTime? Time
{
get => _time;
set
{
SetProperty(ref _time, value);
}
}
public bool CanCloseDialog()
{
return true;
}
public void OnDialogClosed()
{
}
string typeS;
public void OnDialogOpened(IDialogParameters parameters)
{
DateTime o = parameters.GetValue<DateTime>("DateTime");
typeS = parameters.GetValue<string>("Type");
Date = o;
Time = o;
}
public DelegateCommand CloseAction
{
get => new DelegateCommand(() =>
{
var datetime=new DateTime(Date?.Year ?? DateTime.Now.Year, Date?.Month ?? DateTime.Now.Month, Date?.Day ?? DateTime.Now.Day,
Time?.Hour ?? DateTime.Now.Hour, Time?.Minute ?? DateTime.Now.Minute, Time?.Second ?? DateTime.Now.Second);
var result = new DialogResult(ButtonResult.OK, new DialogParameters
{
{ "DateTime", datetime },
{"Type",typeS }
});
RequestClose?.Invoke(result);
});
}
}
}

View File

@ -16,6 +16,7 @@ using DM_Weight.Models;
using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.util;
using System.Threading;
namespace DM_Weight.ViewModels
{
@ -185,7 +186,7 @@ namespace DM_Weight.ViewModels
// 完成按钮
public DelegateCommand TakeFinish
{
get => new DelegateCommand(async() =>
get => new DelegateCommand(() =>
{
if (!_isFinishClick)
{
@ -193,7 +194,7 @@ namespace DM_Weight.ViewModels
List<ChannelStock> record = ChannelStocks.FindAll(it => it.AddQuantity != 0).ToList();
if (record.Count > 0)
{
string InvoiceId = "DRAWER_" + CurrentTimeMillis();
string InvoiceId = "DRAWER_Add_" + CurrentTimeMillis();
var f = SqlSugarHelper.Db.UseTran(() =>
{
@ -214,7 +215,7 @@ namespace DM_Weight.ViewModels
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
// 获取更新完库存后的药品库存
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId.Equals(it.MachineId))
.Where(cs => cs.MachineId.Equals(it.MachineId) || cs.MachineId.Equals(ConfigurationManager.AppSettings["jj_machineId"]))
.Where(cs => cs.DrugId.Equals(it.DrugId))
.Where(cs => cs.DrawerType == 1)
.ToList();
@ -252,8 +253,9 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
CreateTime = DateTime.Now
CreateTime = DateTime.Now,
TotalStock = nowChannels.Sum(itx => itx.Quantity),
ManuStock = nowChannels.Where(itx => itx.ManuNo == it.ManuNo && itx.EffDate == it.EffDate).Sum(itx => itx.Quantity),
}).ExecuteCommand();
//修改凌晨生成的日结存数据
AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
@ -265,6 +267,7 @@ namespace DM_Weight.ViewModels
if (accountBookG2Day != null)
{
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + it.AddQuantity;
accountBookG2Day.AddQuantity = accountBookG2Day.AddQuantity + it.AddQuantity;
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
}
else
@ -283,7 +286,9 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
InvoiceNo = "日结存"
CreateTime=DateTime.Now,
InvoiceNo = "日结存",
AddQuantity=it.AddQuantity
}).ExecuteCommand();
if (iDayResult <= 0)
{
@ -315,6 +320,7 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
CreateTime = DateTime.Now,
InvoiceNo = "总结存"
}).ExecuteCommand();
if (iTotalResult <= 0)
@ -327,38 +333,41 @@ namespace DM_Weight.ViewModels
});
if (f.Data)
{
List<ChannelStock> singleChannels = 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 = singleChannels.Where(it => it.AddQuantity > 0).ToList();
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
Task.Factory.StartNew(() =>
{
//将库位多批次的总库存数更新标签
//_portUtil.WriteQuantity(singleChannels[0].DrawerNo, singleChannels[0].ColNo, singleChannels.Sum(it => it.Quantity) - singleChannels.Sum(it => it.TakeQuantity));
singleChannels.ForEach(async it =>
List<ChannelStock> singleChannels = 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 = singleChannels.Where(it => it.AddQuantity > 0).ToList();
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
{
//将库位多批次的总库存数更新标签
//_portUtil.WriteQuantity(singleChannels[0].DrawerNo, singleChannels[0].ColNo, singleChannels.Sum(it => it.Quantity) - singleChannels.Sum(it => it.TakeQuantity));
await Task.Delay(200);
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
});
}
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 35)
{
for (int i = 0; i < singleChannels.Count; i++)
{
await Task.Delay(200);
await _portUtil.WriteChannelInfoMethod(2, (singleChannels[i].Quantity + singleChannels[i].AddQuantity).ToString(), singleChannels[i].DrawerNo, singleChannels[i].ColNo);
await Task.Delay(200);
await _portUtil.ShowContentMethod(singleChannels[i].DrawerNo, singleChannels[i].ColNo);
singleChannels.ForEach(it =>
{
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
Thread.Sleep(150);
});
}
}
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 35)
{
for (int i = 0; i < singleChannels.Count; i++)
{
_portUtil.WriteQuantityMethod((singleChannels[i].Quantity + singleChannels[i].AddQuantity), singleChannels[i].DrawerNo, singleChannels[i].ColNo);
//await _portUtil.WriteChannelIn foMethod(2, (singleChannels[i].Quantity + singleChannels[i].AddQuantity).ToString(), singleChannels[i].DrawerNo, singleChannels[i].ColNo);
//await Task.Delay(200);
//await _portUtil.ShowContentMethod(singleChannels[i].DrawerNo, singleChannels[i].ColNo);
Thread.Sleep(200);
}
}
});
RequestData();
AlertMsg alertMsg = new AlertMsg
{
@ -378,6 +387,7 @@ namespace DM_Weight.ViewModels
}
Status = 0;
_isFinishClick = false;
_portUtil.OperateFinish = true;
}
else
{
@ -402,6 +412,7 @@ namespace DM_Weight.ViewModels
{
_portUtil.ResetData();
Status = 0;
_portUtil.OperateFinish = true;
});
}

View File

@ -39,7 +39,7 @@ namespace DM_Weight.ViewModels
private static readonly DateTime Jan1st1970 = new DateTime
(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
private bool _openBoxVisibility=false;
private bool _openBoxVisibility = false;
public bool OpenBoxVisibility
{
get => _openBoxVisibility;
@ -194,7 +194,7 @@ namespace DM_Weight.ViewModels
logger.Info("点击完成按钮,库位数据:" + JsonConvert.SerializeObject(record));
if (record.Count > 0)
{
string InvoiceId = "DRAWER_" + CurrentTimeMillis();
string InvoiceId = "DRAWER_Take_" + CurrentTimeMillis();
var f = SqlSugarHelper.Db.UseTran(() =>
{
@ -213,7 +213,7 @@ namespace DM_Weight.ViewModels
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
// 获取更新完库存后的药品库存
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId.Equals(it.MachineId))
.Where(cs => cs.MachineId.Equals(it.MachineId) || cs.MachineId.Equals(ConfigurationManager.AppSettings["jj_machineId"]))
.Where(cs => cs.DrugId.Equals(it.DrugId))
.Where(cs => cs.DrawerType == 1)
.ToList();
@ -251,7 +251,9 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
CreateTime = DateTime.Now
CreateTime = DateTime.Now,
TotalStock = nowChannels.Sum(itx => itx.Quantity),
ManuStock = nowChannels.Where(itx => itx.ManuNo == it.ManuNo && itx.EffDate == it.EffDate).Sum(itx => itx.Quantity)
}).ExecuteCommand();
//修改凌晨生成的日结存数据
@ -264,6 +266,7 @@ namespace DM_Weight.ViewModels
if (accountBookG2Day != null)
{
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - it.TakeQuantity;
accountBookG2Day.OutQuantity = accountBookG2Day.OutQuantity + accountBookG2Day.OutQuantity;
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
}
else
@ -282,7 +285,9 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
InvoiceNo = "日结存"
CreateTime = DateTime.Now,
InvoiceNo = "日结存",
OutQuantity=it.TakeQuantity
}).ExecuteCommand();
if (iDayResult <= 0)
{
@ -314,6 +319,7 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
CreateTime = DateTime.Now,
InvoiceNo = "总结存"
}).ExecuteCommand();
if (iTotalResult <= 0)
@ -339,27 +345,33 @@ namespace DM_Weight.ViewModels
return ret;
}).ToList();
singleChannels = singleChannels.Where(it => it.TakeQuantity > 0).ToList();
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
Task.Factory.StartNew(() =>
{
//将库位多批次的总库存数更新标签
//_portUtil.WriteQuantity(singleChannels[0].DrawerNo, singleChannels[0].ColNo, singleChannels.Sum(it => it.Quantity) - singleChannels.Sum(it => it.TakeQuantity));
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
{
//将库位多批次的总库存数更新标签
//_portUtil.WriteQuantity(singleChannels[0].DrawerNo, singleChannels[0].ColNo, singleChannels.Sum(it => it.Quantity) - singleChannels.Sum(it => it.TakeQuantity));
singleChannels.ForEach(async it =>
singleChannels.ForEach(it =>
{
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
Thread.Sleep(150);
});
}
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 35)
{
await Task.Delay(200);
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
});
}
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 35)
{
singleChannels.ForEach(async it =>
{
await Task.Delay(200);
await _portUtil.WriteChannelInfoMethod(2, (it.Quantity - it.TakeQuantity).ToString(), it.DrawerNo, it.ColNo);
await Task.Delay(200);
await _portUtil.ShowContentMethod(it.DrawerNo, it.ColNo);
});
}
singleChannels.ForEach(it =>
{
//await Task.Delay(200);
//_portUtil.WriteChannelInfoMethod(2, (it.Quantity - it.TakeQuantity).ToString(), it.DrawerNo, it.ColNo);
//await Task.Delay(200);
//_portUtil.ShowContentMethod(it.DrawerNo, it.ColNo);
_portUtil.WriteQuantityMethod((it.Quantity - it.TakeQuantity), it.DrawerNo, it.ColNo);
Thread.Sleep(200);
});
}
});
RequestData();
AlertMsg alertMsg = new AlertMsg
{
@ -379,6 +391,7 @@ namespace DM_Weight.ViewModels
}
Status = 0;
_isFinishClick = false;
_portUtil.OperateFinish = true;
}
else
{
@ -403,6 +416,7 @@ namespace DM_Weight.ViewModels
{
_portUtil.ResetData();
Status = 0;
_portUtil.OperateFinish = true;
});
}

View File

@ -16,6 +16,7 @@ using DM_Weight.msg;
using Prism.Events;
using System.Configuration;
using static Unity.Storage.RegistrationSet;
using SqlSugar;
namespace DM_Weight.ViewModels
{
@ -306,7 +307,7 @@ namespace DM_Weight.ViewModels
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
RequestData();
}, () => SelectedDrug.DrugId !=null).ObservesProperty(() => SelectedDrug);
}, () => SelectedDrug.DrugId != null).ObservesProperty(() => SelectedDrug);
}
public DelegateCommand AddManuCommand
@ -322,7 +323,7 @@ namespace DM_Weight.ViewModels
GetManuNos();
}
}, () => SelectedDrug.DrugId !=null).ObservesProperty(() => SelectedDrug);
}, () => SelectedDrug.DrugId != null).ObservesProperty(() => SelectedDrug);
}
public DelegateCommand EditManuCommand
@ -362,17 +363,28 @@ namespace DM_Weight.ViewModels
{
int totalCount = 0;
DrugInfos = SqlSugarHelper.Db.Queryable<DrugInfo>()
.Includes(di => di.drugBase)
//.LeftJoin<DrugBase>((di, db) => di.DrugId == db.DrugId && db.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
.Includes(di=>di.drugBase)
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (di) => di.DrugId.ToString().Contains(SearchValue))
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (di) => di.DrugName.Contains(SearchValue))
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (di) => di.PyCode.Contains(SearchValue))
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (di) => di.DrugBarcode.Contains(SearchValue))
//.Select(di => di)
//.Select((di, db) => new DrugInfo()
//{
// DrugName = di.DrugName,
// DrugId = di.DrugId,
// DrugBarcode = di.DrugBarcode,
// DrugSpec = di.DrugSpec,
// PyCode = di.PyCode,
// PackUnit=di.PackUnit,
// Manufactory=di.Manufactory,
// drugBase = db,
//})
.ToPageList(PageNum, PageSize, ref totalCount);
foreach(DrugInfo di in DrugInfos)
foreach (DrugInfo di in DrugInfos)
{
if(di.drugBase==null)
if (di.drugBase == null)
{
di.drugBase = new DrugBase();
}

View File

@ -0,0 +1,105 @@
using DM_Weight.Models;
using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.util;
using log4net;
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using Prism.Regions;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Threading;
namespace DM_Weight.ViewModels
{
public class EmergencyWindowViewModel : BindableBase, IRegionMemberLifetime, INavigationAware
{
private readonly ILog logger = LogManager.GetLogger(typeof(HomeWindowViewModel));
IEventAggregator _eventAggregator;
private PortUtil _portUtil;
IRegionManager _regionManager;
private bool _dbConnectionFail = !App.DbConnectionFail;
public bool DBConnectionStatus { get => _dbConnectionFail; set => SetProperty(ref _dbConnectionFail, value); }
private int _status;
public int Status { get => _status; set => SetProperty(ref _status, value); }
public EmergencyWindowViewModel(IRegionManager regionManager, PortUtil portUtil, IEventAggregator eventAggregator)
{
_portUtil = portUtil;
_eventAggregator = eventAggregator;
_regionManager = regionManager;
}
public DelegateCommand<string> OpenDrawer
{
get => new DelegateCommand<string>((DrawerNo) =>
{
//应急开锁
logger.Info($"应急开锁正在打开{DrawerNo}号抽屉");
Status = 1;
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
_portUtil.WindowName = "EmergencyWindow";
_portUtil.BoardType = 1;
_portUtil.ColNos = new int[] { 1 };
_portUtil.DrawerNo = Convert.ToInt32(DrawerNo);
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Normal, () => _portUtil.OpenDrawer());
}
);
}
private DelegateCommand? _exitCommand;
public DelegateCommand ExitCommand => _exitCommand ??= new DelegateCommand(Exit);
void Exit()
{
Process.GetCurrentProcess().Kill();
Environment.Exit(0);
}
public DelegateCommand ReturnLoginDelegate
{
get => new DelegateCommand(() =>
{
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
});
}
//间隔1分钟查询数据库连接状态
private void CheckDBConnect()
{
new PromiseUtil<int>().taskAsyncLoop(60000, 0, async (options, next, stop) =>
{
try
{
var userList = SqlSugarHelper.Db.Queryable<UserList>()
.First(u => u.UserName == "admin");
App.DbConnectionFail = false;
DBConnectionStatus = true;
stop();
}
catch (Exception ex)
{
next();
}
});
}
public bool KeepAlive => false;
public void OnNavigatedTo(NavigationContext navigationContext)
{
DBConnectionStatus = !App.DbConnectionFail;
CheckDBConnect();
}
public bool IsNavigationTarget(NavigationContext navigationContext)
{
return true;
}
public void OnNavigatedFrom(NavigationContext navigationContext)
{
}
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.ViewModels
{
internal class EmptyWindowViewModel
{
}
}

View File

@ -161,7 +161,7 @@ namespace DM_Weight.ViewModels
// }
// }
// }
SetProperty(ref _selectedChildMenu, value);
SetProperty(ref _selectedChildMenu, value);
//}
}
}
@ -192,6 +192,7 @@ namespace DM_Weight.ViewModels
logger.Info($"未关闭抽屉切换菜单");
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
SnackbarMessageQueue.Enqueue("请关闭抽屉后再切换菜单");
return;
}
}
}
@ -214,17 +215,19 @@ namespace DM_Weight.ViewModels
logger.Info($"用户【{Operator?.Nickname}】退出登录");
Operator = null;
Reviewer = null;
System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
{
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
}));
//_regionManager.RequestNavigate("MainRegion", "BeforeLogin");
//System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
//{
_regionManager.RequestNavigate("ContentRegion", "EmptyWindow");
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
//}));
//_regionManager.RequestNavigate("MainRegion", "BeforeLogin");
}
else
{
//SelectedMenu.Children = SelectedMenu.Children;
SelectedChildMenu = SelectedMenu.Children[0];
//SelectedChildMenu = SelectedMenu.Children[0];
if (!_portUtil.Operate)
{
_regionManager.RequestNavigate("ContentRegion", SelectedMenu.Children[0].PremissionPath);
@ -346,6 +349,8 @@ namespace DM_Weight.ViewModels
IEventAggregator _eventAggregator;
public HomeWindowViewModel(IRegionManager iRegionManager, PortUtil portUtil, IDialogService dialogService, IUnityContainer container, IEventAggregator eventAggregator)
{
logger.Info("HomeWindowViewModel");
_portUtil = portUtil;
_regionManager = iRegionManager;
_dialogService = dialogService;
@ -489,7 +494,7 @@ namespace DM_Weight.ViewModels
//public DelegateCommand CheckWDCommand { get => new DelegateCommand(CheckAction); }
//private void CheckAction()
//{
//GetWD();
//GetWD();
//}
@ -521,6 +526,7 @@ namespace DM_Weight.ViewModels
Reviewer = null;
Application.Current.Dispatcher.Invoke(() =>
{
_regionManager.RequestNavigate("ContentRegion", "EmptyWindow");
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
});
AlertMsg alertMsg = new AlertMsg
@ -538,34 +544,61 @@ namespace DM_Weight.ViewModels
SelectedChildMenu = premissions[0].Children[0];
_regionManager.RequestNavigate("ContentRegion", premissions[0].Children[0].PremissionPath);
FindDrawerCount();
int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
int stopRecord = Convert.ToInt32(ConfigurationManager.AppSettings["stopRecord"] ?? "0");
if (autoExit > 0)
{
System.Timers.Timer timer = new System.Timers.Timer();
timer.Interval = 1000;
timer.Elapsed += (sender, e) =>
//int interval = autoExit * 1000;
new PromiseUtil<int>().taskAsyncLoop(1000, 0, async (options, next, stop) =>
{
// 串口无人操作
if (!_portUtil.Operate)
try
{
// 30秒内无人操作鼠标键盘
if ((DateTime.Now - _portUtil.dateTime).TotalSeconds > autoExit && CheckComputerFreeState.GetLastInputTime() > autoExit)
if (!_portUtil.Operate &&_portUtil.OperateFinish)
{
logger.Info($"设备30秒内无人操作用户【{Operator?.Nickname}】自动退出登录");
//_chkFunction.HIKStopDVRRecord();
Operator = null;
Reviewer = null;
Application.Current.Dispatcher.Invoke(() =>
// 无人操作鼠标键盘
if ((DateTime.Now - _portUtil.dateTime).TotalSeconds > autoExit && CheckComputerFreeState.GetLastInputTime() > autoExit)
{
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
timer.Stop();
});
logger.Info($"设备{autoExit}内无人操作,用户【{Operator?.Nickname}】自动退出登录,_portUtil.Operate:{_portUtil.Operate},totalSecond:{(DateTime.Now - _portUtil.dateTime).TotalSeconds},lastInputTime:{CheckComputerFreeState.GetLastInputTime()},autoExit:{autoExit}");
Operator = null;
Reviewer = null;
//Application.Current.Dispatcher.Invoke(() =>
//{
stop();
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("MainRegion", "LoginWindow");
}));
//});
//timer.Dispose();
}
else
{
if (Operator == null)
{
stop();
}
else
{
next();
}
}
}
else
{
_portUtil.dateTime = DateTime.Now;
next();
}
}
};
timer.Start();
catch (Exception ex)
{
logger.Info($"自动退出异常:{ex.Message}");
}
});
}
//#region 温度查询定时
//int interval = Convert.ToInt32(ConfigurationManager.AppSettings["Interval"]);

View File

@ -224,7 +224,7 @@ namespace DM_Weight.ViewModels
// 完成按钮
public DelegateCommand TakeFinish
{
get => new DelegateCommand(async () =>
get => new DelegateCommand(() =>
{
if (!_isFinishClick)
{
@ -233,14 +233,16 @@ namespace DM_Weight.ViewModels
string InvoiceId = Invoice.InvoiceNo;
var f = SqlSugarHelper.Db.UseTran(() =>
{
SqlSugarHelper.Db.Updateable(new InOutInvoice()
{
Status = 1,
InvoiceNo = Invoice.InvoiceNo
}).UpdateColumns(it => new { it.Status }).WhereColumns(it => new { it.InvoiceNo }).ExecuteCommand();
for (int i = 0; i < record.Count; i++)
{
SqlSugarHelper.Db.Updateable(new InOutInvoice()
{
Status = 3,
InvoiceNo = Invoice.InvoiceNo,
DrugId= record[i].DrugId,
DrugManuNo = record[i].ManuNo
}).UpdateColumns(it => new { it.Status }).WhereColumns(it => new { it.InvoiceNo,it.DrugId,it.DrugManuNo }).ExecuteCommand();
ChannelStock it = record[i];
if (it.BoardType == 6 && it.PosNo == 0)
{
@ -257,8 +259,9 @@ namespace DM_Weight.ViewModels
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
// 获取更新完库存后的药品库存
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId.Equals(it.MachineId))
.Where(cs => cs.MachineId.Equals(it.MachineId)||cs.MachineId.Equals(ConfigurationManager.AppSettings["jj_machineId"]))
.Where(cs => cs.DrugId.Equals(it.DrugId))
.Where(cs=>cs.ManuNo.Equals(it.ManuNo))
.Where(cs => cs.DrawerType == 1)
.ToList();
@ -280,6 +283,12 @@ namespace DM_Weight.ViewModels
//,StockQuantity = nowChannels.Sum(it => it.Quantity)
}).ExecuteCommand();
//查询上一条账册中的空瓶数
AccountBookG2 accountBookEmpty = SqlSugarHelper.Db.Queryable<AccountBookG2>()
.Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["machineId"].ToString()))
.Where(ab => ab.Type == 1 || ab.Type == 2)
.Where(ab => ab.DrugId == it.DrugId)
.Where(ab => ab.ManuNo == it.ManuNo).OrderByDescending(ab => ab.Id).First();
//保存账册
SqlSugarHelper.Db.Insertable(new AccountBookG2()
{
@ -294,7 +303,9 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
CreateTime = DateTime.Now
CreateTime = DateTime.Now,
ManuStock= nowChannels.Sum(it => it.Quantity),
TotalStock= (accountBookEmpty!=null?(accountBookEmpty.TotalStock>0&& accountBookEmpty.TotalStock>it.AddQuantity ? accountBookEmpty.TotalStock - it.AddQuantity : 0):0) //负数直接记0
}).ExecuteCommand();
//修改凌晨生成的日结存数据
@ -307,6 +318,7 @@ namespace DM_Weight.ViewModels
if (accountBookG2Day != null)
{
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + it.AddQuantity;
accountBookG2Day.AddQuantity = accountBookG2Day.AddQuantity + it.AddQuantity;
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
}
else
@ -325,7 +337,9 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
InvoiceNo = "日结存"
CreateTime=DateTime.Now,
InvoiceNo = "日结存",
AddQuantity=it.AddQuantity
}).ExecuteCommand();
if (iDayResult <= 0)
{
@ -357,7 +371,9 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
InvoiceNo = "总结存"
CreateTime = DateTime.Now,
InvoiceNo = "总结存",
AddQuantity = it.AddQuantity
}).ExecuteCommand();
if (iTotalResult <= 0)
{
@ -369,27 +385,31 @@ namespace DM_Weight.ViewModels
});
if (f.Data)
{
// 更新屏显库存
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
Task.Factory.StartNew(() =>
{
singleChannels.ForEach(async it =>
// 更新屏显库存
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
{
await Task.Delay(200);
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
});
}
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 35)
{
for (int i = 0; i < singleChannels.Count; i++)
{
await Task.Delay(200);
await _portUtil.WriteChannelInfoMethod(2, (singleChannels[i].Quantity + singleChannels[i].AddQuantity).ToString(), singleChannels[i].DrawerNo, singleChannels[i].ColNo);
await Task.Delay(200);
await _portUtil.ShowContentMethod(singleChannels[i].DrawerNo, singleChannels[i].ColNo);
singleChannels.ForEach(it =>
{
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
Thread.Sleep(100);
});
}
}
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 35)
{
for (int i = 0; i < singleChannels.Count; i++)
{
//await Task.Delay(200);
//_portUtil.WriteChannelInfoMethod(2, (singleChannels[i].Quantity + singleChannels[i].AddQuantity).ToString(), singleChannels[i].DrawerNo, singleChannels[i].ColNo);
//await Task.Delay(200);
//_portUtil.ShowContentMethod(singleChannels[i].DrawerNo, singleChannels[i].ColNo);
_portUtil.WriteQuantityMethod((singleChannels[i].Quantity + singleChannels[i].AddQuantity), singleChannels[i].DrawerNo, singleChannels[i].ColNo);
Thread.Sleep(200);
}
}
});
AlertMsg alertMsg = new AlertMsg
{
@ -410,7 +430,7 @@ namespace DM_Weight.ViewModels
Status = 0;
_isFinishClick = false;
RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
_portUtil.OperateFinish = true;
}
});
@ -429,6 +449,7 @@ namespace DM_Weight.ViewModels
RequestData();
_portUtil.ResetData();
Status = 0;
_portUtil.OperateFinish = true;
});
}

View File

@ -8,6 +8,7 @@ using Prism.Events;
using Prism.Mvvm;
using Prism.Regions;
using Prism.Services.Dialogs;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@ -194,18 +195,41 @@ namespace DM_Weight.ViewModels
ChannelStocks.Clear();
InOutInvoices.Clear();
List<ChannelStock> i = new List<ChannelStock>();
//string strMsg = string.Empty;
if (SelectedInvoice != null)
{
var invoices = SqlSugarHelper.Db.Queryable<InOutInvoice>()
.Includes<DrugInfo>(i => i.DrugInfo)
.InnerJoin(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)
.Where(i => i.InvoiceNo == SelectedInvoice.InvoiceNo)
.ToList();
.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
)
.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)
{
List<ChannelStock> q = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Includes<DrugInfo>(cs => cs.DrugInfo)
.WhereIF(!string.IsNullOrEmpty(invoice.DrugEffDate), cs => cs.EffDate.Equals(invoice.DrugEffDate))
.WhereIF(!string.IsNullOrEmpty(invoice.DrugEffDate), cs => cs.EffDate.Equals(invoice.DrugEffDate.Substring(0, 10)))
.WhereIF(!string.IsNullOrEmpty(invoice.DrugManuNo), cs => cs.ManuNo.Equals(invoice.DrugManuNo))
.Where(cs => cs.DrugId == invoice.DrugId)
.Where(cs => cs.DrawerType == 1)
@ -215,14 +239,23 @@ namespace DM_Weight.ViewModels
.OrderBy(cs => cs.ColNo)
.ToList();
for (int j = 0; j < q.Count;j++)
if (q.Count <= 0)
{
//strMsg += $"药品{invoice.DrugInfo.DrugName}未绑定;";
ChannelStock cs = new ChannelStock();
cs.ColNo = -1;
cs.EffDate = invoice.DrugEffDate;
cs.ManuNo = invoice.DrugManuNo;
cs.DrugInfo = invoice.DrugInfo;
cs.Quantity = 0;
q.Add(cs);
}
for (int j = 0; j < q.Count; j++)
{
ChannelStock item = q[j];
if(j == 0)
if (j == 0)
{
invoice.quantity = invoice.Units == "盒" ? invoice.quantity * invoice.DrugInfo.ConvertRatio : invoice.quantity;
item.AddQuantity = invoice.quantity;
}
item.Invoice = invoice;
@ -235,7 +268,26 @@ namespace DM_Weight.ViewModels
ICollectionView vw = CollectionViewSource.GetDefaultView(i);
vw.GroupDescriptions.Add(new PropertyGroupDescription("Invoice"));
ChannelStocks = i;
//if (ChannelStocks == null || ChannelStocks.Count <= 0)
//{
// AlertMsg alertMsg = new AlertMsg
// {
// Message = "调拨单内药品未绑定,请先绑定",
// Type = MsgType.ERROR,
// };
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
// return;
//}
//if (strMsg.Length > 0)
//{
// AlertMsg alertMsg = new AlertMsg
// {
// Message = strMsg,
// Type = MsgType.ERROR,
// };
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
// return;
//}
}
public DelegateCommand OpenInvoiceAdd
@ -243,18 +295,28 @@ namespace DM_Weight.ViewModels
get => new DelegateCommand(() =>
{
bool flag = true;
for (int i = 0; i < InOutInvoices.Count; i++)
{
InOutInvoice invoices = InOutInvoices[i];
if (invoices.quantity != ChannelStocks.FindAll(it => it.DrugId == invoices.DrugId).Sum(it => it.AddQuantity))
{
flag = false;
break;
}
}
//for (int i = 0; i < InOutInvoices.Count; i++)
//{
// InOutInvoice invoices = InOutInvoices[i];
// if (invoices.quantity != ChannelStocks.FindAll(it => it.DrugId == invoices.DrugId).Sum(it => it.AddQuantity))
// {
// flag = false;
// break;
// }
//}
if (flag)
{
AddChannels = ChannelStocks.FindAll(it => it.AddQuantity != 0);
AddChannels = ChannelStocks.FindAll(it => it.AddQuantity != 0 && it.Location != "未绑定");
if (AddChannels == null || AddChannels.Count <= 0)
{
AlertMsg alertMsg = new AlertMsg
{
Message = "药品未绑定或未输入数量",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
return;
}
AddChannels.Sort((a, b) =>
{
if ((a.DrawerNo - b.DrawerNo) == 0)
@ -264,16 +326,17 @@ namespace DM_Weight.ViewModels
return a.DrawerNo - b.DrawerNo;
});
OpenOrderDialog();
} else
{
AlertMsg alertMsg = new AlertMsg
{
Message = "库位添加数量小于应添加数量",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
},() => SelectedInvoice !=null).ObservesProperty(() => SelectedInvoice);
//else
//{
// AlertMsg alertMsg = new AlertMsg
// {
// Message = "库位添加数量小于应添加数量",
// Type = MsgType.ERROR,
// };
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
//}
}, () => SelectedInvoice != null).ObservesProperty(() => SelectedInvoice);
}
@ -323,16 +386,17 @@ namespace DM_Weight.ViewModels
int totalCount = 0;
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(" inner join ( select c.drug_id as drug_id from channel_stock c where c.machine_id = '" + (ConfigurationManager.AppSettings["machineId"] ?? "DM1") + "' group by c.drug_id ) di on di.drug_id = i.drug_id");
sb.Append("select i.invoice_no as InvoiceNo, i.invoice_date as InvoiceDate, COUNT(i.id) as `Count`, SUM(IF(i.units='盒',i.quantity*dr.convert_ratio,i.quantity)) as quantity, p1.pharmacy_name as PharmacyName1, p2.pharmacy_name as PharmacyName2 from in_out_invoice i");
sb.Append(" inner join drug_info dr on i.drug_id=dr.drug_id ");
sb.Append(" left join ( select c.drug_id as drug_id from channel_stock 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");
sb.Append(" where i.status=@Status ");
sb.Append(" and i.type!=@type ");
sb.Append(" and i.type=@type ");
sb.Append(" and i.cancel_flag=@CancelFlag ");
if (OrderDate != null)
{
sb.Append(" and i.invoice_date = @CreateTime ");
sb.Append(" and DATE_FORMAT(i.invoice_date,'%Y-%m-%d') = @CreateTime ");
}
if (!String.IsNullOrEmpty(SearchValue))
{
@ -347,7 +411,7 @@ namespace DM_Weight.ViewModels
Invoices = SqlSugarHelper.Db.SqlQueryable<dynamic>(sb.ToString())
.AddParameters(new
{
Status = 0,
Status = 1,
type = 2,
CancelFlag = 0,
CreateTime = OrderDate,

View File

@ -288,7 +288,7 @@ namespace DM_Weight.ViewModels
// 完成按钮
public DelegateCommand TakeFinish
{
get => new DelegateCommand(async() =>
get => new DelegateCommand(() =>
{
if (!_isFinishClick)
{
@ -301,7 +301,7 @@ namespace DM_Weight.ViewModels
{
SqlSugarHelper.Db.Updateable(new InOutInvoice()
{
Status = 1,
Status = 3,
InvoiceNo = Invoice.InvoiceNo
}).UpdateColumns(it => new { it.Status }).WhereColumns(it => new { it.InvoiceNo }).ExecuteCommand();
@ -318,7 +318,7 @@ namespace DM_Weight.ViewModels
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
// 获取更新完库存后的药品库存
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId.Equals(it.MachineId))
.Where(cs => cs.MachineId.Equals(it.MachineId) || cs.MachineId.Equals(ConfigurationManager.AppSettings["jj_machineId"]))
.Where(cs => cs.DrugId.Equals(it.DrugId))
.Where(cs => cs.DrawerType == 1)
.ToList();
@ -357,7 +357,9 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
CreateTime = DateTime.Now
CreateTime = DateTime.Now,
TotalStock = nowChannels.Sum(itx => itx.Quantity),
ManuStock = nowChannels.Where(itx => itx.ManuNo == it.ManuNo && itx.EffDate == it.EffDate).Sum(itx => itx.Quantity)
}).ExecuteCommand();
//修改凌晨生成的日结存数据
@ -370,6 +372,7 @@ namespace DM_Weight.ViewModels
if (accountBookG2Day != null)
{
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - it.TakeQuantity;
accountBookG2Day.OutQuantity = accountBookG2Day.OutQuantity + it.TakeQuantity;
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
}
else
@ -388,7 +391,9 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
InvoiceNo = "日结存"
CreateTime = DateTime.Now,
InvoiceNo = "日结存",
OutQuantity=it.TakeQuantity
}).ExecuteCommand();
if (iDayResult <= 0)
{
@ -420,6 +425,7 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
CreateTime = DateTime.Now,
InvoiceNo = "总结存"
}).ExecuteCommand();
if (iTotalResult <= 0)
@ -433,26 +439,31 @@ namespace DM_Weight.ViewModels
});
if (f.Data)
{
// 更新屏显库存
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
Task.Factory.StartNew(() =>
{
singleChannels.ForEach(async it =>
// 更新屏显库存
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
{
await Task.Delay(200);
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
});
}
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 35)
{
for (int i = 0; i < singleChannels.Count; i++)
{
await Task.Delay(200);
await _portUtil.WriteChannelInfoMethod(2, (singleChannels[i].Quantity - singleChannels[i].TakeQuantity).ToString(), singleChannels[i].DrawerNo, singleChannels[i].ColNo);
await Task.Delay(200);
await _portUtil.ShowContentMethod(singleChannels[i].DrawerNo, singleChannels[i].ColNo);
singleChannels.ForEach(it =>
{
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
Thread.Sleep(100);
});
}
}
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 35)
{
for (int i = 0; i < singleChannels.Count; i++)
{
//await Task.Delay(200);
//_portUtil.WriteChannelInfoMethod(2, (singleChannels[i].Quantity - singleChannels[i].TakeQuantity).ToString(), singleChannels[i].DrawerNo, singleChannels[i].ColNo);
//await Task.Delay(200);
//_portUtil.ShowContentMethod(singleChannels[i].DrawerNo, singleChannels[i].ColNo);
_portUtil.WriteQuantityMethod((singleChannels[i].Quantity - singleChannels[i].TakeQuantity), singleChannels[i].DrawerNo, singleChannels[i].ColNo);
Thread.Sleep(200);
}
}
});
AlertMsg alertMsg = new AlertMsg
{
Message = "调拨取药完成,库存已更新",
@ -472,6 +483,7 @@ namespace DM_Weight.ViewModels
Status = 0;
_isFinishClick = false;
RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
_portUtil.OperateFinish = true;
}
else
{
@ -501,6 +513,7 @@ namespace DM_Weight.ViewModels
{
_portUtil.ResetData();
Status = 0;
_portUtil.OperateFinish = true;
});
}

View File

@ -1,6 +1,14 @@
using log4net;
using DM_Weight.Finger;
using DM_Weight.HIKVISION;
using DM_Weight.Models;
using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.util;
using DM_Weight.Views;
using log4net;
using log4net.Core;
using log4net.Repository.Hierarchy;
using Microsoft.Win32;
using Prism.Commands;
using Prism.Events;
using Prism.Ioc;
@ -8,29 +16,25 @@ using Prism.Mvvm;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Security.AccessControl;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using DM_Weight.Finger;
using DM_Weight.Models;
using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.util;
using DM_Weight.Views;
using System.Collections.ObjectModel;
using Microsoft.Win32;
using System.Windows.Threading;
using System.Xml;
using System.Diagnostics;
using DM_Weight.HIKVISION;
using System.Security.AccessControl;
namespace DM_Weight.ViewModels
{
public class LoginWindowViewModel : BindableBase, IRegionMemberLifetime, IConfirmNavigationRequest
{
private readonly ILog logger = LogManager.GetLogger(typeof(LoginWindowViewModel));
private string username;
@ -60,7 +64,7 @@ namespace DM_Weight.ViewModels
get => ReadAppSetting("loginUser");
}
private HkcChangeShifts listHkcChangeShifts=new HkcChangeShifts();
private HkcChangeShifts listHkcChangeShifts = new HkcChangeShifts();
private FingerprintUtil _fingerprintUtil;
@ -117,7 +121,7 @@ namespace DM_Weight.ViewModels
//_chkFunction= chcFunction;
_regionManager = regionManager;
_eventAggregator = eventAggregator;
_eventAggregator.GetEvent<FingerprintEvent>().Subscribe(LoginEvent);
//_eventAggregator.GetEvent<FingerprintEvent>().Subscribe(LoginEvent);
}
private DelegateCommand? _loginCommand;
@ -180,7 +184,7 @@ _exitCommand ??= new DelegateCommand(Exit);
Username = "";
Password = "";
}
else if (userList.Role == null|| userList.Role.Permissions.Count<=0)
else if (userList.Role == null || userList.Role.Permissions.Count <= 0)
{
AlertMsg alertMsg = new AlertMsg
{
@ -201,7 +205,7 @@ _exitCommand ??= new DelegateCommand(Exit);
.Where(cs => cs.State == "0").First();
if (listHkcChangeShifts != null)
{
if(!listHkcChangeShifts.FromOperator.Equals(userList.UserName) && !listHkcChangeShifts.FromRviewer.Equals(userList.UserName))
if (!listHkcChangeShifts.FromOperator.Equals(userList.UserName) && !listHkcChangeShifts.FromRviewer.Equals(userList.UserName))
{
AlertMsg alertMsg = new AlertMsg
{
@ -257,7 +261,8 @@ _exitCommand ??= new DelegateCommand(Exit);
keys.Add("operator", user);
//System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
//{
_regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
logger.Info("跳转home页面");
_regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
//}));
}
// 双人登录模式
@ -273,7 +278,7 @@ _exitCommand ??= new DelegateCommand(Exit);
RaisePropertyChanged("Reviewer");
//System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
//{
_regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
_regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
//}));
}
@ -297,7 +302,7 @@ _exitCommand ??= new DelegateCommand(Exit);
RaisePropertyChanged("Operator");
//System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
//{
_regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
_regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
//}));
}
@ -317,9 +322,9 @@ _exitCommand ??= new DelegateCommand(Exit);
//1仅当班人、审核人可登录
if (LoginUserCheck.Equals("1"))
{
if(listHkcChangeShifts!=null)
if (listHkcChangeShifts != null)
{
if(listHkcChangeShifts.FromOperator.Equals(user.UserName))
if (listHkcChangeShifts.FromOperator.Equals(user.UserName))
{
keys.Add("operator", user);
Operator = user;
@ -349,13 +354,15 @@ _exitCommand ??= new DelegateCommand(Exit);
RaisePropertyChanged("Reviewer");
}
Username = string.Empty;
Password =string.Empty;
Password = string.Empty;
}
}
}
void Exit()
{
//清录屏进程
_eventAggregator.GetEvent<PrintScreenEvent>().Publish(2);
//_chkFunction.HIKLoginOut();
Process.GetCurrentProcess().Kill();
Environment.Exit(0);
@ -368,67 +375,83 @@ _exitCommand ??= new DelegateCommand(Exit);
{
FingerMsg = !msg.Result;
}
logger.Info($"LoginBtnEnable:{LoginBtnEnable}");
if (LoginBtnEnable)
{
logger.Info($"msg.Message:{msg.Message};{msg.Message.Equals("LOGIN")}");
if (msg.Message.Equals("LOGIN"))
{
UserList userList = new UserList();
userList = SqlSugarHelper.Db.Queryable<UserList>()
.Includes<RoleDm>(u => u.Role)
.Where(u => u.Id == msg.Id && u.MachineId == ConfigurationManager.AppSettings["machineId"].ToString())
.WithCacheIF(false).First();
//.First(u => u.Id == msg.Id && u.MachineId == ConfigurationManager.AppSettings["machineId"].ToString());
try
{
UserList userList = new UserList();
userList = SqlSugarHelper.Db.Queryable<UserList>()
.Includes<RoleDm>(u => u.Role)
.Where(u => u.Id == msg.Id && u.MachineId == ConfigurationManager.AppSettings["machineId"].ToString())
.WithCacheIF(false).First();
//.First(u => u.Id == msg.Id && u.MachineId == ConfigurationManager.AppSettings["machineId"].ToString());
if (userList == null)
{
AlertMsg alertMsg = new AlertMsg
logger.Info($"userList==null?{userList == null}");
if (userList == null)
{
Message = "无此用户",
Type = MsgType.ERROR
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
Username = "";
Password = "";
}
else if (userList.Role == null)
{
AlertMsg alertMsg = new AlertMsg
{
Message = "用户还未设置权限,请联系管理员",
Type = MsgType.ERROR
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
Username = "";
Password = "";
}
else
{
//1仅当班人、审核人可登录
if (LoginUserCheck.Equals("1"))
{
//检查当前登录人是否是值班人 (审核人与发药人)
listHkcChangeShifts = SqlSugarHelper.Db.Queryable<HkcChangeShifts>()
.Where(cs => cs.State == "0").First();
if (listHkcChangeShifts != null)
AlertMsg alertMsg = new AlertMsg
{
if (!listHkcChangeShifts.FromOperator.Equals(userList.UserName) && !listHkcChangeShifts.FromRviewer.Equals(userList.UserName))
{
AlertMsg alertMsg = new AlertMsg
{
Message = "仅值班人可登录,当前登录人非值班人",
Type = MsgType.ERROR
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
Username = "";
Password = "";
return;
}
}
Message = "无此用户",
Type = MsgType.ERROR
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
Username = "";
Password = "";
}
SetUser(userList);
else if (userList.Role == null)
{
AlertMsg alertMsg = new AlertMsg
{
Message = "用户还未设置权限,请联系管理员",
Type = MsgType.ERROR
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
Username = "";
Password = "";
}
else
{
//1仅当班人、审核人可登录
if (LoginUserCheck.Equals("1"))
{
//检查当前登录人是否是值班人 (审核人与发药人)
listHkcChangeShifts = SqlSugarHelper.Db.Queryable<HkcChangeShifts>()
.Where(cs => cs.State == "0").First();
if (listHkcChangeShifts != null)
{
if (!listHkcChangeShifts.FromOperator.Equals(userList.UserName) && !listHkcChangeShifts.FromRviewer.Equals(userList.UserName))
{
AlertMsg alertMsg = new AlertMsg
{
Message = "仅值班人可登录,当前登录人非值班人",
Type = MsgType.ERROR
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
Username = "";
Password = "";
return;
}
}
}
SetUser(userList);
}
}
catch (Exception ex)
{
if (ex.Message.Contains("连接数据库过程中发生错误"))
{
App.DbConnectionFail = true;
_regionManager.RequestNavigate("MainRegion", "EmergencyWindow");
}
logger.Info(ex.Message);
}
}
}
@ -446,8 +469,11 @@ _exitCommand ??= new DelegateCommand(Exit);
//接收导航传过来的参数 现在是在此处初始化了表格数据
public void OnNavigatedTo(NavigationContext navigationContext)
{
//FingerMsg = !_fingerprintUtil.bIsConnected;
//_eventAggregator.GetEvent<FingerprintEvent>().Subscribe(LoginEvent);
FingerMsg = !_fingerprintUtil.bIsConnected;
logger.Info("OnNavigatedTo");
_eventAggregator.GetEvent<FingerprintEvent>().Subscribe(LoginEvent);
//结束录屏
_eventAggregator.GetEvent<PrintScreenEvent>().Publish(0);
}
@ -460,7 +486,13 @@ _exitCommand ??= new DelegateCommand(Exit);
//这个方法用于拦截请求
public void OnNavigatedFrom(NavigationContext navigationContext)
{
_eventAggregator.GetEvent<FingerprintEvent>().Unsubscribe(LoginEvent);
logger.Info("OnNavigatedFrom");
#region
//登录进来后开始录屏
_eventAggregator.GetEvent<PrintScreenEvent>().Publish(1);
#endregion
}
//手动实现调用配置的逻辑 规避修改配置文件后不起作用的问题
public string ReadAppSetting(string key)
@ -472,5 +504,6 @@ _exitCommand ??= new DelegateCommand(Exit);
XmlNode node = doc.SelectSingleNode(xPath);
return node.Attributes["value"].Value.ToString();
}
}
}

View File

@ -1,26 +1,37 @@
using MaterialDesignThemes.Wpf;
using DM_Weight.Finger;
using DM_Weight.HIKVISION;
using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.util;
using DM_Weight.Views;
using log4net;
using log4net.Repository.Hierarchy;
using MaterialDesignThemes.Wpf;
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.util;
using DM_Weight.Finger;
using DM_Weight.Views;
using Unity;
using DM_Weight.HIKVISION;
namespace DM_Weight.ViewModels
{
internal class MainWindowViewModel : BindableBase
{
#region
//public Recorder _recorder;
private string _outputFolder;
private string _outputFilePath;
//public static MainWindowViewModel vm;
#endregion
private readonly ILog logger = LogManager.GetLogger(typeof(MainWindowViewModel));
private string _title = "Prism App"; //标题
private ISnackbarMessageQueue _snackbarMessageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(3));
@ -60,26 +71,37 @@ namespace DM_Weight.ViewModels
// this.eventAggregator.GetEvent<SnackbarEvent>().Subscribe(doMyPrismEvent2);
// _screenUtil = screenUtil;
//}
//private FingerprintUtil _fingerprintUtil;
private FingerprintUtil _fingerprintUtil;
IRegionManager _regionManager;
IUnityContainer _container;
//private CHKFunction _cHKFunction;
public MainWindowViewModel(IRegionManager regionManager, IUnityContainer container, IEventAggregator eventAggregator)
FFmpegHelper fFmpegHelper;
public MainWindowViewModel(IRegionManager regionManager, IUnityContainer container, IEventAggregator eventAggregator, FingerprintUtil fingerprintUtil, ScreenUtil screenUtil, FFmpegHelper fFmpegHelper)
{
//vm = this;
//_portUtil = portUtil;
this.eventAggregator = eventAggregator;
this.eventAggregator.GetEvent<SnackbarEvent>().Subscribe(doMyPrismEvent2);
//_fingerprintUtil = fingerprintUtil;
this.eventAggregator.GetEvent<PrintScreenEvent>().Subscribe(PrintScreen);
_screenUtil = screenUtil;
_fingerprintUtil = fingerprintUtil;
_regionManager = regionManager;
_container = container;
//_cHKFunction = cHKFunction;
//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 (App.DbConnectionFail)
{
_regionManager.RequestNavigate("MainRegion", "EmergencyWindow");
}
else
{
_container.RegisterType<object, LoginWindow>("LoginWindow");
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
}
_container.RegisterType<object, LoginWindow>("LoginWindow");
_regionManager.RegisterViewWithRegion("MainRegion", "LoginWindow");
//}));
}));
this.fFmpegHelper = fFmpegHelper;
}
void doMyPrismEvent2(AlertMsg msg)
@ -99,5 +121,104 @@ namespace DM_Weight.ViewModels
SnackbarMessageQueue.Enqueue(msg.Message);
}
#region
/// <summary>
/// 录屏事件
/// </summary>
/// <param name="type">0停止录屏1开始录屏2退出软件清进程</param>
void PrintScreen(int type)
{
logger.Info($"录屏事件PrintScreen{type}");
if (type == 0)
{
fFmpegHelper.stopFlag = true;
fFmpegHelper.StopRecording();
//StopPrintScreen();
////删除7天前的录屏文件
//if (Directory.Exists(_outputFolder))
//{
// var files = Directory.GetFiles(_outputFolder);
// foreach (var file in files)
// {
// var fileInfo = new FileInfo(file);
// if (fileInfo.CreationTime < DateTime.Now.AddDays(-7))
// {
// try
// {
// fileInfo.Delete();
// }
// catch (Exception ex)
// {
// logger.Info($"删除录屏文件失败: {ex.Message}");
// }
// }
// }
//}
}
else if (type == 1)
{
fFmpegHelper.stopFlag = false;
// StartPrintScreen();
// 创建输出目录
_outputFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "Log", "ScreenRecordings");
if (!Directory.Exists(_outputFolder))
{
Directory.CreateDirectory(_outputFolder);
}
// 生成输出文件名
string timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss");
_outputFilePath = Path.Combine(_outputFolder, $"{timestamp}.webm");
fFmpegHelper.StartRecording(_outputFilePath, 25);
}
else if (type == 2)
{
// _recorder?.Dispose();
}
}
#endregion
//void StopPrintScreen()
//{
// //退出登录结束录屏
// _recorder?.Stop();
//}
////录屏
//void StartPrintScreen()
//{
// // 创建输出目录
// _outputFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "Log", "ScreenRecordings");
// if (!Directory.Exists(_outputFolder))
// {
// Directory.CreateDirectory(_outputFolder);
// }
// // 生成输出文件名
// string timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss");
// _outputFilePath = Path.Combine(_outputFolder, $"{timestamp}.mp4");
// // 设置录制选项
// var options = new RecorderOptions();
// // 创建录制器实例
// _recorder = Recorder.CreateRecorder(options);
// // 设置事件处理
// _recorder.OnRecordingComplete += Recorder_OnRecordingComplete;
// _recorder.OnRecordingFailed += Recorder_OnRecordingFailed;
// // 开始录制
// _recorder.Record(_outputFilePath);
//}
////录制失败
//private void Recorder_OnRecordingFailed(object sender, RecordingFailedEventArgs e)
//{
// logger.Info($"录制失败: {e.Error}");
//}
////录制完成
//private void Recorder_OnRecordingComplete(object sender, RecordingCompleteEventArgs e)
//{
// logger.Info($"录制完成: {e.FilePath}");
//}
}
}

View File

@ -444,6 +444,7 @@ namespace DM_Weight.ViewModels
}
Status = 0;
_isFinishClick = false;
_portUtil.OperateFinish = true;
//RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
}
@ -464,6 +465,7 @@ namespace DM_Weight.ViewModels
{
_portUtil.ResetData();
Status = 0;
_portUtil.OperateFinish = true;
});
}

View File

@ -283,7 +283,7 @@ namespace DM_Weight.ViewModels
// 完成按钮
public DelegateCommand TakeFinish
{
get => new DelegateCommand(async() =>
get => new DelegateCommand(() =>
{
if (!_isFinishClick)
{
@ -314,7 +314,7 @@ namespace DM_Weight.ViewModels
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
// 获取更新完库存后的药品库存
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId.Equals(it.MachineId))
.Where(cs => cs.MachineId.Equals(it.MachineId) || cs.MachineId.Equals(ConfigurationManager.AppSettings["jj_machineId"]))
.Where(cs => cs.DrugId.Equals(it.DrugId))
.Where(cs => cs.DrawerType == 1)
.ToList();
@ -352,7 +352,10 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
CreateTime = DateTime.Now
CreateTime = DateTime.Now,
TotalStock = nowChannels.Sum(itx => itx.Quantity),
ManuStock = nowChannels.Where(itx => itx.ManuNo == it.ManuNo && itx.EffDate == it.EffDate).Sum(itx => itx.Quantity)
}).ExecuteCommand();
//修改凌晨生成的日结存数据
@ -365,6 +368,7 @@ namespace DM_Weight.ViewModels
if (accountBookG2Day != null)
{
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + it.ReturnQuantity;
accountBookG2Day.AddQuantity = accountBookG2Day.AddQuantity + it.ReturnQuantity;
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
}
else
@ -383,7 +387,9 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
InvoiceNo = "日结存"
CreateTime = DateTime.Now,
InvoiceNo = "日结存",
AddQuantity= it.ReturnQuantity
}).ExecuteCommand();
if (iDayResult <= 0)
{
@ -415,6 +421,7 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
CreateTime = DateTime.Now,
InvoiceNo = "总结存"
}).ExecuteCommand();
if (iTotalResult <= 0)
@ -427,26 +434,27 @@ namespace DM_Weight.ViewModels
});
if (f.Data)
{
// 更新屏显库存
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
Task.Factory.StartNew(() =>
{
singleChannels.ForEach(async it =>
// 更新屏显库存
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
{
await Task.Delay(200);
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.TakeQuantity);
});
}
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 35)
{
for (int i = 0; i < singleChannels.Count; i++)
{
await Task.Delay(200);
await _portUtil.WriteChannelInfoMethod(2, (singleChannels[i].Quantity + singleChannels[i].TakeQuantity).ToString(), singleChannels[i].DrawerNo, singleChannels[i].ColNo);
await Task.Delay(200);
await _portUtil.ShowContentMethod(singleChannels[i].DrawerNo, singleChannels[i].ColNo);
singleChannels.ForEach(it =>
{
Thread.Sleep(100);
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.TakeQuantity);
});
}
}
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 35)
{
for (int i = 0; i < singleChannels.Count; i++)
{
_portUtil.WriteQuantityMethod((singleChannels[i].Quantity + singleChannels[i].TakeQuantity), singleChannels[i].DrawerNo, singleChannels[i].ColNo);
Thread.Sleep(200);
}
}
});
AlertMsg alertMsg = new AlertMsg
{
Message = "处方退药完成,库存已更新",
@ -456,6 +464,7 @@ namespace DM_Weight.ViewModels
}
Status = 0;
_isFinishClick = false;
_portUtil.OperateFinish = true;
RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
//}
//else
@ -486,6 +495,7 @@ namespace DM_Weight.ViewModels
{
_portUtil.ResetData();
Status = 0;
_portUtil.OperateFinish = true;
});
}

View File

@ -337,7 +337,7 @@ namespace DM_Weight.ViewModels
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
// 获取更新完库存后的药品库存
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId.Equals(it.MachineId))
.Where(cs => cs.MachineId.Equals(it.MachineId) || cs.MachineId.Equals(ConfigurationManager.AppSettings["jj_machineId"]))
.Where(cs => cs.DrugId.Equals(it.DrugId))
.Where(cs => cs.DrawerType == 1)
.ToList();
@ -375,7 +375,10 @@ namespace DM_Weight.ViewModels
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
CreateTime = DateTime.Now,
InvoiceNo = OrderInfo.OrderNo
InvoiceNo = OrderInfo.OrderNo,
TotalStock = nowChannels.Sum(itx => itx.Quantity),
ManuStock = nowChannels.Where(itx => itx.ManuNo == it.ManuNo && itx.EffDate == it.EffDate).Sum(itx => itx.Quantity)
}).ExecuteCommand();
//修改凌晨生成的日结存与总结存数据
@ -388,6 +391,7 @@ namespace DM_Weight.ViewModels
if (accountBookG2Day != null)
{
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - it.TakeQuantity;
accountBookG2Day.OutQuantity = accountBookG2Day.OutQuantity + it.TakeQuantity;
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
}
else
@ -406,7 +410,9 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
InvoiceNo = "日结存"
CreateTime = DateTime.Now,
InvoiceNo = "日结存",
OutQuantity=it.TakeQuantity
}).ExecuteCommand();
if(iDayResult<=0)
{
@ -438,6 +444,7 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
CreateTime = DateTime.Now,
InvoiceNo = "总结存"
}).ExecuteCommand();
if (iTotalResult <= 0)
@ -457,8 +464,8 @@ namespace DM_Weight.ViewModels
{
singleChannels.ForEach(async it =>
{
await Task.Delay(200);
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
Thread.Sleep(150);
});
}
@ -467,10 +474,13 @@ namespace DM_Weight.ViewModels
{
for (int i = 0; i < singleChannels.Count; i++)
{
//await Task.Delay(200);
//_portUtil.WriteChannelInfoMethod(2, (singleChannels[i].Quantity - singleChannels[i].TakeQuantity).ToString(), singleChannels[i].DrawerNo, singleChannels[i].ColNo);
//await Task.Delay(200);
//_portUtil.ShowContentMethod(singleChannels[i].DrawerNo, singleChannels[i].ColNo);
await Task.Delay(200);
await _portUtil.WriteChannelInfoMethod(2, (singleChannels[i].Quantity - singleChannels[i].TakeQuantity).ToString(), singleChannels[i].DrawerNo, singleChannels[i].ColNo);
_portUtil.WriteQuantityMethod((singleChannels[i].Quantity - singleChannels[i].TakeQuantity), singleChannels[i].DrawerNo, singleChannels[i].ColNo);
await Task.Delay(200);
await _portUtil.ShowContentMethod(singleChannels[i].DrawerNo, singleChannels[i].ColNo);
}
}
AlertMsg alertMsg = new AlertMsg
@ -491,6 +501,7 @@ namespace DM_Weight.ViewModels
}
Status = 0;
_isFinishClick = false;
_portUtil.OperateFinish = true;
//RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
}
@ -522,6 +533,7 @@ namespace DM_Weight.ViewModels
{
_portUtil.ResetData();
Status = 0;
_portUtil.OperateFinish = true;
});
}

View File

@ -0,0 +1,47 @@
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.ViewModels
{
internal class PickersViewModel:BindableBase
{
private DateTime _date;
private DateTime _time;
private string? _validatingTime;
private DateTime? _futureValidatingDate;
public PickersViewModel()
{
Date = DateTime.Now;
Time = DateTime.Now;
}
public DateTime Date
{
get => _date;
set => SetProperty(ref _date, value);
}
public DateTime Time
{
get => _time;
set => SetProperty(ref _time, value);
}
public string? ValidatingTime
{
get => _validatingTime;
set => SetProperty(ref _validatingTime, value);
}
public DateTime? FutureValidatingDate
{
get => _futureValidatingDate;
set => SetProperty(ref _futureValidatingDate, value);
}
}
}

View File

@ -16,6 +16,7 @@ using DM_Weight.Models;
using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.util;
using System.Threading;
namespace DM_Weight.ViewModels
{
@ -223,7 +224,7 @@ namespace DM_Weight.ViewModels
// 完成按钮
public DelegateCommand TakeFinish
{
get => new DelegateCommand(async() =>
get => new DelegateCommand(() =>
{
IsFinishClick = true;
string InvoiceId = "RETURN_" + CurrentTimeMillis();
@ -239,7 +240,7 @@ namespace DM_Weight.ViewModels
// 获取更新完库存后的药品库存
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId.Equals(ChannelStock.MachineId))
.Where(cs => cs.MachineId.Equals(ChannelStock.MachineId)|| cs.MachineId.Equals(ConfigurationManager.AppSettings["jj_machineId"]))
.Where(cs => cs.DrugId.Equals(ChannelStock.DrugId))
.Where(cs => cs.DrawerType == 1)
.ToList();
@ -283,7 +284,10 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
CreateTime = DateTime.Now
CreateTime = DateTime.Now,
TotalStock = nowChannels.Sum(itx => itx.Quantity),
ManuStock = nowChannels.Where(itx => itx.ManuNo == ChannelStock.ManuNo && itx.EffDate == ChannelStock.EffDate).Sum(itx => itx.Quantity)
}).ExecuteCommand();
//修改凌晨生成的日结存数据
@ -296,6 +300,7 @@ namespace DM_Weight.ViewModels
if (accountBookG2Day != null)
{
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + ChannelStock.ReturnQuantity;
accountBookG2Day.AddQuantity = accountBookG2Day.AddQuantity + ChannelStock.ReturnQuantity;
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
}
else
@ -314,7 +319,9 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
InvoiceNo = "日结存"
CreateTime = DateTime.Now,
InvoiceNo = "日结存",
AddQuantity=ChannelStock.ReturnQuantity
}).ExecuteCommand();
if (iDayResult <= 0)
{
@ -346,6 +353,7 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
CreateTime = DateTime.Now,
InvoiceNo = "总结存"
}).ExecuteCommand();
if (iTotalResult <= 0)
@ -359,19 +367,23 @@ namespace DM_Weight.ViewModels
});
if (f.Data)
{
// 更新屏显库存
if (ChannelStock.BoardType == 5)
Task.Factory.StartNew(() =>
{
await Task.Delay(200);
_portUtil.WriteQuantity(ChannelStock.DrawerNo, ChannelStock.ColNo, ChannelStock.Quantity + ReturnQuantity);
}
if(ChannelStock.BoardType==35)
{
await _portUtil.WriteChannelInfoMethod(2, (ChannelStock.Quantity + ChannelStock.ReturnQuantity).ToString(), ChannelStock.DrawerNo, ChannelStock.ColNo);
await Task.Delay(200);
await _portUtil.ShowContentMethod(ChannelStock.DrawerNo, ChannelStock.ColNo);
}
// 更新屏显库存
if (ChannelStock.BoardType == 5)
{
_portUtil.WriteQuantity(ChannelStock.DrawerNo, ChannelStock.ColNo, ChannelStock.Quantity + ReturnQuantity);
Thread.Sleep(100);
}
if (ChannelStock.BoardType == 35)
{
//_portUtil.WriteChannelInfoMethod(2, (ChannelStock.Quantity + ChannelStock.ReturnQuantity).ToString(), ChannelStock.DrawerNo, ChannelStock.ColNo);
//await Task.Delay(200);
//_portUtil.ShowContentMethod(ChannelStock.DrawerNo, ChannelStock.ColNo);
_portUtil.WriteQuantityMethod((ChannelStock.Quantity + ChannelStock.TakeQuantity), ChannelStock.DrawerNo, ChannelStock.ColNo);
Thread.Sleep(200);
}
});
AlertMsg alertMsg = new AlertMsg
{
Message = "操作完成,库存已更新",
@ -390,6 +402,7 @@ namespace DM_Weight.ViewModels
}
Status = 0;
IsFinishClick = false;
_portUtil.OperateFinish = true;
RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
}, () => !IsFinishClick && ReturnQuantity > 0).ObservesProperty(() => IsFinishClick).ObservesProperty(() => ReturnQuantity);
@ -408,6 +421,7 @@ namespace DM_Weight.ViewModels
IsFinishClick = false;
_portUtil.ResetData();
Status = 0;
_portUtil.OperateFinish = true;
});
}

View File

@ -334,6 +334,7 @@ namespace DM_Weight.ViewModels
}
Status = 0;
IsFinishClick = false;
_portUtil.OperateFinish = true;
RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
} else
{
@ -361,6 +362,7 @@ namespace DM_Weight.ViewModels
IsFinishClick = false;
_portUtil.ResetData();
Status = 0;
_portUtil.OperateFinish = true;
});
}

View File

@ -373,12 +373,19 @@ namespace DM_Weight.ViewModels
PremissionName = "账册",
PremissionPath = "AccountWindow",
};
PremissionDm kuguan7 = new PremissionDm
{
Id = 47,
PremissionName = "使用账册",
PremissionPath = "UseAccountWindow",
};
kuguanChild.Add(kuguan1);
kuguanChild.Add(kuguan2);
kuguanChild.Add(kuguan3);
kuguanChild.Add(kuguan4);
kuguanChild.Add(kuguan5);
kuguanChild.Add(kuguan6);
kuguanChild.Add(kuguan7);
kuguan.Children = kuguanChild;
defaultAll.Add(kuguan);
#endregion

View File

@ -218,7 +218,7 @@ namespace DM_Weight.ViewModels
// 完成按钮
public DelegateCommand TakeFinish
{
get => new DelegateCommand(async () =>
get => new DelegateCommand(() =>
{
if (!_isFinishClick)
{
@ -245,7 +245,7 @@ namespace DM_Weight.ViewModels
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
// 获取更新完库存后的药品库存
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId.Equals(it.MachineId))
.Where(cs => cs.MachineId.Equals(it.MachineId) || cs.MachineId.Equals(ConfigurationManager.AppSettings["jj_machineId"]))
.Where(cs => cs.DrugId.Equals(it.DrugId))
.Where(cs => cs.DrawerType == 1)
.ToList();
@ -283,7 +283,9 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
CreateTime = DateTime.Now
CreateTime = DateTime.Now,
TotalStock = nowChannels.Sum(itx => itx.Quantity),
ManuStock = nowChannels.Where(itx => itx.ManuNo == it.ManuNo && itx.EffDate == it.EffDate).Sum(itx => itx.Quantity)
}).ExecuteCommand();
//修改凌晨生成的日结存数据
@ -296,6 +298,7 @@ namespace DM_Weight.ViewModels
if (accountBookG2Day != null)
{
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + it.AddQuantity;
accountBookG2Day.AddQuantity = accountBookG2Day.AddQuantity + it.AddQuantity;
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
}
else
@ -314,7 +317,9 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
InvoiceNo = "日结存"
CreateTime = DateTime.Now,
InvoiceNo = "日结存",
AddQuantity=it.AddQuantity
}).ExecuteCommand();
if (iDayResult <= 0)
{
@ -347,6 +352,7 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
CreateTime = DateTime.Now,
InvoiceNo = "总结存"
}).ExecuteCommand();
if (iTotalResult <= 0)
@ -361,34 +367,38 @@ namespace DM_Weight.ViewModels
});
if (f.Data)
{
// 更新屏显库存
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
Task.Factory.StartNew(() =>
{
singleChannels.ForEach(async it =>
// 更新屏显库存
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
{
await Task.Delay(200);
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
});
}
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 35)
{
for (int i = 0; i < singleChannels.Count; i++)
{
await Task.Delay(200);
await _portUtil.WriteChannelInfoMethod(2, (singleChannels[i].Quantity + singleChannels[i].AddQuantity).ToString(), singleChannels[i].DrawerNo, singleChannels[i].ColNo);
await Task.Delay(200);
await _portUtil.ShowContentMethod(singleChannels[i].DrawerNo, singleChannels[i].ColNo);
singleChannels.ForEach(it =>
{
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
Thread.Sleep(150);
});
}
//singleChannels.ForEach(async it =>
//{
// await _portUtil.WriteChannelInfoMethod(2, (it.Quantity + it.AddQuantity).ToString(), it.DrawerNo, it.ColNo);
// await Task.Delay(200);
// await _portUtil.ShowContentMethod(it.DrawerNo, it.ColNo);
//});
}
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 35)
{
for (int i = 0; i < singleChannels.Count; i++)
{
//await Task.Delay(200);
//_portUtil.WriteChannelInfoMethod(2, (singleChannels[i].Quantity + singleChannels[i].AddQuantity).ToString(), singleChannels[i].DrawerNo, singleChannels[i].ColNo);
//await Task.Delay(200);
//_portUtil.ShowContentMethod(singleChannels[i].DrawerNo, singleChannels[i].ColNo);
_portUtil.WriteQuantityMethod((singleChannels[i].Quantity + singleChannels[i].AddQuantity), singleChannels[i].DrawerNo, singleChannels[i].ColNo);
Thread.Sleep(200);
}
//singleChannels.ForEach(async it =>
//{
// await _portUtil.WriteChannelInfoMethod(2, (it.Quantity + it.AddQuantity).ToString(), it.DrawerNo, it.ColNo);
// await Task.Delay(200);
// await _portUtil.ShowContentMethod(it.DrawerNo, it.ColNo);
//});
}
});
AlertMsg alertMsg = new AlertMsg
{
Message = "操作完成,库存已更新",
@ -407,6 +417,7 @@ namespace DM_Weight.ViewModels
}
Status = 0;
_isFinishClick = false;
_portUtil.OperateFinish = true;
RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
}
@ -427,6 +438,7 @@ namespace DM_Weight.ViewModels
RequestData();
_portUtil.ResetData();
Status = 0;
_portUtil.OperateFinish = true;
});
}

View File

@ -199,7 +199,7 @@ namespace DM_Weight.ViewModels
// 完成按钮
public DelegateCommand TakeFinish
{
get => new DelegateCommand(async() =>
get => new DelegateCommand(() =>
{
if (!_isFinishClick)
{
@ -221,7 +221,7 @@ namespace DM_Weight.ViewModels
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
// 获取更新完库存后的药品库存
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId.Equals(it.MachineId))
.Where(cs => cs.MachineId.Equals(it.MachineId) || cs.MachineId.Equals(ConfigurationManager.AppSettings["jj_machineId"]))
.Where(cs => cs.DrugId.Equals(it.DrugId))
.Where(cs => cs.DrawerType == 1)
.ToList();
@ -260,7 +260,10 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
CreateTime = DateTime.Now
CreateTime = DateTime.Now,
TotalStock = nowChannels.Sum(itx => itx.Quantity),
ManuStock = nowChannels.Where(itx => itx.ManuNo == it.ManuNo && itx.EffDate == it.EffDate).Sum(itx => itx.Quantity)
}).ExecuteCommand();
//修改凌晨生成的日结存数据
@ -273,6 +276,7 @@ namespace DM_Weight.ViewModels
if (accountBookG2Day != null)
{
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - it.TakeQuantity;
accountBookG2Day.OutQuantity = accountBookG2Day.OutQuantity - it.TakeQuantity;
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
}
else
@ -291,7 +295,9 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
InvoiceNo = "日结存"
CreateTime = DateTime.Now,
InvoiceNo = "日结存",
OutQuantity=it.TakeQuantity
}).ExecuteCommand();
if (iDayResult <= 0)
{
@ -323,6 +329,7 @@ namespace DM_Weight.ViewModels
UserId2 = HomeWindowViewModel.Reviewer?.Id,
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
CreateTime = DateTime.Now,
InvoiceNo = "总结存"
}).ExecuteCommand();
if (iTotalResult <= 0)
@ -336,25 +343,31 @@ namespace DM_Weight.ViewModels
if (f.Data)
{
// 更新屏显库存
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
Task.Factory.StartNew(() =>
{
singleChannels.ForEach(async it =>
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
{
await Task.Delay(200);
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
});
}
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 35)
{
for (int i = 0; i < singleChannels.Count; i++)
{
await Task.Delay(200);
await _portUtil.WriteChannelInfoMethod(2, (singleChannels[i].Quantity - singleChannels[i].TakeQuantity).ToString(), singleChannels[i].DrawerNo, singleChannels[i].ColNo);
await Task.Delay(200);
await _portUtil.ShowContentMethod(singleChannels[i].DrawerNo, singleChannels[i].ColNo);
singleChannels.ForEach(it =>
{
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
Thread.Sleep(150);
});
}
}
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 35)
{
for (int i = 0; i < singleChannels.Count; i++)
{
//await Task.Delay(200);
//_portUtil.WriteChannelInfoMethod(2, (singleChannels[i].Quantity - singleChannels[i].TakeQuantity).ToString(), singleChannels[i].DrawerNo, singleChannels[i].ColNo);
//await Task.Delay(200);
//_portUtil.ShowContentMethod(singleChannels[i].DrawerNo, singleChannels[i].ColNo);
_portUtil.WriteQuantityMethod((singleChannels[i].Quantity - singleChannels[i].TakeQuantity), singleChannels[i].DrawerNo, singleChannels[i].ColNo);
Thread.Sleep(200);
}
}
});
AlertMsg alertMsg = new AlertMsg
{
@ -374,6 +387,7 @@ namespace DM_Weight.ViewModels
}
Status = 0;
_isFinishClick = false;
_portUtil.OperateFinish = true;
RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
}
@ -393,6 +407,7 @@ namespace DM_Weight.ViewModels
{
_portUtil.ResetData();
Status = 0;
_portUtil.OperateFinish = true;
});
}

View File

@ -198,9 +198,9 @@ namespace DM_Weight.ViewModels
ChannelStocks.Clear();
List<DrugInfo> q = SqlSugarHelper.Db.Queryable<DrugInfo>()
.Includes<ChannelStock>(di => di.channelStocks.Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1") && cs.DrugId != null).OrderBy(cs => cs.DrawerNo).OrderBy(cs => cs.ColNo).ToList())
.Includes<ChannelStock>(di => di.channelStocks.Where(cs => cs.DrawerType == 1).Where(cs => (cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1") || cs.MachineId == "DM5") && cs.Quantity > 0 && cs.DrugId != null).OrderBy(cs => cs.DrawerNo).OrderBy(cs => cs.ColNo).ToList())
.WhereIF(!String.IsNullOrEmpty(SearchValue), di => di.DrugName == SearchValue)
.Where(di => di.channelStocks.Any(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1") && cs.DrugId != null))
.Where(di => di.channelStocks.Any(cs =>(cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3")||cs.MachineId=="DM5" )&&cs.Quantity>0&& cs.DrugId != null))
.OrderBy(cs => cs.DrugId)
.ToList();
Drugs = q;

View File

@ -0,0 +1,148 @@
using DM_Weight.Models;
using DM_Weight.Report;
using DM_Weight.util;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Regions;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.DirectoryServices.ActiveDirectory;
using System.Drawing.Printing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.ViewModels
{
public class UseAccountWindowViewModel : BindableBase, INavigationAware
{
private DateTime? _startDate =DateTime.Now;
private DateTime? nowDate = DateTime.Now;
public DateTime? StartDate
{
get => _startDate;
set
{
SetProperty(ref _startDate, value);
}
}
private DateTime? _endDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
public DateTime? EndDate
{
get => _endDate;
set
{
SetProperty(ref _endDate, value);
}
}
private string _name;
public string Name { get => _name; set { SetProperty(ref _name, value); } }
/// <summary>
/// 麻醉医师姓名
/// </summary>
private List<UserList> _UserInfos;
public List<UserList> UserInfos
{
get => _UserInfos;
set { SetProperty(ref _UserInfos, value); }
}
private UserList _User;
public UserList User
{
get => _User;
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);
public long CurrentTimeMillis()
{
return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
}
IDialogService _dialogService;
public UseAccountWindowViewModel(IDialogService dialogService)
{
_dialogService = dialogService;
}
public void OnNavigatedTo(NavigationContext navigationContext)
{
//绑定用户信息
UserInfos = SqlSugarHelper.Db.Queryable<UserList>()
.Where(ul => ul.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM5")).ToList();
}
public bool IsNavigationTarget(NavigationContext navigationContext)
{
return true;
}
public void OnNavigatedFrom(NavigationContext navigationContext)
{
}
/// <summary>
/// 导出账册
/// </summary>
public DelegateCommand DownloadAccountBook
{
get => new DelegateCommand(() =>
{
GridReportUtil.UserAccount(StartDate, EndDate, User == null ? "" : User.Nickname, Box);
});
}
public bool KeepAlive => true;
public DelegateCommand<string> SelectTimeAction
{
get=> new DelegateCommand<string>(async (s) =>
{
// 此处延时1毫秒等待页面渲染
await Task.Delay(TimeSpan.FromMilliseconds(1));
DialogParameters dialogParameters = new DialogParameters();
dialogParameters.Add("DateTime", StartDate);
dialogParameters.Add("Type", s);
DialogServiceExtensions.ShowDialogHost(_dialogService, "DatetimeDialog", dialogParameters, DoDialogResult, "RootDialog");
});
}
private void DoDialogResult(IDialogResult dialogResult)
{
// 委托 被动执行 被子窗口执行
// dialogResult 第一方面可以拿到任意参数 第二方面 可判断关闭状态
if (dialogResult.Result == ButtonResult.OK)
{
if (dialogResult.Parameters.GetValue<string?>("Type").Equals("1"))
{
StartDate = dialogResult.Parameters.GetValue<DateTime?>("DateTime");
}
else
{
EndDate= dialogResult.Parameters.GetValue<DateTime?>("DateTime");
}
}
//MessageBox.Show("返回值:" + dialogResult.Result.ToString());
}
}
}

View File

@ -0,0 +1,165 @@
<UserControl x:Class="DM_Weight.Views.AddToJiaoJieNewWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DM_Weight.Views"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:convert="clr-namespace:DM_Weight.Converter"
xmlns:prism="http://prismlibrary.com/"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<Style x:Key="st" TargetType="GridViewColumnHeader">
<Style.Setters>
<Setter Property="Height">
<Setter.Value>55</Setter.Value>
</Setter>
<Setter Property="Background">
<Setter.Value>#31ccec</Setter.Value>
</Setter>
<Setter Property="Foreground">
<Setter.Value>white</Setter.Value>
</Setter>
</Style.Setters>
</Style>
</UserControl.Resources>
<Grid>
<Grid.Resources>
<!--<CollectionViewSource x:Key="GroupedDataList" Source="{Binding ChannelStocks}">
<CollectionViewSource.GroupDescriptions>
<PropertyGroupDescription PropertyName="ChannelLst" />
</CollectionViewSource.GroupDescriptions>
</CollectionViewSource>-->
<convert:GroupSumConverter x:Key="GroupSumConverter" />
<convert:TotalCountConverter x:Key="TotalCountConverter" />
<convert:StatusConverter x:Key="StatusConverter" />
<convert:StockStatusConverter x:Key="StockStatusConverter" />
<Style x:Key="st" TargetType="GridViewColumnHeader">
<Style.Setters>
<Setter Property="Height">
<Setter.Value>55</Setter.Value>
</Setter>
<Setter Property="Background">
<Setter.Value>#31ccec</Setter.Value>
</Setter>
<Setter Property="Foreground">
<Setter.Value>white</Setter.Value>
</Setter>
</Style.Setters>
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid Margin="0 6 0 6" Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="7*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Visibility="Collapsed"
Margin="3 0 3 0"
VerticalAlignment="Center"
Command="{Binding RejectReport_Download}"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
Content="注射剂报表" />
<Button Visibility="Collapsed"
Margin="3 0 3 0"
VerticalAlignment="Center"
Command="{Binding Account_Download}"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
Content="账册报表" />
<Button
Margin="6 0 6 0"
VerticalAlignment="Center"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
ToolTip="刷新" Command="{Binding QueryCommand}">
<materialDesign:PackIcon
Kind="Refresh" />
</Button>
</StackPanel>
</Grid>
<ListView Grid.ColumnSpan="2"
Padding="0 6 0 0" Grid.Row="1"
ItemsSource="{Binding _ChannelLists, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
SelectedItem="{Binding _ChannelList}"
materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"
materialDesign:DataGridAssist.ColumnHeaderPadding="10"
materialDesign:ListViewAssist.ListViewItemPadding="13">
<ListView.Resources>
<Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
<Setter Property="Foreground" Value="White" />
</Style>
</ListView.Resources>
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding RowSelected}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<ListView.View>
<GridView ColumnHeaderContainerStyle="{StaticResource st}">
<GridViewColumn Width="80"
DisplayMemberBinding="{Binding DrawerNo}"
Header="药箱号"/>
<GridViewColumn Header="药品名称" Width="150">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="DrugInfo.DrugName" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="厂家" Width="150">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="DrugInfo.Manufactory" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="规格" Width="100">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="DrugInfo.DrugSpec" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="基数" Width="100">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="BaseQuantity" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="需补药数" Width="100">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="AddQuantity" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="130"
Header="状态">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" materialDesign:ListBoxItemAssist.ShowSelection="False">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Width="130" Text="{Binding State,Converter={StaticResource StockStatusConverter},ConverterParameter=TextState}">
</TextBlock>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</Grid>
</UserControl>

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace DM_Weight.Views
{
/// <summary>
/// AddToJiaoJieNewWindow.xaml 的交互逻辑
/// </summary>
public partial class AddToJiaoJieNewWindow : UserControl
{
public AddToJiaoJieNewWindow()
{
InitializeComponent();
}
}
}

View File

@ -10,6 +10,21 @@
xmlns:prism="http://prismlibrary.com/"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<Style x:Key="st" TargetType="GridViewColumnHeader">
<Style.Setters>
<Setter Property="Height">
<Setter.Value>55</Setter.Value>
</Setter>
<Setter Property="Background">
<Setter.Value>#31ccec</Setter.Value>
</Setter>
<Setter Property="Foreground">
<Setter.Value>white</Setter.Value>
</Setter>
</Style.Setters>
</Style>
</UserControl.Resources>
<Grid>
<Grid.Resources>
<!--<CollectionViewSource x:Key="GroupedDataList" Source="{Binding ChannelStocks}">
@ -21,6 +36,19 @@
<convert:TotalCountConverter x:Key="TotalCountConverter" />
<convert:StatusConverter x:Key="StatusConverter" />
<convert:StockStatusConverter x:Key="StockStatusConverter" />
<Style x:Key="st" TargetType="GridViewColumnHeader">
<Style.Setters>
<Setter Property="Height">
<Setter.Value>55</Setter.Value>
</Setter>
<Setter Property="Background">
<Setter.Value>#31ccec</Setter.Value>
</Setter>
<Setter Property="Foreground">
<Setter.Value>white</Setter.Value>
</Setter>
</Style.Setters>
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
@ -73,12 +101,12 @@
Style="{StaticResource MaterialDesignOutlinedLightButton}"
Content="账册报表" />
<Button
<!--<Button
Margin="3 0 3 0"
VerticalAlignment="Center"
Command="{Binding TakeDrugCommand}"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
Content="取药" />
Content="取药" />-->
<Button
Margin="6 0 6 0"
@ -92,7 +120,7 @@
</Grid>
<DataGrid
<!--<DataGrid
Grid.Row="1"
materialDesign:DataGridAssist.ColumnHeaderPadding="15"
ItemsSource="{Binding ChannelStocks,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
@ -110,7 +138,8 @@
<Setter Property="BorderThickness" Value="0.6"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
</Style>
<!--<Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource MaterialDesignDataGridCell}">
-->
<!--<Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource MaterialDesignDataGridCell}">
<Style.Triggers>
<Trigger Property="IsReadOnly" Value="True">
<Setter Property="BorderBrush" Value="Transparent" />
@ -119,6 +148,7 @@
</Style.Triggers>
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>-->
<!--
<Style TargetType="DataGridCell">
<Setter Property="Template">
<Setter.Value>
@ -166,11 +196,106 @@
<DataGridTextColumn IsReadOnly="True" Header="药品名称" Binding="{Binding DrugInfo.DrugName}"/>
<DataGridTextColumn IsReadOnly="True" Header="规格" Binding="{Binding DrugInfo.DrugSpec}"/>
<DataGridTextColumn IsReadOnly="True" Header="厂家" Binding="{Binding DrugInfo.Manufactory}"/>
-->
<!--<DataGridTextColumn IsReadOnly="True" Header="批次" Binding="{Binding ManuNo}"/>-->
<!--
<DataGridTextColumn IsReadOnly="True" Header="药品基数" Binding="{Binding BaseQuantity}"/>
<DataGridTextColumn IsReadOnly="True" Header="需补药数量" Binding="{Binding AddQuantity}"/>
<DataGridTextColumn IsReadOnly="True" Header="状态" Binding="{Binding ChannelLst.State,Converter={StaticResource StockStatusConverter},ConverterParameter=TextState}"/>
</DataGrid.Columns>
</DataGrid>
</DataGrid>-->
<ListView Grid.ColumnSpan="2"
Padding="0 6 0 0" Grid.Row="1"
ItemsSource="{Binding _ChannelLists, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
SelectedItem="{Binding _ChannelList}"
materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"
materialDesign:DataGridAssist.ColumnHeaderPadding="10"
materialDesign:ListViewAssist.ListViewItemPadding="13">
<ListView.Resources>
<Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
<Setter Property="Foreground" Value="White" />
</Style>
</ListView.Resources>
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding RowSelected}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<ListView.View>
<GridView ColumnHeaderContainerStyle="{StaticResource st}">
<GridViewColumn Width="80"
DisplayMemberBinding="{Binding DrawerNo}"
Header="药箱号"/>
<GridViewColumn Header="药品名称" Width="150">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="DrugInfo.DrugName" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="厂家" Width="150">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="DrugInfo.Manufactory" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="规格" Width="100">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="DrugInfo.DrugSpec" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="基数" Width="100">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="BaseQuantity" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="需补药数" Width="100">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="AddQuantity" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="130"
Header="状态">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" materialDesign:ListBoxItemAssist.ShowSelection="False">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Width="130" Text="{Binding State,Converter={StaticResource StockStatusConverter},ConverterParameter=TextState}">
</TextBlock>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<!--<GridViewColumn Width="200"
DisplayMemberBinding="{Binding Drug.DrugName}"
Header="药品名称"/>
<GridViewColumn Width="200"
DisplayMemberBinding="{Binding Drug.Manufactory}"
Header="厂家"/>
<GridViewColumn Width="200"
DisplayMemberBinding="{Binding Drug.DrugSpec}"
Header="规格"/>
<GridViewColumn Width="100"
DisplayMemberBinding="{Binding BaseQuantity}"
Header="药品基数"/>
<GridViewColumn Width="100"
DisplayMemberBinding="{Binding BaseQuantity}"
Header="需补药数量"/>-->
</GridView>
</ListView.View>
</ListView>
</Grid>
</UserControl>

View File

@ -23,42 +23,42 @@ namespace DM_Weight.Views
/// </summary>
public partial class AddToJiaoJieWindow : UserControl
{
IEventAggregator _eventAggregator;
public AddToJiaoJieWindow(IEventAggregator eventAggregator)
//IEventAggregator _eventAggregator;
public AddToJiaoJieWindow()
{
InitializeComponent();
_eventAggregator = eventAggregator;
//_eventAggregator = eventAggregator;
}
//展开
private void Expander_Expanded(object sender, RoutedEventArgs e)
{
//Expander expander = sender as Expander;
//if (expander != null)
//{
// // 假设你的数据在DataContext中
// List<ChannelStock> data = expander.DataContext as List<ChannelStock>;
// if (data != null&&data.Count>0)
// {
// // 使用data做你需要的操作
// }
//}
}
//private void Expander_Expanded(object sender, RoutedEventArgs e)
//{
// //Expander expander = sender as Expander;
// //if (expander != null)
// //{
// // // 假设你的数据在DataContext中
// // List<ChannelStock> data = expander.DataContext as List<ChannelStock>;
// // if (data != null&&data.Count>0)
// // {
// // // 使用data做你需要的操作
// // }
// //}
//}
//收起
private void Expander_Collapsed(object sender, RoutedEventArgs e)
{
Expander expander = sender as Expander;
if (expander != null)
{
// 假设你的数据在DataContext中
CollectionViewGroup group = expander.DataContext as CollectionViewGroup;
if (group != null)
{
ChannelStock internalGroup = group.Items[0] as ChannelStock;
//private void Expander_Collapsed(object sender, RoutedEventArgs e)
//{
// Expander expander = sender as Expander;
// if (expander != null)
// {
// // 假设你的数据在DataContext中
// CollectionViewGroup group = expander.DataContext as CollectionViewGroup;
// if (group != null)
// {
// ChannelStock internalGroup = group.Items[0] as ChannelStock;
_eventAggregator.GetEvent<IsSelectedEvent>().Publish(internalGroup);
}
}
}
// _eventAggregator.GetEvent<IsSelectedEvent>().Publish(internalGroup);
// }
// }
//}
}
}

View File

@ -15,6 +15,7 @@
mc:Ignorable="d" >
<UserControl.Resources>
<convert:StatusConverter x:Key="StatusConverter" />
<convert:TakeQuantityVisiable x:Key="TakeQuantityVisiable" />
</UserControl.Resources>
<materialDesign:Card Padding="0">
<Grid>
@ -36,7 +37,7 @@
<materialDesign:PackIcon Kind="Close" Width="34" Height="34" />
</Button>
</Grid>
<DataGrid Grid.Row="1" ItemsSource="{Binding ChannelStocks}" AutoGenerateColumns="False" CanUserAddRows="False">
<DataGrid Grid.Row="1" ItemsSource="{Binding _DrugInfoList}" AutoGenerateColumns="False" CanUserAddRows="False">
<DataGrid.Resources>
<Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
<Setter Property="HorizontalContentAlignment" Value="Center" />
@ -52,56 +53,73 @@
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTextColumn Width="100"
Header="库位"
IsReadOnly="True"
Binding="{Binding Location}"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
/>
<DataGridTextColumn Width="180"
Header="药品名称"
IsReadOnly="True"
Binding="{Binding DrugInfo.DrugName}"
Binding="{Binding DrugName}"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
/>
<DataGridTextColumn Width="180"
Header="规格"
IsReadOnly="True"
Binding="{Binding DrugInfo.DrugSpec}"
Binding="{Binding DrugSpec}"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
/>
<DataGridTextColumn Width="100"
Header="数"
<DataGridTextColumn
Header="需补药数"
IsReadOnly="True"
Binding="{Binding Quantity}"
Binding="{Binding NeedQuantity}"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
/>
<DataGridTextColumn Width="130"
Header="批次"
IsReadOnly="True"
Binding="{Binding ManuNo}"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
/>
<DataGridTextColumn Width="130"
/>
<DataGridTemplateColumn Header="库存" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="Quantity" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn
Header="库位" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="Location" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn IsReadOnly="True"
Header="批次">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="ManuNo" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="130"
Header="效期"
IsReadOnly="True"
Binding="{Binding EffDate}"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
/>
<DataGridTextColumn Width="100"
Header="取出数量"
IsReadOnly="True"
Binding="{Binding TakeQuantity}"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
/>
IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="EffDate" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="取出数量">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" materialDesign:ListBoxItemAssist.ShowSelection="False">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBox Width="60" Visibility="{Binding ColNo,Converter={StaticResource TakeQuantityVisiable}}" Text="{Binding TakeQuantity}">
</TextBox>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
<Grid Grid.Row="2">
@ -147,6 +165,9 @@
</StackPanel>
</Grid>
<materialDesign:Snackbar
Background="{Binding SnackbarBackground}"
MessageQueue="{Binding SnackbarMessageQueue}"/>
</Grid>
</materialDesign:Card>
</UserControl>

View File

@ -88,7 +88,7 @@
Margin="12 0 12 0">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid />
<UniformGrid Columns="3" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>

View File

@ -0,0 +1,36 @@
<UserControl x:Class="DM_Weight.Views.Dialog.DatetimeDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DM_Weight.Views.Dialog"
xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
xmlns:convert="clr-namespace:DM_Weight.Converter"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<Grid Margin="-1">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal">
<Calendar x:Name="CombinedCalendar" SelectedDate="{Binding Date}" Margin="-1 -4 -1 0" />
<materialDesign:Clock Time="{Binding Time}" x:Name="CombinedClock" DisplayAutomation="CycleWithSeconds" Is24Hours="True" />
</StackPanel>
<StackPanel Grid.Row="1" Margin="8" HorizontalAlignment="Right" Orientation="Horizontal">
<Button Style="{StaticResource MaterialDesignFlatButton}" Command="{Binding CloseAction}" CommandParameter="1" Content="确认" />
<Button Style="{StaticResource MaterialDesignFlatButton}" Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}" Content="取消">
<Button.CommandParameter>
<system:Boolean xmlns:system="clr-namespace:System;assembly=mscorlib">
False
</system:Boolean>
</Button.CommandParameter>
</Button>
</StackPanel>
</Grid>
</Grid>
</UserControl>

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace DM_Weight.Views.Dialog
{
/// <summary>
/// DatetimeDialog.xaml 的交互逻辑
/// </summary>
public partial class DatetimeDialog : UserControl
{
public DatetimeDialog()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,100 @@
<UserControl x:Class="DM_Weight.Views.EmergencyWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DM_Weight.Views"
mc:Ignorable="d"
xmlns:pagination="clr-namespace:DM_Weight.Components.pagination"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
xmlns:convert="clr-namespace:DM_Weight.Converter"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="80"></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid Background="#00bcd4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Image Grid.Column="0" Margin="30 0 30 0" HorizontalAlignment="Left" Width="Auto" Height="26" Source="/Images/logo.png" />
</Grid>
<Grid Grid.Row="1" Margin="6">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid Margin="0" Grid.Column="0" Width="280">
<Grid.Background>
<ImageBrush ImageSource="/Images/box.png" />
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="200" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid Grid.Row="1" Height="430" Margin="0 20 0 0">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.Resources>
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource MaterialDesignPaperLightButton}">
<Setter Property="Foreground" Value="#00a0ea" />
<Setter Property="BorderBrush" Value="#00a0ea" />
</Style>
</Grid.Resources>
<Button Grid.Row="0" Width="210" Content="1" Command="{Binding OpenDrawer}" CommandParameter="1" />
<Button Grid.Row="1" Width="210" Content="2" Command="{Binding OpenDrawer}" CommandParameter="2" />
<Button Grid.Row="2" Width="210" Content="3" Command="{Binding OpenDrawer}" CommandParameter="3" />
<Button Grid.Row="3" Width="210" Content="4" Command="{Binding OpenDrawer}" CommandParameter="4" />
<Button Grid.Row="4" Width="210" Content="5" Command="{Binding OpenDrawer}" CommandParameter="5" />
<Button Grid.Row="5" Width="210" Content="6" Command="{Binding OpenDrawer}" CommandParameter="6" />
<Button Grid.Row="6" Width="210" Content="7" Command="{Binding OpenDrawer}" CommandParameter="7" />
<Button Grid.Row="7" Width="210" Content="8" Command="{Binding OpenDrawer}" CommandParameter="8" />
</Grid>
</Grid>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="16 0 0 0">
<Button Margin="0 0 6 0" Content="返回登录" Command="{Binding ReturnLoginDelegate}" CommandParameter="0"
Visibility="{Binding DBConnectionStatus, Converter={StaticResource BooleanToVisibilityConverter}}" Style="{StaticResource MaterialDesignOutlinedLightButton}"/>
<Button
Style="{StaticResource MaterialDesignRaisedLightButton}"
Background="#7986cb"
BorderBrush="#7986cb"
materialDesign:ButtonAssist.CornerRadius="5" Cursor="Hand" IsCancel="true"
Command="{ Binding ExitCommand }" >
<TextBlock Foreground="{DynamicResource MaterialDesignPaper}" Text="退出" />
</Button>
</StackPanel>
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Grid.Row="1">
<GroupBox Width="800px"
Header="重要提示"
Style="{StaticResource MaterialDesignGroupBox}"
Margin="16"
materialDesign:ColorZoneAssist.Mode="SecondaryMid">
<TextBlock Foreground="Red" FontWeight="Bold" FontSize="16" Text="数据库连接失败,此页面为紧急开锁页面!!!" />
</GroupBox>
</StackPanel>
<!--<materialDesign:Snackbar
Background="{Binding SnackbarBackground}"
MessageQueue="{Binding SnackbarMessageQueue}"/>-->
</Grid>
</Grid>
</Grid>
</UserControl>

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace DM_Weight.Views
{
/// <summary>
/// EmergencyWindow.xaml 的交互逻辑
/// </summary>
public partial class EmergencyWindow : UserControl
{
public EmergencyWindow()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,12 @@
<UserControl x:Class="DM_Weight.Views.EmptyWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DM_Weight.Views"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<!--空白页面用于退出登录时先跳转该页面再退出登录ContentRegion先跳转到该页面让上一个页面先进OnNavigatedFrom。-->
</Grid>
</UserControl>

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace DM_Weight.Views
{
/// <summary>
/// EmptyWindow.xaml 的交互逻辑
/// </summary>
public partial class EmptyWindow : UserControl
{
public EmptyWindow()
{
InitializeComponent();
}
}
}

View File

@ -1,4 +1,7 @@
using Prism.Events;
using DM_Weight.msg;
using DM_Weight.util;
using DM_Weight.ViewModels;
using Prism.Events;
using Prism.Ioc;
using Prism.Regions;
using System;
@ -16,8 +19,6 @@ using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Unity;
using Unity.Lifetime;
using DM_Weight.msg;
using DM_Weight.util;
namespace DM_Weight.Views
{
@ -28,9 +29,11 @@ namespace DM_Weight.Views
{
//IRegionManager _regionManager;
//IUnityContainer _container;
//MainWindowViewModel vms;
public MainWindow()
{
InitializeComponent();
//vms = MainWindowViewModel.vm;
//_regionManager = regionManager;
//_container = container;
//System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
@ -42,6 +45,11 @@ namespace DM_Weight.Views
//}));
}
//protected override void OnClosed(EventArgs e)
//{
// vms._recorder?.Dispose();
// base.OnClosed(e);
//}
}
}

View File

@ -0,0 +1,155 @@
<UserControl x:Class="DM_Weight.Views.UseAccountWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DM_Weight.Views"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource MaterialDesignTextBox}">
<Setter Property="Margin" Value="0,8" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<Style x:Key="FieldIcon" TargetType="materialDesign:PackIcon">
<Setter Property="DockPanel.Dock" Value="Right" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<Style x:Key="FieldDockPanel" TargetType="DockPanel">
<Setter Property="Margin" Value="0,0,8,16" />
<Setter Property="VerticalAlignment" Value="Bottom" />
</Style>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Margin="0 6 0 6" Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="8*" />
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Left">
<DockPanel Style="{StaticResource FieldDockPanel}">
<TextBox Style="{StaticResource MaterialDesignOutlinedTextBox}" x:Name="startDataBox" materialDesign:HintAssist.Hint="开始时间"
Text="{Binding StartDate,StringFormat='yyyy-MM-dd HH:mm:ss'}" Margin="6 0 0 0" >
</TextBox>
<Button
Style="{StaticResource MaterialDesignIconForegroundButton}" Command="{Binding SelectTimeAction}" CommandParameter="1" >
<materialDesign:PackIcon Width="40" Height="40" Kind="CalendarRange" Style="{StaticResource FieldIcon}" Foreground="{Binding ElementName=startDataBox, Path=BorderBrush}"/>
</Button>
</DockPanel>
<DockPanel Style="{StaticResource FieldDockPanel}">
<TextBox Style="{StaticResource MaterialDesignOutlinedTextBox}" x:Name="endDataBox" materialDesign:HintAssist.Hint="结束时间"
Text="{Binding EndDate,StringFormat='yyyy-MM-dd HH:mm:ss'}" Margin="6 0 0 0" >
</TextBox>
<Button
Style="{StaticResource MaterialDesignIconForegroundButton}" Command="{Binding SelectTimeAction}" CommandParameter="2" >
<materialDesign:PackIcon Width="40" Height="40" Kind="CalendarRange" Style="{StaticResource FieldIcon}" Foreground="{Binding ElementName=endDataBox, Path=BorderBrush}"/>
</Button>
</DockPanel>
<!-- <DatePicker
SelectedDate="{Binding EndDate}"
Margin="6 0 0 0"
materialDesign:HintAssist.Hint="结束时间"
Style="{StaticResource MaterialDesignOutlinedDatePicker}"
/>-->
<!--<Button Content="选择时间" Command="{Binding SelectTimeAction}" CommandParameter="1"/>-->
<!--<StackPanel Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" FontSize="24" >
<TextBlock.Text>
<MultiBinding StringFormat="{}{0:yyyy-MM-dd} {1:HH:mm:ss}">
<Binding Path="startCalenderDate"/>
<Binding Path="startCalenderTime"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
<Button Margin="8 0 0 0" Content="开始时间" Command="{x:Static materialDesign:DialogHost.OpenDialogCommand}">
<Button.CommandParameter>
<Grid Margin="-1">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal">
<Calendar x:Name="CombinedCalendar" SelectedDate="{Binding startCalenderDate}" Margin="-1 -4 -1 0" />
<materialDesign:Clock Time="{Binding startCalenderTime}" x:Name="CombinedClock" DisplayAutomation="CycleWithSeconds" Is24Hours="True" />
</StackPanel>
<StackPanel Grid.Row="1" Margin="8" HorizontalAlignment="Right" Orientation="Horizontal">
<Button Style="{StaticResource MaterialDesignFlatButton}" Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}" CommandParameter="1" Content="确认" />
</StackPanel>
</Grid>
</Button.CommandParameter>
</Button>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" FontSize="24" >
<TextBlock.Text>
<MultiBinding StringFormat="{}{0:yyyy-MM-dd} {1:HH:mm:ss}">
<Binding Path="endCalenderDate"/>
<Binding Path="endCalenderTime"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
<Button Margin="8 0 0 0" Content="结束时间" Command="{x:Static materialDesign:DialogHost.OpenDialogCommand}">
<Button.CommandParameter>
<Grid Margin="-1">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal">
<Calendar SelectedDate="{Binding endCalenderDate}" x:Name="CombinedCalendar2" Margin="-1 -4 -1 0" />
<materialDesign:Clock Time="{Binding endCalenderTime}" x:Name="CombinedClock2" DisplayAutomation="CycleWithSeconds" Is24Hours="True" />
</StackPanel>
<StackPanel Grid.Row="1" Margin="8" HorizontalAlignment="Right" Orientation="Horizontal">
<Button Style="{StaticResource MaterialDesignFlatButton}" Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}" CommandParameter="1" Content="确认" />
</StackPanel>
</Grid>
</Button.CommandParameter>
</Button>
</StackPanel>-->
<!--<TextBox Margin="6 0 0 0" Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}" materialDesign:HintAssist.Hint="麻醉师姓名"
materialDesign:HintAssist.IsFloating="True" Width="100"/>-->
<ComboBox Width="130"
Margin="16 0 6 0"
Grid.Column="2"
materialDesign:HintAssist.Hint="麻醉医师姓名"
ItemsSource="{Binding UserInfos}"
SelectedItem="{Binding User}"
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" Cursor=""/>
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right" Cursor="">
<Button
Margin="0 0 13 0"
VerticalAlignment="Center"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
ToolTip="导出" Command="{Binding DownloadAccountBook}">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="download" />
<TextBlock Text="导出账册" />
</StackPanel>
</Button>
</StackPanel>
</Grid>
</Grid>
</UserControl>

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace DM_Weight.Views
{
/// <summary>
/// UseAccountWindow.xaml 的交互逻辑
/// </summary>
public partial class UseAccountWindow : UserControl
{
public UseAccountWindow()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,14 @@
using DM_Weight.Models;
using Prism.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.msg
{
internal class PrintScreenEvent : PubSubEvent<int>
{
}
}

View File

@ -0,0 +1,79 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
namespace DM_Weight.util
{
public class FFmpegHelper
{
private Process _ffmpegProcess;
private string _ffmpegPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ffmpeg.exe");
//是否停止录屏标志
public bool stopFlag = false;
public void StartRecording(string outputPath, int frameRate = 30)
{
//int width = (int)SystemParameters.PrimaryScreenWidth;
//int height =(int)SystemParameters.PrimaryScreenHeight;
int segmentDuration = 1800; // 每段半小时
string args = $"-f gdigrab -framerate {frameRate} " +
$"-i desktop -preset ultrafast -t {segmentDuration} {outputPath}";
_ffmpegProcess = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = _ffmpegPath,
Arguments = args,
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardInput = true
}
};
_ffmpegProcess.Start();
ThreadPool.QueueUserWorkItem(CheckFFmpegProcess); // 检查FFmpeg进程是否完成以开始下一个录制段
}
public void StopRecording()
{
_ffmpegProcess?.StandardInput.WriteLine("q");
_ffmpegProcess?.WaitForExit(1000);
_ffmpegProcess?.Close();
stopFlag = true;
}
private void CheckFFmpegProcess(object state)
{
try
{
if (!stopFlag)
{
_ffmpegProcess.WaitForExit(); // 等待FFmpeg进程结束
if (!_ffmpegProcess.HasExited) return; // 如果进程未结束,则不继续
// 开始下一个录制段,如果需要循环录制,可以取消注释下面的代码行并适当调整逻辑
// StartRecording(); // 注意:这将无限循环录制,可能需要用户界面干预来停止或重置计数器。
string _outputFolder;
string _outputFilePath;
_outputFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "Log", "ScreenRecordings");
if (!Directory.Exists(_outputFolder))
{
Directory.CreateDirectory(_outputFolder);
}
// 生成输出文件名
string timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss");
_outputFilePath = Path.Combine(_outputFolder, $"{timestamp}.webm");
StartRecording(_outputFilePath, 25);
}
}
catch (Exception)
{
}
}
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.util
{
public class OpenCVScreenRecord
{
}
}

View File

@ -0,0 +1,41 @@
using SharpPromise;
using System;
using System.Threading.Tasks;
namespace DM_Weight.util
{
public class PromiseUtil<T>
{
public int _delay { get; set; }
public T? _data { get; set; }
public async Task taskAsyncLoop(int delay, T data, Action<PromiseUtil<T>, Action, Action> action)
{
_data = data;
_delay = 0;
while (_delay >= 0)
{
await new Promise(async (Action onResolve, Action onReject) =>
{
await Task.Delay(_delay);
try
{
await Task.Run(() => action(this, onResolve, onReject));
}
catch (Exception ex)
{
onReject();
}
}).Then(() =>
{
_delay = delay;
}).Catch((Exception e) =>
{
_delay = -1;
});
}
}
}
}