Compare commits
18 Commits
SanYa_ZhuYuan
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
ed833f7991 |
|
|
|
ff7716f63d |
|
|
|
2ef1c185e3 |
|
|
|
4f0297f4bc |
|
|
|
db02d51934 |
|
|
|
35695d2094 |
|
|
|
c36cbf4a1f |
|
|
|
a05d131dec |
|
|
|
358f5e57fd |
|
|
|
2f9e86fb75 |
|
|
|
9696d374b9 |
|
|
|
a450ef661d |
|
|
|
2f891bd446 |
|
|
|
e8e7bfc36d |
|
|
|
c9ff369dcf |
|
|
|
adf92e852d |
|
|
|
2d5dabf977 |
|
|
|
3bb1ef457a |
|
|
@ -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=hunanxianchang_db;userid=root;password=root" />
|
||||
<add name="database" connectionString="server=127.0.0.1;port=3306;database=hunanxianchang_db;userid=root;password=root;Pooling=false; ConnectionLifeTime=0;" />
|
||||
</connectionStrings>
|
||||
<!--<runtime>
|
||||
--><!--配置之后,Appdomain.CurrentDomain.UnhandledException 事件的 IsTerminating 就变成了 false 啦!也就是说,程序并不会因为这次的异常而崩溃退出。--><!--
|
||||
|
@ -20,7 +20,7 @@
|
|||
<!--2023/7/13 药房代码 有则写无则空 -->
|
||||
<add key="storage" value="" />
|
||||
<!-- 登录模式 1单人登录2双人登录 -->
|
||||
<add key="loginMode" value="2" />
|
||||
<add key="loginMode" value="1" />
|
||||
<!-- 登录顺序,指定先登录的人的名称有效值,只有在登录模式等于2时才会生效; 发药人:【operator】审核人:【reviewer】 -->
|
||||
<add key="firstLogin" value="operator" />
|
||||
<!-- 按处方还药或者按取药记录还药 1:处方2:药品-->
|
||||
|
@ -44,7 +44,7 @@
|
|||
<!-- can总线串口的串口号 -->
|
||||
<add key="CanBusPortPath" value="COM9" />
|
||||
<!-- 条码枪串口的串口号 -->
|
||||
<add key="ScanCodePortPath" value="COM11" />
|
||||
<add key="ScanCodePortPath" value="COM111" />
|
||||
<!-- 抽屉串口的串口号 --><!--
|
||||
<add key="DrawerPortPath" value="COM11" />
|
||||
--><!-- can总线串口的串口号 --><!--
|
||||
|
@ -61,6 +61,8 @@
|
|||
<add key="fingerIp" value="192.168.50.201"/>
|
||||
<!--一个抽屉对应标签数-->
|
||||
<add key="labelCount" value="2"/>
|
||||
<!--库存盘点17号库位线程等待时间(毫秒)-->
|
||||
<add key="CheckSleepMilliseconds" value="500"/>
|
||||
|
||||
</appSettings>
|
||||
</configuration>
|
|
@ -59,9 +59,9 @@ namespace DM_Weight
|
|||
private readonly ILog logger = LogManager.GetLogger(typeof(App));
|
||||
public App()
|
||||
{
|
||||
//TabTipAutomation.IgnoreHardwareKeyboard = HardwareKeyboardIgnoreOptions.IgnoreAll;
|
||||
//TabTipAutomation.BindTo<TextBox>();
|
||||
//TabTipAutomation.BindTo<PasswordBox>();
|
||||
TabTipAutomation.IgnoreHardwareKeyboard = HardwareKeyboardIgnoreOptions.IgnoreAll;
|
||||
TabTipAutomation.BindTo<TextBox>();
|
||||
TabTipAutomation.BindTo<PasswordBox>();
|
||||
}
|
||||
|
||||
|
||||
|
@ -252,12 +252,12 @@ namespace DM_Weight
|
|||
//交接班记录
|
||||
containerRegistry.RegisterForNavigation<ChangeShiftsListWindow, ChangeShiftsListWindowViewModel>();
|
||||
|
||||
|
||||
containerRegistry.RegisterForNavigation<PrintPdfView, PrintPdfViewModel>();
|
||||
|
||||
//交接班
|
||||
containerRegistry.RegisterForNavigation<ChangeShiftsDialog, ChangeShiftsDialogViewModel>();
|
||||
|
||||
containerRegistry.RegisterSingleton<SqlSugarScope>(() => SqlSugarHelperNew.GetInstance());
|
||||
//containerRegistry.RegisterSingleton<SqlSugarScope>(() => SqlSugarHelperNew.GetInstance());
|
||||
|
||||
//账册页面
|
||||
containerRegistry.RegisterForNavigation<AccountWindow,AccountWindowViewModel>();
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
using DM_Weight.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace DM_Weight.Converter
|
||||
{
|
||||
internal class ColorCountConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var total = 0;
|
||||
bool bInt = int.TryParse(value.ToString(), out var count); if (bInt)
|
||||
{
|
||||
if (count <= 0)
|
||||
{
|
||||
return "Red";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "black";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return "black";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -69,7 +69,9 @@
|
|||
<PackageReference Include="log4net" Version="2.0.15" />
|
||||
<PackageReference Include="MaterialDesignThemes" Version="4.8.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2365.46" />
|
||||
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
|
||||
<PackageReference Include="MySqlConnector" Version="2.3.6" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
|
||||
<PackageReference Include="Prism.Unity" Version="8.1.97" />
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.67" />
|
||||
|
|
|
@ -73,6 +73,8 @@ namespace DM_Weight.Models
|
|||
[SugarColumn(ColumnName = "quantity")]
|
||||
public int Quantity { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 默认值: 1
|
||||
|
@ -110,9 +112,19 @@ namespace DM_Weight.Models
|
|||
get => _addQuantity;
|
||||
set
|
||||
{
|
||||
if (value < 0)
|
||||
{
|
||||
throw new ArgumentException("加药数量不能小于0");
|
||||
}
|
||||
SetProperty(ref _addQuantity, value);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 调拨入库数量
|
||||
/// </summary>
|
||||
private int _invoiceQuantity;
|
||||
[SugarColumn(IsIgnore =true)]
|
||||
public int InvoiceQuantity { get=>_invoiceQuantity; set=>SetProperty(ref _invoiceQuantity, value); }
|
||||
|
||||
private int _takeQuantity = 0;
|
||||
|
||||
|
@ -126,9 +138,29 @@ namespace DM_Weight.Models
|
|||
{
|
||||
throw new ArgumentException("取药数量不能大于库存");
|
||||
}
|
||||
if(value< 0)
|
||||
{
|
||||
throw new ArgumentException("取药数量不能小于0");
|
||||
}
|
||||
if(OrderQuantity>0&&value>OrderQuantity)
|
||||
{
|
||||
throw new ArgumentException("取药数量不能大于应取数量");
|
||||
}
|
||||
SetProperty(ref _takeQuantity, value);
|
||||
}
|
||||
}
|
||||
|
||||
private int _orderQuantity = 0;
|
||||
/// <summary>
|
||||
/// 处方取药数量
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore =true)]
|
||||
public int OrderQuantity
|
||||
{
|
||||
get => _orderQuantity;
|
||||
set=>SetProperty(ref _orderQuantity, value);
|
||||
}
|
||||
|
||||
//private string _tipMessage=string.Empty;
|
||||
//[SugarColumn(IsIgnore = true)]
|
||||
//public string TipMessage
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace DM_Weight.Models
|
|||
[SugarColumn(ColumnName = "eff_date")]
|
||||
public DateTime? EffDate { get; set; }
|
||||
/// <summary>
|
||||
/// 出库入库类型(1入库2出库31还药32还空瓶)
|
||||
/// 出库入库类型(1入库2出库31还药32还空瓶4盘点5日结存)
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "type")]
|
||||
public int Type { get; set; }
|
||||
|
@ -106,13 +106,15 @@ namespace DM_Weight.Models
|
|||
/// 退药量
|
||||
/// 默认值: 0
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "return_quantity1", IsOnlyIgnoreInsert = true)]
|
||||
//[SugarColumn(ColumnName = "return_quantity1", IsOnlyIgnoreInsert = true)]
|
||||
[SugarColumn(ColumnName = "return_quantity1")]
|
||||
public int ReturnQuantity1 { get; set; }
|
||||
/// <summary>
|
||||
/// 退空瓶量
|
||||
/// 默认值: 0
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "return_quantity2", IsOnlyIgnoreInsert = true)]
|
||||
//[SugarColumn(ColumnName = "return_quantity2", IsOnlyIgnoreInsert = true
|
||||
[SugarColumn(ColumnName = "return_quantity2")]
|
||||
public int ReturnQuantity2 { get; set; }
|
||||
/// <summary>
|
||||
/// 取药记录id
|
||||
|
|
|
@ -127,5 +127,10 @@ namespace DM_Weight.Models
|
|||
///</summary>
|
||||
[SugarColumn(ColumnName = "use_dosage")]
|
||||
public string UseDosage { get; set; }
|
||||
/// <summary>
|
||||
/// 处方中该药品状态是否已全部取出0未取1已取(针对处方可取部分药)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "dm_status")]
|
||||
public int? DMStatus { get;set; }
|
||||
}
|
||||
}
|
|
@ -1041,6 +1041,7 @@ namespace DM_Weight.Port
|
|||
Array.Resize(ref contentBuf, contentBuf.Length + 1);
|
||||
}
|
||||
byte[] buffer = new byte[] { 0xaa, (byte)channel, 1, (byte)type, 0, 0, 0, 0xee };
|
||||
logger.Info($"buffer:{Convert.ToHexString(buffer)}");
|
||||
canBusSerial.Write(buffer, 0, 8);
|
||||
//await Task.Delay(20);
|
||||
Thread.Sleep(20);
|
||||
|
@ -1050,6 +1051,7 @@ namespace DM_Weight.Port
|
|||
buffer[5] = contentBuf[i];
|
||||
buffer[6] = contentBuf[i + 1];
|
||||
canBusSerial.Write(buffer, 0, 8);
|
||||
logger.Info($"buffer:{Convert.ToHexString(buffer)}");
|
||||
//await Task.Delay(20);
|
||||
Thread.Sleep(20);
|
||||
}
|
||||
|
@ -1089,6 +1091,7 @@ namespace DM_Weight.Port
|
|||
canBusSerial.DiscardInBuffer();
|
||||
int channel = ((drawerNo > 8 ? (drawerNo - 8) * 2 : (drawerNo * 2 - 1)) - 1) * this.labelCount + 10 + colNo;
|
||||
byte[] buffer = new byte[] { 0xaa, (byte)channel, 2, 0, 0, 0, 0, 0xee };
|
||||
logger.Info($"刷新显示内容buffer:{Convert.ToHexString(buffer)}");
|
||||
canBusSerial.Write(buffer, 0, 8);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -1107,6 +1110,7 @@ namespace DM_Weight.Port
|
|||
{
|
||||
try
|
||||
{
|
||||
logger.Info($"TakeQuantity{drawerNo}-{colNo},操作数量{quantity},操作后数量{stock}");
|
||||
|
||||
canBusSerial.DiscardInBuffer();
|
||||
//int channel = (drawerNo * 10 + colNo);
|
||||
|
@ -1145,14 +1149,14 @@ namespace DM_Weight.Port
|
|||
buffer[6] = (byte)(quantity & 0xff);
|
||||
logger.Info($"写入数量buffer:{Convert.ToHexString(buffer)}");
|
||||
canBusSerial.Write(buffer, 0, 8);
|
||||
Task<byte[]> task = GetBufferByPort(canBusSerial, 8);
|
||||
if (task.Status == TaskStatus.Created)
|
||||
{
|
||||
task.Start();
|
||||
//Task<byte[]> task = GetBufferByPort(canBusSerial, 8);
|
||||
//if (task.Status == TaskStatus.Created)
|
||||
//{
|
||||
// task.Start();
|
||||
|
||||
}
|
||||
byte[] bytes = task.Result;
|
||||
logger.Info($"写入数量返回:" + Convert.ToHexString(bytes));
|
||||
//}
|
||||
//byte[] bytes = task.Result;
|
||||
//logger.Info($"写入数量返回:" + Convert.ToHexString(bytes));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -9,6 +9,11 @@ using System.Threading.Tasks;
|
|||
using DM_Weight.Models;
|
||||
using System.Configuration;
|
||||
using DM_Weight.util;
|
||||
using DM_Weight.Views;
|
||||
using System.Diagnostics;
|
||||
using log4net;
|
||||
using log4net.Repository.Hierarchy;
|
||||
using DM_Weight.ViewModels;
|
||||
|
||||
namespace DM_Weight.Report
|
||||
{
|
||||
|
@ -17,7 +22,7 @@ namespace DM_Weight.Report
|
|||
|
||||
// 定义Grid++Report报表主对象
|
||||
public static GridppReport Report = new GridppReport();
|
||||
public static string gridConnectionString = ConfigurationManager.AppSettings["gridConnectionString"];
|
||||
public static string gridConnectionString = ConfigurationManager.AppSettings["gridConnectionString"];
|
||||
/**
|
||||
* 打印预览
|
||||
* tempname: 模板文件名称
|
||||
|
@ -43,7 +48,7 @@ namespace DM_Weight.Report
|
|||
{
|
||||
Report.ParameterByName("machine_id").Value = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
|
||||
});
|
||||
string machine_id=(ConfigurationManager.AppSettings["machineId"] ?? "DM1");
|
||||
string machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
|
||||
string SQL = $@"SELECT cl.`row_no` AS drawerNo,cl.`col_no` AS colNo,cl.`quantity` AS quantity,cl.`manu_no` AS manuNo,cl.`eff_date` AS effDate,
|
||||
di.`drug_name` AS drugName,di.`drug_spec` AS drugSpec,di.`pack_unit` AS packUnit,di.`manufactory` AS manuFactory,di.`max_stock` AS baseQuantity,
|
||||
cl.`drug_id` AS drugId FROM channel_stock cl INNER JOIN drug_info di ON di.`drug_id` = cl.`drug_id` WHERE cl.`machine_id` = '{machine_id}' AND cl.`drawer_type` = 1 ORDER BY cl.`drug_id`";
|
||||
|
@ -51,7 +56,22 @@ namespace DM_Weight.Report
|
|||
Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "stock_template.grf");
|
||||
Report.DetailGrid.Recordset.ConnectionString = gridConnectionString;
|
||||
Report.DetailGrid.Recordset.QuerySQL = SQL;
|
||||
Report.PrintPreview(true);
|
||||
//Report.PrintPreview(true);
|
||||
string filePath = AppDomain.CurrentDomain.BaseDirectory + "ReportTemp//" + "stock_template.pdf";
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
File.Delete(filePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FindAndKillProcess();
|
||||
|
||||
}
|
||||
}
|
||||
Report.ExportDirect(GRExportType.gretPDF, filePath, false, true);
|
||||
}
|
||||
/// <summary>
|
||||
/// 导出盘点后库存信息
|
||||
|
@ -76,15 +96,64 @@ namespace DM_Weight.Report
|
|||
Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "machine_log_check_new2.grf");
|
||||
Report.DetailGrid.Recordset.ConnectionString = gridConnectionString;
|
||||
Report.DetailGrid.Recordset.QuerySQL = SQL;
|
||||
Report.PrintPreview(true);
|
||||
// Report.PrintPreview(true);
|
||||
|
||||
string filePath = AppDomain.CurrentDomain.BaseDirectory + "ReportTemp//" + "machine_log_check_new2.pdf";
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
File.Delete(filePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FindAndKillProcess();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Report.ExportDirect(GRExportType.gretPDF, filePath, false, true);
|
||||
}
|
||||
public static void PrintReportAccountBook(DateTime? startDate, DateTime? endDate,int type,string drug_id)
|
||||
public static Task<string> PrintReportStockNewTest(DateTime? startDate, DateTime? endDate)
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
string filePath = string.Empty;
|
||||
DateTime? p_startDate = startDate ?? Convert.ToDateTime("2010-1-1");
|
||||
DateTime? p_endDate = endDate ?? DateTime.Now.AddDays(1);
|
||||
// 定义Grid++Report报表主对象
|
||||
GridppReport Report = new GridppReport();
|
||||
//Report.Initialize += new _IGridppReportEvents_InitializeEventHandler(() =>
|
||||
//{
|
||||
// Report.ParameterByName("machine_id").Value = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
|
||||
//});
|
||||
string machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
|
||||
string SQL = $@"SELECT cl.`row_no` AS drawerNo,cl.`col_no` AS colNo,cl.`quantity` AS quantity,cl.`manu_no` AS manuNo,cl.`eff_date` AS effDate,
|
||||
`drug_name` AS drugName,`drug_spec` AS drugSpec,`pack_unit` AS packUnit,`manufactory` AS manuFactory,`max_stock` AS baseQuantity,
|
||||
cl.`drug_id` AS drugId,cl.manuquantity, cl.`optdate` FROM check_stock cl WHERE cl.`machine_id` = '{machine_id}' AND cl.`optdate` > '{p_startDate}' AND cl.`optdate` < '{p_endDate}' ORDER BY cl.`optdate` desc, cl.`drug_id`";
|
||||
// 加载模板文件
|
||||
Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "machine_log_check_new2.grf");
|
||||
Report.DetailGrid.Recordset.ConnectionString = gridConnectionString;
|
||||
Report.DetailGrid.Recordset.QuerySQL = SQL;
|
||||
// Report.PrintPreview(true);
|
||||
//Report.SaveToFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "Test.pdf");
|
||||
bool isSave = Report.ExportDirect(GRExportType.gretPDF, new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "machine_log_check_new2.pdf", false, false);
|
||||
|
||||
if (isSave)
|
||||
{
|
||||
filePath = AppDomain.CurrentDomain.BaseDirectory + "ReportTemp\\" + "machine_log_check_new2.pdf";
|
||||
}
|
||||
return filePath;
|
||||
});
|
||||
}
|
||||
public static void PrintReportAccountBook(DateTime? startDate, DateTime? endDate, int type, string drug_id)
|
||||
{
|
||||
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 p_machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
|
||||
// 定义Grid++Report报表主对象
|
||||
GridppReport Report = new GridppReport();
|
||||
GridppReport Report = new GridppReport();
|
||||
// 加载模板文件
|
||||
Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "account_book_temp.grf");
|
||||
string SQL = string.Empty;
|
||||
|
@ -98,19 +167,20 @@ namespace DM_Weight.Report
|
|||
//Report.DetailGrid.Recordset.QuerySQL = SQL;
|
||||
SQL = $@"SELECT TYPE, stockQuantity,inQuantity,outQuantity,operationTime,invoiceId,drugName,drugId,drugSpec,packUnit,dosage,manufactory,manuNo,effDate,
|
||||
operatorName,reviewerName,supplierDept,receiveDept,bigUnit FROM
|
||||
(SELECT mr.type, mr.`stock_quantity` AS `stockQuantity`, IF(mr.`type` IN (1, 31), mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` > 0, mr.`quantity`, 0))
|
||||
AS `inQuantity`, IF(mr.`type` = 2, mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` < 0, (0 - mr.`quantity`), 0)) AS `outQuantity`,
|
||||
mr.`operation_time` AS `operationTime`,IF(mr.`type`=1,mr.`invoice_id`,NULL) AS `invoiceId`, di.`drug_name` AS `drugName`, di.`drug_id` AS `drugId`,
|
||||
(SELECT mr.type, mr.`stock_quantity` AS `stockQuantity`,
|
||||
IF(mr.`type` IN (1, 31), mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` > 0, mr.`quantity`, IF(mr.`type` = 5,mr.return_quantity1,0))) AS `inQuantity`,
|
||||
IF(mr.`type` = 2, mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` < 0, (0 - mr.`quantity`), IF(mr.`type` = 5,mr.return_quantity2,0))) AS `outQuantity`,
|
||||
mr.`operation_time` AS `operationTime`,IF(mr.`type`=1||mr.type=5,mr.`invoice_id`,NULL) AS `invoiceId`, di.`drug_name` AS `drugName`, di.`drug_id` AS `drugId`,
|
||||
di.`drug_spec` AS `drugSpec`, di.`pack_unit` AS `packUnit`,di.big_unit as bigUnit, di.`dosage` AS `dosage`, di.`manufactory` AS `manufactory`,
|
||||
mr.`manu_no` AS `manuNo`, mr.`eff_date` AS `effDate`, u1.`user_name` AS `operatorName`, u2.`user_name` AS `reviewerName`,mr.supplierDept,mr.receiveDept FROM
|
||||
dm_machine_record mr LEFT JOIN drug_info di ON mr.`drug_id` = di.`drug_id` LEFT JOIN user_list u1 ON mr.`operator` = u1.`id`
|
||||
LEFT JOIN user_list u2 ON mr.`reviewer` = u2.`id` WHERE mr.`machine_id` = '{p_machine_id}' AND mr.`operation_time` > '{p_startDate}'
|
||||
AND mr.`operation_time` < '{p_endDate}' and IF(mr.`type` = 4 AND mr.`quantity` = 0, 99999, mr.`quantity`) <>99999 ";
|
||||
if(!string.IsNullOrEmpty(drug_id))
|
||||
if (!string.IsNullOrEmpty(drug_id))
|
||||
{
|
||||
SQL+= " AND mr.drug_id='"+ drug_id+"' ";
|
||||
SQL += " AND mr.drug_id='" + drug_id + "' ";
|
||||
}
|
||||
SQL+= " ORDER BY mr.`drug_id`, mr.`operation_time`, mr.`id`) AS T";
|
||||
SQL += " ORDER BY mr.`drug_id`, mr.`operation_time`, mr.`id`) AS T";
|
||||
if (type > 0)
|
||||
{
|
||||
if (type == 1)
|
||||
|
@ -127,11 +197,27 @@ namespace DM_Weight.Report
|
|||
}
|
||||
}
|
||||
Report.DetailGrid.Recordset.QuerySQL = SQL;
|
||||
Report.PrintPreview(true);
|
||||
//Report.PrintPreview(true);
|
||||
string filePath = AppDomain.CurrentDomain.BaseDirectory + "ReportTemp//" + "account_book_temp.pdf";
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
File.Delete(filePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FindAndKillProcess();
|
||||
|
||||
}
|
||||
}
|
||||
Report.ExportDirect(GRExportType.gretPDF, filePath, false, true);
|
||||
}
|
||||
|
||||
public static void PrintReportMechineRecord(int type, DateTime? startDate, DateTime? endDate)
|
||||
{
|
||||
string saveFileName = string.Empty;
|
||||
// 定义Grid++Report报表主对象
|
||||
GridppReport Report = new GridppReport();
|
||||
DateTime? p_startDate = startDate ?? Convert.ToDateTime("2010-1-1");
|
||||
|
@ -147,6 +233,7 @@ namespace DM_Weight.Report
|
|||
// 加载模板文件
|
||||
if (type == 1)
|
||||
{
|
||||
saveFileName = "machine_log_add.pdf";
|
||||
Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "machine_log_add.grf");
|
||||
SQL = $@"SELECT dmr.`drawer_no` AS drawerNo,dmr.`col_no` AS colNo,dmr.`type` AS `type`,dmr.`quantity` AS quantity,
|
||||
dmr.`manu_no` AS manuNo,dmr.`eff_date` AS effDate,dmr.`operation_time` AS operationTime,
|
||||
|
@ -158,6 +245,8 @@ namespace DM_Weight.Report
|
|||
}
|
||||
else if (type == 2)
|
||||
{
|
||||
|
||||
saveFileName = "machine_log_take.pdf";
|
||||
Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "machine_log_take.grf");
|
||||
SQL = $@" SELECT dmr.`drawer_no` AS drawerNo,dmr.`col_no` AS colNo,dmr.`type` AS `type`,dmr.`quantity` AS quantity,
|
||||
dmr.`manu_no` AS manuNo,dmr.`eff_date` AS effDate,dmr.`operation_time` AS operationTime,
|
||||
|
@ -170,6 +259,8 @@ namespace DM_Weight.Report
|
|||
}
|
||||
else if (type == 3)
|
||||
{
|
||||
|
||||
saveFileName = "machine_log_return.pdf";
|
||||
Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "machine_log_return.grf");
|
||||
SQL = $@" SELECT dmr.`drawer_no` AS drawerNo,dmr.`col_no` AS colNo,dmr.`type` AS `type`,
|
||||
CONCAT(dmr.`quantity`,IF(dmr.`type`=32,""(空瓶)"","""")) AS quantity,dmr.`manu_no` AS manuNo,
|
||||
|
@ -183,6 +274,7 @@ namespace DM_Weight.Report
|
|||
}
|
||||
else
|
||||
{
|
||||
saveFileName = "machine_log_check.pdf";
|
||||
Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "machine_log_check.grf");
|
||||
SQL = $@" SELECT dmr.`drawer_no` AS drawerNo,dmr.`col_no` AS colNo,dmr.`type` AS `type`,dmr.`check_quantity` AS quantity,
|
||||
dmr.`manu_no` AS manuNo,dmr.`eff_date` AS effDate,dmr.`operation_time` AS operationTime,
|
||||
|
@ -195,14 +287,41 @@ namespace DM_Weight.Report
|
|||
AND dmr.`machine_id` = '{p_machine_id}' AND dmr.`operation_time` > '{p_startDate}'
|
||||
AND dmr.`operation_time` < '{p_endDate}'";
|
||||
}
|
||||
|
||||
Report.DetailGrid.Recordset.ConnectionString = gridConnectionString;
|
||||
Report.DetailGrid.Recordset.QuerySQL= SQL;
|
||||
|
||||
Report.PrintPreview(true);
|
||||
Report.DetailGrid.Recordset.ConnectionString = gridConnectionString;
|
||||
Report.DetailGrid.Recordset.QuerySQL = SQL;
|
||||
|
||||
//Report.PrintPreview(true);
|
||||
string filePath = AppDomain.CurrentDomain.BaseDirectory + "ReportTemp//" + saveFileName;
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
File.Delete(filePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FindAndKillProcess();
|
||||
|
||||
}
|
||||
}
|
||||
Report.ExportDirect(GRExportType.gretPDF, filePath, false, true);
|
||||
}
|
||||
|
||||
|
||||
public static bool FindAndKillProcess()
|
||||
{
|
||||
foreach (Process clsProcess in Process.GetProcesses())
|
||||
{
|
||||
if (clsProcess.ProcessName.Contains("wps")||clsProcess.ProcessName.Contains("msedge"))
|
||||
{
|
||||
clsProcess.Kill();
|
||||
//return true;
|
||||
}
|
||||
}
|
||||
//process not found, return false
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印预览
|
||||
|
@ -215,13 +334,28 @@ namespace DM_Weight.Report
|
|||
GridppReport Report = new GridppReport();
|
||||
// 加载模板文件
|
||||
Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//machine_log.grf");
|
||||
|
||||
|
||||
// 加载数据
|
||||
Report.ParameterByName("type").AsInteger = 1;
|
||||
Report.PrintPreview(true);
|
||||
//Report.PrintPreview(true);
|
||||
string filePath = AppDomain.CurrentDomain.BaseDirectory + "ReportTemp//" + "machine_log.pdf";
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
File.Delete(filePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FindAndKillProcess();
|
||||
|
||||
}
|
||||
}
|
||||
Report.ExportDirect(GRExportType.gretPDF, filePath, false, true);
|
||||
}
|
||||
//交接班记录报表
|
||||
public static void PrintChangeShiftsReport(DateTime? startDate,DateTime? endDate)
|
||||
public static void PrintChangeShiftsReport(DateTime? startDate, DateTime? endDate)
|
||||
{
|
||||
DateTime? p_startDate = startDate ?? Convert.ToDateTime("2010-1-1");
|
||||
DateTime? p_endDate = endDate ?? DateTime.Now.AddDays(1);
|
||||
|
@ -243,7 +377,23 @@ namespace DM_Weight.Report
|
|||
from `hkc_shiftsreport` WHERE `machineid` = '{p_machine_id}' AND `opt_date` > '{p_startDate}'
|
||||
AND opt_date < '{p_endDate}' ORDER BY opt_date";
|
||||
Report.DetailGrid.Recordset.QuerySQL = SQL;
|
||||
Report.PrintPreview(true);
|
||||
//Report.PrintPreview(true);
|
||||
string filePath = AppDomain.CurrentDomain.BaseDirectory + "ReportTemp//" + "changeShifts_temp.pdf";
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
File.Delete(filePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FindAndKillProcess();
|
||||
|
||||
}
|
||||
}
|
||||
Report.ExportDirect(GRExportType.gretPDF, filePath, false, true);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -258,12 +408,27 @@ namespace DM_Weight.Report
|
|||
GridppReport Report = new GridppReport();
|
||||
// 加载模板文件
|
||||
Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//machine_log_check.grf");
|
||||
Dictionary<string,List<MachineRecord>> records = new Dictionary<string,List<MachineRecord>>();
|
||||
Dictionary<string, List<MachineRecord>> records = new Dictionary<string, List<MachineRecord>>();
|
||||
records.Add("table", data);
|
||||
string str= JsonConvert.SerializeObject(records);
|
||||
string str = JsonConvert.SerializeObject(records);
|
||||
Report.LoadDataFromXML(str);
|
||||
// 加载数据
|
||||
Report.PrintPreview(true);
|
||||
//Report.PrintPreview(true);
|
||||
string filePath = AppDomain.CurrentDomain.BaseDirectory + "ReportTemp//" + "machine_log_check.pdf";
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
File.Delete(filePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FindAndKillProcess();
|
||||
|
||||
}
|
||||
}
|
||||
Report.ExportDirect(GRExportType.gretPDF, filePath, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,7 +166,9 @@
|
|||
"ColumnContentCell":[
|
||||
{
|
||||
"Column":"日期",
|
||||
"WordWrap":true,
|
||||
"TextAlign":"MiddleCenter",
|
||||
"ShrinkFontToFit":true,
|
||||
"DataField":"日期"
|
||||
},
|
||||
{
|
||||
|
|
|
@ -91,6 +91,7 @@
|
|||
"ColumnContentCell":[
|
||||
{
|
||||
"Column":"盘点日期",
|
||||
"WordWrap":true,
|
||||
"DataField":"盘点日期"
|
||||
},
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace DM_Weight.Services
|
|||
string SQL = $@"SELECT CS.drug_id as DrugId,CS.manu_no as ManuNo,sum(quantity) as Quantity,CS.eff_date as EffDate,DI.drug_name as DrugName,
|
||||
DI.drug_spec as DrugSpec,DI.dosage as Dosage,DI.manufactory as ManuFactory,DI.small_unit as SmallUnit,DI.pack_unit as PackUnit,
|
||||
CS.machine_id as MachineId FROM channel_stock CS
|
||||
INNER JOIN drug_info DI ON CS.drug_id=DI.drug_id where CS.machine_id='{p_machine_id}' AND quantity>0 GROUP BY CS.drug_id,CS.manu_no ";
|
||||
INNER JOIN drug_info DI ON CS.drug_id=DI.drug_id where CS.machine_id='{p_machine_id}' AND quantity>0 GROUP BY CS.drug_id";//,CS.manu_no ";
|
||||
|
||||
List<ChannelStockCount> accountList = SqlSugarHelper.Db.SqlQueryable<ChannelStockCount>(SQL).ToList();
|
||||
//List<ChannelStock> accountList = SqlSugarHelper.Db.Queryable<ChannelStock>().Includes<DrugInfo>(cs=>cs.DrugInfo)
|
||||
|
|
|
@ -30,9 +30,9 @@ namespace DM_Weight.Services
|
|||
string p_machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
|
||||
string SQL = $@"SELECT TYPE, stockQuantity,inQuantity,outQuantity,operationTime,invoiceId,drugName,drugId,drugSpec,packUnit,dosage,manufactory,manuNo,effDate,
|
||||
operatorName,reviewerName,supplierDept,receiveDept FROM
|
||||
(SELECT mr.type,mr.`stock_quantity` AS `stockQuantity`, IF(mr.`type` IN (1, 31), mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` > 0, mr.`quantity`, 0))
|
||||
AS `inQuantity`, IF(mr.`type` = 2, mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` < 0, (0 - mr.`quantity`), 0)) AS `outQuantity`,
|
||||
DATE_FORMAT(mr.`operation_time`,'%m/%d') AS `operationTime`,IF(mr.`type`=1,mr.`invoice_id`,NULL) AS `invoiceId`, di.`drug_name` AS `drugName`, di.`drug_id` AS `drugId`,
|
||||
(SELECT mr.type,mr.`stock_quantity` AS `stockQuantity`, IF(mr.`type` IN (1, 31), mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` > 0, mr.`quantity`, IF(mr.`type` = 5,mr.return_quantity1,0)))
|
||||
AS `inQuantity`, IF(mr.`type` = 2, mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` < 0, (0 - mr.`quantity`), IF(mr.`type` = 5,mr.return_quantity2,0))) AS `outQuantity`,
|
||||
DATE_FORMAT(mr.`operation_time`,'%m/%d') AS `operationTime`,IF(mr.`type`=1||mr.type=5,mr.`invoice_id`,NULL) AS `invoiceId`, di.`drug_name` AS `drugName`, di.`drug_id` AS `drugId`,
|
||||
di.`drug_spec` AS `drugSpec`, di.`pack_unit` AS `packUnit`, di.`dosage` AS `dosage`, di.`manufactory` AS `manufactory`,
|
||||
mr.`manu_no` AS `manuNo`, DATE_FORMAT(mr.`eff_date`,'%y/%m/%d') AS `effDate`, u1.`user_name` AS `operatorName`, u2.`user_name` AS `reviewerName`,mr.supplierDept,mr.receiveDept FROM
|
||||
dm_machine_record mr LEFT JOIN drug_info di ON mr.`drug_id` = di.`drug_id` LEFT JOIN user_list u1 ON mr.`operator` = u1.`id`
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using DM_Weight.Models;
|
||||
using log4net;
|
||||
using log4net.Repository.Hierarchy;
|
||||
using MySqlConnector;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
|
@ -6,49 +8,98 @@ using System.Collections.Generic;
|
|||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DM_Weight.Services
|
||||
{
|
||||
public class UserService
|
||||
{
|
||||
private readonly ILog logger = LogManager.GetLogger(typeof(UserService));
|
||||
//public static string connStr = ConfigurationManager.AppSettings["database"].ToString();
|
||||
public static string connStr = ConfigurationManager.ConnectionStrings["database"].ToString();
|
||||
public UserList CheckUserByFingerPrinter(int fingerPrinterId)
|
||||
public UserList CheckUserByFingerPrinter(int fingerPrinterId)
|
||||
{
|
||||
UserList? user = null;
|
||||
|
||||
using (MySqlConnection con = new MySqlConnection(connStr))
|
||||
{
|
||||
con.Open();
|
||||
logger.Info($"connStr:{connStr}");
|
||||
//try
|
||||
//{
|
||||
// con.Open();
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// logger.Info($"Open失败:{ex.ToString()}");
|
||||
// if (con.State == System.Data.ConnectionState.Open)
|
||||
// {
|
||||
// con.Close();
|
||||
// }
|
||||
// Thread.Sleep(200);
|
||||
// logger.Info("再次Open");
|
||||
// con.Open();
|
||||
//}
|
||||
connOpen(con);
|
||||
Thread.Sleep(100);
|
||||
while(con.State != System.Data.ConnectionState.Open)
|
||||
{
|
||||
logger.Info($"再次Open:{con.State}");
|
||||
connOpen(con);
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
|
||||
logger.Info("数据库连接已打开");
|
||||
string sql = @"select ul.id as id,ul.User_name as userName,r.id,r.role_name,r.permissions,r.machine_id from user_list ul
|
||||
INNER JOIN role r on ul.machine_role_id=r.id where ul.Id=@ID and ul.machine_id=@machine_id and r.machine_id=@machine_id;";
|
||||
MySqlCommand cmd = new MySqlCommand(sql, con);
|
||||
cmd.Parameters.Clear();
|
||||
MySqlParameter[] mySqlParameter = new MySqlParameter[] {new MySqlParameter("ID", fingerPrinterId),new MySqlParameter("machine_id", (ConfigurationManager.AppSettings["machineId"] ?? "DM1")) };
|
||||
MySqlParameter[] mySqlParameter = new MySqlParameter[] { new MySqlParameter("ID", fingerPrinterId), new MySqlParameter("machine_id", (ConfigurationManager.AppSettings["machineId"] ?? "DM1")) };
|
||||
cmd.Parameters.AddRange(mySqlParameter);
|
||||
//执行语句
|
||||
MySqlDataReader reader = cmd.ExecuteReader();
|
||||
logger.Info("MySqlDataReader读数据");
|
||||
while (reader.Read())
|
||||
{
|
||||
user = new UserList();
|
||||
user.Id = reader.GetInt32("id");
|
||||
user.UserName = reader["userName"] is DBNull ? "" : reader.GetString("userName");
|
||||
//user.UserName = reader["id"] is DBNull ? "" : reader.GetString("id");
|
||||
user.Nickname= reader["userName"] is DBNull ? "" : reader.GetString("userName");
|
||||
user.Nickname = reader["userName"] is DBNull ? "" : reader.GetString("userName");
|
||||
user.MachineId = reader["machine_id"] is DBNull ? "" : reader.GetString("machine_id");
|
||||
RoleDm role= new RoleDm();
|
||||
role.Id= reader.GetInt32("id");
|
||||
RoleDm role = new RoleDm();
|
||||
role.Id = reader.GetInt32("id");
|
||||
//role.Permissions = reader["permissions"] is DBNull ? "" : reader.GetString("permissions");
|
||||
role.RoleName = reader["role_name"] is DBNull ? "" : reader.GetString("role_name");
|
||||
role.Permissions = JsonConvert.DeserializeObject<List<PremissionDm>>(reader["permissions"] is DBNull ? "" : reader.GetString("permissions")); // JsonConvert.SerializeObject(reader.GetString("permissions")).ToList();
|
||||
user.Role = role;
|
||||
}
|
||||
reader.Close();
|
||||
|
||||
reader.Close();
|
||||
logger.Info($"sql:{sql}");
|
||||
return user;
|
||||
}
|
||||
|
||||
}
|
||||
private Task connOpen(MySqlConnection con)
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
if (con.State == System.Data.ConnectionState.Open)
|
||||
{
|
||||
con.Close();
|
||||
}
|
||||
try
|
||||
{
|
||||
con.Open();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Info($"Open失败:{ex.Message}");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -237,8 +237,13 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
try
|
||||
{
|
||||
|
||||
//查询账册中所有记录,与库存中的记录做比校,如果账册中没有,则添加一条
|
||||
string machineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
|
||||
//删除已生成的日结存记录
|
||||
int deleteNum = SqlSugarHelper.Db.Deleteable<MachineRecord>()
|
||||
.Where(cs => cs.Type.Equals(5) && cs.OperationTime.ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd") && cs.MachineId.Equals(machineId)).ExecuteCommand();
|
||||
int inQuantity = 0; //当日入库量
|
||||
int outQuantity = 0; //当日出库量
|
||||
//查询账册中所有记录,与库存中的记录做比校,如果账册中没有,则添加一条,有则添加一条总日结存
|
||||
List<AccountModel> accountList = _machineRecordService.ReportAccountBook(nowDate, null, 0);
|
||||
//库存中的记录
|
||||
List<ChannelStockCount> channelStockList = _channelStockService.GetAll();
|
||||
|
@ -249,33 +254,47 @@ namespace DM_Weight.ViewModels
|
|||
|
||||
for (int i = 0; i < channelStockList.Count; i++)
|
||||
{
|
||||
int Count = accountList.Where(cs => cs.DrugId == channelStockList[i].DrugId && cs.ManuNo == channelStockList[i].ManuNo).Count();
|
||||
int Count = accountList.Where(cs => cs.DrugId == channelStockList[i].DrugId).Count();
|
||||
|
||||
if (Count <= 0)
|
||||
{
|
||||
//没有直接插入
|
||||
// 保存数据 出/入库记录
|
||||
string InvoiceId = "Account_" + CurrentTimeMillis();
|
||||
SqlSugarHelper.Db.Insertable(new MachineRecord()
|
||||
{
|
||||
MachineId = channelStockList[i].MachineId,
|
||||
DrawerNo = 0,//channelStockList[i].DrawerNo,
|
||||
ColNo = 0,// channelStockList[i].ColNo,FV
|
||||
DrugId = channelStockList[i].DrugId,
|
||||
ManuNo = channelStockList[i].ManuNo,
|
||||
EffDate = !String.IsNullOrEmpty(channelStockList[i].EffDate) ? DateTime.ParseExact(channelStockList[i].EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
|
||||
Operator = HomeWindowViewModel.Operator?.Id,
|
||||
Reviewer = HomeWindowViewModel.Reviewer?.Id,
|
||||
OperationTime = DateTime.Now,
|
||||
Quantity = 0,
|
||||
Type = 5,
|
||||
InvoiceId = string.Empty,//InvoiceId,
|
||||
StockQuantity = channelStockList[i].Quantity,
|
||||
ManunoQuantity = 0,
|
||||
SupplierDept = ConfigurationManager.AppSettings["supplierDept"].ToString(),
|
||||
ReceiveDept = ConfigurationManager.AppSettings["receiveDept"].ToString()
|
||||
}).ExecuteCommand();
|
||||
|
||||
inQuantity = 0;
|
||||
outQuantity = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
inQuantity = accountList.Where(cs => cs.DrugId == channelStockList[i].DrugId).Sum(cs => cs.InQuantity);
|
||||
outQuantity= accountList.Where(cs => cs.DrugId == channelStockList[i].DrugId).Sum(cs => cs.OutQuantity);
|
||||
}
|
||||
// 获取药品总库存
|
||||
int channelStockQuantity = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
.Where(cs => cs.DrugId.Equals(channelStockList[i].DrugId)).Sum(it => it.Quantity);
|
||||
//没有直接插入
|
||||
// 保存数据 出/入库记录
|
||||
string InvoiceId = "Account_" + CurrentTimeMillis();
|
||||
SqlSugarHelper.Db.Insertable(new MachineRecord()
|
||||
{
|
||||
MachineId = channelStockList[i].MachineId,
|
||||
DrawerNo = 0,//channelStockList[i].DrawerNo,
|
||||
ColNo = 0,// channelStockList[i].ColNo,FV
|
||||
DrugId = channelStockList[i].DrugId,
|
||||
ManuNo = "",//channelStockList[i].ManuNo,
|
||||
EffDate = null,// !String.IsNullOrEmpty(channelStockList[i].EffDate) ? DateTime.ParseExact(channelStockList[i].EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
|
||||
Operator = HomeWindowViewModel.Operator?.Id,
|
||||
Reviewer = HomeWindowViewModel.Reviewer?.Id,
|
||||
OperationTime = DateTime.Now,
|
||||
Quantity = 0,
|
||||
Type = 5,
|
||||
InvoiceId = "日结存",//InvoiceId,
|
||||
ReturnQuantity1 = inQuantity, //当日入库量总数
|
||||
ReturnQuantity2 = outQuantity, //当日出库量总数
|
||||
StockQuantity = channelStockQuantity,
|
||||
ManunoQuantity = 0,
|
||||
SupplierDept =string.Empty,// ConfigurationManager.AppSettings["supplierDept"].ToString(),
|
||||
ReceiveDept = string.Empty,//ConfigurationManager.AppSettings["receiveDept"].ToString()
|
||||
}).ExecuteCommand();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -284,6 +303,11 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
//账册中没有记录则把库存中的所有数据都要生成一条账册记录
|
||||
// 保存数据 出/入库记录
|
||||
// 获取药品总库存
|
||||
int channelStockQuantity = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
.Where(cs => cs.DrugId.Equals(channelStockList[i].DrugId)).Sum(it => it.Quantity);
|
||||
|
||||
|
||||
string InvoiceId = "Account_" + CurrentTimeMillis();
|
||||
SqlSugarHelper.Db.Insertable(new MachineRecord()
|
||||
{
|
||||
|
@ -291,18 +315,20 @@ namespace DM_Weight.ViewModels
|
|||
DrawerNo = 0,//channelStockList[i].DrawerNo,
|
||||
ColNo = 0,//channelStockList[i].ColNo,
|
||||
DrugId = channelStockList[i].DrugId,
|
||||
ManuNo = channelStockList[i].ManuNo,
|
||||
EffDate = !String.IsNullOrEmpty(channelStockList[i].EffDate) ? DateTime.ParseExact(channelStockList[i].EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
|
||||
ManuNo = "",// channelStockList[i].ManuNo,
|
||||
EffDate = null,// !String.IsNullOrEmpty(channelStockList[i].EffDate) ? DateTime.ParseExact(channelStockList[i].EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
|
||||
Operator = HomeWindowViewModel.Operator?.Id,
|
||||
Reviewer = HomeWindowViewModel.Reviewer?.Id,
|
||||
OperationTime = DateTime.Now,
|
||||
Quantity = 0,
|
||||
Type = 5,
|
||||
InvoiceId = string.Empty,//InvoiceId,
|
||||
StockQuantity = channelStockList[i].Quantity,
|
||||
InvoiceId = "日结存",// string.Empty,//InvoiceId,
|
||||
ReturnQuantity1 = inQuantity, //当日入库量总数
|
||||
ReturnQuantity2 = outQuantity, //当日出库量总数
|
||||
StockQuantity = channelStockQuantity,
|
||||
ManunoQuantity = 0,
|
||||
SupplierDept = ConfigurationManager.AppSettings["supplierDept"].ToString(),
|
||||
ReceiveDept = ConfigurationManager.AppSettings["receiveDept"].ToString()
|
||||
SupplierDept = string.Empty,//ConfigurationManager.AppSettings["supplierDept"].ToString(),
|
||||
ReceiveDept = string.Empty,//ConfigurationManager.AppSettings["receiveDept"].ToString()
|
||||
}).ExecuteCommand();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ using DM_Weight.msg;
|
|||
using DM_Weight.Port;
|
||||
using DM_Weight.util;
|
||||
using log4net;
|
||||
using log4net.Repository.Hierarchy;
|
||||
using Prism.Commands;
|
||||
using Prism.Events;
|
||||
using Prism.Mvvm;
|
||||
|
@ -170,6 +171,7 @@ namespace DM_Weight.ViewModels
|
|||
|
||||
public bool Is17Drawer { get => _is17Drawer; set => SetProperty(ref _is17Drawer, value); }
|
||||
|
||||
|
||||
|
||||
public DelegateCommand<string> UpdateDrawerNo
|
||||
{
|
||||
|
@ -248,7 +250,8 @@ namespace DM_Weight.ViewModels
|
|||
ManuNo = it.ManuNo,
|
||||
EffDate = it.EffDate,
|
||||
Id = it.Id,
|
||||
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
|
||||
DrugId= it.DrugId,
|
||||
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate,it.DrugId }).ExecuteCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -339,7 +342,7 @@ namespace DM_Weight.ViewModels
|
|||
}
|
||||
// 更新屏显库存
|
||||
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
|
||||
List<ChannelStock> singleChannels = ChannelStocks.Where(it => it.BoardType != 1)
|
||||
List<ChannelStock> singleChannels = ChannelStocks.Where(it => it.BoardType ==5&&(it.Quantity>0||it.AddQuantity>0))
|
||||
.GroupBy(it => it.ColNo)
|
||||
.Select(it =>
|
||||
{
|
||||
|
@ -384,6 +387,7 @@ namespace DM_Weight.ViewModels
|
|||
}
|
||||
else
|
||||
{
|
||||
logger.Info($"多批次抽屉加药,库存更新失败!{f.ErrorMessage}");
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "更新库存失败",
|
||||
|
@ -425,7 +429,7 @@ namespace DM_Weight.ViewModels
|
|||
});
|
||||
}
|
||||
|
||||
public bool KeepAlive => true;
|
||||
public bool KeepAlive => false;
|
||||
|
||||
|
||||
|
||||
|
@ -474,7 +478,34 @@ namespace DM_Weight.ViewModels
|
|||
channelLS.channelStocks = stockList;
|
||||
}
|
||||
}
|
||||
|
||||
//删除药品下批次库存为0的批次
|
||||
private void DelManuNO(ChannelStock cstock)
|
||||
{
|
||||
if(cstock != null)
|
||||
{
|
||||
//删除ChannelStock表中该批次数据
|
||||
int isOk = SqlSugarHelper.Db.Deleteable<ChannelStock>().Where(cs => cs.DrugId == cstock.DrugId && cs.ManuNo == cs.ManuNo).ExecuteCommand();
|
||||
if(isOk>0 )
|
||||
{
|
||||
logger.Info($"删除{cstock.DrawerNo}-{cstock.ColNo}抽屉中药品{cstock.DrugId}下的批次{cstock.ManuNo},");
|
||||
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 long CurrentTimeMillis()
|
||||
{
|
||||
return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
|
||||
|
@ -505,11 +536,12 @@ namespace DM_Weight.ViewModels
|
|||
.Where(cl => cl.DrugId != null)
|
||||
.OrderBy(cl => cl.ColNo)
|
||||
.ToList();
|
||||
ChannelLsts = queryData.Select(cl =>
|
||||
ChannelLsts = queryData.AsParallel().Select(cl =>
|
||||
{
|
||||
cl.channelStocks = cl.channelStocks.Select(cs =>
|
||||
{
|
||||
cs.drugManuNo = cl.Drug.DrugManuNos.Find(it => it.ManuNo.Equals(cs.ManuNo));
|
||||
cs.DrugId=cl.DrugId;
|
||||
return cs;
|
||||
}).ToList();
|
||||
return cl;
|
||||
|
@ -523,6 +555,7 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
|
||||
_eventAggregator.GetEvent<AddDrugEvent>().Subscribe(AddAction);
|
||||
_eventAggregator.GetEvent<DelDrugManoEvent>().Subscribe(DelManuNO);
|
||||
FindDrawerCount();
|
||||
RequestData();
|
||||
}
|
||||
|
@ -540,6 +573,7 @@ namespace DM_Weight.ViewModels
|
|||
// 取消消息订阅
|
||||
_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
|
||||
_eventAggregator.GetEvent<AddDrugEvent>().Unsubscribe(AddAction);
|
||||
_eventAggregator.GetEvent<DelDrugManoEvent>().Unsubscribe(DelManuNO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ using DM_Weight.util;
|
|||
using log4net;
|
||||
using System.Threading;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
using System.Windows.Threading;
|
||||
using System.Windows;
|
||||
|
||||
namespace DM_Weight.ViewModels
|
||||
{
|
||||
|
@ -218,7 +220,15 @@ namespace DM_Weight.ViewModels
|
|||
SetProperty(ref _pageSize, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 渲染标签状态
|
||||
/// </summary>
|
||||
private bool _status = false;
|
||||
public bool Status
|
||||
{
|
||||
get => _status;
|
||||
set => SetProperty(ref _status, value);
|
||||
}
|
||||
|
||||
|
||||
public bool CanCloseDialog()
|
||||
|
@ -253,11 +263,11 @@ namespace DM_Weight.ViewModels
|
|||
.OrderBy(cl => cl.DrawerNo)
|
||||
.OrderBy(cl => cl.ColNo)
|
||||
.ToPageList(PageNum, PageSize, ref totalCount);
|
||||
if(list!=null&&list.Count>0)
|
||||
if (list != null && list.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
if(list[i].channelStocks!=null&& list[i].channelStocks.Count>0)
|
||||
if (list[i].channelStocks != null && list[i].channelStocks.Count > 0)
|
||||
{
|
||||
for (int j = 0; j < list[i].channelStocks.Count; j++)
|
||||
{
|
||||
|
@ -322,7 +332,7 @@ namespace DM_Weight.ViewModels
|
|||
await Task.Delay(200);
|
||||
_portUtil.WriteChannelInfo(2, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo);
|
||||
await Task.Delay(200);
|
||||
_portUtil.WriteChannelInfo(8, DrugInfo.Manufactory.Length>10? DrugInfo.Manufactory.Substring(0, 10): DrugInfo.Manufactory, item.DrawerNo, item.ColNo);
|
||||
_portUtil.WriteChannelInfo(8, DrugInfo.Manufactory.Length > 10 ? DrugInfo.Manufactory.Substring(0, 10) : DrugInfo.Manufactory, item.DrawerNo, item.ColNo);
|
||||
await Task.Delay(200);
|
||||
//_portUtil.WriteChannelInfo(6, DrugManuNo.EffDate==null?"": DrugManuNo.EffDate, item.DrawerNo, item.ColNo);
|
||||
//await Task.Delay(200);
|
||||
|
@ -360,7 +370,7 @@ namespace DM_Weight.ViewModels
|
|||
|
||||
if (c > 0)
|
||||
{
|
||||
if(c>1)
|
||||
if (c > 1)
|
||||
{
|
||||
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
|
||||
SnackbarMessageQueue.Enqueue("同一药品不可绑多个库位");
|
||||
|
@ -399,8 +409,8 @@ namespace DM_Weight.ViewModels
|
|||
SnackbarMessageQueue.Enqueue("该药品已绑定库位,不可绑定多个库位");
|
||||
return;
|
||||
}
|
||||
var channelStock = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.Chnguid == item.Id&&cs.Quantity>0).ToList();
|
||||
if(channelStock.Count>0)
|
||||
var channelStock = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.Chnguid == item.Id && cs.Quantity > 0).ToList();
|
||||
if (channelStock.Count > 0)
|
||||
{
|
||||
//有库存,不能解绑
|
||||
|
||||
|
@ -459,7 +469,6 @@ namespace DM_Weight.ViewModels
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
public DelegateCommand RemoveBinding
|
||||
{
|
||||
get => new DelegateCommand(async () =>
|
||||
|
@ -485,7 +494,7 @@ namespace DM_Weight.ViewModels
|
|||
//item.EffDate = null;
|
||||
item.Drug = null;
|
||||
SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId }).ExecuteCommand();
|
||||
SqlSugarHelper.Db.Updateable<ChannelStock>().SetColumns(it =>new ChannelStock { DrugId = null, ManuNo = null, EffDate = null} ).Where(it=>it.Chnguid==item.Id).ExecuteCommand();
|
||||
SqlSugarHelper.Db.Updateable<ChannelStock>().SetColumns(it => new ChannelStock { DrugId = null, ManuNo = null, EffDate = null }).Where(it => it.Chnguid == item.Id).ExecuteCommand();
|
||||
if (item.BoardType == 5)
|
||||
{
|
||||
// 清除显示屏库位信息
|
||||
|
@ -505,7 +514,91 @@ namespace DM_Weight.ViewModels
|
|||
}
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
/// 渲染标签
|
||||
/// </summary>
|
||||
public DelegateCommand ResetLabelCommand
|
||||
{
|
||||
get => new DelegateCommand(ResetLabelMethod, () => Status == false);
|
||||
}
|
||||
private void ResetLabelMethod()
|
||||
{
|
||||
if (Channels != null)
|
||||
{
|
||||
Task t = new Task(() =>
|
||||
{
|
||||
var SelectChannels = Channels.FindAll(item => item.IsSelected && item.BoardType == 5);
|
||||
var c = SelectChannels.Count;
|
||||
if (c > 0)
|
||||
{
|
||||
Status = true;
|
||||
SelectChannels.ForEach(item =>
|
||||
{
|
||||
if (item.DrugId == null)
|
||||
{
|
||||
// 清除显示屏库位信息
|
||||
_portUtil.ClearContent(item.DrawerNo, item.ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.ShowContent(item.DrawerNo, item.ColNo);
|
||||
Thread.Sleep(200);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrugInfo drugSelected = item.Drug ?? new DrugInfo();
|
||||
_portUtil.WindowName = "BindingChannelDialog";
|
||||
// 向显示屏写入库位信息
|
||||
_portUtil.WriteChannelInfo(1, drugSelected.DrugName ?? "", item.DrawerNo, item.ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.WriteChannelInfo(2, drugSelected.DrugSpec ?? "", item.DrawerNo, item.ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.WriteChannelInfo(8, drugSelected.Manufactory == null ? "" : drugSelected.Manufactory.Length > 10 ? drugSelected.Manufactory.Substring(0, 10) : drugSelected.Manufactory, item.DrawerNo, item.ColNo);
|
||||
Thread.Sleep(200);
|
||||
//查询该库存下库存不为0的近效期的批次效期
|
||||
ChannelStock channelStock = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
.Where(cs => cs.MachineId == item.MachineId && cs.DrawerNo == item.DrawerNo && cs.ColNo == item.ColNo && cs.Quantity > 0)
|
||||
.OrderBy(cs => cs.EffDate).First();
|
||||
_portUtil.WriteChannelInfo(6, channelStock.EffDate == null ? "" : channelStock.EffDate, item.DrawerNo, item.ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.WriteChannelInfo(5, channelStock.ManuNo == null ? "" : channelStock.ManuNo, item.DrawerNo, item.ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.ShowContent(item.DrawerNo, item.ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.WriteQuantity(item.DrawerNo, item.ColNo, item.totalCount);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
|
||||
SnackbarMessageQueue.Enqueue("未选择库位或所选库位无标签");
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
t.Start();
|
||||
t.ContinueWith(task =>
|
||||
{
|
||||
if (Status.Equals(true))
|
||||
{
|
||||
Status = false;
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
|
||||
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#00e676"));
|
||||
SnackbarMessageQueue.Enqueue("操作完成!");
|
||||
GetChannelsByDrawerNo();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
//static Task TaskSleep()
|
||||
//{
|
||||
// //await Task.Delay(200);
|
||||
// Thread.Sleep(200);
|
||||
//}
|
||||
public DelegateCommand BtnCloseCommand
|
||||
{
|
||||
get => new DelegateCommand(() =>
|
||||
|
|
|
@ -132,8 +132,16 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
GridReportUtil.PrintReportStockNew(StartDate, EndDate);
|
||||
});
|
||||
|
||||
//get => new DelegateCommand(() =>
|
||||
//{
|
||||
// //DialogParameters dialogParameters = new DialogParameters();
|
||||
// //dialogParameters.Add("orderInfo", SelectedOrder);
|
||||
// DialogServiceExtensions.ShowDialogHost(_dialogService, "PrintPdfView", null, DoDialogResult, "RootDialog");
|
||||
//});
|
||||
|
||||
}
|
||||
public DelegateCommand Query
|
||||
public DelegateCommand Query
|
||||
{
|
||||
get => new DelegateCommand(() =>
|
||||
{
|
||||
|
|
|
@ -278,7 +278,14 @@ namespace DM_Weight.ViewModels
|
|||
channelStocks.ForEach(it => it.process = 1);
|
||||
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
|
||||
|
||||
List<ChannelStock> singleChannels = channelStocks.GroupBy(it => new
|
||||
|
||||
List<ChannelStock> singleChannels = new List<ChannelStock>();
|
||||
for (int i = 0; i < channelStocks.Count; i++)
|
||||
{
|
||||
ChannelStock copy = TransExpV2<ChannelStock, ChannelStock>.Trans(channelStocks[i]);
|
||||
singleChannels.Add(copy);
|
||||
}
|
||||
singleChannels = singleChannels.GroupBy(it => new
|
||||
{
|
||||
it.DrawerNo,
|
||||
it.ColNo
|
||||
|
|
|
@ -170,8 +170,8 @@ namespace DM_Weight.ViewModels
|
|||
|
||||
if (msg.WindowName == "CheckStockNewWindow")
|
||||
{
|
||||
IGrouping<string, ChannelStock> grouping = enumerator.Current;
|
||||
int DrawerNo =Convert.ToInt32(grouping.Key.Substring(0, grouping.Key.IndexOf('-')));
|
||||
IGrouping<int, ChannelStock> grouping = enumerator.Current;
|
||||
int DrawerNo = grouping.Key;// Convert.ToInt32(grouping.Key.Substring(0, grouping.Key.IndexOf('-')));
|
||||
List<ChannelStock> channelStocks = grouping.ToList();
|
||||
|
||||
switch (msg.EventType)
|
||||
|
@ -198,34 +198,36 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
channelStocks.ForEach(it => it.process = 3);
|
||||
}
|
||||
IGrouping<string, ChannelStock> groupingBefore = enumerator.Current;
|
||||
int DrawerNoBefore = Convert.ToInt32(groupingBefore.Key.Substring(0, groupingBefore.Key.IndexOf('-')));
|
||||
IGrouping<int, ChannelStock> groupingBefore = enumerator.Current;
|
||||
int DrawerNoBefore = groupingBefore.Key; //Convert.ToInt32(groupingBefore.Key.Substring(0, groupingBefore.Key.IndexOf('-')));
|
||||
if (enumerator.MoveNext())
|
||||
{
|
||||
IGrouping<string, ChannelStock> groupingAfter = enumerator.Current;
|
||||
int DrawerNoAfter = Convert.ToInt32(groupingAfter.Key.Substring(0, groupingAfter.Key.IndexOf('-')));
|
||||
IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
|
||||
int DrawerNoAfter = groupingAfter.Key;//Convert.ToInt32(groupingAfter.Key.Substring(0, groupingAfter.Key.IndexOf('-')));
|
||||
//if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
|
||||
//{
|
||||
// Thread.Sleep(50);
|
||||
//}
|
||||
|
||||
logger.Info($"抽屉号DrawerNoBefore【{DrawerNoBefore}】抽屉号DrawerNoAfter【{DrawerNoAfter}】");
|
||||
if (DrawerNoAfter == 17)
|
||||
if (DrawerNoAfter == 17 || DrawerNoBefore == 17)
|
||||
{
|
||||
if (DrawerNoBefore == 17)
|
||||
//if (DrawerNoBefore == 17)
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(500);
|
||||
int sleepMilliseconds = Convert.ToInt32(ConfigurationManager.AppSettings["CheckSleepMilliseconds"] ?? "500");
|
||||
Thread.Sleep(sleepMilliseconds);
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// Thread.Sleep(500);
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(80);
|
||||
//Thread.Sleep(80);
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
logger.Info($"抽屉号DrawerNoBefore【{DrawerNoBefore}】抽屉号DrawerNoAfter【{DrawerNoAfter}】");
|
||||
//logger.Info($"抽屉号DrawerNoBefore【{DrawerNoBefore}】抽屉号DrawerNoAfter【{DrawerNoAfter}】");
|
||||
OpenOneByOne();
|
||||
}
|
||||
// 已经全部取出
|
||||
|
@ -272,8 +274,8 @@ namespace DM_Weight.ViewModels
|
|||
set => SetProperty(ref _channelStocks, value);
|
||||
}
|
||||
|
||||
private IEnumerable<IGrouping<string, ChannelStock>> enumerable;
|
||||
private IEnumerator<IGrouping<string, ChannelStock>> enumerator;
|
||||
private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
|
||||
private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
|
||||
|
||||
public DelegateCommand BindingChannelDialog
|
||||
{
|
||||
|
@ -301,8 +303,8 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
if (Status == 0)
|
||||
{
|
||||
//enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
|
||||
enumerable = ChannelStocks.GroupBy(cs => cs.Location, cs => cs);
|
||||
enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
|
||||
//enumerable = ChannelStocks.GroupBy(cs => cs.Location, cs => cs);
|
||||
enumerator = enumerable.GetEnumerator();
|
||||
enumerator.MoveNext();
|
||||
Status = 1;
|
||||
|
@ -312,21 +314,27 @@ namespace DM_Weight.ViewModels
|
|||
}
|
||||
private void OpenOneByOne()
|
||||
{
|
||||
IGrouping<string, ChannelStock> grouping = enumerator.Current;
|
||||
int DrawerNo =Convert.ToInt32(grouping.Key.Substring(0,grouping.Key.IndexOf('-')));
|
||||
List<ChannelStock> channelStocks = grouping.ToList();
|
||||
channelStocks.ForEach(it => it.process = 1);
|
||||
IGrouping<int, ChannelStock> grouping = enumerator.Current;
|
||||
//int DrawerNo =Convert.ToInt32(grouping.Key.Substring(0,grouping.Key.IndexOf('-')));
|
||||
int DrawerNo = grouping.Key;
|
||||
List<ChannelStock> Stocks = grouping.ToList();
|
||||
Stocks.ForEach(it => it.process = 1);
|
||||
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
|
||||
|
||||
List<ChannelStock> singleChannels = channelStocks.GroupBy(it => new
|
||||
List<ChannelStock> singleChannels = new List<ChannelStock>();
|
||||
for (int i = 0; i < Stocks.Count; i++)
|
||||
{
|
||||
ChannelStock copy = TransExpV2<ChannelStock, ChannelStock>.Trans(Stocks[i]);
|
||||
singleChannels.Add(copy);
|
||||
}
|
||||
singleChannels = singleChannels.GroupBy(it => new
|
||||
{
|
||||
it.DrawerNo,
|
||||
it.ColNo
|
||||
}).Select(it =>
|
||||
{
|
||||
var ret = it.First();
|
||||
ret.Quantity = it.Sum(itx => itx.Quantity);
|
||||
ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
|
||||
//ret.Quantity = it.Sum(itx => itx.Quantity);
|
||||
//ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
|
||||
return ret;
|
||||
}).ToList().FindAll(it => it.BoardType != 1);
|
||||
|
||||
|
@ -352,7 +360,7 @@ namespace DM_Weight.ViewModels
|
|||
_portUtil.Operate = true;
|
||||
_portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
|
||||
_portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
|
||||
_portUtil.Stocks = singleChannels.Select(it => it.Quantity).ToArray();
|
||||
//_portUtil.Stocks = singleChannels.Select(it => it.Quantity).ToArray();
|
||||
_portUtil.DrawerNo = DrawerNo;
|
||||
_portUtil.Start();
|
||||
}
|
||||
|
@ -372,7 +380,6 @@ namespace DM_Weight.ViewModels
|
|||
string InvoiceId = "CHECK_" + CurrentTimeMillis();
|
||||
var f = SqlSugarHelper.Db.UseTran(() =>
|
||||
{
|
||||
|
||||
for (int i = 0; i < record.Count; i++)
|
||||
{
|
||||
ChannelStock it = record[i];
|
||||
|
@ -393,31 +400,35 @@ namespace DM_Weight.ViewModels
|
|||
.Where(cs => cs.DrawerType == 1)
|
||||
.ToList();
|
||||
|
||||
// 保存数据 盘点记录
|
||||
SqlSugarHelper.Db.Insertable(new MachineRecord()
|
||||
//盘点时不记录盘点库存为0且盘点后库存仍为0的记录(该批次可能不再用了)
|
||||
if (!it.Quantity.Equals(0) || !it.CheckQuantity.Equals(0))
|
||||
{
|
||||
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.CheckQuantity - it.Quantity,
|
||||
Type = 4,
|
||||
InvoiceId = InvoiceId,
|
||||
StockQuantity = nowChannels.Sum(it => it.Quantity),
|
||||
CheckQuantity = it.CheckQuantity,
|
||||
ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => 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.CheckQuantity - it.Quantity,
|
||||
Type = 4,
|
||||
InvoiceId = InvoiceId,
|
||||
StockQuantity = nowChannels.Sum(it => it.Quantity),
|
||||
CheckQuantity = it.CheckQuantity,
|
||||
ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity)
|
||||
}).ExecuteCommand();
|
||||
|
||||
logger.Info($"库存盘点->库位【{it.DrawerNo}-{it.ColNo}】药品【{it.DrugInfo.DrugName}】盘点前库存【{it.Quantity}】,更改后【{it.CheckQuantity}】");
|
||||
|
||||
logger.Info($"库存盘点->库位【{it.DrawerNo}-{it.ColNo}】药品【{it.DrugInfo.DrugName}】盘点前库存【{it.Quantity}】,更改后【{it.CheckQuantity}】");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Task.Factory.StartNew(()=> SaveCheckRecord());
|
||||
string machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
|
||||
string strSql = $@"SELECT cl.`row_no` AS rowNo,cl.`col_no` AS colNo,cl.`quantity` AS quantity,cl.`manu_no` AS manuNo,cl.`eff_date` AS effDate,
|
||||
di.`drug_name` AS drugName,di.`drug_spec` AS drugSpec,di.`pack_unit` AS packUnit,di.`manufactory` AS manufactory,di.`max_stock` maxStock,
|
||||
|
@ -429,6 +440,9 @@ namespace DM_Weight.ViewModels
|
|||
})
|
||||
.Select(it => new CheckRecordStock())
|
||||
.ToList();
|
||||
|
||||
logger.Info("已完成-查询channel_stock关联drug_info表信息查询");
|
||||
|
||||
List<CheckRecordStock> insertList = new List<CheckRecordStock>();
|
||||
|
||||
if (checkRecordStockList != null && checkRecordStockList.Count > 0)
|
||||
|
@ -443,39 +457,40 @@ namespace DM_Weight.ViewModels
|
|||
for (int j = 0; j < insertList.Count; j++)
|
||||
{
|
||||
|
||||
|
||||
CheckRecordStock cStock = insertList[j];
|
||||
// 保存数据 盘点后药品总库存及批次库存数
|
||||
SqlSugarHelper.Db.Insertable(new CheckRecordStock()
|
||||
//盘点时不记录盘点库存为0且盘点后库存仍为0的记录(该批次可能不再用了)
|
||||
if (!insertList[j].quantity.Equals(0))
|
||||
{
|
||||
rowNo = cStock.rowNo,
|
||||
colNo = cStock.colNo,
|
||||
ManuQuantity = checkRecordStockList.Where(it => it.drugId == cStock.drugId && it.manuNo == cStock.manuNo).Sum(it => it.quantity),
|
||||
manuNo = cStock.manuNo,
|
||||
effDate = cStock.effDate,
|
||||
drugName = cStock.drugName,
|
||||
manufactory = cStock.manufactory,
|
||||
drugSpec = cStock.drugSpec,
|
||||
packUnit = cStock.packUnit,
|
||||
maxStock = cStock.maxStock,
|
||||
drugId = cStock.drugId,
|
||||
MachineId = cStock.MachineId,
|
||||
quantity = checkRecordStockList.Where(it => it.drugId == cStock.drugId).Sum(it => it.quantity),
|
||||
optdate = DateTime.Now.ToString(),
|
||||
operatorUser = HomeWindowViewModel.Operator?.Id.ToString(),
|
||||
reviewerUser = HomeWindowViewModel.Reviewer?.Id.ToString()
|
||||
}).ExecuteCommand();
|
||||
CheckRecordStock cStock = insertList[j];
|
||||
// 保存数据 盘点后药品总库存及批次库存数
|
||||
SqlSugarHelper.Db.Insertable(new CheckRecordStock()
|
||||
{
|
||||
rowNo = cStock.rowNo,
|
||||
colNo = cStock.colNo,
|
||||
ManuQuantity = checkRecordStockList.Where(it => it.drugId == cStock.drugId && it.manuNo == cStock.manuNo).Sum(it => it.quantity),
|
||||
manuNo = cStock.manuNo,
|
||||
effDate = cStock.effDate,
|
||||
drugName = cStock.drugName,
|
||||
manufactory = cStock.manufactory,
|
||||
drugSpec = cStock.drugSpec,
|
||||
packUnit = cStock.packUnit,
|
||||
maxStock = cStock.maxStock,
|
||||
drugId = cStock.drugId,
|
||||
MachineId = cStock.MachineId,
|
||||
quantity = checkRecordStockList.Where(it => it.drugId == cStock.drugId).Sum(it => it.quantity),
|
||||
optdate = DateTime.Now.ToString(),
|
||||
operatorUser = HomeWindowViewModel.Operator?.Id.ToString(),
|
||||
reviewerUser = HomeWindowViewModel.Reviewer?.Id.ToString()
|
||||
}).ExecuteCommand();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
logger.Info("已完成-保存数据 盘点后药品总库存及批次库存数");
|
||||
return true;
|
||||
});
|
||||
if (f.Data)
|
||||
{
|
||||
// 更新屏显库存
|
||||
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
|
||||
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1)
|
||||
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType == 5)
|
||||
.GroupBy(it => new
|
||||
{
|
||||
it.DrawerNo,
|
||||
|
@ -484,26 +499,73 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
var ret = it.First();
|
||||
ret.CheckQuantity = it.Sum(itx => itx.CheckQuantity);
|
||||
//ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
|
||||
ret.Quantity = it.Sum(itx => itx.Quantity);
|
||||
return ret;
|
||||
}).ToList();
|
||||
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
|
||||
}).OrderBy(it => it.EffDate).ToList();
|
||||
if (singleChannels != null && singleChannels.Count > 0)
|
||||
{
|
||||
singleChannels.ForEach(it =>
|
||||
for (int i = 0; i < singleChannels.Count; i++)
|
||||
{
|
||||
// 将库位多批次的总库存数更新标签
|
||||
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.CheckQuantity);
|
||||
|
||||
});
|
||||
|
||||
List<ChannelStock> channel = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
.Where(cs => cs.MachineId == singleChannels[i].MachineId)
|
||||
.Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
|
||||
.Where(cs => cs.ColNo == singleChannels[i].ColNo)
|
||||
//.Where(cs=>cs.Quantity>0)
|
||||
.OrderBy(cs => cs.EffDate)
|
||||
.ToList();
|
||||
//.Sum(it => it.Quantity);
|
||||
if (singleChannels[i].Quantity != singleChannels[i].CheckQuantity)
|
||||
{
|
||||
//将库位多批次的总库存数更新标签
|
||||
_portUtil.WriteQuantity(channel[0].DrawerNo, channel[0].ColNo, channel.Sum(c => c.Quantity));
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
//如果最近效期的批次库存为0则重新绑定批次效期标签为库存不为0的近效期的标签
|
||||
if (channel[0].Quantity == 0)
|
||||
{
|
||||
ChannelStock cs = channel.Where(cs => cs.Quantity > 0).OrderBy(it => it.EffDate).FirstOrDefault();
|
||||
if (cs != null)
|
||||
{
|
||||
_portUtil.WriteChannelInfo(6, cs.EffDate == null ? "" : cs.EffDate, cs.DrawerNo, cs.ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.WriteChannelInfo(5, cs.ManuNo, cs.DrawerNo, cs.ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.ShowContent(cs.DrawerNo, cs.ColNo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//判断盘点前数量是否是0,盘点前数量为0的可能已经把标签绑定的批次效期替换了,所以要更新回来
|
||||
int beForeQuantity = record.Where(it => it.DrawerNo == channel[0].DrawerNo && it.ColNo == channel[0].ColNo && it.ManuNo == channel[0].ManuNo && it.EffDate == channel[0].EffDate).Select(s => s.Quantity).Min();
|
||||
if (beForeQuantity == 0)
|
||||
{
|
||||
_portUtil.WriteChannelInfo(6, channel[0].EffDate == null ? "" : channel[0].EffDate, channel[0].DrawerNo, channel[0].ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.WriteChannelInfo(5, channel[0].ManuNo, channel[0].DrawerNo, channel[0].ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.ShowContent(channel[0].DrawerNo, channel[0].ColNo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//singleChannels.ForEach(it =>
|
||||
//{
|
||||
// // 将库位多批次的总库存数更新标签
|
||||
// _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.CheckQuantity);
|
||||
|
||||
RequestData();
|
||||
//});
|
||||
|
||||
logger.Info("已完成-更新标签");
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "抽屉盘点完成,库存已更新",
|
||||
Type = MsgType.SUCCESS,
|
||||
};
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
|
||||
RequestData();
|
||||
}
|
||||
if (!f.IsSuccess)
|
||||
{
|
||||
|
@ -533,7 +595,64 @@ namespace DM_Weight.ViewModels
|
|||
|
||||
}, () => Status == 3 && !_isFinishClick).ObservesProperty(() => Status);
|
||||
}
|
||||
public void SaveCheckRecord()
|
||||
{
|
||||
string machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
|
||||
string strSql = $@"SELECT cl.`row_no` AS rowNo,cl.`col_no` AS colNo,cl.`quantity` AS quantity,cl.`manu_no` AS manuNo,cl.`eff_date` AS effDate,
|
||||
di.`drug_name` AS drugName,di.`drug_spec` AS drugSpec,di.`pack_unit` AS packUnit,di.`manufactory` AS manufactory,di.`max_stock` maxStock,
|
||||
cl.`drug_id` AS drugId,cl.`machine_id` AS MachineId FROM channel_stock cl INNER JOIN drug_info di ON di.`drug_id` = cl.`drug_id` WHERE cl.`machine_id` = '{machine_id}' AND cl.`drawer_type` = 1 ORDER BY cl.`drug_id`";
|
||||
List<CheckRecordStock> checkRecordStockList = SqlSugarHelper.Db.SqlQueryable<dynamic>(strSql)
|
||||
.AddParameters(new
|
||||
{
|
||||
machineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1"
|
||||
})
|
||||
.Select(it => new CheckRecordStock())
|
||||
.ToList();
|
||||
|
||||
logger.Info("已完成-查询channel_stock关联drug_info表信息查询");
|
||||
|
||||
List<CheckRecordStock> insertList = new List<CheckRecordStock>();
|
||||
|
||||
if (checkRecordStockList != null && checkRecordStockList.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < checkRecordStockList.Count; i++)
|
||||
{
|
||||
if (!(insertList.Where(it => it.drugId == checkRecordStockList[i].drugId && it.manuNo == checkRecordStockList[i].manuNo).Count() > 0))
|
||||
{
|
||||
insertList.Add(checkRecordStockList[i]);
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < insertList.Count; j++)
|
||||
{
|
||||
|
||||
|
||||
CheckRecordStock cStock = insertList[j];
|
||||
// 保存数据 盘点后药品总库存及批次库存数
|
||||
SqlSugarHelper.Db.Insertable(new CheckRecordStock()
|
||||
{
|
||||
rowNo = cStock.rowNo,
|
||||
colNo = cStock.colNo,
|
||||
ManuQuantity = checkRecordStockList.Where(it => it.drugId == cStock.drugId && it.manuNo == cStock.manuNo).Sum(it => it.quantity),
|
||||
manuNo = cStock.manuNo,
|
||||
effDate = cStock.effDate,
|
||||
drugName = cStock.drugName,
|
||||
manufactory = cStock.manufactory,
|
||||
drugSpec = cStock.drugSpec,
|
||||
packUnit = cStock.packUnit,
|
||||
maxStock = cStock.maxStock,
|
||||
drugId = cStock.drugId,
|
||||
MachineId = cStock.MachineId,
|
||||
quantity = checkRecordStockList.Where(it => it.drugId == cStock.drugId).Sum(it => it.quantity),
|
||||
optdate = DateTime.Now.ToString(),
|
||||
operatorUser = HomeWindowViewModel.Operator?.Id.ToString(),
|
||||
reviewerUser = HomeWindowViewModel.Reviewer?.Id.ToString()
|
||||
}).ExecuteCommand();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
logger.Info("已完成-插入check_stock表信息");
|
||||
}
|
||||
// 取消按钮
|
||||
public DelegateCommand CancleTake
|
||||
{
|
||||
|
@ -544,7 +663,7 @@ namespace DM_Weight.ViewModels
|
|||
});
|
||||
}
|
||||
|
||||
public bool KeepAlive => true;
|
||||
public bool KeepAlive => false;
|
||||
|
||||
private void DoDialogResult(IDialogResult dialogResult)
|
||||
{
|
||||
|
@ -613,6 +732,7 @@ namespace DM_Weight.ViewModels
|
|||
|
||||
.WhereIF(!String.IsNullOrEmpty(SearchValue), cs => cs.DrugInfo.DrugName == SearchValue)
|
||||
.OrderBy(cs => cs.DrawerNo)
|
||||
//.OrderByDescending(cs => cs.DrawerNo)
|
||||
.OrderBy(cs => cs.ColNo)
|
||||
//.OrderBy(cs => cs.DrugId)
|
||||
.ToList();
|
||||
|
|
|
@ -17,6 +17,7 @@ using DM_Weight.msg;
|
|||
using DM_Weight.Port;
|
||||
using DM_Weight.util;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Threading;
|
||||
|
||||
namespace DM_Weight.ViewModels
|
||||
{
|
||||
|
@ -186,7 +187,7 @@ namespace DM_Weight.ViewModels
|
|||
if (!_isFinishClick)
|
||||
{
|
||||
_isFinishClick = true;
|
||||
List<ChannelStock> record = ChannelStocks.FindAll(it => it.AddQuantity != 0).ToList();
|
||||
List<ChannelStock> record = ChannelStocks.FindAll(it => it.AddQuantity > 0).ToList();
|
||||
if (record.Count > 0)
|
||||
{
|
||||
//string InvoiceId = "DRAWER_" + CurrentTimeMillis();
|
||||
|
@ -241,21 +242,44 @@ 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(it => it.Quantity);
|
||||
ret.AddQuantity = it.Sum(it => it.AddQuantity);
|
||||
return ret;
|
||||
}).ToList();
|
||||
singleChannels = singleChannels.Where(it => it.AddQuantity > 0).ToList();
|
||||
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
|
||||
//List<ChannelStock> singleChannels = ChannelStocks.Where(it => it.BoardType == 5 && (it.Quantity > 0 || it.AddQuantity > 0))
|
||||
// .GroupBy(it => it.ColNo)
|
||||
// .Select(it =>
|
||||
// {
|
||||
// var ret = it.First();
|
||||
// ret.Quantity = it.Sum(it => it.Quantity);
|
||||
// ret.AddQuantity = it.Sum(it => it.AddQuantity);
|
||||
// return ret;
|
||||
// })
|
||||
// .OrderBy(it => it.EffDate).ToList();
|
||||
|
||||
List<ChannelStock> singleChannels = ChannelStocks.Where(it => it.BoardType == 5 && (it.Quantity > 0 || it.AddQuantity > 0))
|
||||
.GroupBy(it => it.ColNo)
|
||||
.Select(it =>
|
||||
{
|
||||
var ret = it.First();
|
||||
ret.Quantity = it.Sum(itx => itx.Quantity);
|
||||
ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
|
||||
ret.EffDate = it.Min(it => it.EffDate);
|
||||
ret.ManuNo = it.OrderBy(it => it.ManuNo).Select(it => it.ManuNo).First().ToString();
|
||||
return ret;
|
||||
})
|
||||
.OrderBy(it => it.EffDate)
|
||||
.ToList();
|
||||
|
||||
//singleChannels = singleChannels.Where(it => it.AddQuantity > 0).ToList();
|
||||
if (singleChannels.Count > 0)
|
||||
{
|
||||
//将库位多批次的总库存数更新标签
|
||||
singleChannels.ForEach(it =>
|
||||
{
|
||||
_portUtil.WriteChannelInfo(6, it.EffDate == null ? "" : it.EffDate, it.DrawerNo, it.ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.WriteChannelInfo(5, it.ManuNo, it.DrawerNo, it.ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.ShowContent(it.DrawerNo, it.ColNo);
|
||||
|
||||
Thread.Sleep(500);
|
||||
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
|
||||
});
|
||||
}
|
||||
|
@ -269,6 +293,7 @@ namespace DM_Weight.ViewModels
|
|||
}
|
||||
else
|
||||
{
|
||||
logger.Info($"抽屉加药,库存更新失败!{f.ErrorMessage}");
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "更新库存失败",
|
||||
|
|
|
@ -21,6 +21,7 @@ using DM_Weight.util;
|
|||
using Newtonsoft.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Controls;
|
||||
using System.Threading.Channels;
|
||||
|
||||
namespace DM_Weight.ViewModels
|
||||
{
|
||||
|
@ -35,11 +36,11 @@ namespace DM_Weight.ViewModels
|
|||
get => _channelStocks;
|
||||
set => SetProperty(ref _channelStocks, value);
|
||||
}
|
||||
|
||||
|
||||
private static readonly DateTime Jan1st1970 = new DateTime
|
||||
(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
|
||||
|
||||
|
||||
|
||||
private PortUtil _portUtil;
|
||||
IEventAggregator _eventAggregator;
|
||||
|
@ -93,7 +94,7 @@ namespace DM_Weight.ViewModels
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private int _status;
|
||||
|
@ -129,7 +130,7 @@ namespace DM_Weight.ViewModels
|
|||
}, (DrawerNo) => Status == 0
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public DelegateCommand OpenDrawer
|
||||
{
|
||||
|
@ -144,7 +145,7 @@ namespace DM_Weight.ViewModels
|
|||
// group t by new { t.ColNo, t.BoardType }
|
||||
// into grp
|
||||
// select new { grp.Key.ColNo, grp.Key.BoardType, quantity = grp.Sum(t => t.Quantity) }).ToList();
|
||||
|
||||
|
||||
List<ChannelStock> singleChannels = ChannelStocks.FindAll(it => it.BoardType != 1);
|
||||
|
||||
_portUtil.WindowName = "DrawerTakeDrugWindow";
|
||||
|
@ -167,7 +168,7 @@ namespace DM_Weight.ViewModels
|
|||
if (!_isFinishClick)
|
||||
{
|
||||
_isFinishClick = true;
|
||||
List<ChannelStock> record = ChannelStocks.FindAll(it => it.TakeQuantity != 0).ToList();
|
||||
List<ChannelStock> record = ChannelStocks.FindAll(it => it.TakeQuantity > 0).ToList();
|
||||
logger.Info("点击完成按钮,库位数据:" + JsonConvert.SerializeObject(record));
|
||||
if (record.Count > 0)
|
||||
{
|
||||
|
@ -206,7 +207,7 @@ namespace DM_Weight.ViewModels
|
|||
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,
|
||||
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,
|
||||
|
@ -224,12 +225,19 @@ namespace DM_Weight.ViewModels
|
|||
}
|
||||
return true;
|
||||
});
|
||||
if (f.Data)
|
||||
if (f.Data)
|
||||
{
|
||||
logger.Info("更新屏显库存singleChannels");
|
||||
// 更新屏显库存
|
||||
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
|
||||
List<ChannelStock> singleChannels = ChannelStocks.Where(it => it.BoardType != 1)
|
||||
|
||||
List<ChannelStock> singleChannels = new List<ChannelStock>();
|
||||
for (int i = 0; i < ChannelStocks.Count; i++)
|
||||
{
|
||||
ChannelStock copy = TransExpV2<ChannelStock, ChannelStock>.Trans(ChannelStocks[i]);
|
||||
singleChannels.Add(copy);
|
||||
}
|
||||
singleChannels = singleChannels.Where(it => it.BoardType != 1)
|
||||
.GroupBy(it => it.ColNo)
|
||||
.Select(it =>
|
||||
{
|
||||
|
@ -237,7 +245,7 @@ namespace DM_Weight.ViewModels
|
|||
ret.Quantity = it.Sum(itx => itx.Quantity);
|
||||
ret.TakeQuantity = it.Sum(itx => itx.TakeQuantity);
|
||||
return ret;
|
||||
}).ToList();
|
||||
}).OrderBy(it => it.Quantity).ToList();
|
||||
singleChannels = singleChannels.Where(it => it.TakeQuantity > 0).ToList();
|
||||
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
|
||||
{
|
||||
|
@ -248,6 +256,46 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
_portUtil.WriteQuantityAsync(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
|
||||
});
|
||||
|
||||
Thread.Sleep(500);
|
||||
//string varCS = from cs in ChannelStocks orderby cs.EffDate group cs by cs.ColNo into g orderby g.Key select g.;
|
||||
|
||||
List<ChannelStock> groupCS = ChannelStocks
|
||||
.GroupBy(it => it.ColNo)
|
||||
.Select(it =>
|
||||
{
|
||||
var ret = it.First();
|
||||
return ret;
|
||||
}).ToList();
|
||||
|
||||
if (groupCS != null)
|
||||
{
|
||||
for (int i = 0; i < groupCS.Count; i++)
|
||||
{
|
||||
//全部取出
|
||||
if (groupCS[i].Quantity == groupCS[i].TakeQuantity)
|
||||
{
|
||||
//查询该库位下非0的近效期及批次重新绑定
|
||||
//更新绑定的效期、批次
|
||||
ChannelStock newBind= SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
.Where(cs => cs.MachineId == groupCS[i].MachineId)
|
||||
.Where(cs => cs.DrawerNo == groupCS[i].DrawerNo)
|
||||
.Where(cs => cs.ColNo == groupCS[i].ColNo)
|
||||
.Where(cs=>cs.Quantity>0)
|
||||
.OrderBy(cs => cs.EffDate)
|
||||
.First();
|
||||
if (newBind != null)
|
||||
{
|
||||
_portUtil.WriteChannelInfo(6, newBind.EffDate == null ? "" : newBind.EffDate, newBind.DrawerNo , newBind.ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.WriteChannelInfo(5, newBind.ManuNo == null ? "" : newBind.ManuNo, newBind.DrawerNo, newBind.ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.ShowContent(newBind.DrawerNo, newBind.ColNo);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.Info("更新屏显库存singleChannels_完成");
|
||||
RequestData();
|
||||
|
@ -260,6 +308,7 @@ namespace DM_Weight.ViewModels
|
|||
}
|
||||
if (!f.IsSuccess)
|
||||
{
|
||||
logger.Info($"抽屉取药,库存更新失败!{f.ErrorMessage}");
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = $"抽屉取药完成,库存更新失败!{f.ErrorMessage}",
|
||||
|
@ -282,7 +331,7 @@ namespace DM_Weight.ViewModels
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -330,6 +379,7 @@ namespace DM_Weight.ViewModels
|
|||
.Where(cs => cs.DrawerType == 1)
|
||||
.Where(cs => cs.Quantity > 0)
|
||||
.OrderBy(cs => cs.ColNo)
|
||||
.OrderBy(cs => cs.EffDate)
|
||||
.ToList();
|
||||
ChannelStocks = queryData;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ using Prism.Regions;
|
|||
using Prism.Services.Dialogs;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Configuration;
|
||||
|
@ -18,6 +19,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Documents;
|
||||
|
||||
namespace DM_Weight.ViewModels
|
||||
{
|
||||
|
@ -289,7 +291,7 @@ namespace DM_Weight.ViewModels
|
|||
if (SelectedInvoice != null)
|
||||
{
|
||||
//先查询有几种药
|
||||
string strSql = @"SELECT sum(Quantity) AS SumQuantity, COUNT(ID) AS CountNum,INVOICE_NO AS InvoiceNo,drug_id AS DrugId,QUANTITY AS quantity,drug_manu_no AS drugManuNo FROM IN_OUT_INVOICE WHERE INVOICE_NO=@INVOICE_NO GROUP BY INVOICE_NO,DRUG_ID";
|
||||
string strSql = @"SELECT sum(Quantity) AS SumQuantity, COUNT(ID) AS CountNum,INVOICE_NO AS InvoiceNo,drug_id AS DrugId,QUANTITY AS quantity,drug_manu_no AS drugManuNo FROM IN_OUT_INVOICE WHERE STATUS=0 AND INVOICE_NO=@INVOICE_NO GROUP BY INVOICE_NO,DRUG_ID";
|
||||
|
||||
var invoices = SqlSugarHelper.Db.SqlQueryable<InOutInvoice>(strSql)
|
||||
.AddParameters(new
|
||||
|
@ -317,18 +319,18 @@ namespace DM_Weight.ViewModels
|
|||
//_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
continue;
|
||||
}
|
||||
ChannelStock stock = new ChannelStock();
|
||||
//ChannelStock stock = new ChannelStock();
|
||||
//查询每种药有多少个批次
|
||||
var invoicesManuNo = SqlSugarHelper.Db.Queryable<InOutInvoice>()
|
||||
.Where(iManuNo => iManuNo.InvoiceNo == invoices[i].InvoiceNo && iManuNo.DrugId == invoices[i].DrugId).ToList();
|
||||
.Where(iManuNo => iManuNo.InvoiceNo == invoices[i].InvoiceNo && iManuNo.DrugId == invoices[i].DrugId && iManuNo.Status == 0 && iManuNo.Type != 2 && iManuNo.CancelFlag == 0).ToList();
|
||||
for (int j = 0; j < invoicesManuNo.Count; j++)
|
||||
{
|
||||
//查询是否有库存
|
||||
List<ChannelStock> stockList = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
.Where(cs => cs.ManuNo == invoicesManuNo[j].DrugManuNo && cs.DrugId == invoicesManuNo[j].DrugId && cs.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM1")).ToList();
|
||||
stock = stockList.Count > 0 ? stockList[0] : new ChannelStock();
|
||||
//stock = stockList.Count > 0 ? stockList[0] : new ChannelStock();
|
||||
List<DrugManuNo> manuNoList = SqlSugarHelper.Db.Queryable<DrugManuNo>().Where(dm => dm.ManuNo == invoicesManuNo[j].DrugManuNo && dm.DrugId == invoicesManuNo[j].DrugId).ToList();
|
||||
if (stock == null || stock.Id is null)
|
||||
if (stockList == null || stockList.Count <= 0)
|
||||
{
|
||||
if (manuNoList == null || manuNoList.Count <= 0)
|
||||
{
|
||||
|
@ -341,6 +343,7 @@ namespace DM_Weight.ViewModels
|
|||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
continue;
|
||||
}
|
||||
ChannelStock stock = new ChannelStock();
|
||||
//没有库存写入一条数据
|
||||
stock.MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
|
||||
stock.DrawerNo = channelLst.DrawerNo;
|
||||
|
@ -351,13 +354,26 @@ namespace DM_Weight.ViewModels
|
|||
stock.ManuNo = invoicesManuNo[j].DrugManuNo;
|
||||
stock.EffDate = manuNoList[0].EffDate;
|
||||
stock.Chnguid = channelLst.Id;
|
||||
stock.InvoiceQuantity = invoicesManuNo[j].quantity;
|
||||
stockList.Add(stock);
|
||||
}
|
||||
stock.AddQuantity = invoicesManuNo[j].quantity;
|
||||
//stock.AddQuantity = invoicesManuNo[j].quantity;
|
||||
//stockList.ForEach(s => s.AddQuantity = invoicesManuNo[j].quantity);
|
||||
stockList.GroupBy(x => x.ManuNo)
|
||||
.Select(it =>
|
||||
{
|
||||
var ret = it.First();
|
||||
ret.AddQuantity = invoicesManuNo[j].quantity;
|
||||
ret.InvoiceQuantity = invoicesManuNo[j].quantity;
|
||||
return ret;
|
||||
})
|
||||
.ToList();
|
||||
|
||||
if (channelLst.channelStocks == null)
|
||||
{
|
||||
channelLst.channelStocks = new List<ChannelStock>();
|
||||
}
|
||||
channelLst.channelStocks.Add(stock);
|
||||
channelLst.channelStocks.AddRange(stockList);
|
||||
}
|
||||
|
||||
InOutInvoice copy = TransExpV2<InOutInvoice, InOutInvoice>.Trans(invoices[i]);
|
||||
|
@ -376,7 +392,8 @@ namespace DM_Weight.ViewModels
|
|||
ChannelStocks.Clear();
|
||||
foreach (ChannelList lst in ChannelLsts)
|
||||
{
|
||||
ChannelStocks.AddRange(lst.channelStocks);
|
||||
|
||||
ChannelStocks.AddRange(lst.channelStocks.Where(cs => cs.AddQuantity > 9));
|
||||
}
|
||||
AddChannels = ChannelStocks.FindAll(it => it.AddQuantity != 0);
|
||||
|
||||
|
@ -390,6 +407,27 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
if (Status == 0)
|
||||
{
|
||||
if (AddChannels == null || AddChannels.Count <= 0)
|
||||
{
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "请输入入库数量",
|
||||
Type = MsgType.ERROR,
|
||||
};
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
return;
|
||||
}
|
||||
//int totalNum = AddChannels.Sum(add => add.AddQuantity);
|
||||
//if (totalNum != SelectedInvoice.Quantity)
|
||||
//{
|
||||
// AlertMsg alertMsg = new AlertMsg
|
||||
// {
|
||||
// Message = "各批次添加数量要与调拨单药品总数一致!",
|
||||
// Type = MsgType.ERROR,
|
||||
// };
|
||||
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
// return;
|
||||
//}
|
||||
enumerator.MoveNext();
|
||||
Status = 1;
|
||||
OpenOneByOne();
|
||||
|
@ -402,7 +440,13 @@ namespace DM_Weight.ViewModels
|
|||
List<ChannelStock> channelStocks = grouping.ToList();
|
||||
channelStocks.ForEach(it => it.process = 1);
|
||||
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
|
||||
List<ChannelStock> singleChannels = channelStocks.GroupBy(it => new
|
||||
List<ChannelStock> singleChannels = new List<ChannelStock>();
|
||||
for (int i = 0; i < channelStocks.Count; i++)
|
||||
{
|
||||
ChannelStock copy = TransExpV2<ChannelStock, ChannelStock>.Trans(channelStocks[i]);
|
||||
singleChannels.Add(copy);
|
||||
}
|
||||
singleChannels = singleChannels.GroupBy(it => new
|
||||
{
|
||||
it.DrawerNo,
|
||||
it.ColNo
|
||||
|
@ -422,7 +466,13 @@ namespace DM_Weight.ViewModels
|
|||
|
||||
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
|
||||
{
|
||||
List<ChannelStock> ChannelLst = channelStocks.Where(it => it.BoardType != 1)
|
||||
List<ChannelStock> ChannelLst = new List<ChannelStock>();
|
||||
for (int i = 0; i < channelStocks.Count; i++)
|
||||
{
|
||||
ChannelStock copy = TransExpV2<ChannelStock, ChannelStock>.Trans(channelStocks[i]);
|
||||
singleChannels.Add(copy);
|
||||
}
|
||||
ChannelLst = ChannelLst.Where(it => it.BoardType != 1)
|
||||
.GroupBy(it => it.ColNo)
|
||||
.Select(it =>
|
||||
{
|
||||
|
@ -459,18 +509,48 @@ namespace DM_Weight.ViewModels
|
|||
if (!_isFinishClick)
|
||||
{
|
||||
_isFinishClick = true;
|
||||
List<ChannelStock> record = ChannelStocks.ToList();
|
||||
List<ChannelStock> record = ChannelStocks;//.ToList();
|
||||
string InvoiceId = SelectedInvoice.InvoiceNo;
|
||||
var f = SqlSugarHelper.Db.UseTran(() =>
|
||||
{
|
||||
SqlSugarHelper.Db.Updateable(new InOutInvoice()
|
||||
{
|
||||
Status = 1,
|
||||
InvoiceNo = SelectedInvoice.InvoiceNo
|
||||
}).UpdateColumns(it => new { it.Status }).WhereColumns(it => new { it.InvoiceNo }).ExecuteCommand();
|
||||
|
||||
for (int i = 0; i < record.Count; i++)
|
||||
{
|
||||
//添加数量不能大于入库单上要加的数量
|
||||
if (record[i].AddQuantity > record[i].InvoiceQuantity)
|
||||
{
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "添加数量不能大于调拨单中药品数量!",
|
||||
Type = MsgType.ERROR,
|
||||
};
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
return false;
|
||||
}
|
||||
//添加数量等于入库单上要加的数量则更新入库单状态
|
||||
if (record[i].AddQuantity == record[i].InvoiceQuantity)
|
||||
{
|
||||
SqlSugarHelper.Db.Updateable(new InOutInvoice()
|
||||
{
|
||||
Status = 1,
|
||||
InvoiceNo = SelectedInvoice.InvoiceNo,
|
||||
DrugManuNo = record[i].ManuNo,
|
||||
DrugId = record[i].DrugId
|
||||
|
||||
}).UpdateColumns(it => new { it.Status }).WhereColumns(it => new { it.InvoiceNo, it.DrugId, it.DrugManuNo }).ExecuteCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
//添加数量小于入库单上要加的数量则更新入库单中的数量
|
||||
SqlSugarHelper.Db.Updateable(new InOutInvoice()
|
||||
{
|
||||
quantity= record[i].InvoiceQuantity- record[i].AddQuantity,
|
||||
InvoiceNo = SelectedInvoice.InvoiceNo,
|
||||
DrugManuNo = record[i].ManuNo,
|
||||
DrugId = record[i].DrugId
|
||||
|
||||
}).UpdateColumns(it => new { it.Status }).WhereColumns(it => new { it.InvoiceNo, it.DrugId, it.DrugManuNo }).ExecuteCommand();
|
||||
|
||||
}
|
||||
|
||||
|
||||
ChannelStock it = record[i];
|
||||
|
@ -501,7 +581,7 @@ namespace DM_Weight.ViewModels
|
|||
}
|
||||
//查询现有库位中是否有库存为0的记录,如果有直接update
|
||||
ChannelStock recordHistory = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerNo == it.DrawerNo && cs.ColNo == it.ColNo && cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1") && cs.Quantity <= 0).First();
|
||||
if (recordHistory!=null&& recordHistory.Id!=null)
|
||||
if (recordHistory != null && recordHistory.Id != null)
|
||||
{
|
||||
SqlSugarHelper.Db.Updateable<ChannelStock>().SetColumns(item => new ChannelStock()
|
||||
{
|
||||
|
@ -563,7 +643,7 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
//根据ChannelLsts中的库位,删除该库位库存为0的记录
|
||||
SqlSugarHelper.Db.Deleteable<ChannelStock>()
|
||||
.Where(cs => cs.Quantity <= 0 && cs.DrawerNo == ChannelLsts[i].channelStocks[0].DrawerNo && cs.ColNo == ChannelLsts[i].channelStocks[0].ColNo).ExecuteCommand();
|
||||
.Where(cs => cs.Quantity <= 0 && cs.DrugId == ChannelLsts[i].DrugId && cs.MachineId == ChannelLsts[i].MachineId).ExecuteCommand();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -572,7 +652,7 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
// 更新屏显库存
|
||||
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
|
||||
List<ChannelStock> singleChannels = record.Where(it => it.BoardType != 1)
|
||||
List<ChannelStock> singleChannels = record.Where(it => it.BoardType == 5)
|
||||
.GroupBy(it => new { it.DrawerNo, it.ColNo })
|
||||
.Select(it =>
|
||||
{
|
||||
|
@ -586,24 +666,25 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
for (int i = 0; i < singleChannels.Count; i++)
|
||||
{
|
||||
if (singleChannels[i].BoardType == 5)
|
||||
{
|
||||
List<ChannelStock> channelStockEffDate = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
.Where(cs => cs.MachineId==singleChannels[i].MachineId)
|
||||
.Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
|
||||
.Where(cs => cs.ColNo == singleChannels[i].ColNo)
|
||||
.OrderBy(cs => cs.EffDate).ToList();
|
||||
int totalQuantity = channelStockEffDate.Sum(it => it.Quantity);
|
||||
//if (singleChannels[i].BoardType == 5)
|
||||
//{
|
||||
List<ChannelStock> channelStockEffDate = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
.Where(cs => cs.MachineId == singleChannels[i].MachineId)
|
||||
.Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
|
||||
.Where(cs => cs.ColNo == singleChannels[i].ColNo)
|
||||
.Where(cs => cs.Quantity > 0)
|
||||
.OrderBy(cs => cs.EffDate).ToList();
|
||||
int totalQuantity = channelStockEffDate.Sum(it => it.Quantity);
|
||||
|
||||
//将库位多批次的总库存数更新标签
|
||||
_portUtil.WriteQuantity(channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo, totalQuantity);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.WriteChannelInfo(6, channelStockEffDate[0].EffDate == null ? "" : channelStockEffDate[0].EffDate, channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.WriteChannelInfo(5, channelStockEffDate[0].ManuNo, channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.ShowContent(channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo);
|
||||
}
|
||||
//将库位多批次的总库存数更新标签
|
||||
_portUtil.WriteQuantity(channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo, totalQuantity);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.WriteChannelInfo(6, channelStockEffDate[0].EffDate == null ? "" : channelStockEffDate[0].EffDate, channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.WriteChannelInfo(5, channelStockEffDate[0].ManuNo, channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.ShowContent(channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -616,9 +697,11 @@ namespace DM_Weight.ViewModels
|
|||
Type = MsgType.SUCCESS,
|
||||
};
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
RequestData();
|
||||
}
|
||||
if (!f.IsSuccess)
|
||||
{
|
||||
logger.Info($"调拨入库,库存更新失败!{f.ErrorMessage}");
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "库存更新失败!",
|
||||
|
@ -630,7 +713,6 @@ namespace DM_Weight.ViewModels
|
|||
_isFinishClick = false;
|
||||
|
||||
}
|
||||
RequestData();
|
||||
});
|
||||
}
|
||||
// 取消按钮
|
||||
|
|
|
@ -339,11 +339,11 @@ _exitCommand ??= new DelegateCommand(Exit);
|
|||
logger.Info($"msg.Message.Equals:{msg.Message}");
|
||||
if (msg.Message.Equals("LOGIN"))
|
||||
{
|
||||
UserList userList = SqlSugarHelper.Db.Queryable<UserList>()
|
||||
.Includes<RoleDm>(u => u.Role)
|
||||
.First(u => u.Id == msg.Id);
|
||||
//UserList userList = SqlSugarHelper.Db.Queryable<UserList>()
|
||||
//.Includes<RoleDm>(u => u.Role)
|
||||
//.First(u => u.Id == msg.Id);
|
||||
|
||||
//UserList userList = new UserService().CheckUserByFingerPrinter(msg.Id);
|
||||
UserList userList = new UserService().CheckUserByFingerPrinter(msg.Id);
|
||||
|
||||
logger.Info($"userList是空?{userList == null}");
|
||||
if (userList == null)
|
||||
|
|
|
@ -22,6 +22,7 @@ using DM_Weight.Port;
|
|||
using DM_Weight.select;
|
||||
using DM_Weight.util;
|
||||
using System.Threading;
|
||||
using System.Collections;
|
||||
|
||||
namespace DM_Weight.ViewModels
|
||||
{
|
||||
|
@ -265,8 +266,13 @@ namespace DM_Weight.ViewModels
|
|||
channelStocks.ForEach(it => it.process = 1);
|
||||
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
|
||||
|
||||
|
||||
List<ChannelStock> singleChannels = channelStocks
|
||||
List<ChannelStock> singleChannels = new List<ChannelStock>();
|
||||
for (int i = 0; i < channelStocks.Count; i++)
|
||||
{
|
||||
ChannelStock copy = TransExpV2<ChannelStock, ChannelStock>.Trans(channelStocks[i]);
|
||||
singleChannels.Add(copy);
|
||||
}
|
||||
singleChannels = singleChannels
|
||||
.GroupBy(it => new { it.DrawerNo, it.ColNo })
|
||||
.Select(it =>
|
||||
{
|
||||
|
@ -380,13 +386,29 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
if (singleChannels[i].BoardType == 5)
|
||||
{
|
||||
int totalQuantity = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
.Where(cs => cs.MachineId == singleChannels[i].MachineId)
|
||||
.Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
|
||||
.Where(cs => cs.ColNo == singleChannels[i].ColNo)
|
||||
.Sum(it => it.Quantity);
|
||||
//将库位多批次的总库存数更新标签
|
||||
_portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, totalQuantity);
|
||||
List<ChannelStock> channels = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
.Where(cs => cs.MachineId == singleChannels[i].MachineId)
|
||||
.Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
|
||||
.Where(cs => cs.ColNo == singleChannels[i].ColNo)
|
||||
.OrderBy(cs => cs.EffDate).ToList();
|
||||
if (channels != null && channels.Count > 0)
|
||||
{
|
||||
if (channels[0].Quantity == 0)
|
||||
{
|
||||
//近效期的数量是0,则查该抽屉库位下库存不是0的,有则绑定
|
||||
ChannelStock cs = channels.Where(cs => cs.Quantity > 0).OrderBy(it => it.EffDate).FirstOrDefault();
|
||||
if (cs != null)
|
||||
{
|
||||
_portUtil.WriteChannelInfo(6, cs.EffDate == null ? "" : cs.EffDate, cs.DrawerNo, cs.ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.WriteChannelInfo(5, cs.ManuNo, cs.DrawerNo, cs.ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.ShowContent(cs.DrawerNo, cs.ColNo);
|
||||
}
|
||||
}
|
||||
//将库位多批次的总库存数更新标签
|
||||
_portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, channels.Sum(cs => cs.Quantity));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace DM_Weight.ViewModels
|
|||
|
||||
private PortUtil _portUtil;
|
||||
IEventAggregator _eventAggregator;
|
||||
IDialogService _dialogService;
|
||||
IDialogService _dialogService;
|
||||
//private SqlSugarScope SqlSugarHelper.Db;
|
||||
public OrderTakeDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService, SqlSugarScope sqlSugarScope)
|
||||
{
|
||||
|
@ -171,11 +171,12 @@ namespace DM_Weight.ViewModels
|
|||
|
||||
public void RequestData()
|
||||
{
|
||||
orderDetails = SqlSugarHelper.Db.Queryable<OrderDetail>()
|
||||
.Includes<DrugInfo>(od => od.DrugInfo)
|
||||
.InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (od, t) => od.DrugId == t.DrugId)
|
||||
.Where(od => od.OrderNo == OrderInfo.OrderNo)
|
||||
.ToList();
|
||||
orderDetails = SqlSugarHelper.Db.Queryable<OrderDetail>()
|
||||
.Includes<DrugInfo>(od => od.DrugInfo)
|
||||
.InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (od, t) => od.DrugId == t.DrugId)
|
||||
.Where(od=>od.DMStatus==0)
|
||||
.Where(od => od.OrderNo == OrderInfo.OrderNo)
|
||||
.ToList();
|
||||
|
||||
List<ChannelStock> channelStocks = new List<ChannelStock>();
|
||||
List<string> msg = new List<string>();
|
||||
|
@ -194,7 +195,7 @@ namespace DM_Weight.ViewModels
|
|||
.Where(cs => cs.DrugId == orderDetail.DrugId)
|
||||
.OrderBy(cs => cs.EffDate)
|
||||
.OrderBy(cs => cs.DrawerNo)
|
||||
.OrderBy(cs=> cs.ManuNo)
|
||||
.OrderBy(cs => cs.ManuNo)
|
||||
.ToList();
|
||||
int total = HasQChannels.Sum(it => it.Quantity);
|
||||
int TakeQ = orderDetail.Quantity;
|
||||
|
@ -206,12 +207,14 @@ namespace DM_Weight.ViewModels
|
|||
ChannelStock stock = HasQChannels[j];
|
||||
if (TakeQ > stock.Quantity)
|
||||
{
|
||||
stock.OrderQuantity= orderDetail.Quantity;
|
||||
stock.TakeQuantity = stock.Quantity;
|
||||
channelStocks.Add(stock);
|
||||
TakeQ -= stock.Quantity;
|
||||
}
|
||||
else
|
||||
{
|
||||
stock.OrderQuantity = orderDetail.Quantity;
|
||||
stock.TakeQuantity = TakeQ;
|
||||
channelStocks.Add(stock);
|
||||
TakeQ = 0;
|
||||
|
@ -220,7 +223,16 @@ namespace DM_Weight.ViewModels
|
|||
}
|
||||
else
|
||||
{
|
||||
msg.Add($"药品【{orderDetail.DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】");
|
||||
//msg.Add($"药品【{orderDetail.DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】");
|
||||
//数量不够就把全部数量取出
|
||||
for (int n = 0; n < HasQChannels.Count; n++)
|
||||
{
|
||||
ChannelStock stock = HasQChannels[n];
|
||||
stock.OrderQuantity = TakeQ;
|
||||
stock.TakeQuantity = stock.Quantity;
|
||||
channelStocks.Add(stock);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (msg.Count > 0)
|
||||
|
@ -230,7 +242,7 @@ namespace DM_Weight.ViewModels
|
|||
DialogParameters dialogParameters = new DialogParameters();
|
||||
dialogParameters.Add("msgInfo", msg);
|
||||
DialogServiceExtensions.ShowDialogHost(_dialogService, "ShowMessageDialog", dialogParameters, "RootDialog");
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -272,25 +284,31 @@ namespace DM_Weight.ViewModels
|
|||
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
|
||||
|
||||
//List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
|
||||
List<ChannelStock> singleChannels = channelStocks
|
||||
.GroupBy(it => new { it.DrawerNo, it.ColNo })
|
||||
.Select(it =>
|
||||
{
|
||||
var ret = it.First();
|
||||
ret.Quantity = it.Sum(it => it.Quantity);
|
||||
ret.TakeQuantity = it.Sum(it => it.TakeQuantity);
|
||||
return ret;
|
||||
})
|
||||
.ToList()
|
||||
.FindAll(it => it.BoardType != 1);
|
||||
List<ChannelStock> singleChannels = new List<ChannelStock>();
|
||||
for (int i = 0; i < channelStocks.Count; i++)
|
||||
{
|
||||
ChannelStock copy = TransExpV2<ChannelStock, ChannelStock>.Trans(channelStocks[i]);
|
||||
singleChannels.Add(copy);
|
||||
}
|
||||
|
||||
singleChannels = singleChannels
|
||||
.GroupBy(it => new { it.DrawerNo, it.ColNo })
|
||||
.Select(it =>
|
||||
{
|
||||
var ret = it.First();
|
||||
ret.Quantity = it.Sum(it => it.Quantity);
|
||||
ret.TakeQuantity = it.Sum(it => it.TakeQuantity);
|
||||
return ret;
|
||||
})
|
||||
.ToList()
|
||||
.FindAll(it => it.BoardType != 1);
|
||||
|
||||
// 发送取药数量
|
||||
singleChannels.ForEach(it =>
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
_portUtil.TakeQuantity(DrawerNo, it.ColNo, it.TakeQuantity, it.Quantity - it.TakeQuantity);
|
||||
_portUtil.TakeQuantity(DrawerNo, it.ColNo, it.Quantity, it.Quantity - it.TakeQuantity);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -323,26 +341,55 @@ namespace DM_Weight.ViewModels
|
|||
if (record.Count > 0)
|
||||
{
|
||||
string InvoiceId = OrderInfo.OrderNo;
|
||||
var f = SqlSugarHelper.Db.UseTran(() =>
|
||||
try
|
||||
{
|
||||
SqlSugarHelper.Db.Updateable(new OrderInfo()
|
||||
SqlSugarHelper.Db.BeginTran();
|
||||
//如果处方下全部药品都取完则更新orderInfo,order_detail中的dm_status
|
||||
if (ChannelStocks.Sum(cs => cs.TakeQuantity) == ChannelStocks.Sum(cs => cs.OrderQuantity))
|
||||
{
|
||||
DmStatus = 1,
|
||||
OrderNo = OrderInfo.OrderNo
|
||||
}).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand();
|
||||
|
||||
SqlSugarHelper.Db.Insertable(new OrderFinish()
|
||||
{
|
||||
OrderNo = OrderInfo.OrderNo,
|
||||
PatientId = OrderInfo.PatientId,
|
||||
Pharmacy = OrderInfo.Pharmacy,
|
||||
State = 1,
|
||||
Operator = HomeWindowViewModel.Operator?.Nickname,
|
||||
});
|
||||
logger.Info($"更新OrderInfo:{InvoiceId}");
|
||||
SqlSugarHelper.Db.Updateable(new OrderInfo()
|
||||
{
|
||||
DmStatus = 1,
|
||||
OrderNo = OrderInfo.OrderNo
|
||||
}).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand();
|
||||
SqlSugarHelper.Db.Updateable(new OrderDetail()
|
||||
{
|
||||
DMStatus = 1,
|
||||
OrderNo = OrderInfo.OrderNo
|
||||
}).UpdateColumns(it => new { it.DMStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand();
|
||||
}
|
||||
|
||||
logger.Info("进入record循环");
|
||||
for (int i = 0; i < record.Count; i++)
|
||||
{
|
||||
|
||||
|
||||
ChannelStock it = record[i];
|
||||
//该药品下的所有取出数量
|
||||
int alTakeQuantity=record.Where(rd=>rd.DrugId==it.DrugId).Sum(rd=>rd.TakeQuantity);
|
||||
//处方下某一个药品都取完则更新order_detail
|
||||
if(it.OrderQuantity==it.TakeQuantity|| it.OrderQuantity == alTakeQuantity)
|
||||
{
|
||||
SqlSugarHelper.Db.Updateable(new OrderDetail()
|
||||
{
|
||||
DMStatus = 1,
|
||||
OrderNo = OrderInfo.OrderNo,
|
||||
DrugId= it.DrugId,
|
||||
}).UpdateColumns(it => new { it.DMStatus }).WhereColumns(it => new { it.OrderNo,it.DrugId }).ExecuteCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
//处方下某一个药品没有取完则更新order_detail中的取药数量(应取-已取)
|
||||
SqlSugarHelper.Db.Updateable(new OrderDetail()
|
||||
{
|
||||
Quantity = it.OrderQuantity- alTakeQuantity,
|
||||
OrderNo = OrderInfo.OrderNo,
|
||||
DrugId = it.DrugId,
|
||||
}).UpdateColumns(it => new { it.Quantity }).WhereColumns(it => new { it.OrderNo, it.DrugId }).ExecuteCommand();
|
||||
}
|
||||
|
||||
logger.Info($"更新ChannelStock:{it.Id}");
|
||||
// 更新数据 库存信息
|
||||
SqlSugarHelper.Db.Updateable(new ChannelStock()
|
||||
{
|
||||
|
@ -351,13 +398,14 @@ namespace DM_Weight.ViewModels
|
|||
EffDate = it.EffDate,
|
||||
Id = it.Id,
|
||||
}).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.DrugId.Equals(it.DrugId))
|
||||
.Where(cs => cs.DrawerType == 1)
|
||||
.ToList();
|
||||
|
||||
logger.Info($"保存MachineRecord:{it.ManuNo}");
|
||||
// 保存数据 出库记录
|
||||
SqlSugarHelper.Db.Insertable(new MachineRecord()
|
||||
{
|
||||
|
@ -378,54 +426,71 @@ namespace DM_Weight.ViewModels
|
|||
SupplierDept = ConfigurationManager.AppSettings["receiveDept"].ToString(),
|
||||
ReceiveDept = OrderInfo.DeptName
|
||||
}).ExecuteCommand();
|
||||
logger.Info("结束循环");
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (f.Data)
|
||||
{
|
||||
|
||||
SqlSugarHelper.Db.CommitTran();
|
||||
|
||||
logger.Info("事务已提交");
|
||||
// 更新屏显库存
|
||||
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
|
||||
List<ChannelStock> singleChannels = record.Where(it => it.BoardType != 1)
|
||||
.GroupBy(it => it.ColNo)
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
List<ChannelStock> singleChannels = record.Where(it => it.BoardType == 5)
|
||||
.GroupBy(it => new { it.DrawerNo, 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();
|
||||
//if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
|
||||
//{
|
||||
//singleChannels.ForEach(it =>
|
||||
//{
|
||||
// _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
|
||||
//});
|
||||
//}
|
||||
if(singleChannels.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < singleChannels.Count; i++)
|
||||
logger.Info("查询数据并写标签");
|
||||
if (singleChannels.Count > 0)
|
||||
{
|
||||
if (singleChannels[i].BoardType == 5)
|
||||
for (int i = 0; i < singleChannels.Count; i++)
|
||||
{
|
||||
int totalQuantity = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
.Where(cs => cs.MachineId == singleChannels[i].MachineId)
|
||||
.Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
|
||||
.Where(cs => cs.ColNo == singleChannels[i].ColNo)
|
||||
.Sum(it => it.Quantity);
|
||||
//将库位多批次的总库存数更新标签
|
||||
_portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, totalQuantity);
|
||||
List<ChannelStock> channel = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
.Where(cs => cs.MachineId == singleChannels[i].MachineId)
|
||||
.Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
|
||||
.Where(cs => cs.ColNo == singleChannels[i].ColNo)
|
||||
//.Where(cs=>cs.Quantity>0)
|
||||
.OrderBy(cs => cs.EffDate)
|
||||
.ToList();
|
||||
//.Sum(it => it.Quantity);
|
||||
//将库位多批次的总库存数更新标签
|
||||
_portUtil.WriteQuantity(channel[0].DrawerNo, channel[0].ColNo, channel.Sum(c => c.Quantity));
|
||||
Thread.Sleep(500);
|
||||
//如果最近效期的批次库存为0则重新绑定批次效期标签为库存不为0的近效期的标签
|
||||
if (channel[0].Quantity == 0)
|
||||
{
|
||||
ChannelStock cs = channel.Where(cs => cs.Quantity > 0).OrderBy(it => it.EffDate).FirstOrDefault();
|
||||
if (cs != null)
|
||||
{
|
||||
_portUtil.WriteChannelInfo(6, cs.EffDate == null ? "" : cs.EffDate, cs.DrawerNo, cs.ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.WriteChannelInfo(5, cs.ManuNo, cs.DrawerNo, cs.ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.ShowContent(cs.DrawerNo, cs.ColNo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "抽屉取药完成,库存已更新",
|
||||
Type = MsgType.SUCCESS,
|
||||
};
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
|
||||
{
|
||||
logger.Info($"抽屉取药完成,库存已更新");
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "抽屉取药完成,库存已更新",
|
||||
Type = MsgType.SUCCESS,
|
||||
};
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
}));
|
||||
});
|
||||
|
||||
}
|
||||
if(!f.IsSuccess)
|
||||
catch (Exception ex)
|
||||
{
|
||||
SqlSugarHelper.Db.RollbackTran();
|
||||
logger.Info($"抽屉取药完成,库存更新失败!{ex.Message}");
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "抽屉取药完成,库存更新失败!",
|
||||
|
@ -433,6 +498,155 @@ namespace DM_Weight.ViewModels
|
|||
};
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
}
|
||||
|
||||
//var f = SqlSugarHelper.Db.UseTran(() =>
|
||||
//{
|
||||
// logger.Info($"更新OrderInfo:{InvoiceId}");
|
||||
// SqlSugarHelper.Db.Updateable(new OrderInfo()
|
||||
// {
|
||||
// DmStatus = 1,
|
||||
// OrderNo = OrderInfo.OrderNo
|
||||
// }).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand();
|
||||
|
||||
|
||||
// //SqlSugarHelper.Db.Insertable(new OrderFinish()
|
||||
// //{
|
||||
// // OrderNo = OrderInfo.OrderNo,
|
||||
// // PatientId = OrderInfo.PatientId,
|
||||
// // Pharmacy = OrderInfo.Pharmacy,
|
||||
// // State = 1,
|
||||
// // Operator = HomeWindowViewModel.Operator?.Nickname,
|
||||
// //});
|
||||
// logger.Info("进入record循环");
|
||||
// for (int i = 0; i < record.Count; i++)
|
||||
// {
|
||||
// ChannelStock it = record[i];
|
||||
|
||||
// logger.Info($"更新ChannelStock:{it.Id}");
|
||||
// // 更新数据 库存信息
|
||||
// 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> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
// .Where(cs => cs.MachineId.Equals(it.MachineId))
|
||||
// .Where(cs => cs.DrugId.Equals(it.DrugId))
|
||||
// .Where(cs => cs.DrawerType == 1)
|
||||
// .ToList();
|
||||
// logger.Info($"保存MachineRecord:{it.ManuNo}");
|
||||
// // 保存数据 出库记录
|
||||
// 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,
|
||||
// StockQuantity = nowChannels.Sum(it => it.Quantity),
|
||||
// ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity),
|
||||
// SupplierDept = ConfigurationManager.AppSettings["receiveDept"].ToString(),
|
||||
// ReceiveDept = OrderInfo.DeptName
|
||||
// }).ExecuteCommand();
|
||||
// }
|
||||
// return true;
|
||||
//});
|
||||
//if (f.Data)
|
||||
//{
|
||||
// // 更新屏显库存
|
||||
// //List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
|
||||
// Task.Factory.StartNew(() =>
|
||||
// {
|
||||
// //List<ChannelStock> singleChannels = record.Where(it => it.BoardType != 1)
|
||||
// // .GroupBy(it =>new {it.DrawerNo, it.ColNo })
|
||||
// // .Select(it =>
|
||||
// // {
|
||||
// // var ret = it.First();
|
||||
// // ret.Quantity = it.Sum(itx => itx.Quantity);
|
||||
// // ret.TakeQuantity = it.Sum(itx => itx.TakeQuantity);
|
||||
// // ret.EffDate = it.Min(it => it.EffDate);
|
||||
// // ret.ManuNo = it.OrderBy(it => it.ManuNo).Select(it => it.ManuNo).First().ToString();
|
||||
|
||||
// // return ret;
|
||||
// // })
|
||||
// // .Where(it=>it.Quantity> 0)
|
||||
// // .OrderBy(it => it.EffDate)
|
||||
// // .ToList();
|
||||
|
||||
// List<ChannelStock> singleChannels = record.Where(it => it.BoardType != 1)
|
||||
// .GroupBy(it => new { it.DrawerNo, it.ColNo })
|
||||
// .Select(it =>
|
||||
// {
|
||||
// var ret = it.First();
|
||||
// return ret;
|
||||
// }).ToList();
|
||||
// if (singleChannels.Count > 0)
|
||||
// {
|
||||
// for (int i = 0; i < singleChannels.Count; i++)
|
||||
// {
|
||||
// if (singleChannels[i].BoardType == 5)
|
||||
// {
|
||||
// List<ChannelStock> channel = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
// .Where(cs => cs.MachineId == singleChannels[i].MachineId)
|
||||
// .Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
|
||||
// .Where(cs => cs.ColNo == singleChannels[i].ColNo)
|
||||
// //.Where(cs=>cs.Quantity>0)
|
||||
// .OrderBy(cs => cs.EffDate)
|
||||
// .ToList();
|
||||
// //.Sum(it => it.Quantity);
|
||||
// //将库位多批次的总库存数更新标签
|
||||
// _portUtil.WriteQuantity(channel[0].DrawerNo, channel[0].ColNo, channel.Sum(c => c.Quantity));
|
||||
// Thread.Sleep(500);
|
||||
// //如果最近效期的批次库存为0则重新绑定批次效期标签为库存不为0的近效期的标签
|
||||
// if (channel[0].Quantity == 0)
|
||||
// {
|
||||
// ChannelStock cs = channel.Where(cs => cs.Quantity > 0).OrderBy(it => it.EffDate).FirstOrDefault();
|
||||
// if (cs != null)
|
||||
// {
|
||||
// _portUtil.WriteChannelInfo(6, cs.EffDate == null ? "" : cs.EffDate, cs.DrawerNo, cs.ColNo);
|
||||
// Thread.Sleep(200);
|
||||
// _portUtil.WriteChannelInfo(5, cs.ManuNo, cs.DrawerNo, cs.ColNo);
|
||||
// Thread.Sleep(200);
|
||||
// _portUtil.ShowContent(cs.DrawerNo, cs.ColNo);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
|
||||
// {
|
||||
// logger.Info($"抽屉取药完成,库存已更新");
|
||||
// AlertMsg alertMsg = new AlertMsg
|
||||
// {
|
||||
// Message = "抽屉取药完成,库存已更新",
|
||||
// Type = MsgType.SUCCESS,
|
||||
// };
|
||||
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
// }));
|
||||
// });
|
||||
//}
|
||||
//if (!f.IsSuccess)
|
||||
//{
|
||||
// logger.Info($"抽屉取药完成,库存更新失败!");
|
||||
// AlertMsg alertMsg = new AlertMsg
|
||||
// {
|
||||
// Message = "抽屉取药完成,库存更新失败!",
|
||||
// Type = MsgType.ERROR,
|
||||
// };
|
||||
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
// RequestData();
|
||||
//}
|
||||
Status = 0;
|
||||
_isFinishClick = false;
|
||||
//RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
|
||||
|
|
|
@ -249,7 +249,6 @@ namespace DM_Weight.ViewModels
|
|||
//接收导航传过来的参数 现在是在此处初始化了表格数据
|
||||
public void OnNavigatedTo(NavigationContext navigationContext)
|
||||
{
|
||||
|
||||
logger.Info("进入OrderTakeDrugWindowViewModel_OnNavigatedTo");
|
||||
_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
|
||||
//RequestData();
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
using DM_Weight.Report;
|
||||
using Prism.Mvvm;
|
||||
using Prism.Services.Dialogs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DM_Weight.ViewModels
|
||||
{
|
||||
internal class PrintPdfViewModel: BindableBase , IDialogAware
|
||||
{
|
||||
private string _pdfFilePath;
|
||||
public string pdfFilePath
|
||||
{
|
||||
get=>_pdfFilePath;
|
||||
set =>SetProperty(ref _pdfFilePath, value);
|
||||
}
|
||||
public PrintPdfViewModel()
|
||||
{
|
||||
pdfFilePath = GridReportUtil.PrintReportStockNewTest(DateTime.Now.AddDays(-1),DateTime.Now).Result;
|
||||
}
|
||||
|
||||
private string _template;
|
||||
/// <summary>
|
||||
/// PDF 的 html 模板
|
||||
/// </summary>
|
||||
public string Template
|
||||
{
|
||||
get => _template;
|
||||
set => SetProperty(ref _template, value);
|
||||
}
|
||||
|
||||
private ExpandoObject _data;
|
||||
|
||||
public event Action<IDialogResult> RequestClose;
|
||||
|
||||
/// <summary>
|
||||
/// 传递给 pdf 的数据
|
||||
/// </summary>
|
||||
public ExpandoObject Data
|
||||
{
|
||||
get => _data;
|
||||
set => SetProperty(ref _data, value);
|
||||
}
|
||||
|
||||
public void OnDialogOpened(IDialogParameters parameters)
|
||||
{
|
||||
// 弹窗接收 template 和 data 两个参数
|
||||
//parameters.TryGetValue("template", out _template);
|
||||
//parameters.TryGetValue("data", out _data);
|
||||
}
|
||||
|
||||
public bool CanCloseDialog()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void OnDialogClosed()
|
||||
{
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string Title => "预览 PDF";
|
||||
}
|
||||
}
|
|
@ -17,6 +17,7 @@ using DM_Weight.msg;
|
|||
using DM_Weight.Port;
|
||||
using DM_Weight.util;
|
||||
using SqlSugar;
|
||||
using System.Threading;
|
||||
|
||||
namespace DM_Weight.ViewModels
|
||||
{
|
||||
|
@ -279,16 +280,30 @@ namespace DM_Weight.ViewModels
|
|||
// 更新屏显库存
|
||||
if (ChannelStock.BoardType == 5)
|
||||
{
|
||||
//_portUtil.WriteQuantity(ChannelStock.DrawerNo, ChannelStock.ColNo, ChannelStock.Quantity + ReturnQuantity);
|
||||
int totalQuantity = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
.Where(cs => cs.MachineId.Equals(ChannelStock.MachineId))
|
||||
.Where(cs => cs.DrawerNo == ChannelStock.DrawerNo)
|
||||
.Where(cs => cs.ColNo == ChannelStock.ColNo)
|
||||
.Sum(it => it.Quantity);
|
||||
|
||||
_portUtil.WriteQuantity(ChannelStock.DrawerNo, ChannelStock.ColNo, totalQuantity);
|
||||
List<ChannelStock> channels = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
.Where(cs => cs.MachineId == ChannelStock.MachineId)
|
||||
.Where(cs => cs.DrawerNo == ChannelStock.DrawerNo)
|
||||
.Where(cs => cs.ColNo == ChannelStock.ColNo)
|
||||
.OrderBy(cs => cs.EffDate).ToList();
|
||||
if (channels != null && channels.Count > 0)
|
||||
{
|
||||
if (channels[0].Quantity == 0)
|
||||
{
|
||||
//近效期的数量是0,则查该抽屉库位下库存不是0的,有则绑定
|
||||
ChannelStock cs = channels.Where(cs => cs.Quantity > 0).OrderBy(it => it.EffDate).FirstOrDefault();
|
||||
if (cs != null)
|
||||
{
|
||||
_portUtil.WriteChannelInfo(6, cs.EffDate == null ? "" : cs.EffDate, cs.DrawerNo, cs.ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.WriteChannelInfo(5, cs.ManuNo, cs.DrawerNo, cs.ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.ShowContent(cs.DrawerNo, cs.ColNo);
|
||||
}
|
||||
}
|
||||
//将库位多批次的总库存数更新标签
|
||||
_portUtil.WriteQuantity(ChannelStock.DrawerNo, ChannelStock.ColNo, channels.Sum(cs => cs.Quantity));
|
||||
}
|
||||
}
|
||||
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "操作完成,库存已更新",
|
||||
|
|
|
@ -20,6 +20,8 @@ using DM_Weight.Views;
|
|||
using System.Threading;
|
||||
using SqlSugar;
|
||||
using System.Configuration;
|
||||
using System.Collections;
|
||||
using System.Threading.Channels;
|
||||
|
||||
namespace DM_Weight.ViewModels
|
||||
{
|
||||
|
@ -192,8 +194,13 @@ namespace DM_Weight.ViewModels
|
|||
channelStocks.ForEach(it => it.process = 1);
|
||||
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
|
||||
|
||||
|
||||
List<ChannelStock> singleChannels = channelStocks
|
||||
List<ChannelStock> singleChannels = new List<ChannelStock>();
|
||||
for (int i = 0; i < channelStocks.Count; i++)
|
||||
{
|
||||
ChannelStock copy = TransExpV2<ChannelStock, ChannelStock>.Trans(channelStocks[i]);
|
||||
singleChannels.Add(copy);
|
||||
}
|
||||
singleChannels = singleChannels
|
||||
.GroupBy(it => new {
|
||||
it.DrawerNo, it.ColNo
|
||||
})
|
||||
|
@ -310,7 +317,7 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
// 更新屏显库存
|
||||
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
|
||||
List<ChannelStock> singleChannels = record.Where(it => it.BoardType != 1)
|
||||
List<ChannelStock> singleChannels = record.Where(it => it.BoardType == 5)
|
||||
.GroupBy(it => new { it.DrawerNo,it.ColNo })
|
||||
.Select(it =>
|
||||
{
|
||||
|
@ -335,13 +342,43 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
if (singleChannels[i].BoardType == 5)
|
||||
{
|
||||
int totalQuantity = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
.Where(cs => cs.MachineId == singleChannels[i].MachineId)
|
||||
.Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
|
||||
.Where(cs => cs.ColNo == singleChannels[i].ColNo)
|
||||
.Sum(it => it.Quantity);
|
||||
//将库位多批次的总库存数更新标签
|
||||
_portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, totalQuantity);
|
||||
//int totalQuantity = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
// .Where(cs => cs.MachineId == singleChannels[i].MachineId)
|
||||
// .Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
|
||||
// .Where(cs => cs.ColNo == singleChannels[i].ColNo)
|
||||
// .Sum(it => it.Quantity);
|
||||
|
||||
List<ChannelStock> channels = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
.Where(cs => cs.MachineId == singleChannels[i].MachineId)
|
||||
.Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
|
||||
.Where(cs => cs.ColNo == singleChannels[i].ColNo)
|
||||
.OrderBy(cs => cs.EffDate).ToList();
|
||||
if (channels != null && channels.Count > 0)
|
||||
{
|
||||
if (channels[0].Quantity==0)
|
||||
{
|
||||
//近效期的数量是0,则查该抽屉库位下库存不是0的,有则绑定
|
||||
ChannelStock cs = channels.Where(cs => cs.Quantity > 0).OrderBy(it => it.EffDate).FirstOrDefault();
|
||||
if(cs!=null)
|
||||
{
|
||||
_portUtil.WriteChannelInfo(6, cs.EffDate == null ? "" : cs.EffDate, cs.DrawerNo, cs.ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.WriteChannelInfo(5, cs.ManuNo, cs.DrawerNo, cs.ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.ShowContent(cs.DrawerNo, cs.ColNo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_portUtil.WriteChannelInfo(6, channels[0].EffDate == null ? "" : channels[0].EffDate, channels[0].DrawerNo, channels[0].ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.WriteChannelInfo(5, channels[0].ManuNo, channels[0].DrawerNo, channels[0].ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.ShowContent(channels[0].DrawerNo, channels[0].ColNo);
|
||||
}
|
||||
//将库位多批次的总库存数更新标签
|
||||
_portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, channels.Sum(cs => cs.Quantity));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -356,6 +393,7 @@ namespace DM_Weight.ViewModels
|
|||
}
|
||||
if (!f.IsSuccess)
|
||||
{
|
||||
logger.Info($"自选加药,库存更新失败!{f.ErrorMessage}");
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "库存更新失败!",
|
||||
|
|
|
@ -184,8 +184,13 @@ namespace DM_Weight.ViewModels
|
|||
channelStocks.ForEach(it => it.process = 1);
|
||||
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
|
||||
|
||||
|
||||
List<ChannelStock> singleChannels = channelStocks
|
||||
List<ChannelStock> singleChannels = new List<ChannelStock>();
|
||||
for (int i = 0; i < channelStocks.Count; i++)
|
||||
{
|
||||
ChannelStock copy = TransExpV2<ChannelStock, ChannelStock>.Trans(channelStocks[i]);
|
||||
singleChannels.Add(copy);
|
||||
}
|
||||
singleChannels = singleChannels
|
||||
.GroupBy(it => new { it.DrawerNo, it.ColNo })
|
||||
.Select(it =>
|
||||
{
|
||||
|
@ -269,7 +274,7 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
// 更新屏显库存
|
||||
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
|
||||
List<ChannelStock> singleChannels = ChannelStocks.Where(it => it.BoardType != 1)
|
||||
List<ChannelStock> singleChannels = ChannelStocks.Where(it => it.BoardType == 5)
|
||||
.GroupBy(it =>new { it.DrawerNo, it.ColNo })
|
||||
.Select(it =>
|
||||
{
|
||||
|
@ -292,16 +297,39 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
for (int i = 0; i < singleChannels.Count; i++)
|
||||
{
|
||||
if (singleChannels[i].BoardType == 5)
|
||||
{
|
||||
int totalQuantity = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
.Where(cs => cs.MachineId == singleChannels[i].MachineId)
|
||||
.Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
|
||||
.Where(cs => cs.ColNo == singleChannels[i].ColNo)
|
||||
.Sum(it => it.Quantity);
|
||||
//int totalQuantity = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
// .Where(cs => cs.MachineId == singleChannels[i].MachineId)
|
||||
// .Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
|
||||
// .Where(cs => cs.ColNo == singleChannels[i].ColNo)
|
||||
// .Sum(it => it.Quantity);
|
||||
////将库位多批次的总库存数更新标签
|
||||
//_portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, totalQuantity);
|
||||
|
||||
|
||||
List<ChannelStock> channel = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
.Where(cs => cs.MachineId == singleChannels[i].MachineId)
|
||||
.Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
|
||||
.Where(cs => cs.ColNo == singleChannels[i].ColNo)
|
||||
//.Where(cs=>cs.Quantity>0)
|
||||
.OrderBy(cs => cs.EffDate)
|
||||
.ToList();
|
||||
//.Sum(it => it.Quantity);
|
||||
//将库位多批次的总库存数更新标签
|
||||
_portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, totalQuantity);
|
||||
}
|
||||
_portUtil.WriteQuantity(channel[0].DrawerNo, channel[0].ColNo, channel.Sum(c => c.Quantity));
|
||||
Thread.Sleep(500);
|
||||
//如果最近效期的批次库存为0则重新绑定批次效期标签为库存不为0的近效期的标签
|
||||
if (channel[0].Quantity == 0)
|
||||
{
|
||||
ChannelStock cs = channel.Where(cs => cs.Quantity > 0).OrderBy(it => it.EffDate).FirstOrDefault();
|
||||
if (cs != null)
|
||||
{
|
||||
_portUtil.WriteChannelInfo(6, cs.EffDate == null ? "" : cs.EffDate, cs.DrawerNo, cs.ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.WriteChannelInfo(5, cs.ManuNo, cs.DrawerNo, cs.ColNo);
|
||||
Thread.Sleep(200);
|
||||
_portUtil.ShowContent(cs.DrawerNo, cs.ColNo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -314,6 +342,7 @@ namespace DM_Weight.ViewModels
|
|||
}
|
||||
if (!f.IsSuccess)
|
||||
{
|
||||
logger.Info($"自选取药,库存更新失败!{f.ErrorMessage}");
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "库存更新失败!",
|
||||
|
|
|
@ -337,7 +337,29 @@
|
|||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<!--<DataGridTemplateColumn Width="100" Header="操作">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
--><!--<TextBox Style="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}" IsReadOnly="{Binding BoardType, Converter={StaticResource InputQuantityConverter}}">
|
||||
<TextBox.Text>
|
||||
<Binding Path="AddQuantity" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding.ValidationRules>
|
||||
<ExceptionValidationRule />
|
||||
</Binding.ValidationRules>
|
||||
</Binding>
|
||||
</TextBox.Text>
|
||||
</TextBox>--><!--
|
||||
<Button Grid.Row="2" Padding="0 0 0 1 " Style="{x:Null}" BorderBrush="{x:Null}" Background="{x:Null}" Click="Button_Click_1" CommandParameter="{Binding}">
|
||||
|
||||
<Button.Content>
|
||||
<Border Width="30" Height="30" CornerRadius="16" Background="Red" VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||
<Path Data="M3 3 L20 20 M 20 3 L 3 20" Stroke="WhiteSmoke" StrokeThickness="4" VerticalAlignment="Center" HorizontalAlignment="Center"></Path>
|
||||
</Border>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>-->
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<!--<ListView Padding="0 6 0 0" Grid.Column="1"
|
||||
|
|
|
@ -37,5 +37,17 @@ namespace DM_Weight.Views
|
|||
//vms.AddAction(cls);
|
||||
_eventAggregator.GetEvent<AddDrugEvent>().Publish(cls);
|
||||
}
|
||||
//删除库存为0的批次
|
||||
private void Button_Click_1(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Button delBtn= (Button)sender;
|
||||
ChannelStock cs = (ChannelStock)delBtn.CommandParameter;
|
||||
if(cs.Quantity> 0)
|
||||
{
|
||||
MessageBox.Show($"该批次{cs.ManuNo}库存不为0,不能删除","提示");
|
||||
}
|
||||
|
||||
_eventAggregator.GetEvent<DelDrugManoEvent>().Publish(cs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,26 @@
|
|||
DisplayMemberPath="drug_name_spec" IsEditable="True" IsTextSearchEnabled="False" KeyUp="ComboBox_KeyUp"
|
||||
/>
|
||||
<StackPanel HorizontalAlignment="Right" Grid.Column="3" Orientation="Horizontal">
|
||||
<!--<Button
|
||||
Style="{StaticResource MaterialDesignOutlinedLightButton}"
|
||||
ToolTip="渲染标签"
|
||||
Content="渲染标签"
|
||||
Command="{Binding ResetLabelCommand}"
|
||||
materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
|
||||
materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
|
||||
|
||||
/>-->
|
||||
<Button
|
||||
Style="{StaticResource MaterialDesignOutlinedLightButton}"
|
||||
ToolTip="渲染标签"
|
||||
Content="渲染标签"
|
||||
Command="{Binding ResetLabelCommand}"
|
||||
materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding Status, UpdateSourceTrigger=PropertyChanged}"
|
||||
materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Status, UpdateSourceTrigger=PropertyChanged}"
|
||||
|
||||
/>
|
||||
<Button
|
||||
Margin="6 0 6 0"
|
||||
Style="{StaticResource MaterialDesignOutlinedLightButton}"
|
||||
ToolTip="绑定库位"
|
||||
Content="绑定"
|
||||
|
@ -231,7 +250,7 @@
|
|||
InfoTextIsEnabel="True"
|
||||
/>
|
||||
<materialDesign:Snackbar
|
||||
Background="{Binding SnackbarBackground}"
|
||||
Background="{Binding SnackbarBackground,UpdateSourceTrigger=PropertyChanged}"
|
||||
MessageQueue="{Binding SnackbarMessageQueue}"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
|
|
@ -144,13 +144,6 @@
|
|||
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
|
||||
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
|
||||
/>
|
||||
<DataGridTextColumn Width="100"
|
||||
Header="数量"
|
||||
IsReadOnly="True"
|
||||
Binding="{Binding Quantity}"
|
||||
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
|
||||
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
|
||||
/>
|
||||
<DataGridTextColumn Width="130"
|
||||
Header="批次"
|
||||
IsReadOnly="True"
|
||||
|
@ -166,13 +159,36 @@
|
|||
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
|
||||
/>
|
||||
<DataGridTextColumn Width="100"
|
||||
Header="取出数量"
|
||||
Header="库存数量"
|
||||
IsReadOnly="True"
|
||||
Binding="{Binding TakeQuantity}"
|
||||
Binding="{Binding Quantity}"
|
||||
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
|
||||
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
|
||||
/>
|
||||
</DataGrid.Columns>
|
||||
<DataGridTextColumn Width="100"
|
||||
Header="应取数量"
|
||||
IsReadOnly="True"
|
||||
Binding="{Binding OrderQuantity}"
|
||||
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
|
||||
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
|
||||
/>
|
||||
<DataGridTemplateColumn Width="100"
|
||||
Header="取出数量">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBox Width="100" Style="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}">
|
||||
<TextBox.Text>
|
||||
<Binding Path="TakeQuantity" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding.ValidationRules>
|
||||
<ExceptionValidationRule />
|
||||
</Binding.ValidationRules>
|
||||
</Binding>
|
||||
</TextBox.Text>
|
||||
</TextBox>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<Grid Grid.Row="3">
|
||||
<Grid.ColumnDefinitions>
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<UserControl x:Class="DM_Weight.Views.Dialog.PrintPdfView"
|
||||
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:wpf="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
|
||||
mc:Ignorable="d" MinHeight="750" MinWidth="1000"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid Margin="24">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid>
|
||||
<wpf:WebView2 x:Name="webView2" Source="{Binding pdfFilePath}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
|
@ -0,0 +1,61 @@
|
|||
using DM_Weight.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
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>
|
||||
/// PrintPdfView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class PrintPdfView : UserControl
|
||||
{
|
||||
public PrintPdfView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
///// <summary>
|
||||
///// 配置 WebView2,加载 vuejs,加载 pdf 模板,传递数据到 html 中
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//private async Task Load()
|
||||
//{
|
||||
// await webView2.EnsureCoreWebView2Async();
|
||||
// webView2.CoreWebView2.Settings.AreDefaultContextMenusEnabled = false; // 禁止右键菜单
|
||||
|
||||
// var assembly = Assembly.GetExecutingAssembly();
|
||||
// var resourceName = "PrintPdf.Views.vue.global.js";
|
||||
|
||||
// using var stream = assembly.GetManifestResourceStream(resourceName);
|
||||
// if (stream != null)
|
||||
// {
|
||||
// using var reader = new StreamReader(stream);
|
||||
// var vue = await reader.ReadToEndAsync();
|
||||
// await webView2.CoreWebView2.AddScriptToExecuteOnDocumentCreatedAsync(vue); // 加载 vuejs
|
||||
// }
|
||||
|
||||
// var vm = (PrintPdfViewModel)DataContext;
|
||||
|
||||
// webView2.CoreWebView2.NavigateToString(vm.Template); // 加载 pdf 模板
|
||||
|
||||
// webView2.CoreWebView2.NavigationCompleted += (sender, args) =>
|
||||
// {
|
||||
// var json = JsonSerializer.Serialize(vm.Data);
|
||||
// webView2.CoreWebView2.PostWebMessageAsJson(json); // 将数据传递到 html 中
|
||||
// };
|
||||
//}
|
||||
}
|
||||
}
|
|
@ -27,6 +27,8 @@
|
|||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image Grid.Column="0" Margin="30 0 30 0" HorizontalAlignment="Left" Width="Auto" Height="26" Source="/Images/logo.png" />
|
||||
<!--<TextBlock Text="毒麻药品管理系统" Grid.Column="0" Margin="30 0 30 0" HorizontalAlignment="Left" Width="Auto" Height="26" Foreground="White" FontSize="20" FontWeight="Bold" />-->
|
||||
|
||||
<ListBox Name="ListBoxName" Grid.Column="1" SelectedItem="{Binding SelectedMenu}" ItemsSource="{Binding PremissionDmList}" HorizontalAlignment="Right">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="SelectionChanged">
|
||||
|
|
|
@ -272,12 +272,12 @@
|
|||
Binding="{Binding Quantity}"
|
||||
Header="库存"
|
||||
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
|
||||
<DataGridTextColumn Width="100"
|
||||
<!--<DataGridTextColumn Width="100"
|
||||
Binding="{Binding AddQuantity}"
|
||||
Header="添加数量"
|
||||
IsReadOnly="True"
|
||||
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
|
||||
<!--<DataGridTemplateColumn Width="60">
|
||||
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>-->
|
||||
<DataGridTemplateColumn Width="60">
|
||||
<DataGridTemplateColumn.Header>
|
||||
<TextBlock Text="添加数量" TextWrapping="Wrap"/>
|
||||
</DataGridTemplateColumn.Header>
|
||||
|
@ -294,7 +294,7 @@
|
|||
</TextBox>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>-->
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
Topmost="False"
|
||||
prism:ViewModelLocator.AutoWireViewModel="True"
|
||||
Title="主窗口" Height="768" Width="1024" WindowStyle="None" WindowState="Maximized">
|
||||
<WindowChrome.WindowChrome>
|
||||
<!--<WindowChrome.WindowChrome>
|
||||
<WindowChrome CornerRadius="4" GlassFrameThickness="1" />
|
||||
</WindowChrome.WindowChrome>
|
||||
</WindowChrome.WindowChrome>-->
|
||||
|
||||
<materialDesign:DialogHost
|
||||
DialogMargin="0"
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
<convert:DrawerSelectConverter x:Key="DrawerSelectConverter" />
|
||||
<convert:StatusConverter x:Key="StatusConverter" />-->
|
||||
<convert:TotalCountConverter x:Key="TotalCountConverter" />
|
||||
<convert:ColorCountConverter x:Key="ColorCountConverter" />
|
||||
</Grid.Resources>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
|
@ -120,7 +121,9 @@
|
|||
<!--GroupStyle to group data-->
|
||||
<!--<DataGrid.GroupStyle>
|
||||
<GroupStyle>
|
||||
--><!--Group DataItems into DataGroup--><!--
|
||||
-->
|
||||
<!--Group DataItems into DataGroup-->
|
||||
<!--
|
||||
<GroupStyle.ContainerStyle>
|
||||
<Style TargetType="{x:Type GroupItem}">
|
||||
<Setter Property="Template">
|
||||
|
@ -184,6 +187,20 @@
|
|||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<!--<DataGridTemplateColumn Header="库存" IsReadOnly="True">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<ListBox ItemsSource="{Binding channelStocks}" materialDesign:ListBoxItemAssist.ShowSelection="False" >
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Quantity}" Foreground="{Binding Path=Quantity,Converter={StaticResource ColorCountConverter} }" />
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>-->
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<!--<ListView Grid.Row="1"
|
||||
|
|
|
@ -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 DelDrugManoEvent:PubSubEvent<ChannelStock>
|
||||
{
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue