1)多批次加药时写表channel_stock中的drug_id为channel_stock表中的drug_id;
2)药品绑定时添加渲染标签功能 3)指纹登录时查数据库用手写sql执行查询
This commit is contained in:
parent
a4e9300e63
commit
3bb1ef457a
|
@ -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>();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -248,7 +248,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
|
||||
{
|
||||
|
@ -510,6 +511,7 @@ namespace DM_Weight.ViewModels
|
|||
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;
|
||||
|
|
|
@ -253,11 +253,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 +322,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 +360,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 +399,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)
|
||||
{
|
||||
//有库存,不能解绑
|
||||
|
||||
|
@ -485,7 +485,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 +505,53 @@ namespace DM_Weight.ViewModels
|
|||
}
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
/// 渲染标签
|
||||
/// </summary>
|
||||
public DelegateCommand ResetLabelCommand
|
||||
{
|
||||
get => new DelegateCommand(async () =>
|
||||
{
|
||||
var SelectChannels = Channels.FindAll(item => item.IsSelected);
|
||||
var c = SelectChannels.Count;
|
||||
if (c > 0)
|
||||
{
|
||||
|
||||
SelectChannels.ForEach(async item =>
|
||||
{
|
||||
//var channelStock = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.Chnguid == item.Id).ToList();
|
||||
if (item.BoardType == 5)
|
||||
{
|
||||
if (item.DrugId == null)
|
||||
{
|
||||
// 清除显示屏库位信息
|
||||
_portUtil.ClearContent(item.DrawerNo, item.ColNo);
|
||||
await Task.Delay(200);
|
||||
_portUtil.ShowContent(item.DrawerNo, item.ColNo);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrugInfo drugSelected = item.Drug;
|
||||
_portUtil.WindowName = "BindingChannelDialog";
|
||||
// 向显示屏写入库位信息
|
||||
_portUtil.WriteChannelInfo(1, drugSelected.DrugName, item.DrawerNo, item.ColNo);
|
||||
await Task.Delay(200);
|
||||
_portUtil.WriteChannelInfo(2, drugSelected.DrugSpec, item.DrawerNo, item.ColNo);
|
||||
await Task.Delay(200);
|
||||
_portUtil.WriteChannelInfo(8, drugSelected.Manufactory.Length > 10 ? drugSelected.Manufactory.Substring(0, 10) : drugSelected.Manufactory, item.DrawerNo, item.ColNo);
|
||||
await Task.Delay(200);
|
||||
_portUtil.ShowContent(item.DrawerNo, item.ColNo);
|
||||
//_portUtil.WriteChannelInfo(6, DrugManuNo.EffDate==null?"": DrugManuNo.EffDate, item.DrawerNo, item.ColNo);
|
||||
await Task.Delay(200);
|
||||
_portUtil.WriteQuantity(item.DrawerNo, item.ColNo, item.totalCount);
|
||||
//await Task.Delay(200);
|
||||
}
|
||||
}
|
||||
});
|
||||
//GetChannelsByDrawerNo();
|
||||
}
|
||||
});
|
||||
}
|
||||
public DelegateCommand BtnCloseCommand
|
||||
{
|
||||
get => new DelegateCommand(() =>
|
||||
|
|
|
@ -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,8 +314,9 @@ namespace DM_Weight.ViewModels
|
|||
}
|
||||
private void OpenOneByOne()
|
||||
{
|
||||
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 =Convert.ToInt32(grouping.Key.Substring(0,grouping.Key.IndexOf('-')));
|
||||
int DrawerNo = grouping.Key;
|
||||
List<ChannelStock> channelStocks = grouping.ToList();
|
||||
channelStocks.ForEach(it => it.process = 1);
|
||||
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
|
||||
|
@ -372,7 +375,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];
|
||||
|
@ -416,8 +418,8 @@ namespace DM_Weight.ViewModels
|
|||
|
||||
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 +431,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)
|
||||
|
@ -467,15 +472,14 @@ namespace DM_Weight.ViewModels
|
|||
}).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,
|
||||
|
@ -487,7 +491,7 @@ namespace DM_Weight.ViewModels
|
|||
//ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
|
||||
return ret;
|
||||
}).ToList();
|
||||
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
|
||||
//if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
|
||||
{
|
||||
singleChannels.ForEach(it =>
|
||||
{
|
||||
|
@ -496,14 +500,15 @@ namespace DM_Weight.ViewModels
|
|||
|
||||
});
|
||||
}
|
||||
|
||||
RequestData();
|
||||
logger.Info("已完成-更新标签");
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "抽屉盘点完成,库存已更新",
|
||||
Type = MsgType.SUCCESS,
|
||||
};
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
|
||||
RequestData();
|
||||
}
|
||||
if (!f.IsSuccess)
|
||||
{
|
||||
|
@ -533,7 +538,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
|
||||
{
|
||||
|
@ -613,6 +675,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();
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -73,7 +73,13 @@
|
|||
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}"/>
|
||||
<Button
|
||||
Margin="6 0 6 0"
|
||||
Style="{StaticResource MaterialDesignOutlinedLightButton}"
|
||||
ToolTip="绑定库位"
|
||||
Content="绑定"
|
||||
|
|
Loading…
Reference in New Issue