Beispiel #1
0
        /// <summary>
        /// 生成出场煤运输排队记录,同时生成批次信息
        /// </summary>
        /// <param name="autotruck"></param>
        /// <param name="transportsales"></param>
        /// <param name="supplyReceive"></param>
        /// <param name="company"></param>
        /// <param name="fuelKind"></param>
        /// <param name="inFactoryTime"></param>
        /// <param name="remark"></param>
        /// <param name="place"></param>
        /// <param name="loadarea"></param>
        /// <returns></returns>
        public bool JoinQueueSaleFuelTransport(CmcsAutotruck autotruck, CmcsLMYB transportsales, CmcsSupplier supplyReceive, CmcsTransportCompany company, CmcsFuelKind fuelKind, DateTime inFactoryTime, string remark, string place, string loadarea, string transportType, string sampleType, Tuple <string, string> CPC, Tuple <string, string> storageName)
        {
            eTransportType TransportType;

            Enum.TryParse(transportType, out TransportType);
            CmcsSaleFuelTransport transport = new CmcsSaleFuelTransport
            {
                SerialNumber         = carTransportDAO.CreateNewTransportSerialNumber(TransportType, inFactoryTime),
                AutotruckId          = autotruck.Id,
                CarNumber            = autotruck.CarNumber,
                TransportSalesNum    = transportsales != null ? transportsales.YbNum : "",
                TransportSalesId     = transportsales != null ? transportsales.Id : "",
                TransportCompanyName = company.Name,
                TransportCompanyId   = company.Id,
                TransportNo          = transportsales != null ? transportsales.TransportNo : "",
                SupplierId           = supplyReceive.Id,
                SupplierName         = supplyReceive.Name,
                InFactoryTime        = inFactoryTime,
                IsFinish             = 0,
                IsUse          = 1,
                StepName       = eTruckInFactoryStep.入厂.ToString(),
                LoadArea       = loadarea,
                Remark         = remark,
                FuelKindId     = fuelKind != null ? fuelKind.Id : "",
                OutFactoryType = transportType,
                SampleType     = sampleType,
                CPCId          = CPC.Item1,
                CPCName        = CPC.Item2,
                StorageId      = storageName.Item1,
                StorageName    = storageName.Item2,
                LMYBId         = transportsales != null ? transportsales.Id : ""
            };

            //生成批次数据
            CmcsInFactoryBatch inOutBatch = carTransportDAO.GCQCInFactoryBatchBySaleFuelTransport(transport, transportsales);

            if (inOutBatch != null)
            {
                if (SelfDber.Insert(transport) > 0)
                {
                    // 插入未完成运输记录
                    return(SelfDber.Insert(new CmcsUnFinishTransport
                    {
                        TransportId = transport.Id,
                        CarType = transportType.ToString(),
                        AutotruckId = autotruck.Id,
                        PrevPlace = place,
                    }) > 0);
                }
            }
            return(false);
        }
        /// <summary>
        /// 保存销售煤运输记录
        /// </summary>
        /// <param name="transportId"></param>
        /// <param name="weight">重量</param>
        /// <param name="place"></param>
        /// <returns></returns>
        public bool SaveSaleFuelTransport(string transportId, decimal weight, DateTime dt, string place)
        {
            CmcsSaleFuelTransport transport = SelfDber.Get <CmcsSaleFuelTransport>(transportId);

            if (transport == null)
            {
                return(false);
            }
            transport.IsSynch = "0";

            if (transport.TareWeight == 0)
            {
                transport.StepName   = eTruckInFactoryStep.轻车.ToString();
                transport.TareWeight = weight;
                transport.TarePlace  = place;
                transport.TareTime   = dt;
            }
            else if (transport.GrossWeight == 0)
            {
                transport.StepName       = eTruckInFactoryStep.重车.ToString();
                transport.GrossWeight    = weight;
                transport.GrossPlace     = place;
                transport.GrossTime      = dt;
                transport.OutFactoryTime = dt;
                transport.SuttleWeight   = transport.GrossWeight - transport.TareWeight;

                // 回皮即完结
                transport.IsFinish = 1;
                carTransportDAO.DelUnFinishTransport(transport.Id);
                commonDAO.InsertWaitForHandleEvent("汽车智能化_同步销售煤运输记录到批次", transport.Id);
                commonDAO.InsertWaitForHandleEvent("汽车智能化_删除未完成运输记录", transport.Id);
            }
            else
            {
                return(false);
            }
            if (transport.TareTime.Day != transport.InFactoryTime.Day)
            {
                carTransportDAO.GCQCInFactoryBatchBySaleFuelTransport(transport, null);
            }
            return(SelfDber.Update(transport) > 0);
        }