Beispiel #1
0
        /// <summary>
        /// 请求数据
        /// </summary>
        void RequestData()
        {
            string cell = SelfVars.CurrentSelectedCell;
            List <HtmlDataItem> datas = new List <HtmlDataItem>();

            datas.Clear();
            int overday = commonDAO.GetCommonAppletConfigInt32("存样柜超期天数");
            IList <InfAutoCupBoard> cellList = commonDAO.SelfDber.Entities <InfAutoCupBoard>("where CupBoardType=:CupBoardType and ParentPKID is not null", new { CupBoardType = cell });
            decimal useCount    = cellList.Count(a => a.State == 1);
            decimal emptyCount  = cellList.Count - useCount;
            decimal usePercent  = cellList.Count > 0 ? Math.Round(useCount / cellList.Count, 2, MidpointRounding.AwayFromZero) : 0;
            decimal overCount   = cellList.Count(a => a.State == 1 && a.SaveTime < DateTime.Now.AddDays(-overday));
            decimal overPercent = useCount > 0 ? Math.Round(overCount / useCount, 2, MidpointRounding.AwayFromZero) : 0;


            datas.Add(new HtmlDataItem("总仓位", cellList.Count.ToString(), eHtmlDataItemType.svg_text));
            datas.Add(new HtmlDataItem("已存仓位", useCount.ToString(), eHtmlDataItemType.svg_text));
            datas.Add(new HtmlDataItem("未存仓位", emptyCount.ToString(), eHtmlDataItemType.svg_text));
            datas.Add(new HtmlDataItem("超期仓位", overCount.ToString(), eHtmlDataItemType.svg_text));
            datas.Add(new HtmlDataItem("存样率", (usePercent * 100).ToString("F2") + "%", eHtmlDataItemType.svg_text));
            datas.Add(new HtmlDataItem("超期率", (overPercent * 100).ToString("F2") + "%", eHtmlDataItemType.svg_text));

            IList <RowResult> rowResult = new List <RowResult>();

            if (cellList.Count > 0)
            {
                if (cell == "原煤样样柜")
                {
                    int maxRow  = cellList.OrderByDescending(a => a.RowNumber).First().RowNumber;
                    int maxCell = cellList.OrderByDescending(a => a.CellNumber).First().CellNumber;
                    for (int i = 1; i <= maxRow; i++)
                    {
                        RowResult rowEntity = new RowResult();
                        rowEntity.RowName  = String.Format("第 {0} 层", i);
                        rowEntity.CellList = new List <CellResult>();
                        for (int j = 1; j <= maxCell; j++)
                        {
                            CellResult      cellEntity = new CellResult();
                            InfAutoCupBoard sampleCell = cellList.Where(a => a.RowNumber == i && a.CellNumber == j).FirstOrDefault();
                            if (sampleCell == null)
                            {
                                cellEntity.CellFlag = -1;
                            }
                            else
                            {
                                cellEntity.CellNumber = sampleCell.CupBoardDes.Replace("层", "").Replace("格", "").Remove(0, 2);
                                //柜门标识:-1没这一格,0空柜,1已存放,2超期样,3停用
                                if (sampleCell.IsValid == "0")
                                {
                                    cellEntity.CellFlag = 3;
                                }
                                else if (sampleCell.State == 1 && sampleCell.SaveTime < DateTime.Now.AddDays(-overday))
                                {
                                    cellEntity.CellFlag = 2;
                                }
                                else if (sampleCell.State == 1)
                                {
                                    cellEntity.CellFlag = 1;
                                }
                                else
                                {
                                    cellEntity.CellFlag = 0;
                                }
                            }
                            rowEntity.CellList.Add(cellEntity);
                        }
                        rowResult.Add(rowEntity);
                    }
                }
                else
                {
                    int maxRow  = 5;
                    int maxCell = 4;
                    for (int i = 1; i <= maxRow; i++)
                    {
                        RowResult rowEntity = new RowResult();
                        rowEntity.RowName  = String.Format("第 {0} 排", i);
                        rowEntity.CellList = new List <CellResult>();
                        for (int j = 1; j <= maxCell; j++)
                        {
                            CellResult cellEntity = new CellResult();

                            cellEntity.CellNumber = string.Format("{0}排{1}号", i, j);
                            string cellCode = i.ToString().PadLeft(2, '0') + "G" + j.ToString().PadLeft(2, '0');
                            cellEntity.CellCode = cellCode;
                            IList <InfAutoCupBoard> sampleCell = cellList.Where(a => a.CupBoardCode.Contains(cellCode)).ToList();
                            //柜门标识:-1没这一格,0空柜,1已存放,2超期样,3停用
                            if (cellList.Count(a => a.IsValid == "0" && a.CupBoardCode.Contains(cellCode)) == 60)
                            {
                                cellEntity.CellFlag = 3;
                            }
                            else if (cellList.Count(a => a.State == 1 && a.SaveTime < DateTime.Now.AddDays(-overday) && a.CupBoardCode.Contains(cellCode)) > 0)
                            {
                                cellEntity.CellFlag = 2;
                            }
                            else if (cellList.Count(a => a.State == 1 && a.CupBoardCode.Contains(cellCode)) > 0)
                            {
                                cellEntity.CellFlag = 1;
                            }
                            else if (cellList.Count(a => a.State == 0 && a.CupBoardCode.Contains(cellCode)) == 60)
                            {
                                cellEntity.CellFlag = 0;
                            }

                            rowEntity.CellList.Add(cellEntity);
                        }
                        rowResult.Add(rowEntity);
                    }
                }
            }

            datas.Add(new HtmlDataItem("样柜信息", Newtonsoft.Json.JsonConvert.SerializeObject(rowResult), eHtmlDataItemType.json_data));


            // 添加更多...

            // 发送到页面
            cefWebBrowser.Browser.GetMainFrame().ExecuteJavaScript("requestData(" + Newtonsoft.Json.JsonConvert.SerializeObject(datas) + ");", "", 0);
        }
