mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 12:52:07 +08:00
组件创建排单适配长宽0传null
This commit is contained in:
+27
@@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.http.HttpClient;
|
import java.net.http.HttpClient;
|
||||||
import java.net.http.HttpRequest;
|
import java.net.http.HttpRequest;
|
||||||
@@ -44,6 +45,7 @@ public class ProducingPlanOrderClient {
|
|||||||
|
|
||||||
public Long create(String token, Long workflowSchemeId, List<String> blockIds,
|
public Long create(String token, Long workflowSchemeId, List<String> blockIds,
|
||||||
List<ProducingPlanOrderMaterialGroup> customMaterialGroupList) {
|
List<ProducingPlanOrderMaterialGroup> customMaterialGroupList) {
|
||||||
|
normalizeBoardDimensions(customMaterialGroupList);
|
||||||
CreateRequest request = new CreateRequest(
|
CreateRequest request = new CreateRequest(
|
||||||
blockIds, workflowSchemeId, customMaterialGroupList);
|
blockIds, workflowSchemeId, customMaterialGroupList);
|
||||||
if (httpLogProperties.isHttpLogEnabled()) {
|
if (httpLogProperties.isHttpLogEnabled()) {
|
||||||
@@ -170,6 +172,31 @@ public class ProducingPlanOrderClient {
|
|||||||
return properties.getBaseUrl() + "/" + planOrderId + "/" + action;
|
return properties.getBaseUrl() + "/" + planOrderId + "/" + action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件接口以 {@code null} 表示未设置板材尺寸,不能传入 0。
|
||||||
|
* 仅处理本次请求使用的 DTO,不影响本地板材数据。
|
||||||
|
*/
|
||||||
|
private void normalizeBoardDimensions(
|
||||||
|
List<ProducingPlanOrderMaterialGroup> customMaterialGroupList) {
|
||||||
|
if (customMaterialGroupList == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
customMaterialGroupList.stream()
|
||||||
|
.filter(java.util.Objects::nonNull)
|
||||||
|
.forEach(materialGroup -> {
|
||||||
|
if (isZero(materialGroup.getWidth())) {
|
||||||
|
materialGroup.setWidth(null);
|
||||||
|
}
|
||||||
|
if (isZero(materialGroup.getLength())) {
|
||||||
|
materialGroup.setLength(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isZero(BigDecimal value) {
|
||||||
|
return value != null && value.compareTo(BigDecimal.ZERO) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
private String workflowSchemeListUrl(Integer page, Integer type, Long parentId,
|
private String workflowSchemeListUrl(Integer page, Integer type, Long parentId,
|
||||||
Integer pageSize, Boolean isPaging) {
|
Integer pageSize, Boolean isPaging) {
|
||||||
StringBuilder url = new StringBuilder(workflowSchemeBaseUrl())
|
StringBuilder url = new StringBuilder(workflowSchemeBaseUrl())
|
||||||
|
|||||||
+2
@@ -29,9 +29,11 @@ public class ProducingPlanOrderMaterialGroup {
|
|||||||
private Integer type;
|
private Integer type;
|
||||||
|
|
||||||
/** 板材宽度。 */
|
/** 板材宽度。 */
|
||||||
|
@JsonInclude(JsonInclude.Include.ALWAYS)
|
||||||
private BigDecimal width;
|
private BigDecimal width;
|
||||||
|
|
||||||
/** 板材长度。 */
|
/** 板材长度。 */
|
||||||
|
@JsonInclude(JsonInclude.Include.ALWAYS)
|
||||||
private BigDecimal length;
|
private BigDecimal length;
|
||||||
|
|
||||||
/** 板材厚度。 */
|
/** 板材厚度。 */
|
||||||
|
|||||||
+4
@@ -49,6 +49,8 @@ class ProducingPlanOrderClientTest {
|
|||||||
.id("goods-1")
|
.id("goods-1")
|
||||||
.name("颗粒板-白色-18")
|
.name("颗粒板-白色-18")
|
||||||
.type(4)
|
.type(4)
|
||||||
|
.width(java.math.BigDecimal.ZERO)
|
||||||
|
.length(java.math.BigDecimal.ZERO)
|
||||||
.thickness(new java.math.BigDecimal("18"))
|
.thickness(new java.math.BigDecimal("18"))
|
||||||
.hasWave(true)
|
.hasWave(true)
|
||||||
.materialIds(List.of("source-material-2366", "source-material-2367"))
|
.materialIds(List.of("source-material-2366", "source-material-2367"))
|
||||||
@@ -84,6 +86,8 @@ class ProducingPlanOrderClientTest {
|
|||||||
assertThat(materialBody.get("id").textValue()).isEqualTo("goods-1");
|
assertThat(materialBody.get("id").textValue()).isEqualTo("goods-1");
|
||||||
assertThat(materialBody.get("name").textValue()).isEqualTo("颗粒板-白色-18");
|
assertThat(materialBody.get("name").textValue()).isEqualTo("颗粒板-白色-18");
|
||||||
assertThat(materialBody.get("type").intValue()).isEqualTo(4);
|
assertThat(materialBody.get("type").intValue()).isEqualTo(4);
|
||||||
|
assertThat(materialBody.get("width").isNull()).isTrue();
|
||||||
|
assertThat(materialBody.get("length").isNull()).isTrue();
|
||||||
assertThat(materialBody.get("materialIds").isArray()).isTrue();
|
assertThat(materialBody.get("materialIds").isArray()).isTrue();
|
||||||
assertThat(materialBody.get("materialIds").toString())
|
assertThat(materialBody.get("materialIds").toString())
|
||||||
.isEqualTo("[\"source-material-2366\",\"source-material-2367\"]");
|
.isEqualTo("[\"source-material-2366\",\"source-material-2367\"]");
|
||||||
|
|||||||
Reference in New Issue
Block a user