Beispiel #1
0
        public void initdata()
        {
            gvdata.Rows.Clear();
            List <ProduceTask> list = ProduceTaskService.GetItem();

            if (list != null)
            {
                foreach (var row in list)
                {
                    int index = this.gvdata.Rows.Add();
                    this.gvdata.Rows[index].Cells[1].Value = row.batchcode;
                    this.gvdata.Rows[index].Cells[2].Value = row.qty;
                    this.gvdata.Rows[index].Cells[3].Value = row.cuscount;
                    this.gvdata.Rows[index].Cells[4].Value = row.synseq;
                }
            }
        }
        /// <summary>
        /// 查询合同指定时间段内的价格项
        /// </summary>
        /// <param name="contractId"></param>
        /// <param name="beginDate"></param>
        /// <param name="endDate"></param>
        /// <param name="priceType"></param>
        /// <param name="rate"></param>
        /// <returns></returns>
        public dynamic FindValueItems(string contractId, string beginDate, string endDate, string priceType, decimal?rate)
        {
            if (IsSettlementExists(contractId, beginDate, endDate))
            {
                throw new ApplicationException(Lang.Settlement_Error_DateRangeDuplicate);
            }
            DateTime                dtBegin = Convert.ToDateTime(beginDate);
            DateTime                dtEnd   = Convert.ToDateTime(endDate);
            ContractService         conSvr  = new ContractService(this.m_UnitOfWork);
            ShippingDocumentService shipSvr = new ShippingDocumentService(this.m_UnitOfWork);

            ProduceTaskService pt = new ProduceTaskService(this.m_UnitOfWork);


            var contract = conSvr.Get(contractId);

            if (contract != null)
            {
                //查询指定范围生产过的合同明细id

                /*   var conStrengthList =  shipSvr.Query()
                 *     .Where(p => p.IsEffective == true)
                 *     .Where(p => p.ContractID == contractId
                 *         && p.ProduceDate >= dtBegin
                 *         && p.ProduceDate <= dtEnd)
                 *     .Where(p => p.ProduceTask.ContractItem != null)
                 *     .Select(p => p.ProduceTask.ContractItem)
                 *     .Distinct()
                 *     .ToList();
                 */
                //提升发货单页面效率相应修改,发货单对象没有ProduceTask关联对象,此处采用替代方法
                //modify by: Sky
                //date: 2012-12-10
                var produceTaskIds = shipSvr.Query()
                                     .Where(p => p.IsEffective == true)
                                     .Where(p => p.ContractID == contractId &&
                                            p.ProduceDate >= dtBegin &&
                                            p.ProduceDate <= dtEnd)
                                     .Select(p => p.TaskID).ToList();

                var conStrengthList = pt.Query()
                                      .Where(p => produceTaskIds.Contains(p.ID) && p.ContractItem != null)
                                      .Select(p => p.ContractItem)
                                      .Distinct()
                                      .ToList();


                //信息价
                if (priceType == ContractValuationType.InformationValue)
                {
                    var informationPrice = this.m_UnitOfWork.GetRepositoryBase <ConPrice>().Query();
                    var query            = from ci in conStrengthList
                                           join ip in informationPrice
                                           on ci.ConStrength equals ip.ConStrengthCode
                                           select new SettlementItem
                    {
                        ContractItemsID = ci.ID ?? 0,
                        //强度
                        TypeCode  = ci.ConStrength,
                        UnitPrice = ip.InfoPrice,
                        PumpPrice = ip.PumpPrice,
                        //特性
                        PriceType     = "",
                        SlurryPrice   = ip.SlurryPrice,
                        IdentityPrice = 0
                    };
                    // .Join(conStrengthList,ip=>ip.ConStrengthCode, ci=>ci.ConStrength,  (ip,ci)=>ip.ConStrengthCode==ci.ConStrength)
                    // .Select(p => new { ConStrength = p., ConcretePrice = p.InfoPrice, PumpPrice = p.PumpPrice, SlurryPrice = p.SlurryPrice, IdentityPrice = 0 })
                    //.Where(p => conStrengthList.Select(i => i.ConStrength).Contains(p.ConStrength))
                    //.OrderBy(p => p.ConStrength)
                    //.ToList();

                    return(new
                    {
                        OtherPrice = contract.OtherPrice.Select(o => new SettlementItem
                        {
                            //typecode
                            ContractItemsID = o.ID,
                            //加价项目
                            PriceType = o.PriceType,
                            //计算方式
                            TypeCode = o.CalcType,
                            UnitPrice = o.UnitPrice ?? 0
                        }),
                        PumpPrice = contract.ContractPumps.Select(o => new SettlementItem
                        {
                            ContractItemsID = 0,
                            //泵车类型
                            PriceType = o.PumpType,
                            //泵车类型
                            TypeCode = o.PumpType,
                            UnitPrice = o.PumpPrice ?? 0
                        }),
                        ItemPrice = query.ToList()
                    });
                }
                else
                {
                    return(new
                    {
                        OtherPrice = contract.OtherPrice.Select(o => new SettlementItem
                        {
                            //typecode
                            ContractItemsID = o.ID,
                            //加价项目
                            PriceType = o.PriceType,
                            //计算方式
                            TypeCode = o.CalcType,
                            UnitPrice = o.UnitPrice ?? 0
                        }),
                        PumpPrice = contract.ContractPumps.Select(o => new SettlementItem
                        {
                            ContractItemsID = 0,
                            //泵车类型
                            PriceType = o.PumpType,
                            //泵车类型
                            TypeCode = o.PumpType,
                            UnitPrice = o.PumpPrice ?? 0
                        }),
                        ItemPrice = contract.ContractItems
                                    .Where(p => conStrengthList.Select(i => i.ConStrength).Contains(p.ConStrength))
                                    .Select(p => new SettlementItem
                        {
                            ContractItemsID = p.ID ?? 0,
                            //强度
                            TypeCode = p.ConStrength,
                            UnitPrice = p.UnPumpPrice ?? 0,
                            PumpPrice = p.PumpCost ?? 0,
                            //特性
                            PriceType = string.Join(",", p.IdentitySettings.Select(t => t.IdentityName).ToArray()),
                            SlurryPrice = p.SlurryPrice ?? 0,
                            IdentityPrice = p.IdentitySettings.Sum(i => i.IdentityPrice)
                        })
                                    .ToList()
                    });
                }
            }
            return(null);
        }
Beispiel #3
0
        //根据计划创建新任务单
        void CreateProduceTask(CustomerPlan cPlan, IUnitOfWork uow, out string TaskID)
        {
            var contractItem   = CreateContractItem(cPlan, uow);
            int contractItemId = contractItem.ID ?? 0;

            TaskID = string.Empty;;
            if (contractItem != null && contractItemId > 0)
            {
                ProduceTask task = new ProduceTask();

                task.ContractID      = cPlan.ContractID;
                task.ContractItemsID = contractItemId;

                task.ConstructUnit = cPlan.ConstructUnit;
                task.ProjectName   = cPlan.ProjectName;
                task.ProjectAddr   = cPlan.ProjectAddr;
                task.ConStrength   = contractItem.ConStrength;
                task.ConsPos       = cPlan.ConsPos;
                task.Slump         = cPlan.Slump;
                task.CastMode      = cPlan.CastMode;
                task.PlanCube      = cPlan.PlanCube;
                task.PumpType      = cPlan.PumpName;
                task.SupplyUnit    = cPlan.SupplyUnit;
                DateTime dt;
                if (!DateTime.TryParse(cPlan.PlanDate.ToString("yyyy-MM-dd") + " " + cPlan.NeedDate, out dt))
                {
                    DateTime.TryParse(cPlan.PlanDate.ToString("yyyy-MM-dd") + " 21:00:00", out dt);
                }
                task.NeedDate = dt;

                task.Tel      = cPlan.Tel;
                task.LinkMan  = cPlan.LinkMan;
                task.Remark   = cPlan.Remark;
                task.RegionID = cPlan.RegionID;
                task.TaskType = TaskType.ContractTask;
                ProduceTaskService pts = new ProduceTaskService(uow);
                pts.CheckIsAutoAudit(task);
                var project = pts.CreateProject(task);
                task.ProjectID = project.ID;


                string      ID = "";
                ProduceTask pj = this.m_UnitOfWork.GetRepositoryBase <ProduceTask>().Query().Where(p => p.ID.Contains(DateTime.Now.ToString("yyMMdd"))).OrderByDescending(p => p.ID).FirstOrDefault();
                if (pj == null)
                {
                    ID = DateTime.Now.ToString("yyMMdd") + "001";
                }
                else
                {
                    ID = pj.ID.Substring(6, 3);
                    int k = Convert.ToInt32(ID);
                    k++;
                    ID = DateTime.Now.ToString("yyMMdd") + (k.ToString().Length == 1 ? ("00" + k.ToString()) : (k.ToString().Length == 2 ? ("0" + k.ToString()) : k.ToString()));
                }
                task.ID = ID;


                task         = this.m_UnitOfWork.GetRepositoryBase <ProduceTask>().Add(task);
                TaskID       = task.ID;
                cPlan.TaskID = task.ID;
                CreateProducePlan(cPlan);
            }
        }