mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
生产单新增
This commit is contained in:
+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);
|
||||
|
||||
+2
-2
@@ -24,13 +24,13 @@ import java.time.LocalDateTime;
|
||||
@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题
|
||||
public class PlateImportExcelVO {
|
||||
|
||||
@ExcelProperty("客户的商品编号")
|
||||
@ExcelProperty("商品编号")
|
||||
private String goodsId;
|
||||
|
||||
@ExcelProperty("商品名称")
|
||||
private String goodsName;
|
||||
|
||||
@ExcelProperty("材质:颗粒板、欧松板、多层板、生态板、禾香板、密度板、实木、铝蜂窝板、铝塑板")
|
||||
@ExcelProperty("材质")
|
||||
private String material;
|
||||
|
||||
@ExcelProperty("颜色")
|
||||
|
||||
+2
@@ -174,6 +174,7 @@ public interface ErrorCodeConstants {
|
||||
|
||||
//=========== 工序信息 1-002-028-000 ============
|
||||
ErrorCode PROCESS_NOT_EXISTS = new ErrorCode(1_002_028_000, "工序不存在");
|
||||
ErrorCode PROCESS_ID_IS_NULL = new ErrorCode(1_002_028_000, "工序ID不存在");
|
||||
|
||||
//=========== 工序组信息 1-002-029-000 ============
|
||||
ErrorCode PROCESS_GROUP_NOT_EXISTS = new ErrorCode(1_002_029_000, "工序组不存在");
|
||||
@@ -203,5 +204,6 @@ public interface ErrorCodeConstants {
|
||||
|
||||
//=========== 板材信息 1-002-034-000 ============
|
||||
ErrorCode PROCESS_USER_NOT_EXISTS = new ErrorCode(1_002_032_002, "工序用户不存在");
|
||||
ErrorCode PROCESS_USER_EXISTS = new ErrorCode(1_002_032_002, "工序用户存在");
|
||||
|
||||
}
|
||||
|
||||
+3
-14
@@ -53,25 +53,14 @@ public class ProcessGroupController {
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建工序组")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult<Long> createProcessGroup(@Valid @RequestBody ProcessListSaveReqVO createReqVOLists) {
|
||||
StringBuilder itemsBuilder = new StringBuilder();
|
||||
for (ProcessRespVO createReqVO : createReqVOLists.getLists()) {
|
||||
Optional.ofNullable(createReqVO.getId()).ifPresent(id -> {
|
||||
itemsBuilder.append(id).append(",");
|
||||
});
|
||||
}
|
||||
String items = itemsBuilder.length() > 0 ? itemsBuilder.substring(0, itemsBuilder.length() - 1) : null;
|
||||
|
||||
ProcessGroupSaveReqVO createReqVO = BeanUtils.toBean(createReqVOLists, ProcessGroupSaveReqVO.class);
|
||||
createReqVO.setItems(items);
|
||||
|
||||
return success(processGroupService.createProcessGroup(createReqVO));
|
||||
public CommonResult<Long> createProcessGroup(@Valid @RequestBody ProcessGroupSaveReqVO createReqVOLists) {
|
||||
return success(processGroupService.createProcessGroup(createReqVOLists));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新工序组")
|
||||
@PreAuthorize("@ss.hasPermission('system:process-group:update')")
|
||||
public CommonResult<Boolean> updateProcessGroup(@Valid @RequestBody ProcessListSaveReqVO updateReqVO) {
|
||||
public CommonResult<Boolean> updateProcessGroup(@Valid @RequestBody ProcessGroupSaveReqVO updateReqVO) {
|
||||
processGroupService.updateProcessGroup(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
+4
@@ -26,6 +26,10 @@ public class ProcessListSaveReqVO {
|
||||
@NotNull(message = "排序优先级")
|
||||
private Short sort;
|
||||
|
||||
@Schema(description = "明细,工序 ID 逗号分隔", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "明细,工序 ID 逗号分隔不能为空")
|
||||
private String items;
|
||||
|
||||
@Schema(description = "描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便")
|
||||
@NotEmpty(message = "描述不能为空")
|
||||
private String description;
|
||||
|
||||
-4
@@ -19,8 +19,4 @@ public class ProcessAndUserRespVO {
|
||||
@ExcelProperty("用户 ID")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
+3
-3
@@ -13,12 +13,12 @@ import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
||||
@TableName("process_user")
|
||||
@KeySequence("process_user_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ToString(callSuper = false)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ProcessUserDO extends BaseDO {
|
||||
public class ProcessUserDO {
|
||||
|
||||
/**
|
||||
* 工序 ID
|
||||
|
||||
+5
-3
@@ -1,8 +1,12 @@
|
||||
package com.cf.imes.module.system.dal.mysql.process;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.module.system.dal.dataobject.process.ProcessUserDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -22,7 +26,5 @@ public interface ProcessUserMapper extends BaseMapperX<ProcessUserDO> {
|
||||
return selectOne(ProcessUserDO::getProcessId, processId);
|
||||
}
|
||||
|
||||
default int deleteUserByProcessId(Long processId) {
|
||||
return delete(ProcessUserDO::getProcessId, processId);
|
||||
}
|
||||
int deleteUserByProcessId(@Param("processId") Long processId);
|
||||
}
|
||||
+1
-1
@@ -29,7 +29,7 @@ public interface ProcessGroupService {
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateProcessGroup(@Valid ProcessListSaveReqVO updateReqVO);
|
||||
void updateProcessGroup(@Valid ProcessGroupSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除工序组表 process_group
|
||||
|
||||
+67
-15
@@ -6,8 +6,11 @@ import com.cf.imes.module.system.controller.admin.process.vo.group.ProcessListSa
|
||||
import com.cf.imes.module.system.controller.admin.process.vo.process.ProcessRespVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.process.ProcessDO;
|
||||
import com.cf.imes.module.system.dal.mysql.process.ProcessMapper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import com.cf.imes.module.system.dal.dataobject.process.ProcessGroupDO;
|
||||
@@ -17,12 +20,15 @@ import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.module.system.dal.mysql.process.ProcessGroupMapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 工序组表 process_group Service 实现类
|
||||
*
|
||||
@@ -42,28 +48,19 @@ public class ProcessGroupServiceImpl implements ProcessGroupService {
|
||||
public Long createProcessGroup(ProcessGroupSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
ProcessGroupDO processGroup = BeanUtils.toBean(createReqVO, ProcessGroupDO.class);
|
||||
processGroup.setItems(checkProcessGroupExists(createReqVO.getItems()));
|
||||
processGroupMapper.insert(processGroup);
|
||||
// 返回
|
||||
return processGroup.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProcessGroup(ProcessListSaveReqVO updateReqVO) {
|
||||
public void updateProcessGroup(ProcessGroupSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateProcessGroupExists(updateReqVO.getId());
|
||||
// 获取items
|
||||
List<ProcessRespVO> itemLists = updateReqVO.getLists();
|
||||
StringBuilder itemsBuilder = new StringBuilder();
|
||||
for (ProcessRespVO createReqVO : itemLists) {
|
||||
Optional.ofNullable(createReqVO.getId()).ifPresent(id -> {
|
||||
itemsBuilder.append(id).append(",");
|
||||
});
|
||||
}
|
||||
String items = itemsBuilder.length() > 0 ? itemsBuilder.substring(0, itemsBuilder.length() - 1) : null;
|
||||
|
||||
// 更新
|
||||
ProcessGroupDO updateObj = BeanUtils.toBean(updateReqVO, ProcessGroupDO.class);
|
||||
updateObj.setItems(items);
|
||||
updateObj.setItems(checkProcessGroupExists(updateReqVO.getItems()));
|
||||
processGroupMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@@ -85,14 +82,14 @@ public class ProcessGroupServiceImpl implements ProcessGroupService {
|
||||
public ProcessListSaveReqVO getProcessGroup(Long id) {
|
||||
if (processGroupMapper.selectById(id) == null) {
|
||||
throw exception(PROCESS_GROUP_NOT_EXISTS);
|
||||
}else {
|
||||
} else {
|
||||
ProcessGroupDO processGroup = processGroupMapper.selectById(id);
|
||||
ProcessListSaveReqVO processListSaveReqVO = BeanUtils.toBean(processGroup, ProcessListSaveReqVO.class);
|
||||
String[] items = processGroup.getItems().split(",");
|
||||
List<ProcessRespVO> lists = new ArrayList<>();
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
lists.add(BeanUtils.toBean(processMapper.selectById(items[i]), ProcessRespVO.class));
|
||||
System.out.println("each List " +BeanUtils.toBean(processMapper.selectById(items[i]), ProcessRespVO.class));
|
||||
lists.add(BeanUtils.toBean(processMapper.selectById(items[i]), ProcessRespVO.class));
|
||||
System.out.println("each List " + BeanUtils.toBean(processMapper.selectById(items[i]), ProcessRespVO.class));
|
||||
}
|
||||
System.out.println("processGroupSaveReqVO = " + processListSaveReqVO);
|
||||
processListSaveReqVO.setLists(lists);
|
||||
@@ -105,4 +102,59 @@ public class ProcessGroupServiceImpl implements ProcessGroupService {
|
||||
public PageResult<ProcessGroupDO> getProcessGroupPage(ProcessGroupPageReqVO pageReqVO) {
|
||||
return processGroupMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
|
||||
private String checkProcessGroupExists(String userLists) {
|
||||
// 检查输入是否为空或仅包含空白字符
|
||||
if (userLists == null || userLists.trim().isEmpty()) {
|
||||
return "[]"; // 统一返回空列表格式化字符串
|
||||
}
|
||||
|
||||
List<String> itemsList = Arrays.stream(userLists.split(","))
|
||||
.map(String::trim) // 去除每个项两端的空白字符
|
||||
.filter(item -> item != null && !item.isEmpty()) // 过滤空字符串和null
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 如果列表为空,直接返回空字符串,表示没有有效的进程ID
|
||||
if (itemsList.isEmpty()) {
|
||||
return "[]";
|
||||
}
|
||||
|
||||
StringBuilder itemsBuilder = new StringBuilder();
|
||||
StringBuilder missingItemsBuilder = new StringBuilder(); // 使用StringBuilder累积不存在的项的ID
|
||||
|
||||
itemsList.forEach(itemId -> {
|
||||
try {
|
||||
Object item = processMapper.selectById(itemId);
|
||||
if (item != null) {
|
||||
// 优化字符串拼接
|
||||
itemsBuilder.append(itemId).append(",");
|
||||
} else {
|
||||
// 将不存在的项的ID累积到missingItemsBuilder中
|
||||
if (missingItemsBuilder.length() > 0) {
|
||||
missingItemsBuilder.append(",");
|
||||
}
|
||||
missingItemsBuilder.append(itemId);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 处理可能的异常,例如数据库查询异常
|
||||
// 可以记录日志或者转换为业务异常等
|
||||
// 此处为简化仅打印异常,实际应用中应更详细处理
|
||||
System.err.println("Error processing item: " + e.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
// 判断是否存在不存在的项,并一次性抛出异常
|
||||
if (missingItemsBuilder.length() > 0) {
|
||||
throw exception(PROCESS_NOT_EXISTS, "Items with IDs " + missingItemsBuilder.toString() + " do not exist.");
|
||||
}
|
||||
|
||||
// 移除itemsBuilder最后的逗号
|
||||
if (itemsBuilder.length() > 0) {
|
||||
itemsBuilder.setLength(itemsBuilder.length() - 1);
|
||||
}
|
||||
|
||||
// 返回格式化的列表字符串
|
||||
return itemsBuilder.length() > 0 ? itemsBuilder.toString() : "[]";
|
||||
}
|
||||
}
|
||||
+24
-9
@@ -9,6 +9,7 @@ import com.cf.imes.module.system.dal.dataobject.process.ProcessUserDO;
|
||||
import com.cf.imes.module.system.dal.mysql.process.ProcessUserMapper;
|
||||
import com.cf.imes.module.system.service.user.AdminUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -58,9 +59,9 @@ public class ProcessServiceImpl implements ProcessService {
|
||||
for (String user : usersId) {
|
||||
ProcessAndUserSaveReqVO processAndUserSaveReqVO = new ProcessAndUserSaveReqVO();
|
||||
// if (adminUserService.getUser(Long.parseLong(user)) != null){
|
||||
processAndUserSaveReqVO.setProcessId(processID);
|
||||
processAndUserSaveReqVO.setUserId(Long.parseLong(user));
|
||||
processUserService.createProcessUser(processAndUserSaveReqVO);
|
||||
processAndUserSaveReqVO.setProcessId(processID);
|
||||
processAndUserSaveReqVO.setUserId(Long.parseLong(user));
|
||||
processUserService.createProcessUser(processAndUserSaveReqVO);
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -76,13 +77,23 @@ public class ProcessServiceImpl implements ProcessService {
|
||||
ProcessDO updateProcess = BeanUtils.toBean(updateReqVO, ProcessDO.class);
|
||||
|
||||
processUserService.deleteProcessUserByProcess(updateReqVO.getId());
|
||||
if(updateReqVO.getUsers() != null && updateReqVO.getUsers() != ""){
|
||||
// 确保updateReqVO不是null,避免NullPointerException
|
||||
if (updateReqVO != null && (updateReqVO.getUsers() != null || updateReqVO.getUsers() != "")) {
|
||||
String[] usersId = updateReqVO.getUsers().split(",");
|
||||
for (String user : usersId) {
|
||||
ProcessAndUserSaveReqVO processAndUserSaveReqVO = new ProcessAndUserSaveReqVO();
|
||||
processAndUserSaveReqVO.setProcessId(updateReqVO.getId());
|
||||
processAndUserSaveReqVO.setUserId(Long.parseLong(user));
|
||||
processUserService.createProcessUser(processAndUserSaveReqVO);
|
||||
// 增加了对无法解析的用户ID的异常处理
|
||||
try {
|
||||
// 增加了对空字符串和仅包含空白字符的用户ID的验证
|
||||
if (!user.trim().isEmpty()) {
|
||||
ProcessAndUserSaveReqVO processAndUserSaveReqVO = new ProcessAndUserSaveReqVO();
|
||||
processAndUserSaveReqVO.setProcessId(updateProcess.getId());
|
||||
processAndUserSaveReqVO.setUserId(Long.parseLong(user));
|
||||
processUserService.createProcessUser(processAndUserSaveReqVO);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
// 处理NumberFormatException异常,例如记录日志
|
||||
System.err.println("用户ID " + user + " 无法解析为长整型。");
|
||||
}
|
||||
}
|
||||
}
|
||||
processMapper.updateById(updateProcess);
|
||||
@@ -94,6 +105,7 @@ public class ProcessServiceImpl implements ProcessService {
|
||||
validateProcessExists(id);
|
||||
// 删除
|
||||
processMapper.deleteById(id);
|
||||
|
||||
}
|
||||
|
||||
private void validateProcessExists(Long id) {
|
||||
@@ -104,9 +116,11 @@ public class ProcessServiceImpl implements ProcessService {
|
||||
|
||||
@Override
|
||||
public ProcessUserRespVO getProcess(Long id) {
|
||||
// 校验存在
|
||||
validateProcessExists(id);
|
||||
ProcessDO process = processMapper.selectById(id);
|
||||
List<ProcessUserDO> userIdListsByProcessId = processUserService.getProcessUser(id);
|
||||
StringBuilder userIdBuilder = new StringBuilder();
|
||||
List<ProcessUserDO> userIdListsByProcessId = processUserService.getProcessUser(id);
|
||||
if (userIdListsByProcessId != null) {
|
||||
for (ProcessUserDO processUser : userIdListsByProcessId) {
|
||||
if (processUser != null && processUser.getUserId() != null) {
|
||||
@@ -119,6 +133,7 @@ public class ProcessServiceImpl implements ProcessService {
|
||||
ProcessUserRespVO processUserRespVO = BeanUtils.toBean(process, ProcessUserRespVO.class);
|
||||
processUserRespVO.setUsers(userId);
|
||||
return processUserRespVO;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+16
-12
@@ -1,12 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.cf.imes.module.system.dal.mysql.processUser.ProcessUserMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.cf.com/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.cf.imes.module.system.dal.mysql.process.ProcessUserMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.cf.com/MyBatis/x-plugins/
|
||||
-->
|
||||
<delete id="deleteUserByProcessId" parameterType="Long">
|
||||
DELETE FROM process_user
|
||||
WHERE process_id = #{processId};
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
+4
-3
@@ -2,6 +2,7 @@ package com.cf.imes.module.system.service.process;
|
||||
|
||||
import com.cf.imes.module.system.controller.admin.process.vo.process.ProcessPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.process.vo.process.ProcessSaveReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.process.vo.process.ProcessUserSaveReqVO;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -39,7 +40,7 @@ public class ProcessServiceImplTest extends BaseDbUnitTest {
|
||||
@Test
|
||||
public void testCreateProcess_success() {
|
||||
// 准备参数
|
||||
ProcessSaveReqVO createReqVO = randomPojo(ProcessSaveReqVO.class).setId(null);
|
||||
ProcessUserSaveReqVO createReqVO = randomPojo(ProcessUserSaveReqVO.class).setId(null);
|
||||
System.out.println(createReqVO);
|
||||
|
||||
// 调用
|
||||
@@ -57,7 +58,7 @@ public class ProcessServiceImplTest extends BaseDbUnitTest {
|
||||
ProcessDO dbProcess = randomPojo(ProcessDO.class);
|
||||
processMapper.insert(dbProcess);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
ProcessSaveReqVO updateReqVO = randomPojo(ProcessSaveReqVO.class, o -> {
|
||||
ProcessUserSaveReqVO updateReqVO = randomPojo(ProcessUserSaveReqVO.class, o -> {
|
||||
o.setId(dbProcess.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
@@ -71,7 +72,7 @@ public class ProcessServiceImplTest extends BaseDbUnitTest {
|
||||
@Test
|
||||
public void testUpdateProcess_notExists() {
|
||||
// 准备参数
|
||||
ProcessSaveReqVO updateReqVO = randomPojo(ProcessSaveReqVO.class);
|
||||
ProcessUserSaveReqVO updateReqVO = randomPojo(ProcessUserSaveReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> processService.updateProcess(updateReqVO), PROCESS_NOT_EXISTS);
|
||||
|
||||
Reference in New Issue
Block a user