Ejemplo n.º 1
0
        public IActionResult Update([FromBody] error_config ec)
        {
            string msg      = "";
            string myurl1   = url + "api/v1/configuration/andon/error_config";
            var    typeList = CommonHelper <error_config> .Get(myurl1, HttpContext);

            var list = typeList.Where(p => p.id != ec.id);

            var lists = list.Any(p => p.machine_id == ec.machine_id && p.tag_type_sub_id == ec.tag_type_sub_id);

            if (lists == false)
            {
                string  myurl    = url + "api/v1/configuration/andon/error_config";
                var     postData = JsonConvert.SerializeObject(ec);
                string  result   = PutUrl(myurl, postData);
                JObject jo       = (JObject)JsonConvert.DeserializeObject(result);
                switch (Convert.ToInt32(jo["code"]))
                {
                case 200:
                    msg = "Success";
                    break;

                case 400:
                    msg = "fail";
                    break;
                }
            }
            else
            {
                msg = "fail";
            }
            return(Json(msg));
        }
        /// <summary>
        /// 根据异常log记录加载所有信息.初始化加载和web页面确认使用
        /// </summary>
        /// <param name="eLogObject">error_log对象</param>
        /// <param name="unit_no">制程工序</param>
        /// <param name="line_id">线别id</param>
        /// <returns></returns>
        public ErrorObject LoadErrorLogObject(error_log eLogObject, error_config eCfgObject = null)
        {
            ErrorObject errorObject = new ErrorObject();

            errorObject.ELog = eLogObject;
            if (eCfgObject == null)
            {
                errorObject.eConfig = errorConfigManager.GetFirstErrorConfig(eLogObject.system_tag_code, eLogObject.unit_no, eLogObject.line_id);
                if (errorObject.eConfig == null) //未查询到,同时line非0,则以制程查询尝试
                {
                    errorObject.eConfig = errorConfigManager.GetFirstErrorConfig(eLogObject.system_tag_code, eLogObject.unit_no);
                }
            }
            else
            {
                errorObject.eConfig = eCfgObject;
            }

            if (errorObject.eConfig != null)
            {
                errorObject.eCfgPersonList = errorPersonManager.GetCfgPersonList(errorObject.eConfig.id);  //需通知的配置人员加载

                List <error_config_pn> eCfgPns = errorConfigPnManager.GetCfgPns(errorObject.eConfig.id);
                errorObject.eCfgPnList = eCfgPns;          //关联的机种信息加载
                //已通知人员加载
                errorObject.eMsgedPersonList = errorPersonManager.GetErrorLogPersonList(errorObject.ELog.id);
            }

            return(errorObject);
        }
