药品信息页面中基数表查询添加machine_id条件
This commit is contained in:
parent
7f3dd5cc24
commit
1436ad66b4
|
@ -83,7 +83,7 @@ namespace DM_Weight.Models
|
||||||
public int ManuStock { get; set; }
|
public int ManuStock { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 总结存
|
/// 湘谭的报表此字段用于记录空瓶数 -- 总结存
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(ColumnName = "total_stock")]
|
[SugarColumn(ColumnName = "total_stock")]
|
||||||
public int TotalStock { get; set; }
|
public int TotalStock { get; set; }
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace DM_Weight.Models
|
||||||
public class DrugBase:BindableBase
|
public class DrugBase:BindableBase
|
||||||
{
|
{
|
||||||
private int _baseId = 0;
|
private int _baseId = 0;
|
||||||
[SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
|
[SugarColumn(ColumnName = "baseid", IsPrimaryKey = true)]
|
||||||
public int BaseId { get=> _baseId; set { SetProperty(ref _baseId, value); } }
|
public int BaseId { get=> _baseId; set { SetProperty(ref _baseId, value); } }
|
||||||
private string _drugId = "0";
|
private string _drugId = "0";
|
||||||
[SugarColumn(ColumnName = "drugid")]
|
[SugarColumn(ColumnName = "drugid")]
|
||||||
|
@ -24,7 +24,7 @@ namespace DM_Weight.Models
|
||||||
[SugarColumn(ColumnName = "machine_id")]
|
[SugarColumn(ColumnName = "machine_id")]
|
||||||
public string MachineId { get => _machineId; set { SetProperty(ref _machineId, value); } }
|
public string MachineId { get => _machineId; set { SetProperty(ref _machineId, value); } }
|
||||||
private int _baseQuantity = 0;
|
private int _baseQuantity = 0;
|
||||||
[SugarColumn(ColumnName = "base_quantity")]
|
[SugarColumn(ColumnName = "basequantity")]
|
||||||
public int BaseQuantity { get=>_baseQuantity; set{ SetProperty(ref _baseQuantity, value); } }
|
public int BaseQuantity { get=>_baseQuantity; set{ SetProperty(ref _baseQuantity, value); } }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Configuration;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Prism.Mvvm;
|
using Prism.Mvvm;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
|
@ -60,7 +61,7 @@ namespace DM_Weight.Models
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <20><>װ<EFBFBD><D7B0>λ
|
/// <20><>װ<EFBFBD><D7B0>λ
|
||||||
///</summary>
|
///</summary>
|
||||||
[SugarColumn(ColumnName = "pack_unit")]
|
[SugarColumn(ColumnName = "Big_unit")]
|
||||||
public string PackUnit { get; set; }
|
public string PackUnit { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
@ -86,7 +87,7 @@ namespace DM_Weight.Models
|
||||||
public int? StockQuantity { get; set; }
|
public int? StockQuantity { get; set; }
|
||||||
|
|
||||||
private DrugBase _base;
|
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
|
public DrugBase drugBase
|
||||||
{
|
{
|
||||||
get=> _base;
|
get=> _base;
|
||||||
|
|
|
@ -16,6 +16,7 @@ using DM_Weight.msg;
|
||||||
using Prism.Events;
|
using Prism.Events;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
using static Unity.Storage.RegistrationSet;
|
using static Unity.Storage.RegistrationSet;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
namespace DM_Weight.ViewModels
|
namespace DM_Weight.ViewModels
|
||||||
{
|
{
|
||||||
|
@ -306,7 +307,7 @@ namespace DM_Weight.ViewModels
|
||||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||||
}
|
}
|
||||||
RequestData();
|
RequestData();
|
||||||
}, () => SelectedDrug.DrugId !=null).ObservesProperty(() => SelectedDrug);
|
}, () => SelectedDrug.DrugId != null).ObservesProperty(() => SelectedDrug);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DelegateCommand AddManuCommand
|
public DelegateCommand AddManuCommand
|
||||||
|
@ -322,7 +323,7 @@ namespace DM_Weight.ViewModels
|
||||||
GetManuNos();
|
GetManuNos();
|
||||||
}
|
}
|
||||||
|
|
||||||
}, () => SelectedDrug.DrugId !=null).ObservesProperty(() => SelectedDrug);
|
}, () => SelectedDrug.DrugId != null).ObservesProperty(() => SelectedDrug);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DelegateCommand EditManuCommand
|
public DelegateCommand EditManuCommand
|
||||||
|
@ -362,17 +363,28 @@ namespace DM_Weight.ViewModels
|
||||||
{
|
{
|
||||||
int totalCount = 0;
|
int totalCount = 0;
|
||||||
DrugInfos = SqlSugarHelper.Db.Queryable<DrugInfo>()
|
DrugInfos = SqlSugarHelper.Db.Queryable<DrugInfo>()
|
||||||
.Includes(di => di.drugBase)
|
//.LeftJoin<DrugBase>((di, db) => di.DrugId == db.DrugId && db.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
|
||||||
|
.Includes(di=>di.drugBase)
|
||||||
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (di) => di.DrugId.ToString().Contains(SearchValue))
|
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("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("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("PyCode"), (di) => di.PyCode.Contains(SearchValue))
|
||||||
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (di) => di.DrugBarcode.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);
|
.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();
|
di.drugBase = new DrugBase();
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,8 +259,9 @@ namespace DM_Weight.ViewModels
|
||||||
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
|
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
|
||||||
// 获取更新完库存后的药品库存
|
// 获取更新完库存后的药品库存
|
||||||
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||||
.Where(cs => cs.MachineId.Equals(it.MachineId))
|
.Where(cs => cs.MachineId.Equals(it.MachineId)||cs.MachineId.Equals(ConfigurationManager.AppSettings["jj_machineId"]))
|
||||||
.Where(cs => cs.DrugId.Equals(it.DrugId))
|
.Where(cs => cs.DrugId.Equals(it.DrugId))
|
||||||
|
.Where(cs=>cs.ManuNo.Equals(it.ManuNo))
|
||||||
.Where(cs => cs.DrawerType == 1)
|
.Where(cs => cs.DrawerType == 1)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
|
@ -282,6 +283,12 @@ namespace DM_Weight.ViewModels
|
||||||
//,StockQuantity = nowChannels.Sum(it => it.Quantity)
|
//,StockQuantity = nowChannels.Sum(it => it.Quantity)
|
||||||
}).ExecuteCommand();
|
}).ExecuteCommand();
|
||||||
|
|
||||||
|
//查询上一条账册中的空瓶数
|
||||||
|
AccountBookG2 accountBookEmpty = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
||||||
|
.Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["machineId"].ToString()))
|
||||||
|
.Where(ab => ab.Type == 1 || ab.Type == 2)
|
||||||
|
.Where(ab => ab.DrugId == it.DrugId)
|
||||||
|
.Where(ab => ab.ManuNo == it.ManuNo).OrderByDescending(ab => ab.Id).First();
|
||||||
//保存账册
|
//保存账册
|
||||||
SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||||
{
|
{
|
||||||
|
@ -296,7 +303,9 @@ namespace DM_Weight.ViewModels
|
||||||
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||||
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||||
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
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();
|
}).ExecuteCommand();
|
||||||
//修改凌晨生成的日结存数据
|
//修改凌晨生成的日结存数据
|
||||||
|
|
Loading…
Reference in New Issue