添加使用登记账册报表;

修改绑定写标签及写数量相关等待时间及开启新线程写数据
调拨入库数量根据系数转换成支将未绑定药品显示出来保存时不改未绑定药品status
This commit is contained in:
maqiao 2024-12-19 19:55:35 +08:00
parent 5f2c4aee93
commit f4b859520d
28 changed files with 1188 additions and 344 deletions

View File

@ -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=xiangtan_mazuike_xx; Password=root; Port=3306; Server=127.0.0.1; 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="COM5" />
<!-- can总线串口的串口号 -->
<add key="CanBusPortPath" value="COM9" />
<add key="CanBusPortPath" value="COM3" />
<!-- 条码枪串口的串口号 -->
<add key="ScanCodePortPath" value="COM8" />
<add key="ScanCodePortPath" value="COM7" />
<!--是否有冰箱抽屉0无1有一个2两个-->

View File

@ -226,6 +226,8 @@ namespace DM_Weight
containerRegistry.RegisterForNavigation<ChangeShiftsDialog, ChangeShiftsDialogViewModel>();
containerRegistry.RegisterForNavigation<AccountWindow,AccountWindowViewModel>();
//使用登记册
containerRegistry.RegisterForNavigation<UseAccountWindow, UseAccountWindowViewModel>();
#endregion
#region

View File

@ -97,6 +97,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

@ -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?"未绑定": DrawerNo + "-" + ColNo;
}
private int _addQuantity = 0;

View File

