mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
错误
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
package com.cf.imes.framework.common.enums;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum PlanFilterTypeEnum {
|
||||
|
||||
|
||||
DIGGINGTHROUGHTHESHAPE(1,"有挖穿造型"),
|
||||
THEREAREPERFORATEDHOLES(2,"有挖穿孔"),
|
||||
TWODIMENSIONALCUTTINGPATH(4,"有二维刀路"),
|
||||
STACKABLE(8,"可叠");
|
||||
|
||||
private Integer type;
|
||||
private String filterNames;
|
||||
|
||||
public boolean equals(Integer type) {
|
||||
return this.type .equals(type) ;
|
||||
}
|
||||
|
||||
public boolean equals(PlanFilterTypeEnum enableStatusEnum) {
|
||||
return enableStatusEnum != null && enableStatusEnum.type .equals(this.getType()) ;
|
||||
}
|
||||
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.cf.imes.framework.common.enums;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum PlanStatusEnum {
|
||||
|
||||
|
||||
NEWORDER(0,"新单"),
|
||||
BOARDHASBEENAPPLIEDFOR(1,"板材已申请"),
|
||||
DURINGCUTTING(2,"开料中"),
|
||||
OPENEDMATERIAL(3,"已开料");
|
||||
|
||||
private Integer status;
|
||||
private String scheduling;
|
||||
|
||||
|
||||
public boolean equals(Integer status) {
|
||||
return this.status .equals(status) ;
|
||||
}
|
||||
|
||||
public boolean equals(PlanStatusEnum enableStatusEnum) {
|
||||
return enableStatusEnum != null && enableStatusEnum.status .equals(this.getStatus()) ;
|
||||
}
|
||||
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.cf.imes.framework.common.enums;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum ProcessProcessingTypeEnum {
|
||||
|
||||
|
||||
COMPONENTPROCESSING(7L,"组件加工");
|
||||
|
||||
private Long number;
|
||||
private String fabricatedItem;
|
||||
|
||||
public boolean equals(Integer number) {
|
||||
return this.number .equals(number) ;
|
||||
}
|
||||
|
||||
public boolean equals(ProcessProcessingTypeEnum enableStatusEnum) {
|
||||
return enableStatusEnum != null && enableStatusEnum.number .equals(this.getNumber()) ;
|
||||
}
|
||||
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.cf.imes.framework.common.enums;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum RemainTypeEnum {
|
||||
|
||||
WRITEOFF(0,"核销"),
|
||||
SCHEDULING(1,"排单"),
|
||||
PATCHINGPLATE(2,"补板");
|
||||
|
||||
|
||||
private Integer type;
|
||||
private String useType;
|
||||
|
||||
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
package com.cf.imes.module.executor.controller.admin.plan.saveOptimize;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Schema(description = "优化后的余料板数据")
|
||||
public class OptimizeRemainPlate {
|
||||
|
||||
|
||||
@Schema(description = "余料板ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Long id;
|
||||
|
||||
|
||||
@Schema(description = "源排单ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Long initPlanId;
|
||||
|
||||
|
||||
@Schema(description = "排单ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Long planId;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "状态(未使用 = 0, 已使用 = 1)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Integer status;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "商品ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Long goodsId;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "商品名", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String goodsName;
|
||||
|
||||
|
||||
@Schema(description = "材质", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String material;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "颜色", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String color;
|
||||
|
||||
|
||||
@Schema(description = "宽", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private BigDecimal width;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "长", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private BigDecimal length;
|
||||
|
||||
|
||||
@Schema(description = "品牌", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String brand;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "排单号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String planCode;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Integer count;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "厚度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private BigDecimal thickness;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "轮廓", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String outLineJson;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String remark;
|
||||
|
||||
|
||||
@Schema(description = "排版样式", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Integer placeStyle;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package com.cf.imes.module.executor.controller.admin.plan.saveOptimize;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
import static com.cf.imes.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT;
|
||||
|
||||
@Data
|
||||
@Schema(description = "优化后的生产单数据")
|
||||
public class SaveOrderReqVO {
|
||||
|
||||
@Schema(description = "生产单id")
|
||||
private Long orderId;
|
||||
|
||||
@Schema(description = "父id")
|
||||
private Long parentNo;
|
||||
|
||||
@Schema(description = "自定义单号")
|
||||
private String customOrderNo;
|
||||
|
||||
@Schema(description = "客户")
|
||||
private String customer;
|
||||
|
||||
@Schema(description = "地址")
|
||||
private String address;
|
||||
|
||||
@Schema(description = "客户电话")
|
||||
private String phoneNumber;
|
||||
|
||||
@Schema(description = "经销商")
|
||||
private String dealer;
|
||||
|
||||
@Schema(description = "经销商电话")
|
||||
private String dealerPhoneNumber;
|
||||
|
||||
@Schema(description = "业务员")
|
||||
private String salesman;
|
||||
|
||||
@Schema(description = "拆单员")
|
||||
private String splitter;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "交付日期")
|
||||
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
|
||||
private Date deliveryDate;
|
||||
|
||||
@Schema(description = "生产单类型,1主单 2子单")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "生产单排序号")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "CAD数据类型,1CAD 2WebCAD 3Excel")
|
||||
private Integer dataType;
|
||||
|
||||
@Schema(description = "订单状态,0未排单1已排单2生产中3加工完成4打包完成5入库完成6出库完成")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.cf.imes.module.executor.controller.admin.plan.saveOptimize;
|
||||
|
||||
|
||||
import com.cf.imes.module.executor.controller.admin.goods.vo.GoodsSaveReqVO;
|
||||
import com.cf.imes.module.executor.controller.admin.plan.vo.PlateDetialRespVO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.goods.GoodsDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.goods.OptimizeBoardModelDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SavePlanPlateResultReqVO {
|
||||
|
||||
|
||||
// @Schema(description = "优化后的生产单数据", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
// private List<OrderDO> orderList;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "优化后的大板列表数据", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<OptimizeBoardModelDO> optimizeBoardModelDOS;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "优化后的余料板数据", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<OptimizeRemainPlate> optimizeRemainPlates;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "优化后的小板列表数据", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<PlateDetialRespVO> plateList;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "优化后新增的小板ID")
|
||||
private List<Long> addPlateIds;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "优化后删除的小板ID")
|
||||
private List<Long> deletePlateIds;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
package com.cf.imes.module.executor.controller.admin.plan.vo;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 生产单商品表")
|
||||
@Data
|
||||
public class GoodsReqVO {
|
||||
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "4109")
|
||||
private Long id;
|
||||
|
||||
|
||||
@Schema(description = "余料板ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "4109")
|
||||
private Long remainId;
|
||||
|
||||
|
||||
@Schema(description = "生产单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12114")
|
||||
private Long orderId;
|
||||
|
||||
@Schema(description = "设计端商品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "832")
|
||||
private Long rawGoodsId;
|
||||
|
||||
@Schema(description = "商品 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "243")
|
||||
private Long goodsId;
|
||||
|
||||
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "晨丰")
|
||||
private String goodsName;
|
||||
|
||||
@Schema(description = "材质:颗粒板、欧松板、多层板、生态板、禾香板、密度板、实木、铝蜂窝板、铝塑板", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String material;
|
||||
|
||||
@Schema(description = "颜色", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String color;
|
||||
|
||||
@Schema(description = "纹路")
|
||||
private Integer texture;
|
||||
|
||||
@Schema(description = "宽度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private BigDecimal width;
|
||||
|
||||
@Schema(description = "高度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private BigDecimal height;
|
||||
|
||||
@Schema(description = "厚度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private BigDecimal thickness;
|
||||
|
||||
@Schema(description = "价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "7305")
|
||||
private BigDecimal price;
|
||||
|
||||
@Schema(description = "品牌", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String brand;
|
||||
|
||||
@Schema(description = "规格", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String spec;
|
||||
|
||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜")
|
||||
private String remark;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String creator;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "更新人", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String updater;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] updateTime;
|
||||
|
||||
|
||||
|
||||
}
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
package com.cf.imes.module.executor.dal.dataobject.goods;
|
||||
|
||||
|
||||
import com.cf.imes.framework.es.core.dal.ESDocument;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Schema(description = "优化后的大板信息")
|
||||
public class OptimizeBoardModelDO extends ESDocument {
|
||||
|
||||
@Schema(description = "排单ID")
|
||||
private Long planId;
|
||||
|
||||
|
||||
@Schema(description = "生产单id")
|
||||
private Long orderId;
|
||||
|
||||
|
||||
@Schema(description = "大板原长")
|
||||
private BigDecimal orgLength;
|
||||
@Schema(description = "大板原宽")
|
||||
private BigDecimal orgWidth;
|
||||
|
||||
|
||||
@Schema(description = "大板开料长")
|
||||
private BigDecimal length;
|
||||
@Schema(description = "大板开料宽")
|
||||
private BigDecimal width;
|
||||
@Schema(description = "大板厚度")
|
||||
private BigDecimal thickness;
|
||||
|
||||
@Schema(description = "修边值")
|
||||
private BigDecimal cutBorder;
|
||||
|
||||
|
||||
@Schema(description = "开料刀直径")
|
||||
private BigDecimal diameter;
|
||||
|
||||
|
||||
@Schema(description = "开料刀路间隙")
|
||||
private BigDecimal cutKnifeGap;
|
||||
|
||||
|
||||
@Schema(description = "预铣值")
|
||||
private BigDecimal preMillingSize;
|
||||
|
||||
|
||||
@Schema(description = "是否辅助开料")
|
||||
private Boolean isHelpCut;
|
||||
|
||||
|
||||
@Schema(description = "同刀辅助开料偏移")
|
||||
private BigDecimal helpCutGap;
|
||||
|
||||
|
||||
@Schema(description = "开料刀ID")
|
||||
private Integer cutKnifeId;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "辅助刀ID")
|
||||
private Integer helpKnifeId;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "是否已优化")
|
||||
private Boolean isOptimized;
|
||||
|
||||
|
||||
@Schema(description = "大板数")
|
||||
private Integer boardCount;
|
||||
|
||||
|
||||
@Schema(description = "余料板数")
|
||||
private Integer remainBoardCount;
|
||||
|
||||
|
||||
@Schema(description = "最小板号")
|
||||
private Integer minBoardId;
|
||||
|
||||
|
||||
@Schema(description = "最大板号")
|
||||
private Integer maxBoardId;
|
||||
|
||||
|
||||
@Schema(description = "总平均利用率")
|
||||
private BigDecimal avgUsageRateAll;
|
||||
|
||||
|
||||
@Schema(description = "前N块板(不包含最后一块板)的平均利用率")
|
||||
private BigDecimal avgUsageRateExcludeLastBoard;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "最后一块板的利用率")
|
||||
private BigDecimal usageRateLastBoard;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "使用大板情况--大板优化数据")
|
||||
private String usedBoardInfo;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "小板排版情况--小板优化数据")
|
||||
private String blockPlaceInfo;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "余料板排版情况--余料板优化数据")
|
||||
private String remainBoardInfo;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.cf.imes.module.executor.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* 生产单明细类型
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/6/7 14:50
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
public enum OrderItemType {
|
||||
|
||||
BOARD(1, "板材"),
|
||||
|
||||
PARTS(2, "五金/配件"),
|
||||
|
||||
OTHER(3, "其他"),
|
||||
|
||||
QUOTE_PARTS(4, "报价配件");
|
||||
|
||||
/**
|
||||
* 类型编码
|
||||
*/
|
||||
private final Integer code;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private final String desc;
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.cf.imes.module.executor.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* 排单状态
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/6/7 14:25
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
public enum OrderPlanStatusEnum {
|
||||
NEW(0, "新单"),
|
||||
|
||||
APPLY(1, "板材已申请"),
|
||||
|
||||
OPENING(2, "开料中"),
|
||||
|
||||
OPENED(3, "已开料");
|
||||
|
||||
/**
|
||||
* 类型编码
|
||||
*/
|
||||
private final Integer code;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private final String desc;
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.cf.imes.module.executor.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* 生产单板件排单过滤类型
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/6/7 14:31
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
public enum OrderPlateFilterTypeEnum {
|
||||
HAS_CUT_THROUGH_SHAPE(1, "有挖穿造型"),
|
||||
|
||||
HAS_CUT_PUNCH(2, "有挖穿孔"),
|
||||
|
||||
HAS_2D_KNIFE_PATHS(4, "有二维刀路"),
|
||||
|
||||
STACKABLE(8, "可叠");
|
||||
|
||||
/**
|
||||
* 类型编码
|
||||
*/
|
||||
private final Integer code;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private final String desc;
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.cf.imes.module.executor.util;
|
||||
|
||||
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
|
||||
|
||||
|
||||
/**
|
||||
* 获取当前用户的组织ID
|
||||
*
|
||||
* @author 晨丰科技
|
||||
*/
|
||||
public class OrganIdUtils {
|
||||
|
||||
// public static Long getUserOrganId(){
|
||||
//
|
||||
// return SecurityFrameworkUtils.getLoginUser().getOrganId();
|
||||
//
|
||||
// }
|
||||
}
|
||||
+230
@@ -0,0 +1,230 @@
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Base64;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.zip.DataFormatException;
|
||||
import java.util.zip.Deflater;
|
||||
import java.util.zip.Inflater;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
public class JsonUtil {
|
||||
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
String jsonData = "{\n" +
|
||||
" \"code\": 0,\n" +
|
||||
" \"data\": [\n" +
|
||||
" {\n" +
|
||||
" \"createTime\": 1717053232000,\n" +
|
||||
" \"updateTime\": 1717053232000,\n" +
|
||||
" \"creator\": \"晨丰科技\",\n" +
|
||||
" \"updater\": \"晨丰科技\",\n" +
|
||||
" \"deleted\": false,\n" +
|
||||
" \"id\": 358,\n" +
|
||||
" \"name\": \"2024年5月30日2\",\n" +
|
||||
" \"pieceRate\": 0.001,\n" +
|
||||
" \"pieceType\": 3,\n" +
|
||||
" \"type\": 1,\n" +
|
||||
" \"isCustom\": true,\n" +
|
||||
" \"isDealer\": false,\n" +
|
||||
" \"sort\": 1000,\n" +
|
||||
" \"hourCapacity\": 0.001,\n" +
|
||||
" \"unit\": \"件\",\n" +
|
||||
" \"isEnabled\": true,\n" +
|
||||
" \"prepareTime\": 0,\n" +
|
||||
" \"description\": \"2024年5月30日2\",\n" +
|
||||
" \"organId\": 1\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"createTime\": 1717053193000,\n" +
|
||||
" \"updateTime\": 1717053193000,\n" +
|
||||
" \"creator\": \"晨丰科技\",\n" +
|
||||
" \"updater\": \"晨丰科技\",\n" +
|
||||
" \"deleted\": false,\n" +
|
||||
" \"id\": 357,\n" +
|
||||
" \"name\": \"2024年5月30日\",\n" +
|
||||
" \"pieceRate\": 0.001,\n" +
|
||||
" \"pieceType\": 2,\n" +
|
||||
" \"type\": 7,\n" +
|
||||
" \"isCustom\": true,\n" +
|
||||
" \"isDealer\": false,\n" +
|
||||
" \"sort\": 1000,\n" +
|
||||
" \"hourCapacity\": 0.001,\n" +
|
||||
" \"unit\": \"件\",\n" +
|
||||
" \"isEnabled\": true,\n" +
|
||||
" \"prepareTime\": 0,\n" +
|
||||
" \"description\": \"2024年5月30日\",\n" +
|
||||
" \"organId\": 1\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"createTime\": 1716191704000,\n" +
|
||||
" \"updateTime\": 1716280724000,\n" +
|
||||
" \"creator\": \"晨丰科技\",\n" +
|
||||
" \"updater\": \"晨丰科技\",\n" +
|
||||
" \"deleted\": false,\n" +
|
||||
" \"id\": 355,\n" +
|
||||
" \"name\": \"测试编辑dvdvd工序\",\n" +
|
||||
" \"pieceRate\": 985,\n" +
|
||||
" \"pieceType\": 7,\n" +
|
||||
" \"type\": 2,\n" +
|
||||
" \"isCustom\": true,\n" +
|
||||
" \"isDealer\": false,\n" +
|
||||
" \"sort\": 1001,\n" +
|
||||
" \"hourCapacity\": 41,\n" +
|
||||
" \"unit\": \"亩\",\n" +
|
||||
" \"isEnabled\": true,\n" +
|
||||
" \"prepareTime\": 0,\n" +
|
||||
" \"description\": \"测试test69dvdvd9\",\n" +
|
||||
" \"organId\": 1\n" +
|
||||
" }\n" +
|
||||
" ],\n" +
|
||||
" \"msg\": \"\"\n" +
|
||||
"}";
|
||||
|
||||
String s = zipString(jsonData);
|
||||
System.out.println(s.getBytes());
|
||||
System.out.println(s.length());
|
||||
System.out.println(jsonData.length());
|
||||
|
||||
|
||||
String compress = compress(jsonData);
|
||||
System.out.println(compress);
|
||||
System.out.println(compress.length());
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 压缩
|
||||
*/
|
||||
public static String zipString(String unzipString) {
|
||||
/**
|
||||
* https://www.yiibai.com/javazip/javazip_deflater.html#article-start
|
||||
* 0 ~ 9 压缩等级 低到高
|
||||
* public static final int BEST_COMPRESSION = 9; 最佳压缩的压缩级别。
|
||||
* public static final int BEST_SPEED = 1; 压缩级别最快的压缩。
|
||||
* public static final int DEFAULT_COMPRESSION = -1; 默认压缩级别。
|
||||
* public static final int DEFAULT_STRATEGY = 0; 默认压缩策略。
|
||||
* public static final int DEFLATED = 8; 压缩算法的压缩方法(目前唯一支持的压缩方法)。
|
||||
* public static final int FILTERED = 1; 压缩策略最适用于大部分数值较小且数据分布随机分布的数据。
|
||||
* public static final int FULL_FLUSH = 3; 压缩刷新模式,用于清除所有待处理的输出并重置拆卸器。
|
||||
* public static final int HUFFMAN_ONLY = 2; 仅用于霍夫曼编码的压缩策略。
|
||||
* public static final int NO_COMPRESSION = 0; 不压缩的压缩级别。
|
||||
* public static final int NO_FLUSH = 0; 用于实现最佳压缩结果的压缩刷新模式。
|
||||
* public static final int SYNC_FLUSH = 2; 用于清除所有未决输出的压缩刷新模式; 可能会降低某些压缩算法的压缩率。
|
||||
*/
|
||||
|
||||
//使用指定的压缩级别创建一个新的压缩器。
|
||||
Deflater deflater = new Deflater(Deflater.BEST_COMPRESSION);
|
||||
//设置压缩输入数据。
|
||||
deflater.setInput(unzipString.getBytes());
|
||||
//当被调用时,表示压缩应该以输入缓冲区的当前内容结束。
|
||||
deflater.finish();
|
||||
|
||||
final byte[] bytes = new byte[256];
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(256);
|
||||
|
||||
while (!deflater.finished()) {
|
||||
//压缩输入数据并用压缩数据填充指定的缓冲区。
|
||||
int length = deflater.deflate(bytes);
|
||||
outputStream.write(bytes, 0, length);
|
||||
}
|
||||
//关闭压缩器并丢弃任何未处理的输入。
|
||||
deflater.end();
|
||||
return Base64.getEncoder().encodeToString(outputStream.toByteArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* 解压缩
|
||||
*/
|
||||
public static String unzipString(String zipString) {
|
||||
byte[] decode = Base64.getDecoder().decode(zipString);
|
||||
|
||||
//创建一个新的解压缩器 https://www.yiibai.com/javazip/javazip_inflater.html
|
||||
|
||||
Inflater inflater = new Inflater();
|
||||
//设置解压缩的输入数据。
|
||||
inflater.setInput(decode);
|
||||
final byte[] bytes = new byte[256];
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(256);
|
||||
try {
|
||||
//finished() 如果已到达压缩数据流的末尾,则返回true。
|
||||
while (!inflater.finished()) {
|
||||
//将字节解压缩到指定的缓冲区中。
|
||||
int length = inflater.inflate(bytes);
|
||||
outputStream.write(bytes, 0, length);
|
||||
}
|
||||
} catch (DataFormatException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} finally {
|
||||
//关闭解压缩器并丢弃任何未处理的输入。
|
||||
inflater.end();
|
||||
}
|
||||
|
||||
return outputStream.toString();
|
||||
}
|
||||
|
||||
|
||||
// 使用 GZIP 进行压缩
|
||||
public static String compress(String str) throws IOException {
|
||||
if (null == str || str.length() <= 0) {
|
||||
return str;
|
||||
}
|
||||
// 创建一个新的输出流
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
// 使用默认缓冲区大小创建新的输出流
|
||||
GZIPOutputStream gzip = new GZIPOutputStream(out);
|
||||
// 将字节写入此输出流
|
||||
gzip.write(str.getBytes("utf-8")); // 因为后台默认字符集有可能是GBK字符集,所以此处需指定一个字符集
|
||||
gzip.close();
|
||||
// 使用指定的 charsetName,通过解码字节将缓冲区内容转换为字符串
|
||||
return out.toString("ISO-8859-1");
|
||||
}
|
||||
|
||||
|
||||
// 解压缩
|
||||
public static String unCompress(String str) throws IOException {
|
||||
if (null == str || str.length() <= 0) {
|
||||
return str;
|
||||
}
|
||||
// 创建一个新的输出流
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
// 创建一个 ByteArrayInputStream,使用 buf 作为其缓冲 区数组
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(str.getBytes("ISO-8859-1"));
|
||||
// 使用默认缓冲区大小创建新的输入流
|
||||
GZIPInputStream gzip = new GZIPInputStream(in);
|
||||
byte[] buffer = new byte[256];
|
||||
int n = 0;
|
||||
|
||||
// 将未压缩数据读入字节数组
|
||||
while ((n = gzip.read(buffer)) >= 0) {
|
||||
out.write(buffer, 0, n);
|
||||
}
|
||||
// 使用指定的 charsetName,通过解码字节将缓冲区内容转换为字符串
|
||||
return out.toString("utf-8");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
PUT imes_order_remain_plate_model
|
||||
{
|
||||
"settings": {},
|
||||
"mappings": {
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"planId": {
|
||||
"type": "long"
|
||||
},
|
||||
"length": {
|
||||
"type": "long"
|
||||
},
|
||||
"width": {
|
||||
"type": "long"
|
||||
},
|
||||
"thickness": {
|
||||
"type": "long"
|
||||
},
|
||||
"orgLength": {
|
||||
"type": "long"
|
||||
},
|
||||
"orgWidth": {
|
||||
"type": "long"
|
||||
},
|
||||
"cutBorder": {
|
||||
"type": "long"
|
||||
},
|
||||
"diameter": {
|
||||
"type": "long"
|
||||
},
|
||||
"cutKnifeGap": {
|
||||
"type": "long"
|
||||
},
|
||||
"preMillingSize": {
|
||||
"type": "long"
|
||||
},
|
||||
"isHelpCut": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"helpCutGap": {
|
||||
"type": "long"
|
||||
},
|
||||
"cutKnifeId": {
|
||||
"type": "long"
|
||||
},
|
||||
"helpKnifeId": {
|
||||
"type": "long"
|
||||
},
|
||||
"isOptimized": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"boardCount": {
|
||||
"type": "long"
|
||||
},
|
||||
"remainBoardCount": {
|
||||
"type": "long"
|
||||
},
|
||||
"minBoardId": {
|
||||
"type": "long"
|
||||
},
|
||||
"maxBoardId": {
|
||||
"type": "long"
|
||||
},
|
||||
"avgUsageRateAll": {
|
||||
"type": "long"
|
||||
},
|
||||
"avgUsageRateExcludeLastBoard": {
|
||||
"type": "long"
|
||||
},
|
||||
"usageRateLastBoard": {
|
||||
"type": "long"
|
||||
},
|
||||
"usedBoardInfo": {
|
||||
"type": "text",
|
||||
"fields": {
|
||||
"keyword": {
|
||||
"type": "keyword",
|
||||
"ignore_above": 256
|
||||
}
|
||||
}
|
||||
},
|
||||
"blockPlaceInfo": {
|
||||
"type": "text",
|
||||
"fields": {
|
||||
"keyword": {
|
||||
"type": "keyword",
|
||||
"ignore_above": 256
|
||||
}
|
||||
}
|
||||
},
|
||||
"remainBoardInfo": {
|
||||
"type": "text",
|
||||
"fields": {
|
||||
"keyword": {
|
||||
"type": "keyword",
|
||||
"ignore_above": 256
|
||||
}
|
||||
}
|
||||
},
|
||||
"createTime": {
|
||||
"type": "date",
|
||||
"format": "strict_date_optional_time||yyyy-MM-dd HH:mm:ss||epoch_millis"
|
||||
},
|
||||
"creator": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"updateTime": {
|
||||
"type": "date",
|
||||
"format": "strict_date_optional_time||yyyy-MM-dd HH:mm:ss||epoch_millis"
|
||||
},
|
||||
"updater": {
|
||||
"type": "keyword"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user