| @@ -7,7 +7,7 @@ import org.springframework.data.domain.Page | |||||
| import org.springframework.data.domain.Pageable | import org.springframework.data.domain.Pageable | ||||
| import org.springframework.data.jpa.repository.Query | import org.springframework.data.jpa.repository.Query | ||||
| import org.springframework.stereotype.Repository | import org.springframework.stereotype.Repository | ||||
| import java.time.LocalDateTime | |||||
| @Repository | @Repository | ||||
| interface JobOrderRepository : AbstractRepository<JobOrder, Long> { | interface JobOrderRepository : AbstractRepository<JobOrder, Long> { | ||||
| @Query(""" | @Query(""" | ||||
| @@ -114,4 +114,23 @@ interface JobOrderRepository : AbstractRepository<JobOrder, Long> { | |||||
| """ | """ | ||||
| ) | ) | ||||
| fun findJobOrderDetailByCode(code: String): JobOrderDetailWithJsonString?; | fun findJobOrderDetailByCode(code: String): JobOrderDetailWithJsonString?; | ||||
| fun findAllByDeletedFalse(): List<JobOrder> | |||||
| @Query(""" | |||||
| SELECT jo FROM JobOrder jo | |||||
| WHERE jo.deleted = false | |||||
| AND (:code IS NULL OR jo.code LIKE CONCAT('%', :code, '%')) | |||||
| AND (:bomName IS NULL OR jo.bom.name LIKE CONCAT('%', :bomName, '%')) | |||||
| AND (:planStartFrom IS NULL OR jo.planStart >= :planStartFrom) | |||||
| AND (:planStartTo IS NULL OR jo.planStart <= :planStartTo) | |||||
| ORDER BY jo.id DESC | |||||
| """) | |||||
| fun findJobOrderInfoWithDateFilter( | |||||
| code: String?, | |||||
| bomName: String?, | |||||
| planStartFrom: LocalDateTime?, | |||||
| planStartTo: LocalDateTime?, | |||||
| pageable: Pageable | |||||
| ): Page<JobOrderInfo> | |||||
| } | } | ||||
| @@ -109,11 +109,15 @@ open class JobOrderService( | |||||
| } | } | ||||
| open fun allJobOrdersByPageWithTypeName(request: SearchJobOrderInfoRequest): RecordsRes<JobOrderInfoWithTypeName> { | open fun allJobOrdersByPageWithTypeName(request: SearchJobOrderInfoRequest): RecordsRes<JobOrderInfoWithTypeName> { | ||||
| val pageable = PageRequest.of(request.pageNum ?: 0, request.pageSize ?: 10); | val pageable = PageRequest.of(request.pageNum ?: 0, request.pageSize ?: 10); | ||||
| println("allJobOrdersByPage") | |||||
| println("allJobOrdersByPageWithTypeName") | |||||
| println(request) | println(request) | ||||
| val response = jobOrderRepository.findJobOrderInfoByCodeContainsAndBomNameContainsAndDeletedIsFalseOrderByIdDesc( | |||||
| code = request.code ?: "", | |||||
| bomName = request.itemName ?: "", | |||||
| // 修复:使用包含日期过滤的查询方法,在数据库层面先过滤再分页 | |||||
| val response = jobOrderRepository.findJobOrderInfoWithDateFilter( | |||||
| code = if (request.code.isNullOrBlank()) null else request.code, | |||||
| bomName = if (request.itemName.isNullOrBlank()) null else request.itemName, | |||||
| planStartFrom = request.planStart, | |||||
| planStartTo = request.planStartTo, | |||||
| pageable = pageable | pageable = pageable | ||||
| ) | ) | ||||
| @@ -145,13 +149,8 @@ open class JobOrderService( | |||||
| emptyMap() | emptyMap() | ||||
| } | } | ||||
| val planStartFrom = request.planStart | |||||
| val planStartTo = request.planStartTo | |||||
| // 移除内存中的日期过滤,因为已经在数据库层面过滤了 | |||||
| val records = response.content | val records = response.content | ||||
| .filter { | |||||
| (planStartFrom == null || (it.planStart != null && (planStartFrom.isEqual(it.planStart) || planStartFrom.isBefore(it.planStart)))) && | |||||
| (planStartTo == null || (it.planStart != null && (planStartTo.isEqual(it.planStart) || planStartTo.isAfter(it.planStart)))) | |||||
| } | |||||
| .map { info -> | .map { info -> | ||||
| val jobOrder = jobOrdersMap[info.id] | val jobOrder = jobOrdersMap[info.id] | ||||
| @@ -189,6 +188,7 @@ open class JobOrderService( | |||||
| info.jobTypeName?.contains(request.jobTypeName, ignoreCase = true) == true | info.jobTypeName?.contains(request.jobTypeName, ignoreCase = true) == true | ||||
| } | } | ||||
| // 修复:使用 response.totalElements,这是过滤后的总数 | |||||
| val total = response.totalElements | val total = response.totalElements | ||||
| return RecordsRes<JobOrderInfoWithTypeName>(records, total.toInt()); | return RecordsRes<JobOrderInfoWithTypeName>(records, total.toInt()); | ||||
| } | } | ||||
| @@ -9,4 +9,5 @@ interface BomProcessRepository : AbstractRepository<BomProcess, Long> { | |||||
| fun findBySeqNoAndBomIdAndDeletedIsFalse(seqNo: Int, bomId: Long): BomProcess? | fun findBySeqNoAndBomIdAndDeletedIsFalse(seqNo: Int, bomId: Long): BomProcess? | ||||
| fun findByBomIdOrderBySeqNo(bomId: Long): List<BomProcess> | fun findByBomIdOrderBySeqNo(bomId: Long): List<BomProcess> | ||||
| fun findByBomId(bomId: Long): List<BomProcess> | fun findByBomId(bomId: Long): List<BomProcess> | ||||
| fun findAllByBomIdAndDeletedFalse(bomId: Long): List<BomProcess> | |||||
| } | } | ||||
| @@ -51,6 +51,7 @@ open class ProductProcess : BaseEntity<Long>() { | |||||
| @OneToMany(mappedBy = "productProcess", cascade = [CascadeType.ALL], orphanRemoval = true) | @OneToMany(mappedBy = "productProcess", cascade = [CascadeType.ALL], orphanRemoval = true) | ||||
| open var productionScheduleLines: MutableList<ProductProcessLine> = mutableListOf() | open var productionScheduleLines: MutableList<ProductProcessLine> = mutableListOf() | ||||
| @Column(name = "productionPriority") | |||||
| open var productionPriority: Int? = 50 | |||||
| } | } | ||||
| @@ -33,7 +33,7 @@ data class ProductProcessInfo( | |||||
| val itemName: String?, | val itemName: String?, | ||||
| val outputQtyUom: String?, | val outputQtyUom: String?, | ||||
| val outputQty: Int?, | val outputQty: Int?, | ||||
| val productionPriority: String?, | |||||
| val productionPriority: Int?, | |||||
| val productProcessLines: List<ProductProcessLineInfo>?, | val productProcessLines: List<ProductProcessLineInfo>?, | ||||
| val totalStockQty: Int?, | val totalStockQty: Int?, | ||||
| val insufficientStockQty: Int?, | val insufficientStockQty: Int?, | ||||
| @@ -528,6 +528,8 @@ open class ProductProcessService( | |||||
| // 获取 productionPriority | // 获取 productionPriority | ||||
| val itemId = jobOrder?.bom?.item?.id | val itemId = jobOrder?.bom?.item?.id | ||||
| val planEndDate = jobOrder?.planEnd?.toLocalDate() | val planEndDate = jobOrder?.planEnd?.toLocalDate() | ||||
| /* | |||||
| val productionPriority = if (itemId != null && planEndDate != null) { | val productionPriority = if (itemId != null && planEndDate != null) { | ||||
| val scheduleLine = productionScheduleLineRepository | val scheduleLine = productionScheduleLineRepository | ||||
| .findByItemIdAndProduceAtAndType( | .findByItemIdAndProduceAtAndType( | ||||
| @@ -549,6 +551,7 @@ open class ProductProcessService( | |||||
| } else { | } else { | ||||
| "0" | "0" | ||||
| } | } | ||||
| */ | |||||
| fun calculateColourScore(value: Int?): String { | fun calculateColourScore(value: Int?): String { | ||||
| return when (value) { | return when (value) { | ||||
| 0 -> "淺" | 0 -> "淺" | ||||
| @@ -572,6 +575,7 @@ open class ProductProcessService( | |||||
| } | } | ||||
| return productProcesses.map { process -> | return productProcesses.map { process -> | ||||
| val jobType = jobTypeRepository.findById(process.jobOrder?.jobTypeId?:0L).orElse(null) | val jobType = jobTypeRepository.findById(process.jobOrder?.jobTypeId?:0L).orElse(null) | ||||
| println("jobType id ${process.jobOrder?.jobTypeId}") | println("jobType id ${process.jobOrder?.jobTypeId}") | ||||
| @@ -598,7 +602,7 @@ open class ProductProcessService( | |||||
| startTime = process.startTime?:LocalDateTime.now(), | startTime = process.startTime?:LocalDateTime.now(), | ||||
| endTime = process.endTime?:LocalDateTime.now(), | endTime = process.endTime?:LocalDateTime.now(), | ||||
| date = process.date?:LocalDate.now(), | date = process.date?:LocalDate.now(), | ||||
| productionPriority = productionPriority, // 已经是 String,不需要 ?:0 | |||||
| productionPriority = process.productionPriority?:50, | |||||
| totalStockQty = totalStockQty, | totalStockQty = totalStockQty, | ||||
| insufficientStockQty = insufficientStockQty, | insufficientStockQty = insufficientStockQty, | ||||
| sufficientStockQty = sufficientStockQty, | sufficientStockQty = sufficientStockQty, | ||||
| @@ -702,6 +706,7 @@ open class ProductProcessService( | |||||
| this.status = ProductProcessStatus.PENDING | this.status = ProductProcessStatus.PENDING | ||||
| this.date = jobOrder?.planEnd?.toLocalDate() | this.date = jobOrder?.planEnd?.toLocalDate() | ||||
| this.bom = bom | this.bom = bom | ||||
| this.productionPriority = 50 | |||||
| } | } | ||||
| productProcessRepository.save(productProcess) | productProcessRepository.save(productProcess) | ||||
| @@ -1317,5 +1322,19 @@ open class ProductProcessService( | |||||
| ) | ) | ||||
| } | } | ||||
| open fun UpdateProductProcessPriority(productProcessId: Long, productionPriority: Int): MessageResponse { | |||||
| val productProcess = productProcessRepository.findById(productProcessId).orElse(null) | |||||
| productProcess.productionPriority = productionPriority | |||||
| productProcessRepository.save(productProcess) | |||||
| return MessageResponse( | |||||
| id = productProcessId, | |||||
| code = "200", | |||||
| name = "ProductProcess Priority Updated", | |||||
| type = "success", | |||||
| message = "ProductProcess Priority Updated", | |||||
| errorPosition = null, | |||||
| ) | |||||
| } | |||||
| } | } | ||||
| @@ -205,4 +205,8 @@ class ProductProcessController( | |||||
| fun resumeProductProcessLine(@PathVariable productProcessIssueId: Long): MessageResponse { | fun resumeProductProcessLine(@PathVariable productProcessIssueId: Long): MessageResponse { | ||||
| return productProcessService.SaveProductProcessResumeTime(productProcessIssueId) | return productProcessService.SaveProductProcessResumeTime(productProcessIssueId) | ||||
| } | } | ||||
| @PostMapping("/Demo/Process/update/priority/{productProcessId}/{productionPriority}") | |||||
| fun updateProductProcessPriority(@PathVariable productProcessId: Long, @PathVariable productionPriority: Int): MessageResponse { | |||||
| return productProcessService.UpdateProductProcessPriority(productProcessId, productionPriority) | |||||
| } | |||||
| } | } | ||||
| @@ -49,8 +49,8 @@ class PurchaseOrderController( | |||||
| .addDate("estimatedArrivalDateTo") | .addDate("estimatedArrivalDateTo") | ||||
| .build() | .build() | ||||
| // println(criteriaArgs) | // println(criteriaArgs) | ||||
| val pageSize = request.getParameter("pageSize")?.toIntOrNull() ?: 10 // Default to 10 if not provided | |||||
| val pageNum = request.getParameter("pageNum")?.toIntOrNull() ?: 1 // Default to 1 if not provided | |||||
| val pageSize = request.getParameter("pageSize")?.toIntOrNull() ?: 10 | |||||
| val pageNum = request.getParameter("pageNum")?.toIntOrNull() ?: 1 | |||||
| val fullList = purchaseOrderService.getPoList(criteriaArgs) | val fullList = purchaseOrderService.getPoList(criteriaArgs) | ||||
| val paginatedList = PagingUtils.getPaginatedList(fullList,pageSize, pageNum) | val paginatedList = PagingUtils.getPaginatedList(fullList,pageSize, pageNum) | ||||
| @@ -0,0 +1,5 @@ | |||||
| -- liquibase formatted sql | |||||
| -- changeset Enson:add_column | |||||
| ALTER TABLE `fpsmsdb`.`productprocess` | |||||
| ADD COLUMN `productionPriority` INT NULL AFTER `date`; | |||||