Exemple #1
0
        /// <summary>
        /// 明细数据提取
        /// </summary>
        /// <param name="eDCTime">采集时间</param>
        /// <param name="itemCode">项目代码</param>
        /// <param name="lineCode">线别</param>
        /// <param name="equipmentCode">设备代码</param>
        /// <param name="locationName">车间</param>
        /// <returns></returns>
        public async Task <ActionResult> Detail(DateTime eDCTime, string itemCode, string lineCode, string equipmentCode, string locationName)
        {
            MethodReturnResult result = new MethodReturnResult();

            try
            {
                //参数模型
                DataAcquisitionDataViewModel model = new DataAcquisitionDataViewModel()
                {
                    EDCTime           = eDCTime,
                    ItemCode          = itemCode,
                    ViewLineCode      = lineCode,
                    ViewEquipmentCode = equipmentCode
                };

                await Task.Run(() =>
                {
                    result = GetDataAcquisitionData(eDCTime, itemCode, lineCode, equipmentCode, locationName, ref model);
                });

                if (result.Code > 0)
                {
                    return(Json(result));
                }
                else
                {
                    return(PartialView("_InfoPartial", model));
                }
            }
            catch (Exception e)
            {
                result.Code    = 1002;
                result.Message = e.Message;
                result.Detail  = e.ToString();
            }

            return(Json(result));
        }
Exemple #2
0
        public async Task <ActionResult> SaveModify(DataAcquisitionDataViewModel model)
        {
            MethodReturnResult result = new MethodReturnResult();

            try
            {
                string itemCode = model.ItemCode;

                IList <DataAcquisitionData> lstVal = new List <DataAcquisitionData>();

                //取得字段列表
                using (DataAcquisitionFieldServiceClient client = new DataAcquisitionFieldServiceClient())
                {
                    await Task.Run(() =>
                    {
                        string where = string.Format("Key.ItemCode = '{0}'", itemCode);

                        //取得字段列表
                        PagingConfig cfg = new PagingConfig()
                        {
                            IsPaging = false,
                            OrderBy  = "Key.ItemCode,SerialNumber",
                            Where    = where
                        };

                        MethodReturnResult <IList <DataAcquisitionField> > resultField = client.Get(ref cfg);

                        if (resultField.Code > 0)
                        {
                            result.Code    = resultField.Code;
                            result.Message = resultField.Message;
                            result.Detail  = resultField.Detail;
                        }
                        else
                        {
                            DateTime now = DateTime.Now;

                            foreach (DataAcquisitionField field in resultField.Data)
                            {
                                string fieldValue = Request[field.Key.FieldCode] ?? string.Empty;

                                DataAcquisitionData val = new DataAcquisitionData()
                                {
                                    Key = new DataAcquisitionDataKey()
                                    {
                                        EDCTime       = model.EDCTime,
                                        ItemCode      = model.ItemCode,
                                        FieldCode     = field.Key.FieldCode,
                                        LineCode      = model.ViewLineCode,
                                        EquipmentCode = model.ViewEquipmentCode,
                                        LocationName  = ""
                                    },
                                    DataValue  = fieldValue.Split(',')[0],
                                    CreateTime = model.CreateTime,
                                    Creator    = model.Creator,
                                    AuditTime  = model.AuditTime,
                                    Auditor    = model.Auditor ?? string.Empty,
                                    EditTime   = now,
                                    Editor     = User.Identity.Name
                                };

                                lstVal.Add(val);
                            }
                        }
                    });

                    if (result.Code == 0)
                    {
                        using (DataAcquisitionDataServiceClient dataclient = new DataAcquisitionDataServiceClient())
                        {
                            result = await dataclient.ModifyAsync(lstVal);

                            if (result.Code == 0)
                            {
                                result.Message = string.Format(StringResource.DataAcquisitionData_Save_Success);
                            }
                        }
                    }

                    return(Json(result));
                }
            }
            catch (Exception e)
            {
                result.Code    = 1002;
                result.Message = e.Message;
                result.Detail  = e.ToString();
            }

            return(Json(result));
        }
Exemple #3
0
        /// <summary>
        /// 取得采集数据信息
        /// </summary>
        /// <param name="eDCTime">采集时间</param>
        /// <param name="itemCode">项目代码</param>
        /// <param name="lineCode">线别</param>
        /// <param name="equipmentCode">设备代码</param>
        /// <param name="locationName">车间</param>
        /// <param name="routeStepName">返回项目工序</param>
        /// <returns></returns>
        private MethodReturnResult GetDataAcquisitionData(DateTime eDCTime, string itemCode, string lineCode, string equipmentCode, string locationName, ref DataAcquisitionDataViewModel model)
        {
            MethodReturnResult result = new MethodReturnResult();

            try
            {
                string where = "";

                //取得项目信息
                using (DataAcquisitionItemServiceClient client = new DataAcquisitionItemServiceClient())
                {
                    MethodReturnResult <DataAcquisitionItem> resultItem = client.Get(itemCode);

                    if (result.Code == 0)
                    {
                        //采集项目
                        ViewBag.DataAcquisitionItem = resultItem.Data;

                        //返回采集项目工序
                        model.ViewRouteOperationName = resultItem.Data.RouteStepName;
                    }
                }

                //取得字段列表
                using (DataAcquisitionFieldServiceClient client = new DataAcquisitionFieldServiceClient())
                {
                    where = string.Format("Key.ItemCode = '{0}'", itemCode);

                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        OrderBy  = "Key.ItemCode,SerialNumber",
                        Where    = where
                    };

                    MethodReturnResult <IList <DataAcquisitionField> > resultField = client.Get(ref cfg);

                    if (resultField.Code == 0)
                    {
                        //采集字段数据
                        ViewBag.DataAcquisitionFieldList = resultField.Data;
                    }
                }

                using (DataAcquisitionDataServiceClient client = new DataAcquisitionDataServiceClient())
                {
                    //取得采集数据
                    where = string.Format("Key.EDCTime = '{0}' AND Key.ItemCode = '{1}' AND Key.LineCode = '{2}' AND Key.EquipmentCode = '{3}' AND Key.LocationName = '{4}'"
                                          , eDCTime
                                          , itemCode
                                          , lineCode
                                          , equipmentCode
                                          , locationName);

                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        Where    = where
                    };

                    MethodReturnResult <IList <DataAcquisitionData> > resultdata = client.Get(ref cfg);

                    if (resultdata.Code > 0)
                    {
                        result.Code    = resultdata.Code;
                        result.Message = resultdata.Message;
                        result.Detail  = resultdata.Detail;

                        return(result);
                    }

                    model.Creator    = resultdata.Data[0].Creator;          //创建人
                    model.CreateTime = resultdata.Data[0].CreateTime;       //创建日期
                    model.Auditor    = resultdata.Data[0].Auditor;          //审核人
                    model.AuditTime  = resultdata.Data[0].AuditTime;        //审核日期

                    ViewBag.DataAcquisitionDataList = resultdata.Data;
                }
            }
            catch (Exception e)
            {
                result.Code    = 1002;
                result.Message = e.Message;
                result.Detail  = e.ToString();
            }

            return(result);
        }