修改凌晨生成的总结存数据时,如果没有数据则写入一条。(凌晨生成数据时没有绑定库位的则不会生成,当天绑定库位且做库位操作时需要手动写入一条日结存、总结存数据)
This commit is contained in:
parent
3a279d73a0
commit
8fe17f7517
|
@ -330,7 +330,7 @@ namespace DM_Weight.ViewModels
|
||||||
{
|
{
|
||||||
if (SelectDrugPleaseClaim.GetQuantity == 1)
|
if (SelectDrugPleaseClaim.GetQuantity == 1)
|
||||||
{
|
{
|
||||||
if(SelectDrugPleaseClaim.DrugManuNo is null)
|
if (SelectDrugPleaseClaim.DrugManuNo is null)
|
||||||
{
|
{
|
||||||
AlertMsg alertMsg = new AlertMsg
|
AlertMsg alertMsg = new AlertMsg
|
||||||
{
|
{
|
||||||
|
@ -359,7 +359,7 @@ namespace DM_Weight.ViewModels
|
||||||
.OrderBy(cs => cs.DrawerNo)
|
.OrderBy(cs => cs.DrawerNo)
|
||||||
.OrderBy(cs => cs.ColNo)
|
.OrderBy(cs => cs.ColNo)
|
||||||
.First();
|
.First();
|
||||||
if(q is null)
|
if (q is null)
|
||||||
{
|
{
|
||||||
AlertMsg alertMsg = new AlertMsg
|
AlertMsg alertMsg = new AlertMsg
|
||||||
{
|
{
|
||||||
|
@ -655,7 +655,7 @@ 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,
|
||||||
InvoiceNo = SelectDrugPleaseClaim.PleaseNo
|
InvoiceNo = SelectDrugPleaseClaim.PleaseNo
|
||||||
|
|
||||||
}).ExecuteCommand();
|
}).ExecuteCommand();
|
||||||
|
@ -667,7 +667,33 @@ namespace DM_Weight.ViewModels
|
||||||
.Where(ab => ab.ManuNo == it.ManuNo)
|
.Where(ab => ab.ManuNo == it.ManuNo)
|
||||||
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||||
|
|
||||||
|
if (accountBookG2Day != null)
|
||||||
|
{
|
||||||
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + it.AddQuantity;
|
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + it.AddQuantity;
|
||||||
|
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//生成日结存时可能没有该库位的绑定信息,需要写入日结存
|
||||||
|
int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() {
|
||||||
|
DrugId = Convert.ToInt32(it.DrugId),
|
||||||
|
Type=3,
|
||||||
|
ManuNo=it.ManuNo,
|
||||||
|
EffDate=it.EffDate,
|
||||||
|
YQuantity=0,
|
||||||
|
ManuStock= it.AddQuantity,
|
||||||
|
TotalStock= it.AddQuantity,
|
||||||
|
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||||
|
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||||
|
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||||
|
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||||
|
InvoiceNo = "日结存"
|
||||||
|
}).ExecuteCommand();
|
||||||
|
if (iDayResult <= 0)
|
||||||
|
{
|
||||||
|
logger.Info($"未写入日结存数据{it.DrugId}-{it.ManuNo}-{it.EffDate}-{it.AddQuantity}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//修改凌晨生成的日结存与总结存数据
|
//修改凌晨生成的日结存与总结存数据
|
||||||
AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
||||||
|
@ -675,13 +701,34 @@ namespace DM_Weight.ViewModels
|
||||||
.Where(ab => ab.Type == 4)
|
.Where(ab => ab.Type == 4)
|
||||||
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
||||||
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||||
|
if (accountBookG2Total != null)
|
||||||
|
{
|
||||||
accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + it.AddQuantity;
|
accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + it.AddQuantity;
|
||||||
|
|
||||||
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
|
|
||||||
|
|
||||||
SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
|
SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//生成总结存时可能没有该库位的绑定信息,需要写入总结存
|
||||||
|
int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||||
|
{
|
||||||
|
DrugId = Convert.ToInt32(it.DrugId),
|
||||||
|
Type = 4,
|
||||||
|
YQuantity = 0,
|
||||||
|
ManuStock = it.AddQuantity,
|
||||||
|
TotalStock = it.AddQuantity,
|
||||||
|
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||||
|
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||||
|
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||||
|
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||||
|
InvoiceNo = "总结存"
|
||||||
|
}).ExecuteCommand();
|
||||||
|
if (iTotalResult <= 0)
|
||||||
|
{
|
||||||
|
logger.Info($"未写入总结存数据{it.DrugId}-{it.AddQuantity}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
|
@ -150,6 +150,7 @@ namespace DM_Weight.ViewModels
|
||||||
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (cd) => cd.drugInfo.PyCode.Contains(SearchValue))
|
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (cd) => cd.drugInfo.PyCode.Contains(SearchValue))
|
||||||
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (cd) => cd.drugInfo.DrugBarcode.Contains(SearchValue))
|
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (cd) => cd.drugInfo.DrugBarcode.Contains(SearchValue))
|
||||||
.WhereIF((_DrugPleaseState!=null&& _DrugPleaseState.StateValue>=0),(cd,dp)=>dp.State==_DrugPleaseState.StateValue)
|
.WhereIF((_DrugPleaseState!=null&& _DrugPleaseState.StateValue>=0),(cd,dp)=>dp.State==_DrugPleaseState.StateValue)
|
||||||
|
.GroupBy(cd=>cd.Applyid)
|
||||||
.OrderByDescending(cd => cd.Createdate)
|
.OrderByDescending(cd => cd.Createdate)
|
||||||
.OrderByDescending(cd => cd.DrugId)
|
.OrderByDescending(cd => cd.DrugId)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
|
@ -195,6 +195,15 @@ namespace DM_Weight.ViewModels
|
||||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AlertMsg alertMsg = new AlertMsg
|
||||||
|
{
|
||||||
|
Message = "请选择要销毁的数据",
|
||||||
|
Type = MsgType.ERROR,
|
||||||
|
};
|
||||||
|
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,7 +198,7 @@ namespace DM_Weight.ViewModels
|
||||||
ManuNo = it.ManuNo,
|
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,
|
Operator = HomeWindowViewModel.Operator?.Id,
|
||||||
Reviewer=HomeWindowViewModel.Reviewer?.Id,
|
Reviewer = HomeWindowViewModel.Reviewer?.Id,
|
||||||
OperationTime = DateTime.Now,
|
OperationTime = DateTime.Now,
|
||||||
Quantity = it.AddQuantity,
|
Quantity = it.AddQuantity,
|
||||||
Type = 1,
|
Type = 1,
|
||||||
|
@ -231,21 +231,66 @@ namespace DM_Weight.ViewModels
|
||||||
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
||||||
.Where(ab => ab.ManuNo == it.ManuNo)
|
.Where(ab => ab.ManuNo == it.ManuNo)
|
||||||
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||||
|
if (accountBookG2Day != null)
|
||||||
|
{
|
||||||
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + it.AddQuantity;
|
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + it.AddQuantity;
|
||||||
|
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//生成日结存时可能没有该库位的绑定信息,需要写入日结存
|
||||||
|
int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||||
|
{
|
||||||
|
DrugId = Convert.ToInt32(it.DrugId),
|
||||||
|
Type = 3,
|
||||||
|
ManuNo = it.ManuNo,
|
||||||
|
EffDate = it.EffDate,
|
||||||
|
YQuantity = 0,
|
||||||
|
ManuStock = it.AddQuantity,
|
||||||
|
TotalStock = it.AddQuantity,
|
||||||
|
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||||
|
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||||
|
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||||
|
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||||
|
InvoiceNo = "日结存"
|
||||||
|
}).ExecuteCommand();
|
||||||
|
if (iDayResult <= 0)
|
||||||
|
{
|
||||||
|
logger.Info($"未写入日结存数据{it.DrugId}-{it.ManuNo}-{it.EffDate}-{it.AddQuantity}");
|
||||||
|
}
|
||||||
|
}
|
||||||
//修改凌晨生成的总结存数据
|
//修改凌晨生成的总结存数据
|
||||||
AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
||||||
.Where(ab => ab.MachineId.Equals(it.MachineId))
|
.Where(ab => ab.MachineId.Equals(it.MachineId))
|
||||||
.Where(ab => ab.Type == 4)
|
.Where(ab => ab.Type == 4)
|
||||||
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
||||||
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||||
|
if (accountBookG2Total != null)
|
||||||
|
{
|
||||||
accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + it.AddQuantity;
|
accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + it.AddQuantity;
|
||||||
|
|
||||||
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
|
|
||||||
|
|
||||||
SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
|
SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//生成总结存时可能没有该库位的绑定信息,需要写入总结存
|
||||||
|
int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||||
|
{
|
||||||
|
DrugId = Convert.ToInt32(it.DrugId),
|
||||||
|
Type = 4,
|
||||||
|
YQuantity = 0,
|
||||||
|
ManuStock = it.AddQuantity,
|
||||||
|
TotalStock = it.AddQuantity,
|
||||||
|
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||||
|
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||||
|
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||||
|
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||||
|
InvoiceNo = "总结存"
|
||||||
|
}).ExecuteCommand();
|
||||||
|
if (iTotalResult <= 0)
|
||||||
|
{
|
||||||
|
logger.Info($"未写入总结存数据{it.DrugId}-{it.AddQuantity}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
|
@ -233,22 +233,66 @@ namespace DM_Weight.ViewModels
|
||||||
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
||||||
.Where(ab => ab.ManuNo == it.ManuNo)
|
.Where(ab => ab.ManuNo == it.ManuNo)
|
||||||
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||||
|
if (accountBookG2Day != null)
|
||||||
|
{
|
||||||
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - it.TakeQuantity;
|
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - it.TakeQuantity;
|
||||||
|
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//生成日结存时可能没有该库位的绑定信息,需要写入日结存
|
||||||
|
int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||||
|
{
|
||||||
|
DrugId = Convert.ToInt32(it.DrugId),
|
||||||
|
Type = 3,
|
||||||
|
ManuNo = it.ManuNo,
|
||||||
|
EffDate = it.EffDate,
|
||||||
|
YQuantity = 0,
|
||||||
|
ManuStock = it.TakeQuantity,
|
||||||
|
TotalStock = it.TakeQuantity,
|
||||||
|
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||||
|
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||||
|
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||||
|
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||||
|
InvoiceNo = "日结存"
|
||||||
|
}).ExecuteCommand();
|
||||||
|
if (iDayResult <= 0)
|
||||||
|
{
|
||||||
|
logger.Info($"未写入日结存数据{it.DrugId}-{it.ManuNo}-{it.EffDate}-{it.AddQuantity}");
|
||||||
|
}
|
||||||
|
}
|
||||||
//修改凌晨生成的总结存数据
|
//修改凌晨生成的总结存数据
|
||||||
AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
||||||
.Where(ab => ab.MachineId.Equals(it.MachineId))
|
.Where(ab => ab.MachineId.Equals(it.MachineId))
|
||||||
.Where(ab => ab.Type == 4)
|
.Where(ab => ab.Type == 4)
|
||||||
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
||||||
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||||
|
if (accountBookG2Total != null)
|
||||||
|
{
|
||||||
accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - it.TakeQuantity;
|
accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - it.TakeQuantity;
|
||||||
|
|
||||||
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
|
|
||||||
|
|
||||||
SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
|
SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//生成总结存时可能没有该库位的绑定信息,需要写入总结存
|
||||||
|
int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||||
|
{
|
||||||
|
DrugId = Convert.ToInt32(it.DrugId),
|
||||||
|
Type = 4,
|
||||||
|
YQuantity = 0,
|
||||||
|
ManuStock = it.TakeQuantity,
|
||||||
|
TotalStock = it.TakeQuantity,
|
||||||
|
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||||
|
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||||
|
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||||
|
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||||
|
InvoiceNo = "总结存"
|
||||||
|
}).ExecuteCommand();
|
||||||
|
if (iTotalResult <= 0)
|
||||||
|
{
|
||||||
|
logger.Info($"未写入总结存数据{it.DrugId}-{it.AddQuantity}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
logger.Info($"抽屉取药保存->库位【{it.DrawerNo}-{it.ColNo}】取出药品【{it.DrugInfo.DrugName}】个数【{it.TakeQuantity}】,取药前库存【{it.Quantity}】");
|
logger.Info($"抽屉取药保存->库位【{it.DrawerNo}-{it.ColNo}】取出药品【{it.DrugInfo.DrugName}】个数【{it.TakeQuantity}】,取药前库存【{it.Quantity}】");
|
||||||
|
|
|
@ -304,21 +304,67 @@ namespace DM_Weight.ViewModels
|
||||||
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
||||||
.Where(ab => ab.ManuNo == it.ManuNo)
|
.Where(ab => ab.ManuNo == it.ManuNo)
|
||||||
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||||
|
if (accountBookG2Day != null)
|
||||||
|
{
|
||||||
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + it.AddQuantity;
|
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + it.AddQuantity;
|
||||||
|
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//生成日结存时可能没有该库位的绑定信息,需要写入日结存
|
||||||
|
int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||||
|
{
|
||||||
|
DrugId = Convert.ToInt32(it.DrugId),
|
||||||
|
Type = 3,
|
||||||
|
ManuNo = it.ManuNo,
|
||||||
|
EffDate = it.EffDate,
|
||||||
|
YQuantity = 0,
|
||||||
|
ManuStock = it.AddQuantity,
|
||||||
|
TotalStock = it.AddQuantity,
|
||||||
|
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||||
|
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||||
|
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||||
|
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||||
|
InvoiceNo = "日结存"
|
||||||
|
}).ExecuteCommand();
|
||||||
|
if (iDayResult <= 0)
|
||||||
|
{
|
||||||
|
logger.Info($"未写入日结存数据{it.DrugId}-{it.ManuNo}-{it.EffDate}-{it.AddQuantity}");
|
||||||
|
}
|
||||||
|
}
|
||||||
//修改凌晨生成的总结存数据
|
//修改凌晨生成的总结存数据
|
||||||
AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
||||||
.Where(ab => ab.MachineId.Equals(it.MachineId))
|
.Where(ab => ab.MachineId.Equals(it.MachineId))
|
||||||
.Where(ab => ab.Type == 4)
|
.Where(ab => ab.Type == 4)
|
||||||
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
||||||
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||||
|
if (accountBookG2Total != null)
|
||||||
|
{
|
||||||
accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + it.AddQuantity;
|
accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + it.AddQuantity;
|
||||||
|
|
||||||
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
|
|
||||||
|
|
||||||
SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
|
SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//生成总结存时可能没有该库位的绑定信息,需要写入总结存
|
||||||
|
int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||||
|
{
|
||||||
|
DrugId = Convert.ToInt32(it.DrugId),
|
||||||
|
Type = 4,
|
||||||
|
YQuantity = 0,
|
||||||
|
ManuStock = it.AddQuantity,
|
||||||
|
TotalStock = it.AddQuantity,
|
||||||
|
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||||
|
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||||
|
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||||
|
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||||
|
InvoiceNo = "总结存"
|
||||||
|
}).ExecuteCommand();
|
||||||
|
if (iTotalResult <= 0)
|
||||||
|
{
|
||||||
|
logger.Info($"未写入总结存数据{it.DrugId}-{it.AddQuantity}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
if (f.Data)
|
if (f.Data)
|
||||||
|
|
|
@ -172,7 +172,7 @@ namespace DM_Weight.ViewModels
|
||||||
{
|
{
|
||||||
invoices = SqlSugarHelper.Db.Queryable<InOutInvoice>()
|
invoices = SqlSugarHelper.Db.Queryable<InOutInvoice>()
|
||||||
.Includes<DrugInfo>(i => i.DrugInfo)
|
.Includes<DrugInfo>(i => i.DrugInfo)
|
||||||
.InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs =>cs.DrugId),(i,t) => i.DrugId == t.DrugId)
|
.InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (i, t) => i.DrugId == t.DrugId)
|
||||||
.Where(i => i.InvoiceNo == Invoice.InvoiceNo)
|
.Where(i => i.InvoiceNo == Invoice.InvoiceNo)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ namespace DM_Weight.ViewModels
|
||||||
msg.Add($"药品【{invoice.DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】");
|
msg.Add($"药品【{invoice.DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(msg.Count > 0)
|
if (msg.Count > 0)
|
||||||
{
|
{
|
||||||
RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
|
RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
|
||||||
//MessageBox.Show(string.Join("\n", msg));
|
//MessageBox.Show(string.Join("\n", msg));
|
||||||
|
@ -367,20 +367,66 @@ namespace DM_Weight.ViewModels
|
||||||
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
||||||
.Where(ab => ab.ManuNo == it.ManuNo)
|
.Where(ab => ab.ManuNo == it.ManuNo)
|
||||||
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||||
|
if (accountBookG2Day != null)
|
||||||
|
{
|
||||||
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - it.TakeQuantity;
|
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - it.TakeQuantity;
|
||||||
|
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//生成日结存时可能没有该库位的绑定信息,需要写入日结存
|
||||||
|
int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||||
|
{
|
||||||
|
DrugId = Convert.ToInt32(it.DrugId),
|
||||||
|
Type = 3,
|
||||||
|
ManuNo = it.ManuNo,
|
||||||
|
EffDate = it.EffDate,
|
||||||
|
YQuantity = 0,
|
||||||
|
ManuStock = it.TakeQuantity,
|
||||||
|
TotalStock = it.TakeQuantity,
|
||||||
|
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||||
|
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||||
|
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||||
|
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||||
|
InvoiceNo = "日结存"
|
||||||
|
}).ExecuteCommand();
|
||||||
|
if (iDayResult <= 0)
|
||||||
|
{
|
||||||
|
logger.Info($"未写入日结存数据{it.DrugId}-{it.ManuNo}-{it.EffDate}-{it.AddQuantity}");
|
||||||
|
}
|
||||||
|
}
|
||||||
//修改凌晨生成的总结存数据
|
//修改凌晨生成的总结存数据
|
||||||
AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
||||||
.Where(ab => ab.MachineId.Equals(it.MachineId))
|
.Where(ab => ab.MachineId.Equals(it.MachineId))
|
||||||
.Where(ab => ab.Type == 4)
|
.Where(ab => ab.Type == 4)
|
||||||
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
||||||
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||||
|
if (accountBookG2Total != null)
|
||||||
|
{
|
||||||
accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - it.TakeQuantity;
|
accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - it.TakeQuantity;
|
||||||
|
|
||||||
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
|
|
||||||
|
|
||||||
SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
|
SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//生成总结存时可能没有该库位的绑定信息,需要写入总结存
|
||||||
|
int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||||
|
{
|
||||||
|
DrugId = Convert.ToInt32(it.DrugId),
|
||||||
|
Type = 4,
|
||||||
|
YQuantity = 0,
|
||||||
|
ManuStock = it.TakeQuantity,
|
||||||
|
TotalStock = it.TakeQuantity,
|
||||||
|
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||||
|
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||||
|
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||||
|
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||||
|
InvoiceNo = "总结存"
|
||||||
|
}).ExecuteCommand();
|
||||||
|
if (iTotalResult <= 0)
|
||||||
|
{
|
||||||
|
logger.Info($"未写入总结存数据{it.DrugId}-{it.AddQuantity}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -362,21 +362,67 @@ namespace DM_Weight.ViewModels
|
||||||
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
||||||
.Where(ab => ab.ManuNo == it.ManuNo)
|
.Where(ab => ab.ManuNo == it.ManuNo)
|
||||||
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||||
|
if (accountBookG2Day != null)
|
||||||
|
{
|
||||||
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + it.ReturnQuantity;
|
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + it.ReturnQuantity;
|
||||||
|
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//生成日结存时可能没有该库位的绑定信息,需要写入日结存
|
||||||
|
int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||||
|
{
|
||||||
|
DrugId = Convert.ToInt32(it.DrugId),
|
||||||
|
Type = 3,
|
||||||
|
ManuNo = it.ManuNo,
|
||||||
|
EffDate = it.EffDate,
|
||||||
|
YQuantity = 0,
|
||||||
|
ManuStock = it.ReturnQuantity,
|
||||||
|
TotalStock = it.ReturnQuantity,
|
||||||
|
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||||
|
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||||
|
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||||
|
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||||
|
InvoiceNo = "日结存"
|
||||||
|
}).ExecuteCommand();
|
||||||
|
if (iDayResult <= 0)
|
||||||
|
{
|
||||||
|
logger.Info($"未写入日结存数据{it.DrugId}-{it.ManuNo}-{it.EffDate}-{it.AddQuantity}");
|
||||||
|
}
|
||||||
|
}
|
||||||
//修改凌晨生成的总结存数据
|
//修改凌晨生成的总结存数据
|
||||||
AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
||||||
.Where(ab => ab.MachineId.Equals(it.MachineId))
|
.Where(ab => ab.MachineId.Equals(it.MachineId))
|
||||||
.Where(ab => ab.Type == 4)
|
.Where(ab => ab.Type == 4)
|
||||||
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
||||||
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||||
|
if (accountBookG2Total != null)
|
||||||
|
{
|
||||||
accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + it.ReturnQuantity;
|
accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + it.ReturnQuantity;
|
||||||
|
|
||||||
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
|
|
||||||
|
|
||||||
SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
|
SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//生成总结存时可能没有该库位的绑定信息,需要写入总结存
|
||||||
|
int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||||
|
{
|
||||||
|
DrugId = Convert.ToInt32(it.DrugId),
|
||||||
|
Type = 4,
|
||||||
|
YQuantity = 0,
|
||||||
|
ManuStock = it.ReturnQuantity,
|
||||||
|
TotalStock = it.ReturnQuantity,
|
||||||
|
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||||
|
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||||
|
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||||
|
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||||
|
InvoiceNo = "总结存"
|
||||||
|
}).ExecuteCommand();
|
||||||
|
if (iTotalResult <= 0)
|
||||||
|
{
|
||||||
|
logger.Info($"未写入总结存数据{it.DrugId}-{it.AddQuantity}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
if (f.Data)
|
if (f.Data)
|
||||||
|
|
|
@ -361,44 +361,90 @@ namespace DM_Weight.ViewModels
|
||||||
}).ExecuteCommand();
|
}).ExecuteCommand();
|
||||||
|
|
||||||
//保存账册
|
//保存账册
|
||||||
int iInsertResult= SqlSugarHelper.Db.Insertable(new AccountBookG2() {
|
int iInsertResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||||
|
{
|
||||||
DrugId = Convert.ToInt32(it.DrugId),
|
DrugId = Convert.ToInt32(it.DrugId),
|
||||||
Type= 2,
|
Type = 2,
|
||||||
Department= OrderInfo.DeptName,
|
Department = OrderInfo.DeptName,
|
||||||
OrderNo=OrderInfo.OrderNo,
|
OrderNo = OrderInfo.OrderNo,
|
||||||
ManuNo=it.ManuNo,
|
ManuNo = it.ManuNo,
|
||||||
EffDate=it.EffDate,
|
EffDate = it.EffDate,
|
||||||
OutQuantity=it.TakeQuantity,
|
OutQuantity = it.TakeQuantity,
|
||||||
UserId1 = HomeWindowViewModel.Operator?.Id,
|
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||||
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,
|
||||||
InvoiceNo=OrderInfo.OrderNo
|
InvoiceNo = OrderInfo.OrderNo
|
||||||
|
|
||||||
}).ExecuteCommand();
|
}).ExecuteCommand();
|
||||||
//修改凌晨生成的日结存与总结存数据
|
//修改凌晨生成的日结存与总结存数据
|
||||||
AccountBookG2 accountBookG2Day= SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
||||||
.Where(ab=>ab.MachineId.Equals(it.MachineId))
|
.Where(ab => ab.MachineId.Equals(it.MachineId))
|
||||||
.Where(ab=>ab.Type==3)
|
.Where(ab => ab.Type == 3)
|
||||||
.Where(ab=>ab.DrugId==Convert.ToInt32(it.DrugId))
|
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
||||||
.Where(ab=>ab.ManuNo==it.ManuNo)
|
.Where(ab => ab.ManuNo == it.ManuNo)
|
||||||
.Where(ab=>ab.CreateDate==DateTime.Now.ToString("yyyy-MM-dd")).First();
|
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||||
|
if (accountBookG2Day != null)
|
||||||
|
{
|
||||||
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - it.TakeQuantity;
|
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - it.TakeQuantity;
|
||||||
|
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//生成日结存时可能没有该库位的绑定信息,需要写入日结存
|
||||||
|
int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||||
|
{
|
||||||
|
DrugId = Convert.ToInt32(it.DrugId),
|
||||||
|
Type = 3,
|
||||||
|
ManuNo = it.ManuNo,
|
||||||
|
EffDate = it.EffDate,
|
||||||
|
YQuantity = 0,
|
||||||
|
ManuStock = it.TakeQuantity,
|
||||||
|
TotalStock = it.TakeQuantity,
|
||||||
|
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||||
|
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||||
|
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||||
|
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||||
|
InvoiceNo = "日结存"
|
||||||
|
}).ExecuteCommand();
|
||||||
|
if(iDayResult<=0)
|
||||||
|
{
|
||||||
|
logger.Info($"未写入日结存数据{it.DrugId}-{it.ManuNo}-{it.EffDate}-{it.AddQuantity}");
|
||||||
|
}
|
||||||
|
}
|
||||||
//修改凌晨生成的日结存与总结存数据
|
//修改凌晨生成的日结存与总结存数据
|
||||||
AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
||||||
.Where(ab => ab.MachineId.Equals(it.MachineId))
|
.Where(ab => ab.MachineId.Equals(it.MachineId))
|
||||||
.Where(ab => ab.Type == 4)
|
.Where(ab => ab.Type == 4)
|
||||||
.Where(ab=>ab.DrugId==Convert.ToInt32(it.DrugId))
|
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
||||||
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||||
|
if (accountBookG2Total != null)
|
||||||
accountBookG2Total.TotalStock= accountBookG2Total.TotalStock -it.TakeQuantity;
|
{
|
||||||
|
accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - it.TakeQuantity;
|
||||||
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
|
|
||||||
|
|
||||||
SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
|
SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//生成总结存时可能没有该库位的绑定信息,需要写入总结存
|
||||||
|
int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||||
|
{
|
||||||
|
DrugId = Convert.ToInt32(it.DrugId),
|
||||||
|
Type = 4,
|
||||||
|
YQuantity = 0,
|
||||||
|
ManuStock = it.TakeQuantity,
|
||||||
|
TotalStock = it.TakeQuantity,
|
||||||
|
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||||
|
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||||
|
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||||
|
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||||
|
InvoiceNo = "总结存"
|
||||||
|
}).ExecuteCommand();
|
||||||
|
if (iTotalResult <= 0)
|
||||||
|
{
|
||||||
|
logger.Info($"未写入总结存数据{it.DrugId}-{it.AddQuantity}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -422,7 +468,7 @@ namespace DM_Weight.ViewModels
|
||||||
};
|
};
|
||||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||||
}
|
}
|
||||||
if(!f.IsSuccess)
|
if (!f.IsSuccess)
|
||||||
{
|
{
|
||||||
AlertMsg alertMsg = new AlertMsg
|
AlertMsg alertMsg = new AlertMsg
|
||||||
{
|
{
|
||||||
|
|
|
@ -176,12 +176,12 @@ namespace DM_Weight.ViewModels
|
||||||
List<ChannelStock> queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
List<ChannelStock> queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||||
.Where(cs => cs.DrugId == MachineRecord.DrugId)
|
.Where(cs => cs.DrugId == MachineRecord.DrugId)
|
||||||
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
|
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
|
||||||
.WhereIF(MachineRecord.ManuNo != null,cs => cs.ManuNo == MachineRecord.ManuNo)
|
.WhereIF(MachineRecord.ManuNo != null, cs => cs.ManuNo == MachineRecord.ManuNo)
|
||||||
.OrderBy(cs => cs.DrawerNo)
|
.OrderBy(cs => cs.DrawerNo)
|
||||||
.OrderBy(cs => cs.ColNo)
|
.OrderBy(cs => cs.ColNo)
|
||||||
.ToList();
|
.ToList();
|
||||||
ChannelStocks = queryData;
|
ChannelStocks = queryData;
|
||||||
if(ChannelStocks.Count > 0)
|
if (ChannelStocks.Count > 0)
|
||||||
{
|
{
|
||||||
ChannelStock = ChannelStocks[0];
|
ChannelStock = ChannelStocks[0];
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,8 @@ namespace DM_Weight.ViewModels
|
||||||
_portUtil.ColNos = new int[] { ChannelStock.ColNo };
|
_portUtil.ColNos = new int[] { ChannelStock.ColNo };
|
||||||
_portUtil.DrawerNo = ChannelStock.DrawerNo;
|
_portUtil.DrawerNo = ChannelStock.DrawerNo;
|
||||||
_portUtil.Start();
|
_portUtil.Start();
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
AlertMsg alertMsg = new AlertMsg
|
AlertMsg alertMsg = new AlertMsg
|
||||||
{
|
{
|
||||||
|
@ -292,21 +293,66 @@ namespace DM_Weight.ViewModels
|
||||||
.Where(ab => ab.DrugId == Convert.ToInt32(ChannelStock.DrugId))
|
.Where(ab => ab.DrugId == Convert.ToInt32(ChannelStock.DrugId))
|
||||||
.Where(ab => ab.ManuNo == ChannelStock.ManuNo)
|
.Where(ab => ab.ManuNo == ChannelStock.ManuNo)
|
||||||
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||||
|
if (accountBookG2Day != null)
|
||||||
|
{
|
||||||
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + ChannelStock.ReturnQuantity;
|
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + ChannelStock.ReturnQuantity;
|
||||||
|
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//生成日结存时可能没有该库位的绑定信息,需要写入日结存
|
||||||
|
int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||||
|
{
|
||||||
|
DrugId = Convert.ToInt32(ChannelStock.DrugId),
|
||||||
|
Type = 3,
|
||||||
|
ManuNo = ChannelStock.ManuNo,
|
||||||
|
EffDate = ChannelStock.EffDate,
|
||||||
|
YQuantity = 0,
|
||||||
|
ManuStock = ChannelStock.ReturnQuantity,
|
||||||
|
TotalStock = ChannelStock.ReturnQuantity,
|
||||||
|
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||||
|
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||||
|
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||||
|
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||||
|
InvoiceNo = "日结存"
|
||||||
|
}).ExecuteCommand();
|
||||||
|
if (iDayResult <= 0)
|
||||||
|
{
|
||||||
|
logger.Info($"未写入日结存数据{ChannelStock.DrugId}-{ChannelStock.ManuNo}-{ChannelStock.EffDate}-{ChannelStock.AddQuantity}");
|
||||||
|
}
|
||||||
|
}
|
||||||
//修改凌晨生成的总结存数据
|
//修改凌晨生成的总结存数据
|
||||||
AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
||||||
.Where(ab => ab.MachineId.Equals(ChannelStock.MachineId))
|
.Where(ab => ab.MachineId.Equals(ChannelStock.MachineId))
|
||||||
.Where(ab => ab.Type == 4)
|
.Where(ab => ab.Type == 4)
|
||||||
.Where(ab => ab.DrugId == Convert.ToInt32(ChannelStock.DrugId))
|
.Where(ab => ab.DrugId == Convert.ToInt32(ChannelStock.DrugId))
|
||||||
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||||
|
if (accountBookG2Total != null)
|
||||||
|
{
|
||||||
accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + ChannelStock.ReturnQuantity;
|
accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + ChannelStock.ReturnQuantity;
|
||||||
|
|
||||||
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
|
|
||||||
|
|
||||||
SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
|
SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//生成总结存时可能没有该库位的绑定信息,需要写入总结存
|
||||||
|
int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||||
|
{
|
||||||
|
DrugId = Convert.ToInt32(ChannelStock.DrugId),
|
||||||
|
Type = 4,
|
||||||
|
YQuantity = 0,
|
||||||
|
ManuStock = ChannelStock.ReturnQuantity,
|
||||||
|
TotalStock = ChannelStock.ReturnQuantity,
|
||||||
|
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||||
|
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||||
|
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||||
|
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||||
|
InvoiceNo = "总结存"
|
||||||
|
}).ExecuteCommand();
|
||||||
|
if (iTotalResult <= 0)
|
||||||
|
{
|
||||||
|
logger.Info($"未写入总结存数据{ChannelStock.DrugId}-{ChannelStock.AddQuantity}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -192,7 +192,7 @@ namespace DM_Weight.ViewModels
|
||||||
_portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
|
_portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
|
||||||
_portUtil.DrawerNo = DrawerNo;
|
_portUtil.DrawerNo = DrawerNo;
|
||||||
|
|
||||||
if((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
|
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
|
||||||
{
|
{
|
||||||
// 发送加药数量
|
// 发送加药数量
|
||||||
singleChannels.ForEach(it =>
|
singleChannels.ForEach(it =>
|
||||||
|
@ -203,7 +203,7 @@ namespace DM_Weight.ViewModels
|
||||||
|
|
||||||
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 6)
|
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 6)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < singleChannels.Count; i++)
|
for (int i = 0; i < singleChannels.Count; i++)
|
||||||
{
|
{
|
||||||
ChannelStock it = singleChannels[i];
|
ChannelStock it = singleChannels[i];
|
||||||
_portUtil.ClearCount(it.DrawerNo, it.ColNo);
|
_portUtil.ClearCount(it.DrawerNo, it.ColNo);
|
||||||
|
@ -293,20 +293,68 @@ namespace DM_Weight.ViewModels
|
||||||
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
||||||
.Where(ab => ab.ManuNo == it.ManuNo)
|
.Where(ab => ab.ManuNo == it.ManuNo)
|
||||||
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||||
|
if (accountBookG2Day != null)
|
||||||
|
{
|
||||||
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + it.AddQuantity;
|
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + it.AddQuantity;
|
||||||
|
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//生成日结存时可能没有该库位的绑定信息,需要写入日结存
|
||||||
|
int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||||
|
{
|
||||||
|
DrugId = Convert.ToInt32(it.DrugId),
|
||||||
|
Type = 3,
|
||||||
|
ManuNo = it.ManuNo,
|
||||||
|
EffDate = it.EffDate,
|
||||||
|
YQuantity = 0,
|
||||||
|
ManuStock = it.AddQuantity,
|
||||||
|
TotalStock = it.AddQuantity,
|
||||||
|
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||||
|
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||||
|
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||||
|
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||||
|
InvoiceNo = "日结存"
|
||||||
|
}).ExecuteCommand();
|
||||||
|
if (iDayResult <= 0)
|
||||||
|
{
|
||||||
|
logger.Info($"未写入日结存数据{it.DrugId}-{it.ManuNo}-{it.EffDate}-{it.AddQuantity}");
|
||||||
|
}
|
||||||
|
}
|
||||||
//修改凌晨生成的总结存数据
|
//修改凌晨生成的总结存数据
|
||||||
AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
||||||
.Where(ab => ab.MachineId.Equals(it.MachineId))
|
.Where(ab => ab.MachineId.Equals(it.MachineId))
|
||||||
.Where(ab => ab.Type == 4)
|
.Where(ab => ab.Type == 4)
|
||||||
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
||||||
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||||
|
if (accountBookG2Total != null)
|
||||||
|
{
|
||||||
accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + it.AddQuantity;
|
accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + it.AddQuantity;
|
||||||
|
|
||||||
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
|
|
||||||
|
|
||||||
SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
|
SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//生成总结存时可能没有该库位的绑定信息,需要写入总结存
|
||||||
|
int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||||
|
{
|
||||||
|
DrugId = Convert.ToInt32(it.DrugId),
|
||||||
|
Type = 4,
|
||||||
|
YQuantity = 0,
|
||||||
|
ManuStock = it.AddQuantity,
|
||||||
|
TotalStock = it.AddQuantity,
|
||||||
|
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||||
|
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||||
|
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||||
|
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||||
|
InvoiceNo = "总结存"
|
||||||
|
}).ExecuteCommand();
|
||||||
|
if (iTotalResult <= 0)
|
||||||
|
{
|
||||||
|
logger.Info($"未写入总结存数据{it.DrugId}-{it.AddQuantity}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -270,21 +270,67 @@ namespace DM_Weight.ViewModels
|
||||||
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
||||||
.Where(ab => ab.ManuNo == it.ManuNo)
|
.Where(ab => ab.ManuNo == it.ManuNo)
|
||||||
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||||
|
if (accountBookG2Day != null)
|
||||||
|
{
|
||||||
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - it.TakeQuantity;
|
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - it.TakeQuantity;
|
||||||
|
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//生成日结存时可能没有该库位的绑定信息,需要写入日结存
|
||||||
|
int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||||
|
{
|
||||||
|
DrugId = Convert.ToInt32(it.DrugId),
|
||||||
|
Type = 3,
|
||||||
|
ManuNo = it.ManuNo,
|
||||||
|
EffDate = it.EffDate,
|
||||||
|
YQuantity = 0,
|
||||||
|
ManuStock = it.TakeQuantity,
|
||||||
|
TotalStock = it.TakeQuantity,
|
||||||
|
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||||
|
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||||
|
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||||
|
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||||
|
InvoiceNo = "日结存"
|
||||||
|
}).ExecuteCommand();
|
||||||
|
if (iDayResult <= 0)
|
||||||
|
{
|
||||||
|
logger.Info($"未写入日结存数据{it.DrugId}-{it.ManuNo}-{it.EffDate}-{it.AddQuantity}");
|
||||||
|
}
|
||||||
|
}
|
||||||
//修改凌晨生成的总结存数据
|
//修改凌晨生成的总结存数据
|
||||||
AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
||||||
.Where(ab => ab.MachineId.Equals(it.MachineId))
|
.Where(ab => ab.MachineId.Equals(it.MachineId))
|
||||||
.Where(ab => ab.Type == 4)
|
.Where(ab => ab.Type == 4)
|
||||||
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
.Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
|
||||||
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||||
|
if (accountBookG2Total != null)
|
||||||
|
{
|
||||||
accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - it.TakeQuantity;
|
accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - it.TakeQuantity;
|
||||||
|
|
||||||
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
|
|
||||||
|
|
||||||
SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
|
SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//生成总结存时可能没有该库位的绑定信息,需要写入总结存
|
||||||
|
int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||||
|
{
|
||||||
|
DrugId = Convert.ToInt32(it.DrugId),
|
||||||
|
Type = 4,
|
||||||
|
YQuantity = 0,
|
||||||
|
ManuStock = it.TakeQuantity,
|
||||||
|
TotalStock = it.TakeQuantity,
|
||||||
|
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||||
|
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||||
|
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||||
|
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||||
|
InvoiceNo = "总结存"
|
||||||
|
}).ExecuteCommand();
|
||||||
|
if (iTotalResult <= 0)
|
||||||
|
{
|
||||||
|
logger.Info($"未写入总结存数据{it.DrugId}-{it.AddQuantity}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
if (f.Data)
|
if (f.Data)
|
||||||
|
|
Loading…
Reference in New Issue