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 | 100 | map.clear(); |
| 101 | 101 | map.put("timeStart",localDateTimeStart.toInstant(ZoneOffset.of("+8")).toEpochMilli()); |
| 102 | 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 | 115 | String weeks=""; |
| 106 | 116 | if(weekStr==weekEnd){ |
| 107 | 117 | weeks="= "+weekStr; |
| ... | ... | @@ -111,6 +121,8 @@ public class Contrast { |
| 111 | 121 | map.put("weeks",weeks); |
| 112 | 122 | map.put("year",localDateTimeStart.getYear()); |
| 113 | 123 | List<ArrivalInfo> list= siteMapper2.getArrivalInfo(map); |
| 124 | + logger.info("====================map "+map.toString()); | |
| 125 | + logger.info("====================list "+list.size()); | |
| 114 | 126 | List<ArrivalInfo> arrivalInfoList=new ArrayList<>(); |
| 115 | 127 | ArrivalInfo in=null; |
| 116 | 128 | for (ArrivalInfo arrivalInfo : list) { | ... | ... |