Преглед на файлове

update unsubmitted timesheet departDate & leave check

pull/3/head
MSI\derek преди 7 месеца
родител
ревизия
8fb91756ba
променени са 2 файла, в които са добавени 37 реда и са изтрити 35 реда
  1. +31
    -30
      src/main/java/com/ffii/tsms/modules/data/service/DashboardService.kt
  2. +6
    -5
      src/main/java/com/ffii/tsms/modules/data/web/DashboardController.kt

+ 31
- 30
src/main/java/com/ffii/tsms/modules/data/service/DashboardService.kt Целия файл

@@ -4,12 +4,10 @@ import com.ffii.core.support.JdbcDao
import com.ffii.core.utils.CheckingUtils
import com.ffii.tsms.modules.data.entity.CustomerRepository
import com.ffii.tsms.modules.data.entity.CustomerTypeRepository
import com.ffii.tsms.modules.data.entity.StaffRepository
import com.ffii.tsms.modules.data.entity.TeamRepository
import com.ffii.tsms.modules.data.web.models.FinancialSummaryByClient
import com.ffii.tsms.modules.data.web.models.FinancialSummaryByProject
import com.ffii.tsms.modules.project.entity.*
import com.ffii.tsms.modules.project.entity.projections.DashboardData
import com.ffii.tsms.modules.project.service.InvoiceService
import com.ffii.tsms.modules.project.service.ProjectExpenseService
import com.ffii.tsms.modules.timesheet.entity.TimesheetRepository
@@ -29,21 +27,13 @@ import java.time.format.DateTimeFormatter

