public ActionResult Get(List <CollectorData> list)
        {
            List <OvenCurrentData> ovenCurrentDatas = new List <OvenCurrentData>();
            List <OvenHistoryData> ovenHistoryDatas = new List <OvenHistoryData>();
            List <OvenInfo>        ovenInfos        = _ovenInfoService.Queryable().ToList();

            if (list != null)
            {
                //遍历接收的数据队列
                foreach (CollectorData collectorData in list)
                {
                    OvenInfo ovenInfo = ovenInfos
                                        .Where(x => x.collector_port == collectorData.Com)
                                        .FirstOrDefault();
                    //这边需要加一个开启专案的判定
                    //只有配置过的端口才会接收
                    if (ovenInfo != null)
                    {
                        OvenCurrentData ovenCurrentData = new OvenCurrentData();
                        OvenHistoryData ovenHistoryData = new OvenHistoryData();
                        ovenCurrentData.door_state  = collectorData.DoorState;
                        ovenCurrentData.oven_id     = ovenInfo.id;
                        ovenCurrentData.dam_state   = collectorData.DAMState;
                        ovenCurrentData.port        = collectorData.Com;
                        ovenCurrentData.tc_state    = collectorData.TC;
                        ovenCurrentData.point1      = collectorData.tmp1;
                        ovenCurrentData.point2      = collectorData.tmp2;
                        ovenCurrentData.point3      = collectorData.tmp3;
                        ovenCurrentData.point4      = collectorData.tmp4;
                        ovenCurrentData.point5      = collectorData.tmp5;
                        ovenCurrentData.point6      = collectorData.tmp6;
                        ovenCurrentData.oven_state  = collectorData.Oventate;
                        ovenCurrentData.update_time = DateTime.Now;
                        ovenCurrentDatas.Add(ovenCurrentData);


                        ovenHistoryData.oven_id     = ovenInfo.id;
                        ovenHistoryData.point1      = collectorData.tmp1;
                        ovenHistoryData.point2      = collectorData.tmp2;
                        ovenHistoryData.point3      = collectorData.tmp3;
                        ovenHistoryData.point4      = collectorData.tmp4;
                        ovenHistoryData.point5      = collectorData.tmp5;
                        ovenHistoryData.point6      = collectorData.tmp6;
                        ovenHistoryData.insert_time = DateTime.Now;
                        ovenHistoryDatas.Add(ovenHistoryData);
                    }
                    else
                    {
                        return(Json(false));
                    }
                }
                _ovenCurrentDataService.Saveable(ovenCurrentDatas);
                _ovenHistoryDataService.Insert(ovenHistoryDatas);
            }
            return(Json(true));
        }
Exemplo n.º 2
0
        public IActionResult GetProjectInfo()
        {
            List <Entity.ProjectInfo> projectInfos = _projectInfoService.Queryable().ToList();
            List <OvenInfo>           ovenInfos    = _ovenInfoService.Queryable().ToList();
            var ft = from a in projectInfos
                     join b in ovenInfos on a.oven_id equals b.id
                     select new
            {
                id             = a.id,
                name           = a.name,
                oven_name      = b.oven_name,
                project_status = a.project_status,
                start_time     = a.start_time,
                end_time       = a.end_time
            };

            return(Json(ft));
        }
        public IActionResult GetCurrentData()
        {
            //第一步 查询所有创建的烤炉
            List <OvenInfo> ovenInfos = _ovenInfoService.Queryable().ToList();
            //第二步 查看所有专案信息
            List <ProjectInfo> projectInfos = _projectInfoService.Queryable().ToList();
            //第三步 查看实时数据
            List <OvenCurrentData> ovenCurrentDatas = _ovenCurrentDataService.Queryable().ToList();

            if (ovenInfos != null)
            {
                var cd = from a in ovenInfos
                         join b in ovenCurrentDatas on a.id equals b.oven_id into ab
                         //from c in ab.DefaultIfEmpty(new OvenCurrentData())
                         join d in projectInfos on a.id equals d.oven_id into ad
                         from e in ab.DefaultIfEmpty(new OvenCurrentData())
                         from f in ad.DefaultIfEmpty(new ProjectInfo())

                         select new
                {
                    id             = a.id,
                    name           = a.oven_name,
                    p1             = e.point1,
                    p2             = e.point2,
                    p3             = e.point3,
                    p4             = e.point4,
                    p5             = e.point5,
                    p6             = e.point6,
                    dam_state      = e.dam_state,
                    door_state     = e.door_state,
                    tc             = e.tc_state,
                    oven_state     = e.oven_state,
                    project_status = f.project_status
                };
                return(Json(cd));
            }
            return(Json(null));
        }
        /// <summary>
        /// 获取所有烤炉信息
        /// </summary>
        /// <returns></returns>
        public IActionResult GetOvenInfo()
        {
            List <OvenInfo> list = _ovenInfoService.Queryable().ToList();

            return(Json(list));
        }