xml导入

This commit is contained in:
lym
2024-09-10 15:47:46 +08:00
parent a38c2ece52
commit b7acf4d436
41 changed files with 586 additions and 267 deletions
@@ -0,0 +1,19 @@
package com.cf.imes.module.executor.enums;
/**
* executor 字典类型的枚举类
*/
public interface DictTypeConstants {
// ========== PLATE 模块 ==========
String TYPOGRAPHY_TYPE = "typographyType"; // 排版面
String GRAIN_TYPE = "grainType";// 小板纹路类型
String DOOR_OPENING_DIRECTIONS = "doorOpeningDirections";//开门方向
String PLATE_TYPE = "order_plate_type"; // 板类型
// ========== HOLE 模块 ==========
String HOLE_FACE = "hole_face";//孔加工面
String HOLE_DIR = "hole_direction";// 孔方向
String HOLE_TYPE = "hole_type";//孔类型
}
@@ -21,6 +21,7 @@ import com.cf.imes.module.executor.util.fileConversion.admin.files.excel.ExcelRe
import com.cf.imes.module.executor.util.fileConversion.admin.files.excel.OrderPlateImportExcelVO;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.OrderXmlVO;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.XMLReadUtil;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.XmlTypeRealize;
import io.swagger.v3.oas.annotations.Parameters;
import lombok.extern.slf4j.Slf4j;
import org.springdoc.webmvc.core.RequestService;
@@ -92,7 +93,7 @@ public class OrderController {
private IdentifierGenerator identifierGenerator;
@Resource
private ThreadPoolTaskExecutor asyncExecutor;
private XmlTypeRealize xmlTypeRealize;
@PutMapping("/update")
@@ -295,6 +296,10 @@ public class OrderController {
try {
List<?> list = null;
OrderDO orderDO = new OrderDO();
OrderXmlVO orderXmlVO = null;
Map<String, Object> mapOrder = null;
String err = "";
if (type == 0) { //excel
excelReadUtil.setErr(0);
@@ -305,42 +310,51 @@ public class OrderController {
return;
} else {
list = (List<?>) map.get("plate");
if (index == null || index == 0) { // 整单导入
Map<String, Object> mapOrder = (Map<String, Object>) map.get("order");
orderDO = ((OrderDO) mapOrder.get("order")).setOrderType(OrderTypeEnum.MAIN_ORDER.getStatus());
String err = ((String) mapOrder.get("error"));
if (!orderService.customOrderNoIsExists(orderDO.getCustomOrderNo())) {
err += orderDO.getCustomOrderNo() + "-自定义生产单号已存在;";
}
if (!err.equals("")) {
ExcelWriterUtil.writeErr(response, err, orderService.getSavePath() + File.separator + "order_err.xlsx");
return;
}
if (list.size() == 0) {
orderDO.setStatus(OrderStatusEnum.EMPTY.getStatus());
} else {
orderDO.setStatus(OrderStatusEnum.NEW_ORDER.getStatus());
}
} else { // 板材导入
orderDO = orderService.getOrder(orderId);
mapOrder = (Map<String, Object>) map.get("order");
if (list.size() == 0) {
orderDO.setStatus(OrderStatusEnum.EMPTY.getStatus());
} else {
orderDO.setStatus(OrderStatusEnum.NEW_ORDER.getStatus());
}
}
} else if (type == 1) { // json
} else if (type == 2) { // xml
OrderXmlVO orderXmlVO = (OrderXmlVO) XMLReadUtil.read(file, OrderXmlVO.class);
System.out.println("orderXmlVO = " + orderXmlVO);
orderXmlVO = (OrderXmlVO) XMLReadUtil.read(file, OrderXmlVO.class);
// 数据内容正确判断
// if(){
//
// }
assert orderXmlVO != null;
mapOrder = xmlTypeRealize.changeOrder(orderXmlVO, getUserOrganId());
if (orderXmlVO.getMaterialXmlVO().getPlateXmlVOS().getPlateXmlVOList().size() == 0) {
orderDO.setStatus(OrderStatusEnum.EMPTY.getStatus());
} else {
orderDO.setStatus(OrderStatusEnum.NEW_ORDER.getStatus());
}
}
orderService.importExcelData(orderDO, list, index);
if (index == null || index == 0) { // 整单导入
assert mapOrder != null;
orderDO = (OrderDO) mapOrder.get("order");
err = ((String) mapOrder.get("error"));
orderDO.setOrderType(OrderTypeEnum.MAIN_ORDER.getStatus());
if (!orderService.customOrderNoIsExists(orderDO.getCustomOrderNo())) {
err += orderDO.getCustomOrderNo() + "-自定义生产单号已存在;";
}
if (!err.equals("")) {
ExcelWriterUtil.writeErr(response, err, orderService.getSavePath() + File.separator + "order_err.xlsx");
return;
}
} else { // 板材导入
orderDO = orderService.getOrder(orderId);
}
orderService.importExcelData(orderDO, list, index, orderXmlVO);
} catch (Exception e) {
ExcelWriterUtil.writeErr(response, "系统出现未知错误,请下载模板,按照模板重新上传文件", orderService.getSavePath() + File.separator + "order_err.xlsx");
ExcelWriterUtil.writeErr(response, "系统出现未知错误,请下载模板,按照模板重新上传文件,注意编码格式", orderService.getSavePath() + File.separator + "order_err.xlsx");
log.error("导入文件出现异常", e);
}
}
@@ -1,11 +1,10 @@
package com.cf.imes.module.executor.dal.dataobject.ordermodel;
import com.alibaba.fastjson.JSONObject;
import com.cf.imes.framework.common.util.json.JsonUtils;
import com.cf.imes.framework.es.core.dal.ESDocument;
import com.cf.imes.module.executor.util.deviseData.dataTwo.HoleDetail;
import com.cf.imes.module.executor.util.deviseData.dataTwo.ModelDetail;
import com.cf.imes.module.executor.util.deviseData.dataTwo.PointDetail;
import com.cf.imes.module.executor.util.deviseData.structure.BasePosition;
import com.cf.imes.module.executor.util.deviseData.structure.HoleDetail;
import com.cf.imes.module.executor.util.deviseData.structure.ModelDetail;
import com.cf.imes.module.executor.util.deviseData.structure.PointDetail;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
@@ -32,6 +31,11 @@ public class OrderModelDO extends ESDocument {
@Schema(description = "小板id")
private Long plateId;
@Schema(description = "柜体的基点坐标")
private BasePosition bodyBasePosition; // 板件基准点坐标
@Schema(description = "板件的基点坐标")
private BasePosition plateBasePosition; // 板件基准点坐标
@Schema(description = "纹路 纹路(0正纹1可翻转2反纹)")
private Integer texture;
@Schema(description = "排版面 排钻类型(0正面1反面2随意面)")
@@ -9,21 +9,15 @@ import com.cf.imes.module.executor.controller.admin.order.vo.order.*;
import com.cf.imes.module.executor.controller.admin.order.vo.product.OrderBodyRespVO;
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.goods.GoodsDO;
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.module.executor.dal.dataobject.orderBody.OrderBodyDO;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.OrderXmlVO;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
/**
* 生产单表 order_{N} Service 接口
@@ -113,7 +107,7 @@ public interface OrderService {
/**
* 文件数据导入
*/
void importExcelData(OrderDO orderDO, List<?> list, Integer index);
void importExcelData(OrderDO orderDO, List<?> list, Integer index, OrderXmlVO orderXmlVO);
/**
* 生产导入文件模板下载
@@ -1,7 +1,5 @@
package com.cf.imes.module.executor.service.order;
import cn.smallbun.screw.core.util.CollectionUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@@ -13,7 +11,6 @@ import com.cf.imes.framework.common.pojo.PageParam;
import com.cf.imes.framework.mybatis.core.generator.SnowFlakeGenerator;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
import com.cf.imes.framework.web.core.util.WebFrameworkUtils;
import com.cf.imes.module.executor.controller.admin.order.vo.order.*;
import com.cf.imes.module.executor.controller.admin.order.vo.product.OrderBodyRespVO;
import com.cf.imes.module.executor.controller.admin.order.vo.product.OrderRoomBodyRespVO;
@@ -43,11 +40,12 @@ import com.cf.imes.module.executor.dal.mysql.rawgoods.RawGoodsMapper;
import com.cf.imes.module.executor.enums.OrderDeletedEnum;
import com.cf.imes.module.executor.enums.OrderStatusEnum;
import com.cf.imes.framework.common.enums.OrderPackageStatusEnum;
import com.cf.imes.module.executor.util.deviseData.dataTwo.PlateDetail;
import com.cf.imes.module.executor.util.deviseData.structure.PlateDetail;
import com.cf.imes.module.executor.util.fileConversion.admin.api.webcad.ApiDataAchieve;
import com.cf.imes.module.executor.util.fileConversion.admin.api.webcad.ApiTypeRealize;
import com.cf.imes.module.executor.util.fileConversion.admin.files.excel.ExcelTypeRealize;
import org.springframework.scheduling.annotation.Async;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.OrderXmlVO;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.XmlTypeRealize;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -68,7 +66,6 @@ import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -78,8 +75,6 @@ import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.ge
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.*;
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
/**
* 生产单表 order_{N} Service 实现类
@@ -144,6 +139,9 @@ public class OrderServiceImpl implements OrderService {
public static final String ORDER_PARTS_REMARK_MODEL = "imes_order_parts_remark_model";
@Resource
private XmlTypeRealize xmlTypeRealize;
@Override
public void updateOrder(OrderSaveReqVO updateReqVO) {
// 校验存在, 生产单未删除
@@ -425,14 +423,18 @@ public class OrderServiceImpl implements OrderService {
@Override
@Transactional(rollbackFor = Exception.class)
public void importExcelData(OrderDO orderDO, List<?> list, Integer index) {
public void importExcelData(OrderDO orderDO, List<?> list, Integer index, OrderXmlVO orderXmlVO) {
if (index == null || index == 0) {
orderDO.setId((Long) snowFlakeGenerator.nextId(null));
orderMapper.insert(orderDO);
}
Map<String, List<?>> listMap = null;
if (list.size() > 0) {
Map<String, List<?>> listMap = excelTypeRealize.changeDate(list, orderDO.getId());
if (list != null && list.size() > 0) {
listMap = excelTypeRealize.changeDate(list, orderDO.getId());
} else if (orderXmlVO != null) {
listMap = xmlTypeRealize.goodsInfoChange(orderXmlVO, orderDO.getId(), getUserOrganId());
}
List<RawGoodsDO> rawGoodsDO = (List<RawGoodsDO>) listMap.get("rawGoodsDOS");
List<GoodsDO> goodsDO = (List<GoodsDO>) listMap.get("goodsDOS");
@@ -443,6 +445,7 @@ public class OrderServiceImpl implements OrderService {
List<OrderItemDO> itemDO = (List<OrderItemDO>) listMap.get("orderItemDOS");
List<OrderModelDO> orderModelDOS = (List<OrderModelDO>) listMap.get("orderModelDOS");
List<OrderPartsRemark> orderPartsRemarks = (List<OrderPartsRemark>) listMap.get("orderPartsRemarks");
List<PlateDetail> plateDetail = (List<PlateDetail>) listMap.get("plateDetail");
// 板材库匹配
Map<String, List<?>> map = getPlateGoods(goodsDO);// 检验商品板材信息是否存在 excel
goodsDO = (List<GoodsDO>) map.get("goodsDO");
@@ -465,13 +468,20 @@ public class OrderServiceImpl implements OrderService {
}
}
orderInputProcessor.batchInsert(rawGoodsDO, bodyDO, groupDO, partsDO, plateDO, itemDO, goodsDO, plateGoodDOS);
if (orderModelDOS.size() > 0) {
if (orderModelDOS != null && orderModelDOS.size() > 0) {
orderInputProcessor.batchSaveModel(orderModelDOS);
}
if (orderPartsRemarks.size() > 0) {
if (plateDetail != null){
List<OrderModelDO> orderModelDOs = BeanUtils.toBean(plateDetail, OrderModelDO.class);
if (orderModelDOs.size() > 0) {
orderModelDOs.forEach(orderModelDO -> orderModelDO.setOrderId(orderDO.getId()));
orderInputProcessor.batchSaveModel(orderModelDOs);
}
}
if (orderPartsRemarks != null && orderPartsRemarks.size() > 0) {
orderInputProcessor.batchSaveOrderPartsModel(orderPartsRemarks);
}
}
}
@Override
@@ -1,4 +1,4 @@
package com.cf.imes.module.executor.util.deviseData.dataTwo;
package com.cf.imes.module.executor.util.deviseData.structure;
import lombok.AllArgsConstructor;
import lombok.Builder;
@@ -21,4 +21,10 @@ public class BasePosition {
private String basePointZ;// 基准点Z坐标
private String axisXrotate;// 绕X轴旋转角度
private String axisYrotate;// 绕Y轴旋转角度
private String axisZrotate;// 绕Z轴旋转角度
}
@@ -1,4 +1,4 @@
package com.cf.imes.module.executor.util.deviseData.dataTwo;
package com.cf.imes.module.executor.util.deviseData.structure;
import lombok.AllArgsConstructor;
import lombok.Builder;
@@ -1,4 +1,4 @@
package com.cf.imes.module.executor.util.deviseData.dataTwo;
package com.cf.imes.module.executor.util.deviseData.structure;
import lombok.AllArgsConstructor;
import lombok.Builder;
@@ -1,4 +1,4 @@
package com.cf.imes.module.executor.util.deviseData.dataTwo;
package com.cf.imes.module.executor.util.deviseData.structure;
import lombok.AllArgsConstructor;
import lombok.Builder;
@@ -1,4 +1,4 @@
package com.cf.imes.module.executor.util.deviseData.dataTwo;
package com.cf.imes.module.executor.util.deviseData.structure;
import lombok.AllArgsConstructor;
import lombok.Builder;
@@ -1,4 +1,4 @@
package com.cf.imes.module.executor.util.deviseData.dataTwo;
package com.cf.imes.module.executor.util.deviseData.structure;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
@@ -1,4 +1,4 @@
package com.cf.imes.module.executor.util.deviseData.dataTwo;
package com.cf.imes.module.executor.util.deviseData.structure;
import com.cf.imes.module.executor.controller.admin.plan.dto.Point;
import io.swagger.v3.oas.annotations.media.Schema;
@@ -1,4 +1,4 @@
package com.cf.imes.module.executor.util.deviseData.dataTwo;
package com.cf.imes.module.executor.util.deviseData.structure;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
@@ -1,11 +1,10 @@
package com.cf.imes.module.executor.util.deviseData.dataTwo;
package 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 lombok.experimental.Accessors;
import java.util.List;
@@ -1,4 +1,4 @@
package com.cf.imes.module.executor.util.deviseData.dataTwo;
package com.cf.imes.module.executor.util.deviseData.structure;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
@@ -1,4 +1,4 @@
package com.cf.imes.module.executor.util.deviseData.dataTwo;
package com.cf.imes.module.executor.util.deviseData.structure;
import lombok.AllArgsConstructor;
import lombok.Builder;
@@ -1,7 +1,5 @@
package com.cf.imes.module.executor.util.deviseData.dataTwo;
package com.cf.imes.module.executor.util.deviseData.structure;
import com.alibaba.fastjson.JSONObject;
import com.cf.imes.framework.es.core.dal.ESDocument;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -90,7 +88,8 @@ public class PlateDetail{
private Boolean has3DModel; // 是否有三维刀路
// 轮廓数据造型数据
private BasePosition bodyBasePosition; // 柜体基准点坐标
private BasePosition plateBasePosition; // 板件基准点坐标
private List<PointDetail> pointDetail ; //点明细表示小板外围轮廓的几个转折点不含封边
private List<PointDetail> rawPointDetail ; //原始点明细含封边
@@ -1,4 +1,4 @@
package com.cf.imes.module.executor.util.deviseData.dataTwo;
package com.cf.imes.module.executor.util.deviseData.structure;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
@@ -1,4 +1,4 @@
package com.cf.imes.module.executor.util.deviseData.dataTwo;
package com.cf.imes.module.executor.util.deviseData.structure;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
@@ -1,6 +1,5 @@
package com.cf.imes.module.executor.util.fileConversion.admin.api.webcad;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
@@ -15,7 +14,7 @@ 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.enums.*;
import com.cf.imes.module.executor.util.fileConversion.admin.SnowflakeIdWorker3rd;
import com.cf.imes.module.executor.util.deviseData.dataTwo.*;
import com.cf.imes.module.executor.util.deviseData.structure.*;
import com.cf.imes.module.system.api.dict.DictDataApi;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@@ -24,7 +23,6 @@ import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@@ -560,7 +558,7 @@ public class ApiTypeRealize {
JSONObject plate = plateLists.getJSONObject(i);
Integer type = Integer.valueOf(dictDataApi.parseDictData("order_plate_type",
Integer type = Integer.valueOf(dictDataApi.parseDictData(DictTypeConstants.PLATE_TYPE,
plate.getString("BoardType"))
.getData().getValue());
Long plateId = (Long) identifierGenerator.nextId(null);
@@ -7,10 +7,11 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.nacos.common.utils.StringUtils;
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
import com.cf.imes.module.executor.enums.DataTypeEnum;
import com.cf.imes.module.executor.util.fileConversion.admin.ToolUtil;
import com.cf.imes.module.system.api.dict.DictDataApi;
import com.cf.imes.module.system.api.dict.dto.DictDataRespDTO;
import com.cf.imes.module.system.enums.DictTypeConstants;
import com.cf.imes.module.executor.enums.DictTypeConstants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
@@ -111,7 +112,7 @@ public class ExcelReadUtil { // 文件读取
}
OrderDO orderDO = OrderDO.builder()
.organId(OrganContextHolder.getOrganId())
.dataType(0)
.dataType(DataTypeEnum.FILE_IMPORT.getStatus())
.orderDate(LocalDateTime.now())
.customer((String) orderMap.get("客户")) //
.customOrderNo((String) orderMap.get("自定义单号"))
@@ -19,8 +19,7 @@ import com.cf.imes.module.executor.enums.OrderItemTypeEnum;
import com.cf.imes.module.executor.util.fileConversion.admin.SnowflakeIdWorker3rd;
import com.cf.imes.module.system.api.dict.DictDataApi;
import com.cf.imes.module.system.api.dict.dto.DictDataRespDTO;
import com.cf.imes.module.system.enums.DictTypeConstants;
import io.swagger.v3.oas.models.security.SecurityScheme;
import com.cf.imes.module.executor.enums.DictTypeConstants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@@ -4,10 +4,7 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.*;
import java.io.Serializable;
@Data
@@ -74,6 +71,10 @@ public class AssemblyXmlVO implements Serializable {
@XmlAttribute(name = "unit")
private String unit;
// 数量单位
@XmlAttribute(name = "unitCount")
private String unitCount;
// 仓库
@XmlAttribute(name = "warehouse")
private String warehouse;
@@ -97,4 +98,12 @@ public class AssemblyXmlVO implements Serializable {
// 模块ID
@XmlAttribute(name = "moduleId")
private String moduleId;
// 父ID
@XmlAttribute(name = "parentId")
private String parentId;
// 备注
@XmlElement(name = "Remarks")
private RemarkXmlVOS remarkXmlVOS;
}
@@ -127,6 +127,30 @@ public class BlockXmlVO implements Serializable {
@XmlAttribute(name = "moduleId")
private String moduleId;
// 基点X坐标
@XmlAttribute(name = "basePointX")
private String basePointX;
// 基点Y坐标
@XmlAttribute(name = "basePointY")
private String basePointY;
// 基点Z坐标
@XmlAttribute(name = "basePointZ")
private String basePointZ;
// 绕X轴旋转角度
@XmlAttribute(name = "axisXrotate")
private String axisXrotate;
// 绕Y轴旋转角度
@XmlAttribute(name = "axisYrotate")
private String axisYrotate;
// 绕Z轴旋转角度
@XmlAttribute(name = "axisZrotate")
private String axisZrotate;
// 成品(设计成型/已封边/贴皮或涂装的板件)轮廓信息
@XmlElement(name = "Outline")
private OutlineXmlVO outlineXmlVO ;
@@ -41,4 +41,28 @@ public class BoxXmlVO implements Serializable {
@XmlAttribute(name = "length")
private String length;
// 基点X坐标
@XmlAttribute(name = "basePointX")
private String basePointX;
// 基点Y坐标
@XmlAttribute(name = "basePointY")
private String basePointY;
// 基点Z坐标
@XmlAttribute(name = "basePointZ")
private String basePointZ;
// 绕X轴旋转角度
@XmlAttribute(name = "axisXrotate")
private String axisXrotate;
// 绕Y轴旋转角度
@XmlAttribute(name = "axisYrotate")
private String axisYrotate;
// 绕Z轴旋转角度
@XmlAttribute(name = "axisZrotate")
private String axisZrotate;
}
@@ -4,10 +4,7 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.*;
import java.io.Serializable;
@Data
@@ -78,6 +75,10 @@ public class EdgingXmlVO implements Serializable {
@XmlAttribute(name = "count")
private String count;
// 数量单位(默认m米)
@XmlAttribute(name = "unitCount")
private String unitCount;
// 房间ID
@XmlAttribute(name = "roomId")
private String roomId;
@@ -93,4 +94,12 @@ public class EdgingXmlVO implements Serializable {
// 模块ID
@XmlAttribute(name = "moduleId")
private String moduleId;
// 父ID
@XmlAttribute(name = "parentId")
private String parentId;
// 备注
@XmlElement(name = "Remarks")
private RemarkXmlVOS remarkXmlVOS;
}
@@ -13,7 +13,7 @@ import java.io.Serializable;
@Data
@AllArgsConstructor
@NoArgsConstructor
@XmlRootElement(name = "Box")
@XmlRootElement(name = "Group")
@XmlAccessorType(XmlAccessType.FIELD)
public class GroupXmlVO implements Serializable {
@@ -41,7 +41,4 @@ public class GroupXmlVO implements Serializable {
@XmlAttribute(name = "length")
private String length;
// 加工组数量
@XmlAttribute(name = "count")
private String count;
}
@@ -21,6 +21,6 @@ public class GroupXmlVOS implements Serializable {
private String count;
// 房间
@XmlElement(name = "Room")
@XmlElement(name = "Group")
private List<GroupXmlVO> groupXmlVOList;
}
@@ -4,10 +4,7 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.*;
import java.io.Serializable;
@Data
@@ -74,6 +71,10 @@ public class HardwareXmlVO implements Serializable {
@XmlAttribute(name = "unit")
private String unit;
// 数量单位
@XmlAttribute(name = "unitCount")
private String unitCount;
// 仓库
@XmlAttribute(name = "warehouse")
private String warehouse;
@@ -98,4 +99,11 @@ public class HardwareXmlVO implements Serializable {
@XmlAttribute(name = "moduleId")
private String moduleId;
// 父ID
@XmlAttribute(name = "parentId")
private String parentId;
// 备注
@XmlElement(name = "Remarks")
private RemarkXmlVOS remarkXmlVOS;
}
@@ -30,7 +30,7 @@ public class HoleXmlVO implements Serializable {
@XmlAttribute(name = "face")
private String face;
// 方向——向后Z-、向前Z+、向右X+、向左X-、向下Y-、向上Y+、斜O
// 方向——向后Z-、向前Z+、向右X+、向左X-、向下Y-、向上Y+、斜O 孔加工面
@XmlAttribute(name = "direction")
private String direction;
@@ -14,32 +14,28 @@ import java.io.Serializable;
@XmlAccessorType(XmlAccessType.FIELD)
public class ModuleXmlVO implements Serializable {
// 房间ID
// 模块ID
@XmlAttribute(name = "id")
private String id;
// 房间名称
// 模块名称
@XmlAttribute(name = "name")
private String name;
// 房间编号
// 模块编号
@XmlAttribute(name = "code")
private String code;
// 房间高度
// 模块高度
@XmlAttribute(name = "height")
private String height;
// 房间宽度
// 模块宽度
@XmlAttribute(name = "width")
private String width;
// 房间长度
// 模块长度
@XmlAttribute(name = "length")
private String length;
// 房间数量
@XmlAttribute(name = "count")
private String count;
}
@@ -20,6 +20,6 @@ public class ModuleXmlVOS implements Serializable {
private String count;
// 房间
@XmlElement(name = "Room")
@XmlElement(name = "Module")
private List<ModuleXmlVO> moduleXmlVOList;
}
@@ -1,6 +1,8 @@
package com.cf.imes.module.executor.util.fileConversion.admin.files.xml;
import com.alibaba.fastjson.JSON;
import com.cf.imes.module.executor.util.fileConversion.admin.ToolUtil;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
@@ -11,6 +13,9 @@ import java.nio.charset.StandardCharsets;
@Slf4j
@Component
public class XMLReadUtil {
final String TYPE_ERR = "数据类型错误";
public static Object read(MultipartFile file, Class<?> clazz) throws IOException {
@@ -33,7 +38,6 @@ public class XMLReadUtil {
// XML转为JAVA对象
Object odfBody = XmlBuilder.xmlStrToOject(clazz, builder.toString());
System.out.println(" odfBody " + JSON.toJSONString(odfBody));
return odfBody;
} catch (IOException e) {
@@ -44,4 +48,82 @@ public class XMLReadUtil {
return null;
}
// 数据格式转换
public Boolean checkVO(OrderXmlVO orderXmlVO) {
Boolean flag = true;
RoomXmlVOS roomXmlVOS = orderXmlVO.getRoomXmlVOS();
if ( roomXmlVOS != null ) {
for ( RoomXmlVO room : roomXmlVOS.getRoomXmlVOList() ) {
if (room != null){
if (!ToolUtil.convertToType(room.getHeight(), Double.class)){
room.setHeight(room.getHeight() + "-" + TYPE_ERR);
}
if (!ToolUtil.convertToType(room.getLength(), Double.class)){
room.setLength(room.getLength() + "-" + TYPE_ERR);
}
if (!ToolUtil.convertToType(room.getWidth(), Double.class)){
room.setWidth(room.getWidth() + "-" + TYPE_ERR);
}
if (!ToolUtil.convertToType(room.getCount(), Integer.class)){
room.setCount(room.getCount() + "-" + TYPE_ERR);
}
if (room.getBoxXmlVOList() != null){
for (BoxXmlVO box : room.getBoxXmlVOList()) {
if (box != null){
if (!ToolUtil.convertToType(box.getHeight(), Double.class)){
box.setHeight(box.getHeight() + "-" + TYPE_ERR);
}
if (!ToolUtil.convertToType(box.getLength(), Double.class)){
box.setLength(box.getLength() + "-" + TYPE_ERR);
}
if (!ToolUtil.convertToType(box.getWidth(), Double.class)){
box.setWidth(box.getWidth() + "-" + TYPE_ERR);
}
}
}
}
}
}
}
ModuleXmlVOS moduleXmlVOS = orderXmlVO.getModuleXmlVOS();
if ( moduleXmlVOS != null ) {
for ( ModuleXmlVO module : moduleXmlVOS.getModuleXmlVOList() ) {
if (module != null){
if (!ToolUtil.convertToType(module.getHeight(), Double.class)){
module.setHeight(module.getHeight() + "-" + TYPE_ERR);
}
if (!ToolUtil.convertToType(module.getLength(), Double.class)){
module.setLength(module.getLength() + "-" + TYPE_ERR);
}
if (!ToolUtil.convertToType(module.getWidth(), Double.class)){
module.setWidth(module.getWidth() + "-" + TYPE_ERR);
}
}
}
}
GroupXmlVOS grooveXmlVOS = orderXmlVO.getGroupXmlVOS();
if ( grooveXmlVOS != null ) {
for ( GroupXmlVO groove : grooveXmlVOS.getGroupXmlVOList() ) {
if (groove != null){
if (!ToolUtil.convertToType(groove.getHeight(), Double.class)){
groove.setHeight(groove.getHeight() + "-" + TYPE_ERR);
}
if (!ToolUtil.convertToType(groove.getLength(), Double.class)){
groove.setLength(groove.getLength() + "-"+ TYPE_ERR);
}
if (!ToolUtil.convertToType(groove.getWidth(), Double.class)){
groove.setWidth(groove.getWidth() + "-" + TYPE_ERR);
}
}
}
}
return flag;
}
}
@@ -3,7 +3,7 @@ package com.cf.imes.module.executor.util.fileConversion.admin.files.xml;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import com.cf.imes.framework.mybatis.core.generator.SnowFlakeGenerator;
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
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;
@@ -12,27 +12,28 @@ 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.plate.PlateDO;
import com.cf.imes.module.executor.dal.dataobject.rawgoods.RawGoodsDO;
import com.cf.imes.module.executor.util.deviseData.dataTwo.*;
import com.cf.imes.module.executor.enums.DataTypeEnum;
import com.cf.imes.module.executor.util.deviseData.structure.*;
import com.cf.imes.module.executor.util.fileConversion.admin.SnowflakeIdWorker3rd;
import com.cf.imes.module.executor.util.fileConversion.admin.ToolUtil;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.*;
import com.cf.imes.module.system.api.dict.DictDataApi;
import com.cf.imes.module.system.api.dict.dto.DictDataRespDTO;
import com.cf.imes.module.executor.enums.DictTypeConstants;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.cf.imes.module.system.enums.DictTypeConstants.*;
/**
* 实现数据格式转换
@@ -42,9 +43,6 @@ import static com.cf.imes.module.system.enums.DictTypeConstants.*;
@Component
public class XmlTypeRealize {
@Resource
private SnowFlakeGenerator snowFlakeGenerator;
@Resource
SnowflakeIdWorker3rd idWorker;
@@ -53,10 +51,6 @@ public class XmlTypeRealize {
final String NOT_ASSIGNED = "未命名";
final String NOT_ROOM = "无房间";
final String NOT_BODY = "无柜体";
@Resource
private IdentifierGenerator identifierGenerator;
@@ -72,7 +66,7 @@ public class XmlTypeRealize {
}
// 生产单转换
public Map<String, Object> changeOrder(OrderXmlVO orderXmlVO, Long orderId, Long organId) {
public Map<String, Object> changeOrder(OrderXmlVO orderXmlVO, Long organId) {
Map<String, Object> map = new HashMap<>();
String error = "";
@@ -98,15 +92,14 @@ public class XmlTypeRealize {
}
}
OrderDO orderDO = OrderDO.builder()
.id(orderId)
.organId(organId)
.dataType(0)
.customer(orderXmlVO.getCustomer()) //
.dataType(DataTypeEnum.FILE_IMPORT.getStatus())
.customer(orderXmlVO.getCustomer())
.customOrderNo(orderXmlVO.getCustomOrderNo())
.dealer(orderXmlVO.getDealer()) //
.dealer(orderXmlVO.getDealer())
.dealerPhoneNumber(orderXmlVO.getDealerPhone())
.address(orderXmlVO.getCustomerAddress()) //
.phoneNumber(orderXmlVO.getCustomerPhone()) //
.address(orderXmlVO.getCustomerAddress())
.phoneNumber(orderXmlVO.getCustomerPhone())
.salesman(orderXmlVO.getSeller())
.splitter(orderXmlVO.getAnalyst())
.remark(orderXmlVO.getMemo())
@@ -143,11 +136,12 @@ public class XmlTypeRealize {
Map<String, Map<String, OrderBodyDO>> roomInfos = new HashMap<>();
if (roomXmlVOS != null && roomXmlVOS.getRoomXmlVOList() != null && roomXmlVOS.getRoomXmlVOList().size() > 0) {
Map<String, OrderBodyDO> bodyInfos = new HashMap<>();
for (RoomXmlVO roomXmlVO : roomXmlVOS.getRoomXmlVOList()) {
Map<String, OrderBodyDO> bodyInfos = new HashMap<>();
Long roomId = Long.valueOf(roomXmlVO.getId());
for (BoxXmlVO boxXmlVO : roomXmlVO.getBoxXmlVOList()) {
bodyInfos.put(boxXmlVO.getId(), OrderBodyDO.builder()
OrderBodyDO orderBodyDO = OrderBodyDO.builder()
.id((Long) identifierGenerator.nextId(null))
.organId(organId)
.orderId(orderId)
@@ -157,7 +151,10 @@ public class XmlTypeRealize {
.width(Double.parseDouble(boxXmlVO.getWidth()))
.height(Double.parseDouble(boxXmlVO.getHeight()))
.depth(Double.parseDouble(boxXmlVO.getLength()))
.build());
.plateNum(0)
.unregularNum(0)
.build();
bodyInfos.put(boxXmlVO.getId(), orderBodyDO);
}
roomInfos.put(roomXmlVO.getId(), bodyInfos);
}
@@ -165,44 +162,75 @@ public class XmlTypeRealize {
return roomInfos;
}
// 柜体基点坐标转换
public Map<String, Map<String, BasePosition>> basePositionChange(RoomXmlVOS roomXmlVOS) {
Map<String, Map<String, BasePosition>> roomInfos = new HashMap<>();
if (roomXmlVOS != null && roomXmlVOS.getRoomXmlVOList() != null && roomXmlVOS.getRoomXmlVOList().size() > 0) {
Map<String, BasePosition> basePositions = new HashMap<>();
for (RoomXmlVO roomXmlVO : roomXmlVOS.getRoomXmlVOList()) {
for (BoxXmlVO boxXmlVO : roomXmlVO.getBoxXmlVOList()) {
BasePosition basePosition = BasePosition.builder()
.basePointX(boxXmlVO.getBasePointX())
.basePointY(boxXmlVO.getBasePointY())
.basePointZ(boxXmlVO.getBasePointZ())
.axisXrotate(boxXmlVO.getAxisXrotate())
.axisYrotate(boxXmlVO.getAxisYrotate())
.axisZrotate(boxXmlVO.getAxisZrotate())
.build();
basePositions.put(boxXmlVO.getId(), basePosition);
}
roomInfos.put(roomXmlVO.getId(), basePositions);
}
}
return roomInfos;
}
// 加工组信息转换
public Map<String, OrderGroupDO> groupInfoChange(GroupXmlVOS groupXmlVOS, Long orderId, Long organId) {
Map<String, OrderGroupDO> groupInfos = new HashMap<>();
if (groupXmlVOS != null && groupXmlVOS.getGroupXmlVOList() != null && groupXmlVOS.getGroupXmlVOList().size() > 0) {
for (GroupXmlVO groupXmlVO : groupXmlVOS.getGroupXmlVOList()) {
groupInfos.put(groupXmlVO.getId(), OrderGroupDO.builder()
OrderGroupDO groupDO = OrderGroupDO.builder()
.id((Long) identifierGenerator.nextId(null))
.organId(organId)
.orderId(orderId)
.bodyId(0L)
.groupTypeId(0L)
.name(groupXmlVO.getName())
.height(Double.parseDouble(groupXmlVO.getHeight()))
.width(Double.parseDouble(groupXmlVO.getWidth()))
.depth(Double.parseDouble(groupXmlVO.getLength()))
.build());
.plateNum(0)
.unregularNum(0)
.build();
groupInfos.put(groupXmlVO.getId(), groupDO);
}
}
return groupInfos;
}
// 板材信息转换
public Map<String, List<Object>> goodsInfoChange(OrderXmlVO orderXmlVO, Long orderId, Long organId) {
Map<String, List<Object>> map = new HashMap<>();
public Map<String, List<?>> goodsInfoChange(OrderXmlVO orderXmlVO, Long orderId, Long organId) {
Map<String, List<?>> map = new HashMap<>();
List<RawGoodsDO> rawGoodsDOs = new ArrayList<>();
List<GoodsDO> goodsDOs = new ArrayList<>();
List<OrderBodyDO> bodyBOs = new ArrayList<>();
List<OrderGroupDO> groupDOs = new ArrayList<>();
List<PlateDO> plateDOs = new ArrayList<>();
List<OrderItemDO> itemDOs = new ArrayList<>();
List<OrderPartsDO> partsDOs = new ArrayList<>();
Map<String, OrderGroupDO> groupInfos = groupInfoChange(orderXmlVO.getGroupXmlVOS(), orderId, organId); // 加工组
Map<String, Object> itemInfos = new HashMap<>();
Map<String, Object> partsInfos = new HashMap<>();
List<Object> rawGoodsDOs = new ArrayList<>();
List<Object> goodsDOs = new ArrayList<>();
List<Object> plateDOs = new ArrayList<>();
List<Object> plateDetail = null;
// 房间柜体
Map<String, Map<String, OrderBodyDO>> roomInfos = bodyInfoChange(orderXmlVO.getRoomXmlVOS(), orderId, organId);
Map<String, Map<String, OrderBodyDO>> roomInfos = bodyInfoChange(orderXmlVO.getRoomXmlVOS(), orderId, organId); // roomInfos 这个在跟着一起变
// 房间柜体基点
Map<String, Map<String, BasePosition>> boxBasePositions = basePositionChange(orderXmlVO.getRoomXmlVOS());
// 加工组
Map<String, OrderGroupDO> groupInfos = groupInfoChange(orderXmlVO.getGroupXmlVOS(), orderId, organId); // groupInfos 这个在跟着一起变
Map<String, Object> itemInfos = new HashMap<>();
Map<String, Object> partsInfos = new HashMap<>();
Map<String, Object> orderPartsRemarks = new HashMap<>();
Map<String, Object> partsDOInfos = new HashMap<>();
if (orderXmlVO.getMaterialXmlVO() != null ){
MaterialXmlVO materialXmlVO = orderXmlVO.getMaterialXmlVO();
@@ -214,6 +242,8 @@ public class XmlTypeRealize {
Map<String, Map<String, Object>> partAllInfo = goodsInfoChange(accessoryXmlVO, assemblieXmlVOS, orderId, organId, roomInfos, groupInfos);
itemInfos.putAll(partAllInfo.get("orderItemMap"));
partsInfos.putAll(partAllInfo.get("orderPartsMap"));
orderPartsRemarks.putAll(partAllInfo.get("orderPartsRemarks"));
partsDOInfos.putAll(partAllInfo.get("orderPartsDOMap"));
// 板材 小板
if (plateXmlVOS.getPlateXmlVOList() != null && plateXmlVOS.getPlateXmlVOList().size() > 0) {
@@ -256,25 +286,52 @@ public class XmlTypeRealize {
goodsDOs.add(goodsDO);
// 小板信息
plateInfoChange(plateXmlVO.getBlockXmlVOS(), orderId, goodsDO.getId(), organId, roomInfos, groupInfos, partsInfos, itemInfos, plateDOs);
plateDetail = plateInfoChange(plateXmlVO.getBlockXmlVOS(), orderId, goodsDO.getId(), organId, roomInfos, groupInfos, partsInfos, itemInfos, plateDOs, boxBasePositions);
}
}
}
}
// 取map中的值
System.out.println(" roomInfos " + roomInfos);
List<Object> orderBodyDOList = roomInfos.values().stream()
.flatMap(innerMap -> innerMap.values().stream())
.collect(Collectors.toList());
List<Object> groupDOList = new ArrayList<>(groupInfos.values());
List<Object> itemDOList = new ArrayList<>(itemInfos.values());
List<Object> partDOList = new ArrayList<>(partsDOInfos.values());
List<Object> partRemarks = new ArrayList<>(orderPartsRemarks.values());
map.put("rawGoodsDOS", rawGoodsDOs);
map.put("goodsDOS", goodsDOs);
map.put("orderBodyDOS", orderBodyDOList);
map.put("orderGroupDOS", groupDOList);
map.put("plateDOS", plateDOs);
map.put("orderPartsDOS", partDOList);
map.put("orderItemDOS", itemDOList);
map.put("plateDetail", plateDetail);
map.put("orderPartsRemarks", partRemarks);
return map;
}
// id得到
private Map<String,Long> getId(String roomNo, String BoxNo, Map<String, Map<String, OrderBodyDO>> roomInfos,
String groupNo, Map<String, OrderGroupDO> groupInfos,
Long orderId, Long organId) {
String groupNo, Map<String, OrderGroupDO> groupInfos, Double plateNum,
Double unregularNum, Long orderId, Long organId) {
Map<String,Long> map = new HashMap<>();
Map<String, OrderBodyDO> bodyMap = roomInfos.get(roomNo);
OrderBodyDO bodyDO;
if (bodyMap.containsKey(BoxNo)) {
bodyDO = (OrderBodyDO) bodyMap.get(BoxNo);
if (bodyMap == null){
bodyMap = new HashMap<>();
roomInfos.put(roomNo, bodyMap);
}
if ( bodyMap.containsKey(BoxNo)) {
bodyDO = bodyMap.get(BoxNo);
bodyDO.setPlateNum((int) (bodyDO.getPlateNum() + plateNum + unregularNum))
.setUnregularNum((int) (bodyDO.getUnregularNum() + unregularNum));
} else {
Long roomId = (Long) identifierGenerator.nextId(null);
bodyDO = OrderBodyDO.builder()
@@ -287,9 +344,10 @@ public class XmlTypeRealize {
.width(0.0)
.height(0.0)
.depth(0.0)
.plateNum((int) Math.round(plateNum))
.unregularNum((int) Math.round(unregularNum))
.build();
bodyMap.put(NOT_ASSIGNED, bodyDO);
roomInfos.put(NOT_ASSIGNED, bodyMap);
bodyMap.put(BoxNo, bodyDO);
}
Long roomId = bodyDO.getRoomId();
@@ -299,6 +357,8 @@ public class XmlTypeRealize {
Long groupId = 0L;
if (orderGroupDO != null) {
groupId = orderGroupDO.getId();
orderGroupDO.setBodyId(bodyId).setPlateNum((int) (orderGroupDO.getPlateNum() + plateNum))
.setUnregularNum((int) (orderGroupDO.getUnregularNum() + unregularNum));
}
map.put("roomId", roomId);
map.put("bodyId", bodyId);
@@ -311,13 +371,15 @@ public class XmlTypeRealize {
Map<String, Map<String, Object>> map = new HashMap<>();
Map<String, Object> orderPartsMap = new HashMap<>();
Map<String, Object> orderItemMap = new HashMap<>();
Map<String, Object> orderPartsDOMap = new HashMap<>();
Map<String, Object> orderPartsRemarks = new HashMap<>();
if (accessoryXmlVO != null) {
if (accessoryXmlVO.getEdgingXmlVOS() != null && accessoryXmlVO.getEdgingXmlVOS().getEdgingXmlVOList() != null && accessoryXmlVO.getEdgingXmlVOS().getEdgingXmlVOList().size() > 0) {
EdgingXmlVOS edgingXmlVOS = accessoryXmlVO.getEdgingXmlVOS();
for (EdgingXmlVO edgingXmlVO : edgingXmlVOS.getEdgingXmlVOList()) {
Map<String,Long> idMap = getId(edgingXmlVO.getRoomId(), edgingXmlVO.getBoxId(), roomInfos, edgingXmlVO.getGroupId(), groupInfos, orderId, organId);
Map<String,Long> idMap = getId(edgingXmlVO.getRoomId(), edgingXmlVO.getBoxId(), roomInfos, edgingXmlVO.getGroupId(), groupInfos, 0.0, 0.0, orderId, organId);
Long partsId = (Long) identifierGenerator.nextId(null);
orderPartsMap.put(edgingXmlVO.getId(), OrderPartsAddVO.builder()
@@ -352,13 +414,33 @@ public class XmlTypeRealize {
.bodyId(idMap.get("bodyId"))
.num(Double.valueOf(edgingXmlVO.getCount()))
.build());
orderPartsDOMap.put(edgingXmlVO.getId(), OrderPartsDO.builder()
.id(partsId)
.organId(organId)
.orderId(orderId)
.name(edgingXmlVO.getName())
.material(edgingXmlVO.getMaterial())
.type("封边条")
.brand(edgingXmlVO.getBrand())
.spec(edgingXmlVO.getSpecs())
.unit(edgingXmlVO.getUnit())
.isComposite(false)
.build());
if (edgingXmlVO.getRemarkXmlVOS() != null && edgingXmlVO.getRemarkXmlVOS().getRemarkXmlVOList() != null && edgingXmlVO.getRemarkXmlVOS().getRemarkXmlVOList().size() > 0) {
orderPartsRemarks.put(edgingXmlVO.getId(), OrderPartsRemark.builder()
.partsId(partsId)
.orderId(orderId)
.remark(edgingXmlVO.getRemarkXmlVOS().toString())
.build());
}
}
}
if (accessoryXmlVO.getHardwareXmlVOS() != null && accessoryXmlVO.getHardwareXmlVOS().getHardwareXmlVOList() != null && accessoryXmlVO.getHardwareXmlVOS().getHardwareXmlVOList().size() > 0) {
HardwareXmlVOS hardwareXmlVOS = accessoryXmlVO.getHardwareXmlVOS();
for (HardwareXmlVO hardwareXmlVO : hardwareXmlVOS.getHardwareXmlVOList()) {
Map<String,Long> idMap = getId(hardwareXmlVO.getRoomId(), hardwareXmlVO.getBoxId(), roomInfos, hardwareXmlVO.getGroupId(), groupInfos, orderId, organId);
Map<String,Long> idMap = getId(hardwareXmlVO.getRoomId(), hardwareXmlVO.getBoxId(), roomInfos, hardwareXmlVO.getGroupId(), groupInfos, 0.0, 0.0,orderId, organId);
Long partsId = (Long) identifierGenerator.nextId(null);
orderPartsMap.put(hardwareXmlVO.getId(), OrderPartsAddVO.builder()
@@ -395,6 +477,25 @@ public class XmlTypeRealize {
.bodyId(idMap.get("bodyId"))
.num(Double.valueOf(hardwareXmlVO.getCount()))
.build());
orderPartsDOMap.put(hardwareXmlVO.getId(), OrderPartsDO.builder()
.id(partsId)
.organId(organId)
.orderId(orderId)
.name(hardwareXmlVO.getName())
.material(hardwareXmlVO.getMaterial())
.type(hardwareXmlVO.getType())
.brand(hardwareXmlVO.getBrand())
.spec(hardwareXmlVO.getSpecs())
.unit(hardwareXmlVO.getUnit())
.isComposite(false)
.build());
if (hardwareXmlVO.getRemarkXmlVOS() != null && hardwareXmlVO.getRemarkXmlVOS().getRemarkXmlVOList() != null && hardwareXmlVO.getRemarkXmlVOS().getRemarkXmlVOList().size() > 0) {
orderPartsRemarks.put(hardwareXmlVO.getId(), OrderPartsRemark.builder()
.partsId(partsId)
.orderId(orderId)
.remark(hardwareXmlVO.getRemarkXmlVOS().toString())
.build());
}
}
}
}
@@ -402,73 +503,101 @@ public class XmlTypeRealize {
if (assemblieXmlVOS != null && assemblieXmlVOS.getAssemblyXmlVOList() != null && assemblieXmlVOS.getAssemblyXmlVOList().size() > 0) {
for (AssemblyXmlVO assemblyXmlVO : assemblieXmlVOS.getAssemblyXmlVOList()) {
Map<String,Long> idMap = getId(assemblyXmlVO.getRoomId(), assemblyXmlVO.getBoxId(), roomInfos, assemblyXmlVO.getGroupId(), groupInfos, orderId, organId);
if (assemblyXmlVO != null && assemblyXmlVO.toString().length() > 0) {
Map<String,Long> idMap = getId(assemblyXmlVO.getRoomId(), assemblyXmlVO.getBoxId(), roomInfos, assemblyXmlVO.getGroupId(), groupInfos, 0.0, 0.0, orderId, organId);
Long partsId = (Long) identifierGenerator.nextId(null);
orderPartsMap.put(assemblyXmlVO.getId(), OrderPartsAddVO.builder()
.id(partsId)
.organId(organId)
.orderId(orderId)
.type(assemblyXmlVO.getType())
.goodsId(assemblyXmlVO.getItemNo())
.factory(assemblyXmlVO.getManufacturer())
.brand(assemblyXmlVO.getBrand())
.name(assemblyXmlVO.getName())
.material(assemblyXmlVO.getMaterial())
.spec(assemblyXmlVO.getSpecs())
.color(assemblyXmlVO.getColor())
.length(BigDecimal.valueOf(Double.parseDouble(assemblyXmlVO.getLength())))
.width(BigDecimal.valueOf(Double.parseDouble(assemblyXmlVO.getWidth())))
.thickness(BigDecimal.valueOf(Double.parseDouble(assemblyXmlVO.getHeight())))
.num(Double.valueOf(assemblyXmlVO.getCount()))
.unit((assemblyXmlVO.getUnit()))
.warehouse(assemblyXmlVO.getWarehouse())
.shelf(assemblyXmlVO.getShelf())
.roomId(assemblyXmlVO.getRoomId())
.bodyId(assemblyXmlVO.getBoxId())
.isComposite(true)
.build());
orderItemMap.put(assemblyXmlVO.getId(), OrderItemDO.builder()
.id((Long) identifierGenerator.nextId(null))
.organId(organId)
.orderId(orderId)
.type(2)
.partsId(partsId)
.groupId(idMap.get("groupId"))
.roomId(idMap.get("roomId"))
.bodyId(idMap.get("bodyId"))
.num(Double.valueOf(assemblyXmlVO.getCount()))
.build());
Long partsId = (Long) identifierGenerator.nextId(null);
orderPartsMap.put(assemblyXmlVO.getId(), OrderPartsAddVO.builder()
.id(partsId)
.organId(organId)
.orderId(orderId)
.type(assemblyXmlVO.getType())
.goodsId(assemblyXmlVO.getItemNo())
.factory(assemblyXmlVO.getManufacturer())
.brand(assemblyXmlVO.getBrand())
.name(assemblyXmlVO.getName())
.material(assemblyXmlVO.getMaterial())
.spec(assemblyXmlVO.getSpecs())
.color(assemblyXmlVO.getColor())
.length(BigDecimal.valueOf(Double.parseDouble(assemblyXmlVO.getLength())))
.width(BigDecimal.valueOf(Double.parseDouble(assemblyXmlVO.getWidth())))
.thickness(BigDecimal.valueOf(Double.parseDouble(assemblyXmlVO.getHeight())))
.num(Double.valueOf(assemblyXmlVO.getCount()))
.unit((assemblyXmlVO.getUnit()))
.warehouse(assemblyXmlVO.getWarehouse())
.shelf(assemblyXmlVO.getShelf())
.roomId(assemblyXmlVO.getRoomId())
.bodyId(assemblyXmlVO.getBoxId())
.isComposite(true)
.build());
orderItemMap.put(assemblyXmlVO.getId(), OrderItemDO.builder()
.id((Long) identifierGenerator.nextId(null))
.organId(organId)
.orderId(orderId)
.type(2)
.partsId(partsId)
.groupId(idMap.get("groupId"))
.roomId(idMap.get("roomId"))
.bodyId(idMap.get("bodyId"))
.num(Double.valueOf(assemblyXmlVO.getCount()))
.build());
orderPartsDOMap.put(assemblyXmlVO.getId(), OrderPartsDO.builder()
.id(partsId)
.organId(organId)
.orderId(orderId)
.name(assemblyXmlVO.getName())
.material(assemblyXmlVO.getMaterial())
.type(assemblyXmlVO.getType())
.brand(assemblyXmlVO.getBrand())
.spec(assemblyXmlVO.getSpecs())
.unit(assemblyXmlVO.getUnit())
.isComposite(true)
.build());
if (assemblyXmlVO.getRemarkXmlVOS() != null && assemblyXmlVO.getRemarkXmlVOS().getRemarkXmlVOList() != null && assemblyXmlVO.getRemarkXmlVOS().getRemarkXmlVOList().size() > 0) {
orderPartsRemarks.put(assemblyXmlVO.getId(), OrderPartsRemark.builder()
.partsId(partsId)
.orderId(orderId)
.remark(assemblyXmlVO.getRemarkXmlVOS().toString())
.build());
}
}
}
}
map.put("orderItemMap", orderItemMap);
map.put("orderPartsMap", orderPartsMap);
map.put("orderPartsDOMap", orderPartsDOMap);
map.put("orderPartsRemarks", orderPartsRemarks);
return map;
}
public List<PlateDetail> plateInfoChange(BlockXmlVOS blockXmlVOS, Long orderId, Long goodsId, Long organId,
Map<String, Map<String, OrderBodyDO>> roomInfos, Map<String, OrderGroupDO> groupInfos,
Map<String, Object> partsMap, Map<String, Object> orderItemMap, List<PlateDO> plateDOs) {
List<PlateDetail> plateDetails = new ArrayList<>();
public List<Object> plateInfoChange(BlockXmlVOS blockXmlVOS, Long orderId, Long goodsId, Long organId,
Map<String, Map<String, OrderBodyDO>> roomInfos, Map<String, OrderGroupDO> groupInfos,
Map<String, Object> partsMap, Map<String, Object> orderItemMap, List<Object> plateDOs,
Map<String, Map<String, BasePosition>> boxBasePositionMap) {
List<Object> plateDetails = new ArrayList<>();
if (blockXmlVOS != null && blockXmlVOS.getBlockXmlVOList() != null && blockXmlVOS.getBlockXmlVOList().size() > 0) {
for (BlockXmlVO blockXmlVO : blockXmlVOS.getBlockXmlVOList()) {
String roomId = blockXmlVO.getRoomId();
String bodyId = blockXmlVO.getBoxId();
String groupId = blockXmlVO.getGroupId();
long plateNo = idWorker.nextId();
long obtainingTime = idWorker.obtainingTime();
Long plateId = (Long) identifierGenerator.nextId(null);
BigDecimal area = BigDecimal.valueOf(Double.parseDouble(blockXmlVO.getWidth()) * Double.parseDouble(blockXmlVO.getLength()));
BigDecimal area = BigDecimal.valueOf((Double.parseDouble(blockXmlVO.getWidth()) / 1000) * (Double.parseDouble(blockXmlVO.getLength())) );
// 开料面积
BigDecimal sealAcreage = BigDecimal.valueOf(Double.parseDouble(blockXmlVO.getCuttingWidth()) * Double.parseDouble(blockXmlVO.getCuttingLength()));
BigDecimal sealAcreage = BigDecimal.valueOf( (Double.parseDouble(blockXmlVO.getCuttingWidth()) / 1000) * ( Double.parseDouble(blockXmlVO.getCuttingLength()) / 1000));
// 开门类型获取
Integer doorType = Integer.valueOf(dictDataApi.parseDictData(DOOR_OPEN_DIR, blockXmlVO.getOpenDirection()).getData().getValue());
Integer doorType = Integer.valueOf(dictDataApi.parseDictData(DictTypeConstants.DOOR_OPENING_DIRECTIONS, blockXmlVO.getOpenDirection()).getData().getValue());
// 板材获取
Map<String,Long> idMap = getId(blockXmlVO.getRoomId(), blockXmlVO.getBoxId(), roomInfos, blockXmlVO.getGroupId(), groupInfos, orderId, organId);
Double plateNum = 0.0;
Double unregularNum = 0.0;
if (convertToBoolean(blockXmlVO.getUnregular())){
unregularNum = 1.0;
}else {
plateNum = 1.0;
}
Map<String,Long> idMap = getId(blockXmlVO.getRoomId(), blockXmlVO.getBoxId(), roomInfos, blockXmlVO.getGroupId(), groupInfos, plateNum, unregularNum, orderId, organId);
BasePosition boxBasePoint = boxBasePositionMap.get(blockXmlVO.getRoomId()).get(blockXmlVO.getBoxId()).setBasePoint(String.valueOf(idMap.get("bodyId")));
PlateDO plateDO = PlateDO.builder()
.id(plateId)
@@ -476,7 +605,8 @@ public class XmlTypeRealize {
.orderId(orderId)
.name(blockXmlVO.getName())
.plateNo((obtainingTime) + Long.toString(plateNo).substring(2))
.type(Integer.valueOf(blockXmlVO.getType()))
.type(dictDataApi.parseDictData(DictTypeConstants.PLATE_TYPE,
blockXmlVO.getType()).getData() == null ? 2 : Integer.valueOf(dictDataApi.parseDictData(DictTypeConstants.PLATE_TYPE, blockXmlVO.getType()).getData().getValue()))
.goodsId(goodsId)
.width(BigDecimal.valueOf(Double.parseDouble(blockXmlVO.getWidth())))
.height(BigDecimal.valueOf(Double.parseDouble(blockXmlVO.getLength())))
@@ -485,8 +615,8 @@ public class XmlTypeRealize {
.splitThickness(BigDecimal.valueOf(Double.parseDouble(blockXmlVO.getThickness())))
.splitWidth(BigDecimal.valueOf(Double.parseDouble(blockXmlVO.getWidth())))
.area(area)
.texture(Integer.valueOf(blockXmlVO.getTexture()))
.holeFace(Integer.valueOf(blockXmlVO.getLayoutFace()))
.texture(Integer.valueOf(dictDataApi.parseDictData(DictTypeConstants.GRAIN_TYPE, blockXmlVO.getTexture()).getData().getValue()))
.holeFace(Integer.valueOf(dictDataApi.parseDictData(DictTypeConstants.TYPOGRAPHY_TYPE, blockXmlVO.getLayoutFace()).getData().getValue()))
.isDoor(doorType == 0)
.openDoorType(doorType)
.isSpecialShaped(convertToBoolean(blockXmlVO.getUnregular()))
@@ -504,6 +634,16 @@ public class XmlTypeRealize {
.num(1.0)
.build());
// 基点坐标获取
BasePosition plateBasePosition = BasePosition.builder()
.basePoint(blockXmlVO.getId())
.basePointX(blockXmlVO.getBasePointX())
.basePointY(blockXmlVO.getBasePointY())
.basePointZ(blockXmlVO.getBasePointZ())
.axisXrotate(blockXmlVO.getAxisXrotate())
.axisYrotate(blockXmlVO.getAxisYrotate())
.axisZrotate(blockXmlVO.getAxisZrotate())
.build();
PlateDetail plateDetail = PlateDetail.builder()
.plateId(plateId)
.plateNo(plateDO.getPlateNo())
@@ -517,9 +657,18 @@ public class XmlTypeRealize {
.plateWidth(plateDO.getWidth())
.plateLength(plateDO.getHeight())
.acreage(plateDO.getArea())
.bodyBasePosition(boxBasePoint)
.plateBasePosition(plateBasePosition)
.splitLength(BigDecimal.valueOf(Long.parseLong(blockXmlVO.getCuttingLength())))
.splitWidth(BigDecimal.valueOf(Long.parseLong(blockXmlVO.getCuttingWidth())))
.sealAcreage(sealAcreage)
.pointDetail(new ArrayList<>())
.rawPointDetail(new ArrayList<>())
.holeDetail(new ArrayList<>())
.contourDetail(new ArrayList<>())
.sideHoleDetail(new ArrayList<>())
.remark(new HashMap<>())
.sideRemark(new HashMap<>())
.isUnRegular(plateDO.getIsSpecialShaped())
.build();
// 小板、es 封边值
@@ -533,7 +682,7 @@ public class XmlTypeRealize {
// 小板备注信息
addRemark(plateDO, plateDetail, blockXmlVO);
//
plateDOs.add(plateDO);
plateDetails.add(plateDetail);
}
@@ -562,24 +711,29 @@ public class XmlTypeRealize {
BigDecimal sealRight = BigDecimal.valueOf(0);
BigDecimal sealUp = BigDecimal.valueOf(0);
BigDecimal sealDown = BigDecimal.valueOf(0);
BigDecimal size = BigDecimal.valueOf(0);
if (outlineXmlVO != null && outlineXmlVO.getPointXmlVOList() != null && outlineXmlVO.getPointXmlVOList().size() > 0) {
for (PointXmlVO pointXmlVO : outlineXmlVO.getPointXmlVOList()) {
Double x = Double.parseDouble(pointXmlVO.getPointX());
Double y = Double.parseDouble(pointXmlVO.getPointY());
OrderPartsAddVO edging = (OrderPartsAddVO) edgIng.get(pointXmlVO.getEdgingId());
if (edging != null){
size = edging.getThickness();
}
if (!plateDO.getIsSpecialShaped()) {
if (x == 0 && y == 0) {
sealDown = edging.getThickness();
sealDown = size;
}
if (x != 0 && y == 0) {
sealRight = edging.getThickness();
sealRight = size;
}
if (x != 0 && y != 0) {
sealUp = edging.getThickness();
sealUp = size;
}
if (x == 0 && y != 0) {
sealLeft = edging.getThickness();
sealLeft = size;
}
}
@@ -589,7 +743,7 @@ public class XmlTypeRealize {
.pointY(y)
.curve(Double.parseDouble(pointXmlVO.getCurvature()))
.radius(Double.parseDouble(pointXmlVO.getRadius()))
.sealSize(edging.getThickness())
.sealSize(size)
.build());
plateDetail.getSideRemark().put(pointXmlVO.getId(), pointXmlVO.getRemark());
}
@@ -601,8 +755,8 @@ public class XmlTypeRealize {
// 点明细(不含封边)
private void addPointDetail(PlateDO plateDO, PlateDetail plateDetail, CuttingOutlineXmlVO cuttingOutlineXmlVO) {
if (cuttingOutlineXmlVO != null) {
plateDO.setOffsetX(BigDecimal.valueOf(Long.parseLong(cuttingOutlineXmlVO.getReferenceOffsetX()))).
setOffsetY(BigDecimal.valueOf(Long.parseLong(cuttingOutlineXmlVO.getReferenceOffsetY())));
plateDO.setOffsetX(BigDecimal.valueOf(Double.parseDouble(cuttingOutlineXmlVO.getReferenceOffsetX()))).
setOffsetY(BigDecimal.valueOf(Double.parseDouble(cuttingOutlineXmlVO.getReferenceOffsetY())));
plateDetail.setOffsetX(plateDO.getOffsetX()).setOffsetY(plateDO.getOffsetY());
if (cuttingOutlineXmlVO.getPointXmlVOList() != null && cuttingOutlineXmlVO.getPointXmlVOList().size() > 0) {
for (PointXmlVO pointXmlVO : cuttingOutlineXmlVO.getPointXmlVOList()) {
@@ -620,7 +774,7 @@ public class XmlTypeRealize {
// 孔
private void addHole(PlateDO plateDO, PlateDetail plateDetail, HoleXmlVOS holeXmlVOS) {
if (holeXmlVOS != null) {
if (holeXmlVOS != null && holeXmlVOS.getHoleXmlVOList() != null && holeXmlVOS.getHoleXmlVOList().size() > 0) {
plateDO.setFrontHoleCount(Integer.valueOf(holeXmlVOS.getCountFaceA())).
setBackHoleCount(Integer.valueOf(holeXmlVOS.getCountFaceB())).
setSideHoleCount(Integer.valueOf(holeXmlVOS.getCountSide()));
@@ -629,18 +783,17 @@ public class XmlTypeRealize {
}
if (holeXmlVOS.getHoleXmlVOList() != null && holeXmlVOS.getHoleXmlVOList().size() > 0) {
for (HoleXmlVO holeXmlVO : holeXmlVOS.getHoleXmlVOList()) {
Integer faceType = Integer.valueOf(dictDataApi.parseDictData(HOLE_FACE, holeXmlVO.getFace()).getData().getValue());
faceType = faceType == 0 || faceType == 1 ? faceType : 2;
Integer direction = Integer.valueOf(dictDataApi.parseDictData(HOLE_DIR, holeXmlVO.getDirection()).getData().getValue());
Integer holeType = Integer.valueOf(dictDataApi.parseDictData(HOLE_TYPE, holeXmlVO.getType()).getData().getValue());
DictDataRespDTO faceType = dictDataApi.parseDictData(DictTypeConstants.HOLE_FACE, holeXmlVO.getFace()).getData();
Integer faceTypeValue = faceType != null ? Integer.valueOf(faceType.getValue()) : 2;
Integer direction = Integer.valueOf(dictDataApi.parseDictData(DictTypeConstants.HOLE_DIR, holeXmlVO.getDirection()).getData().getValue());
DictDataRespDTO holeType = holeXmlVO.getType() == null ? null : dictDataApi.parseDictData(DictTypeConstants.HOLE_TYPE, holeXmlVO.getType()).getData();
Double radius = holeXmlVO.getDiameter() != null ? Double.parseDouble(holeXmlVO.getDiameter()) / 2 : 0;
Double depth = holeXmlVO.getDepth() != null ? Double.parseDouble(holeXmlVO.getDepth()) : 0;
HoleDetail holeDetail = HoleDetail.builder()
.holeName(holeXmlVO.getName())
.faceType(faceType)
.holeType(Integer.valueOf(holeXmlVO.getType()))
.faceType(faceTypeValue)
.direction(direction)
.holeType(holeType)
.holeType(holeType != null ? Integer.valueOf(holeType.getValue()) : null)
.radius(radius)
.depth(depth)
.build();
@@ -662,7 +815,7 @@ public class XmlTypeRealize {
// 造型
private void addContourDetail(PlateDO plateDO, PlateDetail plateDetail, GrooveXmlVOS grooveXmlVOS) {
if (grooveXmlVOS != null) {
if (grooveXmlVOS != null && ObjectUtils.allNull(grooveXmlVOS)) {
plateDO.setFrontModelCount(Integer.valueOf(grooveXmlVOS.getCountFaceA())).
setBackModelCount(Integer.valueOf(grooveXmlVOS.getCountFaceB()));
if (grooveXmlVOS.getCountThrough() != null && Integer.parseInt(grooveXmlVOS.getCountThrough()) > 0) {
@@ -670,7 +823,7 @@ public class XmlTypeRealize {
}
if (grooveXmlVOS.getGrooveXmlVOList() != null && grooveXmlVOS.getGrooveXmlVOList().size() > 0) {
for (GrooveXmlVO grooveXmlVO : grooveXmlVOS.getGrooveXmlVOList()) {
Integer faceType = Integer.valueOf(dictDataApi.parseDictData(HOLE_FACE, grooveXmlVO.getFace()).getData().getValue());
Integer faceType = Integer.valueOf(dictDataApi.parseDictData(DictTypeConstants.HOLE_FACE, grooveXmlVO.getFace()).getData().getValue());
faceType = faceType == 0 || faceType == 1 ? faceType : 2;
ModelDetail modelDetail = ModelDetail.builder()
.type(grooveXmlVO.getType())
@@ -1,24 +0,0 @@
package com.cf.imes.module.executor.util.fileConversion.admin.files.xml;
import com.cf.imes.module.executor.dal.dataobject.orderBody.OrderBodyDO;
import java.lang.reflect.Method;
/**
* @projectName: cf_imes_server
* @author: 晨丰科技
* @date: 2024/8/23 16:59
*/
public class test {
public static void main(String[] args) {
// 给定的圆的直径
double diameter = 5;
// 计算半径
double radius = diameter / 3;
// 输出结果
System.out.println("圆的半径是: " + radius);
}
}