当数据库里的时间需要从后往前递推补充时

 依次判断数据库里的时间是否存在并且与当前时间是否相同!


				for (DayLoad item : lstmonth) {
					if (item.getDate() != null && item.getDate().equals(2019 + "-" + 0 + (new Date().getMonth() + 1))) {
						{
							arrdates[5] = item.getDate();
							demand[5] = item.getDemand();
							pavg[5] = item.getPavg();
						}
					} else {

						if (arrdates[5] == null) {
							arrdates[5] = 2019 + "-" + 0 + (new Date().getMonth() + 1);
							demand[5] = 0;
							pavg[5] = 0;
						}
						if (item.getDate() != null && item.getDate().equals(2019 + "-" + 0 + (new Date().getMonth()))) {
							arrdates[4] = item.getDate();
							demand[4] = item.getDemand();
							pavg[4] = item.getPavg();
						} else {
							arrdates[4] = 2019 + "-" + 0 + (new Date().getMonth());
							demand[4] = 0;
							pavg[4] = 0;
						}
						if (item.getDate() != null
								&& item.getDate().equals(2019 + "-" + 0 + (new Date().getMonth() - 1))) {
							arrdates[3] = item.getDate();
							demand[3] = item.getDemand();
							pavg[3] = item.getPavg();
						} else {

							arrdates[3] = 2019 + "-" + 0 + (new Date().getMonth() - 1);
							demand[3] = 0;
							pavg[3] = 0;

						}
						if (item.getDate() != null
								&& item.getDate().equals(2019 + "-" + 0 + (new Date().getMonth() - 2))) {
							arrdates[2] = item.getDate();
							demand[2] = item.getDemand();
							pavg[2] = item.getPavg();
						} else {

							arrdates[2] = 2019 + "-" + 0 + (new Date().getMonth() - 2);
							demand[2] = 0;
							pavg[2] = 0;

						}
						if (item.getDate() != null
								&& item.getDate().equals(2019 + "-" + 0 + (new Date().getMonth() - 3))) {
							arrdates[1] = 2019 + "-" + 0 + (new Date().getMonth() - 3);
							demand[1] = item.getDemand();
							pavg[1] = item.getPavg();
						} else {

							arrdates[1] = 2019 + "-" + 0 + (new Date().getMonth() - 3);
							demand[1] = 0;
							pavg[1] = 0;

						}
						if (item.getDate() != null
								&& item.getDate().equals(2019 + "-" + 0 + (new Date().getMonth() - 4))) {
							arrdates[0] = item.getDate();
							demand[0] = item.getDemand();
							pavg[0] = item.getPavg();
						} else {

							arrdates[0] = 2019 + "-" + 0 + (new Date().getMonth() - 4);
							demand[0] = 0;
							pavg[0] = 0;
						}

					}
				}
			
发布了47 篇原创文章 · 获赞 14 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/qq_35097794/article/details/99648581