Beispiel #2
0
        protected override bool Execute(string name, CefV8Value obj, CefV8Value[] arguments, out CefV8Value returnValue, out string exception)
        {
            exception   = null;
            returnValue = null;
            string paramSampler = arguments[0].GetStringValue();

            switch (name)
            {
            case "ChangeSelected":
                CefProcessMessage cefMsg = CefProcessMessage.Create("ChangeSelected");
                cefMsg.Arguments.SetSize(0);
                cefMsg.Arguments.SetString(0, paramSampler);
                CefV8Context.GetCurrentContext().GetBrowser().SendProcessMessage(CefProcessId.Browser, cefMsg);
                break;

            case "ShowYGDetail":
                int overday = CommonDAO.GetInstance().GetCommonAppletConfigInt32("存样柜超期天数");
                IList <RowResult>       rowResult = new List <RowResult>();
                IList <InfAutoCupBoard> cellList  = CommonDAO.GetInstance().SelfDber.Entities <InfAutoCupBoard>(string.Format("where CupBoardCode like '%{0}%' and CupBoardType='{1}' and ParentPKID is not null", paramSampler, arguments[1].GetStringValue()));
                if (cellList != null && cellList.Count > 0)
                {
                    int maxRow  = cellList.OrderByDescending(a => a.RowNumber).First().RowNumber;
                    int maxCell = cellList.OrderByDescending(a => a.CellNumber).First().CellNumber;
                    for (int i = 1; i <= maxRow; i++)
                    {
                        RowResult rowEntity = new RowResult();
                        rowEntity.RowName  = String.Format("第 {0} 层", i);
                        rowEntity.CellList = new List <CellResult>();
                        for (int j = 1; j <= maxCell; j++)
                        {
                            CellResult      cellEntity = new CellResult();
                            InfAutoCupBoard sampleCell = cellList.Where(a => a.RowNumber == i && a.CellNumber == j).FirstOrDefault();
                            if (sampleCell == null)
                            {
                                cellEntity.CellFlag = -1;
                            }
                            else
                            {
                                cellEntity.CellNumber = sampleCell.CupBoardDes.Replace("层", "").Replace("格", "").Remove(0, 2);
                                //柜门标识:-1没这一格,0空柜,1已存放,2超期样,3停用
                                if (sampleCell.IsValid == "0")
                                {
                                    cellEntity.CellFlag = 3;
                                }
                                else if (sampleCell.State == 1 && sampleCell.SaveTime < DateTime.Now.AddDays(-overday))
                                {
                                    cellEntity.CellFlag = 2;
                                }
                                else if (sampleCell.State == 1)
                                {
                                    cellEntity.CellFlag = 1;
                                }
                                else
                                {
                                    cellEntity.CellFlag = 0;
                                }
                            }
                            rowEntity.CellList.Add(cellEntity);
                        }
                        rowResult.Add(rowEntity);
                    }
                }
                returnValue = CefV8Value.CreateString(Newtonsoft.Json.JsonConvert.SerializeObject(rowResult));
                break;

            default:
                returnValue = null;
                break;
            }

            return(true);
        }
        /// <summary>
        /// 同步存样柜信息
        /// </summary>
        /// <param name="output"></param>
        /// <returns></returns>
        public int SyncCYGInfo(Action <string, eOutputType> output)
        {
            int res = 0;

            foreach (EquCYG item in DcDbers.GetInstance().AutoCupboard_Dber.Entities <EquCYG>())
            {
                string pkid         = item.YGId.ToString();
                string CupBoardType = item.YGLX;
                if (item.YGLX == "432")
                {
                    CupBoardType = "制样室样柜";
                }
                else if (item.YGLX == "433")
                {
                    CupBoardType = "化验室样柜";
                }
                else if (item.YGLX == "646")
                {
                    CupBoardType = "原煤样样柜";
                }

                int State = 0;
                if (item.ZT == 435)
                {
                    State = 1;
                }
                else if (item.ZT == 436)
                {
                    State = 0;
                }

                int row = 0, cell = 0;
                if (item.YGBM.Length == 9)
                {
                    string ms     = item.WZMS.Replace("层", "").Replace("格", "");
                    int    number = int.Parse(ms.Remove(0, 2));
                    if (CupBoardType == "原煤样样柜")
                    {
                        row  = number % 4;
                        cell = number / 4 + 1;
                        if (row == 0)
                        {
                            row  = 4;
                            cell = number / 4;
                        }
                    }
                    else
                    {
                        row  = number % 10;
                        cell = number / 10 + 1;
                        if (row == 0)
                        {
                            row  = 10;
                            cell = number / 10;
                        }
                    }
                }
                InfAutoCupBoard entity = commonDAO.SelfDber.Entity <InfAutoCupBoard>(" where PKID=:PKID", new { PKID = pkid });
                EquCYGDetail    detail = DcDbers.GetInstance().AutoCupboard_Dber.Entity <EquCYGDetail>("where YGID=@YGID and ZT=438 order by CYSJ desc", new { YGID = item.YGId });
                if (entity == null)
                {
                    entity = new InfAutoCupBoard();
                    entity.CupBoardCode = item.YGBM;
                    entity.CupBoardType = CupBoardType;
                    entity.CupBoardDes  = item.WZMS;
                    entity.State        = State;
                    entity.IsValid      = item.Is_Valid;
                    entity.PKID         = pkid;
                    entity.ParentPKID   = item.Parent_YGID;
                    entity.RowNumber    = row;
                    entity.CellNumber   = cell;
                    entity.CupNumber    = item.Num_Url;
                    if (detail != null)
                    {
                        entity.SaveTime = detail.CYSJ;
                    }
                    res += commonDAO.SelfDber.Insert(entity);
                }
                else
                {
                    entity.CupBoardCode = item.YGBM;
                    entity.CupBoardType = CupBoardType;
                    entity.CupBoardDes  = item.WZMS;
                    entity.State        = State;
                    entity.IsValid      = item.Is_Valid;
                    entity.RowNumber    = row;
                    entity.CellNumber   = cell;
                    entity.CupNumber    = item.Num_Url;
                    entity.ParentPKID   = item.Parent_YGID;
                    if (detail != null)
                    {
                        entity.SaveTime = detail.CYSJ;
                    }
                    res += commonDAO.SelfDber.Update(entity);
                }
            }
            output(string.Format("同步存样柜数据 {0} 条", res), eOutputType.Normal);

            return(res);
        }