public void QueryMaterialsProportion() { string res = "[{\"propertion\":[{\"data\":["; IList <WorkOrder> wo = _bal.FindOnlineWOByKanBan("1000", "1"); int demandTotal = 0; int finishTotal = 0; int noFinishTotal = 0; if (wo != null && wo.Count > 0) { for (int i = 0; i < wo.Count; i++) { demandTotal += (int)wo[i].PlanQuantity; noFinishTotal += (int)(wo[i].PlanQuantity - (wo[i].MaterialQty == null?0:wo[i].MaterialQty)); finishTotal += (int)(wo[i].MaterialQty == null ? 0 : wo[i].MaterialQty); } } float ffinishTotal = (float)(Math.Round(((double)finishTotal / (demandTotal == 0?1:demandTotal)) * 10000) / 100); float fnofinishTotal = 100 - ffinishTotal; res += "{\"name\":\"已发料\",\"y\":" + ffinishTotal + ",\"drilldown\":\"send\"},{\"name\":\"未发料\",\"y\":" + fnofinishTotal + ",\"drilldown\":\"nosend\"}]}],"; res += "\"drilldown\":[{\"name\":\"send\",\"id\":\"send\",\"data\":["; for (int i = 0; i < wo.Count; i++) { float proportion = (float)(Math.Round(((double)((wo[i].MaterialQty == null ? 0 : wo[i].MaterialQty) / wo[i].PlanQuantity)) * 10000) / 100); res += "[\""; //res += wo[i].PartsdrawingCode + "\",\"" + (wo[i].MaterialQty == null ? 0 : wo[i].MaterialQty) + "/" + wo[i].PlanQuantity + "\"],"; res += wo[i].PartsdrawingCode + "\"," + proportion + "],"; } res = res.Substring(0, res.Length - 1); res += "]},{\"name\":\"nosend\",\"id\":\"nosend\",\"data\":["; for (int i = 0; i < wo.Count; i++) { res += "[\""; int inosend = (int)(wo[i].PlanQuantity - (wo[i].MaterialQty == null ? 0 : wo[i].MaterialQty)); float proportion = (float)(Math.Round(((double)(inosend / wo[i].PlanQuantity)) * 10000) / 100); res += wo[i].PartsdrawingCode + "\"," + proportion + "],"; // res += wo[i].PartsdrawingCode + "\",\"" + inosend + "/" + wo[i].PlanQuantity + "\"],"; } res = res.Substring(0, res.Length - 1); res += "]}]}]"; //Dictionary<String, Object> map = new Dictionary<String, Object>(); //map.Add("total", count); //map.Add("rows", wo); //Context.Response.Write(JsonConvert.SerializeObject(map)); Context.Response.Write(res); }