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:
+3
-3
@@ -55,15 +55,15 @@ public class OrderBodyDO extends BaseDO {
|
|||||||
/**
|
/**
|
||||||
* 模块复制数量
|
* 模块复制数量
|
||||||
*/
|
*/
|
||||||
private Short multiNum;
|
private Double multiNum;
|
||||||
/**
|
/**
|
||||||
* 板材数量
|
* 板材数量
|
||||||
*/
|
*/
|
||||||
private Double plateNum;
|
private Integer plateNum;
|
||||||
/**
|
/**
|
||||||
* 异型数量
|
* 异型数量
|
||||||
*/
|
*/
|
||||||
private Double unregularNum;
|
private Integer unregularNum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件名
|
* 文件名
|
||||||
|
|||||||
+6
-6
@@ -117,27 +117,27 @@ public class PlateDO extends BaseDO {
|
|||||||
/**
|
/**
|
||||||
* 异型孔数量
|
* 异型孔数量
|
||||||
*/
|
*/
|
||||||
private Short unregularPointCount;
|
private Integer unregularPointCount;
|
||||||
/**
|
/**
|
||||||
* 正面孔数量
|
* 正面孔数量
|
||||||
*/
|
*/
|
||||||
private Short frontHoleCount;
|
private Integer frontHoleCount;
|
||||||
/**
|
/**
|
||||||
* 背面孔数量
|
* 背面孔数量
|
||||||
*/
|
*/
|
||||||
private Short backHoleCount;
|
private Integer backHoleCount;
|
||||||
/**
|
/**
|
||||||
* 侧面孔数量
|
* 侧面孔数量
|
||||||
*/
|
*/
|
||||||
private Short sideHoleCount;
|
private Integer sideHoleCount;
|
||||||
/**
|
/**
|
||||||
* 正面造型量
|
* 正面造型量
|
||||||
*/
|
*/
|
||||||
private Short frontModelCount;
|
private Integer frontModelCount;
|
||||||
/**
|
/**
|
||||||
* 背面造型量
|
* 背面造型量
|
||||||
*/
|
*/
|
||||||
private Short backModelCount;
|
private Integer backModelCount;
|
||||||
/**
|
/**
|
||||||
* 是否门板
|
* 是否门板
|
||||||
*/
|
*/
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
|||||||
@TableName("order_raw_goods")
|
@TableName("order_raw_goods")
|
||||||
@KeySequence("order_raw_goods_n_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
@KeySequence("order_raw_goods_n_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
|
|||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
package com.cf.imes.module.executor.dal.dto;
|
||||||
|
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.orderBody.OrderBodyDO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.orderGroup.OrderGroupDO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.orderParts.OrderPartsDO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.rawgoods.RawGoodsDO;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Beal
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class BoardProdInfoDTO {
|
||||||
|
@Schema(description = "商品表")
|
||||||
|
private RawGoodsDO rawGoodsDO;
|
||||||
|
@Schema(description = "生产单柜体表")
|
||||||
|
private OrderBodyDO orderBodyDO;
|
||||||
|
@Schema(description = "生产单加工组表")
|
||||||
|
private OrderGroupDO orderGroupDO;
|
||||||
|
@Schema(description = "生产单五金表")
|
||||||
|
private OrderPartsDO orderPartsDO;
|
||||||
|
@Schema(description = "生产单小板表")
|
||||||
|
private PlateDO plateDO;
|
||||||
|
}
|
||||||
+62
@@ -0,0 +1,62 @@
|
|||||||
|
package com.cf.imes.module.executor.dal.dto;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Beal
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class RawGoodsDTO {
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 生产单号
|
||||||
|
*/
|
||||||
|
private Long orderId;
|
||||||
|
/**
|
||||||
|
* 设计端商品编码
|
||||||
|
*/
|
||||||
|
private String rawGoodsId;
|
||||||
|
/**
|
||||||
|
* 设计端商品名称
|
||||||
|
*/
|
||||||
|
private String goodsName;
|
||||||
|
/**
|
||||||
|
* 材质
|
||||||
|
*/
|
||||||
|
private String material;
|
||||||
|
/**
|
||||||
|
* 颜色
|
||||||
|
*/
|
||||||
|
private String color;
|
||||||
|
/**
|
||||||
|
* 厚度
|
||||||
|
*/
|
||||||
|
private Double thickness;
|
||||||
|
/**
|
||||||
|
* 价格
|
||||||
|
*/
|
||||||
|
private Double price;
|
||||||
|
/**
|
||||||
|
* 品牌
|
||||||
|
*/
|
||||||
|
private String brand;
|
||||||
|
/**
|
||||||
|
* 规格
|
||||||
|
*/
|
||||||
|
private String spec;
|
||||||
|
/**
|
||||||
|
* 小板id
|
||||||
|
*/
|
||||||
|
private List<Long> plateId;
|
||||||
|
|
||||||
|
}
|
||||||
+274
@@ -0,0 +1,274 @@
|
|||||||
|
package com.cf.imes.module.executor.service.order;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
|
||||||
|
import com.cf.imes.framework.common.util.json.JsonUtils;
|
||||||
|
import com.cf.imes.framework.mybatis.core.generator.SnowFlakeGenerator;
|
||||||
|
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.orderBody.OrderBodyDO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.orderGroup.OrderGroupDO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.orderItem.OrderItemDO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.orderModuleExtra.OrderModuleExtraDO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.orderParts.OrderPartsDO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.rawgoods.RawGoodsDO;
|
||||||
|
import com.cf.imes.module.executor.dal.mysql.orderBody.OrderBodyMapper;
|
||||||
|
import com.cf.imes.module.executor.dal.mysql.orderGroup.OrderGroupMapper;
|
||||||
|
import com.cf.imes.module.executor.dal.mysql.orderItem.OrderItemMapper;
|
||||||
|
import com.cf.imes.module.executor.dal.mysql.orderModuleExtra.OrderModuleExtraMapper;
|
||||||
|
import com.cf.imes.module.executor.dal.mysql.orderParts.OrderPartsMapper;
|
||||||
|
import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper;
|
||||||
|
import com.cf.imes.module.executor.dal.mysql.rawgoods.RawGoodsMapper;
|
||||||
|
import com.cf.imes.module.executor.util.RandomUtils;
|
||||||
|
import com.cf.imes.module.executor.util.deviseData.Detail;
|
||||||
|
import com.cf.imes.module.executor.util.deviseData.IBoardProdInfo;
|
||||||
|
import com.cf.imes.module.executor.util.deviseData.PartsModuleExtra;
|
||||||
|
import com.cf.imes.module.executor.util.deviseData.PlateModuleExtra;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Beal
|
||||||
|
* 生产单入库处理器
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class OrderInputProcessor {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IdentifierGenerator identifierGenerator;
|
||||||
|
/*private IdentifierGenerator identifierGenerator = new SnowFlakeGenerator(0, 0);*/
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RawGoodsMapper rawGoodsMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OrderBodyMapper orderBodyMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OrderGroupMapper orderGroupMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OrderPartsMapper orderPartsMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PlateMapper plateMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OrderItemMapper orderItemMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OrderModuleExtraMapper orderModuleExtraMapper;
|
||||||
|
|
||||||
|
|
||||||
|
public void input(List<Detail> sourceList, Long orderId) {
|
||||||
|
Long organId = OrganContextHolder.getOrganId();
|
||||||
|
ArrayList<RawGoodsDO> rawGoodsDOS = new ArrayList<>();
|
||||||
|
ArrayList<OrderBodyDO> orderBodyDOS = new ArrayList<>();
|
||||||
|
ArrayList<OrderGroupDO> orderGroupDOS = new ArrayList<>();
|
||||||
|
ArrayList<PlateDO> plateDOS = new ArrayList<>();
|
||||||
|
ArrayList<OrderPartsDO> orderPartsDOS = new ArrayList<>();
|
||||||
|
ArrayList<OrderItemDO> orderItemDOS = new ArrayList<>();
|
||||||
|
ArrayList<OrderModuleExtraDO> orderModuleExtraDOS = new ArrayList<>();
|
||||||
|
Map<RawGoodsDO, Map<OrderBodyDO, Map<OrderGroupDO, List<Detail>>>> map = sourceList.stream().collect(Collectors.groupingBy(e ->
|
||||||
|
RawGoodsDO.builder()
|
||||||
|
.rawGoodsId(e.getIBoardProdInfo().getGoodsId())
|
||||||
|
.goodsName(e.getIBoardProdInfo().getGoodsName())
|
||||||
|
.material(e.getIBoardProdInfo().getMaterial())
|
||||||
|
.color(e.getIBoardProdInfo().getColor())
|
||||||
|
.brand(e.getIBoardProdInfo().getBrand())
|
||||||
|
.spec(e.getIBoardProdInfo().getSpec())
|
||||||
|
.price(0.0)
|
||||||
|
.orderId(orderId)
|
||||||
|
.build(),
|
||||||
|
Collectors.groupingBy(e ->
|
||||||
|
OrderBodyDO.builder()
|
||||||
|
.orderId(orderId)
|
||||||
|
.roomName(e.getIBoardProdInfo().getRoomsName())
|
||||||
|
.name(e.getIBoardProdInfo().getCabinetsName())
|
||||||
|
.width(e.getWidth())
|
||||||
|
.height(e.getHeight())
|
||||||
|
.depth(e.getDepth())
|
||||||
|
.multiNum(e.getMultiNum().doubleValue())
|
||||||
|
.filename("")
|
||||||
|
.remark("")
|
||||||
|
.build(),
|
||||||
|
Collectors.groupingBy(e ->
|
||||||
|
OrderGroupDO.builder()
|
||||||
|
.groupId((long) e.getIBoardProdInfo().getSynthesis())
|
||||||
|
.groupType(e.getIBoardProdInfo().getCombinationName())
|
||||||
|
.name(e.getIBoardProdInfo().getSynthesisTypeName())
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
))
|
||||||
|
);
|
||||||
|
|
||||||
|
map.entrySet().forEach(i -> {
|
||||||
|
|
||||||
|
RawGoodsDO rawGoodsDO = i.getKey();
|
||||||
|
rawGoodsDOS.add(rawGoodsDO);
|
||||||
|
rawGoodsDO.setId(identifierGenerator.nextId(null).longValue());
|
||||||
|
i.getValue().entrySet().forEach(j -> {
|
||||||
|
|
||||||
|
OrderBodyDO orderBodyDO = j.getKey();
|
||||||
|
orderBodyDO.setId(identifierGenerator.nextId(null).longValue());
|
||||||
|
orderBodyDO.setRoomId(identifierGenerator.nextId(null).longValue());
|
||||||
|
Map<OrderGroupDO, List<Detail>> value = j.getValue();
|
||||||
|
Integer reduce = value.values().stream().map(List::size).reduce(0, Integer::sum);
|
||||||
|
int unregularNum = value.values().stream().flatMap(Collection::stream).filter(e -> !e.getIBoardProdInfo().getIsRect()).collect(Collectors.toList()).size();
|
||||||
|
orderBodyDO.setPlateNum(reduce);
|
||||||
|
orderBodyDO.setUnregularNum(unregularNum);
|
||||||
|
orderBodyDOS.add(orderBodyDO);
|
||||||
|
j.getValue().entrySet().forEach(k -> {
|
||||||
|
OrderGroupDO orderGroupDO = k.getKey();
|
||||||
|
orderGroupDO.setId(identifierGenerator.nextId(null).longValue());
|
||||||
|
orderGroupDO.setOrderId(orderId);
|
||||||
|
orderGroupDO.setBodyId(orderBodyDO.getId());
|
||||||
|
orderGroupDOS.add(orderGroupDO);
|
||||||
|
|
||||||
|
//moduleExtra
|
||||||
|
List<PlateModuleExtra> plateExtras = k.getValue().stream().filter(e -> e.getIBoardProdInfo().getGoodType() == 1)
|
||||||
|
.map(e -> PlateModuleExtra.builder()
|
||||||
|
.width(e.getIBoardProdInfo().getWidth())
|
||||||
|
.height(e.getIBoardProdInfo().getHeight())
|
||||||
|
.thickness(e.getIBoardProdInfo().getThickness())
|
||||||
|
.groupType(orderGroupDO.getGroupType())
|
||||||
|
.build()
|
||||||
|
).toList();
|
||||||
|
List<PartsModuleExtra> partsModuleExtras = k.getValue().stream().filter(e -> e.getIBoardProdInfo().getGoodType() == 1)
|
||||||
|
.map(e -> PartsModuleExtra.builder()
|
||||||
|
.name(e.getIBoardProdInfo().getName())
|
||||||
|
.bodyName(e.getIBoardProdInfo().getCabinetsName())
|
||||||
|
.model(e.getIBoardProdInfo().getModel())
|
||||||
|
.spec(e.getIBoardProdInfo().getSpec())
|
||||||
|
.unit(e.getIBoardProdInfo().getUnit())
|
||||||
|
.build()
|
||||||
|
).toList();
|
||||||
|
if(CollectionUtil.isNotEmpty(plateExtras)) {
|
||||||
|
orderModuleExtraDOS.add(
|
||||||
|
OrderModuleExtraDO.builder()
|
||||||
|
.orderId(orderId)
|
||||||
|
.bodyId(orderBodyDO.getId())
|
||||||
|
.roomId(orderBodyDO.getRoomId())
|
||||||
|
.type(1)
|
||||||
|
.extraData(JsonUtils.toJsonString(plateExtras))
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(CollectionUtil.isNotEmpty(partsModuleExtras)) {
|
||||||
|
orderModuleExtraDOS.add(
|
||||||
|
OrderModuleExtraDO.builder()
|
||||||
|
.orderId(orderId)
|
||||||
|
.bodyId(orderBodyDO.getId())
|
||||||
|
.roomId(orderBodyDO.getRoomId())
|
||||||
|
.type(2)
|
||||||
|
.extraData(JsonUtils.toJsonString(partsModuleExtras))
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
k.getValue().forEach(e -> {
|
||||||
|
int goodType = e.getIBoardProdInfo().getGoodType();
|
||||||
|
OrderItemDO orderItemDO = new OrderItemDO();
|
||||||
|
orderItemDO.setOrderId(orderId);
|
||||||
|
orderItemDO.setPlanId(0L);
|
||||||
|
orderItemDO.setPackageId(0L);
|
||||||
|
orderItemDO.setGroupId(orderGroupDO.getId());
|
||||||
|
orderItemDO.setRoomId(orderBodyDO.getRoomId());
|
||||||
|
orderItemDO.setBodyId(orderBodyDO.getId());
|
||||||
|
orderItemDO.setNum(e.getIBoardProdInfo().getGoodsNumber());
|
||||||
|
if (goodType == 1) {
|
||||||
|
PlateDO plateDO = PlateDO.builder()
|
||||||
|
.id(identifierGenerator.nextId(null).longValue())
|
||||||
|
.goodsId(rawGoodsDO.getRawGoodsId())
|
||||||
|
.orderId(orderId)
|
||||||
|
.name(e.getIBoardProdInfo().getName())
|
||||||
|
.plateNo(e.getIBoardProdInfo().getPlateNo())
|
||||||
|
//.type(e.getIBoardProdInfo().)
|
||||||
|
.goodsId(rawGoodsDO.getRawGoodsId())
|
||||||
|
.height(e.getIBoardProdInfo().getHeight())
|
||||||
|
.width(e.getIBoardProdInfo().getWidth())
|
||||||
|
.thickness(new BigDecimal(e.getIBoardProdInfo().getThickness().toString()))
|
||||||
|
.splitHeight(new BigDecimal(e.getIBoardProdInfo().getSplitHeight().toString()))
|
||||||
|
.splitWidth(new BigDecimal(e.getIBoardProdInfo().getSplitWidth().toString()))
|
||||||
|
.splitThickness(new BigDecimal(e.getIBoardProdInfo().getThickness().toString()))
|
||||||
|
.sealLeft(e.getIBoardProdInfo().getSealLeft())
|
||||||
|
.sealRight(e.getIBoardProdInfo().getSealRight())
|
||||||
|
.sealUp(e.getIBoardProdInfo().getSealUp())
|
||||||
|
.sealDown(e.getIBoardProdInfo().getSealDown())
|
||||||
|
.area(e.getIBoardProdInfo().getWidth().multiply(e.getIBoardProdInfo().getHeight()))
|
||||||
|
.texture(e.getIBoardProdInfo().getTexture())
|
||||||
|
.type(0)
|
||||||
|
.holeFace(e.getHoleDetail().getFaceType())
|
||||||
|
.holeArrange(0)
|
||||||
|
.unregularPointCount(0)
|
||||||
|
.frontHoleCount(0)
|
||||||
|
.frontModelCount(0)
|
||||||
|
.backHoleCount(0)
|
||||||
|
.sideHoleCount(0)
|
||||||
|
.backModelCount(0)
|
||||||
|
.isDoor(false)
|
||||||
|
.openDoorType(e.getIBoardProdInfo().getOpenDoorType())
|
||||||
|
.offsetX(0.0)
|
||||||
|
.offsetY(0.0)
|
||||||
|
.isArcAcross(false)
|
||||||
|
.moduleTypeId(orderBodyDO.getId())
|
||||||
|
.filterType(0)
|
||||||
|
.remark(e.getIBoardProdInfo().getRemark())
|
||||||
|
.isCancel(false)
|
||||||
|
.build();
|
||||||
|
orderItemDO.setPlateId(plateDO.getId());
|
||||||
|
orderItemDO.setPartsId(0L);
|
||||||
|
orderItemDO.setType(1);
|
||||||
|
plateDOS.add(plateDO);
|
||||||
|
} else {
|
||||||
|
OrderPartsDO orderPartsDO = OrderPartsDO.builder()
|
||||||
|
.id(identifierGenerator.nextId(null).longValue())
|
||||||
|
.orderId(orderId)
|
||||||
|
.goodsId(rawGoodsDO.getRawGoodsId())
|
||||||
|
.name(e.getIBoardProdInfo().getName())
|
||||||
|
.material(e.getIBoardProdInfo().getMaterial())
|
||||||
|
.model(e.getIBoardProdInfo().getModel())
|
||||||
|
.spec(e.getIBoardProdInfo().getSpec())
|
||||||
|
.brand(e.getIBoardProdInfo().getBrand())
|
||||||
|
.factory(e.getIBoardProdInfo().getFactory())
|
||||||
|
.unit(e.getIBoardProdInfo().getUnit())
|
||||||
|
.price(0.0)
|
||||||
|
.isComposite(false)
|
||||||
|
.remark(e.getIBoardProdInfo().getRemark())
|
||||||
|
.type(0)
|
||||||
|
.build();
|
||||||
|
orderItemDO.setType(2);
|
||||||
|
orderItemDO.setPartsId(orderPartsDO.getId());
|
||||||
|
orderItemDO.setPlateId(0L);
|
||||||
|
orderPartsDOS.add(orderPartsDO);
|
||||||
|
orderItemDOS.add(orderItemDO);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
batchInsert(rawGoodsDOS, orderBodyDOS, orderGroupDOS, orderPartsDOS, plateDOS, orderModuleExtraDOS, orderItemDOS);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void batchInsert(Collection<RawGoodsDO> rawGoodsDOS, Collection<OrderBodyDO> orderBodyDOS,
|
||||||
|
Collection<OrderGroupDO> orderGroupDOS, Collection<OrderPartsDO> orderPartsDOS,
|
||||||
|
Collection<PlateDO> plateDOS, Collection<OrderModuleExtraDO> orderModuleExtraDOS, Collection<OrderItemDO> itemDOS) {
|
||||||
|
rawGoodsMapper.insertBatch(rawGoodsDOS);
|
||||||
|
orderBodyMapper.insertBatch(orderBodyDOS);
|
||||||
|
orderGroupMapper.insertBatch(orderGroupDOS);
|
||||||
|
orderPartsMapper.insertBatch(orderPartsDOS);
|
||||||
|
plateMapper.insertBatch(plateDOS);
|
||||||
|
orderModuleExtraMapper.insertBatch(orderModuleExtraDOS);
|
||||||
|
orderItemMapper.insertBatch(itemDOS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
+75
@@ -0,0 +1,75 @@
|
|||||||
|
package com.cf.imes.module.executor.util;
|
||||||
|
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.zip.Deflater;
|
||||||
|
import java.util.zip.Inflater;
|
||||||
|
|
||||||
|
public class CompressTest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 压缩
|
||||||
|
*
|
||||||
|
* @param str 要压缩的字符串
|
||||||
|
* @return 压缩后的字符串
|
||||||
|
*/
|
||||||
|
public static String compress(String str) throws Exception{
|
||||||
|
Deflater deflater = new Deflater(9); // 0 ~ 9 压缩等级 低到高 推荐9
|
||||||
|
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(256)){
|
||||||
|
deflater.setInput(str.getBytes());
|
||||||
|
deflater.finish();
|
||||||
|
final byte[] bytes = new byte[256];
|
||||||
|
while (!deflater.finished()) {
|
||||||
|
int length = deflater.deflate(bytes);
|
||||||
|
outputStream.write(bytes, 0, length);
|
||||||
|
}
|
||||||
|
return new String( java.util.Base64.getEncoder().encode(outputStream.toByteArray()));
|
||||||
|
// return new sun.misc.BASE64Encoder().encodeBuffer(outputStream.toByteArray());
|
||||||
|
} finally {
|
||||||
|
deflater.end();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param encodeStr 待解压缩的字符串
|
||||||
|
* @return 解压缩后的字节数组
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public static String uncompress(String encodeStr) throws IOException {
|
||||||
|
int len = 0;
|
||||||
|
Inflater infl = new Inflater();
|
||||||
|
infl.setInput(Base64.decodeBase64(encodeStr));
|
||||||
|
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
|
byte[] outByte = new byte[1024];
|
||||||
|
try {
|
||||||
|
while (!infl.finished()) {
|
||||||
|
// 解压缩并将解压缩后的内容输出到字节输出流bos中
|
||||||
|
len = infl.inflate(outByte);
|
||||||
|
if (len == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
bos.write(outByte, 0, len);
|
||||||
|
}
|
||||||
|
infl.end();
|
||||||
|
} catch (Exception e) {
|
||||||
|
//
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
bos.close();
|
||||||
|
}
|
||||||
|
return bos.toString();
|
||||||
|
}
|
||||||
|
public static void main(String[] args)throws Exception{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("{\"test\":\"111\"}");
|
||||||
|
String str = sb.toString();
|
||||||
|
String eos = compress(str);
|
||||||
|
System.out.println(eos);
|
||||||
|
String deos = uncompress(eos);
|
||||||
|
System.out.println(deos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
+1
-1
@@ -29,7 +29,7 @@ public class Detail {
|
|||||||
|
|
||||||
private List<ModelDetail> contourDetail ; //轮廓明细
|
private List<ModelDetail> contourDetail ; //轮廓明细
|
||||||
private List<PointDetail> pointDetail ; //点明细
|
private List<PointDetail> pointDetail ; //点明细
|
||||||
private List<HoleDetail> holeDetail ; //孔明细
|
private HoleDetail holeDetail ; //孔明细
|
||||||
private List<PointDetail> rawPointDetail ; //原始点明细
|
private List<PointDetail> rawPointDetail ; //原始点明细
|
||||||
private List<ModelDetail> sideModelDetail ; //侧面轮廓明细
|
private List<ModelDetail> sideModelDetail ; //侧面轮廓明细
|
||||||
private List<HoleDetail> sideHoleDetail;//侧面孔明细
|
private List<HoleDetail> sideHoleDetail;//侧面孔明细
|
||||||
|
|||||||
+3
-2
@@ -1,13 +1,14 @@
|
|||||||
package com.cf.imes.module.executor.util.deviseData;
|
package com.cf.imes.module.executor.util.deviseData;
|
||||||
|
|
||||||
import io.vavr.collection.List;
|
import com.cf.imes.module.executor.controller.admin.plan.dto.Point;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 轮廓数据
|
* 轮廓数据
|
||||||
|
|||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package com.cf.imes.module.executor.util.deviseData;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Beal
|
||||||
|
* 五金配置的extra
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class PartsModuleExtra {
|
||||||
|
private String name;
|
||||||
|
private String bodyName;
|
||||||
|
private String model;
|
||||||
|
private String spec;
|
||||||
|
private String unit;
|
||||||
|
}
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
package com.cf.imes.module.executor.util.deviseData;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Beal
|
||||||
|
* 小板的extra数据
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class PlateModuleExtra {
|
||||||
|
private BigDecimal width;
|
||||||
|
private BigDecimal height;
|
||||||
|
private Double thickness;
|
||||||
|
private String groupType;
|
||||||
|
}
|
||||||
+6
-2
@@ -6,6 +6,7 @@ import cn.hutool.json.JSONObject;
|
|||||||
import com.alibaba.druid.pool.DruidDataSource;
|
import com.alibaba.druid.pool.DruidDataSource;
|
||||||
import com.alibaba.nacos.shaded.io.grpc.netty.shaded.io.netty.handler.codec.compression.JdkZlibDecoder;
|
import com.alibaba.nacos.shaded.io.grpc.netty.shaded.io.netty.handler.codec.compression.JdkZlibDecoder;
|
||||||
import com.alibaba.nacos.shaded.io.grpc.netty.shaded.io.netty.handler.codec.compression.ZlibDecoder;
|
import com.alibaba.nacos.shaded.io.grpc.netty.shaded.io.netty.handler.codec.compression.ZlibDecoder;
|
||||||
|
import com.cf.imes.module.executor.util.CompressTest;
|
||||||
import com.cf.imes.module.executor.util.ZLibUtils;
|
import com.cf.imes.module.executor.util.ZLibUtils;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
@@ -45,11 +46,14 @@ public class ZlibTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getOrderBoxBlock() throws UnsupportedEncodingException {
|
void getOrderBoxBlock() throws IOException {
|
||||||
List<OrderBoxBlock> list = jdbcTemplate.query("select * from order_box_block limit 10", new BeanPropertyRowMapper<OrderBoxBlock>(OrderBoxBlock.class));
|
List<OrderBoxBlock> list = jdbcTemplate.query("select * from order_box_block limit 10", new BeanPropertyRowMapper<OrderBoxBlock>(OrderBoxBlock.class));
|
||||||
for (OrderBoxBlock bean : list) {
|
for (OrderBoxBlock bean : list) {
|
||||||
if (!Objects.isNull(bean.Data)) {
|
if (!Objects.isNull(bean.Data)) {
|
||||||
System.out.println(new String(ZLibUtils.decompress(bean.Data)));
|
byte[] bytes = Arrays.copyOfRange(bean.Data, 2, bean.Data.length - 1);
|
||||||
|
System.out.println( new String(bean.Data));
|
||||||
|
System.out.println( CompressTest.uncompress(new String(bytes)));
|
||||||
|
//System.out.println(new String(ZLibUtils.decompress(bean.Data)));
|
||||||
System.err.println("------------------------------------------");
|
System.err.println("------------------------------------------");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user