技师设置时间
This commit is contained in:
parent
018686ee11
commit
d646c70feb
|
@ -28,6 +28,7 @@ import java.text.SimpleDateFormat;
|
|||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Service
|
||||
|
@ -101,28 +102,30 @@ public class ArtificerTimeServiceImpl extends ServiceImpl<ArtificerTimeDao, Arti
|
|||
public Result setArtificerTime(String idleTime,String busyTime,Long userId){
|
||||
Artificer artificer = artificerService.selectArtificerByUserId(userId);
|
||||
if(StringUtils.isNotEmpty(idleTime)){
|
||||
Map<String,List> dateMap = new HashMap();
|
||||
for(String times:idleTime.split(",")){
|
||||
String[] datetime = times.split(" ");
|
||||
if(datetime!=null && datetime.length>0) {
|
||||
baseMapper.delete(new QueryWrapper<ArtificerTime>().eq("artificer_date", datetime[0]).eq("artificer_id", artificer.getArtificerId()).eq("artificer_time", datetime[1]));
|
||||
if(dateMap.get(datetime[0])!=null){
|
||||
List<String> timeList = dateMap.get(datetime[0]);
|
||||
timeList.add(datetime[1]);
|
||||
}else{
|
||||
List<String> timeList = new ArrayList<>();
|
||||
timeList.add(datetime[1]);
|
||||
dateMap.put(datetime[0],timeList);
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String,Map> busyMap = getBusyMap(dateMap);
|
||||
String[] idelTimes = idleTime.split(",");
|
||||
String[] datetime1 = idelTimes[0].split(" ");
|
||||
String startDay = datetime1[0];
|
||||
String startTime = datetime1[1];
|
||||
String[] datetime2 = idelTimes[1].split(" ");
|
||||
String endDay = datetime2[0];
|
||||
String endTime = datetime2[1];
|
||||
QueryWrapper qw = new QueryWrapper<ArtificerTime>();
|
||||
qw.eq("artificer_id", artificer.getArtificerId());
|
||||
qw.ge("artificer_date", startDay);
|
||||
qw.le("artificer_date", endDay);
|
||||
qw.ge("artificer_time", startTime);
|
||||
qw.le("artificer_time", endTime);
|
||||
baseMapper.delete(qw);
|
||||
|
||||
Map<String,List> dateMap = getIdelMap(idelTimes[0],idelTimes[1]);
|
||||
|
||||
Map<String,List> busyMap = getBusyMap(dateMap);
|
||||
for (String key : busyMap.keySet()) {
|
||||
Map<String,String> busyTimeMap = busyMap.get(key);
|
||||
for (String timeKey : busyTimeMap.keySet()) {
|
||||
List<String> busyTimeList = busyMap.get(key);
|
||||
for(String time : busyTimeList){
|
||||
ArtificerTime artificerTime=new ArtificerTime();
|
||||
artificerTime.setArtificerDate(key);
|
||||
artificerTime.setArtificerTime(busyTimeMap.get(timeKey));
|
||||
artificerTime.setArtificerTime(time);
|
||||
artificerTime.setArtificerId(artificer.getArtificerId());
|
||||
artificerTime.setClassify(2);
|
||||
artificerTime.setCreateTime(DateUtils.format(new Date()));
|
||||
|
@ -150,18 +153,41 @@ public class ArtificerTimeServiceImpl extends ServiceImpl<ArtificerTimeDao, Arti
|
|||
return Result.success();
|
||||
}
|
||||
|
||||
private Map<String,Map> getBusyMap(Map<String,List> dateMap){
|
||||
Map<String,Map> map = new HashMap();
|
||||
private Map<String,List> getIdelMap(String startDateStr,String endDateStr){
|
||||
Map<String,List> map = new HashMap();
|
||||
Date startDate = DateUtils.stringToDate(startDateStr,"yyyy-MM-dd HH:mm");
|
||||
Date endDate = DateUtils.stringToDate(endDateStr,"yyyy-MM-dd HH:mm");
|
||||
Date current = startDate;
|
||||
while(current.getTime()<=endDate.getTime()){
|
||||
String day = DateUtils.format(current,"yyyy-MM-dd");
|
||||
String time = DateUtils.format(current,"HH:mm");
|
||||
if(map.get(day)!=null){
|
||||
List<String> timeList = map.get(day);
|
||||
timeList.add(time);
|
||||
}else{
|
||||
List<String> timeList = new ArrayList<>();
|
||||
timeList.add(time);
|
||||
map.put(day,timeList);
|
||||
}
|
||||
DateUtils.addDateMinutes(current,30);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private Map<String,List> getBusyMap(Map<String,List> dateMap){
|
||||
Map<String,List> map = new HashMap();
|
||||
for (String key : dateMap.keySet()) {
|
||||
List<String> timeList = dateMap.get(key);
|
||||
Map allTimes = getTimeMap();
|
||||
Map<String,String> allTimes = getTimeMap();
|
||||
for(int i=0; i < timeList.size();i++){
|
||||
String time = timeList.get(i);
|
||||
if(allTimes.get(time)!=null){
|
||||
allTimes.remove(time);
|
||||
}
|
||||
}
|
||||
map.put(key,allTimes);
|
||||
List<String> keyList = allTimes.keySet().stream().collect(Collectors.toList());
|
||||
Collections.sort(keyList);
|
||||
map.put(key,keyList);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
@ -183,24 +209,28 @@ public class ArtificerTimeServiceImpl extends ServiceImpl<ArtificerTimeDao, Arti
|
|||
|
||||
public static void main(String[] args) {
|
||||
|
||||
String idleTime = "2024-08-28 12:00,2024-08-28 13:00,2024-08-28 14:00,2024-08-28 15:00,2024-08-28 16:00,2024-08-28 17:00,2024-08-28 18:00,2024-08-28 19:00,2024-08-28 20:00,2024-08-28 21:00,2024-08-28 22:00,2024-08-28 23:00,2024-08-29 00:30,2024-08-29 01:30,2024-08-29 02:30,2024-08-29 03:30,2024-08-29 04:30,2024-08-29 05:30,2024-08-29 06:30,2024-08-29 07:30,2024-08-29 08:30,2024-08-29 09:30";
|
||||
String idleTime = "2024-08-28 12:00,2024-08-28 18:30";
|
||||
String[] idelTimes = idleTime.split(",");
|
||||
|
||||
Map<String,List> dateMap = new HashMap();
|
||||
for(String times:idleTime.split(",")){
|
||||
String[] datetime = times.split(" ");
|
||||
if(datetime!=null && datetime.length>0) {
|
||||
if(dateMap.get(datetime[0])!=null){
|
||||
List<String> timeList = dateMap.get(datetime[0]);
|
||||
timeList.add(datetime[1]);
|
||||
}else{
|
||||
List<String> timeList = new ArrayList<>();
|
||||
timeList.add(datetime[1]);
|
||||
dateMap.put(datetime[0],timeList);
|
||||
}
|
||||
Date startDate = DateUtils.stringToDate(idelTimes[0],"yyyy-MM-dd HH:mm");
|
||||
Date endDate = DateUtils.stringToDate(idelTimes[1],"yyyy-MM-dd HH:mm");
|
||||
Date current = startDate;
|
||||
while(current.getTime()<=endDate.getTime()){
|
||||
String day = DateUtils.format(current,"yyyy-MM-dd");
|
||||
String time = DateUtils.format(current,"HH:mm");
|
||||
if(dateMap.get(day)!=null){
|
||||
List<String> timeList = dateMap.get(day);
|
||||
timeList.add(time);
|
||||
}else{
|
||||
List<String> timeList = new ArrayList<>();
|
||||
timeList.add(time);
|
||||
dateMap.put(day,timeList);
|
||||
}
|
||||
current = DateUtils.addDateMinutes(current,30);
|
||||
}
|
||||
|
||||
Map<String,Map> map = new HashMap();
|
||||
Map<String,List> map = new HashMap();
|
||||
for (String key : dateMap.keySet()) {
|
||||
List<String> timeList = dateMap.get(key);
|
||||
Map<String,String> allTimes = new HashMap();
|
||||
|
@ -220,19 +250,20 @@ public class ArtificerTimeServiceImpl extends ServiceImpl<ArtificerTimeDao, Arti
|
|||
allTimes.remove(time);
|
||||
}
|
||||
}
|
||||
map.put(key,allTimes);
|
||||
List<String> keyList = allTimes.keySet().stream().collect(Collectors.toList());
|
||||
Collections.sort(keyList);
|
||||
map.put(key,keyList);
|
||||
}
|
||||
|
||||
for (String key : map.keySet()) {
|
||||
Map<String,String> busyTimeMap = map.get(key);
|
||||
for (String timeKey : busyTimeMap.keySet()) {
|
||||
List<String> busyTimeList = map.get(key);
|
||||
for(String time : busyTimeList){
|
||||
System.out.print(key);
|
||||
System.out.print(" ");
|
||||
System.out.print(busyTimeMap.get(timeKey));
|
||||
System.out.print(time);
|
||||
System.out.println("");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
if(c.id is null,0,1) as sfdz
|
||||
FROM bl_shipinquan a
|
||||
left join artificer b on a.create_by = b.user_id
|
||||
left join bl_shipinquan_dianzan c on a.id = c.shipinquan_id
|
||||
left join bl_shipinquan_dianzan c on a.id = c.shipinquan_id and c.create_by = #{params.createBy}
|
||||
<if test="params.userId!=null and params.userId!=''">and c.create_by = #{params.userId}</if>
|
||||
left join collect_artificer d on b.artificer_id = d.artificer_id
|
||||
<if test="params.userId!=null and params.userId!=''">and d.user_id = #{params.userId}</if>
|
||||
|
|
Loading…
Reference in New Issue