mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 12:52:07 +08:00
api新增sideModel
This commit is contained in:
+3
-3
@@ -464,18 +464,18 @@ public class OrderServiceImpl implements OrderService {
|
||||
}
|
||||
}
|
||||
orderInputProcessor.batchInsert(rawGoodsDO, bodyDO, groupDO, partsDO, plateDO, itemDO, goodsDO, plateGoodDOS);
|
||||
if (orderModelDOS != null && orderModelDOS.size() > 0) {
|
||||
if (orderModelDOS != null && !orderModelDOS.isEmpty()) {
|
||||
orderInputProcessor.batchSaveModel(orderModelDOS);
|
||||
}
|
||||
if (plateDetail != null){
|
||||
List<OrderModelDO> orderModelDOs = BeanUtils.toBean(plateDetail, OrderModelDO.class);
|
||||
if (orderModelDOs.size() > 0) {
|
||||
if (!orderModelDOs.isEmpty()) {
|
||||
orderModelDOs.forEach(orderModelDO -> orderModelDO.setOrderId(orderDO.getId()));
|
||||
System.out.println("----" + orderModelDOs);
|
||||
orderInputProcessor.batchSaveModel(orderModelDOs);
|
||||
}
|
||||
}
|
||||
if (orderPartsRemarks != null && orderPartsRemarks.size() > 0) {
|
||||
if (orderPartsRemarks != null && !orderPartsRemarks.isEmpty()) {
|
||||
orderInputProcessor.batchSaveOrderPartsModel(orderPartsRemarks);
|
||||
}
|
||||
|
||||
|
||||
+63
-43
@@ -637,9 +637,7 @@ public class ApiTypeRealize {
|
||||
|
||||
if (plateDetail != null){
|
||||
Long blockNo = plate.getLong(ProduceApiConstants.BD_BLOCK_NO);
|
||||
System.out.println("blockNo " + blockNo);
|
||||
PlateDetail plateDetailInfo = plateDetail.get(blockNo);
|
||||
System.out.println("hhhh " + plateDetailInfo);
|
||||
|
||||
if (plateDetailInfo != null) {
|
||||
plateDetailInfo.setPlateId(plateId)
|
||||
@@ -942,60 +940,82 @@ public class ApiTypeRealize {
|
||||
// 造型明细板数据解析 (type 为1,正面;3,侧面)
|
||||
private List<ModelDetail> getModelDetail(JSONObject block) {
|
||||
JSONArray models = block.getJSONArray(ProduceApiConstants.BPD_MODEL);
|
||||
JSONArray sideModels = block.getJSONArray(ProduceApiConstants.BPD_SIDE_MODEL); // 侧面造型
|
||||
|
||||
List<ModelDetail> modelDetails = new ArrayList<>();
|
||||
|
||||
try {
|
||||
List<ModelDetail> modelData = getModelData(models);
|
||||
if (modelData != null && !modelData.isEmpty()) {
|
||||
modelDetails.addAll(modelData);
|
||||
}
|
||||
|
||||
List<ModelDetail> sideModelData = getModelData(sideModels);
|
||||
if (sideModelData != null && !sideModelData.isEmpty()) {
|
||||
modelDetails.addAll(sideModelData);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 处理异常,例如记录日志或抛出自定义异常
|
||||
}
|
||||
|
||||
return modelDetails;
|
||||
}
|
||||
|
||||
// 造型数据生成
|
||||
private List<ModelDetail> getModelData(JSONArray models) {
|
||||
if (models == null || models.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
List<ModelDetail> modelDetails = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < models.size(); i++) {
|
||||
JSONObject model = models.getJSONObject(i);
|
||||
for (int i = 0; i < models.size(); i++) {
|
||||
JSONObject model = models.getJSONObject(i);
|
||||
|
||||
List<PointList> pointLists = new ArrayList<>();
|
||||
JSONArray pointsJson = model.getJSONArray(ProduceApiConstants.BPD_MODEL_POINTS);
|
||||
if (pointsJson != null && !pointsJson.isEmpty()) {
|
||||
for (int j = 0; j < pointsJson.size(); j++) {
|
||||
JSONObject point = pointsJson.getJSONObject(j);
|
||||
String[] points = splitAndTrim(point.getString(ProduceApiConstants.BPD_MODEL_POINTS_POS));
|
||||
pointLists.add(PointList.builder()
|
||||
.pointX(Double.valueOf(points[X]))
|
||||
.pointY(Double.valueOf(points[Y]))
|
||||
.pointZ(Double.valueOf(points[Z]))
|
||||
.curve(Double.valueOf(point.getString(ProduceApiConstants.BPD_MODEL_POINTS_CURVE)))
|
||||
.build());
|
||||
}
|
||||
List<PointList> pointLists = new ArrayList<>();
|
||||
JSONArray pointsJson = model.getJSONArray(ProduceApiConstants.BPD_MODEL_POINTS);
|
||||
if (pointsJson != null && !pointsJson.isEmpty()) {
|
||||
for (int j = 0; j < pointsJson.size(); j++) {
|
||||
JSONObject point = pointsJson.getJSONObject(j);
|
||||
String[] points = splitAndTrim(point.getString(ProduceApiConstants.BPD_MODEL_POINTS_POS));
|
||||
pointLists.add(PointList.builder()
|
||||
.pointX(Double.valueOf(points[X]))
|
||||
.pointY(Double.valueOf(points[Y]))
|
||||
.pointZ(Double.valueOf(points[Z]))
|
||||
.curve(Double.valueOf(point.getString(ProduceApiConstants.BPD_MODEL_POINTS_CURVE)))
|
||||
.build());
|
||||
}
|
||||
|
||||
List<OffSetList> offSetLists = new ArrayList<>();
|
||||
JSONArray offSets = model.getJSONArray(ProduceApiConstants.BPD_MODEL_OFFSET_LIST);
|
||||
if (offSets != null && !offSets.isEmpty()) {
|
||||
for (int j = 0; j < offSets.size(); j++) {
|
||||
JSONObject offSet = offSets.getJSONObject(j);
|
||||
offSetLists.add(OffSetList.builder()
|
||||
.value(Double.valueOf(offSet.getString(ProduceApiConstants.BPD_MODEL_OFFSET_LIST_VALUE)))
|
||||
.name(offSet.getString(ProduceApiConstants.BPD_MODEL_OFFSET_LIST_NAME))
|
||||
.radius(Double.parseDouble(offSet.getString(ProduceApiConstants.BPD_MODEL_OFFSET_LIST_DIRECTION)) / 2)
|
||||
.angle(Double.valueOf(offSet.getString(ProduceApiConstants.BPD_MODEL_OFFSET_LIST_ANGLE)))
|
||||
.depth(Double.valueOf(offSet.getString(ProduceApiConstants.BPD_MODEL_OFFSET_LIST_DEPTH)))
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
modelDetails.add(ModelDetail.builder()
|
||||
.depth(Double.valueOf(model.getString(ProduceApiConstants.BPD_MODEL_DEPTH)))
|
||||
.faceType(Integer.valueOf(model.getString(ProduceApiConstants.BPD_MODEL_FACE)))
|
||||
.knifeName(model.getString(ProduceApiConstants.BPD_MODEL_TOOL_NO))
|
||||
.knifeRadius(Double.parseDouble(model.getString(ProduceApiConstants.BPD_MODEL_DIAMETER)) / 2)
|
||||
.pointList(pointLists)
|
||||
.offSetList(offSetLists)
|
||||
.originModeling(getOriginModeling(model.getJSONObject(ProduceApiConstants.BPD_MODEL_ORIGIN_MODELING)))
|
||||
.build());
|
||||
}
|
||||
|
||||
List<OffSetList> offSetLists = new ArrayList<>();
|
||||
JSONArray offSets = model.getJSONArray(ProduceApiConstants.BPD_MODEL_OFFSET_LIST);
|
||||
if (offSets != null && !offSets.isEmpty()) {
|
||||
for (int j = 0; j < offSets.size(); j++) {
|
||||
JSONObject offSet = offSets.getJSONObject(j);
|
||||
offSetLists.add(OffSetList.builder()
|
||||
.value(Double.valueOf(offSet.getString(ProduceApiConstants.BPD_MODEL_OFFSET_LIST_VALUE)))
|
||||
.name(offSet.getString(ProduceApiConstants.BPD_MODEL_OFFSET_LIST_NAME))
|
||||
.radius(Double.parseDouble(offSet.getString(ProduceApiConstants.BPD_MODEL_OFFSET_LIST_DIRECTION)) / 2)
|
||||
.angle(Double.valueOf(offSet.getString(ProduceApiConstants.BPD_MODEL_OFFSET_LIST_ANGLE)))
|
||||
.depth(Double.valueOf(offSet.getString(ProduceApiConstants.BPD_MODEL_OFFSET_LIST_DEPTH)))
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
modelDetails.add(ModelDetail.builder()
|
||||
.depth(Double.valueOf(model.getString(ProduceApiConstants.BPD_MODEL_DEPTH)))
|
||||
.faceType(Integer.valueOf(model.getString(ProduceApiConstants.BPD_MODEL_FACE)))
|
||||
.knifeName(model.getString(ProduceApiConstants.BPD_MODEL_TOOL_NO))
|
||||
.knifeRadius(Double.parseDouble(model.getString(ProduceApiConstants.BPD_MODEL_DIAMETER)) / 2)
|
||||
.pointList(pointLists)
|
||||
.offSetList(offSetLists)
|
||||
.originModeling(getOriginModeling(model.getJSONObject(ProduceApiConstants.BPD_MODEL_ORIGIN_MODELING)))
|
||||
.build());
|
||||
}
|
||||
|
||||
return modelDetails;
|
||||
}
|
||||
|
||||
// 造型 --- OriginModeling
|
||||
// 造型 --- OriginModeling
|
||||
private IOriginModelingData getOriginModeling(JSONObject originModeling) {
|
||||
|
||||
if (originModeling == null || originModeling.isEmpty()) {
|
||||
|
||||
+1
@@ -247,6 +247,7 @@ public class ProduceApiConstants {
|
||||
public static final String BPD_HOLE_START_POINT = "StartPoint";
|
||||
|
||||
public static final String BPD_MODEL = "Models"; // 造型
|
||||
public static final String BPD_SIDE_MODEL = "SideModels"; // 侧面造型造型
|
||||
public static final String BPD_MODEL_DEPTH = "Depth";
|
||||
public static final String BPD_MODEL_DIAMETER = "Diameter";
|
||||
public static final String BPD_MODEL_FACE = "Face";
|
||||
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
package com.cf.imes.module.manage.controller.admin.parts.vo;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageParam;
|
||||
import com.cf.imes.framework.common.validation.NumberValid;
|
||||
import com.cf.imes.module.manage.validation.parts.PartsNumberValid;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -55,15 +55,15 @@ public class PartsPageReqVO extends PageParam {
|
||||
private String spec;
|
||||
|
||||
@Schema(description = "宽度")
|
||||
@NumberValid(name = "宽度")
|
||||
@PartsNumberValid(name = "宽度")
|
||||
private Double[] width;
|
||||
|
||||
@Schema(description = "长度")
|
||||
@NumberValid(name = "长度")
|
||||
@PartsNumberValid(name = "长度")
|
||||
private Double[] length;
|
||||
|
||||
@Schema(description = "厚度")
|
||||
@NumberValid(name = "厚度")
|
||||
@PartsNumberValid(name = "厚度")
|
||||
private Double[] thickness;
|
||||
|
||||
@Schema(description = "品牌")
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package com.cf.imes.module.manage.validation.parts;
|
||||
|
||||
import javax.validation.Constraint;
|
||||
import javax.validation.Payload;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 数组校验注解
|
||||
*/
|
||||
@Target({
|
||||
ElementType.METHOD,
|
||||
ElementType.FIELD,
|
||||
ElementType.ANNOTATION_TYPE,
|
||||
ElementType.CONSTRUCTOR,
|
||||
ElementType.PARAMETER,
|
||||
ElementType.TYPE_USE
|
||||
})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Constraint(validatedBy = PartsNumberValidator.class)
|
||||
public @interface PartsNumberValid {
|
||||
|
||||
String name();
|
||||
|
||||
String message() default "数字不合法";
|
||||
|
||||
Class<?>[] groups() default {};
|
||||
|
||||
Class<? extends Payload>[] payload() default {};
|
||||
|
||||
int integer() default 5;
|
||||
|
||||
int fraction() default 3;
|
||||
|
||||
}
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
package com.cf.imes.module.manage.validation.parts;
|
||||
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
/**
|
||||
* 数组校验
|
||||
*/
|
||||
public class PartsNumberValidator implements ConstraintValidator<PartsNumberValid, Object> {
|
||||
|
||||
private static final String ZERO = "0";
|
||||
|
||||
private static final String GREATER_THAN_ZERO_NOTIFICATION = "%s必须大于0";
|
||||
|
||||
private static final String FLOAT_NUMBER_LENGTH_ERROR_NOTIFICATION = "%s长度不合法,总长度不超过8位,小数点后不超过3位";
|
||||
|
||||
private String name;
|
||||
|
||||
private int integer;
|
||||
|
||||
private int fraction;
|
||||
|
||||
@Override
|
||||
public void initialize(PartsNumberValid constraintAnnotation) {
|
||||
this.name = constraintAnnotation.name();
|
||||
this.integer = constraintAnnotation.integer();
|
||||
this.fraction = constraintAnnotation.fraction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(Object value, ConstraintValidatorContext context) {
|
||||
// 空的不校验,由原生@NotNull之类的进行判断
|
||||
if (value == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (value instanceof Number[]) {
|
||||
return validateArray((Number[]) value, context);
|
||||
} else if (value instanceof Number) {
|
||||
return validateSingleValue((Number) value, context);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean validateArray(Number[] values, ConstraintValidatorContext context) {
|
||||
for (Number value : values) {
|
||||
if (!validateSingleValue(value, context)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean validateSingleValue(Number value, ConstraintValidatorContext context) {
|
||||
// 提示信息
|
||||
String notification = null;
|
||||
if (value instanceof Integer) {
|
||||
notification = handleInteger(value.intValue());
|
||||
} else if (value instanceof Long) {
|
||||
notification = handleLong(value.longValue());
|
||||
} else if (value instanceof Double) {
|
||||
notification = handleDouble(value.doubleValue());
|
||||
} else if (value instanceof BigDecimal) {
|
||||
notification = handleBigDecimal((BigDecimal) value);
|
||||
}
|
||||
if (notification != null) {
|
||||
context.disableDefaultConstraintViolation(); // 禁用默认的 message 的值
|
||||
context.buildConstraintViolationWithTemplate(notification).addConstraintViolation();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private String handleInteger(Integer value) {
|
||||
if (value < Integer.parseInt(ZERO)) {
|
||||
return String.format(GREATER_THAN_ZERO_NOTIFICATION, name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String handleLong(Long value) {
|
||||
if (value < Long.parseLong(ZERO)) {
|
||||
return String.format(GREATER_THAN_ZERO_NOTIFICATION, name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String handleDouble(Double value) {
|
||||
if (value < Double.parseDouble(ZERO)) {
|
||||
return String.format(GREATER_THAN_ZERO_NOTIFICATION, name);
|
||||
}
|
||||
// 处理科学计数法,保留小数点后四位
|
||||
DecimalFormat decimalFormat = new DecimalFormat("#.####");
|
||||
String valueString = decimalFormat.format(value);
|
||||
|
||||
String[] split = valueString.split("\\.");
|
||||
// 获取小数点前的位数
|
||||
int integerPartLength = split[0].length();
|
||||
// 获取小数点后的位数
|
||||
int fractionalPartLength = 0;
|
||||
if (split.length > 1) {
|
||||
fractionalPartLength = split[1].length();
|
||||
}
|
||||
|
||||
// 总位数不超过 8 位,小数点后位数不超过 3 位
|
||||
if (integerPartLength > integer || fractionalPartLength > fraction) {
|
||||
return String.format(FLOAT_NUMBER_LENGTH_ERROR_NOTIFICATION, name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String handleBigDecimal(BigDecimal value) {
|
||||
if (value.compareTo(BigDecimal.ZERO) < 0) {
|
||||
return String.format(GREATER_THAN_ZERO_NOTIFICATION, name);
|
||||
}
|
||||
|
||||
String[] split = value.toPlainString().split("\\.");
|
||||
// 获取小数点前的位数
|
||||
int integerPartLength = split[0].length();
|
||||
// 获取小数点后的位数
|
||||
int fractionalPartLength = 0;
|
||||
if (split.length > 1) {
|
||||
fractionalPartLength = split[1].length();
|
||||
}
|
||||
|
||||
// 总位数不超过 8 位,小数点后位数不超过 3 位
|
||||
if (integerPartLength > integer || fractionalPartLength > fraction) {
|
||||
return String.format(FLOAT_NUMBER_LENGTH_ERROR_NOTIFICATION, name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user