Ejemplo n.º 3
0
        public IActionResult Delete([FromBody] error_config ec)
        {
            string  myurl  = url + "api/v1/configuration/andon/error_config?id=" + ec.id.ToString();
            string  result = DeleteUrl(myurl);
            JObject jo     = (JObject)JsonConvert.DeserializeObject(result);

            switch (Convert.ToInt32(jo["code"]))
            {
            case 200:
                Json("Success");
                break;

            case 400:
                break;

            case 410:
                break;

            case 411:
                break;

            default:
                break;
            }
            return(Json("Success"));
        }
        /// <summary>
        /// 获取指定配置
        /// </summary>
        /// <param name="system_tag_code">系统标签类型</param>
        /// <param name="unit_no">制程</param>
        /// <param name="line_id">线别,=-1则不启用</param>
        /// <returns>配置列表</returns>
        public error_config GetErrorConfigByCode(string system_tag_code, String unit_no, int line_id = -1)
        {
            error_config obj     = new error_config();
            string       command = string.Empty;

            if (system_tag_code != null && line_id >= 0 && unit_no != null && unit_no.Length > 0)
            {
                command = string.Format("Select * from andon.error_config where system_tag_code='{0}' and unit_no='{1}' and line_id='{2}'", system_tag_code, unit_no, line_id);
                obj     = PostgreHelper.GetSingleEntity <error_config>(command);
                if (obj == null)//查找不到,再向上一级查找
                {
                    command = string.Format("Select * from andon.error_config where system_tag_code='{0}' and unit_no='{1}'", system_tag_code, unit_no);
                }
            }
            else if (system_tag_code != null && unit_no != null && unit_no.Length > 0)
            {
                command = string.Format("Select * from andon.error_config where system_tag_code='{0}' and unit_no='{1}'", system_tag_code, unit_no);
            }

            if (command != string.Empty)
            {
                obj = PostgreHelper.GetSingleEntity <error_config>(command);

                return(obj);
            }
            return(null);
        }
        /// <summary>
        /// 用于网页模式下的解除.时间均在外部维护
        /// </summary>
        /// <param name="logItem">记录对象</param>
        /// <param name="cfgItem">配置对象</param>
        /// <param name="error_code">解除编码</param>
        /// <param name="defectives_count">不良品数量</param>
        /// <returns>正确执行返回ErrorObject,错误执行返回null</returns>
        public ErrorObject AckErrorLogDetails(error_log logItem, error_config cfgItem)
        {
            ErrorObject errorObject         = null;
            Dictionary <string, object> dic = new Dictionary <string, object>();//加入需要更新的字段信息

            errorObject = LoadErrorLogObject(logItem, cfgItem);

            if (errorObject != null && errorObject.ELog != null)
            {
                if (errorObject.eConfig.check_ack == (int)AckModeEnum.CodeAck)
                {
                    dic.Add("maintenance_time", errorObject.ELog.maintenance_time);
                    dic.Add("error_type_id", errorObject.ELog.error_type_id);//未确认原因的再给值。物料呼叫监测typeid会提前赋值
                }
                dic.Add("defectives_count", errorObject.ELog.defectives_count);
                dic.Add("release_time", errorObject.ELog.release_time);
                int count = errorLogManager.Update(errorObject.ELog, dic);        //提交数据库
                if (count > 0)
                {
                    Console.WriteLine("AckErrorLogDetails,确认成功,id=" + errorObject.ELog.id);
                }
                else
                {
                    Console.WriteLine("安灯解除更新数据失败!");
                }
                return(errorObject);
            }
            else
            {
                Console.WriteLine("安灯解除出错,errorObject != null && errorObject.ELog !=null 失败!");
            }

            return(null);
        }
        /// <summary>
        /// 责任人员现场签到,用于网页端
        /// </summary>
        /// <param name="logItem">异常监控队列</param>
        /// <param name="cfgItem">设备编码</param>
        /// <returns></returns>
        public ErrorObject AckErrorLogPersonForWeb(error_log logItem, error_config cfgItem)
        {
            ErrorTypeService      errorTypeService = new ErrorTypeService();
            person                person           = null;
            material_request_info reInfo           = null;
            ErrorObject           errorObject      = null;

            errorObject = LoadErrorLogObject(logItem, cfgItem);
            if (errorObject.ELog != null && errorObject.eConfig != null)
            {
                Dictionary <string, object> dic = new Dictionary <string, object>();
                if (errorObject.eConfig.check_arrival == (int)ArrivalModeEnum.CardArrival)
                {
                    errorObject.eSignedPersons.Add(person);             //记录签到的人员
                    errorObject.ELog.arrival_person_id = person.id;     //更新具体的id信息
                    dic.Add("arrival_person_id", logItem.arrival_person_id);
                    errorObject.eSignedPersons.Add(person);             //签到人员记录
                }

                dic.Add("arrival_time", errorObject.ELog.arrival_time);

                errorLogManager.Update(errorObject.ELog, dic);      //提交数据库
                Console.WriteLine("AckErrorLogPerson,执行结束,id=" + errorObject.ELog.id);
                return(errorObject);
            }

            return(null);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Web页面处理异常解除
        /// </summary>
        /// <param name="logItem">记录对象</param>
        /// <param name="cfgItem">配置对象</param>
        /// <param name="error_code">确认代码</param>
        /// <param name="defectives_count">不良品数量</param>
        public static void HandleErrorAck(error_log logItem, error_config cfgItem, ErrorObject errorObj = null)
        {
            string      subject = string.Empty, content = string.Empty;
            ErrorObject errorObject = null;

            if (errorObj != null)
            {
                errorObject = errorObj;
            }
            else
            {
                errorObject = andonErrorManager.AckErrorLogDetails(logItem, cfgItem);
            }

            if (errorObject != null && errorObject.eConfig != null)
            {
                if (errorObject.eConfig.trigger_message_type > (int)ErrorMsgType.None)//需要消息通知
                {
                    subject = "安灯系统" + errorObject.ELog.error_name;
                    if (errorObject.eTypeDetails != null)
                    {
                        content = String.Format("{0}已解除{1},原因为{2}" + MessageAdditional, logItem.machine_code, subject, errorObject.eTypeDetails.code_name_cn);
                    }
                    else if (errorObject.RequireMat != null)
                    {
                        content = String.Format("{0}已解除{1},呼叫的物料id为{2}" + MessageAdditional, logItem.machine_code, subject, errorObject.RequireMat.material_id);
                    }
                    else
                    {
                        content = String.Format("{0}已解除{1}" + MessageAdditional, logItem.machine_code, subject);
                    }
                    errorMessageManager.SendErrorMessageAsync(errorObject, (int)MessageLevel.Level1, EventHandleFlowEnum.Event_Ack, subject, content, true);//发送消息通知
                }
                if (errorObject.eConfig.arrival_out_color > (int)LightTowerEnum.None &&
                    errorObject.eConfig.check_arrival > (int)ArrivalModeEnum.NoArrival)     //签到灯颜色复位
                {
                    //写值
                    lightTowerTagManager.WriteLightColorAsync(logItem.station_id, errorObject.eConfig.arrival_out_color, tagAreaAttributeMode, 0);
                    lightTowerTagManager.GreenStatusLightOutAsync(logItem.station_id, tagAreaAttributeMode); //绿灯状态切换
                }
                if (errorObject.eConfig.trigger_out_color > (int)LightTowerEnum.None)                        //警示灯颜色复位
                {
                    //写值
                    lightTowerTagManager.WriteLightColorAsync(logItem.station_id, errorObject.eConfig.trigger_out_color, tagAreaAttributeMode, 0);
                    lightTowerTagManager.GreenStatusLightOutAsync(logItem.station_id, tagAreaAttributeMode);//绿灯状态切换
                }
            }
            else
            {
                Console.WriteLine("安灯解除记录失败,errorObject != null && errorObject.eConfig != null 失败!");
                if (errorObject.eConfig == null)
                {
                    Console.WriteLine("安灯解除记录失败,errorObject.eConfig == null" + logItem.system_tag_code);
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 人员签到处理
        /// </summary>
        /// <param name="logItem"></param>
        /// <param name="cfgItem"></param>
        /// <param name="errorObj"></param>
        public static void HandlePersonArrival(error_log logItem, error_config cfgItem, ErrorObject errorObj = null)
        {
            string      subject = string.Empty, content = string.Empty;
            ErrorObject errorObject;

            if (errorObj != null)
            {
                errorObject = errorObj;
            }
            else
            {
                errorObject = andonErrorManager.AckErrorLogPersonForWeb(logItem, cfgItem);
            }
            if (errorObject != null && errorObject.eConfig != null)
            {
                if (errorObject.eConfig.arrival_message_type > (int)ErrorMsgType.None)//需要消息通知
                {
                    if (errorObject.eConfig.check_arrival == (int)ArrivalModeEnum.CardArrival)
                    {
                        subject = "安灯系统" + errorObject.ELog.error_name;
                        if (errorObject.eSignedPersons.Count > 0)
                        {
                            content = String.Format("{0}发生{1},签到人员为{2}" + MessageAdditional, errorObject.ELog.machine_code, subject, errorObject.eSignedPersons[0].user_name);
                        }
                        else
                        {
                            content = String.Format("{0}发生{1},人员已签到" + MessageAdditional, errorObject.ELog.machine_code, subject);
                        }
                    }
                    else
                    {
                        subject = "安灯系统" + errorObject.ELog.error_name;
                        content = String.Format("{0}发生{1},人员已签到" + MessageAdditional, errorObject.ELog.machine_code, subject);
                    }
                    errorMessageManager.SendErrorMessageAsync(errorObject, (int)MessageLevel.Level1, EventHandleFlowEnum.Event_SignIn, subject, content); //发送消息通知,人员签到在第一层级??
                }
                if (errorObject.eConfig.arrival_out_color > (int)LightTowerEnum.None)                                                                     //灯颜色输出
                {
                    //写值
                    lightTowerTagManager.WriteLightColorAsync(errorObject.ELog.station_id, errorObject.eConfig.arrival_out_color, tagAreaAttributeMode, 1);
                    lightTowerTagManager.GreenStatusLightOutAsync(errorObject.ELog.station_id, tagAreaAttributeMode);//绿灯状态切换
                }
            }
        }
        /// <summary>
        /// 获取指定配置
        /// </summary>
        /// <param name="system_tag_code">系统标签类型</param>
        /// <param name="unit_no">制程工序,不能为空</param>
        /// <param name="line_id">线别,=-1则不启用</param>
        /// <returns>配置列表</returns>
        public error_config GetFirstErrorConfig(string system_tag_code, String unit_no, int line_id = -1)
        {
            error_config obj     = new error_config();
            string       command = string.Empty;

            if (line_id > 0)
            {
                command = string.Format("Select * from andon.error_config where system_tag_code='{0}' and unit_no='{1}' and line_id='{2}' limit 1", system_tag_code, unit_no, line_id);
            }
            else if (line_id < 0)
            {
                command = string.Format("Select * from andon.error_config where system_tag_code='{0}' and unit_no='{1}' limit 1", system_tag_code, unit_no);
            }

            if (command != string.Empty)
            {
                obj = PostgreHelper.GetSingleEntity <error_config>(command);

                return(obj);
            }
            return(null);
        }
        public int Update(error_config Obj)
        {
            int count = PostgreHelper.UpdateSingleEntity <error_config>(Obj);

            return(count);
        }
        public int Insert(error_config Obj)
        {
            int count = PostgreHelper.InsertSingleEntity <error_config>(Obj);

            return(count);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 工时更新变化事件接收。需要优化!!!!!!!!!!!!!1
        /// </summary>
        /// <param name="e"></param>
        private static void CTManager_CtValueChangedEvent(CT ct)
        {
            machine_working_time mWorking_Time;
            MachineInfo          machine           = null;
            station_info         station           = null;
            int                 deviceId           = -1;
            error_config        ecfg               = null;
            DeviceTagValueInfo  deviceTagValueInfo = new DeviceTagValueInfo();
            List <error_config> eCfgList;

            if (tagAreaAttributeMode == TagAreaAttributeEnum.machine_info)
            {
                machine = machineInfoManager.SelectSingle(-1, ct.machine_code);
            }
            else
            {
                station = stationManager.SelectSingle(ct.station_id);
            }
            if (machine != null || station != null)
            {
                if (machine != null)
                {
                    deviceId      = machine.machine_id;
                    mWorking_Time = machineworkingtimeManager.SelectSingle(deviceId);
                    eCfgList      = errorConfigManager.GetErrorConfig(SystemTagCodeEnum.machine_time_error.ToString(), machine.unit_no, machine.line_id);//先按照最小单位查询
                    ////ecfg = deviceTimeErrCfgList.FirstOrDefault(x => x.unit_no == machine.unit_no && x.line_id == machine.line_id);
                    //if (ecfg == null)
                    //{
                    //    ecfg = deviceTimeErrCfgList.FirstOrDefault(x => x.unit_no == station.unit_no);//按照制程查找
                    //}
                    if (eCfgList == null || eCfgList.Count == 0)
                    {
                        eCfgList = errorConfigManager.GetErrorConfig(SystemTagCodeEnum.machine_time_error.ToString(), machine.unit_no);//再按照大一级别查询
                    }
                    if (eCfgList != null && eCfgList.Count > 0)
                    {
                        ecfg = eCfgList[0];
                    }
                    deviceTagValueInfo.device_code = ct.machine_code;
                }
                else
                {
                    deviceId      = station.station_id;
                    mWorking_Time = machineworkingtimeManager.SelectSingle(-1, deviceId);
                    //ecfg = deviceTimeErrCfgList.FirstOrDefault(x => x.unit_no == station.unit_no && x.line_id == station.line_id);//先按照制程+线别查找
                    //if(ecfg==null)
                    //{
                    //    ecfg = deviceTimeErrCfgList.FirstOrDefault(x => x.unit_no == station.unit_no);//按照制程查找
                    //}
                    eCfgList = errorConfigManager.GetErrorConfig(SystemTagCodeEnum.machine_time_error.ToString(), station.unit_no, station.line_id);//先按照最小单位查询
                    if (eCfgList == null || eCfgList.Count == 0)
                    {
                        eCfgList = errorConfigManager.GetErrorConfig(SystemTagCodeEnum.machine_time_error.ToString(), station.unit_no);//再按照大一级别查询
                    }
                    if (eCfgList != null && eCfgList.Count > 0)
                    {
                        ecfg = eCfgList[0];
                    }
                    deviceTagValueInfo.device_code = station.station_name_en;
                }

                if (ct.value > mWorking_Time.standard_time)//大于标准设定时间
                {
                    try
                    {
                        if (ct.pn != string.Empty &&
                            mWorking_Time.part_num != string.Empty &&
                            mWorking_Time.part_num.Contains(ct.pn))     //机种不为空,在设定的队列里面
                        {
                            if (deviceTimeErrDic.ContainsKey(deviceId)) //已经发生过
                            {
                                deviceTimeErrDic[deviceId] += 1;
                            }
                            else
                            {
                                deviceTimeErrDic.Add(deviceId, 1);   //新增到临时
                            }

                            if (ecfg != null &&
                                ecfg.error_active == 1 &&
                                ecfg.trigger_count <= deviceTimeErrDic[deviceId])//激活,且超过了设定的次数
                            {
                                deviceTagValueInfo.device_id        = deviceId;
                                deviceTagValueInfo.system_tag_code  = SystemTagCodeEnum.machine_time_error.ToString();
                                deviceTagValueInfo.system_type_code = TagTypeEnum.Error.ToString();
                                deviceTagValueInfo.tag_value        = ct.value.ToString();
                                deviceTagValueInfo.insert_time      = ct.end_time;
                                ErrorHandle(deviceTagValueInfo, tagAreaAttributeMode); //工时异常处理
                                deviceTimeErrDic.Remove(deviceId);                     //移除
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("CTManager_CtValueChangedEvent error:" + ex.Message);
                        srpLogManager.Insert("CTManager_CtValueChangedEvent error:" + ex.Message);
                    }
                }
            }
        }
Ejemplo n.º 13
0
 public int Update(error_config Obj)
 {
     return(errorConfigService.Update(Obj));
 }
Ejemplo n.º 14
0
 public int Insert(error_config Obj)
 {
     return(errorConfigService.Insert(Obj));
 }