|
|
|
@ -4,16 +4,14 @@ import com.markma.leave_manager_spb.entity.LeaveDetail;
|
|
|
|
|
import com.markma.leave_manager_spb.entity.OutDetail;
|
|
|
|
|
import com.markma.leave_manager_spb.entity.UserDetail;
|
|
|
|
|
import com.markma.leave_manager_spb.repository.LeaveDetailRepository;
|
|
|
|
|
|
|
|
|
|
import com.markma.leave_manager_spb.repository.OutDetailRepository;
|
|
|
|
|
import com.markma.leave_manager_spb.repository.UserDetailRepository;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import java.text.DateFormat;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Locale;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
@ -23,6 +21,8 @@ public class LeaveDetailHandler {
|
|
|
|
|
private LeaveDetailRepository leaveDetailRepository;
|
|
|
|
|
@Autowired
|
|
|
|
|
private UserDetailRepository userDetailRepository;
|
|
|
|
|
@Autowired
|
|
|
|
|
private OutDetailRepository outDetailRepository;
|
|
|
|
|
|
|
|
|
|
public static long dateToMs(String _date, String pattern) {
|
|
|
|
|
SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.getDefault());
|
|
|
|
@ -157,8 +157,8 @@ public class LeaveDetailHandler {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("findFromSID/{school_id}")
|
|
|
|
|
public List<LeaveDetail> findFromSID(@PathVariable("school_id") int school_id) {
|
|
|
|
|
@GetMapping("findFromSIDTimeLimit/{school_id}/{page}/{size}")
|
|
|
|
|
public List<LeaveDetail> findFromSID(@PathVariable("school_id") String school_id, @PathVariable("page") int page, @PathVariable("size") int size) {
|
|
|
|
|
List<LeaveDetail> LDs = leaveDetailRepository.findAll();
|
|
|
|
|
List<UserDetail> UDs = userDetailRepository.findAll();
|
|
|
|
|
UserDetail UD = null;
|
|
|
|
@ -171,15 +171,50 @@ public class LeaveDetailHandler {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Integer UDid = UD.getId();
|
|
|
|
|
|
|
|
|
|
int num = 0, pageNum = 0;
|
|
|
|
|
for (int i = 0; i < LDs.size(); i++) {
|
|
|
|
|
LD = LDs.get(i);
|
|
|
|
|
|
|
|
|
|
if (LD.getUserid().equals(UDid)) {
|
|
|
|
|
result.add(LD);
|
|
|
|
|
long backTimeMS = dateToMs(LD.getBack_time(), "yyyy-mm-dd hh:mm:ss");
|
|
|
|
|
long leaveTimeMS = dateToMs(LD.getLeave_time(), "yyyy-mm-dd hh:mm:ss");
|
|
|
|
|
long nowTimeMS = System.currentTimeMillis();
|
|
|
|
|
if (nowTimeMS > leaveTimeMS && nowTimeMS < backTimeMS && LD.getType().equals("已通过")) {
|
|
|
|
|
num++;
|
|
|
|
|
pageNum = num / size;
|
|
|
|
|
if (num % size != 0) pageNum++;
|
|
|
|
|
if (pageNum == page) result.add(LD);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("findByIDAndSaveOD/{leave_detail_id}")
|
|
|
|
|
public String findByIDAndSaveOD(@PathVariable Integer leave_detail_id) {
|
|
|
|
|
List<LeaveDetail> LDs = leaveDetailRepository.findAll();
|
|
|
|
|
LeaveDetail LD = null;
|
|
|
|
|
for (int i = 0; i < LDs.size(); i++) {
|
|
|
|
|
if (LDs.get(i).getId().equals(leave_detail_id)) {
|
|
|
|
|
LD = LDs.get(i);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
|
String now = df.format(calendar.getTime());
|
|
|
|
|
|
|
|
|
|
OutDetail OD = new OutDetail();
|
|
|
|
|
OD.setLeave_detail_id(leave_detail_id);
|
|
|
|
|
OD.setUserid(LD.getUserid());
|
|
|
|
|
OD.setOut_time(now);
|
|
|
|
|
OutDetail result = outDetailRepository.save(OD);
|
|
|
|
|
if (result != null) {
|
|
|
|
|
return "success";
|
|
|
|
|
} else {
|
|
|
|
|
return "error";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|