Beispiel #1
0
        /// <summary>
        /// 根据入场煤运输记录生成批次并返回。
        /// 根据入场时间(实际到厂时间)、供煤单位、煤种生成,已存在则不创建
        /// </summary>
        /// <param name="buyFuelTransport"></param>
        /// <returns></returns>
        public CmcsInFactoryBatch GCQCInFactoryBatchByBuyFuelTransport(CmcsBuyFuelTransport buyFuelTransport, CmcsLMYB lmyb)
        {
            bool isSuccess = false;

            CmcsInFactoryBatch entity = HasInFactoryBatch(buyFuelTransport);

            if (entity == null)
            {
                //记录运输方式Id
                CodeContent        transporttype = new CodeContent();
                List <CodeContent> par           = commonDAO.GetCodeContentByKind("运输方式");
                if (par != null)
                {
                    transporttype = par.Where(a => a.Content == "汽车").FirstOrDefault();
                }

                entity = new CmcsInFactoryBatch()
                {
                    Batch              = CreateNewBatchNumber("QC", buyFuelTransport.InFactoryTime),
                    BatchType          = "汽车",
                    TransportTypeId    = transporttype != null ? transporttype.Id : "",
                    TransportTypeName  = "汽车",
                    PlanArriveDate     = buyFuelTransport.InFactoryTime,
                    FactArriveDate     = buyFuelTransport.InFactoryTime,
                    FuelKindId         = buyFuelTransport.FuelKindId,
                    SupplierId         = buyFuelTransport.SupplierId,
                    SentSupplierId     = buyFuelTransport.SupplierId,
                    SendSupplierId     = buyFuelTransport.SupplierId,
                    MineId             = buyFuelTransport.MineId,
                    RunDate            = buyFuelTransport.InFactoryTime,
                    TransportCompanyId = buyFuelTransport.TransportCompanyId,
                    Remark             = "由汽车煤智能化自动创建",
                    IsFinish           = 0,
                    IsCheck            = 0,
                    IsCTAutoCreate     = 1,
                    IsScale            = 0,
                    BACKBATCHDATE      = buyFuelTransport.InFactoryTime,
                    InFactoryType      = buyFuelTransport.InFactoryType
                };
                if (lmyb != null)
                {
                    entity.LMYBID         = lmyb.Id;
                    entity.PlanArriveDate = lmyb.InFactoryTime;
                    entity.QCal           = lmyb.Q;
                    entity.Stad           = lmyb.S;
                    entity.Vad            = lmyb.V;
                }
                // 创建新批次
                isSuccess = SelfDber.Insert(entity) > 0;
            }
            if (buyFuelTransport.SamplingType != eSamplingType.人工采样.ToString())
            {
                // 生成采制化数据记录
                CmcsRCSampling rCSampling = commonDAO.GCSamplingMakeAssay(entity, buyFuelTransport.SamplingType, "由汽车煤智能化自动创建", eAssayType.级编码化验);
                buyFuelTransport.SamplingId = rCSampling.Id;
            }
            buyFuelTransport.InFactoryBatchId = entity.Id;
            return(entity);
        }
        /// <summary>
        /// 生成制样明细
        /// </summary>
        /// <param name="rcMake"></param>
        /// <returns></returns>
        public List <CmcsRCMakeDetail> CreateRcMakeDetail(CmcsRCMake rcMake)
        {
            IList <CodeContent> maketype = commonDAO.GetCodeContentByKind("样品类型");

            foreach (CodeContent item in maketype)
            {
                CmcsRCMakeDetail makedetail = commonDAO.SelfDber.Entity <CmcsRCMakeDetail>("where MakeId=:MakeId and SampleType=:SampleType", new { MakeId = rcMake.Id, SampleType = item.Content });
                if (makedetail == null)
                {
                    makedetail            = new CmcsRCMakeDetail();
                    makedetail.MakeId     = rcMake.Id;
                    makedetail.SampleType = item.Content;
                    makedetail.BarrelCode = commonDAO.CreateNewMakeBarrelCodeByMakeCode(rcMake.MakeCode, item.Content);
                    commonDAO.SelfDber.Insert(makedetail);
                }
            }
            return(commonDAO.SelfDber.Entities <CmcsRCMakeDetail>("where MakeId=:MakeId", new { MakeId = rcMake.Id }));
        }