更新核对时出库账册的批次库存数
This commit is contained in:
		
							parent
							
								
									500974a947
								
							
						
					
					
						commit
						d8d08559f3
					
				| 
						 | 
					@ -511,7 +511,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                            continue;
 | 
					                            continue;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        cs.Quantity = cs.Quantity - oi._OrderDetail.Quantity;
 | 
					                        cs.Quantity = cs.Quantity - oi._OrderDetail.Quantity;
 | 
				
			||||||
                        cs.NeedNum = cs.NeedNum>0? cs.NeedNum + oi._OrderDetail.Quantity: oi._OrderDetail.Quantity;
 | 
					                        cs.NeedNum = cs.NeedNum > 0 ? cs.NeedNum + oi._OrderDetail.Quantity : oi._OrderDetail.Quantity;
 | 
				
			||||||
                        logger.Info($"更新手术间{cs.DrawerNo}药品{cs.DrugId}批次{cs.ManuNo}库存为{cs.Quantity},需补药数量为{cs.NeedNum}");
 | 
					                        logger.Info($"更新手术间{cs.DrawerNo}药品{cs.DrugId}批次{cs.ManuNo}库存为{cs.Quantity},需补药数量为{cs.NeedNum}");
 | 
				
			||||||
                        // 更新数据 库存信息
 | 
					                        // 更新数据 库存信息
 | 
				
			||||||
                        SqlSugarHelper.Db.Updateable(cs).UpdateColumns(it => new { it.Quantity, it.NeedNum }).ExecuteCommand();
 | 
					                        SqlSugarHelper.Db.Updateable(cs).UpdateColumns(it => new { it.Quantity, it.NeedNum }).ExecuteCommand();
 | 
				
			||||||
| 
						 | 
					@ -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,6 +576,46 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                        #endregion
 | 
					                        #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        //}
 | 
					                        //}
 | 
				
			||||||
 | 
					                        //修改凌晨生成的日结存与总结存数据
 | 
				
			||||||
 | 
					                        AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
				
			||||||
 | 
					                        .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["dm_machineId"].ToString()))
 | 
				
			||||||
 | 
					                        .Where(ab => ab.Type == 3)
 | 
				
			||||||
 | 
					                        .Where(ab => ab.DrugId == oi._OrderDetail.DrugId)
 | 
				
			||||||
 | 
					                        .Where(ab => ab.ManuNo == cs.ManuNo)
 | 
				
			||||||
 | 
					                        .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
				
			||||||
 | 
					                        int manuStock = 0;
 | 
				
			||||||
 | 
					                        if (accountBookG2Day != null)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - oi._OrderDetail.Quantity;
 | 
				
			||||||
 | 
					                            accountBookG2Day.OutQuantity = accountBookG2Day.OutQuantity + oi._OrderDetail.Quantity;
 | 
				
			||||||
 | 
					                            SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
 | 
				
			||||||
 | 
					                            manuStock = accountBookG2Day.ManuStock;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            //生成日结存时可能没有该库位的绑定信息,需要写入日结存
 | 
				
			||||||
 | 
					                            int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                DrugId = oi._OrderDetail.DrugId,
 | 
				
			||||||
 | 
					                                Type = 3,
 | 
				
			||||||
 | 
					                                ManuNo = cs.ManuNo,
 | 
				
			||||||
 | 
					                                EffDate = cs.EffDate,
 | 
				
			||||||
 | 
					                                YQuantity = 0,
 | 
				
			||||||
 | 
					                                ManuStock = nowChannels.Sum(it => it.Quantity), //oi._OrderDetail.Quantity,
 | 
				
			||||||
 | 
					                                TotalStock = 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 = "日结存",
 | 
				
			||||||
 | 
					                                OutQuantity = oi._OrderDetail.Quantity,
 | 
				
			||||||
 | 
					                            }).ExecuteCommand();
 | 
				
			||||||
 | 
					                            if (iDayResult <= 0)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                logger.Info($"未写入日结存数据{oi._OrderDetail.DrugId}-{cs.ManuNo}-{cs.EffDate}-{cs.Quantity}");
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
                        //查询上一条账册中的空瓶数
 | 
					                        //查询上一条账册中的空瓶数
 | 
				
			||||||
                        AccountBookG2 accountBookEmpty = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
					                        AccountBookG2 accountBookEmpty = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
				
			||||||
                        .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["dm_machineId"].ToString()))
 | 
					                        .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["dm_machineId"].ToString()))
 | 
				
			||||||
| 
						 | 
					@ -600,49 +638,11 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                            CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
					                            CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
				
			||||||
                            CreateTime = DateTime.Now,
 | 
					                            CreateTime = DateTime.Now,
 | 
				
			||||||
                            InvoiceNo = oi.OrderNo,
 | 
					                            InvoiceNo = oi.OrderNo,
 | 
				
			||||||
                                ManuStock = nowChannels.Sum(it => it.Quantity),
 | 
					                            ManuStock = manuStock > 0 ? manuStock : nowChannels.Sum(it => it.Quantity),
 | 
				
			||||||
                            TotalStock = (accountBookEmpty != null ? (accountBookEmpty.TotalStock > 0 ? accountBookEmpty.TotalStock : 0) : 0) + oi._OrderDetail.Quantity,
 | 
					                            TotalStock = (accountBookEmpty != null ? (accountBookEmpty.TotalStock > 0 ? accountBookEmpty.TotalStock : 0) : 0) + oi._OrderDetail.Quantity,
 | 
				
			||||||
                                ShoushuJian= drawerNo.ToString()
 | 
					                            ShoushuJian = drawerNo.ToString()
 | 
				
			||||||
                        }).ExecuteCommand();
 | 
					                        }).ExecuteCommand();
 | 
				
			||||||
                        //修改凌晨生成的日结存与总结存数据
 | 
					                        //修改凌晨生成的日结存与总结存数据
 | 
				
			||||||
                            AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
					 | 
				
			||||||
                            .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["dm_machineId"].ToString()))
 | 
					 | 
				
			||||||
                            .Where(ab => ab.Type == 3)
 | 
					 | 
				
			||||||
                            .Where(ab => ab.DrugId == oi._OrderDetail.DrugId)
 | 
					 | 
				
			||||||
                            .Where(ab => ab.ManuNo == cs.ManuNo)
 | 
					 | 
				
			||||||
                            .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
					 | 
				
			||||||
                            if (accountBookG2Day != null)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - oi._OrderDetail.Quantity;
 | 
					 | 
				
			||||||
                                accountBookG2Day.OutQuantity= accountBookG2Day.OutQuantity + oi._OrderDetail.Quantity;
 | 
					 | 
				
			||||||
                                SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            else
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                //生成日结存时可能没有该库位的绑定信息,需要写入日结存
 | 
					 | 
				
			||||||
                                int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    DrugId = oi._OrderDetail.DrugId,
 | 
					 | 
				
			||||||
                                    Type = 3,
 | 
					 | 
				
			||||||
                                    ManuNo = cs.ManuNo,
 | 
					 | 
				
			||||||
                                    EffDate = cs.EffDate,
 | 
					 | 
				
			||||||
                                    YQuantity = 0,
 | 
					 | 
				
			||||||
                                    ManuStock =nowChannels.Sum(it => it.Quantity), //oi._OrderDetail.Quantity,
 | 
					 | 
				
			||||||
                                    TotalStock = 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 = "日结存",
 | 
					 | 
				
			||||||
                                    OutQuantity = oi._OrderDetail.Quantity,
 | 
					 | 
				
			||||||
                                }).ExecuteCommand();
 | 
					 | 
				
			||||||
                                if (iDayResult <= 0)
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    logger.Info($"未写入日结存数据{oi._OrderDetail.DrugId}-{cs.ManuNo}-{cs.EffDate}-{cs.Quantity}");
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            //修改凌晨生成的日结存与总结存数据
 | 
					 | 
				
			||||||
                        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()))
 | 
				
			||||||
                        .Where(ab => ab.Type == 4)
 | 
					                        .Where(ab => ab.Type == 4)
 | 
				
			||||||
| 
						 | 
					@ -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