生产单板材造型新增大板等字段,ES板材造型数据压缩保存,标签Bug修改

This commit is contained in:
liuzhaotian
2024-12-06 16:05:57 +08:00
parent 3252fc9c84
commit e2cc2b6fef
25 changed files with 394 additions and 215 deletions
@@ -15,8 +15,10 @@ import com.cf.imes.module.executor.controller.admin.order.vo.product.OrderBodyRe
import com.cf.imes.module.executor.controller.admin.order.vo.product.OrderRoomBodyRespVO;
import com.cf.imes.module.executor.controller.admin.orderParts.vo.OrderPartsRespVO;
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
import com.cf.imes.module.executor.dal.mysql.order.OrderMapper;
import com.cf.imes.module.executor.enums.OrderDeletedEnum;
import com.cf.imes.module.executor.enums.OrderStatusEnum;
import com.cf.imes.module.executor.service.order.OrderInputProcessor;
import com.cf.imes.module.executor.service.order.OrderService;
import com.cf.imes.module.executor.util.ExcelWriterUtil;
import com.cf.imes.module.executor.util.fileConversion.admin.api.webcad.ApiDataAchieve;
@@ -57,11 +59,6 @@ import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.ge
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Tag(name = "管理后台 - 生产单管理")
@RestController
@RequestMapping("/executor/order")
@@ -72,6 +69,9 @@ public class OrderController {
@Resource
private OrderService orderService;
@Resource
private OrderMapper orderMapper;
@Resource
private ExcelReadUtil excelReadUtil;
@@ -99,6 +99,9 @@ public class OrderController {
@Resource
private RedisLockUtil redisLockUtil;
@Resource
private OrderInputProcessor orderInputProcessor;
private String lockKey = "order:1631:lock:";
private String errKey = "api数据导入异常";
private String errValue = "当前存在导入情况,请稍后";
@@ -209,8 +212,9 @@ public class OrderController {
log.error(errKey, errValue);
return success(errValue);
}
Long orderId = null;
try {
Long orderId = (Long) identifierGenerator.nextId(null);
orderId = (Long) identifierGenerator.nextId(null);
Long organId = getUserOrganId();
JSONObject oauth = apiDataAchieve.getApiToken(organId).get();
String token = oauth.getJSONObject("info").getString("access_token");
@@ -248,6 +252,12 @@ public class OrderController {
log.error(errKey, e);
return success(e.getMessage());
} finally {
// 进行判断,为空,写入时出现了错误,数据库数据回滚,此时删除 ES 里的数据
OrderDO orderDO = orderMapper.selectById(orderId);
if (orderDO == null) {
orderInputProcessor.deleteByOrderId(orderId, ORDER_PLATE_MODEL);
orderInputProcessor.deleteByOrderId(orderId, ORDER_PLATE_MODEL_COMPRESS);
}
redisLockUtil.unlock(lockKey);
}
@@ -395,6 +405,12 @@ public class OrderController {
XMLUtil.writeErr(response, xmlStr, " order_add_xml_err.xml");
}
} finally {
// 进行判断,为空,写入时出现了错误,数据库数据回滚,此时删除 ES 里的数据
OrderDO order = orderMapper.selectById(orderDO.getId());
if (order == null) {
orderInputProcessor.deleteByOrderId(orderDO.getId(), ORDER_PLATE_MODEL);
orderInputProcessor.deleteByOrderId(orderDO.getId(), ORDER_PLATE_MODEL_COMPRESS);
}
redisLockUtil.unlock(lockKey);
}
}
@@ -0,0 +1,30 @@
package com.cf.imes.module.executor.controller.admin.order.vo.order;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "大板,小板,生产单ID合集")
@Data
public class OrderGoodsPlateIds {
@Schema(description = "板件ID", requiredMode = Schema.RequiredMode.REQUIRED)
private Long id;
@Schema(description = "生产单号", requiredMode = Schema.RequiredMode.REQUIRED)
private Long orderId;
@Schema(description = "实际的大板ID", requiredMode = Schema.RequiredMode.REQUIRED)
private String actualGoodsId;
@Schema(description = "大板分类ID", requiredMode = Schema.RequiredMode.REQUIRED)
private Long goodsId;
}
@@ -11,6 +11,7 @@ import org.hibernate.validator.constraints.Length;
import javax.validation.Valid;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.List;
@@ -24,7 +25,7 @@ public class PlanSaveReqVO {
private Long id;
@Schema(description = "排序优先级", requiredMode = Schema.RequiredMode.REQUIRED)
@Schema(description = "排序优先级")
private Long sort;
@@ -55,11 +56,11 @@ public class PlanSaveReqVO {
private String remark;
@Schema(description = "生产操作人", requiredMode = Schema.RequiredMode.REQUIRED)
@Schema(description = "生产操作人")
private String operator;
@Schema(description = "生产时间", requiredMode = Schema.RequiredMode.REQUIRED)
@Schema(description = "生产时间")
private LocalDateTime produceTime;
@@ -68,7 +69,7 @@ public class PlanSaveReqVO {
private List<Item> itemList;
@Schema(description = "去除的大板分类ID",requiredMode = Schema.RequiredMode.REQUIRED)
@Schema(description = "去除的大板分类ID")
private List<Long> deleteIds;
@@ -0,0 +1,29 @@
package com.cf.imes.module.executor.dal.dataobject.ordermodel;
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;
/**
* @author 生产单板材造型数据的压缩保存
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class OrderModelCompressDO extends ESDocument {
@Schema(description = "生产单id")
private Long orderId;
@Schema(description = "生产单造型的压缩数据")
private String orderModelZip;
}
@@ -29,6 +29,15 @@ public class OrderModelDO extends ESDocument {
@Schema(description = "小板id")
private Long plateId;
@Schema(description = "大板的实际ID")
private String goodsId;
@Schema(description = "大板的分类ID")
private Long plateGoodsId;
@Schema(description = "是否已优化")
private Boolean isOptimized;
@Schema(description = "房间的基点坐标")
private BasePosition roomBasePosition; // 板件基准点坐标
@Schema(description = "柜体的基点坐标")
@@ -0,0 +1,104 @@
package com.cf.imes.module.executor.dal.dataobject.ordermodel;
import com.alibaba.fastjson.JSONObject;
import com.cf.imes.module.executor.util.deviseData.structure.*;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class OrderPlateList {
@Schema(description = "小板id")
private Long plateId;
@Schema(description = "是否已优化")
private Boolean isOptimized;
@Schema(description = "房间的基点坐标")
private BasePosition roomBasePosition; // 板件基准点坐标
@Schema(description = "柜体的基点坐标")
private BasePosition bodyBasePosition; // 板件基准点坐标
@Schema(description = "板件的基点坐标")
private BasePosition plateBasePosition; // 板件基准点坐标
@Schema(description = "纹路 纹路(0正纹1可翻转2反纹)")
private Integer texture;
@Schema(description = "排版面 排钻类型(0正面1反面2随意面)")
private Integer typographicFace;
@Schema(description = "开门类型 0非门板,1左开,2右开,3上翻,4下翻")
private Integer openDoorType; // 字典转换
@Schema(description = "小板类型")
private String boardType;
@Schema(description = "板件配件信息")
private List<PartsInfo> partsInfos;
@Schema(description = "开料长")
private BigDecimal splitLength;
@Schema(description = "开料宽")
private BigDecimal splitWidth;
@Schema(description = "偏移量X")
private BigDecimal offsetX;
@Schema(description = "偏移量Y")
private BigDecimal offsetY;
@Schema(description = "是否有二维刀路")
private Boolean has2DModel;
@Schema(description = "是否有三维刀路")
private Boolean has3DModel;
@Schema(description = "点明细,表示小板外围轮廓的几个转折点(不含封边)")
private List<PointDetail> pointDetail;
@Schema(description = "原始点明细列表")
private List<PointDetail> rawPointDetail;
@Schema(description = "坯料点明细")
private List<PointDetail> basePointDetail ; //坯料点明细
@Schema(description = "holes数量集合 count=孔数量 countFaceA=正面垂直孔数量] countFaceB=反面垂直孔数量] countSide=水平侧孔数量] countSideL=左侧孔数量] countSideR=右侧孔数量 countSideU=上侧孔数量 countSideD=下侧孔数量 countBevelled=斜面孔数量 countLocking=偏心轮/锁定孔数量 countBuildIn=预埋件/插入孔数量 countHinge=铰链孔数量 countThrough=通孔(对穿孔)/挖穿孔数量]")
private Map<String,Integer> holeCount;//孔类型数量集合
@Schema(description = "孔明细列表")
private List<HoleDetail> holeDetail;
@Schema(description = "凹槽数量集合")
private Map<String,Integer> contourCount;//凹槽数量集合
@Schema(description = "造型明细(凹槽)")
private List<ModelDetail> contourDetail;
@Schema(description = "造型明细(孤岛,现在是xml数据格式添加)")
private List<ModelDetail> sideDetail ; //造型明细(孤岛) sideDetail
@Schema(description = "侧面孔明细列表")
private List<HoleDetail> sideHoleDetail;
@Schema(description = "生产封边备注")
private Map<String,String> sideRemark;// 封边备注
@Schema(description = "板材扩展备注")
private JSONObject plateExtraRemark;// 封边备注
@Schema(description = "扩展备注(包含铰链备注、订单板件流水号)")
private String extraRemark; // 扩展备注(包含铰链备注、订单板件流水号)(板材明细中)
@Schema(description = "特殊备注(Json字符串)")
private String specialRemarkDei; // 特殊备注(Json字符串)
@Schema(description = "拉手备注(Json字符串)")
private String extraHandleRemark; // 拉手备注
@Schema(description = "排钻备注(Json字符串)")
private String drillsRemark; // 排钻备注(Json字符串)
@Schema(description = "板其他备注(Json字符串)")
private String infoRemark; // 板其他备注(Json字符串)
@Schema(description = "板件备注(Json字符串)")
private String remarkJsonDei; // 板件备注(Json字符串)
@Schema(description = "普通备注(板材数据中)")
private String remarkJson; // 普通备注(板材数据中)
@Schema(description = "特殊备注(板材数据中)")
private String specialRemark; // 特殊备注(板材数据中)
}
@@ -0,0 +1,29 @@
package com.cf.imes.module.executor.dal.dataobject.ordermodel;
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;
/**
* @author 高级筛选数据
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class OrderPlateModel extends ESDocument {
@Schema(description = "生产单id")
private Long orderId;
@Schema(description = "大板分类ID")
private Long plateGoodsId;
@Schema(description = "大板实际ID")
private String goodsId;
}
@@ -567,6 +567,7 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
// 查询排单对应的大板信息
List<GoodsReqVO> goodsDOS = goodsMapper.selectGoodsListByOrderIds(planId,getUserOrganId());
AssertUtils.notEmpty(goodsDOS,PLAN_GOODS_DATA_ERROR);
List<Long> orderIds = goodsDOS.stream().map(GoodsReqVO::getOrderId).distinct().toList();
@@ -10,13 +10,12 @@ import com.cf.imes.framework.common.exception.ServiceException;
import com.cf.imes.framework.es.core.service.ESDocumentService;
import com.cf.imes.module.executor.controller.admin.orderParts.vo.OrderPartsRemark;
import com.cf.imes.module.executor.dal.dataobject.goods.GoodsDO;
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
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.orderParts.PartsDO;
import com.cf.imes.module.executor.dal.dataobject.ordermodel.OrderModelCompressDO;
import com.cf.imes.module.executor.dal.dataobject.ordermodel.OrderModelDO;
import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
import com.cf.imes.module.executor.dal.dataobject.plate.PlateGoodDO;
@@ -26,20 +25,20 @@ import com.cf.imes.module.executor.dal.mysql.order.OrderMapper;
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.orderParts.PartsMapper;
import com.cf.imes.module.executor.dal.mysql.plate.PlateGoodMapper;
import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper;
import com.cf.imes.module.executor.dal.mysql.rawgoods.RawGoodsMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;
@@ -99,6 +98,8 @@ public class OrderInputProcessor {
public static final String ORDER_PARTS_REMARK_MODEL = "imes_order_parts_remark_model";
public static final String ORDER_PLATE_MODEL_COMPRESS = "imes_order_plate_model_compress";
/**
* 批量保存生产单小板五金数据
*
@@ -203,6 +204,31 @@ public class OrderInputProcessor {
}
/**
* 保存生产单板材造型的压缩数据
*
* @param orderModelDOs
*/
public void batchSaveCompressModel(List<OrderModelCompressDO> orderModelDOs) {
try {
BulkResponse bulkResponse = esDocumentService.bulkCreate(ORDER_PLATE_MODEL_COMPRESS, orderModelDOs);
boolean errors = bulkResponse.errors();
if (errors) {
log.error(bulkResponse.items().toString());
throw new ServiceException(500, "未知异常");
}
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
throw new RuntimeException(e);
}
}
/**
* 保存生产单配件备注数据
*
@@ -30,7 +30,9 @@ 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.orderParts.OrderPartsDO;
import com.cf.imes.module.executor.dal.dataobject.orderParts.PartsDO;
import com.cf.imes.module.executor.dal.dataobject.ordermodel.OrderModelCompressDO;
import com.cf.imes.module.executor.dal.dataobject.ordermodel.OrderModelDO;
import com.cf.imes.module.executor.dal.dataobject.ordermodel.OrderPlateList;
import com.cf.imes.module.executor.dal.dataobject.pack.OrderPackageDO;
import com.cf.imes.module.executor.dal.dataobject.plan.PlanDO;
import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
@@ -78,6 +80,8 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.cf.imes.framework.common.util.json.JsonUtils.toJsonString;
import static com.cf.imes.framework.common.util.json.JsonUtils.zipString;
import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.getUserOrganId;
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.*;
@@ -423,8 +427,16 @@ public class OrderServiceImpl implements OrderService {
List<OrderModelDO> orderModelDOs = BeanUtils.toBean(plateDetail, OrderModelDO.class);
if (orderModelDOs != null && !orderModelDOs.isEmpty()) {
// 将生产单板材的造型信息进行压缩并保存
OrderModelCompressDO orderModelCompressDO = new OrderModelCompressDO();
orderModelCompressDO.setOrderId(order.getId());
orderModelDOs.forEach(orderModelDO -> orderModelDO.setOrderId(order.getId()));
// 保存大板的分类和实际ID和未优化
saveOrderPlateModel(plateDO,goodsDO,orderModelDOs,orderModelCompressDO);
orderInputProcessor.batchSaveModel(orderModelDOs);
// 保存压缩的数据
orderInputProcessor.batchSaveCompressModel(Collections.singletonList(orderModelCompressDO));
}
if (partsRemark != null && !partsRemark.isEmpty()) {
orderInputProcessor.batchSaveOrderPartsModel(partsRemark);
@@ -497,6 +509,19 @@ public class OrderServiceImpl implements OrderService {
if (plateDetail != null && !plateDetail.isEmpty()){
List<OrderModelDO> orderModelDOs = BeanUtils.toBean(plateDetail, OrderModelDO.class);
orderInputProcessor.batchSaveModel(orderModelDOs);
// if (!orderModelDOs.isEmpty()) {
// orderModelDOs.forEach(orderModelDO -> orderModelDO.setOrderId(orderDO.getId()));
// System.out.println("----" + orderModelDOs);
// 将生产单板材的造型信息进行压缩并保存
OrderModelCompressDO orderModelCompressDO = new OrderModelCompressDO();
orderModelCompressDO.setOrderId(orderDO.getId());
saveOrderPlateModel(plateDO,goodsDO,orderModelDOs,orderModelCompressDO);
orderInputProcessor.batchSaveModel(orderModelDOs);
// 保存压缩的数据
orderInputProcessor.batchSaveCompressModel(Collections.singletonList(orderModelCompressDO));
// }
}
if (orderPartsRemarks != null && !orderPartsRemarks.isEmpty()) {
orderInputProcessor.batchSaveOrderPartsModel(orderPartsRemarks);
@@ -1186,5 +1211,25 @@ public class OrderServiceImpl implements OrderService {
private void saveOrderPlateModel(List<PlateDO> plateDO, List<GoodsDO> goodsDO, List<OrderModelDO> orderModelDOs,OrderModelCompressDO orderModelCompressDO) {
// 将生产单板材的造型信息进行压缩并保存
String orderPlateModeList = toJsonString(BeanUtils.toBean(orderModelDOs, OrderPlateList.class));
orderModelCompressDO.setOrderModelZip(zipString(orderPlateModeList));
// 板材造型数据添加 大板分类ID,实际ID,优化信息(默认为 false)
List<OrderGoodsPlateIds> orderGoodsPlateIds = BeanUtils.toBean(plateDO, OrderGoodsPlateIds.class);
List<GoodsDO> finalGoodsDO = goodsDO;
orderGoodsPlateIds.forEach(f->
f.setActualGoodsId(finalGoodsDO.stream().filter(g->g.getId().equals(f.getGoodsId())).map(GoodsDO::getGoodsId).toList().get(0))
);
orderModelDOs.forEach(f->{
f.setGoodsId(orderGoodsPlateIds.stream().filter(fo->fo.getId().equals(f.getPlateId())).map(OrderGoodsPlateIds::getActualGoodsId).toList().get(0));
f.setPlateGoodsId(orderGoodsPlateIds.stream().filter(fo->fo.getId().equals(f.getPlateId())).map(OrderGoodsPlateIds::getGoodsId).toList().get(0));
f.setIsOptimized(false);
});
}
}