mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-14 05:42:06 +08:00
生产单新增
This commit is contained in:
+6
@@ -39,4 +39,10 @@ public interface ErrorCodeConstants {
|
||||
// ========== 生产单 TODO 补充编号 ==========
|
||||
ErrorCode ORDER_PARTS_NOT_EXISTS = new ErrorCode(1_001_115_000, "生产单配件不存在");
|
||||
|
||||
// ========== 生产单 TODO 补充编号 ==========
|
||||
ErrorCode PHONE_NOT_LAWFUL = new ErrorCode(1_001_116_000, "手机号不合法");
|
||||
ErrorCode CUSTOM_ORDER_EXISTS = new ErrorCode(1_001_117_000, "自定义生产单号存在");
|
||||
ErrorCode SALESMAN_ORDER_NOT_EXISTS = new ErrorCode(1_001_118_000, "业务员不存在");
|
||||
ErrorCode SPLITTER_ORDER_NOT_EXISTS = new ErrorCode(1_001_119_000, "拆单员不存在");
|
||||
|
||||
}
|
||||
|
||||
+24
-9
@@ -1,11 +1,14 @@
|
||||
package com.cf.imes.module.executor.controller.admin.order;
|
||||
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.*;
|
||||
import com.cf.imes.module.executor.util.OrderExcelUtil;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -15,6 +18,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
|
||||
@@ -22,11 +26,13 @@ import com.cf.imes.framework.common.pojo.PageParam;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
|
||||
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import com.cf.imes.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import com.cf.imes.framework.operatelog.core.annotations.OperateLog;
|
||||
|
||||
import static com.cf.imes.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
||||
@@ -101,20 +107,20 @@ public class OrderController {
|
||||
@PreAuthorize("@ss.hasPermission('executor:order:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportOrderExcel(@Valid OrderPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<OrderDO> list = orderService.getOrderPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "生产单表 order_{N}.xls", "数据", OrderRespVO.class,
|
||||
BeanUtils.toBean(list, OrderRespVO.class));
|
||||
BeanUtils.toBean(list, OrderRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/get-import-template")
|
||||
@Operation(summary = "获得导入生产单模板")
|
||||
public void importTemplate(HttpServletResponse response) {
|
||||
public void importTemplate(HttpServletResponse response) {
|
||||
try {
|
||||
// path是指想要下载的文件的路径
|
||||
File file = new File(ResourceUtils.getURL("classpath:").getPath()+ "\\files\\生产单上传样式.xlsx");
|
||||
File file = new File(ResourceUtils.getURL("classpath:").getPath() + "\\files\\生产单上传样式.xlsx");
|
||||
log.info(file.getPath());
|
||||
// 获取文件名
|
||||
String filename = file.getName();
|
||||
@@ -152,12 +158,21 @@ public class OrderController {
|
||||
@Operation(summary = "导入生产单")
|
||||
@Parameters({
|
||||
@Parameter(name = "file", description = "Excel 文件", required = true),
|
||||
@Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true")
|
||||
@Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true"),
|
||||
@Parameter(name = "upload", description = "是否上传表头、表体(1,只上传表头;2,包含板材信息", required = true)
|
||||
})
|
||||
@PreAuthorize("@ss.hasPermission('system:user:import')")
|
||||
public CommonResult<OrderImportRespVO> importExcel(@RequestParam("file") MultipartFile file,
|
||||
@RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport) throws Exception {
|
||||
List<OrderImportExcelVO> list = ExcelUtils.read(file, OrderImportExcelVO.class);
|
||||
return success(orderService.importOrderList(list, updateSupport));
|
||||
public void importExcel(@RequestParam("file") MultipartFile file,
|
||||
@RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport,
|
||||
@RequestParam(value = "upload") int upload,
|
||||
@Valid @RequestBody OrderSaveReqVO createReqVO) throws Exception {
|
||||
success(orderService.createOrder(createReqVO));
|
||||
// 有板材,返回包含金额,出现错误进行上传
|
||||
if (upload == 2) {
|
||||
// BigDecimal money = orderService.importOrderList(file, updateSupport , updateSupport);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
+42
-5
@@ -1,14 +1,51 @@
|
||||
package com.cf.imes.module.executor.controller.admin.order.vo.order;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.cf.imes.framework.excel.core.annotations.DictFormat;
|
||||
import com.cf.imes.module.system.enums.DictTypeConstants;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @projectName: cf_imes_server
|
||||
* @author: 晨丰科技
|
||||
* @date: 2024/3/6 10:01
|
||||
* 生产单 Excel 导入 VO
|
||||
*/
|
||||
@Schema(description = "管理后台 - 生产单表 order_{N}新增/修改 Request VO")
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = false) // 设置 chain = false,避免生产单导入有问
|
||||
public class OrderImportExcelVO {
|
||||
@ExcelProperty("自定义单号")
|
||||
private String customOrderNo;
|
||||
|
||||
@ExcelProperty("客户")
|
||||
private String customer;
|
||||
|
||||
@ExcelProperty("经销商")
|
||||
private String dealer;
|
||||
|
||||
@ExcelProperty(value = "客户地址")
|
||||
private String address;
|
||||
|
||||
@ExcelProperty(value = "经销商电话")
|
||||
private String dealerPhoneNumber;
|
||||
|
||||
@ExcelProperty(value = "客户电话")
|
||||
private String phoneNumber;
|
||||
|
||||
@ExcelProperty(value = "业务员")
|
||||
private String salesman;
|
||||
|
||||
@ExcelProperty(value = "交付日期")
|
||||
private LocalDateTime deliveryDate;
|
||||
|
||||
@ExcelProperty(value = "拆单员")
|
||||
private String splitter;
|
||||
|
||||
@ExcelProperty(value = "备注")
|
||||
private List<String> remarkLists;
|
||||
}
|
||||
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
package com.cf.imes.module.executor.controller.admin.order.vo.order;
|
||||
|
||||
import com.cf.imes.framework.excel.core.annotations.DictFormat;
|
||||
import com.cf.imes.module.system.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 生产单 Excel 导入 VO
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = false) // 设置 chain = false,避免生产单导入有问
|
||||
public class OrderPlateImportExcelVO {
|
||||
@ExcelProperty(value = "序号")
|
||||
private int ordinal;
|
||||
|
||||
@ExcelProperty(value = "类型")
|
||||
private String type;
|
||||
|
||||
@ExcelProperty(value = "物料编码")
|
||||
private String rawGoodsId;
|
||||
|
||||
@ExcelProperty(value = "商品名称")
|
||||
private String goodsName;
|
||||
|
||||
@ExcelProperty(value = "材质")
|
||||
private String material;
|
||||
|
||||
@ExcelProperty(value = "颜色")
|
||||
private String color;
|
||||
|
||||
@ExcelProperty(value = "厂家")
|
||||
private String factory;
|
||||
|
||||
@ExcelProperty(value = "品牌")
|
||||
private String brand;
|
||||
|
||||
@ExcelProperty(value = "规格")
|
||||
private String goodsModel;
|
||||
|
||||
@ExcelProperty(value = "型号")
|
||||
private String goodsSpecs;
|
||||
|
||||
@ExcelProperty(value = "单位")
|
||||
private String goodsUnit;
|
||||
|
||||
@ExcelProperty(value = "数量")
|
||||
private BigDecimal goodsNumber;
|
||||
|
||||
@ExcelProperty(value = "房间")
|
||||
private String roomsName;
|
||||
|
||||
@ExcelProperty(value = "柜体")
|
||||
private String cabinetsName;
|
||||
|
||||
@ExcelProperty(value = "板名称")
|
||||
private String platesName;
|
||||
|
||||
@ExcelProperty(value = "板号")
|
||||
private String platesNumber;
|
||||
|
||||
@ExcelProperty(value = "成品长")
|
||||
private BigDecimal productLength;
|
||||
|
||||
@ExcelProperty(value = "成品宽")
|
||||
private BigDecimal productWidth;
|
||||
|
||||
@ExcelProperty(value = "开料长")
|
||||
private BigDecimal actualLength;
|
||||
|
||||
@ExcelProperty(value = "开料宽")
|
||||
private BigDecimal actualWidth;
|
||||
|
||||
@ExcelProperty(value = "厚")
|
||||
private BigDecimal thickness;
|
||||
|
||||
@ExcelProperty(value = "左封边")
|
||||
private BigDecimal sealLeft;
|
||||
|
||||
@ExcelProperty(value = "右封边")
|
||||
private BigDecimal sealRight;
|
||||
|
||||
@ExcelProperty(value = "上封边")
|
||||
private BigDecimal sealAbove;
|
||||
|
||||
@ExcelProperty(value = "下封边")
|
||||
private BigDecimal sealUnder;
|
||||
|
||||
@ExcelProperty(value = "组合类型")
|
||||
private String synthesis;
|
||||
|
||||
@ExcelProperty(value = "组合名称")
|
||||
private String combinationName;
|
||||
|
||||
@ExcelProperty(value = "排版面")
|
||||
private int typographicFace;
|
||||
|
||||
@ExcelProperty(value = "纹路")
|
||||
private int grain;
|
||||
|
||||
@ExcelProperty(value = "开门方向")
|
||||
@DictFormat(DictTypeConstants.USER_SEX)
|
||||
private int openingDirections;
|
||||
|
||||
@ExcelProperty(value = "备注1")
|
||||
private String remark1;
|
||||
|
||||
@ExcelProperty(value = "备注2")
|
||||
private String remark2;
|
||||
|
||||
@ExcelProperty(value = "备注3")
|
||||
private String remark3;
|
||||
|
||||
@ExcelProperty(value = "备注4")
|
||||
private String remark4;
|
||||
|
||||
@ExcelProperty(value = "备注5")
|
||||
private String remark5;
|
||||
|
||||
@ExcelProperty(value = "备注6")
|
||||
private String remark6;
|
||||
|
||||
@ExcelProperty(value = "备注7")
|
||||
private String remark7;
|
||||
|
||||
@ExcelProperty(value = "备注8")
|
||||
private String remark8;
|
||||
|
||||
@ExcelProperty(value = "备注9")
|
||||
private String remark9;
|
||||
|
||||
@ExcelProperty(value = "备注10")
|
||||
private String remark10;
|
||||
|
||||
}
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class OrderSaveReqVO {
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "父单号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "父单号不能为空")
|
||||
@NotNull(message = "父单号不能为空,无父单时为0")
|
||||
private Long parentNo;
|
||||
|
||||
@Schema(description = "交付日期", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
|
||||
+4
-7
@@ -2,10 +2,7 @@ package com.cf.imes.module.executor.service.order;
|
||||
|
||||
import javax.validation.*;
|
||||
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderImportExcelVO;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderImportRespVO;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPageReqVO;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderSaveReqVO;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.*;
|
||||
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
|
||||
@@ -57,11 +54,11 @@ public interface OrderService {
|
||||
PageResult<OrderDO> getOrderPage(OrderPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 批量导入用户
|
||||
* 批量导入生产单
|
||||
*
|
||||
* @param importOrders 导入用户列表
|
||||
* @param importOrders 导入生产单列表
|
||||
* @param isUpdateSupport 是否支持更新
|
||||
* @return 导入结果
|
||||
*/
|
||||
OrderImportRespVO importOrderList(List<OrderImportExcelVO> importOrders, Boolean isUpdateSupport);
|
||||
OrderImportRespVO importOrderList(List<OrderPlateImportExcelVO> importOrders, Boolean isUpdateSupport);
|
||||
}
|
||||
+82
-17
@@ -1,17 +1,9 @@
|
||||
package com.cf.imes.module.executor.service.order;
|
||||
|
||||
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
||||
import com.cf.imes.framework.excel.core.util.ExcelUtils;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderImportExcelVO;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderImportRespVO;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPageReqVO;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderSaveReqVO;
|
||||
import com.cf.imes.module.system.enums.common.SexEnum;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.*;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@@ -20,11 +12,15 @@ import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
|
||||
import com.cf.imes.module.executor.dal.mysql.order.OrderMapper;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.*;
|
||||
@@ -41,12 +37,20 @@ public class OrderServiceImpl implements OrderService {
|
||||
@Resource
|
||||
private OrderMapper orderMapper;
|
||||
|
||||
private static final int DEFAULT_DAYS_TO_ADD = 30;
|
||||
|
||||
@Override
|
||||
public Long createOrder(OrderSaveReqVO createReqVO) {
|
||||
/**
|
||||
* 1、解析文件
|
||||
*
|
||||
*/
|
||||
//校验手机号是否合法
|
||||
validatePhoneNumber(createReqVO.getPhoneNumber());
|
||||
validatePhoneNumber(createReqVO.getDealerPhoneNumber());
|
||||
//验证自定义单号是否存在,业务员、拆单员是否存在
|
||||
validateCustomOrderNoExists(createReqVO.getCustomOrderNo());
|
||||
validateSalesmanOrderNoExists(createReqVO.getSalesman());
|
||||
validateSplitterOrderNoExists(createReqVO.getSplitter());
|
||||
|
||||
LocalDateTime time = getAfterDate(createReqVO.getDeliveryDate());
|
||||
createReqVO.setDeliveryDate(time);
|
||||
// 插入
|
||||
OrderDO order = BeanUtils.toBean(createReqVO, OrderDO.class);
|
||||
orderMapper.insert(order);
|
||||
@@ -88,8 +92,69 @@ public class OrderServiceImpl implements OrderService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderImportRespVO importOrderList(List<OrderImportExcelVO> importOrders, Boolean isUpdateSupport) {
|
||||
public OrderImportRespVO importOrderList(List<OrderPlateImportExcelVO> importOrders, Boolean isUpdateSupport) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private LocalDateTime getAfterDate(LocalDateTime date) {
|
||||
// 获取当前日期类型 2024-03-06 16:50:15
|
||||
// 获取当前日期,明确指定时区为业务所在时区,例如Asia/Shanghai
|
||||
ZonedDateTime now = ZonedDateTime.now(ZoneId.of("UTC"));
|
||||
LocalDateTime localDateTime = now.toLocalDateTime();
|
||||
|
||||
if (localDateTime.isAfter(date)) {
|
||||
// 添加30天
|
||||
LocalDateTime futureDate = localDateTime.plusDays(DEFAULT_DAYS_TO_ADD);
|
||||
try {
|
||||
// 考虑到异常处理,使用try-catch块
|
||||
return futureDate;
|
||||
} catch (DateTimeParseException e) {
|
||||
// 在实际应用中应该有更详细的错误处理逻辑
|
||||
System.err.println("Error parsing future date: " + e.getMessage());
|
||||
// 根据业务需求,这里可以选择记录日志、抛出自定义异常或进行其他处理
|
||||
}
|
||||
}
|
||||
return date;
|
||||
}
|
||||
|
||||
// 验证自定义单号是否存在
|
||||
private void validateCustomOrderNoExists(String customOrderNo){
|
||||
if (orderMapper.selectOne("custom_order_no", customOrderNo) != null) {
|
||||
throw exception(CUSTOM_ORDER_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
// 业务员是否存在
|
||||
private void validateSalesmanOrderNoExists(String salesman){
|
||||
if (orderMapper.selectOne("salesman", salesman) == null) {
|
||||
throw exception(SALESMAN_ORDER_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
// 拆单员是否存在
|
||||
private void validateSplitterOrderNoExists(String splitter){
|
||||
if (orderMapper.selectOne("splitter", splitter) == null) {
|
||||
throw exception(SPLITTER_ORDER_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
// 校验手机号是否合法
|
||||
private void validatePhoneNumber(String phoneNumber){
|
||||
// 定义手机号正则表达式
|
||||
String regex = "^1[3-9]\\d{9}$";
|
||||
|
||||
// 编译正则表达式
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
|
||||
// 创建 Matcher 对象
|
||||
Matcher matcher = pattern.matcher(phoneNumber);
|
||||
|
||||
// 判断手机号是否匹配正则表达式
|
||||
if (matcher.matches()) {
|
||||
System.out.println("手机号合法");
|
||||
} else {
|
||||
throw exception(PHONE_NOT_LAWFUL);
|
||||
}
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package com.cf.imes.module.executor.util;
|
||||
|
||||
import com.cf.imes.framework.excel.core.util.ExcelUtils;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
public class OrderExcelUtil extends ExcelUtils {
|
||||
public static <T> List<T> read(MultipartFile file, Class<T> head , int upload) throws IOException {
|
||||
if (file.isEmpty()) {
|
||||
throw new IOException("文件为空");
|
||||
} else if (!file.getOriginalFilename().endsWith(".xlsx")) {
|
||||
throw new IOException("文件格式不正确");
|
||||
} else if (file.getSize() > 1024 * 1024 * 10) {
|
||||
throw new IOException("文件大小超过 10M");
|
||||
} else if (file.getSize() == 0) {
|
||||
throw new IOException("文件大小为 0");
|
||||
} else {
|
||||
//读取文件内容
|
||||
|
||||
|
||||
try {
|
||||
// 将 MultipartFile 转换为 InputStream
|
||||
InputStream inputStream = file.getInputStream();
|
||||
// 使用 WorkbookFactory 创建 Workbook 对象
|
||||
Workbook workbook = WorkbookFactory.create(inputStream);
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
extractOrderInformation(sheet, file);
|
||||
|
||||
workbook.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void extractOrderInformation(Sheet sheet, MultipartFile file) throws IOException {
|
||||
int rowNum=sheet.getLastRowNum();
|
||||
for (Row row : sheet) {
|
||||
Cell firstCell = row.getCell(0);
|
||||
if (firstCell != null && firstCell.getCellType() == CellType.STRING) {
|
||||
String cellValue = firstCell.getStringCellValue().trim();
|
||||
if (cellValue.equals("&&&")) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
package com.cf.imes.module.executor.util;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.zip.Deflater;
|
||||
import java.util.zip.DeflaterOutputStream;
|
||||
import java.util.zip.Inflater;
|
||||
import java.util.zip.InflaterInputStream;
|
||||
|
||||
|
||||
/**
|
||||
* zlib压缩工具类
|
||||
*/
|
||||
public class ZLibUtils {
|
||||
|
||||
// 压缩直接数组
|
||||
public static byte[] compress(byte[] data) {
|
||||
byte[] output = new byte[0];
|
||||
Deflater compresser = new Deflater();
|
||||
compresser.reset();
|
||||
compresser.setInput(data);
|
||||
compresser.finish();
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(data.length);
|
||||
try {
|
||||
byte[] buf = new byte[1024];
|
||||
while (!compresser.finished()) {
|
||||
int i = compresser.deflate(buf);
|
||||
bos.write(buf, 0, i);
|
||||
}
|
||||
output = bos.toByteArray();
|
||||
} catch (Exception e) {
|
||||
output = data;
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
bos.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
compresser.end();
|
||||
return output;
|
||||
}
|
||||
|
||||
// 压缩 字节数组到输出流
|
||||
public static void compress(byte[] data, OutputStream os) {
|
||||
DeflaterOutputStream dos = new DeflaterOutputStream(os);
|
||||
try {
|
||||
dos.write(data, 0, data.length);
|
||||
dos.finish();
|
||||
dos.flush();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// 解压缩 字节数组
|
||||
public static byte[] decompress(byte[] data) {
|
||||
byte[] output = new byte[0];
|
||||
Inflater inflater = new Inflater();
|
||||
inflater.reset();
|
||||
inflater.setInput(data);
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length);
|
||||
try {
|
||||
byte[] result = new byte[1024];
|
||||
while (!inflater.finished()) {
|
||||
int count = inflater.inflate(result );
|
||||
outputStream .write(result , 0, count );
|
||||
}
|
||||
output = outputStream .toByteArray();
|
||||
} catch (Exception e) {
|
||||
output = data;
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
outputStream .close();
|
||||
inflater.end();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
// 解压缩 字节数组
|
||||
public static String decompress_str(byte[] data) {
|
||||
byte[] output = new byte[0];
|
||||
Inflater inflater = new Inflater();
|
||||
inflater.reset();
|
||||
inflater.setInput(data);
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length);
|
||||
try {
|
||||
byte[] buf = new byte[1024];
|
||||
while (!inflater.finished()) {
|
||||
int count = inflater.inflate(buf);
|
||||
outputStream .write(buf, 0, count );
|
||||
}
|
||||
output = outputStream.toByteArray();
|
||||
} catch (Exception e) {
|
||||
output = data;
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
outputStream .close();
|
||||
inflater.end();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
// 解压缩 输入流 到字节数组
|
||||
public static byte[] decompress(InputStream is) {
|
||||
InflaterInputStream iis = new InflaterInputStream(is);
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(1024);
|
||||
try {
|
||||
int i = 1024;
|
||||
byte[] buf = new byte[i];
|
||||
while ((i = iis.read(buf, 0, i)) > 0) {
|
||||
outputStream.write(buf, 0, i);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return outputStream.toByteArray();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String source = "xxxxxxxxxxaassad";
|
||||
byte[] compress = compress(source.getBytes());
|
||||
String str = new String(compress);
|
||||
System.out.println(str);
|
||||
|
||||
System.out.println(new String(decompress(str.getBytes())));
|
||||
}
|
||||
}
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
export function getPointInfo(dataList) {
|
||||
const list = [];
|
||||
dataList.forEach(d => {
|
||||
if (d.CadData != null && d.CadData != '') {
|
||||
const data = JSON.parse(d.CadData);
|
||||
const pointInfo = {};
|
||||
pointInfo['ID'] = d.ID;
|
||||
pointInfo['OrderNo'] = d.OrderNo;
|
||||
const dList = data[0] == null ? [] : data[0];
|
||||
const pList = dList[0] == null ? [] : dList[0];
|
||||
const hList = dList[1] == null ? [] : dList[1];
|
||||
const mList = dList[2] == null ? [] : dList[2];
|
||||
const oList = data[3] == null ? [] : data[3];
|
||||
const orgPList = dList[3] == null ? [] : dList[3];
|
||||
const smList = dList[4] == null ? [] : dList[4];
|
||||
const shList = dList[5] == null ? [] : dList[5];
|
||||
const kaiLiaoSizeList = data[4] == null ? [] : data[4];
|
||||
pointInfo['PointDetail'] = ArrayToObject(CadBlockPoint, pList);
|
||||
pointInfo['ModelDetail'] = ArrayToObject(CadBlockModel, mList);
|
||||
pointInfo['HoleDetail'] = ArrayToObject(CadBlockHoles, hList);
|
||||
pointInfo['OffSet'] = new V3().ParseObject(oList);
|
||||
// console.log('orgPList', orgPList)
|
||||
pointInfo['NewVersion'] = orgPList.length > 0 && orgPList[0][5] == 1;
|
||||
pointInfo['OrgPointDetail'] = ArrayToObject(CadBlockPoint, orgPList);
|
||||
if (kaiLiaoSizeList != null && kaiLiaoSizeList.length > 0) {
|
||||
pointInfo['KaiLiaoSize'] = new KaiLiaoSize().ParseObject([kaiLiaoSizeList[0], kaiLiaoSizeList[1]])
|
||||
} else {
|
||||
pointInfo['KaiLiaoSize'] = null;
|
||||
}
|
||||
pointInfo['SideModelDetail'] = ArrayToObject(CadBlockModel, smList);
|
||||
pointInfo['SideHoleDetail'] = ArrayToObject(CadBlockHoles, shList)
|
||||
list.push(pointInfo);
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
{
|
||||
"OrderNo" : "$OrderNo$ 订单号",
|
||||
"CustomOrderNo" : "$CustomOrderNo$ 自定义单号",
|
||||
"CustomNo": "$CustomNo$ 客户代码(经销商)",
|
||||
"CustomName": "$CustomName$ 客户名称(经销商)",
|
||||
"SalePerson": "$SalePerson$ 业务员",
|
||||
"SaleDate": "$SaleDate$ 销售日期",
|
||||
"DeliveryDate": "$DeliveryDate$ 送货日期",
|
||||
"Consignee": "$Consignee$ 收货人(终端客户)",
|
||||
"ConsigneePhone": "$ConsigneePhone$ 收货电话(终端客户电话)",
|
||||
"ConsigneeAddress": "$ConsigneeAddress$ 地址",
|
||||
"OrderRemark": "$Remark$ 备注",
|
||||
"IOriginModelingData //造型数据": {
|
||||
"outline": "IContourData 轮郭",
|
||||
"holes //孔轮廓": {
|
||||
"pts": "Vector2[] 点集(二维向量(x,y))",
|
||||
"buls": "number[] //凸度(0直线段 >0逆时针方向 <0顺时针方向)"
|
||||
},
|
||||
"thickness": "number 厚度",
|
||||
"dir": "FaceDirection | number 方向",
|
||||
"knifeRadius": "number 刀半径",
|
||||
"addLen": "number; 槽加长",
|
||||
"addWidth": "number 槽加宽",
|
||||
"addDepth": "number 槽加深"
|
||||
},
|
||||
"detail //CAD板件信息": {
|
||||
"ModelDetail //模块明细": {
|
||||
"ModelID": "number 模块ID",
|
||||
"LineID": "number 纹路ID",
|
||||
"Face": " 板面类型(0正面, 1反面, 2侧面)",
|
||||
"KnifeName": " 刀具名称",
|
||||
"KnifeRadius": "number 刀半径",
|
||||
"Depth": "number 深度",
|
||||
"OriginModeling": "IOriginModelingData 造型数据",
|
||||
"PointList //点列表":{
|
||||
"LineID": "number 纹路ID",
|
||||
"PointID": "number 点ID",
|
||||
"PointX": "number x",
|
||||
"PointY": "number y",
|
||||
"Radius": "number 半径",
|
||||
"Depth": "number 深度",
|
||||
"Curve": "number 曲线"
|
||||
},
|
||||
"OffSetList//偏移量列表 //模块偏移数据":{
|
||||
"Name": "string 名称",
|
||||
"Face": "FaceType 面向类型(0正面, 1反面, 2侧面)",
|
||||
"Value": "number 值",
|
||||
"Radius": "number 半径",
|
||||
"Deep": "number 深度",
|
||||
"Angle": "number 角度"
|
||||
}
|
||||
},
|
||||
"PointDetail //点明细" : {
|
||||
"PointID": "number id",
|
||||
"PointX": "number x",
|
||||
"PointY": "number y",
|
||||
"Curve": "number 曲线",
|
||||
"SealSize": "number 封边尺寸"
|
||||
},
|
||||
"HoleDetail //孔明细": {
|
||||
"HoleID": "number 孔ID",
|
||||
"HoleType": "HoleType 孔类型(0大孔, 10小孔, 20木削, 21木削大孔, 30层板钉, 40通孔, 50连接杆, -10造型孔)",
|
||||
"Face": "FaceType 孔面类型(0正面, 1反面, 2侧面)",
|
||||
"PointX": "number x",
|
||||
"PointY": "number y",
|
||||
"PointZ": "number x",
|
||||
"Radius": "number 半径",
|
||||
"Depth": "number 深度",
|
||||
"EndPoint": "string 末端点",
|
||||
"PointX2": "number x2",
|
||||
"PointY2": "number y2",
|
||||
"Angle": "number 角度"
|
||||
},
|
||||
"OrgPointDetail //原始点明细": {
|
||||
"PointID": "number id",
|
||||
"PointX": "number x",
|
||||
"PointY": "number y",
|
||||
"Curve": "number 曲线",
|
||||
"SealSize": "number 封边尺寸"
|
||||
},
|
||||
"SideModelDetail //侧面模块明细": {
|
||||
"ModelID": "number 模块ID",
|
||||
"LineID": "number 纹路ID",
|
||||
"Face": " 板面类型(0正面, 1反面, 2侧面)",
|
||||
"KnifeName": " 刀具名称",
|
||||
"KnifeRadius": "number 刀半径",
|
||||
"Depth": "number 深度",
|
||||
"OriginModeling": "IOriginModelingData 造型数据",
|
||||
"PointList //点列表":{
|
||||
"LineID": "number 纹路ID",
|
||||
"PointID": "number 点ID",
|
||||
"PointX": "number x",
|
||||
"PointY": "number y",
|
||||
"Radius": "number 半径",
|
||||
"Depth": "number 深度",
|
||||
"Curve": "number 曲线"
|
||||
},
|
||||
"OffSetList//偏移量列表 //模块偏移数据":{
|
||||
"Name": "string 名称",
|
||||
"Face": "FaceType 面向类型(0正面, 1反面, 2侧面)",
|
||||
"Value": "number 值",
|
||||
"Radius": "number 半径",
|
||||
"Deep": "number 深度",
|
||||
"Angle": "number 角度"
|
||||
}
|
||||
},
|
||||
"SideHoleDetail //侧面孔明细": {
|
||||
"HoleID": "number 孔ID",
|
||||
"HoleType": "HoleType 孔类型(0大孔, 10小孔, 20木削, 21木削大孔, 30层板钉, 40通孔, 50连接杆, -10造型孔)",
|
||||
"Face": "FaceType 孔面类型(0正面, 1反面, 2侧面)",
|
||||
"PointX": "number x",
|
||||
"PointY": "number y",
|
||||
"PointZ": "number x",
|
||||
"Radius": "number 半径",
|
||||
"Depth": "number 深度",
|
||||
"EndPoint": "string 末端点",
|
||||
"PointX2": "number x2",
|
||||
"PointY2": "number y2",
|
||||
"Angle": "number 角度"
|
||||
},
|
||||
"PlateRemark //备注": {
|
||||
"remark": "string 备注",
|
||||
"remark2": "string 备注2"
|
||||
}
|
||||
}
|
||||
}
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
|
||||
//轮廓数据
|
||||
export interface IContourData
|
||||
{
|
||||
// pts: Vector2[]; //点集(二维向量(x,y))
|
||||
buls: number[]; //凸度(0直线段 >0逆时针方向 <0顺时针方向)
|
||||
}
|
||||
|
||||
//偏心轮类型
|
||||
// 左右侧板:Font朝向柜内,Back朝向柜外
|
||||
// 顶底板:Font朝向柜外,Back两面朝下,Inside朝向柜内
|
||||
export enum FaceDirection
|
||||
{
|
||||
Front = 0, //正面
|
||||
Back = 1, //反面
|
||||
Inside = 2 //侧面
|
||||
}
|
||||
|
||||
//造型数据
|
||||
export interface IOriginModelingData
|
||||
{
|
||||
outline: IContourData, //轮郭
|
||||
holes: IContourData[]; //孔轮廓
|
||||
thickness?: number; //厚度
|
||||
dir?: FaceDirection | number; //方向
|
||||
knifeRadius?: number; //刀半径
|
||||
addLen?: number; //槽加长
|
||||
addWidth?: number; //槽加宽
|
||||
addDepth?: number; //槽加深
|
||||
}
|
||||
|
||||
export abstract class BaseModel
|
||||
{
|
||||
protected get props()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
ToArray()
|
||||
{
|
||||
let reuslt = [];
|
||||
for (const key of this.props)
|
||||
{
|
||||
reuslt.push(this[key]);
|
||||
}
|
||||
return reuslt;
|
||||
}
|
||||
}
|
||||
|
||||
//CAD板件点属性
|
||||
export class CadBlockPoint extends BaseModel
|
||||
{
|
||||
PointID: number; //id
|
||||
PointX: number; //x
|
||||
PointY: number; //y
|
||||
Curve: number; //曲线
|
||||
SealSize: number; //封边尺寸
|
||||
}
|
||||
|
||||
//CAD板件孔属性
|
||||
export class CadBlockHoles extends BaseModel
|
||||
{
|
||||
HoleID: number; //孔ID
|
||||
HoleType: HoleType; //孔类型(0大孔, 10小孔, 20木削, 21木削大孔, 30层板钉, 40通孔, 50连接杆, -10造型孔)
|
||||
Face: FaceType; //孔面类型(0正面, 1反面, 2侧面)
|
||||
PointX: number; //x
|
||||
PointY: number; //y
|
||||
PointZ: number; //z
|
||||
Radius: number; //半径
|
||||
Depth: number; //深度
|
||||
EndPoint: string; //末端点
|
||||
PointX2: number; //x2
|
||||
PointY2: number; //y2
|
||||
Angle?: number; //角度
|
||||
}
|
||||
export enum HoleType { 大孔 = 0, 小孔 = 10, 木削 = 20, 木削大孔 = 21, 层板钉 = 30, 通孔 = 40, 连接杆 = 50, 造型孔 = -10 }
|
||||
export enum FaceType { 正面 = 0, 反面 = 1, 侧面 = 2 }
|
||||
|
||||
//CAD板件模块
|
||||
export class CadBlockModel extends BaseModel
|
||||
{
|
||||
ModelID: number; //模块ID
|
||||
LineID: number; //纹路ID
|
||||
Face: FaceType; //板面类型(0正面, 1反面, 2侧面)
|
||||
KnifeName: string; //刀具名称
|
||||
KnifeRadius: number; //刀半径
|
||||
Depth: number; //深度
|
||||
PointList: CadBlockModelPoint[]; //点列表
|
||||
OffSetList: ModelOffSetData[]; //偏移量列表
|
||||
OriginModeling: IOriginModelingData; //造型数据
|
||||
|
||||
}
|
||||
|
||||
//模块偏移数据
|
||||
export class ModelOffSetData extends BaseModel
|
||||
{
|
||||
Name: string; //名称
|
||||
Face: FaceType; //面向类型(0正面, 1反面, 2侧面)
|
||||
Value: number; //值
|
||||
Radius: number; //半径
|
||||
Deep: number; //深度
|
||||
Angle: number; //角度
|
||||
}
|
||||
|
||||
//CAD板件模块点
|
||||
export class CadBlockModelPoint extends BaseModel
|
||||
{
|
||||
LineID: number; //纹路ID
|
||||
PointID: number; //点ID
|
||||
PointX: number; //x
|
||||
PointY: number; //y
|
||||
Radius: number; //半径
|
||||
Depth: number; //深度
|
||||
Curve: number; //曲线
|
||||
|
||||
|
||||
}
|
||||
|
||||
//基准位置
|
||||
export class BasePosition extends BaseModel
|
||||
{
|
||||
BasePoint: string; //基准点
|
||||
XVec: string; //x矢量坐标
|
||||
YVec: string; //y矢量坐标
|
||||
ZVec: string; //z矢量坐标
|
||||
|
||||
}
|
||||
|
||||
//CAD板件信息
|
||||
export class CadBlockInfo
|
||||
{
|
||||
PointDetail: CadBlockPoint[]; //点明细
|
||||
HoleDetail: CadBlockHoles[]; //孔明细
|
||||
ModelDetail: CadBlockModel[]; //模块明细
|
||||
OrgPointDetail: CadBlockPoint[]; //原始点明细
|
||||
SideModelDetail: CadBlockModel[]; //侧面模块明细
|
||||
SideHoleDetail: CadBlockHoles[]; //侧面孔明细
|
||||
}
|
||||
+3
-3
@@ -110,7 +110,7 @@ public class GoodsServiceImplTest extends BaseDbUnitTest {
|
||||
public void testGetGoodsPage() {
|
||||
// mock 数据
|
||||
GoodsDO dbGoods = randomPojo(GoodsDO.class, o -> { // 等会查询到
|
||||
o.setOrderNo(null);
|
||||
o.setOrderId(null);
|
||||
o.setGoodsId(null);
|
||||
o.setGoodsName(null);
|
||||
o.setMaterial(null);
|
||||
@@ -126,7 +126,7 @@ public class GoodsServiceImplTest extends BaseDbUnitTest {
|
||||
});
|
||||
goodsMapper.insert(dbGoods);
|
||||
// 测试 orderNo 不匹配
|
||||
goodsMapper.insert(cloneIgnoreId(dbGoods, o -> o.setOrderNo(null)));
|
||||
goodsMapper.insert(cloneIgnoreId(dbGoods, o -> o.setOrderId(null)));
|
||||
// 测试 goodsId 不匹配
|
||||
goodsMapper.insert(cloneIgnoreId(dbGoods, o -> o.setGoodsId(null)));
|
||||
// 测试 goodsName 不匹配
|
||||
@@ -153,7 +153,7 @@ public class GoodsServiceImplTest extends BaseDbUnitTest {
|
||||
goodsMapper.insert(cloneIgnoreId(dbGoods, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
GoodsPageReqVO reqVO = new GoodsPageReqVO();
|
||||
reqVO.setOrderNo(null);
|
||||
reqVO.setOrderId(null);
|
||||
reqVO.setGoodsId(null);
|
||||
reqVO.setGoodsName(null);
|
||||
reqVO.setMaterial(null);
|
||||
|
||||
Reference in New Issue
Block a user