修改凌晨生成的总结存数据时,如果没有数据则写入一条。(凌晨生成数据时没有绑定库位的则不会生成,当天绑定库位且做库位操作时需要手动写入一条日结存、总结存数据)
This commit is contained in:
		
							parent
							
								
									091be0ac37
								
							
						
					
					
						commit
						948f91212c
					
				| 
						 | 
				
			
			@ -673,22 +673,67 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
                        .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                        .Where(ab => ab.ManuNo == it.ManuNo)
 | 
			
		||||
                        .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
 | 
			
		||||
                        if (accountBookG2Day != null)
 | 
			
		||||
                        {
 | 
			
		||||
                            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>()
 | 
			
		||||
                        .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
                        .Where(ab => ab.Type == 4)
 | 
			
		||||
                        .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                        .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
 | 
			
		||||
                        if (accountBookG2Total != null)
 | 
			
		||||
                        {
 | 
			
		||||
                            accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + it.AddQuantity;
 | 
			
		||||
 | 
			
		||||
                        SqlSugarHelper.Db.Updateable(accountBookG2Day).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;
 | 
			
		||||
                });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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("DrugBarcode"), (cd) => cd.drugInfo.DrugBarcode.Contains(SearchValue))
 | 
			
		||||
                           .WhereIF((_DrugPleaseState != null && _DrugPleaseState.StateValue >= 0), (cd, dp) => dp.State == _DrugPleaseState.StateValue)
 | 
			
		||||
                           .GroupBy(cd => cd.Applyid)
 | 
			
		||||
                           .OrderByDescending(cd => cd.Createdate)
 | 
			
		||||
                           .OrderByDescending(cd => cd.DrugId)
 | 
			
		||||
                           .ToList();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -195,6 +195,16 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
                        Message = "请选择要销毁的数据",
 | 
			
		||||
                        Type = MsgType.ERROR,
 | 
			
		||||
                    };
 | 
			
		||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -231,21 +231,67 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
                                .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                                .Where(ab => ab.ManuNo == it.ManuNo)
 | 
			
		||||
                                .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                                if (accountBookG2Day != null)
 | 
			
		||||
                                {
 | 
			
		||||
                                    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>()
 | 
			
		||||
                                .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
                                .Where(ab => ab.Type == 4)
 | 
			
		||||
                                .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                                .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
 | 
			
		||||
                                if (accountBookG2Total != null)
 | 
			
		||||
                                {
 | 
			
		||||
                                    accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + it.AddQuantity;
 | 
			
		||||
 | 
			
		||||
                                SqlSugarHelper.Db.Updateable(accountBookG2Day).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;
 | 
			
		||||
                        });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -233,20 +233,66 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
                                .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                                .Where(ab => ab.ManuNo == it.ManuNo)
 | 
			
		||||
                                .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                                if (accountBookG2Day != null)
 | 
			
		||||
                                {
 | 
			
		||||
                                    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>()
 | 
			
		||||
                                .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
                                .Where(ab => ab.Type == 4)
 | 
			
		||||
                                .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                                .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
 | 
			
		||||
                                if (accountBookG2Total != null)
 | 
			
		||||
                                {
 | 
			
		||||
                                    accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - it.TakeQuantity;
 | 
			
		||||
 | 
			
		||||
                                SqlSugarHelper.Db.Updateable(accountBookG2Day).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}");
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -304,21 +304,67 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
                            .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                            .Where(ab => ab.ManuNo == it.ManuNo)
 | 
			
		||||
                            .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                            if (accountBookG2Day != null)
 | 
			
		||||
                            {
 | 
			
		||||
                                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>()
 | 
			
		||||
                            .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
                            .Where(ab => ab.Type == 4)
 | 
			
		||||
                            .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                            .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
 | 
			
		||||
                            if (accountBookG2Total != null)
 | 
			
		||||
                            {
 | 
			
		||||
                                accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + it.AddQuantity;
 | 
			
		||||
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(accountBookG2Day).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;
 | 
			
		||||
                    });
 | 
			
		||||
                    if (f.Data)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -367,21 +367,66 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
                                .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                                .Where(ab => ab.ManuNo == it.ManuNo)
 | 
			
		||||
                                .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                                if (accountBookG2Day != null)
 | 
			
		||||
                                {
 | 
			
		||||
                                    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>()
 | 
			
		||||
                                .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
                                .Where(ab => ab.Type == 4)
 | 
			
		||||
                                .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                                .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
 | 
			
		||||
                                if (accountBookG2Total != null)
 | 
			
		||||
                                {
 | 
			
		||||
                                    accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - it.TakeQuantity;
 | 
			
		||||
 | 
			
		||||
                                SqlSugarHelper.Db.Updateable(accountBookG2Day).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;
 | 
			
		||||
                        });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -362,21 +362,67 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
                            .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                            .Where(ab => ab.ManuNo == it.ManuNo)
 | 
			
		||||
                            .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                            if (accountBookG2Day != null)
 | 
			
		||||
                            {
 | 
			
		||||
                                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>()
 | 
			
		||||
                            .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
                            .Where(ab => ab.Type == 4)
 | 
			
		||||
                            .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                            .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
 | 
			
		||||
                            if (accountBookG2Total != null)
 | 
			
		||||
                            {
 | 
			
		||||
                                accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + it.ReturnQuantity;
 | 
			
		||||
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(accountBookG2Day).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;
 | 
			
		||||
                    });
 | 
			
		||||
                    if (f.Data)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -384,22 +384,66 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
                                .Where(ab=>ab.DrugId==Convert.ToInt32(it.DrugId))
 | 
			
		||||
                                .Where(ab=>ab.ManuNo==it.ManuNo)
 | 
			
		||||
                                .Where(ab=>ab.CreateDate==DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
 | 
			
		||||
                                if (accountBookG2Day != null)
 | 
			
		||||
                                {
 | 
			
		||||
                                    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>()
 | 
			
		||||
                                .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
                                .Where(ab => ab.Type == 4)
 | 
			
		||||
                                .Where(ab=>ab.DrugId==Convert.ToInt32(it.DrugId))
 | 
			
		||||
                                .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
 | 
			
		||||
                                if (accountBookG2Total != null)
 | 
			
		||||
                                {
 | 
			
		||||
                                    accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - it.TakeQuantity;
 | 
			
		||||
 | 
			
		||||
                                SqlSugarHelper.Db.Updateable(accountBookG2Day).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;
 | 
			
		||||
                        });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -202,7 +202,8 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
                    _portUtil.ColNos = new int[] { ChannelStock.ColNo };
 | 
			
		||||
                    _portUtil.DrawerNo = ChannelStock.DrawerNo;
 | 
			
		||||
                    _portUtil.Start();
 | 
			
		||||
                } else
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    AlertMsg alertMsg = new AlertMsg
 | 
			
		||||
                    {
 | 
			
		||||
| 
						 | 
				
			
			@ -292,20 +293,66 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
                    .Where(ab => ab.DrugId == Convert.ToInt32(ChannelStock.DrugId))
 | 
			
		||||
                    .Where(ab => ab.ManuNo == ChannelStock.ManuNo)
 | 
			
		||||
                    .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                    if (accountBookG2Day != null)
 | 
			
		||||
                    {
 | 
			
		||||
                        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>()
 | 
			
		||||
                    .Where(ab => ab.MachineId.Equals(ChannelStock.MachineId))
 | 
			
		||||
                    .Where(ab => ab.Type == 4)
 | 
			
		||||
                    .Where(ab => ab.DrugId == Convert.ToInt32(ChannelStock.DrugId))
 | 
			
		||||
                    .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
 | 
			
		||||
                    if (accountBookG2Total != null)
 | 
			
		||||
                    {
 | 
			
		||||
                        accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + ChannelStock.ReturnQuantity;
 | 
			
		||||
 | 
			
		||||
                    SqlSugarHelper.Db.Updateable(accountBookG2Day).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}");
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -293,8 +293,35 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
                            .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                            .Where(ab => ab.ManuNo == it.ManuNo)
 | 
			
		||||
                            .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                            if (accountBookG2Day != null)
 | 
			
		||||
                            {
 | 
			
		||||
                                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>()
 | 
			
		||||
                            .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
| 
						 | 
				
			
			@ -302,11 +329,32 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
                            .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                            .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
 | 
			
		||||
                            if (accountBookG2Total != null)
 | 
			
		||||
                            {
 | 
			
		||||
                                accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + it.AddQuantity;
 | 
			
		||||
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(accountBookG2Day).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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -270,8 +270,35 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
                            .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                            .Where(ab => ab.ManuNo == it.ManuNo)
 | 
			
		||||
                            .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
                            if (accountBookG2Day != null)
 | 
			
		||||
                            {
 | 
			
		||||
                                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>()
 | 
			
		||||
                            .Where(ab => ab.MachineId.Equals(it.MachineId))
 | 
			
		||||
| 
						 | 
				
			
			@ -279,12 +306,33 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
                            .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId))
 | 
			
		||||
                            .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
			
		||||
 | 
			
		||||
                            if (accountBookG2Total != null)
 | 
			
		||||
                            {
 | 
			
		||||
                                accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - it.TakeQuantity;
 | 
			
		||||
 | 
			
		||||
                            SqlSugarHelper.Db.Updateable(accountBookG2Day).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;
 | 
			
		||||
                    });
 | 
			
		||||
                    if (f.Data)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue