Commit cc56c6c453e0b0309e9797d44fd3dc40b99e1fea
1 parent
2f2cfdbf
计算当前第几周的bug
Showing
1 changed file
with
14 additions
and
2 deletions
src/main/java/com/example/demo/service/Contrast.java
| @@ -100,8 +100,18 @@ public class Contrast { | @@ -100,8 +100,18 @@ public class Contrast { | ||
| 100 | map.clear(); | 100 | map.clear(); |
| 101 | map.put("timeStart",localDateTimeStart.toInstant(ZoneOffset.of("+8")).toEpochMilli()); | 101 | map.put("timeStart",localDateTimeStart.toInstant(ZoneOffset.of("+8")).toEpochMilli()); |
| 102 | map.put("timeEnd",localDateTimeEnd.toInstant(ZoneOffset.of("+8")).toEpochMilli()); | 102 | map.put("timeEnd",localDateTimeEnd.toInstant(ZoneOffset.of("+8")).toEpochMilli()); |
| 103 | - int weekStr=getWeek(localDateTimeStart.toString()); | ||
| 104 | - int weekEnd=getWeek(localDateTimeEnd.toString()); | 103 | + |
| 104 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 105 | + Date ds = sdf.parse(localDateTimeStart.format(tdf)); | ||
| 106 | + Calendar cs = Calendar.getInstance(); | ||
| 107 | + cs.setTime(ds); | ||
| 108 | + int weekStr=cs.get(Calendar.WEEK_OF_YEAR); | ||
| 109 | + | ||
| 110 | + Date de = sdf.parse(localDateTimeEnd.format(tdf)); | ||
| 111 | + Calendar ce = Calendar.getInstance(); | ||
| 112 | + ce.setTime(de); | ||
| 113 | + int weekEnd=ce.get(Calendar.WEEK_OF_YEAR); | ||
| 114 | + | ||
| 105 | String weeks=""; | 115 | String weeks=""; |
| 106 | if(weekStr==weekEnd){ | 116 | if(weekStr==weekEnd){ |
| 107 | weeks="= "+weekStr; | 117 | weeks="= "+weekStr; |
| @@ -111,6 +121,8 @@ public class Contrast { | @@ -111,6 +121,8 @@ public class Contrast { | ||
| 111 | map.put("weeks",weeks); | 121 | map.put("weeks",weeks); |
| 112 | map.put("year",localDateTimeStart.getYear()); | 122 | map.put("year",localDateTimeStart.getYear()); |
| 113 | List<ArrivalInfo> list= siteMapper2.getArrivalInfo(map); | 123 | List<ArrivalInfo> list= siteMapper2.getArrivalInfo(map); |
| 124 | + logger.info("====================map "+map.toString()); | ||
| 125 | + logger.info("====================list "+list.size()); | ||
| 114 | List<ArrivalInfo> arrivalInfoList=new ArrayList<>(); | 126 | List<ArrivalInfo> arrivalInfoList=new ArrayList<>(); |
| 115 | ArrivalInfo in=null; | 127 | ArrivalInfo in=null; |
| 116 | for (ArrivalInfo arrivalInfo : list) { | 128 | for (ArrivalInfo arrivalInfo : list) { |