Exemple #1
0
        public List <DefectInfo> GetISRADefectList(GetDefectInfoListRequestData reqData)
        {
            // 如果是refresh,需要在数据库查询时间
            if (reqData.refresh == "1")
            {
                DataOpt   dOpt = new DataOpt();
                DataTable dt   = dOpt.getRollTimeByEventId(reqData.eventId);
                if (dt != null && dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["Start_Time"].ToString() == dt.Rows[0]["timeStamp"].ToString())
                    {
                        reqData.endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    }
                    else
                    {
                        reqData.endTime = dt.Rows[0]["timeStamp"].ToString();
                    }
                }
            }

            // 接口调用获取纸病信息
            string url = "http://" + print1Url + ":18096/getDefectInfo/";

            //string url = "http://127.0.0.1:18096/getDefectInfo/";

            // 根据pathId、puId确定访问印刷1、印刷2?    2	印刷1下卷/4	印刷2下卷
            if (reqData.puId == "2")
            {
            }
            else if (reqData.puId == "4")
            {
                url = "http://" + print2Url + ":18096/getDefectInfo/";
            }


            string resData = PostHttp(url, JsonConvert.SerializeObject(reqData), "application/json");
            //string resData = "{\"uploadFailDefectId\":\"\",\"defectList\":[{\"defectId\":\"18464\",\"time\":\"2018/8/17 12:42:42\",\"startMeter\":\"150.270935743123\",\"endMeter\":\"150.270935743123\",\"defectType\":\"advanced streak\",\"webNum\":\"6\"},{\"defectId\":\"19624\",\"time\":\"2018/8/17 12:50:52\",\"startMeter\":\"3662.37127868693\",\"endMeter\":\"3662.37127868693\",\"defectType\":\"small defect\",\"webNum\":\"6\"}]}";
            //1. 解析数据
            ResponseDefectInfoList res = JsonConvert.DeserializeObject <ResponseDefectInfoList>(resData);

            if (res == null)
            {
                return(new List <DefectInfo>());
            }
            List <DefectInfo> dfList = res.defectList.ToList <DefectInfo>();

            //1.5 解析纸病信息,组合纸病
            return(MergeDefect(dfList));
            //1.5 保存dfList到JSON文件,当删除数据库中数据时,动态刷新上方表格,添加
        }
