@@ -1,5 +1,6 @@ | |||||
package com.ffii.fpsms.modules.master.entity | package com.ffii.fpsms.modules.master.entity | ||||
import com.fasterxml.jackson.annotation.JsonBackReference | |||||
import com.fasterxml.jackson.annotation.JsonManagedReference | import com.fasterxml.jackson.annotation.JsonManagedReference | ||||
import com.ffii.core.entity.BaseEntity | import com.ffii.core.entity.BaseEntity | ||||
import jakarta.persistence.* | import jakarta.persistence.* | ||||
@@ -21,6 +22,7 @@ open class Bom : BaseEntity<Long>() { | |||||
@Column | @Column | ||||
open var isDense: Int? = null | open var isDense: Int? = null | ||||
@JsonBackReference | |||||
@OneToOne | @OneToOne | ||||
@JoinColumn(name = "itemId") | @JoinColumn(name = "itemId") | ||||
open var item: Items? = null | open var item: Items? = null | ||||
@@ -12,6 +12,7 @@ import java.time.LocalDateTime | |||||
@Table(name = "bom_material") | @Table(name = "bom_material") | ||||
@Entity | @Entity | ||||
open class BomMaterial : BaseEntity<Long>() { | open class BomMaterial : BaseEntity<Long>() { | ||||
@JsonBackReference | |||||
@ManyToOne | @ManyToOne | ||||
@JoinColumn(name = "itemId") | @JoinColumn(name = "itemId") | ||||
open var item: Items? = null | open var item: Items? = null | ||||
@@ -1,5 +1,6 @@ | |||||
package com.ffii.fpsms.modules.master.entity | package com.ffii.fpsms.modules.master.entity | ||||
import com.fasterxml.jackson.annotation.JsonBackReference | |||||
import com.fasterxml.jackson.annotation.JsonInclude | import com.fasterxml.jackson.annotation.JsonInclude | ||||
import com.fasterxml.jackson.annotation.JsonManagedReference | import com.fasterxml.jackson.annotation.JsonManagedReference | ||||
import com.ffii.core.entity.BaseEntity | import com.ffii.core.entity.BaseEntity | ||||
@@ -42,6 +43,7 @@ open class BomProcess : BaseEntity<Long>() { | |||||
@NotNull | @NotNull | ||||
@ManyToOne(optional = false) | @ManyToOne(optional = false) | ||||
@JsonBackReference | |||||
@JoinColumn(name = "bomId", nullable = false) | @JoinColumn(name = "bomId", nullable = false) | ||||
open var bom: Bom? = null | open var bom: Bom? = null | ||||
@@ -380,8 +380,10 @@ open class BomService( | |||||
// println("hi") | // println("hi") | ||||
break | break | ||||
} else { | } else { | ||||
println(tempCell.cellType) | |||||
println(tempCell.toString()) | |||||
// println(startRowIndex) | |||||
// println(startColumnIndex) | |||||
// println(tempCell.cellType) | |||||
// println(tempCell.toString()) | |||||
try { | try { | ||||
when (startColumnIndex) { | when (startColumnIndex) { | ||||
0 -> { | 0 -> { | ||||
@@ -488,6 +490,7 @@ open class BomService( | |||||
val resolver = PathMatchingResourcePatternResolver() | val resolver = PathMatchingResourcePatternResolver() | ||||
// val excels = resolver.getResources("bomImport/*.xlsx") | // val excels = resolver.getResources("bomImport/*.xlsx") | ||||
val excels = resolver.getResources("file:C:/Users/2Fi/Desktop/test folder/*.xlsx") | val excels = resolver.getResources("file:C:/Users/2Fi/Desktop/test folder/*.xlsx") | ||||
// val excels = resolver.getResources("file:C:/Users/2Fi/Desktop/Third Wave of BOM Excel/*.xlsx") | |||||
println("size: ${excels.size}") | println("size: ${excels.size}") | ||||
val logExcel = ClassPathResource("excelTemplate/bom_excel_issue_log.xlsx") | val logExcel = ClassPathResource("excelTemplate/bom_excel_issue_log.xlsx") | ||||
val templateInputStream = logExcel.inputStream | val templateInputStream = logExcel.inputStream | ||||
@@ -497,11 +500,11 @@ open class BomService( | |||||
/////// for outputing issue log //////////// | /////// for outputing issue log //////////// | ||||
// excels.forEachIndexed { index, resource -> | // excels.forEachIndexed { index, resource -> | ||||
//get sheet | |||||
//// get sheet | |||||
// println(resource.filename) | // println(resource.filename) | ||||
// val templateInputStream = resource.inputStream | |||||
// val workbook: Workbook = XSSFWorkbook(templateInputStream) | |||||
// val sheet: Sheet = workbook.getSheetAt(0) | |||||
// val templateInputStream1 = resource.inputStream | |||||
// val workbook1: Workbook = XSSFWorkbook(templateInputStream1) | |||||
// val sheet: Sheet = workbook1.getSheetAt(0) | |||||
// println("sheetName") | // println("sheetName") | ||||
// println(sheet.sheetName) | // println(sheet.sheetName) | ||||
// val successPath: Path = Paths.get("C:/Users/2Fi/Desktop/success/${resource.filename}") | // val successPath: Path = Paths.get("C:/Users/2Fi/Desktop/success/${resource.filename}") | ||||
@@ -28,6 +28,25 @@ open class ItemsService( | |||||
return items | return items | ||||
} | } | ||||
open fun allConsumables(): List<Map<String, Any>> { | |||||
val args = mapOf( | |||||
"type" to "mat" | |||||
) | |||||
val sql = StringBuilder("select" | |||||
+ " i.id, " | |||||
+ " concat(i.code , ' - ' , i.name) as label, " | |||||
+ " uc.id as uomId, " | |||||
+ " uc.code as uom " | |||||
+ " from items i " | |||||
+ " left join item_uom iu on iu.itemId = i.id and iu.deleted = false and iu.salesUnit = true " | |||||
+ " left join uom_conversion uc on uc.id = iu.uomId " | |||||
+ " where i.deleted = false " | |||||
+ " and i.type = :type " | |||||
) | |||||
return jdbcDao.queryForList(sql.toString(), args); | |||||
} | |||||
open fun getRoughScheduleList(): List<Map<String, Any>> { | open fun getRoughScheduleList(): List<Map<String, Any>> { | ||||
val now = LocalDateTime.now() | val now = LocalDateTime.now() | ||||
val lastMonthStart = now.minusMonths(1).withDayOfMonth(1) // Start of last month | val lastMonthStart = now.minusMonths(1).withDayOfMonth(1) // Start of last month | ||||
@@ -164,6 +183,7 @@ open class ItemsService( | |||||
val item = if (request.m18Id != null) findByM18Id(request.m18Id) ?: Items() | val item = if (request.m18Id != null) findByM18Id(request.m18Id) ?: Items() | ||||
else if (request.id != null && request.id > 0) itemsRepository.findByIdAndDeletedFalse(request.id) ?: Items() | else if (request.id != null && request.id > 0) itemsRepository.findByIdAndDeletedFalse(request.id) ?: Items() | ||||
else Items() | else Items() | ||||
logger.info("item: $item") | |||||
if (item.m18LastModifyDate == request.m18LastModifyDate) { | if (item.m18LastModifyDate == request.m18LastModifyDate) { | ||||
return MessageResponse( | return MessageResponse( | ||||
id = item.id, | id = item.id, | ||||
@@ -187,7 +207,9 @@ open class ItemsService( | |||||
m18Id = request.m18Id ?: this.m18Id | m18Id = request.m18Id ?: this.m18Id | ||||
m18LastModifyDate = request.m18LastModifyDate ?: this.m18LastModifyDate | m18LastModifyDate = request.m18LastModifyDate ?: this.m18LastModifyDate | ||||
} | } | ||||
logger.info("saving item: $item") | |||||
val savedItem = itemsRepository.saveAndFlush(item) | val savedItem = itemsRepository.saveAndFlush(item) | ||||
logger.info("save success") | |||||
return MessageResponse( | return MessageResponse( | ||||
id = savedItem.id, | id = savedItem.id, | ||||
name = savedItem.name, | name = savedItem.name, | ||||
@@ -24,6 +24,10 @@ class ItemsController( | |||||
return itemsService.allItems() | return itemsService.allItems() | ||||
} | } | ||||
@GetMapping("/consumables") | |||||
fun allConsumables(): List<Map<String, Any>> { | |||||
return itemsService.allConsumables() | |||||
} | |||||
// @GetMapping("/getRecordByPage") | // @GetMapping("/getRecordByPage") | ||||
// fun getAllItemsByPage(@RequestBody filterRequest: HttpServletRequest): RecordsRes<Map<String, Any>> { | // fun getAllItemsByPage(@RequestBody filterRequest: HttpServletRequest): RecordsRes<Map<String, Any>> { | ||||
// val pageSize = filterRequest.getParameter("pageSize").toString().toInt(); // Default to 10 if not provided | // val pageSize = filterRequest.getParameter("pageSize").toString().toInt(); // Default to 10 if not provided | ||||
@@ -9,6 +9,7 @@ enum class PickOrderStatus(val value: String) { | |||||
} | } | ||||
enum class PickOrderType(val value: String) { | enum class PickOrderType(val value: String) { | ||||
Consumable ("consumable"), | |||||
MATERIAL ("material"), | MATERIAL ("material"), | ||||
JOB_ORDER ("jo"), | JOB_ORDER ("jo"), | ||||
DELIVERY_ORDER ("do") | DELIVERY_ORDER ("do") |
@@ -59,14 +59,14 @@ open class PickOrderService( | |||||
val code = assignPickCode() | val code = assignPickCode() | ||||
val pickOrder = PickOrder().apply { | val pickOrder = PickOrder().apply { | ||||
this.code = code | this.code = code | ||||
this.targetDate = request.targetDate | |||||
this.targetDate = request.targetDate.atStartOfDay() | |||||
this.type = request.type | this.type = request.type | ||||
this.status = PickOrderStatus.PENDING | this.status = PickOrderStatus.PENDING | ||||
} | } | ||||
val savedPickOrder = saveAndFlush(pickOrder) | val savedPickOrder = saveAndFlush(pickOrder) | ||||
val polEntries = request.pickOrderLine.map { | val polEntries = request.pickOrderLine.map { | ||||
val item = itemsRepository.findById(it.itemId).orElseThrow() | val item = itemsRepository.findById(it.itemId).orElseThrow() | ||||
val uom = uomConversionRepository.findById(it.uomId).orElseThrow() | |||||
val uom = uomConversionRepository.findByCodeAndDeletedFalse(it.uom) | |||||
PickOrderLine().apply { | PickOrderLine().apply { | ||||
this.pickOrder = savedPickOrder | this.pickOrder = savedPickOrder | ||||
this.item = item | this.item = item | ||||
@@ -8,11 +8,12 @@ import java.time.LocalDateTime | |||||
data class SavePickOrderLineRequest ( | data class SavePickOrderLineRequest ( | ||||
val itemId: Long, | val itemId: Long, | ||||
val qty: BigDecimal, | val qty: BigDecimal, | ||||
val uomId: Long | |||||
// val uomId: Long | |||||
val uom: String, | |||||
) | ) | ||||
data class SavePickOrderRequest ( | data class SavePickOrderRequest ( | ||||
val type: PickOrderType, | val type: PickOrderType, | ||||
var targetDate: LocalDateTime, | |||||
var targetDate: LocalDate, | |||||
val pickOrderLine: List<SavePickOrderLineRequest> | val pickOrderLine: List<SavePickOrderLineRequest> | ||||
) | ) | ||||
@@ -1,5 +1,6 @@ | |||||
package com.ffii.fpsms.modules.stock.entity | package com.ffii.fpsms.modules.stock.entity | ||||
import com.fasterxml.jackson.annotation.JsonBackReference | |||||
import com.ffii.core.entity.BaseEntity | import com.ffii.core.entity.BaseEntity | ||||
import com.ffii.fpsms.modules.master.entity.Currency | import com.ffii.fpsms.modules.master.entity.Currency | ||||
import com.ffii.fpsms.modules.master.entity.Items | import com.ffii.fpsms.modules.master.entity.Items | ||||
@@ -27,6 +28,7 @@ open class Inventory: BaseEntity<Long>(){ | |||||
@Column(name = "price") | @Column(name = "price") | ||||
open var price: BigDecimal? = null | open var price: BigDecimal? = null | ||||
@JsonBackReference | |||||
@ManyToOne | @ManyToOne | ||||
@JoinColumn(name = "itemId") | @JoinColumn(name = "itemId") | ||||
open var item: Items? = null | open var item: Items? = null | ||||