更新核对时出库账册的批次库存数
This commit is contained in:
		
							parent
							
								
									500974a947
								
							
						
					
					
						commit
						d8d08559f3
					
				| 
						 | 
					@ -523,8 +523,6 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                            .Where(it => it.ManuNo.Equals(cs.ManuNo))
 | 
					                            .Where(it => it.ManuNo.Equals(cs.ManuNo))
 | 
				
			||||||
                            .Where(it => it.DrawerType == 1)
 | 
					                            .Where(it => it.DrawerType == 1)
 | 
				
			||||||
                            .ToList();
 | 
					                            .ToList();
 | 
				
			||||||
                        if (cs != null)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
					                        SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
| 
						 | 
					@ -578,32 +576,6 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                        #endregion
 | 
					                        #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        //}
 | 
					                        //}
 | 
				
			||||||
                            //查询上一条账册中的空瓶数
 | 
					 | 
				
			||||||
                            AccountBookG2 accountBookEmpty = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
					 | 
				
			||||||
                            .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["dm_machineId"].ToString()))
 | 
					 | 
				
			||||||
                            .Where(ab => ab.Type == 1 || ab.Type == 2)
 | 
					 | 
				
			||||||
                            .Where(ab => ab.DrugId == oi._OrderDetail.DrugId)
 | 
					 | 
				
			||||||
                            .Where(ab => ab.ManuNo == cs.ManuNo).OrderByDescending(ab =>  ab.Id).First();
 | 
					 | 
				
			||||||
                            //保存账册
 | 
					 | 
				
			||||||
                            int iInsertResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                DrugId = oi._OrderDetail.DrugId,
 | 
					 | 
				
			||||||
                                Type = 2,
 | 
					 | 
				
			||||||
                                Department = oi.DeptName,
 | 
					 | 
				
			||||||
                                OrderNo = oi.OrderNo,
 | 
					 | 
				
			||||||
                                ManuNo = cs.ManuNo,
 | 
					 | 
				
			||||||
                                EffDate = cs.EffDate,
 | 
					 | 
				
			||||||
                                OutQuantity = oi._OrderDetail.Quantity,
 | 
					 | 
				
			||||||
                                UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
					 | 
				
			||||||
                                UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
					 | 
				
			||||||
                                MachineId = ConfigurationManager.AppSettings["dm_machineId"].ToString(),
 | 
					 | 
				
			||||||
                                CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
					 | 
				
			||||||
                                CreateTime = DateTime.Now,
 | 
					 | 
				
			||||||
                                InvoiceNo = oi.OrderNo,
 | 
					 | 
				
			||||||
                                ManuStock = nowChannels.Sum(it => it.Quantity),
 | 
					 | 
				
			||||||
                                TotalStock = (accountBookEmpty != null ? (accountBookEmpty.TotalStock > 0 ? accountBookEmpty.TotalStock : 0) : 0) + oi._OrderDetail.Quantity,
 | 
					 | 
				
			||||||
                                ShoushuJian= drawerNo.ToString()
 | 
					 | 
				
			||||||
                            }).ExecuteCommand();
 | 
					 | 
				
			||||||
                        //修改凌晨生成的日结存与总结存数据
 | 
					                        //修改凌晨生成的日结存与总结存数据
 | 
				
			||||||
                        AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
					                        AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
				
			||||||
                        .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["dm_machineId"].ToString()))
 | 
					                        .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["dm_machineId"].ToString()))
 | 
				
			||||||
