| | |
| | | |
| | | List<DtLocVo> locVos = new ArrayList<>(); |
| | | |
| | | Date startTime; |
| | | Date endTime; |
| | | if (startDate == null || endDate == null || startDate.isEmpty() || endDate.isEmpty()){ |
| | | Date now = new Date(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(now); |
| | | calendar.add(Calendar.DAY_OF_MONTH, -7); |
| | | Date start = calendar.getTime(); |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); |
| | | endDate = sdf.format(now); |
| | | startDate = sdf.format(start); |
| | | } |
| | | List<LocCount> locCounts; |
| | | if (areaId != null && !areaId.isEmpty()) { |
| | | locCounts = locCountMapper.getByAreaAndDate(areaId, Integer.parseInt(startDate), Integer.parseInt(endDate)); |
| | | startTime = calendar.getTime(); |
| | | endTime = now; |
| | | } else { |
| | | locCounts = locCountMapper.getByDate(Integer.parseInt(startDate), Integer.parseInt(endDate)); |
| | | SimpleDateFormat sdf; |
| | | try { |
| | | if (startDate.length() == 8 && endDate.length() == 8) { |
| | | sdf = new SimpleDateFormat("yyyyMMdd"); |
| | | startTime = sdf.parse(startDate); |
| | | endTime = sdf.parse(endDate); |
| | | } else { |
| | | sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | startTime = sdf.parse(startDate); |
| | | endTime = sdf.parse(endDate); |
| | | } |
| | | } catch (ParseException e) { |
| | | Date now = new Date(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(now); |
| | | calendar.add(Calendar.DAY_OF_MONTH, -7); |
| | | startTime = calendar.getTime(); |
| | | endTime = now; |
| | | } |
| | | } |
| | | |
| | | int totalLoc = locMastMapper.selectCount(new EntityWrapper<LocMast>().ne("loc_sts", "Z")); |
| | | int usedLoc = locMastMapper.selectCount(new EntityWrapper<LocMast>().in("loc_sts", Arrays.asList("F", "P", "Q", "R", "S", "X"))); |
| | | int idleNum = totalLoc - usedLoc; |
| | | |
| | | for (LocCount locCount : locCounts) { |
| | | String date = locCount.getDate().toString(); |
| | | String locDate = date.substring(0, 4) + "-" + date.substring(4, 6) + "-" + date.substring(6, 8); |
| | | SimpleDateFormat outSdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | Calendar cursor = Calendar.getInstance(); |
| | | cursor.setTime(startTime); |
| | | Calendar endCursor = Calendar.getInstance(); |
| | | endCursor.setTime(endTime); |
| | | while (!cursor.after(endCursor)) { |
| | | DtLocVo dtLocVo = DtLocVo.builder() |
| | | .locDate(locDate) |
| | | .idleNum(locCount.getRemainNum()) |
| | | .locDate(outSdf.format(cursor.getTime())) |
| | | .idleNum(idleNum) |
| | | .build(); |
| | | locVos.add(dtLocVo); |
| | | cursor.add(Calendar.DAY_OF_MONTH, 1); |
| | | } |
| | | |
| | | return locVos; |