瀏覽代碼

Update for QC

master
cyril.tsui 1 周之前
父節點
當前提交
4115004977
共有 15 個檔案被更改,包括 218 行新增29 行删除
  1. +19
    -4
      src/main/java/com/ffii/fpsms/modules/master/entity/ItemCategory.kt
  2. +8
    -0
      src/main/java/com/ffii/fpsms/modules/master/entity/Items.kt
  3. +12
    -7
      src/main/java/com/ffii/fpsms/modules/master/entity/QcCategory.kt
  4. +7
    -4
      src/main/java/com/ffii/fpsms/modules/master/entity/QcItemCategory.kt
  5. +3
    -1
      src/main/java/com/ffii/fpsms/modules/master/entity/ShopRepository.kt
  6. +11
    -0
      src/main/java/com/ffii/fpsms/modules/master/entity/projections/ShopCombo.kt
  7. +9
    -1
      src/main/java/com/ffii/fpsms/modules/master/service/ShopService.kt
  8. +23
    -0
      src/main/java/com/ffii/fpsms/modules/master/web/ShopController.kt
  9. +11
    -1
      src/main/java/com/ffii/fpsms/modules/purchaseOrder/entity/projections/PurchaseOrderLineInfo.kt
  10. +22
    -11
      src/main/java/com/ffii/fpsms/modules/purchaseOrder/service/PurchaseOrderService.kt
  11. +20
    -0
      src/main/resources/db/changelog/changes/20250813_01_cyril/01_update_qc.sql
  12. +13
    -0
      src/main/resources/db/changelog/changes/20250813_01_cyril/02_add_item_category.sql
  13. +6
    -0
      src/main/resources/db/changelog/changes/20250813_01_cyril/03_update_qc_item.sql
  14. +13
    -0
      src/main/resources/db/changelog/changes/20250813_01_cyril/04_update_item.sql
  15. +41
    -0
      src/main/resources/db/changelog/changes/20250813_01_cyril/05_update_qc_id_with_auto.sql

+ 19
- 4
src/main/java/com/ffii/fpsms/modules/master/entity/ItemCategory.kt 查看文件

@@ -8,8 +8,23 @@ import jakarta.validation.constraints.Size
@Entity
@Table(name = "item_category")
open class ItemCategory : BaseEntity<Long>() {
@Size(max = 50)
@NotNull
@Column(name = "name", nullable = false, length = 50)
open var name: String? = null
@Size(max = 100)
@Column(name = "code", length = 100)
open var code: String? = null

@Size(max = 100)
@Column(name = "parent", length = 100)
open var parent: String? = null

@Size(max = 100)
@Column(name = "sub", length = 100)
open var sub: String? = null

@Size(max = 100)
@Column(name = "temperature", length = 100)
open var temperature: String? = null

@ManyToOne
@JoinColumn(name = "qcCategoryId")
open var qcCategory: QcCategory? = null
}

+ 8
- 0
src/main/java/com/ffii/fpsms/modules/master/entity/Items.kt 查看文件

@@ -54,4 +54,12 @@ open class Items : BaseEntity<Long>() {
@JsonManagedReference
@OneToOne(mappedBy = "item", cascade = [CascadeType.ALL], orphanRemoval = true)
open var bom: Bom? = null

@ManyToOne
@JoinColumn(name = "categoryId")
open var category: ItemCategory? = null

@ManyToOne
@JoinColumn(name = "qcCategoryId")
open var qcCategory: QcCategory? = null
}

+ 12
- 7
src/main/java/com/ffii/fpsms/modules/master/entity/QcCategory.kt 查看文件

@@ -1,5 +1,6 @@
package com.ffii.fpsms.modules.master.entity

import com.fasterxml.jackson.annotation.JsonManagedReference
import com.ffii.core.entity.BaseEntity
import jakarta.persistence.CascadeType
import jakarta.persistence.Column
@@ -21,11 +22,15 @@ open class QcCategory : BaseEntity<Long>() {
@Column(name = "name")
open var name: String? = null

@OneToMany(cascade = [CascadeType.ALL])
@JoinTable(
name = "qc_item_category",
joinColumns = [JoinColumn(name = "qcCategoryId")],
inverseJoinColumns = [JoinColumn(name = "qcItemId")]
)
open var qcItems: MutableSet<QcItem> = mutableSetOf()
// @OneToMany(cascade = [CascadeType.ALL])
// @JoinTable(
// name = "qc_item_category",
// joinColumns = [JoinColumn(name = "qcCategoryId")],
// inverseJoinColumns = [JoinColumn(name = "qcItemId")]
// )
// open var qcItems: MutableList<QcItem> = mutableListOf()

@JsonManagedReference
@OneToMany(mappedBy = "qcCategory", cascade = [CascadeType.ALL], orphanRemoval = true)
open var qcItemCategory: MutableList<QcItemCategory> = mutableListOf()
}

