示例#1
0
        /// <summary>
        /// 获取搅拌车不同状态的车辆信息
        /// </summary>
        /// <returns></returns>
        public dynamic GetMixerCarStatus()
        {
            IList <Car> carList = this.Query()
                                  .Where(c => c.CarTypeID == CarType.Mixer)
                                  .Where(c => c.IsUsed == true)
                                  .OrderBy(c => c.OrderNum).OrderBy(c => c.ID).ToList();
            SysConfig config = new SysConfigService(this.m_UnitOfWork).GetSysConfig(SysConfigEnum.IsCarLendFilter);

            if (config != null && config.ConfigValue == "true")
            {
                var carLendItemList = new CarLendItemService(this.m_UnitOfWork).All("BackTime is null", "ID", true);
                Car car             = null;
                foreach (CarLendItem item in carLendItemList)
                {
                    car = carList.FirstOrDefault(c => c.ID == item.CarID);
                    if (car != null)
                    {
                        carList.Remove(car);
                    }
                }
            }
            //查询几种状态的车辆
            dynamic carInfo = new
            {
                Result       = true,
                Message      = string.Empty,
                AllowShipCar = carList.Where(c => c.CarStatus == CarStatus.AllowShipCar),
                ShippingCar  = carList.Where(c => c.CarStatus == CarStatus.ShippingCar),
                RestCar      = carList.Where(c => c.CarStatus == CarStatus.RestCar)
            };

            return(carInfo);
        }
示例#2
0
        /// <summary>
        /// 获取GPS是否开启全局配置参数
        /// </summary>
        /// <param name="gpsname"></param>
        /// <returns></returns>
        public virtual bool GPSSwitch(string gpsname)
        {
            SysConfigService configSvr = new SysConfigService(this.m_UnitOfWork);
            SysConfig        configGPS = configSvr.GetSysConfig(gpsname);
            bool             GPSBool   = configGPS == null ? false : Convert.ToBoolean(configGPS.ConfigValue);

            return(GPSBool);
        }
示例#3
0
        internal GPSHelper(IUnitOfWork uow)
            : base(uow)
        {
            SysConfigService configService = new SysConfigService(this.m_UnitOfWork);
            SysConfig        config2       = configService.GetSysConfig("GPSServiceSwitch");

            Boolean.TryParse(config2.ConfigValue, out GPSServiceSwitch);

            logger.Debug("GPS接口:" + (GPSServiceSwitch?"开启":"关闭"));
        }
示例#4
0
        public IList <Car> GetCarSelectList(string carType)
        {
            SysConfig config = new SysConfigService(this.m_UnitOfWork).GetSysConfig(SysConfigEnum.CarListView);
            int       value  = 0;

            if (config != null)
            {
                value = Convert.ToInt32(config.ConfigValue);
            }
            IList <Car> carList = null;

            if (carType == null)
            {
                carList = this.All(new List <string> {
                    "ID", "CarNo", "CarTypeID", "CarStatus"
                }, "IsUsed=1", "OrderNum", true);
            }
            else
            {
                carList = this.All(new List <string> {
                    "ID", "CarNo", "CarTypeID", "CarStatus"
                },
                                   string.Format("CarTypeID  in ('{0}') AND IsUsed=1", carType),
                                   "OrderNum",
                                   true);
            }
            foreach (Car item in carList)
            {
                string carid = item.ID;
                string carNo = item.CarNo;
                switch (value)
                {
                case 0:
                    item.CarNo = carid;
                    break;

                case 1:
                    item.CarNo = string.Format("{0} -- {1}", carid, carNo);
                    break;

                case 3:
                    item.CarNo = string.Format("{0} -- {1}", carNo, carid);
                    break;

                case 2:
                default:
                    break;
                }
            }
            return(carList);
        }
