Commit ed0b2472 authored by ='s avatar =

Hieu

parent 4d795cae
package com.itsol.quantrivanphong.manager.reportdetail.bussiness; package com.itsol.quantrivanphong.manager.reportdetail.bussiness;
import com.itsol.quantrivanphong.manager.project.project.repository.ProjectRRepository;
import com.itsol.quantrivanphong.manager.reportdetail.dto.request.ReportDTO; import com.itsol.quantrivanphong.manager.reportdetail.dto.request.ReportDTO;
import com.itsol.quantrivanphong.manager.reportdetail.dto.request.TimesheetRequestDTO; import com.itsol.quantrivanphong.manager.reportdetail.dto.request.TimesheetRequestDTO;
import com.itsol.quantrivanphong.manager.reportdetail.repository.ProjectReportRepository; import com.itsol.quantrivanphong.manager.reportdetail.repository.ProjectReportRepository;
import com.itsol.quantrivanphong.manager.project.project.repository.ProjectRRepository;
import com.itsol.quantrivanphong.model.*; 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.EProjectRepository;
import com.itsol.quantrivanphong.report.timesheet.repository.TimeSheetRepository; import com.itsol.quantrivanphong.report.timesheet.repository.TimeSheetRepository;
import com.itsol.quantrivanphong.repository.EmployeeRepository; import com.itsol.quantrivanphong.repository.EmployeeRepository;
...@@ -34,6 +32,7 @@ public class ReportProjectBussiness { ...@@ -34,6 +32,7 @@ public class ReportProjectBussiness {
@Autowired @Autowired
private TimeSheetRepository timeSheetRepository; private TimeSheetRepository timeSheetRepository;
//====================================================================================================================== //======================================================================================================================
public List<Project> listProjectWorking(){ public List<Project> listProjectWorking(){
...@@ -105,6 +104,14 @@ public class ReportProjectBussiness { ...@@ -105,6 +104,14 @@ public class ReportProjectBussiness {
return employeeList; return employeeList;
} }
// public String insertProjectReport(ReportDTO reportDTO){
// ProjectReport projectReport = new ProjectReport();
// projectReport.setProjectName(projectRepository.ProjectName(reportDTO.getProjectId()));
// projectReport.setTeamLeader(employeeRepository.findTeamLeader(reportDTO.getProjectId()));
// projectReport.setNumberOfMember(employeeRepository.numberOfMember(reportDTO.getProjectId()));
// projectReport.setCalendarEffort(10);
// projectReport.set
// }
//
} }
...@@ -67,6 +67,17 @@ public class ReportProjectController { ...@@ -67,6 +67,17 @@ public class ReportProjectController {
//================================================================================================================= //=================================================================================================================
//Tạo một báo cáo mới
@PostMapping(path = "/project/newReport", consumes = "application/json", produces = "application/json")
public ResponseEntity<String> updateTimesheetChecked(@RequestBody TimesheetRequestDTO timesheetRequestDTO){
String mess = reportProjectBussiness.updateTimesheetChecked(timesheetRequestDTO);
return ResponseEntity.ok(mess);
}
//Báo cáo gần nhất của dự án //Báo cáo gần nhất của dự án
@GetMapping(path = "/project/latest",consumes = "application/json", produces = "application/json") @GetMapping(path = "/project/latest",consumes = "application/json", produces = "application/json")
public ResponseEntity<ProjectReport> latestReport(@RequestBody ReportDTO reportDTO){ public ResponseEntity<ProjectReport> latestReport(@RequestBody ReportDTO reportDTO){
......
...@@ -2,7 +2,9 @@ package com.itsol.quantrivanphong.manager.reportdetail.repository; ...@@ -2,7 +2,9 @@ package com.itsol.quantrivanphong.manager.reportdetail.repository;
import com.itsol.quantrivanphong.model.ProjectReport; import com.itsol.quantrivanphong.model.ProjectReport;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
...@@ -15,5 +17,8 @@ public interface ProjectReportRepository extends JpaRepository<ProjectReport, In ...@@ -15,5 +17,8 @@ public interface ProjectReportRepository extends JpaRepository<ProjectReport, In
@Query(value = "SELECT * FROM project_report pr WHERE pr.project_id = ?1 ORDER BY pr.created_at DESC", nativeQuery = true) @Query(value = "SELECT * FROM project_report pr WHERE pr.project_id = ?1 ORDER BY pr.created_at DESC", nativeQuery = true)
List<ProjectReport> allProjectReport(int projectId); List<ProjectReport> allProjectReport(int projectId);
@Transactional
@Modifying
@Query(value = "INSERT INTO project_report(project_name, team_leader, number_of_members, calendar_effort, lack_of_reports, created_at, updated_at, status, project_id) VALUES (?1, ?2, ?3, ?4, ?5, CURRENT_DATE(), CURRENT_DATE() ,?6, ?7)",nativeQuery = true)
void insertProjectReport(String projectName, String teamLeader, int NumberOfMember, int CalendarEffort, int LackOfReport, boolean status, int projectId);
} }
package com.itsol.quantrivanphong.report.timesheet.business; package com.itsol.quantrivanphong.report.timesheet.business;
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.model.Employee; import com.itsol.quantrivanphong.model.Employee;
import com.itsol.quantrivanphong.model.Eproject; import com.itsol.quantrivanphong.model.Eproject;
import com.itsol.quantrivanphong.model.TimeSheet; import com.itsol.quantrivanphong.model.TimeSheet;
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 com.itsol.quantrivanphong.repository.EmployeeRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -21,10 +21,10 @@ public class TimeSheetBusiness { ...@@ -21,10 +21,10 @@ public class TimeSheetBusiness {
EProjectRepository eProjectRepository; EProjectRepository eProjectRepository;
@Autowired @Autowired
EmployeeRepository employeeRepository; EmployeeRepository employeeRepository;
public String insertTimeSheet(int employee_Id, TimeSheetDTO timeSheetDTO) { public String insertTimeSheet(TimeSheetDTO timeSheetDTO) {
String message; String message;
Employee employee = employeeRepository.findEmployeeById(employee_Id); Employee employee = employeeRepository.findEmployeeById(timeSheetDTO.getEmployeeId());
Eproject eproject = eProjectRepository.findEprojectByIdAndEmployee(timeSheetDTO.getEproject_id(), employee); Eproject eproject = eProjectRepository.findEprojectByIdAndEmployee(timeSheetDTO.getEprojectId(), employee);
if (eproject != null) { if (eproject != null) {
// SimpleDateFormat formatter= new SimpleDateFormat("dd-MM-yyyy HH:mm"); // SimpleDateFormat formatter= new SimpleDateFormat("dd-MM-yyyy HH:mm");
// Date date = new Date(System.currentTimeMillis()); // Date date = new Date(System.currentTimeMillis());
...@@ -35,7 +35,7 @@ public class TimeSheetBusiness { ...@@ -35,7 +35,7 @@ public class TimeSheetBusiness {
timeSheet1.setNote(timeSheetDTO.getNote()); timeSheet1.setNote(timeSheetDTO.getNote());
timeSheet1.setEproject(eproject); timeSheet1.setEproject(eproject);
timeSheet1.setChecked(""); timeSheet1.setChecked("");
timeSheet1.setStatus(true); timeSheet1.setStatus(timeSheetDTO.isStatus());
TimeSheet timeSheet = timeSheetRepository.save(timeSheet1); TimeSheet timeSheet = timeSheetRepository.save(timeSheet1);
if (timeSheet != null) { if (timeSheet != null) {
......
package com.itsol.quantrivanphong.report.timesheet.controller; package com.itsol.quantrivanphong.report.timesheet.controller;
import com.itsol.quantrivanphong.exception.InputException; import com.itsol.quantrivanphong.exception.InputException;
import com.itsol.quantrivanphong.model.TimeSheet;
import com.itsol.quantrivanphong.report.timesheet.business.TimeSheetBusiness; import com.itsol.quantrivanphong.report.timesheet.business.TimeSheetBusiness;
import com.itsol.quantrivanphong.report.timesheet.dto.TimeSheetDTO; import com.itsol.quantrivanphong.report.timesheet.dto.TimeSheetDTO;
import com.itsol.quantrivanphong.model.TimeSheet;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -16,13 +16,13 @@ import java.util.List; ...@@ -16,13 +16,13 @@ import java.util.List;
public class TimeSheetController { public class TimeSheetController {
@Autowired @Autowired
TimeSheetBusiness timeSheetBusiness; TimeSheetBusiness timeSheetBusiness;
@PostMapping(path = "/{employee_Id}/timesheet", consumes = "application/json", produces = "application/json") @PostMapping(path = "/timesheet", consumes = "application/json", produces = "application/json")
public ResponseEntity<String> insertTimeSheet(@PathVariable int employee_Id, @Valid @RequestBody TimeSheetDTO timeSheetDTO) { public ResponseEntity<String> insertTimeSheet(@RequestBody TimeSheetDTO timeSheetDTO) {
String message; String message;
try { try {
if (timeSheetDTO.getTitle().trim().equals("")) throw new InputException("Tiêu đề không được để trống"); if (timeSheetDTO.getTitle().trim().equals("")) throw new InputException("Tiêu đề không được để trống");
if (timeSheetDTO.getContent().trim().equals("")) throw new InputException("Nội dung không được để trống"); if (timeSheetDTO.getContent().trim().equals("")) throw new InputException("Nội dung không được để trống");
message = timeSheetBusiness.insertTimeSheet(employee_Id, timeSheetDTO); message = timeSheetBusiness.insertTimeSheet(timeSheetDTO);
} catch (InputException e) { } catch (InputException e) {
message = e.getMessage(); message = e.getMessage();
} }
......
...@@ -14,5 +14,7 @@ public class TimeSheetDTO { ...@@ -14,5 +14,7 @@ public class TimeSheetDTO {
private String note; private String note;
private String checked; private String checked;
private boolean status; private boolean status;
private int eproject_id; private int eprojectId;
private int employeeId;
} }
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