+ 7
- 4
src/main/java/com/ffii/fpsms/modules/master/entity/QcItemCategory.kt 查看文件

@@ -4,15 +4,14 @@ import com.fasterxml.jackson.annotation.JsonBackReference
import com.fasterxml.jackson.annotation.JsonManagedReference
import com.ffii.core.entity.BaseEntity
import com.ffii.core.entity.IdEntity
import jakarta.persistence.Entity
import jakarta.persistence.JoinColumn
import jakarta.persistence.ManyToOne
import jakarta.persistence.Table
import jakarta.persistence.*
import jakarta.validation.constraints.NotNull
import jakarta.validation.constraints.Size

@Entity
@Table(name = "qc_item_category")
open class QcItemCategory : IdEntity<Long>() {
@JsonBackReference
@NotNull
@ManyToOne
@JoinColumn(name = "qcCategoryId")
@@ -22,4 +21,8 @@ open class QcItemCategory : IdEntity<Long>() {
@ManyToOne
@JoinColumn(name = "qcItemId")
open var qcItem: QcItem? = null

@Size(max = 1000)
@Column(name = "description", length = 1000)
open var description: String? = null
}

+ 3
- 1
src/main/java/com/ffii/fpsms/modules/master/entity/ShopRepository.kt 查看文件

@@ -1,7 +1,7 @@
package com.ffii.fpsms.modules.master.entity

import com.ffii.core.support.AbstractRepository
import com.ffii.fpsms.modules.master.entity.projections.SearchId
import com.ffii.fpsms.modules.master.entity.projections.ShopCombo
import com.ffii.fpsms.modules.master.enums.ShopType
import org.springframework.data.jpa.repository.Query
import org.springframework.stereotype.Repository
@@ -23,4 +23,6 @@ interface ShopRepository : AbstractRepository<Shop, Long> {
nativeQuery = true,
value = "select s.m18Id from Shop s where s.code not regexp ?1 and s.type = ?2 and s.deleted = false")
fun findM18IdsByCodeNotRegexpAndTypeAndDeletedIsFalse(codeNotRegexp: String, type: String): List<Long>?

fun findShopComboByTypeAndDeletedIsFalse(type: ShopType): List<ShopCombo>
}

+ 11
- 0
src/main/java/com/ffii/fpsms/modules/master/entity/projections/ShopCombo.kt 查看文件

@@ -0,0 +1,11 @@
package com.ffii.fpsms.modules.master.entity.projections

import org.springframework.beans.factory.annotation.Value

interface ShopCombo {
val id: Long;
@get:Value("#{target.id}")
val value: Long;
@get:Value("#{target.code} - #{target.name}")
val label: String;
}

+ 9
- 1
src/main/java/com/ffii/fpsms/modules/master/service/ShopService.kt 查看文件

@@ -2,7 +2,7 @@ package com.ffii.fpsms.modules.master.service

import com.ffii.fpsms.modules.master.entity.Shop
import com.ffii.fpsms.modules.master.entity.ShopRepository
import com.ffii.fpsms.modules.master.entity.projections.SearchId
import com.ffii.fpsms.modules.master.entity.projections.ShopCombo
import com.ffii.fpsms.modules.master.enums.ShopType
import com.ffii.fpsms.modules.master.web.models.SaveShopRequest
import com.ffii.fpsms.modules.master.web.models.SaveShopResponse
@@ -39,6 +39,14 @@ open class ShopService(
return shopRepository.findM18IdsByCodeNotRegexpAndTypeAndDeletedIsFalse(codeRegexp, type = ShopType.SUPPLIER.value)
}

open fun findSupplierCombo(): List<ShopCombo> {
return shopRepository.findShopComboByTypeAndDeletedIsFalse(ShopType.SUPPLIER)
}

open fun findShopCombo(): List<ShopCombo> {
return shopRepository.findShopComboByTypeAndDeletedIsFalse(ShopType.SHOP)
}