@Service
open class DashboardService(
private val customerRepository: CustomerRepository,
private val customerTypeRepository: CustomerTypeRepository,
private val customerSubsidiaryService: CustomerSubsidiaryService,
private val customerContactService: CustomerContactService,
private val projectRepository: ProjectRepository,
private val timesheetsService: TimesheetsService,
private val invoiceService: InvoiceService,
private val projectExpenseService: ProjectExpenseService,
private val timesheetRepository: TimesheetRepository,
private val invoiceRepository: InvoiceRepository,
private val staffsService: StaffsService,
private val teamLogService: TeamLogService,
private val salaryEffectiveService: SalaryEffectiveService,
private val projectExpenseRepository: ProjectExpenseRepository,
private val teamRepository: TeamRepository,
private val companyHolidayService: CompanyHolidayService,
private val jdbcDao: JdbcDao
) {
@@ -2672,7 +2662,7 @@ open class DashboardService(
+ " left join team_cte tc on tc.staffId = t.staffId "
+ " left join staff s on s.id = t.staffId "
+ " where t.recordDate >= :startdate and t.recordDate < DATE_ADD(:startdate, INTERVAL 1 MONTH) "
+ " union "
+ " union all"
+ " select "
+ " recordDate, "
+ " staffId, "
@@ -2708,7 +2698,7 @@ open class DashboardService(
+ " left join team_cte tc on tc.staffId = t.staffId "
+ " left join staff s on s.id = t.staffId "
+ " where t.recordDate >= :startdate and t.recordDate < DATE_ADD(:startdate, INTERVAL 7 DAY) "
+ " union "
+ " union all "
+ " select "
+ " recordDate, "
+ " staffId, "
@@ -2722,9 +2712,12 @@ open class DashboardService(
+ " and staffId = :staffId; "
)
return jdbcDao.queryForList(submittedSQL.toString(), args)
// change to for int, count(marked)
}

fun getWeeklyUnsubmittedTimesheet(args: Map<String, Any>): List<Map<String, Any>> {
val today = LocalDate.now()
val today2 = LocalDate.now()
val result = mutableListOf<Map<String, Any>>()
val teamId = args["teamId"] as Long
val staffs = staffsService.findAll().orElseThrow()
@@ -2732,44 +2725,45 @@ open class DashboardService(
val year = startDate.year
val month = startDate.month
val day = startDate.dayOfMonth

val dayInWeek = today.dayOfWeek.value % 7
// println(today.dayOfWeek.value % 7)
val yearMonth = YearMonth.of(year, month)
val daysInMonth = yearMonth.lengthOfMonth()
val dateList = (0..6).mapNotNull {
val date = LocalDate.of(year, month, day + it)
if (date.dayOfWeek != DayOfWeek.SATURDAY && date.dayOfWeek != DayOfWeek.SUNDAY) {
date // Include the date if it's not Saturday or Sunday
} else {
null
}
val dateList = (1..5).map {
val date = LocalDate.of(year, month, day)
val newDate = date.plusDays(it.toLong())
newDate
}.toMutableList()
val publicHolidayList = (args["publicHolidayList"] as List<LocalDate>).filter { it.year == startDate.year && it.month == startDate.month }
val publicHolidayList = (args["publicHolidayList"] as List<LocalDate>).filter {it >= dateList.first() && it <= dateList.last() }
val companyHoliday = companyHolidayService.allCompanyHolidays().filter { it.date.month == month }
val thisArgs = args.toMutableMap()

for (curr in staffs) {
val thisTeam = teamLogService.getStaffTeamLog(curr.id!!, startDate)
println(thisTeam)
if (thisTeam == null || thisTeam.team.id != teamId) {
continue
}
if (curr.departDate != null) {
dateList.filter { it.isBefore(curr.departDate) }
publicHolidayList.filter { it.isBefore(curr.departDate) }
companyHoliday.filter { it.date.isBefore(curr.departDate) }
}
thisArgs["staffId"] = curr.id!!
val submittedMonth = monthlySubmittedTimesheet(thisArgs)
val UnsubmittedCount = dateList.size - publicHolidayList.size - companyHoliday.size - submittedMonth.size
val submittedWeek = weeklySubmittedTimesheet(thisArgs)
val unsubmittedCount = dateList.size - publicHolidayList.size - companyHoliday.size - submittedWeek.size
if (unsubmittedCount <= 0) continue
result.add(
mapOf(
"id" to curr.id!!,
"name" to curr.name,
"teamId" to thisTeam.team.id,
"UnsubmittedCount" to UnsubmittedCount,
"UnsubmittedCount" to unsubmittedCount,
))
}
return result
}
fun getMonthlyUnsubmittedTimesheet(args: Map<String, Any>): List<Map<String, Any>> {
val today = LocalDate.now()
val result = mutableListOf<Map<String, Any>>()
val teamId = args["teamId"] as Long
val staffs = staffsService.findAll().orElseThrow()
@@ -2777,8 +2771,12 @@ open class DashboardService(
val year = startDate.year
val month = startDate.month
val yearMonth = YearMonth.of(year, month)
val daysInMonth = yearMonth.lengthOfMonth()
val dateList = (1..daysInMonth).mapNotNull { day ->
val dayInMonth = if (today.year == startDate.year && today.month == startDate.month) {
today.dayOfMonth
} else {
yearMonth.lengthOfMonth()
}
val dateList = (1..dayInMonth).mapNotNull { day ->
val date = LocalDate.of(year, month, day)
if (date.dayOfWeek != DayOfWeek.SATURDAY && date.dayOfWeek != DayOfWeek.SUNDAY) {
date // Include the date if it's not Saturday or Sunday
@@ -2792,22 +2790,25 @@ open class DashboardService(

for (curr in staffs) {
val thisTeam = teamLogService.getStaffTeamLog(curr.id!!, startDate)
println(thisTeam)
// println(thisTeam)
if (thisTeam == null || thisTeam.team.id != teamId) {
continue
}
if (curr.departDate != null) {
dateList.filter { it.isBefore(curr.departDate) }
publicHolidayList.filter { it.isBefore(curr.departDate) }
companyHoliday.filter { it.date.isBefore(curr.departDate) }
}
thisArgs["staffId"] = curr.id!!
val submittedMonth = monthlySubmittedTimesheet(thisArgs)
val UnsubmittedCount = dateList.size - publicHolidayList.size - companyHoliday.size - submittedMonth.size
val unsubmittedCount = dateList.size - publicHolidayList.size - companyHoliday.size - submittedMonth.size
if (unsubmittedCount <= 0) continue
result.add(
mapOf(
"id" to curr.id!!,
"name" to curr.name,
"teamId" to thisTeam.team.id,
"UnsubmittedCount" to UnsubmittedCount,
"UnsubmittedCount" to unsubmittedCount,
))
}
return result


+ 6
- 5
src/main/java/com/ffii/tsms/modules/data/web/DashboardController.kt Целия файл

@@ -350,20 +350,21 @@ class DashboardController(
val publicHolidayListParam = request?.getParameter("publicHolidayList")
println(enddate)
if (teamId != null) {
args["teamId"] = teamId
args["teamId"] = teamId.toLong()
}
if (startdate != null) {
args["startdate"] = startdate
args["startdate"] = LocalDate.parse(startdate)
}
if (enddate != null) {
args["enddate"] = enddate
args["enddate"] = LocalDate.parse(enddate)
}
if (publicHolidayListParam != null) {
val publicHolidayList = publicHolidayListParam.split(",").map { it.trim() }
val publicHolidayList = publicHolidayListParam.split(",").map { LocalDate.parse(it.trim()) }
args["publicHolidayList"] = publicHolidayList
}
println(args)
return dashboardService.weeklyUnsubmittedTimeSheet(args)
return dashboardService.getWeeklyUnsubmittedTimesheet(args)
// return dashboardService.weeklyUnsubmittedTimeSheet(args)
}
@GetMapping("/searchMonthlyUnsubmittedTimeSheet")
fun searchMonthlyUnsubmittedTimeSheet(request: HttpServletRequest?): List<Map<String, Any>> {


Зареждане…
Отказ
Запис