示例#5
0
        bool IsLogEnabled()
        {
            SysConfigService conf = new SysConfigService(this.m_UnitOfWork);
            var sysConf           = conf.GetSysConfig(SysConfigEnum.EnableSysLog);

            if (sysConf != null && sysConf.ConfigValue != "1" && sysConf.ConfigValue != "true")
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
示例#6
0
        private bool IsSysLogEnabled()
        {
            SysConfigService service = new SysConfigService(this.m_UnitOfWork);
            var logSetting           = service.GetSysConfig(SysConfigEnum.EnableSysLog);

            //不记录日志
            if (logSetting != null)
            {
                bool ret = true;
                if (logSetting.ConfigValue != "1" && logSetting.ConfigValue != "true")
                {
                    ret = false;
                }
                return(ret);
            }
            return(true);
        }
示例#7
0
        /// <summary>
        /// 取得泵车下拉列表数据
        /// </summary>
        /// <returns></returns>
        public IList <Car> GetPumpList()
        {
            var       carList = this.GetCarSelectList(ZLERP.Model.Enums.CarType.Pump);
            SysConfig config  = new SysConfigService(this.m_UnitOfWork).GetSysConfig(SysConfigEnum.IsCarLendFilter);

            if (config != null && config.ConfigValue == "true")
            {
                var carLendItemList = new CarLendItemService(this.m_UnitOfWork).All("BackTime is null", "ID", true);
                Car car             = null;
                foreach (CarLendItem item in carLendItemList)
                {
                    car = carList.FirstOrDefault(c => c.ID == item.CarID);
                    if (car != null)
                    {
                        carList.Remove(car);
                    }
                }
            }
            return(carList);
        }
示例#8
0
        /// <summary>
        /// 检测是否自动审核
        /// </summary>
        /// <param name="entity"></param>
        public virtual void CheckIsAutoAudit(TEntity entity)
        {
            Type             type          = entity.GetType();
            string           entityName    = type.Name;
            SysConfigService configService = new SysConfigService(this.m_UnitOfWork);
            //IList<SysConfig> configs = configService.GetAllSysConfigs();
            SysConfig config    = configService.GetSysConfig("IsAutoAuditFor" + entityName);
            bool      configVal = config == null ? false : Convert.ToBoolean(config.ConfigValue);

            if (configVal)
            {
                if (null != type.GetProperty("AuditStatus"))
                {
                    type.GetProperty("AuditStatus").SetValue(entity, 1, null);
                }
                if (null != type.GetProperty("AuditTime"))
                {
                    type.GetProperty("AuditTime").SetValue(entity, DateTime.Now, null);
                }
            }
        }
示例#9
0
        /// <summary>
        /// 取得搅拌车列表,按车号排序
        /// </summary>
        /// <returns></returns>
        public IList <Car> GetMixerCarListOrderByID()
        {
            var       carList = GetMixerCarList();
            SysConfig config  = new SysConfigService(this.m_UnitOfWork).GetSysConfig(SysConfigEnum.IsCarLendFilter);

            if (config != null && config.ConfigValue == "true")
            {
                var carLendItemList = new CarLendItemService(this.m_UnitOfWork).All("BackTime is null", "ID", true);
                Car car             = null;
                foreach (CarLendItem item in carLendItemList)
                {
                    car = carList.FirstOrDefault(c => c.ID == item.CarID);
                    if (car != null)
                    {
                        carList.Remove(car);
                    }
                }
            }
            if (carList != null)
            {
                carList = carList.OrderBy(p => p.ID.PadLeft(3, '0')).ToList();
            }
            return(carList);
        }
        public dynamic GetLastDocByTaskId(string taskid)
        {
            ShippingDocument doc = this.Find("TaskID = '" + taskid + "' AND IsEffective = 1 AND ShipDocType = '0'", 1, 1, "ID", "DESC").FirstOrDefault();

            //已下配比生产线判断不全面,如1#线下了混凝土配比,2#线只下了砂浆配比,搅拌机组下拉框中只有有1#线
            //只有砂浆配比的情况,只要判断IsSlurry = 0的数量是否为0
            //IList<ConsMixprop> phblistcount = this.m_UnitOfWork.ConsMixpropRepository.Find("TaskID = '" + taskid + "' AND IsSlurry = 0", 1, 30, "ProductLineID", "ASC");
            //IList<ConsMixprop> phblist = null;
            //if (phblistcount.Count == 0)
            //{
            //    phblist = this.m_UnitOfWork.ConsMixpropRepository.Find("TaskID = '" + taskid + "' AND AuditStatus = 1 ", 1, 30, "ProductLineID", "ASC");
            //}
            //else {
            //    phblist = this.m_UnitOfWork.ConsMixpropRepository.Find("TaskID = '" + taskid + "' AND AuditStatus = 1 AND IsSlurry = 0", 1, 30, "ProductLineID", "ASC");
            //}

            IList <ConsMixprop> phblist = null;

            phblist = this.m_UnitOfWork.ConsMixpropRepository.Find("TaskID = '" + taskid + "' AND AuditStatus = 1 ", 1, 30, "ProductLineID", "ASC");

            IList <string>      pdlist        = phblist.Select(p => p.ProductLineID).Distinct().ToList();
            IList <ProductLine> productlines  = null;
            SysConfigService    configService = new SysConfigService(this.m_UnitOfWork);

            if (pdlist.Count > 0)
            {
                productlines = this.m_UnitOfWork.GetRepositoryBase <ProductLine>()
                               .Query().Where(p => p.IsUsed && pdlist.Contains(p.ID))
                               .OrderBy(p => p.ID).ToList();
                //获取所有未完成的单
                IList <DispatchList> dispatchList = this.m_UnitOfWork.GetRepositoryBase <DispatchList>()
                                                    .Query().Where(d => d.IsCompleted == false).OrderBy(d => d.DispatchOrder).ToList();

                //计算预计发车时间
                //SysConfig delayConfig = this.m_UnitOfWork.GetRepositoryBase<SysConfig>()
                //    .Find("ConfigName = 'DelayDeliveryTime'", 1, 1, "ID", "DESC").FirstOrDefault();
                SysConfig delayConfig = configService.GetSysConfig(SysConfigEnum.DelayDeliveryTime);

                int delayTime = delayConfig == null ? 8 : Convert.ToInt32(delayConfig.ConfigValue);//未找到参数,默认8
                foreach (ProductLine item in productlines)
                {
                    string id    = item.ID;
                    int    count = dispatchList.Where(d => d.ProductLineID == id).ToList().Count + 1;
                    //将预计发车时间赋值给productline的modifytime
                    int      delayMinute  = count * delayTime;
                    DateTime deliveryTime = DateTime.Now.AddMinutes(delayMinute);
                    item.ModifyTime = deliveryTime;
                }
            }
            //自动选中车辆
            SysConfig config        = configService.GetSysConfig(Model.Enums.SysConfigEnum.AutoSelectCarID);
            bool      autoSelectCar = config == null ? true : Convert.ToBoolean(config.ConfigValue);
            string    autoCarID     = string.Empty;

            if (autoSelectCar)
            {
                Car         crtCar  = null;
                IList <Car> carList = this.m_UnitOfWork.GetRepositoryBase <Car>().Query()
                                      .Where(p => p.CarStatus == CarStatus.AllowShipCar && p.CarTypeID == CarType.Mixer && p.IsUsed)
                                      .OrderBy(p => p.OrderNum).OrderBy(p => p.ID).ToList();
                SysConfig carLendFilterConfig = configService.GetSysConfig(Model.Enums.SysConfigEnum.IsCarLendFilter);
                if (carLendFilterConfig != null && carLendFilterConfig.ConfigValue == "true")
                {
                    var carLendList = new CarLendItemService(this.m_UnitOfWork).All("BackTime is null", "ID", true).Select(c => c.CarID);
                    crtCar = carList.Where(p => !carLendList.Contains(p.ID)).FirstOrDefault();
                }
                else
                {
                    crtCar = carList.FirstOrDefault();
                }
                if (crtCar != null)
                {
                    autoCarID = crtCar.ID;
                }
            }

            CustomerPlan cp = new CustomerPlan();


            cp = new PublicService().CustomerPlan.Query().Where(m => m.TaskID == taskid).FirstOrDefault();


            return(new {
                Result = true
                , Message = string.Empty
                , Remark = doc == null ? string.Empty : (doc.Remark != null && doc.Remark.IndexOf("CODEADD") >= 0 ? doc.Remark.Remove(doc.Remark.IndexOf("CODEADD")) : doc.Remark)

                           //,PumpName = doc == null ? string.Empty : doc.PumpName
                , PumpName = doc == null ? (cp == null?string.Empty:cp.PumpName) : doc.PumpName
                ,
                PumpMan = doc == null? (cp == null ? string.Empty : cp.PumpMan):doc.PumpMan

                , ProvidedCube = doc == null ? 0 : doc.ProvidedCube
                , PlanCube = doc == null ? 0 : doc.PlanCube
                             //累计车数
                , ProvidedTimes = doc == null ? 0 : doc.ProvidedTimes
                             //生产线
                , ProductLines = productlines
                             //自动选中的车辆
                , AutoCarID = autoCarID
            });
        }
示例#11
0
        /// <summary>
        /// 保存横向与纵向配比
        /// </summary>
        /// <param name="cm"></param>
        /// <param name="updateKeys"></param>
        public IList <string> UpdatePrimaryAndItems(ConsMixprop cm, NameValueCollection updateKeys)
        {
            using (var tx = this.m_UnitOfWork.BeginTransaction()) {
                try
                {
                    IList <string> errorList      = new List <string>();
                    string         _ConsMixpropID = cm.ID;
                    //先更新主表,此时synstatus为0表示修改状态
                    this.Update(cm, updateKeys);
                    //获取需要更新的子表
                    cm = this.Get(cm.ID);
                    IList <SiloProductLine> siloProductLines = this.m_UnitOfWork.GetRepositoryBase <SiloProductLine>().Query().Where(m => m.ProductLineID == cm.ProductLineID).ToList();
                    var  updateKeysOrderList = updateKeys.AllKeys.ToList();
                    Type tp = cm.GetType();
                    Dictionary <int, decimal> orderList = new Dictionary <int, decimal>();
                    string startWith = "S";
                    string endWith   = "_wet";
                    foreach (string item in updateKeysOrderList)
                    {
                        if (item.TrimStart().StartsWith(startWith) && item.TrimEnd().EndsWith(endWith))
                        {
                            Dictionary <int, decimal> orderAndValDic = new Dictionary <int, decimal>();
                            //取得orderNum
                            Regex rg    = new Regex("(?<=(" + startWith + "))[.\\s\\S]*?(?=(" + endWith + "))", RegexOptions.Multiline | RegexOptions.Singleline);
                            int   order = Convert.ToInt32(rg.Match(item).Value);
                            //取得orderNum对应的用量
                            var val = tp.GetProperty(string.Format("S{0}_wet", order).ToString()).GetValue(cm, null);
                            orderList.Add(order, Convert.ToDecimal(val));
                            //orderList.Add(orderAndValDic);
                        }
                    }
                    //根据orderNum取得需要更新的siloID
                    Dictionary <string, decimal> needToUpdateSiloIdList = new Dictionary <string, decimal>();
                    foreach (SiloProductLine sp in siloProductLines)
                    {
                        if (orderList.ContainsKey(sp.OrderNum))
                        {
                            string siloId = sp.SiloID;
                            needToUpdateSiloIdList.Add(siloId, orderList[sp.OrderNum]);
                        }
                    }

                    //开始更新子表
                    foreach (KeyValuePair <string, decimal> kvp in needToUpdateSiloIdList)
                    {
                        ConsMixpropItem cmi = this.m_UnitOfWork.ConsMixpropItemRepository.Query().Where(c => c.ConsMixpropID == _ConsMixpropID && c.SiloID == kvp.Key).FirstOrDefault();
                        cmi.Amount = kvp.Value;
                        this.m_UnitOfWork.ConsMixpropItemRepository.Update(cmi, null);
                    }
                    //检查容重与水泥、水的用量
                    IConsMixpropItemRepository IConItems = this.m_UnitOfWork.ConsMixpropItemRepository;
                    IList <ConsMixpropItem>    citems    = IConItems.Query().Where(m => m.ConsMixpropID == cm.ID).ToList();
                    decimal totolWeight = 0;
                    foreach (ConsMixpropItem citem in citems)
                    {
                        totolWeight = totolWeight + citem.Amount;
                    }
                    SysConfigService configService = new SysConfigService(this.m_UnitOfWork);
                    SysConfig        config        = configService.GetSysConfig(SysConfigEnum.IsAllowConsMixpropLimit);
                    if (!cm.IsSlurry)
                    {
                        SysConfig configFormulaRZMax = configService.GetSysConfig(SysConfigEnum.FormulaRZMax);
                        SysConfig configFormulaRZMin = configService.GetSysConfig(SysConfigEnum.FormulaRZMin);
                        decimal   dFormulaRZMax      = decimal.Parse(configFormulaRZMax.ConfigValue);
                        decimal   dFormulaRZMin      = decimal.Parse(configFormulaRZMin.ConfigValue);
                        decimal   weight             = cm.Weight ?? 0;
                        if (config != null && bool.Parse(config.ConfigValue) && cm.ProduceTask.CementType == Model.Enums.CementType.CommonCement)
                        {
                            if (totolWeight > dFormulaRZMax || totolWeight < dFormulaRZMin)
                            {
                                errorList.Add("施工配比号[" + cm.ID + "]" + "&nbsp;&nbsp;超出混凝土配比容重范围");
                                tx.Rollback();
                                return(errorList);
                                //throw new Exception("混凝土配比超出容重范围");
                            }
                            string measureError = CheckMesureScale(cm.TaskID, cm.ProductLineID, 0, 0, true, false);
                            if (!string.IsNullOrEmpty(measureError))
                            {
                                errorList.Add(measureError);
                                tx.Rollback();
                                return(errorList);
                                //throw new Exception(measureError);
                            }
                        }
                    }
                    else
                    {
                        if (config != null && bool.Parse(config.ConfigValue) && cm.ProduceTask.CementType == Model.Enums.CementType.CommonCement)
                        {
                            string measureError = CheckMesureScale(cm.TaskID, cm.ProductLineID, 0, 0, false, true);
                            if (!string.IsNullOrEmpty(measureError))
                            {
                                errorList.Add(measureError);
                                tx.Rollback();
                                return(errorList);
                            }
                        }
                    }
                    cm.SynStatus = 1;      //主表与子表修改完毕后将SynStatus设为1,准备同步与发送搅拌楼
                    base.Update(cm, null);
                    if (cm.SynStatus == 1) //发送配比至搅拌楼(12版楼站)
                    {
                        /*//直连:通知控制系统修改配比
                         * by:Sky 2013/3/17
                         *****************************************************************************/
                        IList <ConsMixpropItem> cmItems = this.m_UnitOfWork.GetRepositoryBase <ConsMixpropItem>().All("ConsMixpropID='" + cm.ID + "'", "ID", true);
                        ResultInfo result = controlSystem.UpdateConsMixprop(cm, cmItems);
                        if (!result.Result)       //配比没有发送成功
                        {
                            errorList.Add(result.Message);
                            tx.Rollback();
                            return(errorList);
                            //throw new Exception(result.Message);
                        }
                    }
                    tx.Commit();
                    return(errorList);
                }
                catch (Exception e) {
                    tx.Rollback();
                    throw e;
                }
            }
        }
示例#12
0
        public void SendModifiedPBToKZ(ConsMixprop entity, string[] DirtyDataArr)
        {
            using (var tx = this.m_UnitOfWork.BeginTransaction())
            {
                try
                {
                    if (DirtyDataArr != null)
                    {
                        ////先保存子表数据,只用到编号与数量
                        string        is2012   = "";
                        Synmonitor    synTable = null;
                        PublicService op       = null;

                        foreach (string DirtyData in DirtyDataArr)
                        {
                            string[] dirty = DirtyData.Split(',');
                            ConsMixpropItemService consMixpropItemservice = new ConsMixpropItemService(this.m_UnitOfWork);
                            ConsMixpropItem        item = consMixpropItemservice.Get(Convert.ToInt32(dirty[0]));
                            item.Amount = Convert.ToDecimal(dirty[1]);
                            consMixpropItemservice.Update(item, null);

                            is2012 = ConfigurationManager.AppSettings["Is2012"];
                            if (is2012 == "true")
                            {
                                //是2012工控则插入同步表
                                synTable               = new Synmonitor();
                                synTable.tb_name       = "view_ConsMixpropItems";
                                synTable.tb_action     = "UPDATE";
                                synTable.key_name      = "ConsMixpropID";
                                synTable.key_value     = dirty[0];
                                synTable.key_type      = "0";
                                synTable.action_time   = DateTime.Now;
                                synTable.ProductLineID = item.ConsMixprop.ProductLineID;
                                if (op == null)
                                {
                                    op = new PublicService();
                                }
                                op.Synmonitor.Add(synTable);
                            }
                        }
                    }
                    IConsMixpropItemRepository IConItems = this.m_UnitOfWork.ConsMixpropItemRepository;
                    IList <ConsMixpropItem>    citems    = IConItems.Query().Where(m => m.ConsMixpropID == entity.ID).ToList();
                    decimal totolWeight = 0;
                    foreach (ConsMixpropItem citem in citems)
                    {
                        totolWeight = totolWeight + citem.Amount;
                    }
                    ConsMixprop cons = this.Get(entity.ID);
                    cons.SynStatus = entity.SynStatus;
                    base.Update(cons, null);
                    entity = this.Get(entity.ID);
                    SysConfigService configService = new SysConfigService(this.m_UnitOfWork);
                    SysConfig        config        = configService.GetSysConfig(SysConfigEnum.IsAllowConsMixpropLimit);
                    if (!entity.IsSlurry)
                    {
                        SysConfig configFormulaRZMax = configService.GetSysConfig(SysConfigEnum.FormulaRZMax);
                        SysConfig configFormulaRZMin = configService.GetSysConfig(SysConfigEnum.FormulaRZMin);
                        decimal   dFormulaRZMax      = decimal.Parse(configFormulaRZMax.ConfigValue);
                        decimal   dFormulaRZMin      = decimal.Parse(configFormulaRZMin.ConfigValue);
                        decimal   weight             = entity.Weight ?? 0;
                        if (config != null && bool.Parse(config.ConfigValue) && entity.ProduceTask.CementType == Model.Enums.CementType.CommonCement)
                        {
                            if (totolWeight > dFormulaRZMax || totolWeight < dFormulaRZMin)
                            {
                                throw new Exception("混凝土配比超出容重范围");
                            }
                            string measureError = CheckMesureScale(entity.TaskID, entity.ProductLineID, 0, 0, true, false);
                            if (!string.IsNullOrEmpty(measureError))
                            {
                                throw new Exception(measureError);
                            }
                        }
                    }
                    else
                    {
                        if (config != null && bool.Parse(config.ConfigValue) && entity.ProduceTask.CementType == Model.Enums.CementType.CommonCement)
                        {
                            string measureError = CheckMesureScale(entity.TaskID, entity.ProductLineID, 0, 0, false, true);
                            if (!string.IsNullOrEmpty(measureError))
                            {
                                throw new Exception(measureError);
                            }
                        }
                    }
                    if (entity.SynStatus == 1)      //发送配比
                    {
                        /*//直连:通知控制系统修改配比
                         * by:Sky 2013/3/17
                         *****************************************************************************/
                        IList <ConsMixpropItem> cmItems = this.m_UnitOfWork.GetRepositoryBase <ConsMixpropItem>().All("ConsMixpropID='" + entity.ID + "'", "ID", true);
                        ResultInfo result = controlSystem.UpdateConsMixprop(entity, cmItems);
                        if (!result.Result)       //配比没有发送成功
                        {
                            throw new Exception(result.Message);
                        }
                    }
                    tx.Commit();
                }
                catch (Exception e)
                {
                    tx.Rollback();
                    throw e;
                }
            }
        }