コード例 #1
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void AppSaveForm(string keyValue, SafeworkcontrolEntity entity)
 {
     try
     {
         service.AppSaveForm(keyValue, entity);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
コード例 #2
0
        /// <summary>
        /// 获取电子围栏内所有摄像头信息
        /// </summary>
        public string GetElectricFenceCameraList(SafeworkcontrolEntity data)
        {
            string ComerId = string.Empty;

            try
            {
                //三维监控点位服务接口地址
                DataItemDetailBLL pdata   = new DataItemDetailBLL();
                var             ThreeDApi = pdata.GetItemValue("kbsThreeMonitoringPoints");
                space           sp        = new space();
                spacedata       sds       = new spacedata();
                List <spacegeo> geolist   = new List <spacegeo>();
                List <spacepnt> pntlist   = new List <spacepnt>();
                var             comList   = new KbscameramanageBLL().GetPageList("").Where(a => a.State == "在线" && a.CameraType == "枪机" && a.MonitoringArea != null).ToList();
                spacegeo        geo       = new spacegeo();
                geo.id = data.ID;
                if (data.Areacode != null)
                {//电子围栏坐标点
                    PositionsEntity alist = JsonConvert.DeserializeObject <PositionsEntity>(data.Areacode);
                    List <double>   dlist = new List <double>();
                    if (data.Areastate == 0)
                    {//矩形
                        geo.type     = 1;
                        geo.distance = 0;
                        //第一个点
                        dlist.Add(alist.positions[0].x);
                        dlist.Add(alist.positions[0].z);
                        //第二个点
                        dlist.Add(alist.positions[1].x);
                        dlist.Add(alist.positions[0].z);
                        //第三个点
                        dlist.Add(alist.positions[1].x);
                        dlist.Add(alist.positions[1].z);
                        //第四个点
                        dlist.Add(alist.positions[0].x);
                        dlist.Add(alist.positions[1].z);
                        //回到原点
                        dlist.Add(alist.positions[0].x);
                        dlist.Add(alist.positions[0].z);
                        geo.coor = dlist;
                        geolist.Add(geo);
                    }
                    else if (data.Areastate == 1)
                    {//圆形
                        geo.type = 0;
                        dlist.Add(alist.positions[0].x);
                        dlist.Add(alist.positions[0].z);
                        geo.distance = Convert.ToInt32(data.Radius);
                        geo.coor     = dlist;
                        geolist.Add(geo);
                    }
                    else if (data.Areastate == 2)
                    {//手绘多边形
                        foreach (var ac in alist.positions)
                        {
                            dlist.Add(ac.x);
                            dlist.Add(ac.z);
                        }
                        //闭合回到原点
                        dlist.Add(alist.positions[0].x);
                        dlist.Add(alist.positions[0].z);
                        geo.coor     = dlist;
                        geo.type     = 1;
                        geo.distance = 0;
                        geolist.Add(geo);
                    }

                    foreach (var com in comList)
                    {//摄像头坐标点集
                        PositionsEntity alist1 = JsonConvert.DeserializeObject <PositionsEntity>(com.MonitoringArea);
                        if (alist1.floorID == alist.floorID)
                        {
                            List <double> dlist1 = new List <double>();
                            foreach (var ac in alist1.positions)
                            {
                                dlist1.Add(ac.x);
                                dlist1.Add(ac.z);
                            }
                            //闭合回到原点
                            dlist1.Add(alist1.positions[0].x);
                            dlist1.Add(alist1.positions[0].z);
                            spacepnt pnt = new spacepnt()
                            {
                                id   = com.CameraId,
                                x    = 0,
                                y    = 0,
                                coor = dlist1
                            };
                            pntlist.Add(pnt);
                        }
                    }
                }
                sds.geo = geolist;
                sds.pnt = pntlist;
                sp.type = "2";
                sp.data = sds;
                string          rtn = HttpUtillibKbs.HttpThreeDPost(ThreeDApi, JsonConvert.SerializeObject(sp));
                List <RtnSpace> rss = JsonConvert.DeserializeObject <List <RtnSpace> >(rtn);
                foreach (var item in rss)
                {
                    if (string.IsNullOrEmpty(item.pntId))
                    {
                        continue;
                    }
                    ComerId += item.pntId + ',';
                }
                return(ComerId);
            }
            catch (Exception er)
            {
                return(ComerId);
            }
        }
コード例 #3
0
        public ActionResult SaveForm(string keyValue, SafeworkcontrolEntity entity)
        {
            try
            {
                if (entity.State == 0)
                {//延期
                    var data = safeworkcontrolbll.GetEntity(keyValue);
                    if (data != null)
                    {
                        data.Planendtime = entity.Planendtime;
                        safeworkcontrolbll.AppSaveForm(keyValue, data);
                    }
                }
                else if (entity.State == 1)
                {//提交作业
                    entity.comerid        = GetElectricFenceCameraList(entity);
                    entity.Takeeffecttime = entity.Actualstarttime;
                    entity.Create();
                    safeworkcontrolbll.AppSaveForm(keyValue, entity);
                    //将现场工作信息同步到后台计算服务中
                    RabbitMQHelper rh = RabbitMQHelper.CreateInstance();
                    SendData       sd = new SendData();
                    sd.DataName     = "AddSafeworkcontrolEntity";
                    sd.EntityString = JsonConvert.SerializeObject(entity);
                    rh.SendMessage(JsonConvert.SerializeObject(sd));
                }

                else if (entity.State == 2)
                {//结束作业
                    var data = safeworkcontrolbll.GetEntity(keyValue);
                    if (data != null)
                    {
                        data.ActualEndTime = entity.ActualEndTime;
                        data.State         = entity.State;
                        data.Invalidtime   = entity.ActualEndTime;
                        safeworkcontrolbll.SaveForm(data.ID, data);
                        //通知三维删除对应预警信息
                        RabbitMQHelper rh   = RabbitMQHelper.CreateInstance();
                        var            list = safeworkcontrolbll.GetBatchWarningInfoList(data.ID);
                        if (list.Count > 0)
                        {
                            foreach (var item in list)
                            {
                                if (item.type == 0 && item.NoticeType != 2)
                                {//人员未到岗
                                    SendTDWarning(3, item.WarningContent, item.LiableId, item.BaseId, rh);
                                }
                                else if (item.type == 0 && item.NoticeType == 2)
                                {//非作业人员误闯
                                    SendTDWarning(4, item.WarningContent, item.LiableId, item.Remark, rh);
                                }
                            }
                            //将现场工作信息同步到后台计算服务中
                            SendData sd = new SendData();
                            sd.DataName     = "DelSafeworkcontrolEntity";
                            sd.EntityString = data.ID;
                            rh.SendMessage(JsonConvert.SerializeObject(sd));
                        }
                        else
                        {
                            //将现场工作信息同步到后台计算服务中
                            SendData sd = new SendData();
                            sd.DataName     = "DelSafeworkcontrolEntity";
                            sd.EntityString = data.ID;
                            rh.SendMessage(JsonConvert.SerializeObject(sd));
                        }
                    }
                }
                return(Success("操作成功。"));
            }
            catch (Exception ex)
            {
                return(Success("操作失败!"));
            }
        }