| @@ -1,5 +1,6 @@ | |||
| package com.ffii.fpsms.api.service | |||
| import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper | |||
| import com.ffii.core.utils.JwtTokenUtil | |||
| import com.ffii.fpsms.m18.M18Config | |||
| import com.ffii.fpsms.m18.model.M18TokenRequest | |||
| @@ -98,6 +99,21 @@ open class ApiCallerService( | |||
| } | |||
| .retrieve() | |||
| .bodyToMono(T::class.java) | |||
| // Below is for test bug (200 but error). Need to comment out bodyToMono and add jsonIgnore to data class | |||
| // .toEntity(String::class.java) // Get raw body as String | |||
| // .flatMap { entity -> | |||
| // logger.info("Response Status: ${entity.statusCode}") | |||
| // logger.info("Response Headers: ${entity.headers}") | |||
| // logger.info("Raw Response Body: ${entity.body}") | |||
| // try { | |||
| // val objectMapper = jacksonObjectMapper() | |||
| // val deserialized = objectMapper.readValue(entity.body, T::class.java) | |||
| // Mono.just(deserialized) | |||
| // } catch (e: Exception) { | |||
| // logger.error("Deserialization failed: ${e.message}") | |||
| // Mono.error(e) | |||
| // } | |||
| // } | |||
| .doOnError { error -> | |||
| println("Error occurred: ${error.message}") | |||
| } | |||
| @@ -105,6 +121,7 @@ open class ApiCallerService( | |||
| logger.error("WebClientResponseException") | |||
| logger.error("Error Status: ${error.statusCode} - ${error.statusText}") | |||
| logger.error("Error Message: ${error.message}") | |||
| logger.error("Error Response: ${error.responseBodyAsString}") | |||
| if (error.statusCode == HttpStatusCode.valueOf(400)) { | |||
| updateToken() | |||
| } | |||
| @@ -1,5 +1,7 @@ | |||
| package com.ffii.fpsms.m18.model | |||
| import com.fasterxml.jackson.annotation.JsonIgnoreProperties | |||
| import com.fasterxml.jackson.annotation.JsonProperty | |||
| import java.math.BigDecimal | |||
| /** Product / Material Response */ | |||
| @@ -63,8 +65,10 @@ data class M18VendorVen ( | |||
| val code: String, | |||
| /** name */ | |||
| val desc: String, | |||
| val `desc_zh-TW`: String, | |||
| val `desc_zh-CN`: String, | |||
| @JsonProperty("desc_zh-TW") | |||
| val descZhTW: String, | |||
| @JsonProperty("desc_zh-CN") | |||
| val descZhCN: String, | |||
| /** contactNo */ | |||
| val tel: String, | |||
| val email: String, | |||
| @@ -199,22 +203,27 @@ data class M18BomUdfProduct ( | |||
| ) | |||
| /** Shop Response */ | |||
| //@JsonIgnoreProperties(ignoreUnknown = true) | |||
| data class M18BusinessUnitResponse ( | |||
| val data: M18BusinessUnitData?, | |||
| val messages: List<M18ErrorMessages>? | |||
| ) | |||
| //@JsonIgnoreProperties(ignoreUnknown = true) | |||
| data class M18BusinessUnitData ( | |||
| val virdept: List<M18BusinessUnitVirdept>? | |||
| ) | |||
| //@JsonIgnoreProperties(ignoreUnknown = true) | |||
| data class M18BusinessUnitVirdept ( | |||
| val id: Long, | |||
| val code: String, | |||
| /** name */ | |||
| val desc: String, | |||
| val `desc_zh-TW`: String, | |||
| val `desc_zh-CN`: String, | |||
| @JsonProperty("desc_zh-TW") | |||
| val descZhTW: String, | |||
| @JsonProperty("desc_zh-CN") | |||
| val descZhCN: String, | |||
| /** contactNo */ | |||
| val tel: String, | |||
| val email: String, | |||
| @@ -229,11 +238,13 @@ data class M18BusinessUnitVirdept ( | |||
| ) | |||
| /** BusinessUnit List Response */ | |||
| //@JsonIgnoreProperties(ignoreUnknown = true) | |||
| data class M18BusinessUnitListResponse ( | |||
| val values: List<M18BusinessUnitListValue>?, | |||
| val messages: List<M18ErrorMessages>? | |||
| ) | |||
| //@JsonIgnoreProperties(ignoreUnknown = true) | |||
| data class M18BusinessUnitListValue ( | |||
| val id: Long, | |||
| val lastModifyDate: String?, | |||
| @@ -367,7 +367,7 @@ open class M18MasterDataService( | |||
| val saveShopRequest = SaveShopRequest( | |||
| id = null, | |||
| code = ven.code, | |||
| name = ven.`desc_zh-TW`.ifEmpty { ven.`desc_zh-CN`.ifEmpty { ven.desc } }, | |||
| name = ven.descZhTW.ifEmpty { ven.descZhCN.ifEmpty { ven.desc } }, | |||
| brNo = null, | |||
| contactNo = ven.tel, | |||
| contactEmail = ven.email, | |||
| @@ -384,7 +384,7 @@ open class M18MasterDataService( | |||
| shopService.saveShop(saveShopRequest) | |||
| successList.add(vendor.id) | |||
| logger.info("Success Count ${successList.size}: ${vendor.id} | ${ven.code} | ${ven.`desc_zh-TW`.ifEmpty { ven.`desc_zh-CN`.ifEmpty { ven.desc } }}") | |||
| logger.info("Success Count ${successList.size}: ${vendor.id} | ${ven.code} | ${ven.descZhTW.ifEmpty { ven.descZhCN.ifEmpty { ven.desc } }}") | |||
| } else { | |||
| failList.add(vendor.id) | |||
| logger.error("Fail Message: ${vendorDetail?.messages?.get(0)?.msgDetail}") | |||
| @@ -712,7 +712,7 @@ open class M18MasterDataService( | |||
| val saveShopRequest = SaveShopRequest( | |||
| id = null, | |||
| code = virdept.code, | |||
| name = virdept.`desc_zh-TW`.ifEmpty { virdept.`desc_zh-CN`.ifEmpty { virdept.desc } }, | |||
| name = virdept.descZhTW.ifEmpty { virdept.descZhCN.ifEmpty { virdept.desc } }, | |||
| brNo = null, | |||
| contactNo = virdept.tel, | |||
| contactEmail = virdept.email, | |||
| @@ -729,7 +729,7 @@ open class M18MasterDataService( | |||
| shopService.saveShop(saveShopRequest) | |||
| successList.add(businessUnit.id) | |||
| logger.info("Success Count ${successList.size}: ${businessUnit.id} | ${virdept.code} | ${virdept.`desc_zh-TW`.ifEmpty { virdept.`desc_zh-CN`.ifEmpty { virdept.desc } }}") | |||
| logger.info("Success Count ${successList.size}: ${businessUnit.id} | ${virdept.code} | ${virdept.descZhTW.ifEmpty { virdept.descZhCN.ifEmpty { virdept.desc } }}") | |||
| } else { | |||
| failList.add(businessUnit.id) | |||
| logger.error("(Business Unit) Fail Message: ${buMessages?.msgDetail}") | |||
| @@ -125,8 +125,8 @@ open class MailTemplateService( | |||
| "N/A" | |||
| } | |||
| } ?: "N/A" | |||
| val acceptedQty = (stockInLine.acceptedQty ?: zero).minus(stockInLine.demandQty ?: zero).toString() | |||
| val rejectedQty = (stockInLine.demandQty ?: zero).toString() // reject? | |||
| val rejectedQty = (stockInLine.acceptedQty ?: zero).minus(stockInLine.demandQty ?: zero).toString() // reject? | |||
| val acceptedQty = (stockInLine.acceptedQty ?: zero).toString() | |||
| val nonDelieveredQty = (zero).toString() | |||
| // HTML | |||
| @@ -48,7 +48,7 @@ class PurchaseOrderController( | |||
| .addDate("estimatedArrivalDate") | |||
| .addDate("estimatedArrivalDateTo") | |||
| .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 | |||