Exemple #2
0
        public Dictionary <string, object> GetDefectInfoList(GetDefectInfoListRequestData reqData, bool isDelete = false, List <string> refDefectId = null)
        {
            // 通过接口获取最新的纸病信息,返回后,本地保存到json文件中
            Dictionary <string, object> dictionary = new Dictionary <string, object>();  //实例化一个参数集合

            try
            {
                // 如果是当前工单的第一卷,则 取上一个下卷记录的结束时间为当前卷的起始时间
                DataOpt dOpt = new DataOpt();
                //18019T01
                if (reqData.rollNum.Length == 8 && reqData.rollNum.Substring(6, 2) == "01")
                {
                    string startTime = dOpt.getRollStartTime(reqData.startTime, reqData.puId);
                    if (!string.IsNullOrEmpty(startTime))
                    {
                        reqData.startTime = startTime;
                    }
                }


                MyHttpRequest     myRq   = new MyHttpRequest();
                List <DefectInfo> dfList = myRq.GetISRADefectList(reqData);
                //1.5 保存dfList到JSON文件,当删除数据库中数据时,动态刷新上方表格,添加

                //2. 读取数据库获取已经处理完成的数据

                DataSet dtDefectInfo = dOpt.getDefectInfoByRollNum(reqData.puId, reqData.eventId);
                if (dtDefectInfo == null || dtDefectInfo.Tables.Count != 2)// || dtDefectInfo.Rows.Count == 0
                {
                    dictionary.Clear();
                    dictionary.Add("state", 2);
                    dictionary.Add("errmessage", "获取纸病信息失败");
                    return(dictionary);
                }
                dictionary.Add("eventNum", dtDefectInfo.Tables[0].Rows[0][0].ToString());
                dictionary.Add("isBlocked", string.IsNullOrEmpty(dtDefectInfo.Tables[0].Rows[0][1].ToString()) ? "-1" : dtDefectInfo.Tables[0].Rows[0][1].ToString());
                // 存在已经保存入库的纸病记录,与接口获取的原始纸病对比,保留未处理的数据
                for (int i = 0; i < dfList.Count;)
                {
                    bool isSame = false;
                    for (int j = 0; j < dtDefectInfo.Tables[1].Rows.Count; j++)
                    {
                        if (dtDefectInfo.Tables[1].Rows[j]["defectID"].ToString().IndexOf(dfList[i].defectId) >= 0)
                        {
                            dfList.RemoveAt(i);
                            isSame = true;
                            break;
                        }
                    }

                    if (!isSame)
                    {
                        i++;
                    }
                }

                if (isDelete)
                {
                    List <int> refDefectIdInt = new List <int>();
                    for (int k = 0; k < refDefectId.Count; k++)
                    {
                        refDefectIdInt.Add(Convert.ToInt32(refDefectId[k].ToString()));
                    }
                    refDefectIdInt.Sort();
                    for (int k = 0, i = 0; k < refDefectIdInt.Count; k++)
                    {
                        for (; i < dfList.Count;)
                        {
                            if (refDefectIdInt[k].ToString() != dfList[i].defectId.ToString())
                            {
                                dfList.RemoveAt(i);
                            }
                            else
                            {
                                i++;
                                if (k != refDefectIdInt.Count - 1)
                                {
                                    break;
                                }
                            }
                        }
                    }
                }

                //3、 读取数据库获取纸病代码
                if (!isDelete)
                {
                    DataTable dtDefectCode = dOpt.getDefectCodeList();
                    if (dtDefectCode == null || dtDefectCode.Rows.Count == 0)
                    {
                        dictionary.Clear();
                        dictionary.Add("state", 2);
                        dictionary.Add("errmessage", "获取纸病代码失败");
                        return(dictionary);
                    }
                    // 整理纸病代码
                    ArrayList defectCodeList = new ArrayList();
                    foreach (DataRow dataRow in dtDefectCode.Rows)
                    {
                        Dictionary <string, object> defectCode = new Dictionary <string, object>();
                        foreach (DataColumn dataColumn in dtDefectCode.Columns)
                        {
                            defectCode.Add(dataColumn.ColumnName, dataRow[dataColumn.ColumnName].ToString());
                        }
                        defectCodeList.Add(defectCode); //ArrayList集合中添加键值
                    }
                    dictionary.Add("defectCodeList", defectCodeList);
                }



                //4、 读取处理工序
                if (!isDelete)
                {
                    DataTable dtDefectProcedure = dOpt.getDefectProcedure();
                    if (dtDefectProcedure == null || dtDefectProcedure.Rows.Count == 0)
                    {
                        dictionary.Clear();
                        dictionary.Add("state", 2);
                        dictionary.Add("errmessage", "获取纸病代码失败");
                        return(dictionary);
                    }
                    // 整理处理工序
                    ArrayList defectProcedureList = new ArrayList();
                    foreach (DataRow dataRow in dtDefectProcedure.Rows)
                    {
                        Dictionary <string, object> defectProcedure = new Dictionary <string, object>();
                        foreach (DataColumn dataColumn in dtDefectProcedure.Columns)
                        {
                            defectProcedure.Add(dataColumn.ColumnName, dataRow[dataColumn.ColumnName].ToString());
                        }
                        defectProcedureList.Add(defectProcedure); //ArrayList集合中添加键值
                    }
                    dictionary.Add("defectProcedureList", defectProcedureList);
                }


                // 组合两个表格数据为JSON, 返回页面
                if (!isDelete)
                {
                    ArrayList arrayList = new ArrayList();
                    foreach (DataRow dataRow in dtDefectInfo.Tables[1].Rows)
                    {
                        Dictionary <string, object> defectInfo = new Dictionary <string, object>();
                        foreach (DataColumn dataColumn in dtDefectInfo.Tables[1].Columns)
                        {
                            defectInfo.Add(dataColumn.ColumnName, dataRow[dataColumn.ColumnName].ToString());
                        }
                        arrayList.Add(defectInfo); //ArrayList集合中添加键值
                    }
                    dictionary.Add("defectListDB", arrayList);
                }

                // 根据dfList中数据,查看图片文件是否存在
                if (!CheckDefectImage(dfList, reqData.puId, reqData.eventId))
                {
                    dictionary.Add("state", 3);
                }
                else
                {
                    dictionary.Add("state", 1);
                }

                dictionary.Add("defectList", dfList);
            }
            catch (Exception ex)
            {
                // 记录日志
                dictionary.Clear();
                dictionary.Add("state", 2);
                dictionary.Add("errmessage", ex.StackTrace.ToString());
            }

            return(dictionary);
        }