| 
						 | 
					@ -611,11 +583,13 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                        .Where(ab => ab.DrugId == oi._OrderDetail.DrugId)
 | 
					                        .Where(ab => ab.DrugId == oi._OrderDetail.DrugId)
 | 
				
			||||||
                        .Where(ab => ab.ManuNo == cs.ManuNo)
 | 
					                        .Where(ab => ab.ManuNo == cs.ManuNo)
 | 
				
			||||||
                        .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
					                        .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
				
			||||||
 | 
					                        int manuStock = 0;
 | 
				
			||||||
                        if (accountBookG2Day != null)
 | 
					                        if (accountBookG2Day != null)
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - oi._OrderDetail.Quantity;
 | 
					                            accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - oi._OrderDetail.Quantity;
 | 
				
			||||||
                            accountBookG2Day.OutQuantity = accountBookG2Day.OutQuantity + oi._OrderDetail.Quantity;
 | 
					                            accountBookG2Day.OutQuantity = accountBookG2Day.OutQuantity + oi._OrderDetail.Quantity;
 | 
				
			||||||
                            SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
 | 
					                            SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
 | 
				
			||||||
 | 
					                            manuStock = accountBookG2Day.ManuStock;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        else
 | 
					                        else
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
| 
						 | 
					@ -642,6 +616,32 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                                logger.Info($"未写入日结存数据{oi._OrderDetail.DrugId}-{cs.ManuNo}-{cs.EffDate}-{cs.Quantity}");
 | 
					                                logger.Info($"未写入日结存数据{oi._OrderDetail.DrugId}-{cs.ManuNo}-{cs.EffDate}-{cs.Quantity}");
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					                        //查询上一条账册中的空瓶数
 | 
				
			||||||
 | 
					                        AccountBookG2 accountBookEmpty = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
				
			||||||
 | 
					                        .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["dm_machineId"].ToString()))
 | 
				
			||||||
 | 
					                        .Where(ab => ab.Type == 1 || ab.Type == 2)
 | 
				
			||||||
 | 
					                        .Where(ab => ab.DrugId == oi._OrderDetail.DrugId)
 | 
				
			||||||
 | 
					                        .Where(ab => ab.ManuNo == cs.ManuNo).OrderByDescending(ab => ab.Id).First();
 | 
				
			||||||
 | 
					                        //保存账册
 | 
				
			||||||
 | 
					                        int iInsertResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            DrugId = oi._OrderDetail.DrugId,
 | 
				
			||||||
 | 
					                            Type = 2,
 | 
				
			||||||
 | 
					                            Department = oi.DeptName,
 | 
				
			||||||
 | 
					                            OrderNo = oi.OrderNo,
 | 
				
			||||||
 | 
					                            ManuNo = cs.ManuNo,
 | 
				
			||||||
 | 
					                            EffDate = cs.EffDate,
 | 
				
			||||||
 | 
					                            OutQuantity = oi._OrderDetail.Quantity,
 | 
				
			||||||
 | 
					                            UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                            UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
				
			||||||
 | 
					                            MachineId = ConfigurationManager.AppSettings["dm_machineId"].ToString(),
 | 
				
			||||||
 | 
					                            CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
				
			||||||
 | 
					                            CreateTime = DateTime.Now,
 | 
				
			||||||
 | 
					                            InvoiceNo = oi.OrderNo,
 | 
				
			||||||
 | 
					                            ManuStock = manuStock > 0 ? manuStock : nowChannels.Sum(it => it.Quantity),
 | 
				
			||||||
 | 
					                            TotalStock = (accountBookEmpty != null ? (accountBookEmpty.TotalStock > 0 ? accountBookEmpty.TotalStock : 0) : 0) + oi._OrderDetail.Quantity,
 | 
				
			||||||
 | 
					                            ShoushuJian = drawerNo.ToString()
 | 
				
			||||||
 | 
					                        }).ExecuteCommand();
 | 
				
			||||||
                        //修改凌晨生成的日结存与总结存数据
 | 
					                        //修改凌晨生成的日结存与总结存数据
 | 
				
			||||||
                        AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
					                        AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
				
			||||||
                        .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["dm_machineId"].ToString()))
 | 
					                        .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["dm_machineId"].ToString()))
 | 
				
			||||||
| 
						 | 
					@ -675,8 +675,6 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                                logger.Info($"未写入总结存数据{oi._OrderDetail.DrugId}-{oi._OrderDetail.Quantity}");
 | 
					                                logger.Info($"未写入总结存数据{oi._OrderDetail.DrugId}-{oi._OrderDetail.Quantity}");
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    if (!string.IsNullOrEmpty(empChannelStock))
 | 
					                    if (!string.IsNullOrEmpty(empChannelStock))
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue