Exemple #1
0
        public bool ConfirmCargoOutOrder(int cargoOutOrderId, string userId)
        {
            var shipmentView = _dbd.pihao.FirstOrDefault(a => a.ID == cargoOutOrderId);
            var shipment     = _db.ShipmentInfoes.FirstOrDefault(a => a.ShipmentNo == shipmentView.PH_NO);
            var cargo        = _db.CargoInfoes.Find(shipment.CargoId);
            var shipmentHuot = _db.ShipmentHuotInfoes.First(a => a.HuotId == (int)shipmentView.HuotId && a.ShipmentId == shipment.Id);
            var cargoHuot    = _db.CargoHuotInfoes.First(a => a.HuotId == shipmentView.HuotId && a.CargoId == cargo.Id);

            shipmentView.InspectId   = userId;
            shipmentView.InspectTime = DateTime.Now;
            shipmentView.IsChecked   = true;
            _dbd.Entry(shipmentView).Property(c => c.IsChecked).IsModified   = true;
            _dbd.Entry(shipmentView).Property(c => c.InspectTime).IsModified = true;
            _dbd.Entry(shipmentView).Property(c => c.InspectId).IsModified   = true;

            cargo.Weight -= (decimal)shipmentView.PH_ZL;

            shipment.Weight -= (decimal)shipmentView.PH_ZL;

            shipmentHuot.Weight -= (decimal)shipmentView.PH_ZL;

            cargoHuot.Weight -= (decimal)shipmentView.PH_ZL;

            if (cargo.Weight < 0 || shipment.Weight < 0 || shipmentHuot.Weight < 0 || cargoHuot.Weight < 0)
            {
                return(false);
            }

            _db.Entry(cargo).Property(c => c.Weight).IsModified        = true;
            _db.Entry(shipment).Property(c => c.Weight).IsModified     = true;
            _db.Entry(shipmentHuot).Property(c => c.Weight).IsModified = true;
            _db.Entry(cargoHuot).Property(c => c.Weight).IsModified    = true;

            var cargoLog = new CargoLogInfoes()
            {
                IsIncome     = false,
                InspectTime  = DateTime.Now,
                StateId      = 2,
                CargoId      = cargo.Id,
                ChangeWeight = (decimal)shipmentView.PH_ZL,
                ShipmentId   = shipment.Id,
                ShipmentNo   = shipment.ShipmentNo,
                CargoInId    = 2,
                HuotId       = shipmentHuot.HuotId,
                InspectName  = shipmentView.qianfa,
                Desc         = "汽车出库",
            };

            _db.CargoLogInfoes.Add(cargoLog);


            return(_db.SaveChanges() == 5 && _dbd.SaveChanges() == 1);
        }
Exemple #2
0
        public bool AddCargoShipLog(int huom2Id, int huotId, int shipmentId, decimal changeWeight, int cargoInId, string inspectName)
        {
            //CheckCargo(huom2Id);
            //var cargo = _db.CargoInfoes.First(c => c.Huom2Id == huom2Id);
            //CheckShipment(shipmentNo, cargo.Id);
            //var shipment = _db.ShipmentInfoes.First(a => a.ShipmentNo == shipmentNo);

            var cargo              = _db.CargoInfoes.First(a => a.Huom2Id == huom2Id);
            var shipment           = _db.ShipmentInfoes.First(a => a.Id == shipmentId);
            var shipmentHuotInfoes = _db.ShipmentHuotInfoes.First(a => a.ShipmentId == shipment.Id && a.HuotId == huotId);
            var cargoHuot          = _db.CargoHuotInfoes.First(a => a.CargoId == cargo.Id && a.HuotId == huotId);

            cargo.Weight -= changeWeight;
            _db.Entry(cargo).Property(c => c.Weight).IsModified = true;
            shipment.Weight -= changeWeight;
            _db.Entry(shipment).Property(c => c.Weight).IsModified = true;
            shipmentHuotInfoes.Weight -= changeWeight;
            _db.Entry(shipmentHuotInfoes).Property(c => c.Weight).IsModified = true;
            cargoHuot.Weight -= changeWeight;
            _db.Entry(cargoHuot).Property(c => c.Weight).IsModified = true;

            if (cargo.Weight < 0 || shipment.Weight < 0 || shipmentHuotInfoes.Weight < 0 || cargoHuot.Weight < 0)
            {
                return(false);
            }

            if (shipment.CargoId != cargo.Id)
            {
                return(false);
                // return Json(new { success = "fail", message = "当前批号不对应该产品" });
            }

            var cargoLog = new CargoLogInfoes()
            {
                IsIncome     = false,
                InspectTime  = DateTime.Now,
                StateId      = 2,
                CargoId      = cargo.Id,
                ChangeWeight = changeWeight,
                ShipmentId   = shipment.Id,
                ShipmentNo   = shipment.ShipmentNo,
                CargoInId    = cargoInId,
                HuotId       = huotId,
                InspectName  = inspectName,
                Desc         = "火车出库"
            };

            _db.CargoLogInfoes.Add(cargoLog);

            return(_db.SaveChanges() > 0);
        }
Exemple #3
0
        public bool SelfSellOut(int id, string userId)
        {
            var user     = _db.sys_ry.Find(userId);
            var pihao    = _dbd.pihao.Find(id);
            var shipment = _db.ShipmentInfoes.FirstOrDefault(a => a.ShipmentNo == pihao.PH_NO);

            var cargoLog = new CargoLogInfoes()
            {
                ChangeWeight = (decimal)pihao.PH_ZL,
                IsIncome     = true,
                InspectTime  = DateTime.Now,
                InspectName  = user.name,
                StateId      = 3,
                Desc         = "入库自提",
                CargoId      = shipment.CargoId,
                ShipmentId   = shipment.Id,
                ShipmentNo   = shipment.ShipmentNo,
                HuotId       = (int)pihao.HuotId,
                Count        = 0,
                WeightType   = ""
            };
            var cargoLog2 = new CargoLogInfoes()
            {
                ChangeWeight = (decimal)pihao.PH_ZL,
                IsIncome     = false,
                InspectTime  = DateTime.Now,
                InspectName  = user.name,
                StateId      = 3,
                Desc         = "出库自提",
                CargoId      = shipment.CargoId,
                ShipmentNo   = shipment.ShipmentNo,
                ShipmentId   = shipment.Id,
                HuotId       = (int)pihao.HuotId,
                Count        = 0,
                WeightType   = ""
            };

            _db.CargoLogInfoes.Add(cargoLog);
            _db.CargoLogInfoes.Add(cargoLog2);
            pihao.IsChecked   = true;
            pihao.InspectId   = userId;
            pihao.InspectTime = DateTime.Now;
            return(_db.SaveChanges() == 2 && _dbd.SaveChanges() == 1);
        }
Exemple #4
0
        public bool AddCargoComeLog(int huom2Id, int huotId, string shipmentNo, decimal changeWeight, string inspectName, int count, decimal weightType)
        {
            CheckCargo(huom2Id);
            var cargo = _db.CargoInfoes.FirstOrDefault(c => c.Huom2Id == huom2Id);

            CheckShipment(shipmentNo, cargo.Id);
            var shipment = _db.ShipmentInfoes.FirstOrDefault(a => a.ShipmentNo == shipmentNo && a.CargoId == cargo.Id);

            CheckShipmentHuot(shipment.Id, huotId);
            var shipmentHuot = _db.ShipmentHuotInfoes.FirstOrDefault(a => a.ShipmentId == shipment.Id && a.HuotId == huotId);

            CheckCargoHuot(cargo.Id, huotId);
            var cargoHuot = _db.CargoHuotInfoes.FirstOrDefault(a => a.CargoId == cargo.Id && a.HuotId == huotId);

            var cargoLog = new CargoLogInfoes()
            {
                ChangeWeight = changeWeight,
                IsIncome     = true,
                InspectTime  = DateTime.Now,
                InspectName  = inspectName,
                StateId      = (int)StateEnum.正在审核,
                Desc         = StateEnum.正在审核.ToString(),//"等待审核",
                CargoId      = cargo.Id,
                ShipmentId   = shipment.Id,
                ShipmentNo   = shipment.ShipmentNo,
                HuotId       = huotId,
                Count        = count,
                WeightType   = weightType == 0 ? "" : "每袋" + weightType,
            };

            _db.CargoLogInfoes.Add(cargoLog);

            cargo.Weight        += changeWeight;
            shipment.Weight     += changeWeight;
            shipmentHuot.Weight += changeWeight;
            cargoHuot.Weight    += changeWeight;

            return(_db.SaveChanges() > 0);
        }
Exemple #5
0
        public bool ExchangeShipment(string shipmentNo, int huotId, int newHuotId, decimal weight, string userId)
        {
            var shipment       = _db.ShipmentInfoes.First(a => a.ShipmentNo == shipmentNo);
            var cargoId        = shipment.CargoId;
            var user           = _db.sys_ry.Find(userId);
            var cargoAreaCargo = _db.ShipmentHuotInfoes.First(a => a.HuotId == huotId && a.ShipmentId == shipment.Id);

            cargoAreaCargo.Weight -= weight;
            if (cargoAreaCargo.Weight < 0)
            {
                return(false);
            }
            var cargoHuot = _db.CargoHuotInfoes.FirstOrDefault(a => a.CargoId == shipment.CargoId && a.HuotId == huotId);

            cargoHuot.Weight -= weight;
            if (cargoHuot.Weight < 0)
            {
                return(false);
            }
            CheckCargoHuot(cargoId, newHuotId);
            var newCargoHuot = _db.CargoHuotInfoes.First(a => a.CargoId == cargoId && a.HuotId == newHuotId);

            newCargoHuot.Weight += weight;

            CheckShipmentHuot(shipment.Id, newHuotId);
            var newShipmentHuo = _db.ShipmentHuotInfoes.FirstOrDefault(a => a.HuotId == newHuotId && a.ShipmentId == shipment.Id);
            var huot           = _db.huot.Find(newHuotId);

            newShipmentHuo.Weight += weight;

            //var cargoLogList = new List<CargoLogInfo>();
            var cargoLog = new CargoLogInfoes();

            cargoLog.IsIncome     = false;
            cargoLog.ChangeWeight = weight;
            cargoLog.CargoId      = cargoId;
            cargoLog.HuotId       = huotId;
            cargoLog.ShipmentId   = shipment.Id;
            cargoLog.ShipmentNo   = shipment.ShipmentNo;
            cargoLog.StateId      = 3;
            cargoLog.InspectName  = user.name;
            cargoLog.InspectTime  = DateTime.Now;
            cargoLog.Desc         = "转库";
            _db.CargoLogInfoes.Add(cargoLog);

            var cargoLog2 = new CargoLogInfoes();

            cargoLog2.IsIncome     = true;
            cargoLog2.ChangeWeight = weight;
            cargoLog2.CargoId      = cargoId;
            cargoLog2.HuotId       = newHuotId;
            cargoLog2.ShipmentId   = shipment.Id;
            cargoLog.ShipmentNo    = shipment.ShipmentNo;
            cargoLog2.StateId      = 3;
            cargoLog2.InspectName  = user.name;
            cargoLog2.InspectTime  = DateTime.Now;
            cargoLog2.Desc         = "转库";
            _db.CargoLogInfoes.Add(cargoLog2);


            return(_db.SaveChanges() >= 2);
        }
Exemple #6
0
        public bool ChangeQuality(string shipmentNo, int huotId, int newHuom2Id, string userId)
        {
            var user         = _db.sys_ry.Find(userId);
            var shipment     = _db.ShipmentInfoes.FirstOrDefault(a => a.ShipmentNo == shipmentNo);
            var cargo        = _db.CargoInfoes.Find(shipment.CargoId);
            var cargoHuot    = _db.CargoHuotInfoes.FirstOrDefault(a => a.CargoId == cargo.Id && a.HuotId == huotId);
            var shipmentHuot = _db.ShipmentHuotInfoes.FirstOrDefault(a => a.ShipmentId == shipment.Id && a.HuotId == huotId);
            var weight       = shipment.Weight;

            // cargo 减库存 加库存
            cargo.Weight -= weight;
            _cargoService.CheckCargo(newHuom2Id);
            var newCargo = _db.CargoInfoes.First(a => a.Huom2Id == newHuom2Id);

            newCargo.Weight += weight;

            // shipment 减库存 加库存
            shipment.Weight -= weight;
            _db.ShipmentInfoes.Remove(shipment);
            _cargoService.CheckShipment(shipmentNo, cargo.Huom2Id);
            var newShipment = _db.ShipmentInfoes.First(a => a.ShipmentNo == shipmentNo && a.CargoId == newCargo.Id);

            newShipment.Weight += weight;

            // cargoHuot 减库存 加库存
            cargoHuot.Weight -= weight;
            _cargoService.CheckCargoHuot(newCargo.Id, huotId);
            var newCargoHuot = _db.CargoHuotInfoes.First(a => a.CargoId == newCargo.Id && a.HuotId == huotId);

            newCargoHuot.Weight += weight;

            // ShipmentHuot 减库存 加库存
            shipmentHuot.Weight -= weight;
            _cargoService.CheckShipmentHuot(newShipment.Id, huotId);
            var newShipmentHuot = _db.ShipmentHuotInfoes.First(a => a.ShipmentId == newShipment.Id && a.HuotId == huotId);

            newShipmentHuot.Weight += weight;
            // CargoLog 加

            var cargoLog = new CargoLogInfoes()
            {
                ChangeWeight = weight,
                IsIncome     = false,
                InspectTime  = DateTime.Now,
                InspectName  = user.name,
                StateId      = 2,
                Desc         = "调整品质出库",
                CargoId      = shipment.CargoId,
                ShipmentId   = shipment.Id,
                ShipmentNo   = shipment.ShipmentNo,
                HuotId       = huotId,
                Count        = 0,
                WeightType   = ""
            };
            var cargoLog2 = new CargoLogInfoes()
            {
                ChangeWeight = weight,
                IsIncome     = true,
                InspectTime  = DateTime.Now,
                InspectName  = user.name,
                StateId      = 2,
                Desc         = "调整品质入库",
                CargoId      = newCargo.Id,
                ShipmentId   = newShipment.Id,
                ShipmentNo   = shipment.ShipmentNo,
                HuotId       = huotId,
                Count        = 0,
                WeightType   = ""
            };

            _db.CargoLogInfoes.Add(cargoLog);
            _db.CargoLogInfoes.Add(cargoLog2);
            return(_db.SaveChanges() > 0 && _dbd.SaveChanges() == 1);
        }