@ -72,6 +72,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; }

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
{
@ -1138,20 +1139,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 +1230,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 +1263,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 +1279,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 +1312,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 +1334,48 @@ namespace DM_Weight.Port
}
}
public async Task WriteQuantityMethod(int quantity, int drawerNo, int colNo)
{
try
{
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);
logger.Info($"写标签指令:{Convert.ToHexString(buffer)}");
}
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,40 @@ namespace DM_Weight.Report
Report.PrintPreview(true);
}
/// <summary>
/// 使用登记册
/// 能按麻醉师名字、时间结合起来查找
/// </summary>
public static void UserAccount(DateTime? startDate, DateTime? endDate, string Name)
{
// 定义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,re.manu_no as ManuNo,'' BedNum,re.patient_name as PName,
CONCAT(use_dose,dose_unit) as UDose,CONCAT(residual_dose,dose_unit) as ReDose,'' as Disposal,
re.anaesthetist_name as AName,re.operator_name as OName,re.supervisor_name as CName,'' EmpManuNO,'' EmpRecive,'' as EmpMedicRecive
from surgical_residual re inner join drug_info di on re.drug_id=di.drug_id
where re.create_time > '{startDate}' and re.create_time< '{endDate}'";
if (!string.IsNullOrEmpty(Name))
{
SQL += " AND re.anaesthetist_name='" + Name + "' ";
}
SQL += " ORDER BY re.create_time";
Report.DetailGrid.Recordset.ConnectionString = gridConnectionString;
Report.DetailGrid.Recordset.QuerySQL = SQL;
Report.PrintPreview(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

@ -405,7 +405,7 @@ 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();
SqlSugarHelper.Db.Deleteable<ChannelStock>().Where(cs => cs.DrawerNo == jiaoStock.DrawerNo && cs.DrugId == jiaoStock.DrugId && cs.MachineId == jiaoStock.MachineId && cs.Quantity <= 0).ExecuteCommand();
List<ChannelStock> csStockList = record.Where(cs => cs.DrugId == jiaoStock.DrugId && cs.TakeQuantity > 0).ToList();
if (csStockList != null && csStockList.Count > 0)
{
@ -431,17 +431,18 @@ namespace DM_Weight.ViewModels
newStock.Id = Guid.NewGuid().ToString();
newStock.MachineId = jiaoStock.MachineId;
newStock.Id = Guid.NewGuid().ToString();
newStock.NeedNum = 0;
AddJJStock.Add(newStock);
csStock.TakeQuantity = 0;
jiaoStock.NeedNum = jiaoStock.NeedNum - csStock.TakeQuantity;
jiaoStock.NeedNum = jiaoStock.NeedNum- 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();
@ -450,12 +451,13 @@ namespace DM_Weight.ViewModels
newStock.ManuNo = jiaoStock.ManuNo;
newStock.DrawerNo = jiaoStock.DrawerNo;
newStock.DrugId = jiaoStock.DrugId;
newStock.AddToJJNum = csStock.TakeQuantity;
newStock.AddToJJNum = jiaoStock.NeedNum;
newStock.Id = Guid.NewGuid().ToString();
newStock.MachineId = jiaoStock.MachineId;
newStock.Id=Guid.NewGuid().ToString();
newStock.NeedNum = 0;
AddJJStock.Add(newStock);
csStock.TakeQuantity = jiaoStock.NeedNum - csStock.TakeQuantity;
csStock.TakeQuantity = csStock.TakeQuantity-jiaoStock.NeedNum;
jiaoStock.NeedNum = 0;
break;
}
@ -466,16 +468,17 @@ namespace DM_Weight.ViewModels
{
//不够取
ChannelStock newStock = new ChannelStock();
newStock.BaseQuantity = jiaoStock.BaseQuantity;
newStock.Chnguid = jiaoStock.Chnguid;
newStock.BaseQuantity = csStock.BaseQuantity;
newStock.DrawerNo = jiaoStock.DrawerNo;
newStock.DrugId = jiaoStock.DrugId;
newStock.ManuNo = csStock.ManuNo;
newStock.AddToJJNum = csStock.Quantity;
newStock.AddToJJNum = csStock.TakeQuantity;
newStock.Id = Guid.NewGuid().ToString();
newStock.MachineId = jiaoStock.MachineId;
newStock.NeedNum= 0;
AddJJStock.Add(newStock);
jiaoStock.NeedNum = jiaoStock.NeedNum - csStock.Quantity;
jiaoStock.NeedNum = jiaoStock.NeedNum - csStock.TakeQuantity;
csStockList[j].TakeQuantity = 0;
}
else
@ -483,7 +486,7 @@ namespace DM_Weight.ViewModels
//够取
ChannelStock newStock = new ChannelStock();
newStock.Chnguid = jiaoStock.Chnguid;
newStock.BaseQuantity = csStock.BaseQuantity;
newStock.BaseQuantity = jiaoStock.BaseQuantity;
newStock.DrawerNo = jiaoStock.DrawerNo;
newStock.DrugId = jiaoStock.DrugId;
newStock.ManuNo = csStock.ManuNo;
@ -492,13 +495,24 @@ namespace DM_Weight.ViewModels
newStock.Id = Guid.NewGuid().ToString();
newStock.MachineId=jiaoStock.MachineId;
AddJJStock.Add(newStock);
csStock.TakeQuantity = csStock.Quantity - newStock.AddToJJNum;
csStock.TakeQuantity = csStock.TakeQuantity - newStock.AddToJJNum;
break;
}
}
}
}
SqlSugarHelper.Db.Updateable<ChannelStock>()
.SetColumns(cs => new ChannelStock() { NeedNum = 0 })
.Where(cs => cs.DrawerNo == jiaoStock.DrawerNo)
.ExecuteCommand();
}
AddJJStock= AddJJStock.GroupBy(jj => new { jj.DrawerNo, jj.DrugId, jj.ManuNo })
.Select(jj =>
{
var ret = jj.First();
ret.AddToJJNum = jj.Sum(itx => itx.AddToJJNum);
return ret;
}).ToList();
//保存交接柜数据
SqlSugarHelper.Db.Insertable(AddJJStock).ExecuteCommand();
@ -548,15 +562,28 @@ namespace DM_Weight.ViewModels
});
if (f.Data)
{
// 更新屏显库存
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 5);
if (singleChannels.Count > 0)
Task.Factory.StartNew(() =>
{
singleChannels.ForEach(it =>
// 更新屏显库存
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 5);
if (singleChannels.Count > 0)
{
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
});
}
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 =>
{
_portUtil.WriteQuantityMethod((it.Quantity - it.TakeQuantity), it.DrawerNo, it.ColNo);
Thread.Sleep(150);
});
}
});
AlertMsg alertMsg = new AlertMsg
{
Message = "抽屉取药完成,库存已更新",

View File

@ -82,8 +82,9 @@ namespace DM_Weight.ViewModels
{
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);

View File

@ -797,13 +797,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
{
@ -204,12 +205,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 +241,30 @@ 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);
_portUtil.ShowContentMethod(item.DrawerNo, item.ColNo);
Task.Delay(200);
}
}
@ -292,54 +295,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 +373,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();
}
@ -438,12 +458,12 @@ namespace DM_Weight.ViewModels
{
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))
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(150);
}
}
});
RequestData();
AlertMsg alertMsg = new AlertMsg
{

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)
{
@ -327,38 +328,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.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);
Thread.Sleep(150);
}
}
});
RequestData();
AlertMsg alertMsg = new AlertMsg
{

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;
@ -339,27 +339,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(150);
});
}
});
RequestData();
AlertMsg alertMsg = new AlertMsg
{

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)
{
@ -369,27 +371,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(100);
}
}
});
AlertMsg alertMsg = new AlertMsg
{

View File

@ -194,18 +194,19 @@ 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)
.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)
.Where(i => i.InvoiceNo == SelectedInvoice.InvoiceNo&&i.Status==1&&i.Type==2&&i.CancelFlag==0)
.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 +216,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 +245,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 +272,18 @@ 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!="未绑定");
AddChannels.Sort((a, b) =>
{
if ((a.DrawerNo - b.DrawerNo) == 0)
@ -264,16 +293,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 +353,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 +378,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();
@ -433,26 +433,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(100);
}
}
});
AlertMsg alertMsg = new AlertMsg
{
Message = "调拨取药完成,库存已更新",

View File

@ -283,7 +283,7 @@ namespace DM_Weight.ViewModels
// 完成按钮
public DelegateCommand TakeFinish
{
get => new DelegateCommand(async() =>
get => new DelegateCommand(() =>
{
if (!_isFinishClick)
{
@ -427,26 +427,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(100);
}
}
});
AlertMsg alertMsg = new AlertMsg
{
Message = "处方退药完成,库存已更新",

View File

@ -457,8 +457,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 +467,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

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();
@ -359,19 +360,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(100);
}
});
AlertMsg alertMsg = new AlertMsg
{
Message = "操作完成,库存已更新",

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)
{
@ -361,34 +361,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(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);
//});
}
});
AlertMsg alertMsg = new AlertMsg
{
Message = "操作完成,库存已更新",

View File

@ -199,7 +199,7 @@ namespace DM_Weight.ViewModels
// 完成按钮
public DelegateCommand TakeFinish
{
get => new DelegateCommand(async() =>
get => new DelegateCommand(() =>
{
if (!_isFinishClick)
{
@ -336,25 +336,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(async 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(150);
}
}
});
AlertMsg alertMsg = new AlertMsg
{

View File

@ -0,0 +1,74 @@
using DM_Weight.Report;
using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.ViewModels
{
public class UseAccountWindowViewModel:BindableBase
{
private DateTime? _startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
private DateTime? nowDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
public DateTime? StartDate
{
get => _startDate;
set
{
if (value != null)
{
SetProperty(ref _startDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0));
}
else
{
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
{
if (value != null)
{
TimeSpan ershisi = new TimeSpan(23, 59, 59);
SetProperty(ref _endDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0, 23, 59, 59));
}
else
{
SetProperty(ref _endDate, value);
}
}
}
private string _name;
public string Name { get => _name; set { SetProperty(ref _name, 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;
}
/// <summary>
/// 导出账册
/// </summary>
public DelegateCommand DownloadAccountBook
{
get => new DelegateCommand(() =>
{
GridReportUtil.UserAccount(StartDate, EndDate, Name ?? "");
});
}
public bool KeepAlive => true;
}
}

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,69 @@
<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 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.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Margin="0 6 0 6" Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="9*" />
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Left">
<DatePicker
SelectedDate="{Binding StartDate, TargetNullValue=''}"
Margin="6 0 0 0"
materialDesign:HintAssist.Hint="开始时间"
Style="{StaticResource MaterialDesignOutlinedDatePicker}"
/>
<DatePicker
SelectedDate="{Binding EndDate}"
Margin="6 0 0 0"
materialDesign:HintAssist.Hint="结束时间"
Style="{StaticResource MaterialDesignOutlinedDatePicker}"
/>
<TextBox Margin="6 0 0 0" Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}" materialDesign:HintAssist.Hint="麻醉师姓名"
materialDesign:HintAssist.IsFloating="True" Width="100"/>
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
<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();
}
}
}