open fun saveShop(request: SaveShopRequest): SaveShopResponse {
val shop = if (request.m18Id != null) {
when (request.type){


+ 23
- 0
src/main/java/com/ffii/fpsms/modules/master/web/ShopController.kt 查看文件

@@ -0,0 +1,23 @@
package com.ffii.fpsms.modules.master.web

import com.ffii.fpsms.modules.master.entity.projections.ShopCombo
import com.ffii.fpsms.modules.master.service.ShopService
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/shop")
class ShopController (
private val shopService: ShopService,
) {
@GetMapping("/combo/shop")
fun getShopCombo(): List<ShopCombo> {
return shopService.findShopCombo();
}

@GetMapping("/combo/supplier")
fun getSupplierCombo(): List<ShopCombo> {
return shopService.findSupplierCombo();
}
}

+ 11
- 1
src/main/java/com/ffii/fpsms/modules/purchaseOrder/entity/projections/PurchaseOrderLineInfo.kt 查看文件

@@ -1,5 +1,6 @@
package com.ffii.fpsms.modules.purchaseOrder.entity.projections

import com.ffii.fpsms.modules.master.entity.QcItem
import com.ffii.fpsms.modules.master.entity.UomConversion
import com.ffii.fpsms.modules.stock.entity.StockInLine
import com.ffii.fpsms.modules.stock.entity.projection.StockInLineInfo
@@ -33,5 +34,14 @@ data class PoLineWithStockInLine (
val price: BigDecimal,
val status: String,

val stockInLine: List<StockInLineInfo>?
val stockInLine: List<StockInLineInfo>?,

val qcItems: List<QcForPoLine>
)

data class QcForPoLine (
val id: Long?,
val code: String?,
val name: String?,
val description: String?,
)

+ 22
- 11
src/main/java/com/ffii/fpsms/modules/purchaseOrder/service/PurchaseOrderService.kt 查看文件

@@ -7,6 +7,7 @@ import com.ffii.fpsms.m18.entity.GrnSendLog
import com.ffii.fpsms.m18.entity.GrnSendLogRepository
import com.ffii.fpsms.m18.entity.M18DataLogRepository
import com.ffii.fpsms.m18.utils.CommonUtils
import com.ffii.fpsms.modules.master.entity.QcItem
import com.ffii.fpsms.modules.master.entity.ShopRepository
import com.ffii.fpsms.modules.master.service.CurrencyService
import com.ffii.fpsms.modules.master.service.ShopService
@@ -17,6 +18,7 @@ import com.ffii.fpsms.modules.purchaseOrder.entity.PurchaseOrderRepository
import com.ffii.fpsms.modules.purchaseOrder.entity.projections.PoLineWithStockInLine
import com.ffii.fpsms.modules.purchaseOrder.entity.projections.PurchaseOrderDataClass
import com.ffii.fpsms.modules.purchaseOrder.entity.projections.PurchaseOrderInfo
import com.ffii.fpsms.modules.purchaseOrder.entity.projections.QcForPoLine
import com.ffii.fpsms.modules.purchaseOrder.enums.PurchaseOrderLineStatus
import com.ffii.fpsms.modules.purchaseOrder.enums.PurchaseOrderStatus
import com.ffii.fpsms.modules.purchaseOrder.enums.PurchaseOrderType
@@ -183,18 +185,27 @@ open class PurchaseOrderService(
}
val mappedPoLine = pol.map { thisPol ->
val inLine = stockInLine.filter { it.purchaseOrderLineId == thisPol.id }
val qcItems = thisPol.item?.qcCategory?.qcItemCategory?.map {
QcForPoLine(
id = it.qcItem?.id,
code = it.qcItem?.code,
name = it.qcItem?.name,
description = it.description
)
} ?: mutableListOf();
PoLineWithStockInLine(
thisPol.id!!,
thisPol.purchaseOrder!!.id!!,
thisPol.item!!.id!!,
thisPol.itemNo!!,
thisPol.item!!.name,
thisPol.qty!!,
inLine.filter{ it.status == StockInLineStatus.COMPLETE.status}.sumOf { it.acceptedQty },
thisPol.uom!!,
thisPol.price!!,
thisPol.status!!.toString(),
inLine
id = thisPol.id!!,
purchaseOrderId = thisPol.purchaseOrder!!.id!!,
itemId = thisPol.item!!.id!!,
itemNo = thisPol.itemNo!!,
itemName = thisPol.item!!.name,
qty = thisPol.qty!!,
processed = inLine.filter{ it.status == StockInLineStatus.COMPLETE.status}.sumOf { it.acceptedQty },
uom = thisPol.uom!!,
price = thisPol.price!!,
status = thisPol.status!!.toString(),
stockInLine = inLine,
qcItems = qcItems
)
}
val result = mapOf(


+ 20
- 0
src/main/resources/db/changelog/changes/20250813_01_cyril/01_update_qc.sql 查看文件

@@ -0,0 +1,20 @@
-- liquibase formatted sql
-- changeset cyril:update_qc

ALTER TABLE `qc_item_category`
ADD COLUMN `description` VARCHAR(1000) NULL AFTER `qcCategoryId`;

ALTER TABLE `item_category`
ADD COLUMN `code` VARCHAR(100) NULL AFTER `deleted`,
ADD COLUMN `sub` VARCHAR(100) NULL AFTER `parent`,
ADD COLUMN `temperature` VARCHAR(100) NULL AFTER `sub`,
ADD COLUMN `qcCategoryId` INT NULL AFTER `temperature`,
CHANGE COLUMN `name` `parent` VARCHAR(100) NULL ,
ADD INDEX `FK_ITEM_CATEGORY_ON_QC_CATEGORY_ID` (`qcCategoryId` ASC) VISIBLE;
;
ALTER TABLE `item_category`
ADD CONSTRAINT `FK_ITEM_CATEGORY_ON_QC_CATEGORY_ID`
FOREIGN KEY (`qcCategoryId`)
REFERENCES `qc_category` (`id`)
ON DELETE RESTRICT
ON UPDATE RESTRICT;

+ 13
- 0
src/main/resources/db/changelog/changes/20250813_01_cyril/02_add_item_category.sql 查看文件

@@ -0,0 +1,13 @@
-- liquibase formatted sql
-- changeset cyril:add_item_category

ALTER TABLE `items`
ADD COLUMN `categoryId` INT NULL AFTER `type`,
ADD INDEX `FK_ITEM_ON_CATEGORYID` (`categoryId` ASC) VISIBLE;
;
ALTER TABLE `items`
ADD CONSTRAINT `FK_ITEM_ON_CATEGORYID`
FOREIGN KEY (`categoryId`)
REFERENCES `item_category` (`id`)
ON DELETE RESTRICT
ON UPDATE RESTRICT;

+ 6
- 0
src/main/resources/db/changelog/changes/20250813_01_cyril/03_update_qc_item.sql 查看文件

@@ -0,0 +1,6 @@
-- liquibase formatted sql
-- changeset cyril:update_qc_item

ALTER TABLE `qc_item`
CHANGE COLUMN `code` `code` VARCHAR(100) NOT NULL ,
CHANGE COLUMN `name` `name` VARCHAR(100) NOT NULL ;

+ 13
- 0
src/main/resources/db/changelog/changes/20250813_01_cyril/04_update_item.sql 查看文件

@@ -0,0 +1,13 @@
-- liquibase formatted sql
-- changeset cyril:update_item

ALTER TABLE `items`
ADD COLUMN `qcCategoryId` INT NULL AFTER `categoryId`,
ADD INDEX `FK_ITEM_ON_QCCATEGORYID` (`qcCategoryId` ASC) VISIBLE;
;
ALTER TABLE `items`
ADD CONSTRAINT `FK_ITEM_ON_QCCATEGORYID`
FOREIGN KEY (`qcCategoryId`)
REFERENCES `qc_category` (`id`)
ON DELETE RESTRICT
ON UPDATE RESTRICT;

+ 41
- 0
src/main/resources/db/changelog/changes/20250813_01_cyril/05_update_qc_id_with_auto.sql 查看文件

@@ -0,0 +1,41 @@
-- liquibase formatted sql
-- changeset cyril:update_qc_id_with_auto

ALTER TABLE `item_category`
DROP FOREIGN KEY `FK_ITEM_CATEGORY_ON_QC_CATEGORY_ID`;

ALTER TABLE `qc_item_category`
DROP FOREIGN KEY `FK_QC_ITEM_CATEGORY_ON_QCCATEGORYID`;
ALTER TABLE `qc_item_category`
CHANGE COLUMN `id` `id` INT NOT NULL AUTO_INCREMENT ,
ADD INDEX `FK_QC_ITEM_CATEGORY_ON_QCCATEGORYID` (`qcCategoryId` ASC) VISIBLE,
DROP INDEX `FK_QC_ITEM_CATEGORY_ON_QCCATEGORYID` ;

ALTER TABLE `items`
DROP FOREIGN KEY `FK_ITEM_ON_QCCATEGORYID`;

ALTER TABLE `qc_category`
CHANGE COLUMN `id` `id` INT NOT NULL AUTO_INCREMENT ;

ALTER TABLE `item_category` ALTER INDEX `FK_ITEM_CATEGORY_ON_QC_CATEGORY_ID` VISIBLE;
ALTER TABLE `item_category`
ADD CONSTRAINT `FK_ITEM_CATEGORY_ON_QC_CATEGORY_ID`
FOREIGN KEY (`qcCategoryId`)
REFERENCES `qc_category` (`id`)
ON DELETE RESTRICT
ON UPDATE RESTRICT;

ALTER TABLE `qc_item_category`
ADD CONSTRAINT `FK_QC_ITEM_CATEGORY_ON_QCCATEGORYID`
FOREIGN KEY (`qcCategoryId`)
REFERENCES `qc_category` (`id`)
ON DELETE RESTRICT
ON UPDATE RESTRICT;

ALTER TABLE `items` ALTER INDEX `FK_ITEM_ON_QCCATEGORYID` VISIBLE;
ALTER TABLE `items`
ADD CONSTRAINT `FK_ITEM_ON_QCCATEGORYID`
FOREIGN KEY (`qcCategoryId`)
REFERENCES `qc_category` (`id`)
ON DELETE RESTRICT
ON UPDATE RESTRICT;

Loading…
取消
儲存