diff --git a/DM_Weight/Models/AccountBookG2.cs b/DM_Weight/Models/AccountBookG2.cs index 74ede11..89d2d3d 100644 --- a/DM_Weight/Models/AccountBookG2.cs +++ b/DM_Weight/Models/AccountBookG2.cs @@ -83,7 +83,7 @@ namespace DM_Weight.Models public int ManuStock { get; set; } /// - /// 总结存 + /// 湘谭的报表此字段用于记录空瓶数 -- 总结存 /// [SugarColumn(ColumnName = "total_stock")] public int TotalStock { get; set; } diff --git a/DM_Weight/Models/DrugBase.cs b/DM_Weight/Models/DrugBase.cs index 6d79200..b7ba962 100644 --- a/DM_Weight/Models/DrugBase.cs +++ b/DM_Weight/Models/DrugBase.cs @@ -15,7 +15,7 @@ namespace DM_Weight.Models public class DrugBase:BindableBase { private int _baseId = 0; - [SugarColumn(ColumnName = "id", IsPrimaryKey = true)] + [SugarColumn(ColumnName = "baseid", IsPrimaryKey = true)] public int BaseId { get=> _baseId; set { SetProperty(ref _baseId, value); } } private string _drugId = "0"; [SugarColumn(ColumnName = "drugid")] @@ -24,7 +24,7 @@ namespace DM_Weight.Models [SugarColumn(ColumnName = "machine_id")] public string MachineId { get => _machineId; set { SetProperty(ref _machineId, value); } } private int _baseQuantity = 0; - [SugarColumn(ColumnName = "base_quantity")] + [SugarColumn(ColumnName = "basequantity")] public int BaseQuantity { get=>_baseQuantity; set{ SetProperty(ref _baseQuantity, value); } } } diff --git a/DM_Weight/Models/DrugInfo.cs b/DM_Weight/Models/DrugInfo.cs index fc41a64..8506887 100644 --- a/DM_Weight/Models/DrugInfo.cs +++ b/DM_Weight/Models/DrugInfo.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Configuration; using System.Linq; using Prism.Mvvm; using SqlSugar; @@ -60,7 +61,7 @@ namespace DM_Weight.Models /// /// ��װ��λ /// - [SugarColumn(ColumnName = "pack_unit")] + [SugarColumn(ColumnName = "Big_unit")] public string PackUnit { get; set; } /// /// �������� @@ -86,7 +87,7 @@ namespace DM_Weight.Models public int? StockQuantity { get; set; } private DrugBase _base; - [Navigate(NavigateType.OneToOne, nameof(DrugBase.DrugId), nameof(DrugId))] + [Navigate(NavigateType.OneToOne, nameof(DrugBase.DrugId), nameof(DrugId), whereSql: "machine_id='DM3'")] public DrugBase drugBase { get=> _base; diff --git a/DM_Weight/ViewModels/DrugListWindowViewModel.cs b/DM_Weight/ViewModels/DrugListWindowViewModel.cs index fce0cc8..3135a1b 100644 --- a/DM_Weight/ViewModels/DrugListWindowViewModel.cs +++ b/DM_Weight/ViewModels/DrugListWindowViewModel.cs @@ -16,6 +16,7 @@ using DM_Weight.msg; using Prism.Events; using System.Configuration; using static Unity.Storage.RegistrationSet; +using SqlSugar; namespace DM_Weight.ViewModels { @@ -306,7 +307,7 @@ namespace DM_Weight.ViewModels _eventAggregator.GetEvent().Publish(alertMsg); } RequestData(); - }, () => SelectedDrug.DrugId !=null).ObservesProperty(() => SelectedDrug); + }, () => SelectedDrug.DrugId != null).ObservesProperty(() => SelectedDrug); } public DelegateCommand AddManuCommand @@ -322,7 +323,7 @@ namespace DM_Weight.ViewModels GetManuNos(); } - }, () => SelectedDrug.DrugId !=null).ObservesProperty(() => SelectedDrug); + }, () => SelectedDrug.DrugId != null).ObservesProperty(() => SelectedDrug); } public DelegateCommand EditManuCommand @@ -362,17 +363,28 @@ namespace DM_Weight.ViewModels { int totalCount = 0; DrugInfos = SqlSugarHelper.Db.Queryable() - .Includes(di => di.drugBase) + //.LeftJoin((di, db) => di.DrugId == db.DrugId && db.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")) + .Includes(di=>di.drugBase) .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (di) => di.DrugId.ToString().Contains(SearchValue)) .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (di) => di.DrugName.Contains(SearchValue)) .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (di) => di.PyCode.Contains(SearchValue)) .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (di) => di.DrugBarcode.Contains(SearchValue)) - //.Select(di => di) + //.Select((di, db) => new DrugInfo() + //{ + // DrugName = di.DrugName, + // DrugId = di.DrugId, + // DrugBarcode = di.DrugBarcode, + // DrugSpec = di.DrugSpec, + // PyCode = di.PyCode, + // PackUnit=di.PackUnit, + // Manufactory=di.Manufactory, + // drugBase = db, + //}) .ToPageList(PageNum, PageSize, ref totalCount); - foreach(DrugInfo di in DrugInfos) + foreach (DrugInfo di in DrugInfos) { - if(di.drugBase==null) + if (di.drugBase == null) { di.drugBase = new DrugBase(); } diff --git a/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs b/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs index 7c8ac31..4af7337 100644 --- a/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs +++ b/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs @@ -259,8 +259,9 @@ namespace DM_Weight.ViewModels }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand(); // 获取更新完库存后的药品库存 List nowChannels = SqlSugarHelper.Db.Queryable() - .Where(cs => cs.MachineId.Equals(it.MachineId)) + .Where(cs => cs.MachineId.Equals(it.MachineId)||cs.MachineId.Equals(ConfigurationManager.AppSettings["jj_machineId"])) .Where(cs => cs.DrugId.Equals(it.DrugId)) + .Where(cs=>cs.ManuNo.Equals(it.ManuNo)) .Where(cs => cs.DrawerType == 1) .ToList(); @@ -282,6 +283,12 @@ namespace DM_Weight.ViewModels //,StockQuantity = nowChannels.Sum(it => it.Quantity) }).ExecuteCommand(); + //查询上一条账册中的空瓶数 + AccountBookG2 accountBookEmpty = SqlSugarHelper.Db.Queryable() + .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["machineId"].ToString())) + .Where(ab => ab.Type == 1 || ab.Type == 2) + .Where(ab => ab.DrugId == it.DrugId) + .Where(ab => ab.ManuNo == it.ManuNo).OrderByDescending(ab => ab.Id).First(); //保存账册 SqlSugarHelper.Db.Insertable(new AccountBookG2() { @@ -296,7 +303,9 @@ namespace DM_Weight.ViewModels UserId2 = HomeWindowViewModel.Reviewer?.Id, MachineId = ConfigurationManager.AppSettings["machineId"].ToString(), CreateDate = DateTime.Now.ToString("yyyy-MM-dd"), - CreateTime = DateTime.Now + CreateTime = DateTime.Now, + ManuStock= nowChannels.Sum(it => it.Quantity), + TotalStock= (accountBookEmpty!=null?(accountBookEmpty.TotalStock>0&& accountBookEmpty.TotalStock>it.AddQuantity ? accountBookEmpty.TotalStock - it.AddQuantity : 0):0) //负数直接记0 }).ExecuteCommand(); //修改凌晨生成的日结存数据