mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-13 13:22:07 +08:00
板材工序接口修改
This commit is contained in:
+105
-60
@@ -6,7 +6,9 @@ import com.cf.imes.module.executor.dal.dataobject.orderModuleExtra.OrderModuleEx
|
||||
import com.cf.imes.module.executor.service.order.OrderInputProcessor;
|
||||
import com.cf.imes.module.executor.util.FileTypeChangeUtil;
|
||||
import com.cf.imes.module.executor.util.deviseData.Detail;
|
||||
import com.cf.imes.module.executor.util.fileConversion.admin.files.excel.OrderPlateImportExcelVO;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -170,35 +172,33 @@ public class OrderController {
|
||||
@Parameter(name = "orderSaveReqVO", description = "生产单新增参数", required = true)
|
||||
})
|
||||
@PreAuthorize("@ss.hasPermission('executor:order:import')")
|
||||
public CommonResult<OrderImportRespVO> importExcel(@RequestPart("file") MultipartFile file,
|
||||
@RequestParam(value = "isAddPlate", required = false, defaultValue = "false") Boolean isAddPlate,
|
||||
@RequestParam(value = "upload", required = false, defaultValue = "false") Boolean upload,
|
||||
@RequestPart("orderSaveReqVO") OrderSaveReqVO createReqVO) throws IOException {
|
||||
OrderImportRespVO orderImportRespVO = OrderImportRespVO.builder().createOrder(new ArrayList<>())
|
||||
.updateOrder(new ArrayList<>()).failureOrder(new LinkedHashMap<>()).build();
|
||||
|
||||
public CommonResult<Map<Boolean, String>> importExcel(@RequestPart("file") MultipartFile file,
|
||||
@RequestParam(value = "isAddPlate", required = false, defaultValue = "false") Boolean isAddPlate,
|
||||
@RequestParam(value = "upload", required = false, defaultValue = "false") Boolean upload,
|
||||
@RequestPart("orderSaveReqVO") OrderSaveReqVO createReqVO) throws IOException {
|
||||
Map<Boolean, String> map = new HashMap<>();
|
||||
// 判断是否更新板材
|
||||
if(!isAddPlate){//不需要添加板材
|
||||
if(upload){
|
||||
if (!isAddPlate) {//不需要添加板材
|
||||
if (upload) {
|
||||
orderService.updateOrder(createReqVO);//更新
|
||||
orderImportRespVO.getUpdateOrder().add(createReqVO.getId()+"单独更新生产单成功");
|
||||
}else {
|
||||
map.put(true, "单独更新生产单成功");
|
||||
} else {
|
||||
Long id = orderService.createOrder(createReqVO);//新建
|
||||
orderImportRespVO.getCreateOrder().add(id + "单独新增生产单成功");
|
||||
map.put(true, "单独新增生产单成功");
|
||||
}
|
||||
return success(orderImportRespVO);
|
||||
}else {
|
||||
return success(map);
|
||||
} else {
|
||||
Long id = 0L;
|
||||
if (upload) {
|
||||
orderService.updateOrder(createReqVO);//更新
|
||||
id = createReqVO.getId();
|
||||
orderImportRespVO.getUpdateOrder().add(id + "新增生产单成功");
|
||||
map.put(true, "单独更新生产单成功");
|
||||
} else {
|
||||
id = orderService.createOrder(createReqVO);//新建
|
||||
orderImportRespVO.getCreateOrder().add(id + "新增生产单成功");
|
||||
map.put(true, "单独新增生产单成功");
|
||||
}
|
||||
// 解析导入文件,生成统一格式
|
||||
List<Detail> list = new ArrayList<>();
|
||||
List<?> list = new ArrayList<>();
|
||||
if (createReqVO.getDataType() == 1) {//CAD
|
||||
|
||||
} else if (createReqVO.getDataType() == 2) {//WebCAD
|
||||
@@ -208,17 +208,70 @@ public class OrderController {
|
||||
list = fileTypeChangeUtil.fileDataChange(file);
|
||||
}
|
||||
if (list == null || list.size() == 0) {
|
||||
orderImportRespVO.getFailureOrder().put("生产单导入错误", String.valueOf(fileTypeChangeUtil.getValue()));
|
||||
return success(orderImportRespVO);
|
||||
map.put(false, "导入文件有误");
|
||||
return success(map);
|
||||
}
|
||||
// OrderImportRespVO respVO = orderService.importOrderList(list , id , orderImportRespVO);
|
||||
orderInputProcessor.input(list , id);
|
||||
return success(orderImportRespVO);
|
||||
orderInputProcessor.input((List<Detail>) list, id);
|
||||
// 是否新增成功需要返回
|
||||
map.putIfAbsent(true, "文件导入成功");
|
||||
return success(map);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 清理生产单
|
||||
// 导出错误的excel
|
||||
@PostMapping("/import-excel")
|
||||
@Operation(summary = "生产单导入新增")
|
||||
@Parameters({
|
||||
@Parameter(name = "file", description = "Excel 文件", required = true),
|
||||
@Parameter(name = "isAddPlate", description = "是否为生产单新增板材", example = "false"),
|
||||
@Parameter(name = "upload", description = "是 更新、否 新建", example = "false"),
|
||||
@Parameter(name = "orderSaveReqVO", description = "生产单新增参数", required = true)
|
||||
})
|
||||
@PreAuthorize("@ss.hasPermission('executor:order:importExcel')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportExcel(@RequestPart("file") MultipartFile file,
|
||||
@RequestParam(value = "isAddPlate", required = false, defaultValue = "false") Boolean isAddPlate,
|
||||
@RequestParam(value = "upload", required = false, defaultValue = "false") Boolean upload,
|
||||
@RequestPart("orderSaveReqVO") OrderSaveReqVO createReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
// 判断是否更新板材
|
||||
if (!isAddPlate) {//不需要添加板材
|
||||
if (upload) {
|
||||
orderService.updateOrder(createReqVO);//更新
|
||||
} else {
|
||||
Long id = orderService.createOrder(createReqVO);//新建
|
||||
}
|
||||
} else {
|
||||
Long id = 0L;
|
||||
if (upload) {
|
||||
orderService.updateOrder(createReqVO);//更新
|
||||
id = createReqVO.getId();
|
||||
} else {
|
||||
// id = orderService.createOrder(createReqVO);//新建
|
||||
}
|
||||
// 解析导入文件,生成统一格式
|
||||
List<?> list = new ArrayList<>();
|
||||
if (createReqVO.getDataType() == 1) {//CAD
|
||||
|
||||
} else if (createReqVO.getDataType() == 2) {//WebCAD
|
||||
|
||||
} else if (createReqVO.getDataType() == 3) {//Excel
|
||||
// 文件数据读取
|
||||
list = fileTypeChangeUtil.fileDataChange(file);
|
||||
}
|
||||
if (!fileTypeChangeUtil.getFlag()) {
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "生产单导入错误返回.xlsx", "数据", OrderPlateImportExcelVO.class,
|
||||
BeanUtils.toBean(list, OrderPlateImportExcelVO.class));
|
||||
}
|
||||
orderInputProcessor.input((List<Detail>) list, id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 清理生产单
|
||||
@DeleteMapping("/clean")
|
||||
@Operation(summary = "清理生产单")
|
||||
@Parameter(name = "orderId", description = "生产单编号", required = true, example = "1024")
|
||||
@@ -228,7 +281,7 @@ public class OrderController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
// 获取当前条件下所有生产单信息
|
||||
// 获取当前条件下所有生产单信息
|
||||
@GetMapping("/allOrder")
|
||||
@Operation(summary = "获得所有生产单")
|
||||
@PreAuthorize("@ss.hasPermission('executor:order:query')")
|
||||
@@ -237,7 +290,7 @@ public class OrderController {
|
||||
return success(BeanUtils.toBean(pageResult, OrderRespVO.class));
|
||||
}
|
||||
|
||||
// 获得 房间和柜体 信息
|
||||
// 获得 房间和柜体 信息
|
||||
@GetMapping("/get-room")
|
||||
@Operation(summary = "获得房间——柜体 基本信息")
|
||||
@Parameter(name = "orderId", description = "生产单编号", required = true, example = "1024")
|
||||
@@ -248,7 +301,7 @@ public class OrderController {
|
||||
}
|
||||
|
||||
|
||||
// 获得模组 —— 模块信息
|
||||
// 获得模组 —— 模块信息
|
||||
@GetMapping("/get-moduleDetails")
|
||||
@Operation(summary = "获得模组——模块信息")
|
||||
@Parameters({
|
||||
@@ -260,11 +313,11 @@ public class OrderController {
|
||||
public CommonResult<List<OrderModuleExtraDO>> getModule(@RequestParam("orderId") Long orderId,
|
||||
@RequestParam(value = "roomId", required = false) Long roomId,
|
||||
@RequestParam(value = "bodyId", required = false) Long bodyId) {
|
||||
List<OrderModuleExtraDO> moduleDOList = orderService.getModule(orderId ,roomId ,bodyId);
|
||||
List<OrderModuleExtraDO> moduleDOList = orderService.getModule(orderId, roomId, bodyId);
|
||||
return success(moduleDOList);
|
||||
}
|
||||
|
||||
// 删除柜体
|
||||
// 删除柜体
|
||||
@DeleteMapping("/delete-body")
|
||||
@Operation(summary = "删除柜体")
|
||||
@Parameters({
|
||||
@@ -272,55 +325,47 @@ public class OrderController {
|
||||
@Parameter(name = "bodyIds", description = "柜体编号集合", required = true, example = "1,2")
|
||||
})
|
||||
@PreAuthorize("@ss.hasPermission('executor:order:delete')")
|
||||
public CommonResult<Boolean> deleteBody(@RequestParam("orderId")Long orderId , @RequestParam("bodyIds")Set<Long> bodyIds){
|
||||
orderService.deleteBodyByOrder(orderId,bodyIds);
|
||||
public CommonResult<Boolean> deleteBody(@RequestParam("orderId") Long orderId, @RequestParam("bodyIds") Set<Long> bodyIds) {
|
||||
orderService.deleteBodyByOrder(orderId, bodyIds);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
// 柜体数据获取,需要加上柜体的属性
|
||||
// 柜体数据获取,需要加上柜体的属性
|
||||
@GetMapping("/get-body")
|
||||
@Operation(summary = "生产单柜体数据获取")
|
||||
@Parameter(name = "orderId", description = "生产单编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('executor:order:query')")
|
||||
public CommonResult<List<OrderBodyRespVO>> getBody(@RequestParam("orderId")Long orderId){
|
||||
public CommonResult<List<OrderBodyRespVO>> getBody(@RequestParam("orderId") Long orderId) {
|
||||
return success(BeanUtils.toBean(orderService.getBody(orderId), OrderBodyRespVO.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* api获取数据接口(用户从其他应用点击数据传输,首先进行用户数据验证【用户传入token,本生产系统获得token之后,调用erp接口,进行用户账号数据
|
||||
* 获取,获取的数据进行本系统的登陆,获取本系统的token】,然后进行数据推送【redis首先缓存数据,生成唯一数据标识符,返回给应用用户】,再用户进入
|
||||
* 本系统的生产单新增页面,进行新增生产单数据的传入(有问题)
|
||||
* 调用本系统的接口,进行数据传输,
|
||||
* 传输成功之后,返回数据给用户,用户进行数据查看,
|
||||
*/
|
||||
|
||||
@GetMapping("api-import")
|
||||
@Operation(summary = "api调用传入设计数据")
|
||||
@PostMapping("file-import")
|
||||
@Operation(summary = "文件上产接口")
|
||||
@Parameters({
|
||||
@Parameter(name = "body", description = "api传输数据", required = true)
|
||||
// ,
|
||||
// @Parameter(name = "isAddPlate", description = "是否为生产单新增板材", example = "false"),
|
||||
// @Parameter(name = "upload", description = "是 更新、否 新建", example = "false"),
|
||||
// @Parameter(name = "orderSaveReqVO", description = "生产单新增参数", required = true)
|
||||
@Parameter(name = "file", description = "文件", required = false),
|
||||
@Parameter(name = "isAddPlate", description = "是否为生产单新增板材", example = "false"),
|
||||
@Parameter(name = "upload", description = "是 更新、否 新建", example = "false"),
|
||||
@Parameter(name = "orderSaveReqVO", description = "生产单新增参数", required = true),
|
||||
@Parameter(name = "type", description = "文件类型", required = true)
|
||||
})
|
||||
@PreAuthorize("@ss.hasPermission('executor:order:import')")
|
||||
public CommonResult<OrderImportRespVO> apiImport(@RequestPart("data") String data
|
||||
// ,
|
||||
// @RequestParam(value = "isAddPlate", required = false, defaultValue = "false") Boolean isAddPlate,
|
||||
// @RequestParam(value = "upload", required = false, defaultValue = "false") Boolean upload,
|
||||
// @RequestPart("orderSaveReqVO") OrderSaveReqVO createReqVO
|
||||
) {
|
||||
@PreAuthorize("@ss.hasPermission('executor:fileData:import')")
|
||||
public CommonResult<OrderImportRespVO> apiImport(@RequestPart(value = "file", required = false) MultipartFile file,
|
||||
@RequestParam(value = "isAddPlate", required = false, defaultValue = "false") Boolean isAddPlate,
|
||||
@RequestParam(value = "upload", required = false, defaultValue = "false") Boolean upload,
|
||||
@RequestPart("orderSaveReqVO") OrderSaveReqVO createReqVO,
|
||||
@RequestParam(value = "type", required = false, defaultValue = "cf_cad") String type,
|
||||
final HttpServletResponse respons) throws IOException {
|
||||
|
||||
OrderImportRespVO orderImportRespVO = OrderImportRespVO.builder().createOrder(new ArrayList<>())
|
||||
.updateOrder(new ArrayList<>()).failureOrder(new LinkedHashMap<>()).build();
|
||||
|
||||
// OrderImportRespVO respVO = orderService.importOrderList(list , id , orderImportRespVO);
|
||||
// json转换
|
||||
// List<Detail> list = fileDataChangeUtil.fileDataChange(data);
|
||||
// orderInputProcessor.input(list , 1L);
|
||||
System.out.println("webcad数据: " + data);
|
||||
// 数据格式转换,返回转换完成的数据(传入文件类型,和文件类容),判断需要使用那种解析之后,进行数据的转换
|
||||
List<?> list = fileTypeChangeUtil.chooseType(file, type);
|
||||
if (fileTypeChangeUtil.getFlag()) {//文件数据转换成功,进行数据填入
|
||||
|
||||
}
|
||||
|
||||
return success(orderImportRespVO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -37,11 +37,11 @@ public class OrderGroupDO extends BaseDO {
|
||||
/**
|
||||
* 加工组类型id,依据同一生产单的同一房间的同一柜体的相同加工组类型,由服务端生成
|
||||
*/
|
||||
private Long groupId;
|
||||
private Long groupTypeId;
|
||||
/**
|
||||
* 加工组类型
|
||||
*/
|
||||
private String groupType;
|
||||
private String groupTypeName;
|
||||
/**
|
||||
* 模块名称
|
||||
*/
|
||||
|
||||
+3
-3
@@ -111,8 +111,8 @@ public class OrderInputProcessor {
|
||||
.build(),
|
||||
Collectors.groupingBy(e ->
|
||||
OrderGroupDO.builder()
|
||||
.groupId((long) e.getIBoardProdInfo().getSynthesis())
|
||||
.groupType(e.getIBoardProdInfo().getCombinationName())
|
||||
.groupTypeId((long) e.getIBoardProdInfo().getSynthesis())
|
||||
.groupTypeName(e.getIBoardProdInfo().getCombinationName())
|
||||
.name(e.getIBoardProdInfo().getSynthesisTypeName())
|
||||
.build()
|
||||
)
|
||||
@@ -148,7 +148,7 @@ public class OrderInputProcessor {
|
||||
.width(e.getIBoardProdInfo().getWidth())
|
||||
.height(e.getIBoardProdInfo().getHeight())
|
||||
.thickness(e.getIBoardProdInfo().getThickness())
|
||||
.groupType(orderGroupDO.getGroupType())
|
||||
.groupType(orderGroupDO.getGroupTypeName())
|
||||
.build()
|
||||
).toList();
|
||||
List<PartsModuleExtra> partsModuleExtras = k.getValue().stream().filter(e -> e.getIBoardProdInfo().getGoodType() == 1)
|
||||
|
||||
+4
-4
@@ -235,7 +235,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
// 板数量
|
||||
final Double[] plateCountByCombination = {0.0};
|
||||
OrderGroupDO orderGroupDO = OrderGroupDO.builder().orderId(id).bodyId(bodyId)
|
||||
.groupId(Long.valueOf(synthesis)).groupType(listCombinationName.get(0).getIBoardProdInfo().getSynthesisTypeName()).name(combinationName).build();
|
||||
.groupTypeId(Long.valueOf(synthesis)).groupTypeName(listCombinationName.get(0).getIBoardProdInfo().getSynthesisTypeName()).name(combinationName).build();
|
||||
|
||||
orderGroupMapper.insert(orderGroupDO);
|
||||
Long groupId = orderGroupDO.getId();
|
||||
@@ -251,7 +251,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
|
||||
plateMapper.insert(plateDO);
|
||||
productRespVOS.add(new ProductRespVO().setRoomId(roomId).setRoomName(roomName).setBodyId(bodyId).setBodyName(cabinetName)
|
||||
.setGroupId(groupId).setGroupTypeId(orderGroupDO.getGroupId()).setGroupTypeName(orderGroupDO.getName())
|
||||
.setGroupId(groupId).setGroupTypeId(orderGroupDO.getGroupTypeId()).setGroupTypeName(orderGroupDO.getName())
|
||||
.setGoodType(1).setGoodName(plateDO.getName()).setUnits("片").setNum(1.0));
|
||||
Long plateId = plateDO.getId();
|
||||
orderImportRespVO.getCreateOrder().add(plateDO.getId() + "板材存入生成id");
|
||||
@@ -275,7 +275,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
.num(Double.valueOf(plateOrParts.getIBoardProdInfo().getGoodsNumber())).build();
|
||||
orderItemMapper.insert(orderItemDO);
|
||||
productRespVOS.add(new ProductRespVO().setRoomId(roomId).setRoomName(roomName).setBodyId(bodyId).setBodyName(cabinetName)
|
||||
.setGroupId(groupId).setGroupTypeId(orderGroupDO.getGroupId()).setGroupTypeName(orderGroupDO.getName())
|
||||
.setGroupId(groupId).setGroupTypeId(orderGroupDO.getGroupTypeId()).setGroupTypeName(orderGroupDO.getName())
|
||||
.setGoodType(1).setGoodName(orderPartsDO.getName()).setUnits(orderPartsDO.getUnit()).setNum(orderItemDO.getNum()));
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
|
||||
|
||||
});
|
||||
fileTypeChangeUtil.fileDataChangeToJson(list, id);
|
||||
// fileTypeChangeUtil.fileDataChangeToJson(list, id);
|
||||
return orderImportRespVO;
|
||||
}
|
||||
|
||||
|
||||
+10
-7
@@ -1,26 +1,29 @@
|
||||
package com.cf.imes.module.executor.util;
|
||||
|
||||
import com.cf.imes.module.executor.util.deviseData.Detail;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 生产单新增传入文件格式转换工具
|
||||
*/
|
||||
public interface FileTypeChangeUtil {
|
||||
// 文件数据格式转换
|
||||
List<Detail> fileDataChange(MultipartFile file) throws IOException;
|
||||
// List<Detail>转json,并且文件压缩存储
|
||||
void fileDataChangeToJson(List<Detail> detailList , Long orderId) throws IOException;
|
||||
<T> List<?> fileDataChange(MultipartFile file) throws IOException;
|
||||
|
||||
// Api数据格式转换
|
||||
|
||||
// ds数据转换
|
||||
|
||||
Map<String, String> getValue();
|
||||
// 数据转换成功判断
|
||||
boolean getFlag();
|
||||
|
||||
// 根据文件类型判断使用那种方式进行数据转换
|
||||
default <T> List<?> chooseType(MultipartFile file,String type) throws IOException {
|
||||
if (type.equals("cf_cad"))
|
||||
return fileDataChange(file);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-3
@@ -13,12 +13,11 @@ import lombok.experimental.Accessors;
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = false) // 设置 chain = false,避免生产单导入有问
|
||||
public class HoleDetail {
|
||||
|
||||
private Integer holeId; //孔ID
|
||||
private float holeType;// 孔类型(0大孔, 10小孔, 20木削, 21木削大孔, 30层板钉, 40通孔, 50连接杆, -10造型孔)
|
||||
private float faceType; // 孔面类型(0正面, 1反面, 2侧面)
|
||||
private Integer holeType;// 孔类型(0大孔, 10小孔, 20木削, 21木削大孔, 30层板钉, 40通孔, 50连接杆, -10造型孔)
|
||||
private Integer faceType; // 孔面类型(0正面, 1反面, 2侧面)
|
||||
private float pointX;
|
||||
private float pointY;
|
||||
private float pointZ;
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.cf.imes.module.executor.util.deviseData.dataTwo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 基准位置,用于画图
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class BasePosition {
|
||||
private String basePoint;// 基准点
|
||||
|
||||
private String basePointX;// 基准点X坐标
|
||||
|
||||
private String basePointY;// 基准点Y坐标
|
||||
|
||||
private String basePointZ;// 基准点Z坐标
|
||||
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.cf.imes.module.executor.util.deviseData.dataTwo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 孔明细,板上的孔的明细
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class HoleDetail {
|
||||
|
||||
private String faceType; // 打孔面(0正面, 1反面, 2侧面)
|
||||
private String holeType;// 孔类型(0大孔, 10小孔, 20木削, 21木削大孔, 30层板钉, 40通孔, 50连接杆, -10造型孔)
|
||||
private String holeName;// 孔名称,用于类型相同的孔,进行分组区分,一组的孔名称相同
|
||||
|
||||
// 孔的起点坐标
|
||||
private Double startX;
|
||||
private Double startY;
|
||||
private Double startZ;
|
||||
|
||||
// 打孔的半径
|
||||
private float radius; //孔半径
|
||||
|
||||
// 孔的终点坐标
|
||||
private Double endX;
|
||||
private Double endY;
|
||||
private Double endZ;
|
||||
|
||||
private float angle; //角度
|
||||
|
||||
}
|
||||
+21
-3
@@ -17,21 +17,39 @@ import java.util.List;
|
||||
public class IBoardProdInfo {
|
||||
|
||||
// 商品信息
|
||||
private String goodsId; // 商品编码
|
||||
private String goodsNo; // 商品编码
|
||||
private String goodsName; //商品名称
|
||||
private int goodType; //商品类型,用于筛选是板材还是配件类,可传入文字(需做转换)
|
||||
private String goodType; //商品类型,用于筛选是板材还是配件类,可传入文字(需做转换)
|
||||
private String material; //材质
|
||||
private String color; //颜色
|
||||
private String factory; //商品生产厂商
|
||||
private String brand; //商品品牌
|
||||
private String model; //商品型号
|
||||
private String spec; //商品规格
|
||||
private Double thickness;//规格-板厚 板厚,成品和开料都是一样的
|
||||
private float thickness;//规格-板厚 板厚,成品和开料都是一样的
|
||||
private String unit; //商品单位
|
||||
|
||||
// 当有板件时就有板件信息
|
||||
private float goodsNumber; //产品数量为特殊处理,板件和配件都有数量
|
||||
|
||||
// 板材中与造型和轮廓无关的信息
|
||||
private Long plateId; //板件Id,存入数据库之后的主键
|
||||
private Long goodsId;//商品Id,板材所用商品编号
|
||||
private String plateNo;//自定义板号
|
||||
private String name; //板件名称
|
||||
private Integer texture; //纹路 纹路(0正纹1可翻转2反纹)
|
||||
private Integer typographicFace; //排版面 排钻类型(0正面1反面2随意面)
|
||||
private Integer openDoorType; //开门类型 0非门板,1左开,2右开,3上翻,4下翻
|
||||
private Boolean isRect; //是否为矩形
|
||||
|
||||
|
||||
// 板件开料数据
|
||||
//封边数据,矩形存的顺序为左、右、上、下,非矩形存的顺序为从起始点开始,方向为顺时针
|
||||
private float[] sealDate;
|
||||
|
||||
// 这里的数据都是矩形板件才有
|
||||
private float splitHeight; //开料长
|
||||
private float splitWidth; //开料宽
|
||||
private float splitThickness; //开料厚度
|
||||
|
||||
}
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.cf.imes.module.executor.util.deviseData.dataTwo;
|
||||
|
||||
import com.cf.imes.module.executor.controller.admin.plan.dto.Point;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 轮廓数据
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = false) // 设置 chain = false,避免生产单导入有问
|
||||
public class IContourData {
|
||||
private List<Point> pts; //点集(二维向量(x,y))
|
||||
private Double[] buls; //凸度(0直线段 >0逆时针方向 <0顺时针方向)
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.cf.imes.module.executor.util.deviseData.dataTwo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 板的造型数据
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = false) // 设置 chain = false,避免生产单导入有问
|
||||
public class IOriginModelingData {
|
||||
|
||||
private float knifeRadius; // 刀半径
|
||||
|
||||
private float thickness;// 厚度
|
||||
private Integer dir;// 方向
|
||||
|
||||
private IContourData outline; // 轮廓,造型最外围的轮廓数据
|
||||
private List<IContourData> holes; //孔轮廓
|
||||
|
||||
|
||||
private float addLen; // 槽加长
|
||||
private float addWidth; // 槽加宽
|
||||
private float addDepth; // 槽加深
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.cf.imes.module.executor.util.deviseData.dataTwo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 造型明细
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = false) // 设置 chain = false,避免生产单导入有问
|
||||
public class ModelDetail {
|
||||
|
||||
private String typographicFace; //造型排版面 0正面, 1反面, 2侧面
|
||||
|
||||
private String knifeName; //造像使用刀具名称
|
||||
private float knifeRadius; //刀半径
|
||||
|
||||
private float depth; //造型深度
|
||||
|
||||
private IOriginModelingData originModeling;//造型数据
|
||||
private List<PointList> pointList; //点列表
|
||||
private List<OffSetList> offSetList; //偏移量列表 //模块偏移数据
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.cf.imes.module.executor.util.deviseData.dataTwo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 偏移量列表 模块偏移数据
|
||||
* 在有用到二维刀路的时候,需要这个数据
|
||||
* 注:1、有用到type之类需要转换类型的诗句,将type全部存原有的值,然后在接口这一块,通过字典进行进行转换
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = false) // 设置 chain = false,避免生产单导入有问
|
||||
public class OffSetList {
|
||||
|
||||
private String faceType;// 面向类型(0正面, 1反面, 2侧面)
|
||||
|
||||
// 二维刀路的属性
|
||||
private float radius;//刀的半径
|
||||
private String name; //刀的名称
|
||||
private float angle;//角度
|
||||
|
||||
// 刀路的偏移值
|
||||
private float value; // 刀路的偏倚值
|
||||
private float deep;//下刀的深度
|
||||
|
||||
}
|
||||
+22
-10
@@ -16,22 +16,34 @@ import java.util.Map;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PlateDetail {
|
||||
// 柜体成倍拆单的倍数
|
||||
private Integer multiNum;
|
||||
|
||||
// 板件所属信息
|
||||
private String roomsName; //房间名称
|
||||
private String cabinetsName; //柜体名
|
||||
// 柜体 长 宽 深
|
||||
private Double width;
|
||||
private Double height;
|
||||
private Double depth;
|
||||
|
||||
// 柜体成倍拆单的倍数
|
||||
private Integer multiNum;
|
||||
|
||||
// 板材所属加工组
|
||||
// 柜体信息 长 宽 深
|
||||
private float width;
|
||||
private float height;
|
||||
private float depth;
|
||||
// 板材所属加工组
|
||||
private List<String> synthesis;// 板件加工组Group的名称,可以有多个
|
||||
private String synthesisName;// 加工组中Group中每个小加工组的名称
|
||||
|
||||
// 商品基本信息
|
||||
private IBoardProdInfo iBoardProdInfo;
|
||||
|
||||
private Map<String,String> remark;
|
||||
// 基准位置,用于画图
|
||||
private BasePosition basePosition;
|
||||
|
||||
// 轮廓数据、造型数据
|
||||
private List<PointDetail> pointDetail ; //点明细,表示小板外围轮廓的几个转折点
|
||||
private List<HoleDetail> holeDetail ; //孔明细,表示板上的孔
|
||||
private List<ModelDetail> contourDetail ; //造型明细
|
||||
|
||||
private List<HoleDetail> sideHoleDetail;//侧面孔明细
|
||||
private List<ModelDetail> sideModelDetail ; //侧面造型明细
|
||||
|
||||
// 备注
|
||||
private Map<String,String> remark;// 板件备注
|
||||
}
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.cf.imes.module.executor.util.deviseData.dataTwo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 点明细 , 表示小板外围轮廓的几个转折点
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = false) // 设置 chain = false,避免生产单导入有问
|
||||
public class PointDetail {
|
||||
|
||||
// 表明点的顺序,或是下一个点是哪个点
|
||||
private Integer pointId;
|
||||
|
||||
// 点的位置信息
|
||||
private Double pointX;
|
||||
private Double pointY;
|
||||
private Double curve;//曲线
|
||||
|
||||
// 点的封边尺寸
|
||||
private float SealSize;//封边尺寸,封边的厚度,长同边长
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.cf.imes.module.executor.util.deviseData.dataTwo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 点列表
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = false) // 设置 chain = false,避免生产单导入有问
|
||||
public class PointList {
|
||||
|
||||
private Integer lineId;//纹路Id
|
||||
private Integer pointId;//点Id
|
||||
|
||||
// 点的位置信息
|
||||
private Double pointX;
|
||||
private Double pointY;
|
||||
private Double radius;
|
||||
|
||||
private float curve; // 曲线
|
||||
private float depth; //曲线深度
|
||||
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
package com.cf.imes.module.executor.util.fileConversion.admin.files.excel;
|
||||
|
||||
import com.alibaba.excel.exception.ExcelRuntimeException;
|
||||
|
||||
|
||||
public class ExcelDataContentException extends ExcelRuntimeException {
|
||||
}
|
||||
+28
-22
@@ -5,24 +5,20 @@ import com.alibaba.excel.event.AnalysisEventListener;
|
||||
import com.alibaba.excel.exception.ExcelDataConvertException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
public final class ExcelListener<T> extends AnalysisEventListener<T> {
|
||||
public final class ExcelListener<T> extends AnalysisEventListener<OrderPlateImportExcelVO> {
|
||||
|
||||
/**
|
||||
* 自定义用于暂时存储data
|
||||
* 可以通过实例获取该值
|
||||
*/
|
||||
private List<T> datas = new ArrayList<>();
|
||||
private List<OrderPlateImportExcelVO> datas = new ArrayList<>();
|
||||
|
||||
private boolean flag = true;
|
||||
|
||||
private String value = null;
|
||||
|
||||
private Map<Integer, String> valueMap = new HashMap<>();
|
||||
|
||||
|
||||
/**
|
||||
@@ -32,7 +28,24 @@ public final class ExcelListener<T> extends AnalysisEventListener<T> {
|
||||
* @param context 内容
|
||||
*/
|
||||
@Override
|
||||
public void invoke(T data, AnalysisContext context) {
|
||||
public void invoke(OrderPlateImportExcelVO data, AnalysisContext context) {
|
||||
// 根据列来确定是那一条的数据,然后将错误的数据插入其中
|
||||
// 这里要判断数据的合法性,不合法的数据直接插入到错误数据中
|
||||
if (data.getGoodType() == 0) {
|
||||
data.setResult("商品类型未选择");
|
||||
flag = false;
|
||||
} else {
|
||||
if (!data.isValidGoods()){
|
||||
data.setResult("商品信息填写有误");
|
||||
flag = false;
|
||||
}
|
||||
if (data.getGoodType() == 1) { //板材
|
||||
if (!data.isValidRawGoods()) {
|
||||
data.setResult("板材信息填写有误");
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
datas.add(data);
|
||||
}
|
||||
|
||||
@@ -56,21 +69,13 @@ public final class ExcelListener<T> extends AnalysisEventListener<T> {
|
||||
*/
|
||||
@Override
|
||||
public void onException(Exception exception, AnalysisContext context) {
|
||||
log.info("有异常");
|
||||
this.flag = false;
|
||||
// 如果是某一个单元格的转换异常 能获取到具体行号
|
||||
// 如果要获取头的信息 配合invokeHeadMap使用
|
||||
if (exception instanceof ExcelDataConvertException) {
|
||||
ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException) exception;
|
||||
log.error("第{}行,第{}列解析异常,数据为:{}", excelDataConvertException.getRowIndex() + 1,
|
||||
excelDataConvertException.getColumnIndex() + 1, excelDataConvertException.getCellData());
|
||||
value = value + String.valueOf(new RuntimeException("第" + (excelDataConvertException.getRowIndex() + 1) + "行" +
|
||||
",第" + (excelDataConvertException.getColumnIndex() + 1) + "列读取错误")) ;
|
||||
}
|
||||
if (exception instanceof RuntimeException) {
|
||||
RuntimeException runtimeException = (RuntimeException) exception;
|
||||
log.error("读取异常:{}", runtimeException.getMessage());
|
||||
value = value + runtimeException.getMessage();
|
||||
valueMap.put(excelDataConvertException.getRowIndex() + 1 , String.valueOf(new RuntimeException("第" + (excelDataConvertException.getRowIndex() + 1) + "行" +
|
||||
",第" + (excelDataConvertException.getColumnIndex() + 1) + "列数据格式有误,读取失败")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +84,7 @@ public final class ExcelListener<T> extends AnalysisEventListener<T> {
|
||||
*
|
||||
* @return 返回读取的数据集合
|
||||
**/
|
||||
public List<T> getDatas() {
|
||||
public List<OrderPlateImportExcelVO> getDatas() {
|
||||
return datas;
|
||||
}
|
||||
|
||||
@@ -97,7 +102,8 @@ public final class ExcelListener<T> extends AnalysisEventListener<T> {
|
||||
*
|
||||
* @return String
|
||||
**/
|
||||
public String getValue() {
|
||||
return value;
|
||||
public Map<Integer, String> getValueMap() {
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
}
|
||||
+28
-85
@@ -1,16 +1,11 @@
|
||||
package com.cf.imes.module.executor.util.fileConversion.admin.files.excel;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.module.executor.util.FileTypeChangeUtil;
|
||||
import com.cf.imes.module.executor.util.ZLibUtils;
|
||||
import com.cf.imes.module.executor.util.deviseData.Detail;
|
||||
import com.cf.imes.module.executor.util.deviseData.IBoardProdInfo;
|
||||
import com.cf.imes.module.infra.api.file.FileApi;
|
||||
import com.cf.imes.module.infra.api.file.dto.FileCreateReqDTO;
|
||||
import com.cf.imes.module.system.api.dict.DictDataApi;
|
||||
import com.cf.imes.module.system.enums.DictTypeConstants;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -19,7 +14,6 @@ import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 实现数据格式转换
|
||||
@@ -28,99 +22,48 @@ import java.util.Map;
|
||||
@Validated
|
||||
public class FileTypeChangeRealize implements FileTypeChangeUtil {
|
||||
|
||||
private String valueErr = "";
|
||||
@Resource
|
||||
private DictDataApi dictDataApi;
|
||||
|
||||
private Boolean flag = true;
|
||||
|
||||
@Resource
|
||||
private FileApi fileApi;
|
||||
|
||||
@Resource
|
||||
private DictDataApi dictDataApi;
|
||||
private OrderExcelUtil orderExcelUtil;
|
||||
|
||||
@Override
|
||||
public List<Detail> fileDataChange(MultipartFile file) throws IOException {
|
||||
public List<?> fileDataChange(MultipartFile file) throws IOException {
|
||||
List<OrderPlateImportExcelVO> orderPlateImportExcelVOS = orderExcelUtil.read(file, OrderPlateImportExcelVO.class);
|
||||
|
||||
// 判断上传数据解析是否有误
|
||||
if (!orderExcelUtil.getFlag()){
|
||||
this.flag = false;
|
||||
System.out.println(orderPlateImportExcelVOS);
|
||||
orderExcelUtil.clear();
|
||||
return orderPlateImportExcelVOS;
|
||||
}
|
||||
|
||||
List<Detail> details = new ArrayList<>();
|
||||
List<OrderPlateImportExcelVO> orderPlateImportExcelVOS = OrderExcelUtil.read(file, OrderPlateImportExcelVO.class);
|
||||
System.out.println(orderPlateImportExcelVOS);
|
||||
|
||||
// if (orderPlateImportExcelVOS == null || orderPlateImportExcelVOS.isEmpty()) {
|
||||
// return details;
|
||||
// }
|
||||
//
|
||||
// StringBuilder value = new StringBuilder();
|
||||
//
|
||||
//
|
||||
// for (OrderPlateImportExcelVO orderPlateImportExcelVO : orderPlateImportExcelVOS) {
|
||||
// orderPlateImportExcelVO.setRemark(orderPlateImportExcelVO.remarkJSON());
|
||||
// if(dictDataApi.getDictData(DictTypeConstants.SYNTHESIS_TYPE,String.valueOf(orderPlateImportExcelVO.getSynthesis())).getData() != null){
|
||||
// String synthesisTypeName = dictDataApi.getDictData(DictTypeConstants.SYNTHESIS_TYPE,String.valueOf(orderPlateImportExcelVO.getSynthesis())).getData().getLabel();
|
||||
// orderPlateImportExcelVO.setSynthesisTypeName(synthesisTypeName);
|
||||
// }
|
||||
// handleOrderPlateImportExcelVO(orderPlateImportExcelVO, value);
|
||||
// if(flag){
|
||||
// Detail detail = Detail.builder()
|
||||
// .iBoardProdInfo(BeanUtils.toBean(orderPlateImportExcelVO, IBoardProdInfo.class))
|
||||
// .build();
|
||||
// details.add(detail);
|
||||
// }else {
|
||||
// details = null;
|
||||
// System.out.println(value.toString());
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// return details;
|
||||
return null;
|
||||
}
|
||||
|
||||
private void handleOrderPlateImportExcelVO(OrderPlateImportExcelVO orderPlateImportExcelVO, StringBuilder value) {
|
||||
if (orderPlateImportExcelVO.getGoodType() == 0) {
|
||||
appendError(value, " 商品类别未填写 ", orderPlateImportExcelVO);
|
||||
flag = false;
|
||||
} else {
|
||||
if (!orderPlateImportExcelVO.isVail()) {
|
||||
if (orderPlateImportExcelVO.getGoodType() == 1) {
|
||||
if (!orderPlateImportExcelVO.isValidRawGoods()) {
|
||||
appendError(value, " 板材信息填写有误 ", orderPlateImportExcelVO);
|
||||
flag = false;
|
||||
}
|
||||
} else {
|
||||
if (!orderPlateImportExcelVO.isValidParts()) {
|
||||
appendError(value, " 配件信息填写有误 ", orderPlateImportExcelVO);
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
for (OrderPlateImportExcelVO orderPlateImportExcelVO : orderPlateImportExcelVOS) {
|
||||
orderPlateImportExcelVO.setRemark(orderPlateImportExcelVO.remarkJSON());
|
||||
if(dictDataApi.getDictData(DictTypeConstants.SYNTHESIS_TYPE,String.valueOf(orderPlateImportExcelVO.getSynthesis())).getData() != null){
|
||||
String synthesisTypeName = dictDataApi.getDictData(DictTypeConstants.SYNTHESIS_TYPE,String.valueOf(orderPlateImportExcelVO.getSynthesis())).getData().getLabel();
|
||||
orderPlateImportExcelVO.setSynthesisTypeName(synthesisTypeName);
|
||||
}
|
||||
|
||||
Detail detail = Detail.builder()
|
||||
.iBoardProdInfo(BeanUtils.toBean(orderPlateImportExcelVO, IBoardProdInfo.class))
|
||||
.build();
|
||||
details.add(detail);
|
||||
}
|
||||
}
|
||||
|
||||
private void appendError(StringBuilder value, String errorMessage, OrderPlateImportExcelVO orderPlateImportExcelVO) {
|
||||
value.append(orderPlateImportExcelVO.getOrdinal())
|
||||
.append(orderPlateImportExcelVO.getGoodsName())
|
||||
.append(errorMessage);
|
||||
valueErr = valueErr + value.toString();
|
||||
orderExcelUtil.clear();
|
||||
return details;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileDataChangeToJson(List<Detail> detailList , Long orderId) throws IOException {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String detailListJson = objectMapper.writeValueAsString(detailList);
|
||||
byte[] jsonData = detailListJson.getBytes();
|
||||
|
||||
// 使用 Zlib 压缩算法进行压缩
|
||||
byte[] compressedData = ZLibUtils.compress(jsonData);
|
||||
|
||||
// 将压缩后的数据写入文件
|
||||
FileCreateReqDTO fileCreateReqDTO = new FileCreateReqDTO().setName(orderId + ".json")
|
||||
.setContent(compressedData);
|
||||
CommonResult<String> pathNew = fileApi.createFile(fileCreateReqDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getValue() {
|
||||
Map<String, String> err = OrderExcelUtil.getValue();
|
||||
err.put("readErr", valueErr);
|
||||
return err;
|
||||
public boolean getFlag() {
|
||||
return this.flag;
|
||||
}
|
||||
}
|
||||
|
||||
+21
-13
@@ -3,17 +3,22 @@ package com.cf.imes.module.executor.util.fileConversion.admin.files.excel;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
public class OrderExcelUtil{
|
||||
private static String value;
|
||||
@Component
|
||||
public class OrderExcelUtil {
|
||||
private String value;
|
||||
|
||||
private ExcelListener<OrderPlateImportExcelVO> excelListener = new ExcelListener<>();
|
||||
|
||||
public List<OrderPlateImportExcelVO> read(MultipartFile file, Class<OrderPlateImportExcelVO> head) throws IOException {
|
||||
|
||||
public static <T> List<T> read(MultipartFile file, Class<T> head) throws IOException {
|
||||
ExcelListener<T> excelListener = new ExcelListener<>();
|
||||
if (file.isEmpty()) {
|
||||
value = "文件为空";
|
||||
throw new IOException("文件为空");
|
||||
@@ -31,19 +36,22 @@ public class OrderExcelUtil{
|
||||
EasyExcel.read(file.getInputStream(), head, excelListener).
|
||||
headRowNumber(7).sheet(0).doRead();
|
||||
//获取读取的数据
|
||||
List<T> list = excelListener.getDatas();
|
||||
List<OrderPlateImportExcelVO> list = excelListener.getDatas();
|
||||
|
||||
if (excelListener.getFlag())
|
||||
return list;
|
||||
value = excelListener.getValue();
|
||||
return null;
|
||||
if (excelListener.getValueMap().size() > 0)
|
||||
excelListener.getValueMap().forEach((k, v) -> {
|
||||
list.get(k - 8).setResult(v);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> Map<String, String> getValue() {
|
||||
Map<String, String> err = new HashMap<>();
|
||||
err.put("readErr", value);
|
||||
return err;
|
||||
public boolean getFlag() {
|
||||
return excelListener.getFlag();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
excelListener.getDatas().clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-20
@@ -1,4 +1,4 @@
|
||||
package com.cf.imes.module.executor.util.fileConversion.admin.files.excel.excelPoi;
|
||||
package com.cf.imes.module.executor.util.fileConversion.admin.files.excel;
|
||||
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
@@ -26,15 +26,6 @@ import java.math.BigDecimal;
|
||||
@Accessors(chain = false) // 设置 chain = false,避免生产单导入有问
|
||||
public class OrderImportVO {
|
||||
|
||||
// 行号
|
||||
private Integer rowNum;
|
||||
|
||||
// 行数据
|
||||
private String rowData;
|
||||
|
||||
// 错误提示信息
|
||||
private String rowTips;
|
||||
|
||||
@ExcelProperty(value = "序号")
|
||||
@JsonIgnore
|
||||
private int ordinal;
|
||||
@@ -42,7 +33,6 @@ public class OrderImportVO {
|
||||
@ExcelProperty(value = "类型", converter = DictConvert.class)
|
||||
@JsonIgnore
|
||||
@DictFormat(DictTypeConstants.PRODUCT_TYPE)
|
||||
@ExcelImport(value = "类型", required = true)
|
||||
private int goodType;
|
||||
|
||||
@ExcelProperty(value = "物料编码")
|
||||
@@ -102,14 +92,6 @@ public class OrderImportVO {
|
||||
@JsonIgnore
|
||||
private String plateNo;
|
||||
|
||||
@ExcelProperty(value = "成品长")
|
||||
@JsonIgnore
|
||||
private BigDecimal height;
|
||||
|
||||
@ExcelProperty(value = "成品宽")
|
||||
@JsonIgnore
|
||||
private BigDecimal width;
|
||||
|
||||
@ExcelProperty(value = "开料长")
|
||||
@JsonIgnore
|
||||
private BigDecimal splitHeight;
|
||||
@@ -204,7 +186,6 @@ public class OrderImportVO {
|
||||
private String remark;
|
||||
|
||||
|
||||
|
||||
//备注转json数据
|
||||
public String remarkJSON() {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
@@ -218,4 +199,6 @@ public class OrderImportVO {
|
||||
}
|
||||
}
|
||||
|
||||
// 判断非空
|
||||
// 判断数据合理
|
||||
}
|
||||
+15
-34
@@ -12,10 +12,6 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
@@ -76,7 +72,7 @@ public class OrderPlateImportExcelVO {
|
||||
@ExcelProperty(value = "数量")
|
||||
@JsonIgnore
|
||||
@NotNull
|
||||
private Double goodsNumber;
|
||||
private float goodsNumber;
|
||||
|
||||
@ExcelProperty(value = "房间")
|
||||
@JsonIgnore
|
||||
@@ -94,41 +90,33 @@ public class OrderPlateImportExcelVO {
|
||||
@JsonIgnore
|
||||
private String plateNo;
|
||||
|
||||
@ExcelProperty(value = "成品长")
|
||||
@JsonIgnore
|
||||
private BigDecimal height;
|
||||
|
||||
@ExcelProperty(value = "成品宽")
|
||||
@JsonIgnore
|
||||
private BigDecimal width;
|
||||
|
||||
@ExcelProperty(value = "开料长")
|
||||
@JsonIgnore
|
||||
private BigDecimal splitHeight;
|
||||
private float splitHeight;
|
||||
|
||||
@ExcelProperty(value = "开料宽")
|
||||
@JsonIgnore
|
||||
private BigDecimal splitWidth;
|
||||
private float splitWidth;
|
||||
|
||||
@ExcelProperty(value = "厚")
|
||||
@JsonIgnore
|
||||
private BigDecimal splitThickness;
|
||||
private float splitThickness;
|
||||
|
||||
@ExcelProperty(value = "左封边")
|
||||
@JsonIgnore
|
||||
private BigDecimal sealLeft;
|
||||
private float sealLeft;
|
||||
|
||||
@ExcelProperty(value = "右封边")
|
||||
@JsonIgnore
|
||||
private BigDecimal sealRight;
|
||||
private float sealRight;
|
||||
|
||||
@ExcelProperty(value = "上封边")
|
||||
@JsonIgnore
|
||||
private BigDecimal sealUp;
|
||||
private float sealUp;
|
||||
|
||||
@ExcelProperty(value = "下封边")
|
||||
@JsonIgnore
|
||||
private BigDecimal sealDown;
|
||||
private float sealDown;
|
||||
|
||||
@ExcelProperty(value = "组合类型", converter = DictConvert.class)
|
||||
@JsonIgnore
|
||||
@@ -197,20 +185,17 @@ public class OrderPlateImportExcelVO {
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isValidParts() {
|
||||
return (isNonEmpty(goodsId) || isNonEmpty(goodsName)) && (goodsNumber != null && goodsNumber > 0) && (isNonEmpty(model) || isNonEmpty(spec));
|
||||
public boolean isValidGoods() {
|
||||
return (isNonEmpty(goodsId) ||
|
||||
((isNonEmpty(goodsName)) && (isNonEmpty(model) || isNonEmpty(spec)) && isNonEmpty(material) && isNonEmpty(color) && isNonEmpty(unit)))
|
||||
&& goodsNumber > 0;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isValidRawGoods() {
|
||||
return (isNonEmpty(goodsId) || isNonEmpty(goodsName) || isNonEmpty(material) || isNonEmpty(color) || isNonEmpty(spec)) &&
|
||||
(goodsNumber != null && goodsNumber > 0) &&
|
||||
((height != null && height.compareTo(BigDecimal.ZERO) > 0 && width != null && width.compareTo(BigDecimal.ZERO) > 0) ||
|
||||
(splitHeight != null && splitHeight.compareTo(BigDecimal.ZERO) > 0 && splitWidth != null && splitWidth.compareTo(BigDecimal.ZERO) > 0)) &&
|
||||
sealLeft != null && sealLeft.compareTo(BigDecimal.ZERO) > 0 &&
|
||||
sealRight != null && sealRight.compareTo(BigDecimal.ZERO) > 0 &&
|
||||
sealUp != null && sealUp.compareTo(BigDecimal.ZERO) > 0 &&
|
||||
sealDown != null && sealDown.compareTo(BigDecimal.ZERO) > 0;
|
||||
return goodsNumber > 0 &&
|
||||
splitHeight > 0 && splitWidth > 0 &&
|
||||
sealLeft >= 0 && sealRight >= 0 && sealUp >= 0 && sealDown >= 0;
|
||||
}
|
||||
|
||||
private boolean isNonEmpty(String value) {
|
||||
@@ -229,9 +214,5 @@ public class OrderPlateImportExcelVO {
|
||||
return "{}";
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean isVail(){
|
||||
return (isValidParts() && isValidRawGoods());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-78
@@ -1,78 +0,0 @@
|
||||
package com.cf.imes.module.executor.util.fileConversion.admin.files.excel.excelPoi;
|
||||
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* @author sunnyzyq
|
||||
* @date 2021/12/17
|
||||
*/
|
||||
public class ExcelClassField {
|
||||
|
||||
/** 字段名称 */
|
||||
private String fieldName;
|
||||
|
||||
/** 表头名称 */
|
||||
private String name;
|
||||
|
||||
/** 映射关系 */
|
||||
private LinkedHashMap<String, String> kvMap;
|
||||
|
||||
/** 示例值 */
|
||||
private Object example;
|
||||
|
||||
/** 排序 */
|
||||
private int sort;
|
||||
|
||||
/** 是否为注解字段:0-否,1-是 */
|
||||
private int hasAnnotation;
|
||||
|
||||
public String getFieldName() {
|
||||
return fieldName;
|
||||
}
|
||||
|
||||
public void setFieldName(String fieldName) {
|
||||
this.fieldName = fieldName;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public LinkedHashMap<String, String> getKvMap() {
|
||||
return kvMap;
|
||||
}
|
||||
|
||||
public void setKvMap(LinkedHashMap<String, String> kvMap) {
|
||||
this.kvMap = kvMap;
|
||||
}
|
||||
|
||||
public Object getExample() {
|
||||
return example;
|
||||
}
|
||||
|
||||
public void setExample(Object example) {
|
||||
this.example = example;
|
||||
}
|
||||
|
||||
public int getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public void setSort(int sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public int getHasAnnotation() {
|
||||
return hasAnnotation;
|
||||
}
|
||||
|
||||
public void setHasAnnotation(int hasAnnotation) {
|
||||
this.hasAnnotation = hasAnnotation;
|
||||
}
|
||||
|
||||
}
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
package com.cf.imes.module.executor.util.fileConversion.admin.files.excel.excelPoi;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* @author sunnyzyq
|
||||
* @date 2021/12/17
|
||||
*/
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ExcelExport {
|
||||
|
||||
/** 字段名称 */
|
||||
String value();
|
||||
|
||||
/** 导出排序先后: 数字越小越靠前(默认按Java类字段顺序导出) */
|
||||
int sort() default 0;
|
||||
|
||||
/** 导出映射,格式如:0-未知;1-男;2-女 */
|
||||
String kv() default "";
|
||||
|
||||
/** 导出模板示例值(有值的话,直接取该值,不做映射) */
|
||||
String example() default "";
|
||||
|
||||
}
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
package com.cf.imes.module.executor.util.fileConversion.admin.files.excel.excelPoi;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* @author sunnyzyq
|
||||
* @date 2021/12/17
|
||||
*/
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ExcelImport {
|
||||
|
||||
/** 字段名称 */
|
||||
String value();
|
||||
|
||||
/** 导出映射,格式如:0-未知;1-男;2-女 */
|
||||
String kv() default "";
|
||||
|
||||
/** 是否为必填字段(默认为非必填) */
|
||||
boolean required() default false;
|
||||
|
||||
/** 最大长度(默认255) */
|
||||
int maxLength() default 255;
|
||||
|
||||
/** 导入唯一性验证(多个字段则取联合验证) */
|
||||
boolean unique() default false;
|
||||
|
||||
}
|
||||
-1005
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user