Commit 83ecc05e authored by ='s avatar =

hieuuuuuuuuuuuuuuuuuuuuuuuu

parent 7f1278ac
......@@ -23,7 +23,7 @@ public abstract class DateAudit implements Serializable {
private Instant createdAt;
@LastModifiedDate
@Column(nullable = false, columnDefinition = "null")
@Column(nullable = false)
private Instant updatedAt;
public Instant getCreatedAt() {
......
......@@ -2,14 +2,19 @@ package com.itsol.quantrivanphong.manager.reportdetail.bussiness;
import com.itsol.quantrivanphong.manager.reportdetail.dto.request.ReportDTO;
import com.itsol.quantrivanphong.manager.reportdetail.dto.request.TimesheetRequestDTO;
import com.itsol.quantrivanphong.manager.reportdetail.repository.ProjectReportRepository;
import com.itsol.quantrivanphong.manager.project.project.repository.ProjectRRepository;
import com.itsol.quantrivanphong.model.Project;
import com.itsol.quantrivanphong.model.ProjectReport;
import com.itsol.quantrivanphong.model.*;
import com.itsol.quantrivanphong.report.timesheet.business.TimeSheetBusiness;
import com.itsol.quantrivanphong.report.timesheet.dto.TimeSheetDTO;
import com.itsol.quantrivanphong.report.timesheet.repository.EProjectRepository;
import com.itsol.quantrivanphong.report.timesheet.repository.TimeSheetRepository;
import com.itsol.quantrivanphong.repository.EmployeeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
......@@ -23,6 +28,13 @@ public class ReportProjectBussiness {
@Autowired
private ProjectReportRepository projectReportRepository;
@Autowired
private EProjectRepository eProjectRepository;
@Autowired
private TimeSheetRepository timeSheetRepository;
//======================================================================================================================
public List<Project> listProjectWorking(){
......@@ -32,6 +44,47 @@ public class ReportProjectBussiness {
}else
return projectList;
}
//======================================================================================================================
public List<TimeSheet> findAllTimesheetStatusTrue(ReportDTO reportDTO){
List<TimeSheet> timeSheetList = timeSheetRepository.findAllTimesheetStatusTrue(reportDTO.getProjectId(), reportDTO.getCurrentDate());
return timeSheetList;
}
public String updateTimesheetStatus(ReportDTO reportDTO){
String mess;
try {
List<Eproject> eprojectList = eProjectRepository.listEprojectLack(reportDTO.getProjectId(), reportDTO.getCurrentDate());
List<Integer> list = new ArrayList<>();
for (Eproject eproject: eprojectList) {
list.add(eproject.getId());
}
for (Integer i: list){
timeSheetRepository.updateLack(i,false,"checked");
}
mess = "OK !";
}catch (Exception e){
mess = e.getMessage();
}
return mess;
}
public String updateTimesheetChecked(TimesheetRequestDTO timesheetRequestDTO){
String mess;
try {
timeSheetRepository.updateTimesheetChecked(timesheetRequestDTO.getChecked(),timesheetRequestDTO.getId());
mess = "OK !";
}catch (Exception e){
mess = e.getMessage();
}
return mess;
}
//======================================================================================================================
public List<ProjectReport> allProjectReport(ReportDTO reportDTO){
......@@ -46,4 +99,12 @@ public class ReportProjectBussiness {
return projectReportRepository.latestReport(reportDTO.getProjectId());
}
public List<Employee> listLackOfReport(ReportDTO reportDTO){
List<Employee> employeeList = employeeRepository.listLackOfReport(reportDTO.getProjectId(), reportDTO.getCurrentDate());
return employeeList;
}
}
......@@ -2,14 +2,14 @@ package com.itsol.quantrivanphong.manager.reportdetail.controller;
import com.itsol.quantrivanphong.manager.reportdetail.bussiness.ReportProjectBussiness;
import com.itsol.quantrivanphong.manager.reportdetail.dto.request.ReportDTO;
import com.itsol.quantrivanphong.manager.reportdetail.dto.request.TimesheetRequestDTO;
import com.itsol.quantrivanphong.model.Employee;
import com.itsol.quantrivanphong.model.Project;
import com.itsol.quantrivanphong.model.ProjectReport;
import com.itsol.quantrivanphong.model.TimeSheet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
......@@ -19,21 +19,67 @@ public class ReportProjectController {
@Autowired
private ReportProjectBussiness reportProjectBussiness;
//======================================================================================================================
//Danh sách các dự án đang trong thời gian triển khai
@GetMapping(path = "/project/all",consumes = "application/json", produces = "application/json")
public ResponseEntity<List<Project>> listProjectWorking(){
List<Project> projectList = reportProjectBussiness.listProjectWorking();
return ResponseEntity.ok(projectList);
return ResponseEntity.ok(projectList);
}
//======================================================================================================================
//Hiển thị danh sách timesheet của các thành viên đã viết báo cáo trong ngày hôm đó
@GetMapping(path = "/project/timesheet",consumes = "application/json", produces = "application/json")
public ResponseEntity<List<TimeSheet>> findAllTimesheetStatusTrue(@RequestBody ReportDTO reportDTO){
List<TimeSheet> timeSheetList = reportProjectBussiness.findAllTimesheetStatusTrue(reportDTO);
return ResponseEntity.ok(timeSheetList);
}
//Nút "kiểm tra" : Lọc các thành viên chưa viết báo cáo và tự khởi tạo timesheet với trạng thái thái = false
@GetMapping(path = "/project/updateLack", consumes = "application/json", produces = "application/json")
public ResponseEntity<String> updateTimesheetStatus(@RequestBody ReportDTO reportDTO){
String mess = reportProjectBussiness.updateTimesheetStatus(reportDTO);
return ResponseEntity.ok(mess);
}
//Quản trị viên duyệt và đánh dấu (đã duyệt, từ chối) mặc định là chưa duyệt (update bảng timesheet theo id)
@PostMapping(path = "/project/check", consumes = "application/json", produces = "application/json")
public ResponseEntity<String> updateTimesheetChecked(@RequestBody TimesheetRequestDTO timesheetRequestDTO){
String mess = reportProjectBussiness.updateTimesheetChecked(timesheetRequestDTO);
return ResponseEntity.ok(mess);
}
//Danh sách thành viên trong Dự án thiếu báo cáo ngày hôm đó
@GetMapping(path = "/project/alllack",consumes = "application/json", produces = "application/json")
public ResponseEntity<List<Employee>> listLackOfReport(@RequestBody ReportDTO reportDTO){
List<Employee> employeeList = reportProjectBussiness.listLackOfReport(reportDTO);
return ResponseEntity.ok(employeeList);
}
//=================================================================================================================
//Báo cáo gần nhất của dự án
@GetMapping(path = "/project/latest",consumes = "application/json", produces = "application/json")
public ResponseEntity<ProjectReport> latestReport(@RequestBody ReportDTO reportDTO){
ProjectReport projectReport = reportProjectBussiness.latestReport(reportDTO);
return ResponseEntity.ok(projectReport);
}
// Tất cả các báo cáo của dự án
@GetMapping(path = "/project/allReport",consumes = "application/json", produces = "application/json")
public ResponseEntity<List<ProjectReport>> allProjectReport(@RequestBody ReportDTO reportDTO){
List<ProjectReport> projectReportList = reportProjectBussiness.allProjectReport(reportDTO);
return ResponseEntity.ok(projectReportList);
}
}
......@@ -10,6 +10,7 @@ import lombok.NoArgsConstructor;
public class ReportDTO {
private String firstPoint;
private String finalPoint;
private String currentDate;
private int projectId;
private String position;
private boolean status;
......
package com.itsol.quantrivanphong.manager.reportdetail.dto.request;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TimesheetRequestDTO {
private int id;
private String checked;
}
......@@ -3,10 +3,24 @@ package com.itsol.quantrivanphong.report.timesheet.repository;
import com.itsol.quantrivanphong.model.Employee;
import com.itsol.quantrivanphong.model.Eproject;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
public interface EProjectRepository extends JpaRepository<Eproject, Integer> {
// Eproject findEprojectById(int id);
Eproject findEprojectByEmployee(Employee employee);
Eproject findEprojectByIdAndEmployee(int eProject_Id, Employee employee);
//======================================================================================================
// Hieunv
@Query(value = "SELECT * FROM eproject ep JOIN project p on p.id = ep.project_id WHERE p.id = ?1 AND ep.employee_id NOT IN (SELECT e.id FROM employee e JOIN eproject ep ON e.id = ep.employee_id JOIN project p on p.id = ep.project_id JOIN timesheet ts on ts.eproject_id = ep.id WHERE p.id = ?1 AND ts.created_at Like ?2%)", nativeQuery = true)
List<Eproject> listEprojectLack(int projectId, String currentDate);
}
......@@ -5,6 +5,8 @@ import com.itsol.quantrivanphong.model.TimeSheet;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
......@@ -26,4 +28,22 @@ public interface TimeSheetRepository extends JpaRepository<TimeSheet, Integer> {
List<TimeSheet> showTimeSheetByEproject(Eproject eproject);
TimeSheet findTimeSheetByEprojectAndId(Eproject eproject, int timeSheet_Id);
//==================================================================================================================
//Timesheet Of Hieunv
@Query(value = "SELECT * FROM timesheet ts JOIN eproject ep ON ep.id = ts.eproject_id WHERE ep.project_id = ?1 AND ts.status = true and ts.created_at like ?2%", nativeQuery = true)
List<TimeSheet> findAllTimesheetStatusTrue(int projectId, String currentDate);
@Transactional
@Modifying
@Query(value = "INSERT INTO timesheet(eproject_id, status, created_at, updated_at, checked) VALUES (?1, ?2,current_date(), current_date(),?3)",nativeQuery = true)
void updateLack(int eprojectId, boolean status, String checked);
@Transactional
@Modifying
@Query(value = "update TimeSheet ts set ts.checked = ?1 where ts.id = ?2", nativeQuery = true)
void updateTimesheetChecked(String checked, int id);
}
......@@ -5,6 +5,8 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface EmployeeRepository extends JpaRepository<Employee,Integer > {
public Employee findEmployeeByUsername(String username);
......@@ -26,6 +28,13 @@ public interface EmployeeRepository extends JpaRepository<Employee,Integer > {
@Query(value = "SELECT COUNT(e.id)FROM employee e JOIN eproject ep ON e.id = ep.employee_id JOIN project p ON ep.project_id = p.id WHERE p.id = ?1 AND ep.position = 'member'", nativeQuery = true)
int numberOfMember(int projectId);
@Query(value = "SELECT e.username FROM employee e JOIN eproject ep ON e.id = ep.employee_id JOIN project p ON ep.project_id = p.id WHERE p.id = ?1 AND ep.position = 'team_lead' GROUP BY e.id",nativeQuery = true)
List<Employee> listEmployeeLackOfReport(int projectId);
@Query(value = "SELECT * FROM employee e JOIN eproject ep ON e.id = ep.employee_id JOIN project p on p.id = ep.project_id JOIN timesheet ts ON ep.id = ts.eproject_id WHERE p.id = ?1 AND ts.status = false AND ts.created_at Like ?2%", nativeQuery = true)
List<Employee> listLackOfReport(int projectId, String createDate);
//==================================================================================================================
//Emplyee Repository Of PhiCho
Employee findEmployeeById(int id);
......
......@@ -13,7 +13,6 @@ spring.datasource.password=
# ===============================
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
#spring.jpa.properties.hibernate.default_schema=qlns_itsol
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment