Browse Source

时间段

dev_shibei_match
zxc 4 years ago
parent
commit
238d5d253b
  1. 22
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/TimeDTO.java
  2. 3
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcPartyServiceCenterController.java
  3. 70
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcPartyServiceCenterServiceImpl.java

22
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/TimeDTO.java

@ -0,0 +1,22 @@
package com.epmet.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2021/11/22 3:56 下午
* @DESC
*/
@Data
public class TimeDTO implements Serializable {
private static final long serialVersionUID = -3290964095027429971L;
private String timeId;
private Boolean isAppointment = true;
private String time;
}

3
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcPartyServiceCenterController.java

@ -36,8 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
import java.util.*;
/**

70
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcPartyServiceCenterServiceImpl.java

@ -38,6 +38,7 @@ import com.epmet.constant.PartyServiceCenterConstant;
import com.epmet.dao.IcMatterAppointmentRecordDao;
import com.epmet.dao.IcPartyServiceCenterDao;
import com.epmet.dto.IcPartyServiceCenterDTO;
import com.epmet.dto.TimeDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.PartyServiceCenterListResultDTO;
import com.epmet.entity.IcMatterAppointmentRecordEntity;
@ -51,10 +52,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
import static com.epmet.commons.tools.utils.DateUtils.DATE_PATTERN;
@ -278,4 +279,67 @@ public class IcPartyServiceCenterServiceImpl extends BaseServiceImpl<IcPartyServ
return result;
}
public List<TimeDTO> getTimeList(String start,String end,Integer interval){
List<TimeDTO> result = new ArrayList<>();
List<String> intervalTimeList = getIntervalTimeList(start, end, interval);
Integer sort = NumConstant.ONE;
for (int i = NumConstant.ZERO; i < intervalTimeList.size(); i++) {
if (i + NumConstant.ONE >= intervalTimeList.size()){
return result;
}
TimeDTO timeDTO = new TimeDTO();
timeDTO.setTime(intervalTimeList.get(i) + "-" + intervalTimeList.get(i + NumConstant.ONE));
timeDTO.setTimeId(String.valueOf(sort++));
result.add(timeDTO);
}
return result;
}
/**
* @Description 获取固定时间段之间固定时间的集合
* @param start 开始时间
* @param end 结束时间
* @param interval 间隔时间
* @author zxc
* @date 2021/11/22 3:48 下午
*/
public List<String> getIntervalTimeList(String start,String end,Integer interval) {
Date startDate = convertStringToDate("HH:mm", start);
Date endDate = convertStringToDate("HH:mm", end);
List<String> list = new ArrayList<>();
while (startDate.getTime() <= endDate.getTime()) {
list.add(convertDateToString("HH:mm", startDate));
Calendar calendar = Calendar.getInstance();
calendar.setTime(startDate);
calendar.add(Calendar.MINUTE, interval);
if (calendar.getTime().getTime() > endDate.getTime()) {
if (!startDate.equals(endDate)) {
list.add(convertDateToString("HH:mm", endDate));
}
startDate = calendar.getTime();
} else {
startDate = calendar.getTime();
}
}
return list;
}
public Date convertStringToDate(String format, String dateStr) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
try {
Date date = simpleDateFormat.parse(dateStr);
return date;
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
public String convertDateToString(String format, Date date) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
return simpleDateFormat.format(date);
}
}
Loading…
Cancel
Save