浏览代码

update overconsum report

tags/Baseline_30082024_BACKEND_UAT
MSI\derek 1年前
父节点
当前提交
2a71500f1d
共有 4 个文件被更改,包括 16 次插入7 次删除
  1. +6
    -4
      src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt
  2. +9
    -3
      src/main/java/com/ffii/tsms/modules/report/web/ReportController.kt
  3. +1
    -0
      src/main/java/com/ffii/tsms/modules/report/web/model/ReportRequest.kt
  4. 二进制
      src/main/resources/templates/report/AR03_Resource Overconsumption.xlsx

+ 6
- 4
src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt 查看文件

@@ -1424,18 +1424,18 @@ open class ReportService(
generalCreateReportIndexed(sheet, result, rowIndex, columnIndex) generalCreateReportIndexed(sheet, result, rowIndex, columnIndex)


val sheetCF = sheet.sheetConditionalFormatting val sheetCF = sheet.sheetConditionalFormatting
val rule1 = sheetCF.createConditionalFormattingRule("AND(J7 >= $lowerLimit, J7 <= 1)")
val rule2 = sheetCF.createConditionalFormattingRule("J7 > 1")
val rule1 = sheetCF.createConditionalFormattingRule("AND(K7 >= $lowerLimit, K7 <= 1)")
val rule2 = sheetCF.createConditionalFormattingRule("K7 > 1")
var fillOrange = rule1.createPatternFormatting() var fillOrange = rule1.createPatternFormatting()
fillOrange.setFillBackgroundColor(IndexedColors.LIGHT_ORANGE.index); fillOrange.setFillBackgroundColor(IndexedColors.LIGHT_ORANGE.index);
fillOrange.setFillPattern(PatternFormatting.SOLID_FOREGROUND) fillOrange.setFillPattern(PatternFormatting.SOLID_FOREGROUND)


var fillRed = rule2.createPatternFormatting() var fillRed = rule2.createPatternFormatting()
fillRed.setFillBackgroundColor(IndexedColors.PINK.index);
fillRed.setFillBackgroundColor(IndexedColors.RED1.index);
fillRed.setFillPattern(PatternFormatting.SOLID_FOREGROUND) fillRed.setFillPattern(PatternFormatting.SOLID_FOREGROUND)


val cfRules = arrayOf(rule1, rule2) val cfRules = arrayOf(rule1, rule2)
val regions = arrayOf(CellRangeAddress.valueOf("\$J7:\$K${rowIndex + 1}"))
val regions = arrayOf(CellRangeAddress.valueOf("\$K7:\$L${rowIndex + 1}"))
sheetCF.addConditionalFormatting(regions, cfRules); sheetCF.addConditionalFormatting(regions, cfRules);


return workbook return workbook
@@ -1838,6 +1838,8 @@ open class ReportService(
sql.append("and t.id = :teamId") sql.append("and t.id = :teamId")
if (args.containsKey("custId")) if (args.containsKey("custId"))
sql.append("and c.id = :custId") sql.append("and c.id = :custId")
if (args.containsKey("subsidiaryId"))
sql.append("and ss.id = :subsidiaryId")
if (args.containsKey("status")) if (args.containsKey("status"))
statusFilter = when (args.get("status")) { statusFilter = when (args.get("status")) {
"Potential Overconsumption" -> "and " + "Potential Overconsumption" -> "and " +


+ 9
- 3
src/main/java/com/ffii/tsms/modules/report/web/ReportController.kt 查看文件

@@ -35,6 +35,7 @@ import java.time.format.DateTimeFormatter
import org.springframework.stereotype.Controller import org.springframework.stereotype.Controller
import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.JpaRepository
import com.ffii.tsms.modules.project.entity.Project import com.ffii.tsms.modules.project.entity.Project
import com.ffii.tsms.modules.project.service.SubsidiaryService
import com.ffii.tsms.modules.report.web.model.* import com.ffii.tsms.modules.report.web.model.*
import com.ffii.tsms.modules.timesheet.entity.Timesheet import com.ffii.tsms.modules.timesheet.entity.Timesheet
import org.springframework.data.domain.Example import org.springframework.data.domain.Example
@@ -56,6 +57,7 @@ class ReportController(
private val leaveRepository: LeaveRepository, private val leaveRepository: LeaveRepository,
private val teamService: TeamService, private val teamService: TeamService,
private val customerService: CustomerService, private val customerService: CustomerService,
private val subsidiaryService: SubsidiaryService,
private val invoiceService: InvoiceService, private val gradeAllocationRepository: GradeAllocationRepository, private val invoiceService: InvoiceService, private val gradeAllocationRepository: GradeAllocationRepository,
private val subsidiaryRepository: SubsidiaryRepository private val subsidiaryRepository: SubsidiaryRepository
) { ) {
@@ -154,7 +156,7 @@ class ReportController(
fun ProjectResourceOverconsumptionReport(@RequestBody @Valid request: ProjectResourceOverconsumptionReport): ResponseEntity<Resource> { fun ProjectResourceOverconsumptionReport(@RequestBody @Valid request: ProjectResourceOverconsumptionReport): ResponseEntity<Resource> {
val lowerLimit = request.lowerLimit val lowerLimit = request.lowerLimit
var team: String = "All" var team: String = "All"
var customer: String = "All"
var customerOrSubsidiary: String = "All"
val args: MutableMap<String, Any> = mutableMapOf( val args: MutableMap<String, Any> = mutableMapOf(
"status" to request.status, "status" to request.status,
"lowerLimit" to lowerLimit "lowerLimit" to lowerLimit
@@ -165,10 +167,14 @@ class ReportController(
} }
if (request.custId != null) { if (request.custId != null) {
args["custId"] = request.custId args["custId"] = request.custId
customer = customerService.find(request.custId).orElseThrow().name
customerOrSubsidiary = customerService.find(request.custId).orElseThrow().name
}
if (request.subsidiaryId != null) {
args["subsidiaryId"] = request.subsidiaryId
customerOrSubsidiary = subsidiaryService.find(request.subsidiaryId).orElseThrow().name
} }
val result: List<Map<String, Any>> = excelReportService.getProjectResourceOverconsumptionReport(args); val result: List<Map<String, Any>> = excelReportService.getProjectResourceOverconsumptionReport(args);
val reportResult: ByteArray = excelReportService.generateProjectResourceOverconsumptionReport(team, customer, result, lowerLimit)
val reportResult: ByteArray = excelReportService.generateProjectResourceOverconsumptionReport(team, customerOrSubsidiary, result, lowerLimit)
// val mediaType: MediaType = MediaType.parseMediaType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") // val mediaType: MediaType = MediaType.parseMediaType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
return ResponseEntity.ok() return ResponseEntity.ok()
// .contentType(mediaType) // .contentType(mediaType)


+ 1
- 0
src/main/java/com/ffii/tsms/modules/report/web/model/ReportRequest.kt 查看文件

@@ -46,6 +46,7 @@ data class LateStartReportRequest (
data class ProjectResourceOverconsumptionReport ( data class ProjectResourceOverconsumptionReport (
val teamId: Long?, val teamId: Long?,
val custId: Long?, val custId: Long?,
val subsidiaryId: Long?,
val status: String, val status: String,
val lowerLimit: Double val lowerLimit: Double
) )


二进制
src/main/resources/templates/report/AR03_Resource Overconsumption.xlsx 查看文件


正在加载...
取消
保存