Пример #1
0
        public async Task <ContentResult> DealTVUnloadTask()
        {
            try
            {
                byte[] bytes = new byte[Request.InputStream.Length];
                Request.InputStream.Read(bytes, 0, bytes.Length);
                string req = System.Text.Encoding.Default.GetString(bytes);

                JObject jo = (JObject)JsonConvert.DeserializeObject(req);

                string queueID = jo["queueID"].ToString();
                string itaskID = jo["taskID"].ToString();

                int mtskID = Convert.ToInt32(queueID);
                int tid    = Convert.ToInt32(itaskID);

                CWTask   cwtask = new CWTask();
                WorkTask queue  = await cwtask.FindQueueAsync(mtskID);

                ImplementTask task = await cwtask.FindITaskAsync(tid);

                cwtask.DealTVUnloadTask(task, queue);
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
            return(Content("success"));
        }
Пример #2
0
        public async Task <JsonResult> FindITask(int tid)
        {
            SubTask       subtask = null;
            ImplementTask itsk    = await new CWTask().FindAsync(tid);

            if (itsk != null)
            {
                subtask = new SubTask
                {
                    ID               = itsk.ID,
                    Warehouse        = itsk.Warehouse,
                    DeviceCode       = itsk.DeviceCode,
                    Type             = (int)itsk.Type,
                    Status           = (int)itsk.Status,
                    SendStatusDetail = (int)itsk.SendStatusDetail,
                    SendDtime        = itsk.SendDtime.ToString(),
                    CreateDate       = itsk.CreateDate.ToString(),
                    HallCode         = itsk.HallCode,
                    FromLctAddress   = itsk.FromLctAddress,
                    ToLctAddress     = itsk.ToLctAddress,
                    ICCardCode       = itsk.ICCardCode,
                    Distance         = itsk.Distance,
                    CarSize          = itsk.CarSize,
                    CarWeight        = itsk.CarWeight,
                    IsComplete       = itsk.IsComplete,
                    LocSize          = itsk.LocSize
                };
            }
            return(Json(subtask, JsonRequestBehavior.AllowGet));
        }
Пример #3
0
        /// <summary>
        /// 获取有作业的设备信息
        /// </summary>
        /// <returns></returns>
        public async Task <JsonResult> GetDeviceTaskLst()
        {
            List <DeviceTaskDetail> detailLst = new List <DeviceTaskDetail>();

            List <Device> hasTask = await new CWDevice().FindListAsync(dv => dv.TaskID != 0);
            CWTask        cwtask  = new CWTask();

            foreach (Device dev in hasTask)
            {
                ImplementTask itask = await cwtask.FindAsync(dev.TaskID);

                if (itask != null)
                {
                    string           desp   = dev.Warehouse.ToString() + dev.DeviceCode.ToString();
                    string           type   = PlusCvt.ConvertTaskType(itask.Type);
                    string           status = PlusCvt.ConvertTaskStatus(itask.Status, itask.SendStatusDetail);
                    DeviceTaskDetail detail = new DeviceTaskDetail
                    {
                        DevDescp = desp,
                        TaskType = type,
                        Status   = status,
                        Proof    = itask.ICCardCode
                    };
                    detailLst.Add(detail);
                }
            }

            return(Json(detailLst, JsonRequestBehavior.AllowGet));
        }
Пример #4
0
        public async Task <ContentResult> UpdateTaskStatus()
        {
            try
            {
                byte[] bytes = new byte[Request.InputStream.Length];
                Request.InputStream.Read(bytes, 0, bytes.Length);
                string req = System.Text.Encoding.Default.GetString(bytes);

                JObject jo = (JObject)JsonConvert.DeserializeObject(req);

                string tskID  = jo["taskID"].ToString();
                string status = jo["taskstatus"].ToString();

                int itaskID    = Convert.ToInt32(tskID);
                int taskstatus = Convert.ToInt32(status);

                CWTask        cwtask = new CWTask();
                ImplementTask itask  = await cwtask.FindITaskAsync(itaskID);

                Response resp = cwtask.DealUpdateTaskStatus(itask, (EnmTaskStatus)taskstatus);
                if (resp.Code == 1)
                {
                    return(Content("success"));
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
            return(Content("fail"));
        }
Пример #5
0
        public ImplementTask FindITask(int tid)
        {
            string url     = baseURL + "FindITask";
            string param   = "tid=" + tid;
            string jsonStr = HttpRequest.HttpGet(url, param);

            if (jsonStr == "null" || string.IsNullOrEmpty(jsonStr))
            {
                return(null);
            }

            SubTask       itsk    = JsonConvert.DeserializeObject <SubTask>(jsonStr);
            ImplementTask subtask = new ImplementTask
            {
                ID               = itsk.ID,
                Warehouse        = itsk.Warehouse,
                DeviceCode       = itsk.DeviceCode,
                Type             = (EnmTaskType)itsk.Type,
                Status           = (EnmTaskStatus)itsk.Status,
                SendStatusDetail = (EnmTaskStatusDetail)itsk.SendStatusDetail,
                SendDtime        = DateTime.Parse(itsk.SendDtime),
                CreateDate       = DateTime.Parse(itsk.CreateDate),
                HallCode         = itsk.HallCode,
                FromLctAddress   = itsk.FromLctAddress,
                ToLctAddress     = itsk.ToLctAddress,
                ICCardCode       = itsk.ICCardCode,
                Distance         = itsk.Distance,
                CarSize          = itsk.CarSize,
                CarWeight        = itsk.CarWeight,
                IsComplete       = itsk.IsComplete,
                LocSize          = itsk.LocSize
            };

            return(subtask);
        }
Пример #6
0
        /// <summary>
        /// 报文收发的记录(1:发送,2:接收)
        /// </summary>
        /// <param name="data"></param>
        /// <param name="type">1:发送,2:接收</param>
        public async Task AddRecordAsync(Int16[] data, int type)
        {
            try
            {
                #region 记录数据库
                TelegramLog tlog = new TelegramLog();

                tlog.RecordDtime = DateTime.Now;
                tlog.Type        = type;
                if (type == 1)
                {
                    tlog.Warehouse = data[0];
                }
                if (type == 2)
                {
                    tlog.Warehouse = data[1];
                }
                if (data[4] != 0)
                {
                    tlog.Telegram = "(" + data[2] + "," + data[3] + "," + data[4] + ")";
                }
                else
                {
                    tlog.Telegram = "(" + data[2] + "," + data[3] + ")";
                }
                int           dcode = data[6];
                string        plate = "";
                ImplementTask itask = await new CWTask().FindAsync(tsk => tsk.DeviceCode == dcode && tsk.IsComplete == 0);
                if (itask != null)
                {
                    plate = itask.PlateNum;
                }
                string iccode = data[11].ToString();
                tlog.DeviceCode = data[6];
                tlog.ICCode     = iccode;
                tlog.PlateNum   = plate;
                tlog.CarInfo    = data[23] + "," + data[25] + "," + data[40] + "," + data[47];
                string fromAddrs = data[30] + "边" + data[31] + "列" + data[32] + "层";
                string toAddrs   = data[35] + "边" + data[36] + "列" + data[37] + "层";
                tlog.FromAddress = fromAddrs;
                tlog.ToAddress   = toAddrs;
                tlog.TelegramID  = data[48];

                await manager.AddAsync(tlog);

                #endregion
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
        }
Пример #7
0
        public async Task <JsonResult> FindITaskBySmg(int warehouse, int devicecode)
        {
            List <ImplementTask> itaskLst = await new CWTask().FindITaskLstAsync(t => t.Warehouse == warehouse && t.DeviceCode == devicecode);
            SubTask subtask = null;

            ImplementTask itsk = null;

            if (itaskLst.Count > 1)
            {
                foreach (ImplementTask tsk in itaskLst)
                {
                    if (tsk.Status != EnmTaskStatus.WillWaitForUnload)
                    {
                        itsk = tsk;
                        break;
                    }
                }
            }
            else if (itaskLst.Count == 1)
            {
                itsk = itaskLst[0];
            }
            if (itsk != null)
            {
                subtask = new SubTask
                {
                    ID               = itsk.ID,
                    Warehouse        = itsk.Warehouse,
                    DeviceCode       = itsk.DeviceCode,
                    Type             = (int)itsk.Type,
                    Status           = (int)itsk.Status,
                    SendStatusDetail = (int)itsk.SendStatusDetail,
                    SendDtime        = itsk.SendDtime.ToString(),
                    CreateDate       = itsk.CreateDate.ToString(),
                    HallCode         = itsk.HallCode,
                    FromLctAddress   = itsk.FromLctAddress,
                    ToLctAddress     = itsk.ToLctAddress,
                    ICCardCode       = itsk.ICCardCode,
                    Distance         = itsk.Distance,
                    CarSize          = itsk.CarSize,
                    CarWeight        = itsk.CarWeight,
                    IsComplete       = itsk.IsComplete,
                    LocSize          = itsk.LocSize
                };
            }
            return(Json(subtask, JsonRequestBehavior.AllowGet));
        }
Пример #8
0
        public List <ImplementTask> FindITaskLst(int nwarehouse)
        {
            string url   = baseURL + "FindITaskLst";
            var    param = new
            {
                warehouse = nwarehouse
            };
            string nback = JsonConvert.SerializeObject(param);

            string jsonStr = HttpRequest.HttpPost(url, nback);

            if (jsonStr == "null" || string.IsNullOrEmpty(jsonStr))
            {
                return(null);
            }
            List <SubTask> subtaskLst = JsonConvert.DeserializeObject <List <SubTask> >(jsonStr);

            List <ImplementTask> taskLst = new List <ImplementTask>();

            foreach (SubTask itsk in subtaskLst)
            {
                ImplementTask sub = new ImplementTask
                {
                    ID               = itsk.ID,
                    Warehouse        = itsk.Warehouse,
                    DeviceCode       = itsk.DeviceCode,
                    Type             = (EnmTaskType)itsk.Type,
                    Status           = (EnmTaskStatus)itsk.Status,
                    SendStatusDetail = (EnmTaskStatusDetail)itsk.SendStatusDetail,
                    SendDtime        = DateTime.Parse(itsk.SendDtime),
                    CreateDate       = DateTime.Parse(itsk.CreateDate.ToString()),
                    HallCode         = itsk.HallCode,
                    FromLctAddress   = itsk.FromLctAddress,
                    ToLctAddress     = itsk.ToLctAddress,
                    ICCardCode       = itsk.ICCardCode,
                    Distance         = itsk.Distance,
                    CarSize          = itsk.CarSize,
                    CarWeight        = itsk.CarWeight,
                    IsComplete       = itsk.IsComplete,
                    LocSize          = itsk.LocSize
                };
                taskLst.Add(sub);
            }

            return(taskLst);
        }
Пример #9
0
        public async Task <ContentResult> DealLoadFinishing(int taskID, int distance)
        {
            try
            {
                CWTask        cwtask = new CWTask();
                ImplementTask task   = await cwtask.FindITaskAsync(taskID);

                if (task != null)
                {
                    cwtask.DealLoadFinishing(task, distance);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
            return(Content("success"));
        }
Пример #10
0
        public async Task <ContentResult> ODealEVUp(int taskID)
        {
            try
            {
                CWTask        cwtask = new CWTask();
                ImplementTask task   = await cwtask.FindITaskAsync(taskID);

                if (task != null)
                {
                    cwtask.ODealEVUp(task);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
            return(Content("success"));
        }
Пример #11
0
        public async Task <ContentResult> UnpackUnloadOrder(int taskID)
        {
            try
            {
                CWTask        cwtask = new CWTask();
                ImplementTask itask  = await cwtask.FindITaskAsync(taskID);

                if (itask != null)
                {
                    int nback = await cwtask.UnpackUnloadOrderAsync(itask);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
            return(Content("success"));
        }
Пример #12
0
        /// <summary>
        /// 可执行作业推送到云平台
        /// </summary>
        /// <param name="type">1-添加,2-更新,3-删除</param>
        private void ParkingSingleton_ImpTaskWatchEvent(int type, ImplementTask itask)
        {
            #region   执行业务给云服务
            if (itask.Type == EnmTaskType.Avoid ||
                itask.Type == EnmTaskType.RetrySend ||
                itask.Type == EnmTaskType.Move ||
                itask.Type == EnmTaskType.Transpose)
            {
                return;
            }

            var iRet = new
            {
                Type    = type,
                SubTask = itask
            };
            string jsonstr = JsonConvert.SerializeObject(iRet);
            Clients.All.feedbackImpTaskToCloud(jsonstr);
            #endregion
        }
Пример #13
0
 /// <summary>
 /// 推送执行作业信息
 /// </summary>
 /// <param name="itask"></param>
 private void FileWatch_IMPTaskWatchEvent(int type, ImplementTask itask)
 {
     #region 给页面显示处理
     string           desp   = itask.Warehouse.ToString() + itask.DeviceCode.ToString();
     string           ctype  = PlusCvt.ConvertTaskType(itask.Type);
     string           status = PlusCvt.ConvertTaskStatus(itask.Status, itask.SendStatusDetail);
     DeviceTaskDetail detail = new DeviceTaskDetail
     {
         DevDescp = desp,
         TaskType = ctype,
         Status   = status,
         Proof    = itask.ICCardCode
     };
     //作业要删除时
     if (type == 3)
     {
         detail.TaskType = "";
         detail.Status   = "";
         detail.Proof    = "";
     }
     //给界面用
     Clients.All.feedbackImpTask(detail);
     #endregion
 }
Пример #14
0
        /// <summary>
        /// APP,远程取车,只允许使用车牌取车
        /// </summary>
        /// <returns></returns>
        public ActionResult RemoteGetCarInterface()
        {
            Response resp = new Response();
            Log      log  = LogFactory.GetLogger("RemoteGetCarInterface");

            #region
            try
            {
                CWDevice cwdevice = new CWDevice();

                byte[] bytes = new byte[Request.InputStream.Length];
                Request.InputStream.Read(bytes, 0, bytes.Length);
                string req = System.Text.Encoding.UTF8.GetString(bytes);
                //显示,记录
                log.Info(req);
                JObject jo        = (JObject)JsonConvert.DeserializeObject(req);
                string  warehouse = jo["warehouse"].ToString();
                string  hallID    = jo["hallID"].ToString();
                string  plate     = jo["plateNum"].ToString();

                if (string.IsNullOrEmpty(plate))
                {
                    log.Error("车牌号为空的!");
                    resp.Message = "参数错误";
                    return(Json(resp));
                }
                #region 暂不用
                //int wh = Convert.ToInt32(warehouse);
                //int hcode = Convert.ToInt32(hallID);

                //Device moHall = cwdevice.Find(d => d.Warehouse == wh && d.DeviceCode == hcode);
                //if (moHall == null)
                //{
                //    log.Error("APP取车时,查找不到车厅,warehouse- " + warehouse + " ,hallID- " + hallID);
                //    resp.Message = "找不到车厅";
                //    return Json(resp);
                //}
                //if (moHall.Mode != EnmModel.Automatic)
                //{
                //    log.Error("APP取车时,车厅模式不是全自动 , Mode - " + moHall.Mode.ToString());
                //    resp.Message = "车厅不是全自动";
                //    return Json(resp);
                //}
                //if (moHall.HallType == EnmHallType.Entrance)
                //{
                //    log.Error("APP取车时,车厅不是出车厅,halltype - " + moHall.HallType.ToString());
                //    resp.Message = "车厅不是全自动";
                //    return Json(resp);
                //}
                #endregion
                Location loc = new CWLocation().FindLocation(lc => lc.PlateNum == plate);
                if (loc == null)
                {
                    log.Error("APP取车时,找不到取车位,plate - " + plate);
                    resp.Message = "没有存车";
                    return(Json(resp));
                }
                CWTask        motsk = new CWTask();
                ImplementTask task  = motsk.Find(tk => tk.ICCardCode == loc.ICCode && tk.IsComplete == 0);
                if (task != null)
                {
                    log.Error("APP取车时,车位正在作业,iccode - " + loc.ICCode + " ,plate - " + plate);
                    resp.Message = "正在作业";
                    return(Json(resp));
                }
                WorkTask queue = motsk.FindQueue(qu => qu.ICCardCode == loc.ICCode);
                if (queue != null)
                {
                    log.Error("APP取车时,已经加入队列,iccode - " + loc.ICCode + " ,plate - " + plate);
                    resp.Message = "已经加入队列";
                    return(Json(resp));
                }
                if (loc.Type != EnmLocationType.Normal)
                {
                    log.Error("APP取车时,车位已被禁用,address - " + loc.Address);
                    resp.Message = "车位已被禁用";
                    return(Json(resp));
                }
                if (loc.Status != EnmLocationStatus.Occupy)
                {
                    log.Error("APP取车时,当前车位正在任务业,address - " + loc.Address + " ,status - " + loc.Status.ToString());
                    resp.Message = "车位已被禁用";
                    return(Json(resp));
                }
                int mcount = new CWTask().FindQueueList(q => q.IsMaster == 2).Count();
                if (mcount > 6)
                {
                    log.Error("APP取车时,取车队列已满");
                    resp.Message = "取车队列已满";
                    return(Json(resp));
                }

                //分配车厅
                int    hallcode = new CWDevice().AllocateHall(loc, false);
                Device moHall   = new CWDevice().Find(d => d.DeviceCode == hallcode);

                if (moHall != null)
                {
                    resp = motsk.DealOSwipedCard(moHall, loc);

                    log.Info("APP取车,取车车位 - " + loc.Address + " ,出车车厅 - " + moHall.DeviceCode);
                }
                else
                {
                    resp.Message = "找不到合适车厅";
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
                resp.Message = "系统异常";
            }
            #endregion
            return(Json(resp));
        }
Пример #15
0
        public ActionResult RemoteTempGetInterface()
        {
            Response resp = new Response();

            #region
            Log log = LogFactory.GetLogger("RemoteTempGetInterface");
            try
            {
                byte[] bytes = new byte[Request.InputStream.Length];
                Request.InputStream.Read(bytes, 0, bytes.Length);
                string req = System.Text.Encoding.UTF8.GetString(bytes);
                //显示,记录
                log.Info(req);
                JObject jo = (JObject)JsonConvert.DeserializeObject(req);

                string plate = jo["platenum"].ToString();
                if (string.IsNullOrEmpty(plate))
                {
                    log.Info("参数错误,车牌为空的!");
                    resp.Message = "参数错误";
                    return(Json(resp));
                }
                Location loc = new CWLocation().FindLocation(lc => lc.PlateNum == plate);
                if (loc == null)
                {
                    log.Error("APP取物时,找不到取车位,plate - " + plate);
                    resp.Message = "没有存车";
                    return(Json(resp));
                }
                CWTask        motsk = new CWTask();
                ImplementTask task  = motsk.Find(tk => tk.ICCardCode == loc.ICCode);
                if (task != null)
                {
                    log.Error("APP取物时,车位正在作业,iccode - " + loc.ICCode + " ,plate - " + plate);
                    resp.Message = "正在作业";
                    return(Json(resp));
                }
                WorkTask queue = motsk.FindQueue(qu => qu.ICCardCode == loc.ICCode);
                if (queue != null)
                {
                    log.Error("APP取物时,已经加入队列,iccode - " + loc.ICCode + " ,plate - " + plate);
                    resp.Message = "已经加入队列";
                    return(Json(resp));
                }
                if (loc.Type != EnmLocationType.Normal)
                {
                    log.Error("APP取物时,车位已被禁用,address - " + loc.Address);
                    resp.Message = "车位已被禁用";
                    return(Json(resp));
                }
                //分配车厅
                int hallcode = new CWDevice().AllocateHall(loc, false);

                Device moHall = new CWDevice().Find(d => d.DeviceCode == hallcode);
                if (moHall != null)
                {
                    resp = motsk.TempGetCar(moHall, loc);
                }
                else
                {
                    resp.Message = "找不到合适车厅";
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
                resp.Message = "系统异常";
            }
            #endregion
            return(Json(resp));
        }
Пример #16
0
        public async Task <JsonResult> QueryCarQueue()
        {
            Log log = LogFactory.GetLogger("QueryCarQueue");

            try
            {
                #region
                CWTask          cwtask   = new CWTask();
                List <WorkTask> mtaskLst = await cwtask.FindQueueListAsync(m => m.IsMaster == 2);

                //如果是连取时,ETV先执行了,队列消失了,但车厅的队列要显示出来
                List <WorkTask> mtaskhashallLst = await cwtask.FindQueueListAsync(m => m.IsMaster == 1 && (m.MasterType == EnmTaskType.GetCar || m.MasterType == EnmTaskType.TempGet));

                //获取车厅正在执行的作业
                List <ImplementTask> hallTaskLst = await cwtask.FindITaskLstAsync();

                //获取车厅设备
                List <Device> hallsLst = await new CWDevice().FindListAsync(d => d.Type == EnmSMGType.Hall);

                List <FeedbackFingerData> fdataLst = new List <FeedbackFingerData>();
                foreach (Device hall in hallsLst)
                {
                    List <FeedbackQueue> queueLst = new List <FeedbackQueue>();
                    #region
                    int      i            = 1;
                    WorkTask nextworktask = mtaskhashallLst.Find(mt => mt.DeviceCode == hall.DeviceCode && mt.Warehouse == hall.Warehouse);
                    if (nextworktask != null)
                    {
                        string plate = "";
                        if (string.IsNullOrEmpty(nextworktask.PlateNum))
                        {
                            plate = nextworktask.ICCardCode;
                        }
                        else
                        {
                            plate = nextworktask.PlateNum;
                        }

                        FeedbackQueue queue = new FeedbackQueue
                        {
                            queueNum      = i++,
                            queueCarbrand = plate,
                            queueIcCode   = nextworktask.ICCardCode
                        };

                        queueLst.Add(queue);
                    }

                    List <WorkTask> worktaskLst = mtaskLst.FindAll(mt => mt.DeviceCode == hall.DeviceCode && mt.Warehouse == hall.Warehouse);
                    foreach (WorkTask wtask in worktaskLst)
                    {
                        string plate = "";
                        if (string.IsNullOrEmpty(wtask.PlateNum))
                        {
                            plate = wtask.ICCardCode;
                        }
                        else
                        {
                            plate = wtask.PlateNum;
                        }

                        FeedbackQueue queue = new FeedbackQueue
                        {
                            queueNum      = i++,
                            queueCarbrand = plate,
                            queueIcCode   = wtask.ICCardCode
                        };

                        queueLst.Add(queue);
                    }
                    #endregion
                    string platenum = "";
                    string tasktype = "";
                    #region
                    ImplementTask itask = hallTaskLst.Find(ht => ht.DeviceCode == hall.DeviceCode && ht.Warehouse == hall.Warehouse);
                    if (itask != null)
                    {
                        if (string.IsNullOrEmpty(itask.PlateNum))
                        {
                            platenum = itask.ICCardCode;
                        }
                        else
                        {
                            platenum = itask.PlateNum;
                        }
                        if (itask.Type == EnmTaskType.SaveCar)
                        {
                            tasktype = "正在存车";
                        }
                        else
                        {
                            tasktype = "正在取车";
                        }
                    }
                    #endregion
                    FeedbackFingerData single = new FeedbackFingerData
                    {
                        wareHouseName = (hall.DeviceCode - 10).ToString(),
                        carBarnd      = platenum,
                        taskType      = tasktype,
                        queueList     = queueLst
                    };
                    fdataLst.Add(single);
                }

                var iRet = new
                {
                    status = 1,
                    msg    = "查询成功",
                    data   = fdataLst
                };

                return(Json(iRet));

                #endregion
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
            var nback = new
            {
                status = 0,
                msg    = "查询异常"
            };
            return(Json(nback));
        }
Пример #17
0
        /// <summary>
        /// 批量更新
        /// </summary>
        /// <param name="alarmLst"></param>
        /// <returns></returns>
        public async Task <Response> UpdateAlarmListAsync(List <Alarm> alarmLst)
        {
            Response resp = new Response();
            Log      log  = LogFactory.GetLogger("UpdateAlarmList");

            try
            {
                resp = await manager_alarm.UpdateAlarmListAsync(alarmLst);

                #region 报警记录写入数据库
                List <Alarm> faultLst = alarmLst.FindAll(f => f.Color == EnmAlarmColor.Red && f.Description.Contains("备用") == false);
                if (faultLst.Count > 0)
                {
                    new CWFaultLog().AddFaultRecord(faultLst);
                }
                #endregion

                #region 写状态位记录入数据库
                List <Alarm> statusLst = alarmLst.FindAll(f => f.Color == EnmAlarmColor.Green && f.Description.Contains("备用") == false);
                if (faultLst.Count > 0)
                {
                    new CWStatusLog().AddStateRecord(statusLst);
                }
                #endregion

                #region 推送至显示
                int warehouse            = alarmLst.First().Warehouse;
                int devicecode           = alarmLst.First().DeviceCode;
                List <BackAlarm> backlst = new List <BackAlarm>();

                List <Alarm> hasValueLst = await manager_alarm.FindListAsync(al => al.Warehouse == warehouse && al.DeviceCode == devicecode && al.Value == 1);

                foreach (Alarm ar in hasValueLst)
                {
                    if (ar.Description.Contains("备用"))
                    {
                        continue;
                    }
                    int type = 0;
                    if (ar.Color == EnmAlarmColor.Green)
                    {
                        type = 1;
                    }
                    else if (ar.Color == EnmAlarmColor.Red)
                    {
                        type = 2;
                    }

                    BackAlarm back = new BackAlarm
                    {
                        Type        = type,
                        Description = ar.Description
                    };

                    backlst.Add(back);
                }
                SingleCallback.Instance().WatchFaults(warehouse, devicecode, backlst);
                #endregion

                #region 向云服务请求短信发送
                if (faultLst.Count > 0)
                {
                    Alarm  myalarm = faultLst[0];
                    Device smg     = await FindAsync(d => d.Warehouse == myalarm.Warehouse && d.DeviceCode == myalarm.DeviceCode);

                    if (smg == null || smg.TaskID == 0)
                    {
                        return(resp);
                    }
                    //一定是作业时报警才上报
                    ImplementTask itask = await new CWTask().FindAsync(smg.TaskID);
                    if (itask == null)
                    {
                        return(resp);
                    }

                    SMSInfo sms = null;
                    if (dicSmsRequest.ContainsKey(smg.DeviceCode))
                    {
                        SMSInfo info = dicSmsRequest[smg.DeviceCode];
                        //同一个任务,只发送一次
                        if (info.Plate == itask.PlateNum)
                        {
                            return(resp);
                        }
                        //15分钟内只允许发送一条
                        DateTime rcdtime = DateTime.Parse(info.RcdTime);
                        if (DateTime.Compare(rcdtime, DateTime.Now.AddMinutes(15)) < 0)
                        {
                            return(resp);
                        }
                        ////内容重复的,一个小时内只发一次
                        //if (info.Message == myalarm.Description&& DateTime.Compare(rcdtime, DateTime.Now.AddHours(1)) < 0)
                        //{
                        //    return resp;
                        //}

                        sms = new SMSInfo {
                            warehouse  = smg.Warehouse,
                            DeviceCode = smg.DeviceCode,
                            Plate      = itask.PlateNum,
                            AutoStep   = smg.RunStep,
                            Message    = myalarm.Description,
                            RcdTime    = DateTime.Now.ToString()
                        };
                        dicSmsRequest[smg.DeviceCode] = sms;
                    }
                    else
                    {
                        sms = new SMSInfo
                        {
                            warehouse  = smg.Warehouse,
                            DeviceCode = smg.DeviceCode,
                            Plate      = itask.PlateNum,
                            AutoStep   = smg.RunStep,
                            Message    = myalarm.Description,
                            RcdTime    = DateTime.Now.ToString()
                        };

                        dicSmsRequest.Add(smg.DeviceCode, sms);
                    }

                    if (sms != null)
                    {
                        log.Info("发送短信 - " + sms.Message);

                        CloudCallback.Instance().SendSMSToCloud(sms);
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
            return(resp);
        }
Пример #18
0
        /// <summary>
        /// 查询临时用户费用
        /// </summary>
        public Response GetTempUserInfo(string iccode, bool isPlate)
        {
            Log        log    = LogFactory.GetLogger("CWTariff.GetTempUserInfo");
            Response   resp   = new Response();
            CWICCard   cwiccd = new CWICCard();
            CWLocation cwlctn = new CWLocation();

            try
            {
                Location     loc  = null;
                TempUserInfo info = new TempUserInfo();
                #region 暂不用
                //if (!isPlate)
                //{
                //    #region
                //    ICCard iccd = cwiccd.Find(ic=>ic.UserCode==iccode);
                //    if (iccd == null)
                //    {
                //        resp.Message = "不是本系统卡!";
                //        return resp;
                //    }
                //    if (iccd.CustID != 0)
                //    {
                //        Customer cust = cwiccd.FindCust(iccd.CustID);
                //        if (cust != null)
                //        {
                //            if (cust.Type != EnmICCardType.Temp)
                //            {
                //                resp.Message = "该用户不是临时用户!";
                //                return resp;
                //            }
                //        }
                //    }
                //    loc = cwlctn.FindLocation(lc=>lc.ICCode==iccode);
                //    if (loc == null)
                //    {
                //        resp.Message = "当前卡号没有存车!";
                //        return resp;
                //    }
                //    #endregion
                //}
                //else
                //{
                //    #region
                //    loc = cwlctn.FindLocation(l=>l.PlateNum==iccode);
                //    if (loc == null)
                //    {
                //        resp.Message = "当前输入车牌没有存车!";
                //        return resp;
                //    }
                //    string proof = loc.ICCode;
                //    Customer cust = null;
                //    #region
                //    if (Convert.ToInt32(proof) >= 10000) //是指纹激活的
                //    {
                //        int sno = Convert.ToInt32(proof);
                //        FingerPrint print = new CWFingerPrint().Find(p => p.SN_Number == sno);
                //        if (print == null)
                //        {
                //            //上位控制系统故障
                //            resp.Message = "找不到注册指纹,系统异常!";
                //            return resp;
                //        }
                //        cust = new CWICCard().FindCust(print.CustID);
                //        if (cust == null)
                //        {
                //            //上位控制系统故障
                //            resp.Message = "指纹没有绑定用户,系统异常!";
                //            return resp;
                //        }
                //    }
                //    else
                //    {
                //        ICCard iccd = new CWICCard().Find(ic => ic.UserCode == proof);
                //        if (iccd == null)
                //        {
                //            //上位控制系统故障
                //            resp.Message = "上位控制系统异常,找不到卡号!";
                //            return resp;
                //        }
                //        if (iccd.CustID != 0)
                //        {
                //            cust = new CWICCard().FindCust(iccd.CustID);
                //        }
                //    }
                //    #endregion
                //    if (cust != null)
                //    {
                //        if (cust.Type != EnmICCardType.Temp)
                //        {
                //            resp.Message = "该用户不是临时用户!";
                //            return resp;
                //        }
                //    }
                //    #endregion
                //}
                #endregion
                if (isPlate)
                {
                    //是车牌
                    loc = cwlctn.FindLocation(l => l.PlateNum == iccode);
                }
                else
                {
                    loc = cwlctn.FindLocation(l => l.ICCode == iccode);
                }
                if (loc == null)
                {
                    resp.Message = "当前车牌没有存车!Proof - " + iccode;
                    return(resp);
                }
                int             sno   = Convert.ToInt32(loc.ICCode);
                SaveCertificate scert = new CWSaveProof().Find(s => s.SNO == sno);
                if (scert != null)
                {
                    Customer cust = new CWICCard().FindCust(scert.CustID);
                    if (cust != null)
                    {
                        if (cust.Type != EnmICCardType.Temp)
                        {
                            resp.Message = "该用户不是临时用户!";
                            return(resp);
                        }
                    }
                }

                CWTask        cwtask = new CWTask();
                ImplementTask itask  = cwtask.FindITask(tk => tk.ICCardCode == loc.ICCode && tk.IsComplete == 0);
                if (itask != null)
                {
                    resp.Message = "正在作业,无法查询!";
                    return(resp);
                }
                WorkTask queue = cwtask.FindQueue(q => q.ICCardCode == loc.ICCode);
                if (queue != null)
                {
                    resp.Message = "已经加入取车队列,无法查询!";
                    return(resp);
                }

                info.CCode   = iccode;
                info.InDate  = loc.InDate.ToString();
                info.OutDate = DateTime.Now.ToString();
                TimeSpan span = DateTime.Now - loc.InDate;
                info.SpanTime = (span.Days > 0 ? span.Days + "天" : " ") + (span.Hours > 0 ? span.Hours + "小时" : " ") +
                                (span.Minutes >= 0 ? span.Minutes + "分" : " ") + (span.Seconds >= 0 ? span.Seconds + "秒" : " ");
                float fee = 0;
                resp = this.CalculateTempFee(loc.InDate, DateTime.Now, out fee);
                if (resp.Code == 0)
                {
                    return(resp);
                }
                info.NeedFee   = fee.ToString();
                info.Warehouse = loc.Warehouse;

                int hallID = new CWDevice().AllocateHall(loc, false);
                info.HallID = hallID;

                resp.Code    = 1;
                resp.Message = "查询成功";
                resp.Data    = info;
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
            return(resp);
        }
Пример #19
0
        /// <summary>
        /// 固定车位时,ETV分配
        /// </summary>
        /// <param name="hall">存车车厅</param>
        /// <param name="loc">目的车位</param>
        /// <returns></returns>
        public Device PXDAllocateEtvOfFixLoc(Device hall, Location loc)
        {
            CWDevice cwdevice = new CWDevice();
            CWTask   cwtask   = new CWTask();

            List <Device> nEtvList  = cwdevice.FindList(d => d.Type == EnmSMGType.ETV);
            WorkScope     workscope = new WorkScope(nEtvList);
            int           hallColmn = Convert.ToInt32(hall.Address.Substring(1, 2));
            int           locColmn  = loc.LocColumn;

            List <Device> availableLst = new List <Device>();

            #region 可达车厅、可达车位、可用的ETV集合
            foreach (Device dev in nEtvList)
            {
                if (dev.IsAble == 1)
                {
                    CScope scope = workscope.GetEtvScope(dev);
                    if (scope.LeftCol <= hallColmn && hallColmn <= scope.RightCol)
                    {
                        if (scope.LeftCol <= locColmn && locColmn <= scope.RightCol)
                        {
                            availableLst.Add(dev);
                        }
                    }
                }
            }
            #endregion
            if (availableLst.Count == 1)
            {
                return(availableLst[0]);
            }
            else if (availableLst.Count == 2)
            {
                List <Device> freeLst = availableLst.FindAll(d => d.TaskID == 0);
                if (freeLst.Count == 1)
                {
                    Device dev = freeLst[0];
                    if (dev.Region == hall.Region)
                    {
                        return(dev);
                    }
                    Device other = availableLst.FirstOrDefault(d => d.TaskID != 0);
                    if (other != null)
                    {
                        #region 另一ETV在忙,判断当前闲的ETV,是否可达车厅来装载,如果可以,则允许下发
                        ImplementTask task = cwtask.Find(other.TaskID);
                        if (task != null)
                        {
                            string toAddrs = "";
                            if (task.Status == EnmTaskStatus.TWaitforLoad ||
                                task.Status == EnmTaskStatus.TWaitforMove)
                            {
                                toAddrs = task.FromLctAddress;
                            }
                            else
                            {
                                toAddrs = task.ToLctAddress;
                            }
                            int toCol = Convert.ToInt32(toAddrs.Substring(1, 2));
                            //正在作业TV
                            int currCol = Convert.ToInt32(other.Address.Substring(1, 2));
                            //空闲TV
                            int freeCol = Convert.ToInt32(dev.Address.Substring(1, 2));

                            //空闲TV在右侧,即2号ETV空闲
                            if (currCol < freeCol)
                            {
                                #region TV2 空闲
                                if (hallColmn >= toCol + 3)
                                {
                                    //1#车厅不在范围内,则允许2#ETV动作
                                    return(dev);
                                }
                                #endregion
                            }
                            else
                            {
                                #region 1#TV 空闲
                                if (hallColmn <= toCol - 3)
                                {
                                    //2#车厅不在范围内,则允许1#ETV动作
                                    return(dev);
                                }
                                #endregion
                            }
                        }
                        #endregion
                    }
                }
                //有两个空闲或,两个忙时,都优先分配车厅所在区域的ETV
                List <Device> orderbyLst = availableLst.OrderBy(d => Math.Abs(d.Region - hall.Region)).ToList();
                return(orderbyLst[0]);
            }
            return(null);
        }
Пример #20
0
        /// <summary>
        /// 巷道堆垛临时卡车位分配
        /// </summary>
        /// <returns></returns>
        private Location PXDAllocate(Device hall, string checkCode, out int smg)
        {
            smg = 0;
            #region
            CWLocation cwlctn   = new CWLocation();
            CWDevice   cwdevice = new CWDevice();
            CWTask     cwtask   = new CWTask();
            CWICCard   cwiccd   = new CWICCard();

            List <Device> nEtvList  = cwdevice.FindList(d => d.Type == EnmSMGType.ETV);
            WorkScope     workscope = new WorkScope(nEtvList);
            int           hallColmn = Convert.ToInt32(hall.Address.Substring(1, 2));
            List <Device> reachHall = new List <Device>();
            #region 找出可达车厅、可用的ETV集合
            foreach (Device dev in nEtvList)
            {
                CScope scope = workscope.GetEtvScope(dev);
                if (scope.LeftCol <= hallColmn && hallColmn <= scope.RightCol)
                {
                    if (dev.IsAble == 1)
                    {
                        reachHall.Add(dev);
                    }
                }
            }
            #endregion

            List <Location> lctnLst = new List <Location>();
            #region 依距车厅的远近找出所有车位的集合
            List <Location> allLocLst  = cwlctn.FindLocList();
            List <Customer> fixCustLst = cwiccd.FindCustList(cu => cu.Type == EnmICCardType.FixedLocation || cu.Type == EnmICCardType.VIP);
            //排除固定车位
            allLocLst = allLocLst.FindAll(lc => fixCustLst.Exists(cc => cc.LocAddress == lc.Address && cc.Warehouse == lc.Warehouse) == false);

            #region 车位尺寸一致
            List <Location> sameLctnLst = new List <Location>();

            #region
            #region 首先 分配与车厅同一个区域的,车位尺寸一致的, 4-2-1依次排列,
            var L42_locList_small = from loc in allLocLst
                                    where loc.Type == EnmLocationType.Normal &&
                                    loc.Status == EnmLocationStatus.Space &&
                                    compareSize(loc.LocSize, checkCode) == 1 &&
                                    loc.LocSide != 1 &&
                                    loc.Region == hall.Region
                                    orderby Math.Abs(loc.LocColumn - hallColmn) ascending,
                loc.LocSide descending
            select loc;

            //1边
            var L1_locList_small = from loc in allLocLst
                                   where loc.Type == EnmLocationType.Normal &&
                                   loc.Status == EnmLocationStatus.Space &&
                                   compareSize(loc.LocSize, checkCode) == 1 &&
                                   loc.LocSide == 1 &&
                                   loc.Region == hall.Region
                                   orderby Math.Abs(loc.LocColumn - hallColmn) ascending
                                   select loc;

            #endregion
            sameLctnLst.AddRange(L42_locList_small);
            sameLctnLst.AddRange(L1_locList_small);

            #region 再次分配与车厅同一个区域,车位尺寸(仅宽度)偏大点的
            var L42_locList_width = from loc in allLocLst
                                    where loc.Type == EnmLocationType.Normal &&
                                    loc.Status == EnmLocationStatus.Space &&
                                    compareSize(loc.LocSize, checkCode) == 2 &&
                                    loc.LocSide != 1 &&
                                    loc.Region == hall.Region
                                    orderby Math.Abs(loc.LocColumn - hallColmn) ascending,
                loc.LocSide descending
            select loc;

            //1边
            var L1_locList_width = from loc in allLocLst
                                   where loc.Type == EnmLocationType.Normal &&
                                   loc.Status == EnmLocationStatus.Space &&
                                   compareSize(loc.LocSize, checkCode) == 2 &&
                                   loc.LocSide == 1 &&
                                   loc.Region == hall.Region
                                   orderby Math.Abs(loc.LocColumn - hallColmn) ascending
                                   select loc;

            #endregion
            sameLctnLst.AddRange(L42_locList_width);
            sameLctnLst.AddRange(L1_locList_width);

            #region 再分配与车厅不是同一个区域的
            //4边2边
            var L42_locList_small_dif = from loc in allLocLst
                                        where loc.Type == EnmLocationType.Normal &&
                                        loc.Status == EnmLocationStatus.Space &&
                                        compareSize(loc.LocSize, checkCode) == 1 &&
                                        loc.LocSide != 1 &&
                                        loc.Region != hall.Region
                                        orderby Math.Abs(loc.LocColumn - hallColmn) ascending,
                loc.LocSide descending
            select loc;

            //1边
            var L1_locList_small_dif = from loc in allLocLst
                                       where loc.Type == EnmLocationType.Normal &&
                                       loc.Status == EnmLocationStatus.Space &&
                                       compareSize(loc.LocSize, checkCode) == 1 &&
                                       loc.LocSide == 1 &&
                                       loc.Region != hall.Region
                                       orderby Math.Abs(loc.LocColumn - hallColmn) ascending
                                       select loc;

            #endregion
            sameLctnLst.AddRange(L42_locList_small_dif);
            sameLctnLst.AddRange(L1_locList_small_dif);

            #region 再次分配与车厅不同区域,车位尺寸(仅宽度)偏大点的
            var L42_locList_width_dif = from loc in allLocLst
                                        where loc.Type == EnmLocationType.Normal &&
                                        loc.Status == EnmLocationStatus.Space &&
                                        compareSize(loc.LocSize, checkCode) == 2 &&
                                        loc.LocSide != 1 &&
                                        loc.Region != hall.Region
                                        orderby Math.Abs(loc.LocColumn - hallColmn) ascending,
                loc.LocSide descending
            select loc;

            //1边
            var L1_locList_width_dif = from loc in allLocLst
                                       where loc.Type == EnmLocationType.Normal &&
                                       loc.Status == EnmLocationStatus.Space &&
                                       compareSize(loc.LocSize, checkCode) == 2 &&
                                       loc.LocSide == 1 &&
                                       loc.Region != hall.Region
                                       orderby Math.Abs(loc.LocColumn - hallColmn) ascending
                                       select loc;

            #endregion
            sameLctnLst.AddRange(L42_locList_width_dif);
            sameLctnLst.AddRange(L1_locList_width_dif);
            #endregion

            #region 如果是重列车位,优先分配前面车位是空闲的,其次是占用的,最后才是执行中的
            List <Location> spaceLctnLst  = new List <Location>();
            List <Location> occupyLctnLst = new List <Location>();
            List <Location> otherLctnLst  = new List <Location>();
            foreach (Location loc in sameLctnLst)
            {
                if (loc.LocSide == 4)
                {
                    #region 判断前面车位状态
                    string   fwdAddrs = "2" + loc.Address.Substring(1);
                    Location forward  = cwlctn.FindLocation(l => l.Address == fwdAddrs);
                    if (forward != null)
                    {
                        if (forward.Type == EnmLocationType.Normal)
                        {
                            if (forward.Status == EnmLocationStatus.Space)
                            {
                                spaceLctnLst.Add(loc);
                            }
                            else if (forward.Status == EnmLocationStatus.Occupy)
                            {
                                occupyLctnLst.Add(loc);
                            }
                            else
                            {
                                otherLctnLst.Add(loc);
                            }
                        }
                    }
                    #endregion
                }
                else if (loc.LocSide == 2)
                {
                    #region 判断后面车位状态
                    string   bckAddrs = "4" + loc.Address.Substring(1);
                    Location back     = cwlctn.FindLocation(l => l.Address == bckAddrs);
                    if (back != null)
                    {
                        if (back.Type == EnmLocationType.Normal)
                        {
                            if (back.Status == EnmLocationStatus.Space)
                            {
                                spaceLctnLst.Add(loc);
                            }
                            else if (back.Status == EnmLocationStatus.Occupy)
                            {
                                occupyLctnLst.Add(loc);
                            }
                            else
                            {
                                otherLctnLst.Add(loc);
                            }
                        }
                        else //禁用的
                        {
                            spaceLctnLst.Add(loc);
                        }
                    }

                    #endregion
                }
                else
                {
                    spaceLctnLst.Add(loc);
                }
            }
            lctnLst.AddRange(spaceLctnLst);
            lctnLst.AddRange(occupyLctnLst);
            lctnLst.AddRange(otherLctnLst);
            #endregion

            #endregion

            #region 车位尺寸是大的
            List <Location> bigLctnLst = new List <Location>();

            #region
            #region 首先 分配与车厅同一个区域的,车位尺寸一致的, 4-2-1依次排列,
            var L42_locList_big = from loc in allLocLst
                                  where loc.Type == EnmLocationType.Normal &&
                                  loc.Status == EnmLocationStatus.Space &&
                                  compareSize(loc.LocSize, checkCode) == 3 &&
                                  loc.LocSide != 1 &&
                                  loc.Region == hall.Region
                                  orderby Math.Abs(loc.LocColumn - hallColmn) ascending,
                loc.LocSide descending
            select loc;

            //1边
            var L1_locList_big = from loc in allLocLst
                                 where loc.Type == EnmLocationType.Normal &&
                                 loc.Status == EnmLocationStatus.Space &&
                                 compareSize(loc.LocSize, checkCode) == 3 &&
                                 loc.LocSide == 1 &&
                                 loc.Region == hall.Region
                                 orderby Math.Abs(loc.LocColumn - hallColmn) ascending
                                 select loc;

            #endregion
            bigLctnLst.AddRange(L42_locList_big);
            bigLctnLst.AddRange(L1_locList_big);

            #region 再分配与车厅不是同一个区域的
            var L42_locList_big_dif = from loc in allLocLst
                                      where loc.Type == EnmLocationType.Normal &&
                                      loc.Status == EnmLocationStatus.Space &&
                                      compareSize(loc.LocSize, checkCode) == 3 &&
                                      loc.LocSide != 1 &&
                                      loc.Region != hall.Region
                                      orderby Math.Abs(loc.LocColumn - hallColmn) ascending,
                loc.LocSide descending
            select loc;

            //1边
            var L1_locList_big_dif = from loc in allLocLst
                                     where loc.Type == EnmLocationType.Normal &&
                                     loc.Status == EnmLocationStatus.Space &&
                                     compareSize(loc.LocSize, checkCode) == 3 &&
                                     loc.LocSide == 1 &&
                                     loc.Region != hall.Region
                                     orderby Math.Abs(loc.LocColumn - hallColmn) ascending
                                     select loc;

            #endregion
            bigLctnLst.AddRange(L42_locList_big_dif);
            bigLctnLst.AddRange(L1_locList_big_dif);

            #endregion

            #region 如果是重列车位,优先分配前面车位是空闲的,其次是占用的,最后才是执行中的
            List <Location> spaceLctnLst_big  = new List <Location>();
            List <Location> occupyLctnLst_big = new List <Location>();
            List <Location> otherLctnLst_big  = new List <Location>();
            foreach (Location loc in bigLctnLst)
            {
                if (loc.LocSide == 4)
                {
                    #region 判断前面车位状态
                    string   fwdAddrs = "2" + loc.Address.Substring(1);
                    Location forward  = cwlctn.FindLocation(l => l.Address == fwdAddrs);
                    if (forward != null)
                    {
                        if (forward.Type == EnmLocationType.Normal)
                        {
                            if (forward.Status == EnmLocationStatus.Space)
                            {
                                spaceLctnLst_big.Add(loc);
                            }
                            else if (forward.Status == EnmLocationStatus.Occupy)
                            {
                                occupyLctnLst_big.Add(loc);
                            }
                            else
                            {
                                otherLctnLst_big.Add(loc);
                            }
                        }
                    }
                    #endregion
                }
                else if (loc.LocSide == 2)
                {
                    #region 判断后面车位状态
                    string   bckAddrs = "4" + loc.Address.Substring(1);
                    Location back     = cwlctn.FindLocation(l => l.Address == bckAddrs);
                    if (back != null)
                    {
                        if (back.Type == EnmLocationType.Normal)
                        {
                            if (back.Status == EnmLocationStatus.Space)
                            {
                                spaceLctnLst_big.Add(loc);
                            }
                            else if (back.Status == EnmLocationStatus.Occupy)
                            {
                                occupyLctnLst_big.Add(loc);
                            }
                            else
                            {
                                otherLctnLst_big.Add(loc);
                            }
                        }
                        else //禁用的
                        {
                            spaceLctnLst_big.Add(loc);
                        }
                    }

                    #endregion
                }
                else
                {
                    spaceLctnLst_big.Add(loc);
                }
            }
            lctnLst.AddRange(spaceLctnLst_big);
            lctnLst.AddRange(occupyLctnLst_big);
            lctnLst.AddRange(otherLctnLst_big);
            #endregion

            #endregion
            #endregion
            if (reachHall.Count == 1)
            {
                CScope scope = workscope.GetEtvScope(reachHall[0]);
                //只要一个ETV可达车厅,
                //依作业范围,找出在TV范围内的车位
                foreach (Location loc in lctnLst)
                {
                    if (scope.LeftCol <= loc.LocColumn && loc.LocColumn <= scope.RightCol)
                    {
                        smg = reachHall[0].DeviceCode;
                        return(loc);
                    }
                }
            }
            else if (reachHall.Count == 2)
            {
                //如果有两个空闲的
                List <Device> freeEtvs = reachHall.FindAll(ch => ch.TaskID == 0);
                if (freeEtvs.Count == 2)
                {
                    #region
                    freeEtvs = reachHall.OrderBy(h => Math.Abs(h.Region - hall.Region)).ToList();
                    foreach (Device dev in freeEtvs)
                    {
                        CScope scope = workscope.GetEtvScope(dev);
                        foreach (Location loc in lctnLst)
                        {
                            if (scope.LeftCol <= loc.LocColumn && loc.LocColumn <= scope.RightCol)
                            {
                                smg = dev.DeviceCode;
                                return(loc);
                            }
                        }
                    }
                    #endregion
                }
                else if (freeEtvs.Count == 1)
                {
                    #region
                    Device dev = freeEtvs[0];
                    if (dev.Region == hall.Region)
                    {
                        #region
                        smg = dev.DeviceCode;
                        CScope scope = workscope.GetEtvScope(dev);
                        foreach (Location loc in lctnLst)
                        {
                            if (scope.LeftCol <= loc.LocColumn && loc.LocColumn <= scope.RightCol)
                            {
                                return(loc);
                            }
                        }
                        #endregion
                    }
                    else
                    {
                        #region
                        //如果不是同一区域的
                        //判断另一个ETV在执行什么样的动作,
                        //另一台ETV要不要跨区作业
                        Device other = reachHall.Find(h => h.DeviceCode != dev.DeviceCode);
                        if (other.TaskID != 0)
                        {
                            ImplementTask task = cwtask.Find(other.TaskID);
                            if (task != null)
                            {
                                string toAddrs = "";
                                if (task.Status == EnmTaskStatus.TWaitforLoad ||
                                    task.Status == EnmTaskStatus.TWaitforMove)
                                {
                                    toAddrs = task.FromLctAddress;
                                }
                                else
                                {
                                    toAddrs = task.ToLctAddress;
                                }
                                int toCol = Convert.ToInt32(toAddrs.Substring(1, 2));
                                //正在作业TV
                                int currCol = Convert.ToInt32(other.Address.Substring(1, 2));
                                //空闲TV
                                int freeCol = Convert.ToInt32(dev.Address.Substring(1, 2));

                                //空闲TV在右侧,即2号ETV空闲
                                if (currCol < freeCol)
                                {
                                    #region TV2空闲
                                    if (hallColmn >= toCol + 3)
                                    {
                                        //1#车厅不在范围内,则允许2#ETV动作
                                        smg = dev.DeviceCode;
                                        CScope scope = workscope.GetEtvScope(dev);
                                        foreach (Location loc in lctnLst)
                                        {
                                            if (scope.LeftCol <= loc.LocColumn && loc.LocColumn <= scope.RightCol)
                                            {
                                                return(loc);
                                            }
                                        }
                                    }
                                    #endregion
                                }
                                else
                                {
                                    #region 1#TV空闲
                                    if (hallColmn <= toCol - 3)
                                    {
                                        //2#车厅不在范围内,则允许1#ETV动作
                                        smg = dev.DeviceCode;
                                        CScope scope = workscope.GetEtvScope(dev);
                                        foreach (Location loc in lctnLst)
                                        {
                                            if (scope.LeftCol <= loc.LocColumn && loc.LocColumn <= scope.RightCol)
                                            {
                                                return(loc);
                                            }
                                        }
                                    }
                                    #endregion
                                }
                            }
                        }
                        #endregion
                    }
                    #endregion
                }
                List <Device> orderbyEtvs = reachHall.OrderBy(dr => Math.Abs(dr.Region - hall.Region)).ToList();
                #region 两个都在忙或上述找不到时,则依车厅区域内的ETV优先,分配ETV
                foreach (Device devc in orderbyEtvs)
                {
                    CScope scope = workscope.GetEtvScope(devc);
                    foreach (Location loc in lctnLst)
                    {
                        if (scope.LeftCol <= loc.LocColumn && loc.LocColumn <= scope.RightCol)
                        {
                            smg = devc.DeviceCode;
                            return(loc);
                        }
                    }
                }

                #endregion
            }
            #endregion
            return(null);
        }
Пример #21
0
        /// <summary>
        /// APP,扫码或其它存车,
        /// </summary>
        /// <returns></returns>
        public ActionResult SaveCarInterface()
        {
            Response resp = new Response();

            #region
            Log log = LogFactory.GetLogger("SaveCarInterface");
            try
            {
                byte[] bytes = new byte[Request.InputStream.Length];
                Request.InputStream.Read(bytes, 0, bytes.Length);
                string req = System.Text.Encoding.UTF8.GetString(bytes);
                //显示,记录
                log.Info(req);
                JObject jo = (JObject)JsonConvert.DeserializeObject(req);

                string warehouse = jo["warehouse"].ToString();
                string hallID    = jo["hallID"].ToString();
                string iccode    = jo["iccode"].ToString();
                string plate     = jo["plateNum"].ToString();

                if (string.IsNullOrEmpty(hallID))
                {
                    log.Error("APP存车,hallID为空!");
                    resp.Message = "参数错误,hallID为空!";
                    return(Json(resp));
                }
                if (string.IsNullOrEmpty(plate))
                {
                    log.Error("APP存车,车牌号为空!");
                    resp.Message = "参数错误,车牌号为空!";
                    return(Json(resp));
                }

                int wh   = 1;
                int code = Convert.ToInt32(hallID);

                CWDevice cwdevice = new CWDevice();
                CWTask   motsk    = new CWTask();

                Device moHall = cwdevice.Find(dev => dev.Warehouse == wh && dev.DeviceCode == code);
                if (moHall == null)
                {
                    log.Error("APP存车时, 找不到车厅设备. warehouse - " + warehouse + " ,hallID - " + hallID);
                    resp.Message = "找不到车厅";
                    return(Json(resp));
                }
                if (moHall.Mode != EnmModel.Automatic)
                {
                    log.Error("APP存车时, 车厅不是全自动. warehouse - " + warehouse + " ,hallID - " + hallID);
                    resp.Message = "车厅不是全自动";
                    return(Json(resp));
                }
                if (moHall.HallType == EnmHallType.Entrance ||
                    moHall.HallType == EnmHallType.EnterOrExit)
                {
                    if (moHall.TaskID == 0)
                    {
                        //车厅无车,不能存车
                        log.Error("APP存车时, 车厅无车,不能存车. ");
                        resp.Message = "车厅无车,不能存车";
                        return(Json(resp));
                    }
                    ImplementTask tsk = motsk.Find(moHall.TaskID);
                    if (tsk == null)
                    {
                        log.Error("APP存车时, 依车厅TaskID找不到作业信息,TaskID-" + moHall.TaskID + "  hallCode-" + moHall.DeviceCode);
                        //系统故障
                        resp.Message = "系统异常,找不到作业";
                        return(Json(resp));
                    }
                    if (tsk.Status != EnmTaskStatus.ICarInWaitFirstSwipeCard &&
                        tsk.Status != EnmTaskStatus.TempOCarOutWaitforDrive)
                    {
                        log.Error("APP存车时,不是处于刷卡阶段");
                        resp.Message = "不是处于刷卡阶段";
                        return(Json(resp));
                    }
                    if (tsk.PlateNum != plate)
                    {
                        log.Error("APP存车时,入库识别车牌与给定车牌不一致");
                        resp.Message = "APP绑定车牌与车辆车牌不一致";
                        return(Json(resp));
                    }

                    CWICCard cwiccd = new CWICCard();

                    if (tsk.Type == EnmTaskType.SaveCar)
                    {
                        string   physiccode = "1234567890";
                        Customer cust       = cwiccd.FindCust(cc => cc.PlateNum == plate);
                        if (cust != null)
                        {
                            ICCard iccd = cwiccd.Find(ic => ic.CustID == cust.ID);
                            if (iccd != null)
                            {
                                iccode     = iccd.UserCode;
                                physiccode = iccd.PhysicCode;
                            }
                        }
                        CWSaveProof cwsaveproof = new CWSaveProof();
                        if (string.IsNullOrEmpty(iccode))
                        {
                            iccode = cwsaveproof.GetMaxSNO().ToString();
                        }

                        SaveCertificate scert = new SaveCertificate();
                        scert.IsFingerPrint = 2;
                        scert.Proof         = physiccode;
                        scert.SNO           = Convert.ToInt32(iccode);
                        //添加凭证到存车库中
                        Response respe = cwsaveproof.Add(scert);

                        tsk.PlateNum = plate;
                        //更新作业状态为第二次刷卡,启动流程
                        motsk.DealISwipedSecondCard(tsk, iccode);

                        resp.Code    = 1;
                        resp.Message = "流程进行中";
                        return(Json(resp));
                    }
                    else if (tsk.Type == EnmTaskType.TempGet)
                    {
                        motsk.DealAPPSwipeThreeCard(tsk);
                    }
                }
                else
                {
                    log.Error("APP存车时,不是进(进出)车厅");
                    resp.Message = "不是进(进出)车厅";
                    return(Json(resp));
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                resp.Message = "系统异常";
            }
            #endregion
            return(Json(resp));
        }